From patchwork Thu Feb 9 15:33:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 93732 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp94380obz; Thu, 9 Feb 2017 08:04:10 -0800 (PST) X-Received: by 10.99.99.193 with SMTP id x184mr4919670pgb.226.1486656250008; Thu, 09 Feb 2017 08:04:10 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si10423738pgd.21.2017.02.09.08.04.09; Thu, 09 Feb 2017 08:04:10 -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 S1753236AbdBIQDy (ORCPT + 5 others); Thu, 9 Feb 2017 11:03:54 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:35993 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753215AbdBIQC3 (ORCPT ); Thu, 9 Feb 2017 11:02:29 -0500 Received: by mail-lf0-f49.google.com with SMTP id z134so4986455lff.3 for ; Thu, 09 Feb 2017 08:01:33 -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=zpo1FToSBpBvfHHhnkf81Tj6PC2sUnNwEoAoOM32ODQ=; b=Rvdq/jG7XrmbNFUc0efzL8jHldvcn4J2QyzHPynsHIqzuR4qcOMtOd4ZtxYDjDgdPA OnvlpWgs1XwgI15jGnR/0Y9FK3A7qEN8kajblnuYERxMvPVQxsx7qyzHmnOd/rHjKAlP Zm2d+PVaA5gyRCIbeQu6eOOu0rkwU5CIgyXmo= 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=zpo1FToSBpBvfHHhnkf81Tj6PC2sUnNwEoAoOM32ODQ=; b=UUtF5jWW3BJHQ4zwvT8Zlr3sW/+fm+afpYSo0cz8hgyQTTMe6dW1HMWDZPCHsjyqkl E5+UF3CeluzPbO23hbf9QuuUN90vRrQOu5JNbvtL/O7nfV+0Me3VeKkH7LnzL59GDJOA z5GcNmTMc9JGqEV8e8tB7zdbsJApvkS3nHvQsRfWzTO89e+MN/iGYOrtFtHq0lRtKkrT 0yalqg3/v/rx/XPBEwvc/kdWfH1Z3a26C22mmnvdamGN0ciaYP10ZCissuyQgv7q9vZP UKWqoIYvAraXI4WZ6uz3Iv6iblnct5xk+ANkG/kwgnsULd/wDyGE00F3l4sbp9oaIoUe m0rA== X-Gm-Message-State: AMke39majtAOzR2VUmJ0u9BiH+fIJobe2/wa1rLjtLSuzqzD3qDFWs2Arh/uXsQjxiV7crHU X-Received: by 10.46.7.25 with SMTP id 25mr1463461ljh.41.1486654473926; Thu, 09 Feb 2017 07:34:33 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e86sm3670614lji.32.2017.02.09.07.34.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 07:34:32 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Paolo Valente Cc: Chunyan Zhang , Baolin Wang , linux-block@vger.kernel.org, Jens Axboe , Christoph Hellwig , Arnd Bergmann , Linus Walleij Subject: [PATCH 02/16] mmc: core: refactor asynchronous request finalization Date: Thu, 9 Feb 2017 16:33:49 +0100 Message-Id: <20170209153403.9730-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170209153403.9730-1-linus.walleij@linaro.org> References: <20170209153403.9730-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_wait_for_data_req_done() is called in exactly one place, and having it spread out is making things hard to oversee. Factor this function into mmc_finalize_areq(). Signed-off-by: Linus Walleij --- drivers/mmc/core/core.c | 86 +++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 53 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 Reviewed-by: Bartlomiej Zolnierkiewicz diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 53065d1cebf7..b2e7a6dfcbf0 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -485,56 +485,6 @@ static int __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq) return err; } -/* - * mmc_wait_for_data_req_done() - wait for request completed - * @host: MMC host to prepare the command. - * @mrq: MMC request to wait for - * - * Blocks MMC context till host controller will ack end of data request - * execution or new request notification arrives from the block layer. - * Handles command retries. - * - * Returns enum mmc_blk_status after checking errors. - */ -static enum mmc_blk_status mmc_wait_for_data_req_done(struct mmc_host *host, - struct mmc_request *mrq) -{ - struct mmc_command *cmd; - struct mmc_context_info *context_info = &host->context_info; - enum mmc_blk_status status; - - while (1) { - wait_event_interruptible(context_info->wait, - (context_info->is_done_rcv || - context_info->is_new_req)); - - if (context_info->is_done_rcv) { - context_info->is_done_rcv = false; - cmd = mrq->cmd; - - if (!cmd->error || !cmd->retries || - mmc_card_removed(host->card)) { - status = host->areq->err_check(host->card, - host->areq); - break; /* return status */ - } else { - mmc_retune_recheck(host); - pr_info("%s: req failed (CMD%u): %d, retrying...\n", - mmc_hostname(host), - cmd->opcode, cmd->error); - cmd->retries--; - cmd->error = 0; - __mmc_start_request(host, mrq); - continue; /* wait for done/new event again */ - } - } - - return MMC_BLK_NEW_REQUEST; - } - mmc_retune_release(host); - return status; -} - void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) { struct mmc_command *cmd; @@ -639,14 +589,44 @@ static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq, */ static enum mmc_blk_status mmc_finalize_areq(struct mmc_host *host) { + struct mmc_context_info *context_info = &host->context_info; 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; + while (1) { + wait_event_interruptible(context_info->wait, + (context_info->is_done_rcv || + context_info->is_new_req)); + + if (context_info->is_done_rcv) { + struct mmc_command *cmd; + + context_info->is_done_rcv = false; + cmd = host->areq->mrq->cmd; + + if (!cmd->error || !cmd->retries || + mmc_card_removed(host->card)) { + status = host->areq->err_check(host->card, + host->areq); + break; /* return status */ + } else { + mmc_retune_recheck(host); + pr_info("%s: req failed (CMD%u): %d, retrying...\n", + mmc_hostname(host), + cmd->opcode, cmd->error); + cmd->retries--; + cmd->error = 0; + __mmc_start_request(host, host->areq->mrq); + continue; /* wait for done/new event again */ + } + } + + return MMC_BLK_NEW_REQUEST; + } + + mmc_retune_release(host); /* * Check BKOPS urgency for each R1 response