From patchwork Wed Feb 1 12:47:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93011 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301096obz; Wed, 1 Feb 2017 04:48:40 -0800 (PST) X-Received: by 10.84.143.195 with SMTP id 61mr4279290plz.46.1485953320644; Wed, 01 Feb 2017 04:48:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si19095150pli.181.2017.02.01.04.48.40; Wed, 01 Feb 2017 04:48:40 -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 S1750941AbdBAMsj (ORCPT + 5 others); Wed, 1 Feb 2017 07:48:39 -0500 Received: from mail-lf0-f50.google.com ([209.85.215.50]:34775 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750936AbdBAMsj (ORCPT ); Wed, 1 Feb 2017 07:48:39 -0500 Received: by mail-lf0-f50.google.com with SMTP id v186so227905821lfa.1 for ; Wed, 01 Feb 2017 04:48:38 -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=p3WJqq16lIfLSdObPiTQQYSTA3tbus9H0BkT1hTAya4=; b=Hgjf77yD+QzfRlx7Wx7PsosboiB0fjnZHeqwX6RHCifaV1zixg2bzqt6ulswkf4dPi DqCPZCiGm20jb1ciYdY+EsJf0y8mxlkvZYOjIzeiyzyc2WBgsnwo0FjYNYo0VtPghn/N 1FkEqZpTP167agPkjjsiY/Yi7leYc4Gr18Y7I= 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=p3WJqq16lIfLSdObPiTQQYSTA3tbus9H0BkT1hTAya4=; b=FPB8VBk999IT+eFawG3Je5wxRzaFbXTlrDuYHhqg1DS22vuGhQWEcxysIxVtcIuEWZ oXLyxhTsCLnv0jUcq1qcL38+BjlKfDYk3FloGt06d6IUw8dNemrnaeF9IvoU79XmEzi/ +DgKPkdknC65K4ErxwQduNmmGaaWZX8bjoHeCFBUvdEaovxMcsGm+OvTltBL0rLoJRs0 Op/LZans2nCT3iUaobdTcNgsFCb3zkpO8mSPROvA3WmyCkxQamY9moX1FA6EN4Yk3eAE K02HWzHqKyVLoQVQqxs9BO7wWUZtruRdvFeLmYxRi2lJkhPv/Bu5dBxKAmsDsVyUDdl1 dEmQ== X-Gm-Message-State: AIkVDXK4pCE1hvUx2l7MUNfk+NToER/sH0QKbNoClLpzyzFS5y3At0+KElCbVLsjNyPnXDac X-Received: by 10.25.217.205 with SMTP id s74mr854559lfi.8.1485953317554; Wed, 01 Feb 2017 04:48:37 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.48.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:48:36 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 01/10] mmc: block: inline the command abort and start new goto:s Date: Wed, 1 Feb 2017 13:47:51 +0100 Message-Id: <20170201124800.13865-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-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 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 6c8be1a80551..0e23dba62613 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1701,10 +1701,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; @@ -1714,15 +1719,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: @@ -1740,15 +1750,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) { @@ -1763,14 +1779,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 Wed Feb 1 12:47:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93012 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301116obz; Wed, 1 Feb 2017 04:48:45 -0800 (PST) X-Received: by 10.84.241.66 with SMTP id u2mr4295172plm.107.1485953325142; Wed, 01 Feb 2017 04:48:45 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si19095150pli.181.2017.02.01.04.48.44; Wed, 01 Feb 2017 04:48:45 -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 S1750945AbdBAMso (ORCPT + 5 others); Wed, 1 Feb 2017 07:48:44 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:34796 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750940AbdBAMsn (ORCPT ); Wed, 1 Feb 2017 07:48:43 -0500 Received: by mail-lf0-f43.google.com with SMTP id v186so227906685lfa.1 for ; Wed, 01 Feb 2017 04:48:42 -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=Kn8m0sV6b6G0jZkWkfO7YPZPNV7jxkcRhzqT6MTt9Lk=; b=V0edrGOUgARoEdgAr3Y6QYv1pScAR3BWP+AsgTJXCXAr/NGTtM/R9iBOaHWI6adWKy n7CJ2gr/SZ5X/3790stOg/OYLQP0lMtl0Fomz3blXgs/eArBNUp1Qi+qqaRINzSPxBGT TFrUw7kDAmtKBUX7QzNsdMlvLdeW7f2Q9wcM0= 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=Kn8m0sV6b6G0jZkWkfO7YPZPNV7jxkcRhzqT6MTt9Lk=; b=MEC1dUn7p3TuT196O1otZBNBiIJVZRMOeHaaWFmm/dUYMJ7hXEWY6hwhsINn13fC8l is/YkvnE6UJK/vAbkvxPUynJ8kOtVVrlNex3NZDWoslpT+4c2ksugE6UJIl/vm6h5Xil WTxsoBjOqZ9QHQ/u/ET9+ofOf7C7op0ErQXyLlX/Z7bCJVtB7jPCa3333KOEqN59TxN9 WhIXZN3VXTvPRHugZVZWalVwJscbqXm8o+Q66Y4YCGe9sg7WZUunr0z7k1xFkMKCXw34 mDBTAU8+WhZQ2Iltk8D4rgkXzGQ/HwRTkRmrs01/RaYVasTXbNjBHCyKOZIHg+SN1wEH ZPGA== X-Gm-Message-State: AIkVDXKi+SB2e/9OEaO3XozX0SvZKSzyhHLCBAryUHHvHdn4gRjoAO50Y5tE+TaEgLUStD3j X-Received: by 10.25.92.145 with SMTP id u17mr866061lfi.160.1485953321667; Wed, 01 Feb 2017 04:48:41 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.48.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:48:40 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 02/10] mmc: block: rename rqc and req Date: Wed, 1 Feb 2017 13:47:52 +0100 Message-Id: <20170201124800.13865-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-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 0e23dba62613..e1479f114247 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1619,7 +1619,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; @@ -1627,24 +1627,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; } @@ -1671,8 +1671,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) { @@ -1683,7 +1683,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); /* @@ -1693,21 +1693,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; @@ -1719,8 +1719,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; @@ -1729,8 +1729,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 */ @@ -1739,7 +1739,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; } @@ -1748,22 +1748,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 Wed Feb 1 12:47:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93013 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301155obz; Wed, 1 Feb 2017 04:48:51 -0800 (PST) X-Received: by 10.98.19.145 with SMTP id 17mr3438763pft.26.1485953331513; Wed, 01 Feb 2017 04:48:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si19095150pli.181.2017.02.01.04.48.51; Wed, 01 Feb 2017 04:48:51 -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 S1750949AbdBAMsu (ORCPT + 5 others); Wed, 1 Feb 2017 07:48:50 -0500 Received: from mail-lf0-f54.google.com ([209.85.215.54]:33802 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942AbdBAMst (ORCPT ); Wed, 1 Feb 2017 07:48:49 -0500 Received: by mail-lf0-f54.google.com with SMTP id v186so227908015lfa.1 for ; Wed, 01 Feb 2017 04:48:48 -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=91nRmrLtnDewn3MF5WFrLX/5LnbpFDzF52RwS7/Zevc=; b=SHahbgXPhN0YsDg0rXW91yTcubtMwo3pH6qnHlCofdgvTelgCP5qeHsUnhSq3mPY6l K/A7EinQ8X3hHGv84R2kzzWFTphwpSzQNhpgo3I8R44Zxrkt+sQWKDXdc8nVL0mpQ4ou Uk3/kHbcvNAM6+ZXJdbDyPxKoBorfrJx5kTZ0= 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=91nRmrLtnDewn3MF5WFrLX/5LnbpFDzF52RwS7/Zevc=; b=LSUaZ6OjIXZwLHR7GHAZNFAVP7f6JNdut7Dtbv4LF1WurfNUeELEoi7+hHLZc0lHRV Z8M6HlCJrFfGsCN1MWeGaYlQc5Eoz9jU68e8ZL5SfkrQTj70aDoaa9Ir8pYx1QTNMHQ7 x2QNTCyFgBuQ2G+ZARuiW0ec16TOBnuyD+M/uhQ216KexgiFEIbgSQX/5itCg5msCOvs Co3CQA5nK53QDxpKQUPloXyQoOg4MGZzLBccr3gzT8JB5bgiTNhWV8MFtrqRwJZyIazh FLvnqI0wgw3NHCkFqt++Xk2VgzWU0Xf16FuROYNky4JQq2WzasZOLZu8DT7H+Q3+mRhJ WugA== X-Gm-Message-State: AIkVDXJwPCetUuGTRhbym2Yg50TpGuiyPh0R878lnYBgDGAzXVwcXAq4EFGSxuENffTepJpC X-Received: by 10.25.67.11 with SMTP id q11mr1033541lfa.139.1485953327902; Wed, 01 Feb 2017 04:48:47 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.48.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:48:46 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 03/10] mmc: core: rename mmc_start_req() to *areq() Date: Wed, 1 Feb 2017 13:47:53 +0100 Message-Id: <20170201124800.13865-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-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 e1479f114247..3246cd396c77 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1614,8 +1614,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); } } @@ -1653,7 +1653,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 @@ -1774,7 +1774,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 0faa2ee613be..a160c3a7777a 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; @@ -699,7 +699,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 Wed Feb 1 12:47:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93015 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301198obz; Wed, 1 Feb 2017 04:49:00 -0800 (PST) X-Received: by 10.99.146.7 with SMTP id o7mr3462542pgd.6.1485953340418; Wed, 01 Feb 2017 04:49:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si19095150pli.181.2017.02.01.04.49.00; Wed, 01 Feb 2017 04:49:00 -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 S1750952AbdBAMs7 (ORCPT + 5 others); Wed, 1 Feb 2017 07:48:59 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:35819 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750951AbdBAMs6 (ORCPT ); Wed, 1 Feb 2017 07:48:58 -0500 Received: by mail-lf0-f42.google.com with SMTP id n124so227404624lfd.2 for ; Wed, 01 Feb 2017 04:48:52 -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=WmQvNMyqCo5fFqjgKae6UXtPBIefhYad1wvbRgjOjmA=; b=NbD7XIqZq9XZMwbGyDNjONKoOx16noesmwwAnbHdtwdRQZEKuFiQf3WryD7MXtRiTl aC6eg1fsoMjgZZcsFIrHqqpWmSgX+zWhaGrnSotXg4ZCsdl2vWQynkyg/BndXY6AZ+WC UFS4Xrz32LABn8jOvZFlNWXZoJORpXxAuMqww= 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=WmQvNMyqCo5fFqjgKae6UXtPBIefhYad1wvbRgjOjmA=; b=WDridsrjwrgY4gBDzTeLTWi3hBvm4OoexKWyUnRD2ArqJvozGhbCbst2PWLpnSmZ7g hvkz3xDM+onWJOtR8AeDrPna6eJy6GPXq8311HAMtjai41+bFowvyLdb89zrPL05eMTC 3kvStNBIjkGdrLzB8cyoxqZOfKIaYJURVxEUbwKPZHMS1tVHzZoFOuJ/So3c2l4LAVWO Xa7oLI8zK3j4yN+vwYH6nRsNpxutQVBLlC1ta+BwZjkftbBBHlkwIojW0xE1R4UdVk7o RCVjCatjgrE94lZC6K0fAFOMCQEYL42MkLTEDdtrrShNbx9OnPLOFztcjvq97sd/OaIx RWdQ== X-Gm-Message-State: AIkVDXKmJ0t55k6yY6hOnaBHHOAfUYUhK9fJkWmxaom7vw4QLWfAIk2XHGS5VJ6/jhfzGYnc X-Received: by 10.25.89.148 with SMTP id n142mr876186lfb.64.1485953331873; Wed, 01 Feb 2017 04:48:51 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.48.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:48:50 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 04/10] mmc: block: refactor mmc_blk_rw_try_restart() Date: Wed, 1 Feb 2017 13:47:54 +0100 Message-Id: <20170201124800.13865-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-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 3246cd396c77..8216ce3874b9 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1603,20 +1603,27 @@ 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 (!req) return; - 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) @@ -1703,11 +1710,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; @@ -1720,7 +1727,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; @@ -1730,7 +1737,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 */ @@ -1751,19 +1758,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 Wed Feb 1 12:47:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93014 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301195obz; Wed, 1 Feb 2017 04:49:00 -0800 (PST) X-Received: by 10.99.111.138 with SMTP id k132mr3480226pgc.138.1485953339927; Wed, 01 Feb 2017 04:48:59 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si19095150pli.181.2017.02.01.04.48.59; Wed, 01 Feb 2017 04:48:59 -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 S1750953AbdBAMs6 (ORCPT + 5 others); Wed, 1 Feb 2017 07:48:58 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:33844 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750947AbdBAMs6 (ORCPT ); Wed, 1 Feb 2017 07:48:58 -0500 Received: by mail-lf0-f52.google.com with SMTP id v186so227909920lfa.1 for ; Wed, 01 Feb 2017 04:48:57 -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=uGGgOQuK9A+AVc6Q4QhuDhKbUF9xk61s5P9/I2LnUnE=; b=fouxubnIp7BwZk9YrDr7sJEmLoAOz1NM1YKPW1iBaHpM/jWfYdTxrTlZp8HKXvnQi0 37rAQdZuzDXIHskdNZ97TQHw+aUqmL/Oy+dyp1tMzFCbf4M5K4y/O0/ubITnO4+Uqu+e HjTEYUkipMB28dYRd0KzF54UY60N5YPttkem4= 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=uGGgOQuK9A+AVc6Q4QhuDhKbUF9xk61s5P9/I2LnUnE=; b=cFCEOGwECZS6SNf4e8Ip/yWyU+ilcEUNXDhePA/C9Wv7uncdJcybfqSnL4Brgsw4ZR a0W2i/2pUvmgW/7QVATSOeTp7dMfmsIf2jzSnl2Dea9gMejlbP6TxWcz2OrXD29MdhwL fOmyhKeIgbkNGIsmDwBo0rRN4bjuTWwBkQg3I0fQb17jHU26L+v8qVDE1JwsxVtxJvUQ J7qq7ysdo+Xgsjzjh3aNkn8CLQQsOlbmcgkg1B2tkw0V0sUbwaKRPGe82BiJrANMitXm 7XCxVSFj37SxHUo9PnKO/nlCIeK6CsMi3UAXAwDU8iOEm0Ax36UqI3s+LQBu6jxJrPvg 3XdA== X-Gm-Message-State: AIkVDXI5EB7Q89ckarWkjK0s7PwvdrhVdY7nSEdSgNBIIoyAWyJr6dTtH3cqNlKMZqlI+XS2 X-Received: by 10.25.217.205 with SMTP id s74mr854897lfi.8.1485953336603; Wed, 01 Feb 2017 04:48:56 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.48.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:48:55 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 05/10] mmc: block: rename mmc_active to areq Date: Wed, 1 Feb 2017 13:47:55 +0100 Message-Id: <20170201124800.13865-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-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 8216ce3874b9..7dcc27763381 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); } @@ -1623,7 +1623,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) @@ -1656,7 +1656,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; @@ -1676,7 +1676,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; @@ -1782,7 +1782,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 Wed Feb 1 12:47:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93016 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301224obz; Wed, 1 Feb 2017 04:49:05 -0800 (PST) X-Received: by 10.99.112.75 with SMTP id a11mr3422742pgn.7.1485953344768; Wed, 01 Feb 2017 04:49:04 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b69si19054885pfk.235.2017.02.01.04.49.04; Wed, 01 Feb 2017 04:49:04 -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 S1750962AbdBAMtD (ORCPT + 5 others); Wed, 1 Feb 2017 07:49:03 -0500 Received: from mail-lf0-f41.google.com ([209.85.215.41]:33867 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750956AbdBAMtC (ORCPT ); Wed, 1 Feb 2017 07:49:02 -0500 Received: by mail-lf0-f41.google.com with SMTP id v186so227910954lfa.1 for ; Wed, 01 Feb 2017 04:49: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=v3F/OHbpvFFem2OXfPoTyfXMqhk4G/nfAAAoaMtktfQ=; b=Zy/BREgfvixRhaxNEvPGVpiJnDr+OwJ7c/Kaueqt6IG0JTVS6TyT1GiFntZFeaAHtS wRa6BG7duL3gPGyuwfofIDPWLOfdehnQ8MaqX/uMqO6K0Co5Z+AzCdNlhEAoLkdgBExN lnuhmKKorjEZoyrNa3vWRZTXHXAAsfGq3rMHE= 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=v3F/OHbpvFFem2OXfPoTyfXMqhk4G/nfAAAoaMtktfQ=; b=S9jNfklquBEe/TSg7xSscdqOV1KK5Xnuy0keqvI6UBI0bqjVb+QZFZgeEposT8Zx5M IYaWe3TlKZOseeH+PNKBTRzr8qKY9Fp2Xe+eXUB6uYN/yKnflAjNP6zHSacyZggjz4yJ QZFVJZW7apsTEprv9NNb3LiDVR2togPyKSeStCshwf4oIc/iIxe8A1PgYniy/U4K8TWz R+n7GD35yMOivlUKJOIQKlvZdN/AhvIQtaivxyAmMWbfubBNprO6o4Cx8wK4rU88xJJR k6ku+1xYU4jDjkBOXN9OWEPjYIy3buf83Pwl5LvCb4lNV7pm3dkqBBy1/vvzlTJyuYPS lunw== X-Gm-Message-State: AIkVDXISHAe8kN0nVvX2c3BF+nfjEK6baTG++TCkWOm0WVh0hX+0Clw2HKg75P4J+SQhR+wO X-Received: by 10.25.167.135 with SMTP id q129mr1019826lfe.115.1485953341109; Wed, 01 Feb 2017 04:49:01 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.48.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:48:59 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 06/10] mmc: queue: turn queue flags into bools Date: Wed, 1 Feb 2017 13:47:56 +0100 Message-Id: <20170201124800.13865-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-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 7dcc27763381..1ac7fec03c97 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1668,7 +1668,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; } @@ -1807,7 +1807,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) @@ -1828,7 +1828,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; From patchwork Wed Feb 1 12:47:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93017 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301239obz; Wed, 1 Feb 2017 04:49:07 -0800 (PST) X-Received: by 10.84.231.203 with SMTP id g11mr4227790pln.165.1485953347837; Wed, 01 Feb 2017 04:49:07 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b69si19054885pfk.235.2017.02.01.04.49.07; Wed, 01 Feb 2017 04:49:07 -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 S1750970AbdBAMtG (ORCPT + 5 others); Wed, 1 Feb 2017 07:49:06 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:33885 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbdBAMtG (ORCPT ); Wed, 1 Feb 2017 07:49:06 -0500 Received: by mail-lf0-f45.google.com with SMTP id v186so227911708lfa.1 for ; Wed, 01 Feb 2017 04:49:05 -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=6vLsqCUbHYphiRmD21s24+pWS2qMkB6W425zsw1GkQs=; b=dtFvmhMy5WmSl28bQkXJPzINTIX8p9K5LIRenYU4FfwXclU/hQTv/CTY80A9gN1B3G 18dBvYhgjxa7c3pWoCBhCcKsJwfEMT8Dp4S+93DDF7NdhVCOxfuWjkT5Lh3eUIUir89v aIFDXrmCLXtJYTdy8vQCWmAVuUbf2zKovG/2M= 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=6vLsqCUbHYphiRmD21s24+pWS2qMkB6W425zsw1GkQs=; b=FcfQ5Dnvq1iy4leTzkFsey+TkE+BlpPCtqMyNfrvvizm2ZdiP+zpmE67jU/8dmj7Fh zf+m5ZdIuPH2GBB8Jg7MwiFzzQHzefLNBSOHvsD67tvKeV3EMKYu+1SwvBmJk+Gn+7ij C+Y+pzjgfxDK1weh4X+TJF2ZXSxZFUIVgvr85kaJKv71WXuX+AAAIULaVJPFKtMCF5Z9 yQFo3kf9vsU1AYclGjfqdgEIPDe+SabMLaz8q2OlFzj+omf9/gnrbsqzdEPj4Km4m8LV JQsaAjVA/8qPlmH09LP89CPUQT0j7VxMsqn5Isn9FmDI0yat/+n4zNo3/fR/HJTTuWas QLHQ== X-Gm-Message-State: AIkVDXKliYvtvRUOExIN38vfyKcdyyy0AOqmtda/c/xERapDciQUdEKBA1C1gQWJZAs0KIl4 X-Received: by 10.25.67.11 with SMTP id q11mr1033963lfa.139.1485953344725; Wed, 01 Feb 2017 04:49:04 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.49.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:49:03 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 07/10] mmc: block: return errorcode from mmc_sd_num_wr_blocks() Date: Wed, 1 Feb 2017 13:47:57 +0100 Message-Id: <20170201124800.13865-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org mmc_sd_num_wr_blocks() has an interesting construction that saves one return argument by casting (u32)-1 as error code if something goes wrong. This is however a bit confusing when the normal kernel pattern is to return an int error code on success. So instead pass a variable "blocks" that the function can fill in with the number of successfully transfered blocks and return an integer as error code. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 19 +++++++++++-------- 1 file changed, 11 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 1ac7fec03c97..91d506b37024 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -768,7 +768,7 @@ static inline int mmc_blk_part_switch(struct mmc_card *card, return 0; } -static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) +static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks) { int err; u32 result; @@ -786,9 +786,9 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) - return (u32)-1; + return err; if (!mmc_host_is_spi(card->host) && !(cmd.resp[0] & R1_APP_CMD)) - return (u32)-1; + return err; memset(&cmd, 0, sizeof(struct mmc_command)); @@ -808,7 +808,7 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) blocks = kmalloc(4, GFP_KERNEL); if (!blocks) - return (u32)-1; + return -ENOMEM; sg_init_one(&sg, blocks, 4); @@ -818,9 +818,11 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) kfree(blocks); if (cmd.error || data.error) - result = (u32)-1; + return -EIO; - return result; + *written_blocks = result; + + return 0; } static int get_card_status(struct mmc_card *card, u32 *status, int retries) @@ -1581,9 +1583,10 @@ static int mmc_blk_cmd_err(struct mmc_blk_data *md, struct mmc_card *card, */ if (mmc_card_sd(card)) { u32 blocks; + int err; - blocks = mmc_sd_num_wr_blocks(card); - if (blocks != (u32)-1) { + err = mmc_sd_num_wr_blocks(card, &blocks); + if (!err) { ret = blk_end_request(req, 0, blocks << 9); } } else { From patchwork Wed Feb 1 12:47:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93018 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301266obz; Wed, 1 Feb 2017 04:49:11 -0800 (PST) X-Received: by 10.84.248.10 with SMTP id p10mr4128705pll.87.1485953351833; Wed, 01 Feb 2017 04:49:11 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b69si19054885pfk.235.2017.02.01.04.49.11; Wed, 01 Feb 2017 04:49:11 -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 S1750972AbdBAMtL (ORCPT + 5 others); Wed, 1 Feb 2017 07:49:11 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:33906 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966AbdBAMtK (ORCPT ); Wed, 1 Feb 2017 07:49:10 -0500 Received: by mail-lf0-f49.google.com with SMTP id v186so227912612lfa.1 for ; Wed, 01 Feb 2017 04:49:09 -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=dmAjuW/GMKH6E4gSUwyMZ3mfGLEuEBy/KFbaAuLZwLU=; b=N0pgGxKB9FQSIWl5To/Py0NsK6OFOnVasDXblPRwQNLM7TV3T1b3uAvjRl1QmaS9FP 4unD225yWdVcv8+XKnx1pWLal+4iYJLfXzljdHlv9jYcP6+qjewIvRockT5g3szT9xyr edgZP7ax8JtPporWDDQsfUjUPVK7lO0cIZHPI= 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=dmAjuW/GMKH6E4gSUwyMZ3mfGLEuEBy/KFbaAuLZwLU=; b=eSd8wqk9Gof/nPAn6LkZsOjKDFAI3TnU7g7oX10zDEuGPJ1bxNii/K7f2jTgq4jy7t iZeT0bpEyEle38YtU6vyzp7PkxRwQOx4THRpEdcIZI95wenyoJktsQN5XcEtNu3Yt6CR 2ZkcWVwoC90hINuyHm746d49w9YZqRn5tw+aXMW9MC3VS6pgMWbfjhxi8eoW5gA0NO+0 K7His1hkKNVRwo92Vd2utkfnoCca4uVd9YfXbxiLEc1rPcWgSTqoVxuxyFSxq2mB4oW7 XGiT5ieEyjFlzkj/nHHGTQ0lIX9iDES3TJaxJwPqBzzXdoYyTVtGBnwKihmJ9dGKs03P NEcw== X-Gm-Message-State: AIkVDXKEpGVaq2GYXjZTDamyoKs2Nb7j0e3s8uEeY4hxele3CE6Eym+Zi9iEmVdE93RhPGOl X-Received: by 10.25.170.7 with SMTP id t7mr1030908lfe.105.1485953348433; Wed, 01 Feb 2017 04:49:08 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.49.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:49:07 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 08/10] mmc: block: respect bool returned from blk_end_request() Date: Wed, 1 Feb 2017 13:47:58 +0100 Message-Id: <20170201124800.13865-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-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 return value from blk_end_request() is a bool but is treated like an int. This is generally safe, but the variable also has the opaque name "ret" and gets returned from the helper function mmc_blk_cmd_err(). - Switch the variable to a bool, applies everywhere. - Return a bool from mmc_blk_cmd_err() and rename the function mmc_blk_rw_cmd_err() to indicate through the namespace that this is a helper for mmc_blk_issue_rw_rq(). - Rename the variable from "ret" to "req_pending" inside the while() loop inside mmc_blk_issue_rq_rq(), which finally makes it very clear what this while loop is waiting for. - Augment the argument "ret" to mmc_blk_rq_cmd_err() to old_req_pending so it becomes evident that this is an older state, and it is returned only if we fail to get the number of written blocks from an SD card in the function mmc_sd_num_wr_blocks(). - Augment the while() loop in mmc_blk_rq_cmd_abort(): it is evident now that we know this is a bool variable, that the function is just spinning waiting for blk_end_request() to return false. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 51 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 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 91d506b37024..92f7772ca56d 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1566,11 +1566,13 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, mmc_queue_bounce_pre(mqrq); } -static int mmc_blk_cmd_err(struct mmc_blk_data *md, struct mmc_card *card, - struct mmc_blk_request *brq, struct request *req, - int ret) +static bool mmc_blk_rw_cmd_err(struct mmc_blk_data *md, struct mmc_card *card, + struct mmc_blk_request *brq, struct request *req, + bool old_req_pending) { struct mmc_queue_req *mq_rq; + bool req_pending; + mq_rq = container_of(brq, struct mmc_queue_req, brq); /* @@ -1586,24 +1588,23 @@ static int mmc_blk_cmd_err(struct mmc_blk_data *md, struct mmc_card *card, int err; err = mmc_sd_num_wr_blocks(card, &blocks); - if (!err) { - ret = blk_end_request(req, 0, blocks << 9); - } + if (err) + req_pending = old_req_pending; + else + req_pending = blk_end_request(req, 0, blocks << 9); } else { - ret = blk_end_request(req, 0, brq->data.bytes_xfered); + req_pending = blk_end_request(req, 0, brq->data.bytes_xfered); } - return ret; + return req_pending; } static void mmc_blk_rw_cmd_abort(struct mmc_card *card, struct request *req) { - int ret = 1; - if (mmc_card_removed(card)) req->rq_flags |= RQF_QUIET; - while (ret) - ret = blk_end_request(req, -EIO, - blk_rq_cur_bytes(req)); + while (blk_end_request(req, -EIO, blk_rq_cur_bytes(req))) + { + } } /** @@ -1634,12 +1635,13 @@ 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; struct mmc_blk_request *brq; - int ret = 1, disable_multi = 0, retry = 0, type, retune_retry_done = 0; + int disable_multi = 0, retry = 0, type, retune_retry_done = 0; enum mmc_blk_status status; struct mmc_queue_req *mq_rq; struct request *old_req; struct mmc_async_req *new_areq; struct mmc_async_req *old_areq; + bool req_pending = true; if (!new_req && !mq->mqrq_prev->req) return; @@ -1693,15 +1695,14 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) */ mmc_blk_reset_success(md, type); - ret = blk_end_request(old_req, 0, - brq->data.bytes_xfered); - + req_pending = blk_end_request(old_req, 0, + brq->data.bytes_xfered); /* * If the blk_end_request function returns non-zero even * though all data has been transferred and no errors * were returned by the host controller, it's a bug. */ - if (status == MMC_BLK_SUCCESS && ret) { + if (status == MMC_BLK_SUCCESS && req_pending) { pr_err("%s BUG rq_tot %d d_xfer %d\n", __func__, blk_rq_bytes(old_req), brq->data.bytes_xfered); @@ -1710,13 +1711,13 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) } break; case MMC_BLK_CMD_ERR: - ret = mmc_blk_cmd_err(md, card, brq, old_req, ret); + req_pending = mmc_blk_rw_cmd_err(md, card, brq, old_req, req_pending); if (mmc_blk_reset(md, card->host, type)) { mmc_blk_rw_cmd_abort(card, old_req); mmc_blk_rw_try_restart(mq, new_req); return; } - if (!ret) { + if (!req_pending) { mmc_blk_rw_try_restart(mq, new_req); return; } @@ -1758,9 +1759,9 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) * time, so we only reach here after trying to * read a single sector. */ - ret = blk_end_request(old_req, -EIO, - brq->data.blksz); - if (!ret) { + req_pending = blk_end_request(old_req, -EIO, + brq->data.blksz); + if (!req_pending) { mmc_blk_rw_try_restart(mq, new_req); return; } @@ -1777,7 +1778,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) return; } - if (ret) { + if (req_pending) { /* * In case of a incomplete request * prepare it again and resend. @@ -1788,7 +1789,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) &mq_rq->areq, NULL); mq_rq->brq.retune_retry_done = retune_retry_done; } - } while (ret); + } while (req_pending); } void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) From patchwork Wed Feb 1 12:47:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93019 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301284obz; Wed, 1 Feb 2017 04:49:14 -0800 (PST) X-Received: by 10.84.217.18 with SMTP id o18mr4186330pli.51.1485953354237; Wed, 01 Feb 2017 04:49:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b69si19054885pfk.235.2017.02.01.04.49.14; Wed, 01 Feb 2017 04:49:14 -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 S1750985AbdBAMtN (ORCPT + 5 others); Wed, 1 Feb 2017 07:49:13 -0500 Received: from mail-lf0-f51.google.com ([209.85.215.51]:34890 "EHLO mail-lf0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750971AbdBAMtM (ORCPT ); Wed, 1 Feb 2017 07:49:12 -0500 Received: by mail-lf0-f51.google.com with SMTP id n124so227408844lfd.2 for ; Wed, 01 Feb 2017 04:49:12 -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=zDYOtkRlGekN8mZHZKWSzR8kTc70vmMcmj9PXKzWVcw=; b=Iped04yacvAJTmXmUMs/b1W0vHdfeLgpi5zm9SQahDioltcQKD5iuI/dFEqwiP8ZZO w859f6FWAijvfC3dvoo008F+9CUobbuv0iOVNz0lrAQtArTQlhltjAIWZLsgOdI6B+/u rF8jKkxsCb5adXLHQ6VZmGuqdeSQnBVYYoydo= 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=zDYOtkRlGekN8mZHZKWSzR8kTc70vmMcmj9PXKzWVcw=; b=c5s4iSGPAlWrJ6aAzYxPXi9pY2jmkfaf/7JhaFexHWAlxJQtjG21awYqn0e1Sa9o5h +LLnHOdMFDueoQUwYiTx0B0hBF7bIv/04wMoh7jshTGtwbgnq4lt8CO3cfEF8q5i3GvZ XhNewTLdvEL09NAC2Q/pXmAqbTND/N1MumOPI4LsN/a+wecJgo5ZsMbfjTEPehCBlRI9 tLx5o/lrH7tQ5ujoPGEVpdY3HCKxbZB8z6UkD5GAa1ZCNY0xifo90OwH2pJyfjZPhi+s AKgO/mC8ExUoK1qwi9qgYdFmM4WGRAxxS47kRmkuPb/HCD3nvnv4hSLWI6+IzFsb0UFO Gf5A== X-Gm-Message-State: AIkVDXKBrpfGBCimyreS7ZDvqmO0lTQGa3E7zvZdw8/hvr6QObWDQdV5EkfrEBM5ZqiwPiWm X-Received: by 10.25.27.147 with SMTP id b141mr1048108lfb.183.1485953351246; Wed, 01 Feb 2017 04:49:11 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.49.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:49:10 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 09/10] mmc: block: return 0 where evident Date: Wed, 1 Feb 2017 13:47:59 +0100 Message-Id: <20170201124800.13865-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org mmc_sd_num_wr_blocks() has this construction: if (err) return err; if (some_other_stuff_not_touching_err) return err; It follows from logical deduction that we can just return 0 in the latter case. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 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 92f7772ca56d..c49c90dba839 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -788,7 +788,7 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks) if (err) return err; if (!mmc_host_is_spi(card->host) && !(cmd.resp[0] & R1_APP_CMD)) - return err; + return 0; memset(&cmd, 0, sizeof(struct mmc_command)); From patchwork Wed Feb 1 12:48:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93020 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2301302obz; Wed, 1 Feb 2017 04:49:17 -0800 (PST) X-Received: by 10.98.30.4 with SMTP id e4mr3381313pfe.19.1485953357698; Wed, 01 Feb 2017 04:49:17 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b69si19054885pfk.235.2017.02.01.04.49.17; Wed, 01 Feb 2017 04:49:17 -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 S1750990AbdBAMtQ (ORCPT + 5 others); Wed, 1 Feb 2017 07:49:16 -0500 Received: from mail-lf0-f50.google.com ([209.85.215.50]:35998 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750984AbdBAMtQ (ORCPT ); Wed, 1 Feb 2017 07:49:16 -0500 Received: by mail-lf0-f50.google.com with SMTP id z134so227869759lff.3 for ; Wed, 01 Feb 2017 04:49:15 -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=AQ3Nf9owyL3Ox1JI7aL0X6EPdk4hRXLg1fY3xRXCvw0=; b=TZW+xNMzzFd6n/ookWe5Tu3krR/9ViD8DwCyNwLlzipf3QIgnhYcT+ZNWlTOy1Utls MTT+cu9eI7Djf3J/2s5lwPhkKFMw2eFRhjG1iEDDSBd7IvSCtJyXTbGwQIH6iwQdsvlz giVg6PR7tNinF/83LfhWuHKbIwC05lwPn0xtM= 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=AQ3Nf9owyL3Ox1JI7aL0X6EPdk4hRXLg1fY3xRXCvw0=; b=rv8l6cFvFriLzoc44RJRCEzlcJ4sgiKvhua45zI3ov09AYRXfd0t2jHt01SBjzamG6 TXzmaVtDecpjorQpytgokGcIr6SBIcse3LIhRelbpnu80fgWBK+6l2mIffyosd97MIPK /SyP9/PMgUYLvHhOLggae7seIkOWP7d+Z3dd/+czNeTmei3fvS7BfLKDF2l6U3t0VSEp Yas0JTeaesi5rNDDzBjzKPgvhS97slYreaEJ3fT8+0253h9LBA0aJTa3eNiEESIhEvAF Yc6QX+6JFX+SaQFR29MVquvoOd/7C8kS2O6F03bYb3GVcZDFQJxmxNAZzCzXMVowWO4N UHmw== X-Gm-Message-State: AIkVDXJWzLNSlQN81R6B916RbxeGJxSQJf/hrZwk2/CLuQZ1YneCFcO0QWZDSf0aiHqLf8fh X-Received: by 10.25.221.193 with SMTP id w62mr985951lfi.169.1485953354450; Wed, 01 Feb 2017 04:49:14 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t126sm5707754lff.31.2017.02.01.04.49.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 04:49:13 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Linus Walleij Subject: [PATCH 10/10] mmc: core: start to break apart mmc_start_areq() Date: Wed, 1 Feb 2017 13:48:00 +0100 Message-Id: <20170201124800.13865-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201124800.13865-1-linus.walleij@linaro.org> References: <20170201124800.13865-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 function is doing to many clever things at the same time under too many various conditions. Start to make things clearer by refactoring: break out the finalization of the previous asynchronous request to its own function mmc_finalize_areq(). We can get rid of the default assignment of status and let the call deal with this. Signed-off-by: Linus Walleij --- drivers/mmc/core/core.c | 65 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 22 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/core.c b/drivers/mmc/core/core.c index a160c3a7777a..41b4cd01fccc 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -631,6 +631,37 @@ static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq, } /** + * mmc_finalize_areq() - finalize an asynchronous request + * @host: MMC host to finalize any ongoing request on + * @ret_stat: the status of the ongoing asynchronous request: + * will return MMC_BLK_SUCCESS if no request was + * going on. + */ +static enum mmc_blk_status mmc_finalize_areq(struct mmc_host *host) +{ + enum mmc_blk_status status; + + if (!host->areq) + return MMC_BLK_SUCCESS; + + status = mmc_wait_for_data_req_done(host, host->areq->mrq); + if (status == MMC_BLK_NEW_REQUEST) + return status; + + /* + * Check BKOPS urgency for each R1 response + */ + if (host->card && mmc_card_mmc(host->card) && + ((mmc_resp_type(host->areq->mrq->cmd) == MMC_RSP_R1) || + (mmc_resp_type(host->areq->mrq->cmd) == MMC_RSP_R1B)) && + (host->areq->mrq->cmd->resp[0] & R1_EXCEPTION_EVENT)) { + mmc_start_bkops(host->card, true); + } + + return status; +} + +/** * mmc_start_areq - start an asynchronous request * @host: MMC host to start command * @areq: asynchronous request to start @@ -650,7 +681,7 @@ 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; + enum mmc_blk_status status; int start_err = 0; struct mmc_async_req *data = host->areq; @@ -658,35 +689,25 @@ struct mmc_async_req *mmc_start_areq(struct mmc_host *host, if (areq) mmc_pre_req(host, areq->mrq); - if (host->areq) { - status = mmc_wait_for_data_req_done(host, host->areq->mrq); - if (status == MMC_BLK_NEW_REQUEST) { - if (ret_stat) - *ret_stat = status; - /* - * The previous request was not completed, - * nothing to return - */ - return NULL; - } - /* - * Check BKOPS urgency for each R1 response - */ - if (host->card && mmc_card_mmc(host->card) && - ((mmc_resp_type(host->areq->mrq->cmd) == MMC_RSP_R1) || - (mmc_resp_type(host->areq->mrq->cmd) == MMC_RSP_R1B)) && - (host->areq->mrq->cmd->resp[0] & R1_EXCEPTION_EVENT)) { - mmc_start_bkops(host->card, true); - } + /* Finalize previous request */ + status = mmc_finalize_areq(host); + + /* The previous request is still going on... */ + if (status == MMC_BLK_NEW_REQUEST) { + if (ret_stat) + *ret_stat = status; + return NULL; } + /* Fine so far, start the new request! */ if (status == MMC_BLK_SUCCESS && areq) start_err = __mmc_start_data_req(host, areq->mrq); + /* Postprocess the old request at this point */ if (host->areq) mmc_post_req(host, host->areq->mrq, 0); - /* Cancel a prepared request if it was not started. */ + /* Cancel a prepared request if it was not started. */ if ((status != MMC_BLK_SUCCESS || start_err) && areq) mmc_post_req(host, areq->mrq, -EINVAL);