From patchwork Thu Jun 8 08:54:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9774231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D56F60350 for ; Thu, 8 Jun 2017 08:54:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AB2828536 for ; Thu, 8 Jun 2017 08:54:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F6AB28548; Thu, 8 Jun 2017 08:54:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C256D28536 for ; Thu, 8 Jun 2017 08:54:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751853AbdFHIy0 (ORCPT ); Thu, 8 Jun 2017 04:54:26 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:36011 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751850AbdFHIyZ (ORCPT ); Thu, 8 Jun 2017 04:54:25 -0400 Received: by mail-lf0-f54.google.com with SMTP id o83so15231116lff.3 for ; Thu, 08 Jun 2017 01:54:24 -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=6QyEnpEnEq1W9gMyCdLTYe4pPL6lj86W+bS013pGWYQ=; b=QMfHTUH1mAmeWP0SX8ugnjO55GzaMxAeDTFJHmqUXI6AGpwGojUzfg9T2Rz7fiJujl SxuOLUpOmmt6kvKfrht4Q/GBGcyhEmZR6g5f2xThp3ro7TzCvqax8cJnVyXj6e0RPliP q+19jaUk6gHEfU6MqdmrFzY3VGmdTB4QFJxmQ= 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=6QyEnpEnEq1W9gMyCdLTYe4pPL6lj86W+bS013pGWYQ=; b=h5fxMuggzrnwxeqiiZmgSo6rHys0b82ITn9wlYuFdvdmIEQpxPoH0K1BlbYjRgLRGH 6c/5FSAUm1IdB0m14usDru+swLHDDG+hAy/XJ8wpv1OhTyMFUANrC65GpLK67zERGnN7 71z5UuI1DINngZi+hkietScuUXO83vnKY7np2cNMyXgjYPMXs2OKNuI7RsdwwoFXQ6Jf e3Kcvo3Po3dvhAvuXnF3CahZL3HVWHvpRwn85BPLmhnkjs1OSuUjnhVmfToGEQQn/jNs LC8J8a5xJCK8TL9xENzWN8UFE3SxTs0qrQdogUNNew6d/JLnL2ZtfTxMI+jqQ22aVTbi IbcQ== X-Gm-Message-State: AODbwcCdTtUlY7EERJ2DYMCi7dU310JAXLIRH1668AgtksOYHmGXAf1d Rt/q7Wx0Fv9zZqn2cZ4twQ== X-Received: by 10.46.82.79 with SMTP id g76mr6227789ljb.32.1496912063450; Thu, 08 Jun 2017 01:54:23 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n71sm878356lje.14.2017.06.08.01.54.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 01:54:22 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: Linus Walleij Subject: [PATCH 4/6 v3] mmc: debugfs: Move card status retrieveal into the block layer Date: Thu, 8 Jun 2017 10:54:01 +0200 Message-Id: <20170608085403.11795-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170608085403.11795-1-linus.walleij@linaro.org> References: <20170608085403.11795-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This debugfs entry suffers from all the same starvation issues as the other userspace things, under e.g. a heavy dd operation. It is therefore logical to move this over to the block layer when it is enabled, using the new custom requests and issue it using the block request queue. This makes this debugfs card access land under the request queue host lock instead of orthogonally taking the lock. Tested during heavy dd load by cat:in the status file. Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - No changes just resending --- drivers/mmc/core/block.c | 28 ++++++++++++++++++++++++++++ drivers/mmc/core/block.h | 1 + drivers/mmc/core/debugfs.c | 15 ++------------- drivers/mmc/core/queue.h | 2 ++ 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 7a365d7641b5..96fe0640c480 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1176,6 +1176,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) struct mmc_card *card = mq->card; struct mmc_blk_data *md = mq->blkdata; struct mmc_blk_ioc_data **idata; + u32 status; int ret; int i; @@ -1205,6 +1206,11 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) card->ext_csd.boot_ro_lock |= EXT_CSD_BOOT_WP_B_PWR_WP_EN; break; + case MMC_DRV_OP_GET_CARD_STATUS: + ret = mmc_send_status(card, &status); + if (!ret) + ret = status; + break; default: pr_err("%s: unknown driver specific operation\n", md->disk->disk_name); @@ -1954,6 +1960,28 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) mmc_put_card(card); } +/* Called from debugfs for MMC/SD cards */ +int mmc_blk_card_status_get(struct mmc_card *card, u64 *val) +{ + struct mmc_blk_data *md = dev_get_drvdata(&card->dev); + struct mmc_queue *mq = &md->queue; + struct request *req; + int ret; + + /* Ask the block layer about the card status */ + req = blk_get_request(mq->queue, REQ_OP_DRV_IN, __GFP_RECLAIM); + req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_CARD_STATUS; + blk_execute_rq(mq->queue, NULL, req, 0); + ret = req_to_mmc_queue_req(req)->drv_op_result; + if (ret >= 0) { + *val = ret; + ret = 0; + } + + return ret; +} +EXPORT_SYMBOL(mmc_blk_card_status_get); + 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 860ca7c8df86..70861f3a059a 100644 --- a/drivers/mmc/core/block.h +++ b/drivers/mmc/core/block.h @@ -5,5 +5,6 @@ struct mmc_queue; 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); #endif diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index b176932b8092..dca5717c437b 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -22,6 +22,7 @@ #include "core.h" #include "card.h" #include "host.h" +#include "block.h" #include "mmc_ops.h" #ifdef CONFIG_FAIL_MMC_REQUEST @@ -285,19 +286,7 @@ void mmc_remove_host_debugfs(struct mmc_host *host) static int mmc_dbg_card_status_get(void *data, u64 *val) { - struct mmc_card *card = data; - u32 status; - int ret; - - mmc_get_card(card); - - ret = mmc_send_status(data, &status); - if (!ret) - *val = status; - - mmc_put_card(card); - - return ret; + return mmc_blk_card_status_get(data, val); } DEFINE_SIMPLE_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get, NULL, "%08llx\n"); diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index cf26a15a64bf..c2325c6659f5 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -36,10 +36,12 @@ struct mmc_blk_request { * enum mmc_drv_op - enumerates the operations in the mmc_queue_req * @MMC_DRV_OP_IOCTL: ioctl operation * @MMC_DRV_OP_BOOT_WP: write protect boot partitions + * @MMC_DRV_OP_GET_CARD_STATUS: get card status */ enum mmc_drv_op { MMC_DRV_OP_IOCTL, MMC_DRV_OP_BOOT_WP, + MMC_DRV_OP_GET_CARD_STATUS, }; struct mmc_queue_req {