From patchwork Mon Jun 5 12:15:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9766099 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 3339660353 for ; Mon, 5 Jun 2017 12:15:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EA1227E63 for ; Mon, 5 Jun 2017 12:15:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2050A27F8F; Mon, 5 Jun 2017 12:15:57 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 55E3827E63 for ; Mon, 5 Jun 2017 12:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751812AbdFEMPq (ORCPT ); Mon, 5 Jun 2017 08:15:46 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:33559 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbdFEMPn (ORCPT ); Mon, 5 Jun 2017 08:15:43 -0400 Received: by mail-lf0-f54.google.com with SMTP id a136so55611308lfa.0 for ; Mon, 05 Jun 2017 05:15:42 -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=LW4sig/G0bsQch826MBUHTSO8GfmgDy/zCvOrGdaTcU=; b=Rl6hGM6WFh7Vv3B8Pr2Z9u38NOz+yURRj1kQA/JbEAfqbnSJu4A3+JPc+6geLVCUzB Ddantb98+gHIeKCTPBTDWZ9kZWFJqcqvnocwyl/xm7Jl34q/dKrQOLBWzptp/FKlbzb8 RmFTBs10jE7wQC/M8yWy+mlzw0J+Vn8DLACh0= 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=LW4sig/G0bsQch826MBUHTSO8GfmgDy/zCvOrGdaTcU=; b=byecV76btDeoLs1QL/rmvp1m7oTDGE2y8L6HqKkbd8mV8dEgmAHTTwCjBoezZp8w8b hEvWOiGvuaTGBgPoq3nd63LwZba4kk4Eq47V7wlYNuMjzYSLlGA64XVrw+HUeqDEFlpi 0rAmfqEYTxjTHhtzrLwyeyC1LxOgMoTF8Px0XzCKiHQFllqSIUJWTuOcVL0VqxuExicd xPb52soUNPsrxN5O59kn1tRvW9tA5OZXM6/8JPv5cgeOsO6YGYpEflwM3EVt4P+p8TCR QBbmrpvNBNLIdh4F0h2E4WesCCIFWLbkroBSad5kXsbFBJS5GHNsyE10Cl4OD78OMpWx ls+g== X-Gm-Message-State: AODbwcBudLXWi2KnHwqaRqFTCvqFh08euah0OWeqFMppDunKEALWXuDJ bjlIRyFIo+0Vs/LWRVjm0A== X-Received: by 10.46.22.4 with SMTP id w4mr6010638ljd.109.1496664941746; Mon, 05 Jun 2017 05:15:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Jun 2017 05:15:40 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: Linus Walleij Subject: [PATCH 4/4] mmc: debugfs: Move EXT CSD debugfs acces to block layer Date: Mon, 5 Jun 2017 14:15:22 +0200 Message-Id: <20170605121522.27678-5-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 X-Virus-Scanned: ClamAV using ClamSMTP 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. It has been tested with and without the block layer and during heavy load from dd. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebased on the new series, add no stubs. --- drivers/mmc/core/block.c | 21 +++++++++++++++++++++ drivers/mmc/core/block.h | 1 + drivers/mmc/core/debugfs.c | 4 +--- drivers/mmc/core/queue.h | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 96fe0640c480..4708f95ebdd0 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; + u8 **ext_csd; u32 status; int ret; int i; @@ -1211,6 +1212,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); @@ -1982,6 +1987,22 @@ 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 70861f3a059a..377ebbf6a978 100644 --- a/drivers/mmc/core/block.h +++ b/drivers/mmc/core/block.h @@ -6,5 +6,6 @@ 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); #endif diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index dca5717c437b..cc1f7085111c 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -305,9 +305,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 c2325c6659f5..04fc89360a7a 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 the EXT CSD from an eMMC card */ 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 {