From patchwork Fri May 19 13:37:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100191 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp319163qge; Fri, 19 May 2017 06:37:51 -0700 (PDT) X-Received: by 10.98.34.22 with SMTP id i22mr10799133pfi.103.1495201071034; Fri, 19 May 2017 06:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495201071; cv=none; d=google.com; s=arc-20160816; b=tJLVIzbKyRR09luLbIICKjMKE5JxiEOtbjtW8mtGKMbwbi0z+HH8B3S9RPC4lezXa9 9A5o/R0YXPN7xIETi+ME2NiJxf4/RlVjcEe8Nchimw4R9bkRJAx6oNDM+dMU7asCXhra 0nuugFCIfwLl7WUcvoRzaCHc0Vcn5Ci/IFM/wViJF3gpZPwbpoZwQx63NUERmf7DDgww zQbEr3J/AAIx1Y6b8lfJgAlyxUBsrKgk0qam3K8gPimALkkgjvFo73cdfpuDMVoB43yt mSYJB1R6ZsYwR7QiiWZtkA/5j2KzMnCfKSF98tJNcEbjDCJ6L4X373t8fGun4b+YeJDy HDUg== 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=nMO5UxG1e5O0/yH90jzbJmGILxpN0vvonhg6VVWJ5uc=; b=sLa2h8GCbYydFzqAOx8a16gbRSmJGTp5fwXMrOxIsg23oIL61wClsp0yZAa9v58sZV qKQvmiHUOz+QL1KXgcsgiahNvjgnYRLuQKoaBEGo7QF+vC0Qp1ChJXDFKI3m3YeYowv6 2tXLkl3CDBITQh9R5prEQk9gkbwHyHwQHBobGBN9IMpD1nAFI/IQAj2hveEpC4pqmgXE 4zwSWvBhswnh2N3kkZl5qaZlKFasIsvES1GKjIvtS2zRvuqqx1gKKGkEvcj6Biw1wx/z cEyqozNFURiG2ZKbSh2HM2pOjKN2ATseJXXfLGM+c6QukleTZ66jftqi5GYmLbVFbFms LNag== 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.37.50; Fri, 19 May 2017 06:37:51 -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 S1752997AbdESNht (ORCPT + 6 others); Fri, 19 May 2017 09:37:49 -0400 Received: from mail-lf0-f44.google.com ([209.85.215.44]:36474 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752338AbdESNhs (ORCPT ); Fri, 19 May 2017 09:37:48 -0400 Received: by mail-lf0-f44.google.com with SMTP id h4so1206976lfj.3 for ; Fri, 19 May 2017 06:37:47 -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=0ZBVtWtNwaiqPI+Dv653nKDEQ8TOX7Oh4OhnYWzcsnk=; b=VwYMuQpLEYQyujRbV7jbBZzkwK0IiVpBq0JY2rJNtWL3dE6TlHyeX4Z7ABEck9l6V4 VRVfDYtcBbE3JCkm+1gOOWboPQFzTN9+3PL2baLmR97Sw8PASX955K5dHU6aKPJP5GaI 1tEguIwfE0pEsB/mz5VIEz6VqkxO59alOhmAQ= 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=0ZBVtWtNwaiqPI+Dv653nKDEQ8TOX7Oh4OhnYWzcsnk=; b=Qg93f/zLBNIBzXgY0W6eiOc97pP4ARsyF0q+3tEZT3nZ/+P1Vx3WVcCZBpAxqHHrTs df3VVGYc+meVM7jw6fTPRvtZRweXWjij1f3NIPdhS/hLCVWAWZoNeKVzxt4lGE5p6vcX BnaYFqOTSL7MFZvcB+j62tNyfPsvPy/t3PYGUyOZsOH/hY6hKFwvGvp6P2Hvv/uM7Cbd CDJ/6Izf644IX7Om8ua4vgqaT9d1otRqK7Czcg/E0S271kstA09DIJNg9iDiA/SbyN6E c9wKHgSktmYItDrYE0PfTrgnV8mapnv4RQQUFbdQDPYYJ3bkmiNTzn8KnNrCtGqMzPeB WC5w== X-Gm-Message-State: AODbwcA/LekWpHF6U0mBMgD70Na4uuE+uEuQtKWJpLsZ+BU48n28O3Ny 8JxicJkimfgw0Buv X-Received: by 10.25.202.27 with SMTP id a27mr2218272lfg.70.1495201066739; Fri, 19 May 2017 06:37:46 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm1514130ljf.32.2017.05.19.06.37.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 06:37:45 -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 1/6] mmc: block: remove req back pointer Date: Fri, 19 May 2017 15:37:27 +0200 Message-Id: <20170519133732.27470-2-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 as we can use blk_mq_rq_from_pdu() to get the per-request tag we can use blk_mq_rq_to_pdu() to get a request from a tag. Introduce a static inline helper so we are on the clear what is happening. Suggested-by: Christoph Hellwig Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 8 ++++---- drivers/mmc/core/queue.c | 13 +++++-------- drivers/mmc/core/queue.h | 8 +++++++- 3 files changed, 16 insertions(+), 13 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 e9737987956f..553ab4d1db94 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1366,7 +1366,7 @@ static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card, struct mmc_queue_req *mq_mrq = container_of(areq, struct mmc_queue_req, areq); struct mmc_blk_request *brq = &mq_mrq->brq; - struct request *req = mq_mrq->req; + struct request *req = mmc_queue_req_to_req(mq_mrq); int need_retune = card->host->need_retune; bool ecc_err = false; bool gen_err = false; @@ -1473,7 +1473,7 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, struct mmc_blk_data *md = mq->blkdata; struct mmc_card *card = md->queue.card; struct mmc_blk_request *brq = &mqrq->brq; - struct request *req = mqrq->req; + struct request *req = mmc_queue_req_to_req(mqrq); /* * Reliable writes are used to implement Forced Unit Access and @@ -1578,7 +1578,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, { u32 readcmd, writecmd; struct mmc_blk_request *brq = &mqrq->brq; - struct request *req = mqrq->req; + struct request *req = mmc_queue_req_to_req(mqrq); struct mmc_blk_data *md = mq->blkdata; bool do_rel_wr, do_data_tag; @@ -1760,7 +1760,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) */ mq_rq = container_of(old_areq, struct mmc_queue_req, areq); brq = &mq_rq->brq; - old_req = mq_rq->req; + old_req = mmc_queue_req_to_req(mq_rq); type = rq_data_dir(old_req) == READ ? MMC_BLK_READ : MMC_BLK_WRITE; mmc_queue_bounce_post(mq_rq); diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index c18c41289ecf..4bf9978b707a 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -184,8 +184,6 @@ static int mmc_init_request(struct request_queue *q, struct request *req, struct mmc_card *card = mq->card; struct mmc_host *host = card->host; - mq_rq->req = req; - if (card->bouncesz) { mq_rq->bounce_buf = kmalloc(card->bouncesz, gfp); if (!mq_rq->bounce_buf) @@ -223,8 +221,6 @@ static void mmc_exit_request(struct request_queue *q, struct request *req) kfree(mq_rq->sg); mq_rq->sg = NULL; - - mq_rq->req = NULL; } /** @@ -374,12 +370,13 @@ unsigned int mmc_queue_map_sg(struct mmc_queue *mq, struct mmc_queue_req *mqrq) unsigned int sg_len; size_t buflen; struct scatterlist *sg; + struct request *req = mmc_queue_req_to_req(mqrq); int i; if (!mqrq->bounce_buf) - return blk_rq_map_sg(mq->queue, mqrq->req, mqrq->sg); + return blk_rq_map_sg(mq->queue, req, mqrq->sg); - sg_len = blk_rq_map_sg(mq->queue, mqrq->req, mqrq->bounce_sg); + sg_len = blk_rq_map_sg(mq->queue, req, mqrq->bounce_sg); mqrq->bounce_sg_len = sg_len; @@ -401,7 +398,7 @@ void mmc_queue_bounce_pre(struct mmc_queue_req *mqrq) if (!mqrq->bounce_buf) return; - if (rq_data_dir(mqrq->req) != WRITE) + if (rq_data_dir(mmc_queue_req_to_req(mqrq)) != WRITE) return; sg_copy_to_buffer(mqrq->bounce_sg, mqrq->bounce_sg_len, @@ -417,7 +414,7 @@ void mmc_queue_bounce_post(struct mmc_queue_req *mqrq) if (!mqrq->bounce_buf) return; - if (rq_data_dir(mqrq->req) != READ) + if (rq_data_dir(mmc_queue_req_to_req(mqrq)) != READ) return; sg_copy_from_buffer(mqrq->bounce_sg, mqrq->bounce_sg_len, diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index dfe481a8b5ed..2793020a3c8c 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -12,6 +12,13 @@ static inline struct mmc_queue_req *req_to_mmc_queue_req(struct request *rq) return blk_mq_rq_to_pdu(rq); } +struct mmc_queue_req; + +static inline struct request *mmc_queue_req_to_req(struct mmc_queue_req *mqr) +{ + return blk_mq_rq_from_pdu(mqr); +} + struct task_struct; struct mmc_blk_data; struct mmc_blk_ioc_data; @@ -26,7 +33,6 @@ struct mmc_blk_request { }; struct mmc_queue_req { - struct request *req; struct mmc_blk_request brq; struct scatterlist *sg; char *bounce_buf; From patchwork Fri May 19 13:37:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100192 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp319194qge; Fri, 19 May 2017 06:37:55 -0700 (PDT) X-Received: by 10.84.138.193 with SMTP id 59mr11734458plp.184.1495201075318; Fri, 19 May 2017 06:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495201075; cv=none; d=google.com; s=arc-20160816; b=K7ASGSCSY3F8Oty+CXt3inDU/b3nksktM5r0U3bLbUOWSYzFDB+UrnH/uAmRuJLp8s bH6RzD3UOV3YpqAzDNl/Zvbcpx6Cp08ce2QsGXhBr0V6l/hdKcpY4H/JuzZ7Dg9ONlVa mO9gOOcLB2pny+Vu4WqDhTHFxP9oAawLJoJTglbJXNu8vMN4Pn3dQKDcsQZffIwdlWgi JYg7f20XwXGp6DCM8+5Z8s0uuX/vX/L4cOmFE/UTGNGLSdy9XWfjAlF4z/dPbpJP8PYd D1akx3cvvsdwR5xeXD/TYoqR6/GWLIji4aFRKvMi/gjUodyCzAOUiqy43k0bxAi0iBnv toyQ== 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=L1XhwrAydLK+XeQREjGL6+uYAnF20xxBD2mRWxXy+VQ=; b=GQyRrwSkFeaZHRtU223EN91eA63FVSGgXoDxMvHGQ2pWzwVkrcNfnO7aWe28facnoS SAEkvK/uL6Zlcm77KisDsUBvOETZRVY4Vn0+CKUgtj70Orl5JwzQAEWzEcvimDRkg5v7 wT0gZ3plZL4coHLiParQJ/LxVn0+3ncawhL8AxBsRzQvKXb6MpIy9s54f7f3Ax6XOvVD tDtTtT+rNhS0h/rmrUw1bh8a1T8MYczi2q6g7AdVDTR/Fj5JpzriS3xE4uMKAQr7pZdT 0WxDhHzlagcTtt5KXQakp/gBm5yyWRCEImeBPpfruXVemXAdCK6e2Uk3NftYU+GFHR8a hhyg== 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.37.55; Fri, 19 May 2017 06:37:55 -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 S1754853AbdESNhy (ORCPT + 6 others); Fri, 19 May 2017 09:37:54 -0400 Received: from mail-lf0-f48.google.com ([209.85.215.48]:35471 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754825AbdESNhw (ORCPT ); Fri, 19 May 2017 09:37:52 -0400 Received: by mail-lf0-f48.google.com with SMTP id y126so1149059lfc.2 for ; Fri, 19 May 2017 06:37:51 -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=NTJPXbvanHXXpyCKjRIa+kiTutlDZ9dTTt5vB9grCU0=; b=Q6IqN/oAasiZvDuHSS+njr62PSpDrYSO+kCbkUd9fiHcup+0G16XTZjw6Q6Tcre4Au +l8b7a6iy0ZtgUm6ZTOAZGpvM/6LIZva6OgmJ7MUzhMh5tRVT4+9xOL5E+20aEKoRvb2 Y7HETFJUA5TjzjNmMPrhf3TSpbC1eTAKFRgkw= 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=NTJPXbvanHXXpyCKjRIa+kiTutlDZ9dTTt5vB9grCU0=; b=Tfz5yorOMmB0fsX5/wCFnQKAWxXlCmY97Uu5hlmY5mlTQsapY4kjrRIqdjTojZ/Y53 1JaaFrWU/XY4+D5B6ZN3x8Di2tRApqfOECcWNkr/5YMvsDnJXNlce53I0wvhsRimowxc hQIik6IU+3kubg9piKYBhhs8Q77gLxQgXynABcG7nF2ugkZl5ydZ6b3E6l8g3IaofZgy K9fkDScOb5M04cJaALXGPc8nyhthEyVwIgjK0anUbT6dfytKWtASoOnAfs/Ka+fAaIRm 7Vh/o3nRRHQBk8BNAAJujfLKj5s7AmH+IfwLBdAGH9WV+fu7U9Ha24siVr5AgjR/6Cro fhjQ== X-Gm-Message-State: AODbwcCd2ZummNTYk3qyKFxmQm3pFtlamiyh5NRrG/+q7yEn4dO/6GuR WqsMqxK/RewK7LqY X-Received: by 10.25.38.15 with SMTP id m15mr2393633lfm.32.1495201071059; Fri, 19 May 2017 06:37:51 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm1514130ljf.32.2017.05.19.06.37.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 06:37:49 -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 2/6] mmc: block: Tag DRV_OPs with a driver operation type Date: Fri, 19 May 2017 15:37:28 +0200 Message-Id: <20170519133732.27470-3-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 We will expand the DRV_OP usage, so we need to know which operation we're performing. Tag the operations with an enum:ed type and rename the function so it is clear that it deals with any command and put a switch statement in it. Currently only ioctls are supported. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 37 ++++++++++++++++++++++++------------- drivers/mmc/core/queue.h | 9 +++++++++ 2 files changed, 33 insertions(+), 13 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 553ab4d1db94..b24e7f5171c9 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -602,6 +602,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, idata->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, __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)->ioc_count = 1; blk_execute_rq(mq->queue, NULL, req, 0); @@ -618,11 +619,11 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, } /* - * The ioctl commands come back from the block layer after it queued it and + * The non-block commands come back from the block layer after it queued it and * processed it with all other requests and then they get issued in this * function. */ -static void mmc_blk_ioctl_cmd_issue(struct mmc_queue *mq, struct request *req) +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; @@ -631,18 +632,27 @@ static void mmc_blk_ioctl_cmd_issue(struct mmc_queue *mq, struct request *req) int i; mq_rq = req_to_mmc_queue_req(req); - for (i = 0; i < mq_rq->ioc_count; i++) { - ioc_err = __mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]); - if (ioc_err) - break; - } - mq_rq->ioc_result = ioc_err; - /* Always switch back to main area after RPMB access */ - if (md->area_type & MMC_BLK_DATA_AREA_RPMB) - mmc_blk_part_switch(card, dev_get_drvdata(&card->dev)); + switch (mq_rq->drv_op) { + case MMC_DRV_OP_IOCTL: + for (i = 0; i < mq_rq->ioc_count; i++) { + ioc_err = + __mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]); + if (ioc_err) + break; + } + mq_rq->ioc_result = ioc_err; + + /* Always switch back to main area after RPMB access */ + if (md->area_type & MMC_BLK_DATA_AREA_RPMB) + mmc_blk_part_switch(card, dev_get_drvdata(&card->dev)); - blk_end_request_all(req, ioc_err); + blk_end_request_all(req, ioc_err); + break; + default: + /* Unknown operation */ + break; + } } static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev, @@ -705,6 +715,7 @@ static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev, req = blk_get_request(mq->queue, 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)->ioc_count = num_of_cmds; blk_execute_rq(mq->queue, NULL, req, 0); @@ -1904,7 +1915,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) */ if (mq->qcnt) mmc_blk_issue_rw_rq(mq, NULL); - mmc_blk_ioctl_cmd_issue(mq, req); + mmc_blk_issue_drv_op(mq, req); break; case REQ_OP_DISCARD: /* diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index 2793020a3c8c..1e6062eb3e07 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -32,6 +32,14 @@ struct mmc_blk_request { int retune_retry_done; }; +/** + * enum mmc_drv_op - enumerates the operations in the mmc_queue_req + * @MMC_DRV_OP_IOCTL: ioctl operation + */ +enum mmc_drv_op { + MMC_DRV_OP_IOCTL, +}; + struct mmc_queue_req { struct mmc_blk_request brq; struct scatterlist *sg; @@ -39,6 +47,7 @@ struct mmc_queue_req { struct scatterlist *bounce_sg; unsigned int bounce_sg_len; struct mmc_async_req areq; + enum mmc_drv_op drv_op; int ioc_result; struct mmc_blk_ioc_data **idata; unsigned int ioc_count; From patchwork Fri May 19 13:37:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100193 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp319226qge; Fri, 19 May 2017 06:37:59 -0700 (PDT) X-Received: by 10.99.139.195 with SMTP id j186mr10555919pge.134.1495201079349; Fri, 19 May 2017 06:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495201079; cv=none; d=google.com; s=arc-20160816; b=H7FWtpmECWdUueSaRKQwaDWJ0qJPZ3CXgVJTfF+5gSsXWm9YB5p0hWCPo4vAW+2+cp VTvPKzhHlnz3BrXpDUEfDOaKFhQkZcl59NxMbUB32LPBvfh/GGIqg9PXh92FUgBlulBL /ItEGPZlmmq8bwl6UG0on+tgq5maxqnN5vtuxHLChgAiZxVb8PWEM+2rjvOHIjRjfOFZ fkkwkSOEUOiJbOX1qYDCP1LYZm34TJSA9E7OA5SER3UNCM5xXpGQzsu0OgwqQmJTsmcn Ky1cs2ZmrN7154T73EmMqbP4AZ5hwYaRBHEoXv4hZrCadh/Lz2g3kW9jdAPty+fC69c1 vKKg== 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=tbq41NNC2zqTRrwr00UhhAgyFdquJOayeviPoiHfXK0=; b=KPEGg++ze4/uVkl4uv+v0lH6ey9jU1S2X/DlB0x7poRGv06cLhgBxUS8jT7kN3K79F 3pV3D5XE8zyvfhMoyiz+v+fPIQNAX66VtMTL9T+dtqdVgttg2/1lXr04e6+lgmyIYtu0 1HAokRFkCvYUnq3A4hN0JWWdymq4Z/Rqp3EPQ9Hxm25OWoZNjjdvDU/Lo3uoTX01VxkR ZD9eqpy1jeQmyIciTyLQC1xHWyWOhbS3p8HcWHuY+FXneQV+N0BOEIxOzix0QNdDwPQ+ uglg+99p/jO9qcKhmseyVcfFQ3vq2S2iWJ3l6Ujeo5dF4raWUfr3/5NVzcqZ3F6MkRqt Aucg== 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.37.59; Fri, 19 May 2017 06:37:59 -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 S1755001AbdESNh6 (ORCPT + 6 others); Fri, 19 May 2017 09:37:58 -0400 Received: from mail-lf0-f44.google.com ([209.85.215.44]:34485 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752868AbdESNh5 (ORCPT ); Fri, 19 May 2017 09:37:57 -0400 Received: by mail-lf0-f44.google.com with SMTP id 99so1211839lfu.1 for ; Fri, 19 May 2017 06:37:56 -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=/38oOOCKu8MPEpX7e+J5NkGE0zIn39Y/5Ajb9TiwfGw=; b=Eruiibd0pNjjNfktX4goVsua3LGMJJh89n6pmDd1jiV5UYqowGTx8SUxXAAOjscO8T +TKaAERl/qJX74TW6wSNTCDkSph1a7J5UEqmgHTNF3QMy2GqfJn9cFUg2+23UOjQogus D5ULQLds1P+F1xVX4s/jqJnTHH1RI5qgGVc4o= 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=/38oOOCKu8MPEpX7e+J5NkGE0zIn39Y/5Ajb9TiwfGw=; b=oP0H1E2JbTaqjgc8c2Nnp/lMGqMhXZBsUQdlh2S0n0rXMk8nawpxj2/mc0e1PprIJX P7kAdPF0g8qTiGo1WAyDxlDcD0bfd1L1PDcJu3ChVOH7Jg3D3I7waZoV1DL+fVegn+M6 eTtSKP46i/qozEIJCvhycxPpA4xd3Wm5zz5RoC5P6tsZnxxchk5gs8O5KM6SIpLr+T25 q8NDOf1Z24ldBgy6lJNsdX24VKgxQq3HqNgHAG8kj3tjg/H2t3NyIj6f3anTAQ7UKUEM ejcDcfvlq/2xNnlw4+3KieJznUGelJ6kcYJMDrP3AH/sgq3YNFYB95IMTR4vYNE4JFHk BtTQ== X-Gm-Message-State: AODbwcCP2Fa8L4G9p/kGxZuehF/kcq8Es8kC/teYZvyMZH6RKtXf6+IW gAJ2LLRb2kuCVjDl X-Received: by 10.25.221.198 with SMTP id w67mr2434284lfi.114.1495201075592; Fri, 19 May 2017 06:37:55 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm1514130ljf.32.2017.05.19.06.37.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 06:37:54 -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 3/6] mmc: block: Move DRV OP issue function Date: Fri, 19 May 2017 15:37:29 +0200 Message-Id: <20170519133732.27470-4-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 We will need to access static functions above the pure block layer operations in the file, so move the driver operations issue function down so we can see all non-blocklayer symbols. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 74 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 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 b24e7f5171c9..75b1baacf28b 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -618,43 +618,6 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, return ioc_err ? ioc_err : err; } -/* - * The non-block commands come back from the block layer after it queued it and - * processed it with all other requests and then they get issued in this - * function. - */ -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; - int ioc_err; - int i; - - mq_rq = req_to_mmc_queue_req(req); - - switch (mq_rq->drv_op) { - case MMC_DRV_OP_IOCTL: - for (i = 0; i < mq_rq->ioc_count; i++) { - ioc_err = - __mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]); - if (ioc_err) - break; - } - mq_rq->ioc_result = ioc_err; - - /* Always switch back to main area after RPMB access */ - if (md->area_type & MMC_BLK_DATA_AREA_RPMB) - mmc_blk_part_switch(card, dev_get_drvdata(&card->dev)); - - blk_end_request_all(req, ioc_err); - break; - default: - /* Unknown operation */ - break; - } -} - static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev, struct mmc_ioc_multi_cmd __user *user) { @@ -1222,6 +1185,43 @@ int mmc_access_rpmb(struct mmc_queue *mq) return false; } +/* + * The non-block commands come back from the block layer after it queued it and + * processed it with all other requests and then they get issued in this + * function. + */ +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; + int ioc_err; + int i; + + mq_rq = req_to_mmc_queue_req(req); + + switch (mq_rq->drv_op) { + case MMC_DRV_OP_IOCTL: + for (i = 0; i < mq_rq->ioc_count; i++) { + ioc_err = + __mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]); + if (ioc_err) + break; + } + mq_rq->ioc_result = ioc_err; + + /* Always switch back to main area after RPMB access */ + if (md->area_type & MMC_BLK_DATA_AREA_RPMB) + mmc_blk_part_switch(card, dev_get_drvdata(&card->dev)); + + blk_end_request_all(req, ioc_err); + break; + default: + /* Unknown operation */ + break; + } +} + static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) { struct mmc_blk_data *md = mq->blkdata; From patchwork Fri May 19 13:37:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100194 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp319254qge; Fri, 19 May 2017 06:38:03 -0700 (PDT) X-Received: by 10.84.213.143 with SMTP id g15mr11705458pli.53.1495201083683; Fri, 19 May 2017 06:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495201083; cv=none; d=google.com; s=arc-20160816; b=MGezjEBTdkzNVizuSIPGFH3rnK7C8NHchQ9MIaeMmTKAeIIErBLsPfKySmH99a9XMo rQeW+sEEA1h5al9z22TzQRaNS/RlMoACjtwlDrjVDtXgMbCDUKxWktAi24VBi0wUbvsx 8pCwyBthCtJHOjoh+pDyBkaLv0jXJjSo/9nmo33xj9gQWCK+m8dkfTbgL+N2t4ZKhKte 2SsHPEykUtbVX3ZG4KYz0g8TxejmJP0IktPq8Z+6OGhB3ZmIJ89F25qYTeYor24xmsjT rhshIvlwhS5OXxu6DC6AjwBVibGqzesCbKQ6PgffwloU4RMrh8XgdAgAlY7ve6JgoxX+ FD6w== 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=SEMeS5fzPrOI0slc9Sc1bELk7o6yp4DzYA88frx1TQs=; b=R3y27ePkDtKxiKlxalfUo4Ui4HhxxoTr1lYqU8ffPbgI6Y5rYIcTJtnw+q7X/fE0dl i4RGvoF9WlYfPTQG5i2rEpL7p2gyTq9xZMHqCUdDiKMccduHCZzHs5/nrxTWMdC7RrCY rniyN0MP7nOwEA1OgsT+ivAITVcpGtlZyHMftmc8N+HlXpJdACsMFcN2hgwom+sVZ2Je LJrzrTkUjwNxPFKtolli9xz38b30+SUU9rwsOiWGw0eXwv6273Q8SrZJhvNEMDHfEOlm xbEp4Xkan50J21Ovkzqm9L4jHoUyiu5bqhfYmLHBKe3D04novN6Iax84EpV3C9Dc9M0L zCDQ== 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.03; Fri, 19 May 2017 06:38:03 -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 S1754825AbdESNiC (ORCPT + 6 others); Fri, 19 May 2017 09:38:02 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:35526 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751406AbdESNiB (ORCPT ); Fri, 19 May 2017 09:38:01 -0400 Received: by mail-lf0-f41.google.com with SMTP id y126so1151435lfc.2 for ; Fri, 19 May 2017 06:38:00 -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=orImYDu1V2LCCACrRI/UDIodhkBB7DwM/urezQ0MwFA=; b=GzoCNwERs/dkNoQdRNkFn3OobK/IWEynsfR06vCxWtWpMn7amlVFX5Z2kDnj/NS3Dq HvmC+zv+1Y+DtBpkPct2OUQfVKTHHa7x0HOTpz68m1G47Dt9X0CTCtwplZFiI5pLGR/B MRZ+Ml76jeZiGXgXAnlNdhncNSuNpB2xazQ4o= 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=orImYDu1V2LCCACrRI/UDIodhkBB7DwM/urezQ0MwFA=; b=ApgYYytDDA0I2b4TSdfxRPto7aSGT7kdrtlR+7zE7RfXCTpJrGHoL+2PDeLLghwF3A 8ygjqu/IgnSRq9L13q6fUrQsSRhg3CoILWlo5Hf42LIiB92wPQaXXTRDZAgYSJJvX2zW iSHhB54uNxYA1s+UNKiK520Fx/VkIWWJpgXPa3bHk2S1s+jPkORQCoPqZrrXjA85ZQYJ EdJCTl3jkSVlkRFze1aCWoZGmf/J6GHikaE8Kxp2mraJO52A8LBJpPMr99T+6LRrr027 hb8UFOkaYCeKZ5oYC7itMK1lyFLnY9x8HEa0HEaZLg8GRJMvzPY/GXluPjrXK6gXTY+w YUFw== X-Gm-Message-State: AODbwcCzAqP+NFIYXCb6TvvPMmNHi6pzxrIXNAYeRFcSTxjEAI2ZcfhP p59du+mUh26lm2JZ X-Received: by 10.25.181.80 with SMTP id e77mr2089324lff.98.1495201079707; Fri, 19 May 2017 06:37:59 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm1514130ljf.32.2017.05.19.06.37.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 06:37:58 -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 4/6] mmc: block: Move boot partition locking into a driver op Date: Fri, 19 May 2017 15:37:30 +0200 Message-Id: <20170519133732.27470-5-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 This moves the boot partition lock command (issued from sysfs) into a custom block layer request, just like the ioctl()s, getting rid of yet another instance of mmc_get_card(). Since we now have two operations issuing special DRV_OP's, we rename the result variable ->drv_op_result. Tested by locking the boot partition from userspace: > cd /sys/devices/platform/soc/80114000.sdi4_per2/mmc_host/mmc3/ mmc3:0001/block/mmcblk3/mmcblk3boot0 > echo 1 > ro_lock_until_next_power_on [ 178.645324] mmcblk3boot1: Locking boot partition ro until next power on [ 178.652221] mmcblk3boot0: Locking boot partition ro until next power on Also tested this with a huge dd job in the background: it is now possible to lock the boot partitions on the card even under heavy I/O. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 53 +++++++++++++++++++++++++++--------------------- drivers/mmc/core/queue.h | 4 +++- 2 files changed, 33 insertions(+), 24 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 75b1baacf28b..52635120a0a5 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -190,6 +190,8 @@ static ssize_t power_ro_lock_store(struct device *dev, int ret; struct mmc_blk_data *md, *part_md; struct mmc_card *card; + struct mmc_queue *mq; + struct request *req; unsigned long set; if (kstrtoul(buf, 0, &set)) @@ -199,20 +201,14 @@ static ssize_t power_ro_lock_store(struct device *dev, return count; md = mmc_blk_get(dev_to_disk(dev)); + mq = &md->queue; card = md->queue.card; - mmc_get_card(card); - - ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP, - card->ext_csd.boot_ro_lock | - EXT_CSD_BOOT_WP_B_PWR_WP_EN, - card->ext_csd.part_time); - if (ret) - pr_err("%s: Locking boot partition ro until next power on failed: %d\n", md->disk->disk_name, ret); - else - card->ext_csd.boot_ro_lock |= EXT_CSD_BOOT_WP_B_PWR_WP_EN; - - mmc_put_card(card); + /* Dispatch locking to the block layer */ + req = blk_get_request(mq->queue, REQ_OP_DRV_OUT, __GFP_RECLAIM); + req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_BOOT_WP; + blk_execute_rq(mq->queue, NULL, req, 0); + ret = req_to_mmc_queue_req(req)->drv_op_result; if (!ret) { pr_info("%s: Locking boot partition ro until next power on\n", @@ -606,7 +602,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, req_to_mmc_queue_req(req)->idata = 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)->ioc_result; + ioc_err = req_to_mmc_queue_req(req)->drv_op_result; err = mmc_blk_ioctl_copy_to_user(ic_ptr, idata); blk_put_request(req); @@ -682,7 +678,7 @@ static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev, req_to_mmc_queue_req(req)->idata = 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)->ioc_result; + ioc_err = req_to_mmc_queue_req(req)->drv_op_result; /* copy to user if data and response */ for (i = 0; i < num_of_cmds && !err; i++) @@ -1195,7 +1191,7 @@ 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; - int ioc_err; + int ret; int i; mq_rq = req_to_mmc_queue_req(req); @@ -1203,23 +1199,34 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) switch (mq_rq->drv_op) { case MMC_DRV_OP_IOCTL: for (i = 0; i < mq_rq->ioc_count; i++) { - ioc_err = - __mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]); - if (ioc_err) + ret = __mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]); + if (ret) break; } - mq_rq->ioc_result = ioc_err; - /* Always switch back to main area after RPMB access */ if (md->area_type & MMC_BLK_DATA_AREA_RPMB) mmc_blk_part_switch(card, dev_get_drvdata(&card->dev)); - - blk_end_request_all(req, ioc_err); + break; + case MMC_DRV_OP_BOOT_WP: + ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP, + card->ext_csd.boot_ro_lock | + EXT_CSD_BOOT_WP_B_PWR_WP_EN, + card->ext_csd.part_time); + if (ret) + pr_err("%s: Locking boot partition ro until next power on failed: %d\n", + md->disk->disk_name, ret); + else + card->ext_csd.boot_ro_lock |= + EXT_CSD_BOOT_WP_B_PWR_WP_EN; break; default: - /* Unknown operation */ + pr_err("%s: unknown driver specific operation\n", + md->disk->disk_name); + ret = -EINVAL; break; } + mq_rq->drv_op_result = ret; + blk_end_request_all(req, ret); } static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index 1e6062eb3e07..361b46408e0f 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -35,9 +35,11 @@ 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 */ enum mmc_drv_op { MMC_DRV_OP_IOCTL, + MMC_DRV_OP_BOOT_WP, }; struct mmc_queue_req { @@ -48,7 +50,7 @@ struct mmc_queue_req { unsigned int bounce_sg_len; struct mmc_async_req areq; enum mmc_drv_op drv_op; - int ioc_result; + int drv_op_result; struct mmc_blk_ioc_data **idata; unsigned int ioc_count; }; From patchwork Fri May 19 13:37:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100195 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp319269qge; Fri, 19 May 2017 06:38:06 -0700 (PDT) X-Received: by 10.98.34.22 with SMTP id i22mr10800381pfi.103.1495201086481; Fri, 19 May 2017 06:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495201086; cv=none; d=google.com; s=arc-20160816; b=sdIRmn290xFfa4gCn5oRWAgjoMj2UCIrN+Rem7Q3Mk0tKJ5EIZF7+Wwg/TMnXTtuqY UTUfkuX+rw63y4a7FOEP0LDmD9NvmQvgLUIXv0QeGXcoUTiLkfUCyslthJ5jiYKjc1zR ALi66yFcEzUv9UXJf7X41mzGJMjlJ+uISAyeXYM3nPBdIIKcj4MXm+/wYTaewR9zlmza 30Mjm1OB+l+57lLWQHTL3FX1q/49v22y4IWrvvr/Qc1rCOtiV+exrxGGlSP/CHMH1sKl 9WrGz1/bSpX/zyNF+Nq58tVAnbZWmsNhWirzaZeoHeuGvwMiJ3H5i2ajO9CgMKoh6W/2 wDsw== 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=i4DvHYo9Ajx4kXSYhAzSvGA/pefR8XwnP0iruElyMLQ=; b=0qFizd3hZgQt+idICewmv2kNedcuOuSox68z4zhOp9ypKwK46p9vFU4Nj+7YJ2hKHi LNrgvOhbN9ot/hvaHGvYMkrv92nU12LVq4WpTlSrfOMApENtzlmusdyr8cSZ1OnY0yMh tXfb3pRbPF59zJY1DwcsXBAKzypDwLKw7qWI3rl88dAJXThjeTkefhayTVCGtjWKyFnq Ul3eEzWPPOkZmX95AkTDSNF2WOFbodi7q5Jh2HA/3zWpwz2EQ6IH8zTw7esjcDoX8YNi HF9zbHA6YX6qcsDO91ZBtr16cZZTp3sn7GqQscBLdgHlMqgbkbr0yZrcBJbtzIB/uOi5 ANBQ== 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.06; Fri, 19 May 2017 06:38:06 -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 S1755321AbdESNiF (ORCPT + 6 others); Fri, 19 May 2017 09:38:05 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:36565 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755276AbdESNiE (ORCPT ); Fri, 19 May 2017 09:38:04 -0400 Received: by mail-lf0-f43.google.com with SMTP id h4so1210801lfj.3 for ; Fri, 19 May 2017 06:38:03 -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=fmEucGws7S1v0M3gh8izDsrTv5jnZLx7diAoviYtzBw=; b=WemFlcU+GU8g6z5jFApdOQmNlgBEnADgczf0FjwmoU67Rfke87TTsvbl23ZCNzUkDg TUrJSOtzqYK/0E87kflCBzs5qSq4KV7Jns2eLbSu0pSGxXoSvp++Txh9jPr+T76+OtTV D7TRTBODJ3vlrsx4W4koawSeVMqQET0IcBJIU= 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=fmEucGws7S1v0M3gh8izDsrTv5jnZLx7diAoviYtzBw=; b=qKdZBV5ALiRMliwziTThSK/Wt96qKlKppdtKU9RQAc9XeiVMlrL7KZGYBeZ7x6ZYU5 DJllgKyAedd8S1hpliRhaaLMdMEyjapP0P3oLG9CezahIE5BDvClAR/TTHtEpg58XYoB Vbkg8uq/mLrjvyWQqgjdJ9B79qqdax5NOdwSbwkj0TX19d7grRKFOeBW5rY/gZcKNTmU pHgFILk4vCt2yDz3RihgrRDed/53WWIVrJ+xVsRSRRRC3G6WJfoYbEm7u+KyT8qlbPQs t9fmnMDoTXh6cUaTF+kK4xv2CB8ej9a6nzctSYsB8/4yJ8WkaNtpyqUQfnX2sdZaAhV5 FN2w== X-Gm-Message-State: AODbwcDhdVhjw2NlzU6eNTumGUqfAFliJsjcoH+se+2EyOb4nXuZ4Ai2 Nf5XlmrYg+vD2jzk X-Received: by 10.25.40.81 with SMTP id o78mr2119915lfo.157.1495201082377; Fri, 19 May 2017 06:38:02 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 06:38:01 -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 5/6] mmc: debugfs: Move card status retrieveal into the block layer Date: Fri, 19 May 2017 15:37:31 +0200 Message-Id: <20170519133732.27470-6-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 The debugfs file "status" (in e.g. /debug/mmc3/mmc3:0001) is only available if and only if the card used is an (e)MMC or SD card, not for SDIO, as can be seen from this guard in mmc_add_card_debugfs(); if (mmc_card_mmc(card) || mmc_card_sd(card)) (...create debugfs "status" entry...) Further 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. We add IS_ENABLED() guards and keep the code snippet just issueing the card status as a static inline in the header so we can still have card status working when the block layer is compiled out. Keeping two copies of mmc_dbg_card_status_get() around seems to be a necessary evil to be able to have the MMC/SD stack working with the block layer disabled: under these circumstances, the code must simply take another path. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 28 ++++++++++++++++++++++++++++ drivers/mmc/core/block.h | 37 +++++++++++++++++++++++++++++++++++++ drivers/mmc/core/debugfs.c | 15 ++------------- drivers/mmc/core/queue.h | 2 ++ 4 files changed, 69 insertions(+), 13 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 52635120a0a5..8858798d1349 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1191,6 +1191,7 @@ 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; + u32 status; int ret; int i; @@ -1219,6 +1220,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); @@ -1968,6 +1974,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..1e26755a864b 100644 --- a/drivers/mmc/core/block.h +++ b/drivers/mmc/core/block.h @@ -1,9 +1,46 @@ #ifndef _MMC_CORE_BLOCK_H #define _MMC_CORE_BLOCK_H +#include +#include "core.h" +#include "mmc_ops.h" + struct mmc_queue; struct request; +#if IS_ENABLED(CONFIG_MMC_BLOCK) + void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req); +int mmc_blk_card_status_get(struct mmc_card *card, u64 *val); + +#else + +/* + * Small stub functions to be used when the block layer is not + * enabled, e.g. for pure SDIO without MMC/SD configurations. + */ + +static inline void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) +{ + return; +} + +static inline int mmc_blk_card_status_get(struct mmc_card *card, u64 *val) +{ + u32 status; + int ret; + + mmc_get_card(card); + + ret = mmc_send_status(card, &status); + if (!ret) + *val = status; + + 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 a1fba5732d66..ce5b921c7d96 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -19,6 +19,7 @@ #include #include +#include "block.h" #include "core.h" #include "card.h" #include "host.h" @@ -283,19 +284,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 361b46408e0f..2b39717453a5 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 { 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; };