From patchwork Fri May 19 13:37:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100196 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp319285qge; Fri, 19 May 2017 06:38:09 -0700 (PDT) X-Received: by 10.98.34.22 with SMTP id i22mr10800598pfi.103.1495201089151; Fri, 19 May 2017 06:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495201089; cv=none; d=google.com; s=arc-20160816; b=D96tEBNvJaWK+Z2SsltMWFn6jrfxw1tAENrGXLDFopNzOJboPdYe+JiHXXif//M0xh x7JFkkWluVzaGruEazU4mXvr4WuZxl6G2kSMF+jXwFpCdKCMttEv1q8dywQ6ahRJ5GPy esbZH7nbLFgmGDgQHuXwaMBFPQTbWW2oVpNLBUNY1YTWgVCAAH14EWwzGqAb6Dd1gzc9 Kxu7UP0Y0EwTT/+YTKtXXSM7JALTpzZ5Z/6Oq9bWkREJFj8B2xBaCamcHrCR5KD3CTfy AE0zcG+Na4Md7ixS68jnBVlWamVK9ZVoUwUe1tgY/lbw7zRU7uwAIymDPIf5YiVl7XPw v7uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=fdKyXWqTKzTTCsmHyyDhl6ExHRhCsDpS+ZWBLZNRIk0=; b=prHBn2wiP+XzZAkxrTUBE29zYTqJoFnK4wR2eRc0ALzAPx2W0NZWOlcNMWRJZf6ffQ Wr08X+309g0PUm2r/LEOwz2ATdNkG2zUoZgI/D4onoDlEuiMObx+W7QIq8R0nUSLAN7M jgMYkl2X8h8lLBPxcpUHQ49mLiagOkei7n3Wbhi6gdiNqkFgbuS+lF0lz68vAzfgiYbj kO6ffigzkhkGHgfFyfinWZjjf3kAMBXVr1y+wID5tv4zCCBel2YC0dSIDrr/lJiQ5YmX +1jpgFMDpu1gLodjR5xBKMtbWlsYGW0n2UMlK5HY1GI4w1lyAMXa1OL+78spifAB9Jo0 VRaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si8689720plb.270.2017.05.19.06.38.08; Fri, 19 May 2017 06:38:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755351AbdESNiI (ORCPT + 6 others); Fri, 19 May 2017 09:38:08 -0400 Received: from mail-lf0-f48.google.com ([209.85.215.48]:33016 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755276AbdESNiH (ORCPT ); Fri, 19 May 2017 09:38:07 -0400 Received: by mail-lf0-f48.google.com with SMTP id m18so1209900lfj.0 for ; Fri, 19 May 2017 06:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7HYGC6i4N190wXUySSyE1Quct3/Jt2i5Y5ha8EaaT84=; b=am8vzsQuwRWPrOHiY59wnOaZIe8FS6nUhGpAtR4yYJTIZFSWpvqEUVcHWWq1/tf1kv Q5TNKQV10bct3LbuPs4kkoJmIMpb1HlTwuUUp0JJZ5/VBfNJ3JfL1gCXvA1zC4ZvRY88 tMF6idNMXmHQpcl+Wik+smgb2cwe/AAfVAYL8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7HYGC6i4N190wXUySSyE1Quct3/Jt2i5Y5ha8EaaT84=; b=FkD+yVALYYjuBc8juMB0GqGkd4bVYirkd5miofyzMetI9+CiXSXzNEUns5rdp7sm2/ dGO5YrbKJR46IbQm1tCaBZ1KIUJawsDjzzEK82HApSDMbVeutFWQDXIyQRW8zwT0M12m 1MVHQvU7AWyIrD1okpLy9ocSb4wmNpHoJPRmJjMHR2E+i9NJ94Pu4NWS0oQBtXLIzOn3 qNtxmQSX4AlmmcwcjbHEUjWLVoxfP8f/lQTQhE9im0Zs1XSKaF/OslwPDlub/AqmkDIV IkhacAp8N4MX6+oYCF6pv+xj33rW095OMIf4kfJZRKWpxUZtJlAnlYJOnQELMt8JFnlC G5TA== X-Gm-Message-State: AODbwcBHGEdUzTUkPXwStit5ktqeIHX0XjkLC8AvRS3r2Tqa9isa0WJn sAlvjx0CU+K+VcMXPINQNQ== X-Received: by 10.46.80.70 with SMTP id v6mr2445844ljd.6.1495201085185; Fri, 19 May 2017 06:38:05 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm1514130ljf.32.2017.05.19.06.38.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 06:38:03 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: linux-block@vger.kernel.org, Jens Axboe , Christoph Hellwig , Arnd Bergmann , Bartlomiej Zolnierkiewicz , Paolo Valente , Avri Altman , Linus Walleij Subject: [PATCH 6/6] mmc: debugfs: Move EXT CSD debugfs acces to block layer Date: Fri, 19 May 2017 15:37:32 +0200 Message-Id: <20170519133732.27470-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170519133732.27470-1-linus.walleij@linaro.org> References: <20170519133732.27470-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Just like the previous commit moving status retriveal for MMC and SD cards into the block layer (when active), this moves the retrieveal of the EXT CSD from the card from the special ext_csd file into the block stack as well. Again special care is taken to make the debugfs work even with the block layer disabled. Again this solves a starvation issue during heavy block workloads. It has been tested with and without the block layer and during heavy load from dd. Since we can't keep adding weirdo data pointers into struct mmc_queue_req this converts the struct mmc_blk_ioc_data **idata pointer to a simple void *drv_op_data that gets casted into whatever data the driver-specific command needs to pass, and then I cast it to the right target type in the sending and receiving functions. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 30 +++++++++++++++++++++++++++--- drivers/mmc/core/block.h | 12 ++++++++++++ drivers/mmc/core/debugfs.c | 4 +--- drivers/mmc/core/queue.h | 4 +++- 4 files changed, 43 insertions(+), 7 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 8858798d1349..5be7f06d4ecd 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -599,7 +599,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, __GFP_RECLAIM); idatas[0] = idata; req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_IOCTL; - req_to_mmc_queue_req(req)->idata = idatas; + req_to_mmc_queue_req(req)->drv_op_data = idatas; req_to_mmc_queue_req(req)->ioc_count = 1; blk_execute_rq(mq->queue, NULL, req, 0); ioc_err = req_to_mmc_queue_req(req)->drv_op_result; @@ -675,7 +675,7 @@ static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev, idata[0]->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, __GFP_RECLAIM); req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_IOCTL; - req_to_mmc_queue_req(req)->idata = idata; + req_to_mmc_queue_req(req)->drv_op_data = idata; req_to_mmc_queue_req(req)->ioc_count = num_of_cmds; blk_execute_rq(mq->queue, NULL, req, 0); ioc_err = req_to_mmc_queue_req(req)->drv_op_result; @@ -1191,6 +1191,8 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) struct mmc_queue_req *mq_rq; struct mmc_card *card = mq->card; struct mmc_blk_data *md = mq->blkdata; + struct mmc_blk_ioc_data **idata; + u8 **ext_csd; u32 status; int ret; int i; @@ -1199,8 +1201,9 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) switch (mq_rq->drv_op) { case MMC_DRV_OP_IOCTL: + idata = mq_rq->drv_op_data; for (i = 0; i < mq_rq->ioc_count; i++) { - ret = __mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]); + ret = __mmc_blk_ioctl_cmd(card, md, idata[i]); if (ret) break; } @@ -1225,6 +1228,10 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) if (!ret) ret = status; break; + case MMC_DRV_OP_GET_EXT_CSD: + ext_csd = mq_rq->drv_op_data; + ret = mmc_get_ext_csd(card, ext_csd); + break; default: pr_err("%s: unknown driver specific operation\n", md->disk->disk_name); @@ -1996,6 +2003,23 @@ int mmc_blk_card_status_get(struct mmc_card *card, u64 *val) } EXPORT_SYMBOL(mmc_blk_card_status_get); + +/* Called from debugfs for MMC cards */ +int mmc_blk_get_ext_csd(struct mmc_card *card, u8 **ext_csd) +{ + struct mmc_blk_data *md = dev_get_drvdata(&card->dev); + struct mmc_queue *mq = &md->queue; + struct request *req; + + /* Ask the block layer about the EXT CSD */ + req = blk_get_request(mq->queue, REQ_OP_DRV_IN, __GFP_RECLAIM); + req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_EXT_CSD; + req_to_mmc_queue_req(req)->drv_op_data = ext_csd; + blk_execute_rq(mq->queue, NULL, req, 0); + return req_to_mmc_queue_req(req)->drv_op_result; +} +EXPORT_SYMBOL(mmc_blk_get_ext_csd); + static inline int mmc_blk_readonly(struct mmc_card *card) { return mmc_card_readonly(card) || diff --git a/drivers/mmc/core/block.h b/drivers/mmc/core/block.h index 1e26755a864b..c85c3b71dcad 100644 --- a/drivers/mmc/core/block.h +++ b/drivers/mmc/core/block.h @@ -12,6 +12,7 @@ struct request; void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req); int mmc_blk_card_status_get(struct mmc_card *card, u64 *val); +int mmc_blk_get_ext_csd(struct mmc_card *card, u8 **ext_csd); #else @@ -41,6 +42,17 @@ static inline int mmc_blk_card_status_get(struct mmc_card *card, u64 *val) return ret; } +static inline int mmc_blk_get_ext_csd(struct mmc_card *card, u8 **ext_csd) +{ + int ret; + + mmc_get_card(card); + ret = mmc_get_ext_csd(card, ext_csd); + mmc_put_card(card); + + return ret; +} + #endif /* IS_ENABLED(CONFIG_MMC_BLOCK) */ #endif diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index ce5b921c7d96..85e058120e3b 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -303,9 +303,7 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp) if (!buf) return -ENOMEM; - mmc_get_card(card); - err = mmc_get_ext_csd(card, &ext_csd); - mmc_put_card(card); + err = mmc_blk_get_ext_csd(card, &ext_csd); if (err) goto out_free; diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index 2b39717453a5..2f67856661da 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -37,11 +37,13 @@ struct mmc_blk_request { * @MMC_DRV_OP_IOCTL: ioctl operation * @MMC_DRV_OP_BOOT_WP: write protect boot partitions * @MMC_DRV_OP_GET_CARD_STATUS: get card status + * @MMC_DRV_OP_GET_EXT_CSD: get extended card descriptor */ enum mmc_drv_op { MMC_DRV_OP_IOCTL, MMC_DRV_OP_BOOT_WP, MMC_DRV_OP_GET_CARD_STATUS, + MMC_DRV_OP_GET_EXT_CSD, }; struct mmc_queue_req { @@ -53,7 +55,7 @@ struct mmc_queue_req { struct mmc_async_req areq; enum mmc_drv_op drv_op; int drv_op_result; - struct mmc_blk_ioc_data **idata; + void *drv_op_data; unsigned int ioc_count; };