From patchwork Mon Jun 5 12:15:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 101387 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp881641qgd; Mon, 5 Jun 2017 05:16:13 -0700 (PDT) X-Received: by 10.84.224.6 with SMTP id r6mr14595318plj.132.1496664973527; Mon, 05 Jun 2017 05:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496664973; cv=none; d=google.com; s=arc-20160816; b=Cel2XYc1I6MoqIAUIlOLi956puoF7K0d7Oc8AIzU/krAjQyB7WT4axVysOt2tTsFKw ShktZ9SIiKALBB7Af50NWuoY1bAtXWTMxKDYezWyawgguyRpweYH/XC13iZnlJHEcOzU 1s5qpYoMnkpCVVyvxPse6LGKPWSMa7sApe0CUSIEBkvD7mOtQlghrYHOVS/IPQoyh4r/ awuY4Tlz/o4b1Fw/3jXELOZRfgnp18LRBnK5opFBcpPErbkyh5TCxdJuoyBCs2/DNxqE HlWcgmVbP3PdKiXdpNuubmXcsKV8DJ+Jt/BvmwmgQ1kCnzliftEnT2viyxZoDg8siHCU n5PA== 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=7K0k7y8x5M5URg+auI4/JfMPSOhvuo6NOQvnIPFrpfQ=; b=P+3wEGaCro+TrL/SAVGpWBU8ZD+hptOMJvCkGm5ATJukKh62nGQpTzlzWmYlRhZuEv 2PiHe9FSsXFPjz+W9P0vKCK0Hj1mKc3307UoVyg/aTyOWcq2EJr3WBxCcw7fuG7a47Ih 5ytKm2DJQ++WEsvXW4KGSp+E/G+RyR7qV36dmtbsULvgySWx9auEpefJj5oI8j7LlHEZ t7YaWCeSowKPCu7iKAkwB8kk0EdyUNJbxFoukShleFEc2t08K7ZgoC7gUycoibvPd2on M1xsBth+YriaPSwaLPdkARpGaAJ1aRCVgGNWNKRuA4cL1Mzw3LxrTwGFkaEmhz8fvdyH 2HAw== 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 z20si30643154pfi.56.2017.06.05.05.16.13; Mon, 05 Jun 2017 05:16:13 -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 S1751747AbdFEMPm (ORCPT + 6 others); Mon, 5 Jun 2017 08:15:42 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:34296 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751389AbdFEMPl (ORCPT ); Mon, 5 Jun 2017 08:15:41 -0400 Received: by mail-lf0-f43.google.com with SMTP id v20so37884533lfa.1 for ; Mon, 05 Jun 2017 05:15:40 -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=D2YlTZ6WwF+PscMlU6EYXEI2/RFKCtW+ZPM0HhX7hbo=; b=hnS8UjxL6T0hpieBsSUXR4vljozCAKNHa5OpX3j17dWB6h3BZR6Fq9h3USAfvgbASw RUZlf5cXXj8XxETLe5AnFnD+3g4EgIKB514BXCzXZlZe3MwZ/0cjLRmZqHyKpCu6pSEh /zaTXmgflwa8jU8tlpVoypgS1Cr5DT+DeUccE= 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=D2YlTZ6WwF+PscMlU6EYXEI2/RFKCtW+ZPM0HhX7hbo=; b=ZV1/RCpO2uD8N9WjR9pOQZKt9y/3noDzuXcG/OF1KxUqr/HBsO9t7mUAha0+oX2Nq/ aZVfUqnSt6Ap4ZQj/478juviw3ICfgFGp/ivPXkUZm9a8HCb3wzsCZY0JKnEPPgZucRa m8R5+a7+0SoVn8He63IICInhw2hILikFZ1ptaHU958B5EAobDOxDTGe3lNed1c0cYFJD cAv4cf/IRkXiM2++d0tBawdavAIp7nDkHbLhVrHBn5T9kwMXidAJLwASidbvY/Z1YtFt mHmhOgkm1AwlTuJH1C0Xv22avGaDeW8BqqDRVkowVnPxQ1shDuRLRh/hHNefmdKI5UXA YTEA== X-Gm-Message-State: AODbwcB48Yj/eXYwCeM3JP+q4zB9WbZplMNlHrYF62mw0omsRqpX4Kds bHkYK+x0Xp/VSLvhuA80dQ== X-Received: by 10.46.84.92 with SMTP id y28mr1450185ljd.78.1496664939178; Mon, 05 Jun 2017 05:15:39 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id z10sm6797124lja.24.2017.06.05.05.15.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Jun 2017 05:15:38 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: Linus Walleij Subject: [PATCH 3/4 v2] mmc: debugfs: Move card status retrieveal into the block layer Date: Mon, 5 Jun 2017 14:15:21 +0200 Message-Id: <20170605121522.27678-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170605121522.27678-1-linus.walleij@linaro.org> References: <20170605121522.27678-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 v1->v2: - Rebased on the new series, add no stubs. --- 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(-) -- 2.9.4 -- 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 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 {