From patchwork Tue Jan 24 10:17: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: 9534777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 367696042D for ; Tue, 24 Jan 2017 10:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2740225D99 for ; Tue, 24 Jan 2017 10:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C1C026C2F; Tue, 24 Jan 2017 10:18:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5AC125D99 for ; Tue, 24 Jan 2017 10:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750952AbdAXKSV (ORCPT ); Tue, 24 Jan 2017 05:18:21 -0500 Received: from mail-lf0-f46.google.com ([209.85.215.46]:32874 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750940AbdAXKSU (ORCPT ); Tue, 24 Jan 2017 05:18:20 -0500 Received: by mail-lf0-f46.google.com with SMTP id x1so21440045lff.0 for ; Tue, 24 Jan 2017 02:18:19 -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=TLG/8Sbek+9PqeabAok0kUevFGjbn1kN0evrnvSBmGM=; b=Sj1Fa97MtObMn5SZ5jH0GdcpWEA4rTHFTNOCufzFaaxgFyf6hpTi70XEP/1A+OSPi5 xCvTWdK+VZ2P4EOt0/L2+lX9JiPFEJWe6NoxbN7rEwofvzvN5puYbcZYpQ+870rSSet0 rHJTBBLA0TIov51cNvUZpP698zrJk4LG3DoC4= 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=TLG/8Sbek+9PqeabAok0kUevFGjbn1kN0evrnvSBmGM=; b=a39Fygz+SFGDJd2M37COm7s7UzkHbya5SxxTPBqBteBe4WEDLH/4U3qj2uGgjj45D9 gqilDT6Wxda22yibCZqTVxRpxnTrGMSqeMA8UdV2muPJCOOYsJEENNs/FLOfQW0vWVBw Z4LROdq+6BoUNCMGDyk/b7OMuk6D6cJA1vmwVOpNsy2CJidx9lhqVeyP+A2fiE9ys/AK VyqIiKyhOPP7HRt9vE+mzmwODjPbLx4R2SdvnCrn19CK3JP7Ak246ntCab8gmkjN0uzl rUmfjmjV7uwZKcWT9AX9/xox5/2uUrZzpIVqpB5O9gx3P2Xs41EROzdTPdwqNFMO1OYW 2p1g== X-Gm-Message-State: AIkVDXLyZiE7uxNwtox9A330J0Mipsm3sNywCsEHrA0uOGjmLXbGZuQli6Ioe9L2ITgnS2H0 X-Received: by 10.25.104.20 with SMTP id d20mr10802715lfc.108.1485253098571; Tue, 24 Jan 2017 02:18:18 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o91sm7410797lfg.17.2017.01.24.02.18.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 02:18:17 -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: inline command abortions Date: Tue, 24 Jan 2017 11:17:55 +0100 Message-Id: <20170124101757.19676-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170124101757.19676-1-linus.walleij@linaro.org> References: <20170124101757.19676-1-linus.walleij@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Setting rqc to NULL followed by a goto to cmd_abort is just a way to do unconditional abort without starting any new command. Inline the calls to mmc_blk_rw_cmd_abort() and return immediately in those cases. As a result, mmc_blk_rw_start_new() is not called with NULL requests, and we can remove the NULL check in the beginning of this function. Add some comments to the code flow so it is clear that this is where the asynchronous requests come back in and the result of them gets handled. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 13e6fe060f26..4bbb3d16c09b 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1612,9 +1612,6 @@ static void mmc_blk_rw_cmd_abort(struct mmc_card *card, struct request *req) static void mmc_blk_rw_start_new(struct mmc_queue *mq, struct mmc_card *card, struct request *req) { - if (!req) - return; - if (mmc_card_removed(card)) { req->rq_flags |= RQF_QUIET; blk_end_request_all(req, -EIO); @@ -1649,9 +1646,8 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) !IS_ALIGNED(blk_rq_sectors(rqc), 8)) { pr_err("%s: Transfer size is not 4KB sector size aligned\n", rqc->rq_disk->disk_name); - req = rqc; - rqc = NULL; - goto cmd_abort; + mmc_blk_rw_cmd_abort(card, rqc); + return 0; } mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq); @@ -1660,11 +1656,20 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) areq = NULL; areq = mmc_start_req(card->host, areq, &status); if (!areq) { + /* + * We have just put the first request into the pipeline + * and there is nothing more to do until it is + * complete. + */ if (status == MMC_BLK_NEW_REQUEST) mq->flags |= MMC_QUEUE_NEW_REQUEST; return 0; } + /* + * An asynchronous request has been completed and we proceed + * to handle the result of it. + */ mq_rq = container_of(areq, struct mmc_queue_req, mmc_active); brq = &mq_rq->brq; req = mq_rq->req; @@ -1691,8 +1696,8 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) pr_err("%s BUG rq_tot %d d_xfer %d\n", __func__, blk_rq_bytes(req), brq->data.bytes_xfered); - rqc = NULL; - goto cmd_abort; + mmc_blk_rw_cmd_abort(card, req); + return 0; } break; case MMC_BLK_CMD_ERR: