From patchwork Thu May 18 09:29:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 100070 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp629121qge; Thu, 18 May 2017 02:30:22 -0700 (PDT) X-Received: by 10.84.215.15 with SMTP id k15mr3655044pli.104.1495099822299; Thu, 18 May 2017 02:30:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495099822; cv=none; d=google.com; s=arc-20160816; b=h8ItPKYQUwJNuVyFwtCieAKOqpr3dQINsQ3QjEk+sp0soVLIEntUwTAhAM3zH1DYze 1gvainOleGku35VJImVfq5bWcQtOGyntM6y0CcXovHNjlHBIN90vyxVtn7qH3AK5ONwK pfTci1Ye5xQiA+XCfk8xFdoZeh4fE6VQMBPRfwKy4tDAaAKHo8ctFdK5yPJxklJRqiRY 5UIjG6jBorS/AE1IKxaG1PAtl3slqAncc2xBQwjja2jVxpr8VhpsjRny+W6wf80X4mKF IvoH84McsXzWorQvkkzTVdY25W+lcpaN+BNwt9ImCbYz32a4PHBcdDXZ037v66FoVIZc IVSw== 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=ldH0EG8RhovDyQb13BGwLKWx4tDXSwVrZB2seHddAy0=; b=Z27UE4ABKMLy6reHOBth7ZIj06e66B14LbC0Vlx+bMwDK3SZyKHPR7/0NDQIHiOJzb xr+F/DCJJMr6W9WVHqVJPAgPdJiDqyZ6MQz+GFDYJswtIfRPBICJdwoLGRq8/umIjqCs UXoXri4+dwDrRyIxSyYB82wM0CU9DLeSALKBCQ6b1oslQcktIojs3sah1ABaO2vvbCzZ rjnlve7pjs93X54BcYCZuoG6j+43btfYBXcjB23owHkSVzy66iuggm11lmz1O/n2ICQR QDzLhxX/FSSVIYn5Yo+vwag7Zn5S2Fem2JR5SQ8Hy09udbVqSduC8U6ZQ8feVnWvgGfm xbpA== 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 33si4553082plk.96.2017.05.18.02.30.22; Thu, 18 May 2017 02:30:22 -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 S1755188AbdERJaV (ORCPT + 6 others); Thu, 18 May 2017 05:30:21 -0400 Received: from mail-wr0-f177.google.com ([209.85.128.177]:33713 "EHLO mail-wr0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755158AbdERJaU (ORCPT ); Thu, 18 May 2017 05:30:20 -0400 Received: by mail-wr0-f177.google.com with SMTP id w50so29184539wrc.0 for ; Thu, 18 May 2017 02:30:19 -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=kc0kJnDTHe3yqRVoOtCy+1DK2r5Mgt3aJsgeV8GakYA=; b=JscGuDs5ZhibB5i0YhdCJ2ieOnGCAvM4m2ZU/Y9/gkrB3o5ab52/jP1RhGuhdevoWy D0lKh/qcvG1vvtKW+JTV5zXVIGS/QnmKDFSYZc8Kowr9vBbf0nHO7JBxdN7lsvxdVzmt 2QW3yqp8TmRq748f7uInf3BPG15KFnMvJsnG0= 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=kc0kJnDTHe3yqRVoOtCy+1DK2r5Mgt3aJsgeV8GakYA=; b=CtfgzOzp/Ju6iv7sCx88+1vAocNq0R+KxeeOdGlr5yDxcACOtwnV5Mgv9F5tF9Y9f5 YHQ9bZ0do2O6HuxnwXzXMriJRPp0ilqPg8kLyOLH4SzkpGMNtFrPaqUxqbjlWsBjGAcU KDbmM2fHFf1OZtkJh3UT0ZPVZeR8VYZQC17B0R5Ua/mMQ8ZuehybAzWbcxIIkqId64mI o2eQVm5tu2iHuJaEITB8QO8g0O41s2RgavOIZwPjhzlR3Oe7/hdAxNlN7R+6Ad/p4qN4 N5rU8XYhIqfXsgftusSd7uIl/hBI3bwgHPoIV7ZOF2Ptyy3fWAUTWBAeX6NO0BUjVWF3 G1wg== X-Gm-Message-State: AODbwcCGs8PRbUtQkyGif+AvQXbkwBQ7I01CH2p65XSKRrD/+a8hT/OM lPWgGVX/auDOSOM9 X-Received: by 10.46.76.25 with SMTP id z25mr82593lja.1.1495099813831; Thu, 18 May 2017 02:30:13 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u24sm829895ljd.34.2017.05.18.02.30.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 02:30:11 -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 , Linus Walleij Subject: [PATCH 5/6 v2] mmc: block: move multi-ioctl() to use block layer Date: Thu, 18 May 2017 11:29:35 +0200 Message-Id: <20170518092936.9277-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518092936.9277-1-linus.walleij@linaro.org> References: <20170518092936.9277-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 switches also the multiple-command ioctl() call to issue all ioctl()s through the block layer instead of going directly to the device. We extend the passed argument with an argument count and loop over all passed commands in the ioctl() issue function called from the block layer. By doing this we are again loosening the grip on the big host lock, since two calls to mmc_get_card()/mmc_put_card() are removed. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - - Update to the API change for req_to_mmc_queue_req() --- drivers/mmc/core/block.c | 38 +++++++++++++++++++++++++------------- drivers/mmc/core/queue.h | 3 ++- 2 files changed, 27 insertions(+), 14 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 9fb2bd529156..e9737987956f 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -563,6 +563,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, struct mmc_ioc_cmd __user *ic_ptr) { struct mmc_blk_ioc_data *idata; + struct mmc_blk_ioc_data *idatas[1]; struct mmc_blk_data *md; struct mmc_queue *mq; struct mmc_card *card; @@ -600,7 +601,9 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, req = blk_get_request(mq->queue, idata->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, __GFP_RECLAIM); - req_to_mmc_queue_req(req)->idata = idata; + idatas[0] = idata; + 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; err = mmc_blk_ioctl_copy_to_user(ic_ptr, idata); @@ -622,14 +625,17 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, static void mmc_blk_ioctl_cmd_issue(struct mmc_queue *mq, struct request *req) { struct mmc_queue_req *mq_rq; - struct mmc_blk_ioc_data *idata; 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); - idata = mq_rq->idata; - ioc_err = __mmc_blk_ioctl_cmd(card, md, idata); + 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 */ @@ -646,8 +652,10 @@ static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev, struct mmc_ioc_cmd __user *cmds = user->cmds; struct mmc_card *card; struct mmc_blk_data *md; + struct mmc_queue *mq; int i, err = 0, ioc_err = 0; __u64 num_of_cmds; + struct request *req; /* * The caller must have CAP_SYS_RAWIO, and must be calling this on the @@ -689,21 +697,25 @@ static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev, goto cmd_done; } - mmc_get_card(card); - - for (i = 0; i < num_of_cmds && !ioc_err; i++) - ioc_err = __mmc_blk_ioctl_cmd(card, md, idata[i]); - - /* 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)); - mmc_put_card(card); + /* + * Dispatch the ioctl()s into the block request queue. + */ + mq = &md->queue; + 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)->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; /* copy to user if data and response */ for (i = 0; i < num_of_cmds && !err; i++) err = mmc_blk_ioctl_copy_to_user(&cmds[i], idata[i]); + blk_put_request(req); + cmd_done: mmc_blk_put(md); cmd_err: diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index 005ece9ac7cb..8c76e7118c95 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -42,7 +42,8 @@ struct mmc_queue_req { unsigned int bounce_sg_len; struct mmc_async_req areq; int ioc_result; - struct mmc_blk_ioc_data *idata; + struct mmc_blk_ioc_data **idata; + unsigned int ioc_count; }; struct mmc_queue {