From patchwork Thu Jan 26 15:04: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: 92523 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp226806qgi; Thu, 26 Jan 2017 07:04:44 -0800 (PST) X-Received: by 10.84.217.216 with SMTP id d24mr4778012plj.101.1485443084188; Thu, 26 Jan 2017 07:04:44 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si1617664pfg.106.2017.01.26.07.04.43; Thu, 26 Jan 2017 07:04:44 -0800 (PST) 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 S1753097AbdAZPEm (ORCPT + 5 others); Thu, 26 Jan 2017 10:04:42 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:32819 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752864AbdAZPEl (ORCPT ); Thu, 26 Jan 2017 10:04:41 -0500 Received: by mail-lf0-f42.google.com with SMTP id x1so60232012lff.0 for ; Thu, 26 Jan 2017 07:04:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=BSi/AvN9bejboIyHezbWIsZouXf1fw6fhevaTvE/DXM=; b=I3dNJLO2GVZbM44aLziGxcMXstrrhLz9vUIAcdo1sspIs46ft5Ov6usFgEDJ8sABa8 EP8cf+EzMVJ2G2bhP3TEwGIa9jucbLK6AM1cAqM+mCmkB3uN/zmFPDgx2EnjKXh2W/BY 8myaBwpL/MPMAjpbnH7H3Ar9LwF8XOC0XwOLk= 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; bh=BSi/AvN9bejboIyHezbWIsZouXf1fw6fhevaTvE/DXM=; b=XIlfC0RHavDkOyhoef5IhDLJOe7tknlHDuYQDdfbcp7kCdvkGYKMVSOM8Jh3UN50jR B1B2GBtY332jZEUlWqRF4enM5e75spNKwzgEiN8ijvA6ePguNL1AUeooOWSuJpSYxwJC aW7myzUVrh4jF1O0j7Ag8XDQ+B+FeDZBpL1cO5RcuPotrIS1sXcgWeVC4gxv81ddMX8v kd+xjaXqpHi4OpOm0WDgjdxAuhngCxWIO5VvtyWaJXSH+dWWzauHZoE+MDrrVeUdsVeT bvJ+GMIiVkoj0pD+p48XKvPYl/s8m+ekE8aOaM/+Miltq28r7DoHki5UDpe2kRVkTqxO tdNg== X-Gm-Message-State: AIkVDXK8QlS6qN9flANvwbrQSe8X/kHpW1c7nvPrNKy2RxeLWdp67y5d6mAulAS6SL+bSn4r X-Received: by 10.25.203.87 with SMTP id b84mr1024315lfg.158.1485443080234; Thu, 26 Jan 2017 07:04:40 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s7sm540332lja.27.2017.01.26.07.04.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 07:04:38 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Paolo Valente , Linus Walleij Subject: [PATCH 1/6] mmc: block: inline the command abort and start new goto:s Date: Thu, 26 Jan 2017 16:04:28 +0100 Message-Id: <20170126150433.14038-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The goto statements sprinkled over the mmc_blk_issue_rw_rq() function has grown over the years and makes the code pretty hard to read. Inline the calls such that: goto cmd_abort; -> mmc_blk_rw_cmd_abort(card, req); mmc_blk_rw_start_new(mq, card, rqc); return; goto start_new_req; -> mmc_blk_rw_start_new(mq, card, rqc); return; After this it is more clear how we exit the do {} while loop in this function, and it gets possible to split the code apart. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 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 ede759dda395..8f91d7ddfc56 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1698,10 +1698,15 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) break; case MMC_BLK_CMD_ERR: ret = mmc_blk_cmd_err(md, card, brq, req, ret); - if (mmc_blk_reset(md, card->host, type)) - goto cmd_abort; - if (!ret) - goto start_new_req; + if (mmc_blk_reset(md, card->host, type)) { + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; + } + if (!ret) { + mmc_blk_rw_start_new(mq, card, rqc); + return; + } break; case MMC_BLK_RETRY: retune_retry_done = brq->retune_retry_done; @@ -1711,15 +1716,20 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) case MMC_BLK_ABORT: if (!mmc_blk_reset(md, card->host, type)) break; - goto cmd_abort; + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; case MMC_BLK_DATA_ERR: { int err; err = mmc_blk_reset(md, card->host, type); if (!err) break; - if (err == -ENODEV) - goto cmd_abort; + if (err == -ENODEV) { + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; + } /* Fall through */ } case MMC_BLK_ECC_ERR: @@ -1737,15 +1747,21 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) */ ret = blk_end_request(req, -EIO, brq->data.blksz); - if (!ret) - goto start_new_req; + if (!ret) { + mmc_blk_rw_start_new(mq, card, rqc); + return; + } break; case MMC_BLK_NOMEDIUM: - goto cmd_abort; + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; default: pr_err("%s: Unhandled return value (%d)", req->rq_disk->disk_name, status); - goto cmd_abort; + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; } if (ret) { @@ -1760,14 +1776,6 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) mq_rq->brq.retune_retry_done = retune_retry_done; } } while (ret); - - return; - - cmd_abort: - mmc_blk_rw_cmd_abort(card, req); - - start_new_req: - mmc_blk_rw_start_new(mq, card, rqc); } void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) From patchwork Thu Jan 26 15:04: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: 92524 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp226852qgi; Thu, 26 Jan 2017 07:04:50 -0800 (PST) X-Received: by 10.99.65.1 with SMTP id o1mr3567078pga.93.1485443090175; Thu, 26 Jan 2017 07:04:50 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si1617664pfg.106.2017.01.26.07.04.49; Thu, 26 Jan 2017 07:04:50 -0800 (PST) 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 S1753170AbdAZPEt (ORCPT + 5 others); Thu, 26 Jan 2017 10:04:49 -0500 Received: from mail-lf0-f46.google.com ([209.85.215.46]:34461 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753168AbdAZPEs (ORCPT ); Thu, 26 Jan 2017 10:04:48 -0500 Received: by mail-lf0-f46.google.com with SMTP id v186so146961061lfa.1 for ; Thu, 26 Jan 2017 07:04:47 -0800 (PST) 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=h9HwQTYeMnOLtjLVQSHqe788IhGOL2CviPhOIpJLa4I=; b=c1LJWxdUv1mr7HDwwkf/VUXsbO5brkXmmNE6HNan1kkLFrvi2vUDlYAmeoaDXkjmul GOLTgDEXQ/Q/ioRPEP/QfMykqv3b+tJDzv6DbYm87vBs161fmxbCMz6RNdjOvtySlmea 5UyuIkIHrPUZAwdxqY4qxNRasPAQJxnj/jr6A= 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=h9HwQTYeMnOLtjLVQSHqe788IhGOL2CviPhOIpJLa4I=; b=dKQvbxTOthXRsDCqq4ATDY//ICvHKeGmOkAW3/JSMY1la5tRPanqlHcj9EqSTEh4z4 J2Oj/mCgniZ63Rp+DoXAKcP/SsI11NWUvQHx0ITsU3BVMAZkR3fsoMbmPTwzuTFKB+7q u0BrHNDrsJD1Zg41yJG7pII8UmWtn60g89d8MoVrWwuCQ3VZMlYXSX1NCYTJWOdUdBQR oFuOSH2kVm7i8pMMaTpErX67Jv94boMZY8zMfIETGAlREw+7sX4AtTQOgT44OHjzleTf QRnQn8KN7odcNPDjl2lpz0e6hRYtbpoBSFV5t7WqC1D0zeqe5gKkD/dmndccSHt2vbuE XdUQ== X-Gm-Message-State: AIkVDXILdx2aqXQPg3zKlWftFXXXBgdtHFIEukAmZQ9Rg+OupTcLoKrDo+hnOvdrSpKtll+h X-Received: by 10.25.145.90 with SMTP id y26mr969439lfj.49.1485443086294; Thu, 26 Jan 2017 07:04:46 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s7sm540332lja.27.2017.01.26.07.04.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 07:04:45 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Paolo Valente , Linus Walleij Subject: [PATCH 2/6] mmc: block: rename rqc and req Date: Thu, 26 Jan 2017 16:04:29 +0100 Message-Id: <20170126150433.14038-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170126150433.14038-1-linus.walleij@linaro.org> References: <20170126150433.14038-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org In the function mmc_blk_issue_rw_rq() the new request coming in from the block layer is called "rqc" and the old request that was potentially just returned back from the asynchronous mechanism is called "req". This is really confusing when trying to analyze and understand the code, it becomes a perceptual nightmare to me. Maybe others have better parserheads but it is not working for me. Rename "rqc" to "new_req" and "req" to "old_req" to reflect what is semantically going on into the syntax. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 56 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 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 8f91d7ddfc56..aaade079603e 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1616,7 +1616,7 @@ static void mmc_blk_rw_start_new(struct mmc_queue *mq, struct mmc_card *card, } } -static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) +static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) { struct mmc_blk_data *md = mq->blkdata; struct mmc_card *card = md->queue.card; @@ -1624,24 +1624,24 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) int ret = 1, disable_multi = 0, retry = 0, type, retune_retry_done = 0; enum mmc_blk_status status; struct mmc_queue_req *mq_rq; - struct request *req; + struct request *old_req; struct mmc_async_req *new_areq; struct mmc_async_req *old_areq; - if (!rqc && !mq->mqrq_prev->req) + if (!new_req && !mq->mqrq_prev->req) return; do { - if (rqc) { + if (new_req) { /* * When 4KB native sector is enabled, only 8 blocks * multiple read or write is allowed */ if (mmc_large_sector(card) && - !IS_ALIGNED(blk_rq_sectors(rqc), 8)) { + !IS_ALIGNED(blk_rq_sectors(new_req), 8)) { pr_err("%s: Transfer size is not 4KB sector size aligned\n", - rqc->rq_disk->disk_name); - mmc_blk_rw_cmd_abort(card, rqc); + new_req->rq_disk->disk_name); + mmc_blk_rw_cmd_abort(card, new_req); return; } @@ -1668,8 +1668,8 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) */ mq_rq = container_of(old_areq, struct mmc_queue_req, mmc_active); brq = &mq_rq->brq; - req = mq_rq->req; - type = rq_data_dir(req) == READ ? MMC_BLK_READ : MMC_BLK_WRITE; + old_req = mq_rq->req; + type = rq_data_dir(old_req) == READ ? MMC_BLK_READ : MMC_BLK_WRITE; mmc_queue_bounce_post(mq_rq); switch (status) { @@ -1680,7 +1680,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) */ mmc_blk_reset_success(md, type); - ret = blk_end_request(req, 0, + ret = blk_end_request(old_req, 0, brq->data.bytes_xfered); /* @@ -1690,21 +1690,21 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) */ if (status == MMC_BLK_SUCCESS && ret) { pr_err("%s BUG rq_tot %d d_xfer %d\n", - __func__, blk_rq_bytes(req), + __func__, blk_rq_bytes(old_req), brq->data.bytes_xfered); - mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_cmd_abort(card, old_req); return; } break; case MMC_BLK_CMD_ERR: - ret = mmc_blk_cmd_err(md, card, brq, req, ret); + ret = mmc_blk_cmd_err(md, card, brq, old_req, ret); if (mmc_blk_reset(md, card->host, type)) { - mmc_blk_rw_cmd_abort(card, req); - mmc_blk_rw_start_new(mq, card, rqc); + mmc_blk_rw_cmd_abort(card, old_req); + mmc_blk_rw_start_new(mq, card, new_req); return; } if (!ret) { - mmc_blk_rw_start_new(mq, card, rqc); + mmc_blk_rw_start_new(mq, card, new_req); return; } break; @@ -1716,8 +1716,8 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) case MMC_BLK_ABORT: if (!mmc_blk_reset(md, card->host, type)) break; - mmc_blk_rw_cmd_abort(card, req); - mmc_blk_rw_start_new(mq, card, rqc); + mmc_blk_rw_cmd_abort(card, old_req); + mmc_blk_rw_start_new(mq, card, new_req); return; case MMC_BLK_DATA_ERR: { int err; @@ -1726,8 +1726,8 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) if (!err) break; if (err == -ENODEV) { - mmc_blk_rw_cmd_abort(card, req); - mmc_blk_rw_start_new(mq, card, rqc); + mmc_blk_rw_cmd_abort(card, old_req); + mmc_blk_rw_start_new(mq, card, new_req); return; } /* Fall through */ @@ -1736,7 +1736,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) if (brq->data.blocks > 1) { /* Redo read one sector at a time */ pr_warn("%s: retrying using single block read\n", - req->rq_disk->disk_name); + old_req->rq_disk->disk_name); disable_multi = 1; break; } @@ -1745,22 +1745,22 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) * time, so we only reach here after trying to * read a single sector. */ - ret = blk_end_request(req, -EIO, + ret = blk_end_request(old_req, -EIO, brq->data.blksz); if (!ret) { - mmc_blk_rw_start_new(mq, card, rqc); + mmc_blk_rw_start_new(mq, card, new_req); return; } break; case MMC_BLK_NOMEDIUM: - mmc_blk_rw_cmd_abort(card, req); - mmc_blk_rw_start_new(mq, card, rqc); + mmc_blk_rw_cmd_abort(card, old_req); + mmc_blk_rw_start_new(mq, card, new_req); return; default: pr_err("%s: Unhandled return value (%d)", - req->rq_disk->disk_name, status); - mmc_blk_rw_cmd_abort(card, req); - mmc_blk_rw_start_new(mq, card, rqc); + old_req->rq_disk->disk_name, status); + mmc_blk_rw_cmd_abort(card, old_req); + mmc_blk_rw_start_new(mq, card, new_req); return; } From patchwork Thu Jan 26 15:04: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: 92525 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp226892qgi; Thu, 26 Jan 2017 07:04:54 -0800 (PST) X-Received: by 10.99.95.151 with SMTP id t145mr3519230pgb.75.1485443094439; Thu, 26 Jan 2017 07:04:54 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si1617664pfg.106.2017.01.26.07.04.54; Thu, 26 Jan 2017 07:04:54 -0800 (PST) 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 S1753180AbdAZPEx (ORCPT + 5 others); Thu, 26 Jan 2017 10:04:53 -0500 Received: from mail-lf0-f51.google.com ([209.85.215.51]:34484 "EHLO mail-lf0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753104AbdAZPEw (ORCPT ); Thu, 26 Jan 2017 10:04:52 -0500 Received: by mail-lf0-f51.google.com with SMTP id v186so146962265lfa.1 for ; Thu, 26 Jan 2017 07:04:51 -0800 (PST) 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=KJriGxrOQeFgx8Uo1Jb6m+lamKBrHNypGaruMq2rxgw=; b=OedZt6hfnDE60xp7XbRujlCdW0ErERvlnHtdT22J6W62xdsts4af0sNTkW5EZIuNDC 9vesYqjkxz8bxxDsKnUdEe51f+Q4MMb0c0s6Ge+C/Ep2omnLNDVTR+NfiRdbC13f+YRR Ot6Y8/04SoGso4FbBNeHko/ogtfMvmA5EYeTE= 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=KJriGxrOQeFgx8Uo1Jb6m+lamKBrHNypGaruMq2rxgw=; b=RYrP8ichUozTfu3jQHSlbn9BAx6CMSeicw02UhO/htCtzH+WKXmZDUV3UBI31K9HQK NYPAQDkUaOlifQ/71f8T4ohQI9uiYuFPiIW5ES75rVDU4tPmhsrGPZ//46Wi49ftAYfz /LAqs9rWW4oxItX7m/YBZf7yMTBujU9ICpxHST9JZh7XQcataTCp9L+X48d5Im0gRQcd RW4QeAqLvhov87UlLKWVAYeLUY20xatKUMdYx5M0VtWkNptYvY7HyweFAtpsWYCV8GiZ X7TErpYZ8Jg1rnK9XMSjpW1HVrWY5DtwyG+63je6MuW2MhdEnvgVOxX+GSTeqAHpsBN+ ML4A== X-Gm-Message-State: AIkVDXJIDEyJlzI1lEG/0ztUJvfpnwBTF0fQm3yweIrcZbC2OPCqvMqmg+6TxRBlNdgiiY14 X-Received: by 10.25.211.7 with SMTP id k7mr1140912lfg.62.1485443090355; Thu, 26 Jan 2017 07:04:50 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s7sm540332lja.27.2017.01.26.07.04.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 07:04:49 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Paolo Valente , Linus Walleij Subject: [PATCH 3/6] mmc: core: rename mmc_start_req() to *areq() Date: Thu, 26 Jan 2017 16:04:30 +0100 Message-Id: <20170126150433.14038-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170126150433.14038-1-linus.walleij@linaro.org> References: <20170126150433.14038-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org With the coexisting __mmc_start_request(), mmc_start_request() and __mmc_start_req() it is a bit confusing that mmc_start_req() actually does not start a normal request, but an asynchronous request. Rename it to mmc_start_areq() to make it explicit what the function is doing, also fix the kerneldoc for this function while we're at it. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 8 ++++---- drivers/mmc/core/core.c | 14 +++++++------- drivers/mmc/core/mmc_test.c | 8 ++++---- include/linux/mmc/core.h | 2 +- 4 files changed, 16 insertions(+), 16 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 aaade079603e..de9200470c13 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1611,8 +1611,8 @@ static void mmc_blk_rw_start_new(struct mmc_queue *mq, struct mmc_card *card, blk_end_request_all(req, -EIO); } else { mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq); - mmc_start_req(card->host, - &mq->mqrq_cur->mmc_active, NULL); + mmc_start_areq(card->host, + &mq->mqrq_cur->mmc_active, NULL); } } @@ -1650,7 +1650,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) } else new_areq = NULL; - old_areq = mmc_start_req(card->host, new_areq, &status); + old_areq = mmc_start_areq(card->host, new_areq, &status); if (!old_areq) { /* * We have just put the first request into the pipeline @@ -1771,7 +1771,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) */ mmc_blk_rw_rq_prep(mq_rq, card, disable_multi, mq); - mmc_start_req(card->host, + mmc_start_areq(card->host, &mq_rq->mmc_active, NULL); mq_rq->brq.retune_retry_done = retune_retry_done; } diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 8c458255e55a..ed1768cf464a 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -631,10 +631,10 @@ static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq, } /** - * mmc_start_req - start a non-blocking request + * mmc_start_areq - start an asynchronous request * @host: MMC host to start command - * @areq: async request to start - * @error: out parameter returns 0 for success, otherwise non zero + * @areq: asynchronous request to start + * @ret_stat: out parameter for status * * Start a new MMC custom command request for a host. * If there is on ongoing async request wait for completion @@ -646,9 +646,9 @@ static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq, * return the completed request. If there is no ongoing request, NULL * is returned without waiting. NULL is not an error condition. */ -struct mmc_async_req *mmc_start_req(struct mmc_host *host, - struct mmc_async_req *areq, - enum mmc_blk_status *ret_stat) +struct mmc_async_req *mmc_start_areq(struct mmc_host *host, + struct mmc_async_req *areq, + enum mmc_blk_status *ret_stat) { enum mmc_blk_status status = MMC_BLK_SUCCESS; int start_err = 0; @@ -708,7 +708,7 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host, *ret_stat = status; return data; } -EXPORT_SYMBOL(mmc_start_req); +EXPORT_SYMBOL(mmc_start_areq); /** * mmc_wait_for_req - start a request and wait for completion diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c index 83d193c09d98..f99ac3123fd2 100644 --- a/drivers/mmc/core/mmc_test.c +++ b/drivers/mmc/core/mmc_test.c @@ -853,7 +853,7 @@ static int mmc_test_nonblock_transfer(struct mmc_test_card *test, for (i = 0; i < count; i++) { mmc_test_prepare_mrq(test, cur_areq->mrq, sg, sg_len, dev_addr, blocks, blksz, write); - done_areq = mmc_start_req(test->card->host, cur_areq, &status); + done_areq = mmc_start_areq(test->card->host, cur_areq, &status); if (status != MMC_BLK_SUCCESS || (!done_areq && i > 0)) { ret = RESULT_FAIL; @@ -872,7 +872,7 @@ static int mmc_test_nonblock_transfer(struct mmc_test_card *test, dev_addr += blocks; } - done_areq = mmc_start_req(test->card->host, NULL, &status); + done_areq = mmc_start_areq(test->card->host, NULL, &status); if (status != MMC_BLK_SUCCESS) ret = RESULT_FAIL; @@ -2402,7 +2402,7 @@ static int mmc_test_ongoing_transfer(struct mmc_test_card *test, /* Start ongoing data request */ if (use_areq) { - mmc_start_req(host, &test_areq.areq, &blkstat); + mmc_start_areq(host, &test_areq.areq, &blkstat); if (blkstat != MMC_BLK_SUCCESS) { ret = RESULT_FAIL; goto out_free; @@ -2440,7 +2440,7 @@ static int mmc_test_ongoing_transfer(struct mmc_test_card *test, /* Wait for data request to complete */ if (use_areq) { - mmc_start_req(host, NULL, &blkstat); + mmc_start_areq(host, NULL, &blkstat); if (blkstat != MMC_BLK_SUCCESS) ret = RESULT_FAIL; } else { diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 6dcb339fcd45..a0c63ea28796 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -158,7 +158,7 @@ struct mmc_request { struct mmc_card; struct mmc_async_req; -struct mmc_async_req *mmc_start_req(struct mmc_host *host, +struct mmc_async_req *mmc_start_areq(struct mmc_host *host, struct mmc_async_req *areq, enum mmc_blk_status *ret_stat); void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq); From patchwork Thu Jan 26 15:04: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: 92526 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp226928qgi; Thu, 26 Jan 2017 07:04:57 -0800 (PST) X-Received: by 10.98.90.196 with SMTP id o187mr3591738pfb.30.1485443097917; Thu, 26 Jan 2017 07:04:57 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si1617664pfg.106.2017.01.26.07.04.57; Thu, 26 Jan 2017 07:04:57 -0800 (PST) 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 S1753218AbdAZPE4 (ORCPT + 5 others); Thu, 26 Jan 2017 10:04:56 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:36605 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753104AbdAZPE4 (ORCPT ); Thu, 26 Jan 2017 10:04:56 -0500 Received: by mail-lf0-f49.google.com with SMTP id z134so146889142lff.3 for ; Thu, 26 Jan 2017 07:04:55 -0800 (PST) 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=EnU3nZR8EEjIUUKvcI6m+wjQ8akXi5cXvZ4Pt9lhcsI=; b=dGWWX22OVnutm/fpG40EE5Y+BJ5XCcILr1KAnC3hy8OdD8skYGvZHr6/SgwmI8+iqO AGyz1dPS5tuwCD8RG1CTvtvD0LILmIRjFERywz34SKxVn7npJhrAa27Oy4MXeJqYPahk pqsuWi7nM+yBOqLDcziw1Y5daYtQ9GDDVjVTE= 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=EnU3nZR8EEjIUUKvcI6m+wjQ8akXi5cXvZ4Pt9lhcsI=; b=ulmKK7IGac4/00T5v8QhULu1J+4Td8rQGP3f6UfCPVyS19aLHsb18Ng0DzQYgmcMNV 9A78ZKV1DXPbwu90ciZFMbrIafvDQlgykcsHmUQoB3pLy+9c/7cjp5r4ot2yzNL4Iuh4 LL86Kti1ePs6EOvvtJlQn0Dd5+KnMMuLGqan2i+OeUooc5Vb8ZDUzdeP11yz3GhZinuQ J5sdPJwMULhzd8RqocXJdurNYj7ykurU4qwUf/3VQwykIMP0HXIbpfgW6qbLJWU+s6P/ OYKVCXCf5BkGN1hzrfCbC39/VELFcDnEWJyoyPNr5k+CJzec3jrrB8e5yU2+YGbhUSV1 Nx2Q== X-Gm-Message-State: AIkVDXJ3IONak6/g83XPEKckBuwiWlUVG6KZL29+ExAjYnQXnKnTRUeDa7R7AZTb4/r2vFqG X-Received: by 10.25.130.147 with SMTP id e141mr1147578lfd.44.1485443094042; Thu, 26 Jan 2017 07:04:54 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s7sm540332lja.27.2017.01.26.07.04.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 07:04:52 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Paolo Valente , Linus Walleij Subject: [PATCH 4/6] mmc: block: refactor mmc_blk_rw_try_restart() Date: Thu, 26 Jan 2017 16:04:31 +0100 Message-Id: <20170126150433.14038-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170126150433.14038-1-linus.walleij@linaro.org> References: <20170126150433.14038-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 mmc_blk_rw_start_new() was named after the label inside mmc_blk_issue_rw_rq() but is really a confusing name for this function: what it does is to try to restart the latest issued command on the host and card of the current MMC queue. So rename it mmc_blk_rw_try_restart() that reflects what it is doing and at this point also refactore the function to treat the removed card as an exception and just exit if this happens and run on in the function if that is not happening. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 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 de9200470c13..14c33f57776c 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1603,17 +1603,24 @@ static void mmc_blk_rw_cmd_abort(struct mmc_card *card, struct request *req) blk_rq_cur_bytes(req)); } -static void mmc_blk_rw_start_new(struct mmc_queue *mq, struct mmc_card *card, - struct request *req) +/** + * mmc_blk_rw_try_restart() - tries to restart the current async request + * @mq: the queue with the card and host to restart + * @req: a new request that want to be started after the current one + */ +static void mmc_blk_rw_try_restart(struct mmc_queue *mq, struct request *req) { - if (mmc_card_removed(card)) { + /* + * If the card was removed, just cancel everything and return. + */ + if (mmc_card_removed(mq->card)) { req->rq_flags |= RQF_QUIET; blk_end_request_all(req, -EIO); - } else { - mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq); - mmc_start_areq(card->host, - &mq->mqrq_cur->mmc_active, NULL); + return; } + /* Else proceed and try to restart the current async request */ + mmc_blk_rw_rq_prep(mq->mqrq_cur, mq->card, 0, mq); + mmc_start_areq(mq->card->host, &mq->mqrq_cur->mmc_active, NULL); } static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) @@ -1700,11 +1707,11 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) ret = mmc_blk_cmd_err(md, card, brq, old_req, ret); if (mmc_blk_reset(md, card->host, type)) { mmc_blk_rw_cmd_abort(card, old_req); - mmc_blk_rw_start_new(mq, card, new_req); + mmc_blk_rw_try_restart(mq, new_req); return; } if (!ret) { - mmc_blk_rw_start_new(mq, card, new_req); + mmc_blk_rw_try_restart(mq, new_req); return; } break; @@ -1717,7 +1724,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) if (!mmc_blk_reset(md, card->host, type)) break; mmc_blk_rw_cmd_abort(card, old_req); - mmc_blk_rw_start_new(mq, card, new_req); + mmc_blk_rw_try_restart(mq, new_req); return; case MMC_BLK_DATA_ERR: { int err; @@ -1727,7 +1734,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) break; if (err == -ENODEV) { mmc_blk_rw_cmd_abort(card, old_req); - mmc_blk_rw_start_new(mq, card, new_req); + mmc_blk_rw_try_restart(mq, new_req); return; } /* Fall through */ @@ -1748,19 +1755,19 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) ret = blk_end_request(old_req, -EIO, brq->data.blksz); if (!ret) { - mmc_blk_rw_start_new(mq, card, new_req); + mmc_blk_rw_try_restart(mq, new_req); return; } break; case MMC_BLK_NOMEDIUM: mmc_blk_rw_cmd_abort(card, old_req); - mmc_blk_rw_start_new(mq, card, new_req); + mmc_blk_rw_try_restart(mq, new_req); return; default: pr_err("%s: Unhandled return value (%d)", old_req->rq_disk->disk_name, status); mmc_blk_rw_cmd_abort(card, old_req); - mmc_blk_rw_start_new(mq, card, new_req); + mmc_blk_rw_try_restart(mq, new_req); return; } From patchwork Thu Jan 26 15:04: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: 92527 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp226961qgi; Thu, 26 Jan 2017 07:05:01 -0800 (PST) X-Received: by 10.84.224.131 with SMTP id s3mr4821909plj.162.1485443101356; Thu, 26 Jan 2017 07:05:01 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si1617664pfg.106.2017.01.26.07.05.01; Thu, 26 Jan 2017 07:05:01 -0800 (PST) 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 S1753067AbdAZPFA (ORCPT + 5 others); Thu, 26 Jan 2017 10:05:00 -0500 Received: from mail-lf0-f50.google.com ([209.85.215.50]:34536 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753104AbdAZPFA (ORCPT ); Thu, 26 Jan 2017 10:05:00 -0500 Received: by mail-lf0-f50.google.com with SMTP id v186so146964588lfa.1 for ; Thu, 26 Jan 2017 07:04:59 -0800 (PST) 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=icXlKGlOqYqWA0DEmQqp65GnPJXTog34+G0XL2Zy4Mg=; b=KchSbfsxzHEWrOEKZbpLj28hgFphL1b5UJQvQQ0IPLimD4v/9vmm9iohMU9mUsbevt PUG+TyrwSVLdosH8DBh0M9atuMQCGg0Zqo9M3t9dG0QvyPv3nrxQ7+noizK2bCA1WkCK r68ibwnmbSyqELA1JlAa18q8C5l1SlXjE+PHA= 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=icXlKGlOqYqWA0DEmQqp65GnPJXTog34+G0XL2Zy4Mg=; b=nSxKAukkRG8/S3V0Hz3mUvfvYVhVfnyGSNB0ai/oFOeBMZJ1rFG/J0VgPd8BGAJxml 6L7PCybs9fJH53gCSaZun4RqxN1QKK+ilAuiVo8WhSV7en0fiD6JZZcxszrF44tZMYe8 1rtcDFYhsGzUjp5NL/0CR8ADZ224Fsc8UrzVRseXYS/KUWN+KIQc3p07533mb9EZRFWZ qfX9uvToLIoqulPiEdSpBU85vQv0gPrlA5Sobc0Qvei269BqjoF0Qdm6C5BX6TEpcbY1 yGikCb7omrqGhAavuV1BuO18aQQtxBuKbmdOzD+5cKxR/zTFtxHrLtr4JXNENcVGhZup b+zQ== X-Gm-Message-State: AIkVDXJALBxqlsIjWsj0qIrNMgIbsbV/03dTqvvO/U6SShzTBJNmJSFQFiH4ELM2tvv+3go2 X-Received: by 10.25.202.83 with SMTP id h19mr1123002lfj.33.1485443097514; Thu, 26 Jan 2017 07:04:57 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s7sm540332lja.27.2017.01.26.07.04.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 07:04:56 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Paolo Valente , Linus Walleij Subject: [PATCH 5/6] mmc: block: rename mmc_active to areq Date: Thu, 26 Jan 2017 16:04:32 +0100 Message-Id: <20170126150433.14038-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170126150433.14038-1-linus.walleij@linaro.org> References: <20170126150433.14038-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 mmc_active member of struct mmc_queue_req has a very confusing name: this is certainly not always "active", it is the asynchronous request associated by the mmc_queue_req but it is not guaranteed to be "active" in any sense, such as being running on the host. Simply rename this member to "areq". Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 14 +++++++------- drivers/mmc/core/queue.h | 2 +- 2 files changed, 8 insertions(+), 8 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 14c33f57776c..04c7162f444e 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1302,7 +1302,7 @@ static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card, struct mmc_async_req *areq) { struct mmc_queue_req *mq_mrq = container_of(areq, struct mmc_queue_req, - mmc_active); + areq); struct mmc_blk_request *brq = &mq_mrq->brq; struct request *req = mq_mrq->req; int need_retune = card->host->need_retune; @@ -1558,8 +1558,8 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, brq->data.sg_len = i; } - mqrq->mmc_active.mrq = &brq->mrq; - mqrq->mmc_active.err_check = mmc_blk_err_check; + mqrq->areq.mrq = &brq->mrq; + mqrq->areq.err_check = mmc_blk_err_check; mmc_queue_bounce_pre(mqrq); } @@ -1620,7 +1620,7 @@ static void mmc_blk_rw_try_restart(struct mmc_queue *mq, struct request *req) } /* Else proceed and try to restart the current async request */ mmc_blk_rw_rq_prep(mq->mqrq_cur, mq->card, 0, mq); - mmc_start_areq(mq->card->host, &mq->mqrq_cur->mmc_active, NULL); + mmc_start_areq(mq->card->host, &mq->mqrq_cur->areq, NULL); } static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) @@ -1653,7 +1653,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) } mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq); - new_areq = &mq->mqrq_cur->mmc_active; + new_areq = &mq->mqrq_cur->areq; } else new_areq = NULL; @@ -1673,7 +1673,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) * An asynchronous request has been completed and we proceed * to handle the result of it. */ - mq_rq = container_of(old_areq, struct mmc_queue_req, mmc_active); + mq_rq = container_of(old_areq, struct mmc_queue_req, areq); brq = &mq_rq->brq; old_req = mq_rq->req; type = rq_data_dir(old_req) == READ ? MMC_BLK_READ : MMC_BLK_WRITE; @@ -1779,7 +1779,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) mmc_blk_rw_rq_prep(mq_rq, card, disable_multi, mq); mmc_start_areq(card->host, - &mq_rq->mmc_active, NULL); + &mq_rq->areq, NULL); mq_rq->brq.retune_retry_done = retune_retry_done; } } while (ret); diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index 0cea02af79d1..e0cd5b1f40ee 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -33,7 +33,7 @@ struct mmc_queue_req { char *bounce_buf; struct scatterlist *bounce_sg; unsigned int bounce_sg_len; - struct mmc_async_req mmc_active; + struct mmc_async_req areq; }; struct mmc_queue { From patchwork Thu Jan 26 15:04:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 92528 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp227000qgi; Thu, 26 Jan 2017 07:05:05 -0800 (PST) X-Received: by 10.84.143.34 with SMTP id 31mr4707563ply.81.1485443105378; Thu, 26 Jan 2017 07:05:05 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si1617664pfg.106.2017.01.26.07.05.05; Thu, 26 Jan 2017 07:05:05 -0800 (PST) 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 S1753115AbdAZPFE (ORCPT + 5 others); Thu, 26 Jan 2017 10:05:04 -0500 Received: from mail-lf0-f48.google.com ([209.85.215.48]:34560 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753220AbdAZPFD (ORCPT ); Thu, 26 Jan 2017 10:05:03 -0500 Received: by mail-lf0-f48.google.com with SMTP id v186so146965807lfa.1 for ; Thu, 26 Jan 2017 07:05:02 -0800 (PST) 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=tDEBrNPhm4nc7Au24hWJvVDhgs7U/hvJ+ifcb3qJhGs=; b=cuyweW19OU0Vr85hFjlZySvHkpsQe6UBbRV5PhaEQ7oeCGu2nrYCk4BHmrO+JAnQfC eRBgRvykLyMh+s3OZCGRo9B+yOVaOrLEOs57Z1OpsHyCzclbuSZZnC+ESnAJI71d7u8b p0+FxdFinfqF0Y22FDWn814EIxpQf+QsAtl9w= 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=tDEBrNPhm4nc7Au24hWJvVDhgs7U/hvJ+ifcb3qJhGs=; b=dcPTiyy9fHdlKA+EC8mk+WsZazV+SZpRThBbML31j4RY8vfhW3KFebowmWPq+o10+K BKkZfluvpu5Cd950G2+L8FdSVjrfBhzprKqacw6sgQYFFG3yuWH5VrsAa9GmxV6uv2rm ZenYA5nn5niMURfhe0VKfHOLz5K2XzWq5WDCvVbbdzOc1/Z5+BMT7uQ4anmVrYhJjxCZ 9l5/7OgBd6gH0FfMTQS7bjq7IfolZjvEYLa4wBRwd5WvVRqs+q/xItZhrCDbHRFz5SKe crwth6upXlPcxbwjcwawYMtGL4mDjw6euqdIRHDgNJcWMj3LFirq6A1TZrlh1772deMQ HuBw== X-Gm-Message-State: AIkVDXLhlVEpiV74WBPoMP/QB8CHiMM/yO3gZQFOkLGzLJGHOZKXS7c10z4gB4WPytI6f224 X-Received: by 10.25.203.87 with SMTP id b84mr1024791lfg.158.1485443101874; Thu, 26 Jan 2017 07:05:01 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s7sm540332lja.27.2017.01.26.07.05.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 07:05:00 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Paolo Valente , Linus Walleij Subject: [PATCH 6/6] mmc: queue: turn queue flags into bools Date: Thu, 26 Jan 2017 16:04:33 +0100 Message-Id: <20170126150433.14038-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170126150433.14038-1-linus.walleij@linaro.org> References: <20170126150433.14038-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Instead of masking and setting two bits in the "flags" field for the mmc_queue, just use two bools named "suspended" and "new_request". The masking and setting would likely have race conditions anyways, it is better to use a simple member like this. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 6 +++--- drivers/mmc/core/queue.c | 12 ++++++------ drivers/mmc/core/queue.h | 5 ++--- 3 files changed, 11 insertions(+), 12 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 04c7162f444e..7be50ebf300f 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1665,7 +1665,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) * complete. */ if (status == MMC_BLK_NEW_REQUEST) - mq->flags |= MMC_QUEUE_NEW_REQUEST; + mq->new_request = true; return; } @@ -1804,7 +1804,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) goto out; } - mq->flags &= ~MMC_QUEUE_NEW_REQUEST; + mq->new_request = false; if (req && req_op(req) == REQ_OP_DISCARD) { /* complete ongoing async transfer before issuing discard */ if (card->host->areq) @@ -1825,7 +1825,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) } out: - if ((!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) || req_is_special) + if ((!req && !mq->new_request) || req_is_special) /* * Release host when there are no more requests * and after special request(discard, flush) is done. diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index 611f5c6d1950..5cb369c2664b 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -86,8 +86,8 @@ static int mmc_queue_thread(void *d) set_current_state(TASK_RUNNING); mmc_blk_issue_rq(mq, req); cond_resched(); - if (mq->flags & MMC_QUEUE_NEW_REQUEST) { - mq->flags &= ~MMC_QUEUE_NEW_REQUEST; + if (mq->new_request) { + mq->new_request = false; continue; /* fetch again */ } @@ -401,8 +401,8 @@ void mmc_queue_suspend(struct mmc_queue *mq) struct request_queue *q = mq->queue; unsigned long flags; - if (!(mq->flags & MMC_QUEUE_SUSPENDED)) { - mq->flags |= MMC_QUEUE_SUSPENDED; + if (!mq->suspended) { + mq->suspended |= true; spin_lock_irqsave(q->queue_lock, flags); blk_stop_queue(q); @@ -421,8 +421,8 @@ void mmc_queue_resume(struct mmc_queue *mq) struct request_queue *q = mq->queue; unsigned long flags; - if (mq->flags & MMC_QUEUE_SUSPENDED) { - mq->flags &= ~MMC_QUEUE_SUSPENDED; + if (mq->suspended) { + mq->suspended = false; up(&mq->thread_sem); diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index e0cd5b1f40ee..e298f100101b 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -40,9 +40,8 @@ struct mmc_queue { struct mmc_card *card; struct task_struct *thread; struct semaphore thread_sem; - unsigned int flags; -#define MMC_QUEUE_SUSPENDED (1 << 0) -#define MMC_QUEUE_NEW_REQUEST (1 << 1) + bool new_request; + bool suspended; bool asleep; struct mmc_blk_data *blkdata; struct request_queue *queue;