From patchwork Wed Aug 1 09:36:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ludovic BARRE X-Patchwork-Id: 10551975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E573113BB for ; Wed, 1 Aug 2018 09:39:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1EE72A4D2 for ; Wed, 1 Aug 2018 09:39:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C31DE2A713; Wed, 1 Aug 2018 09:39:18 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 587652A4D2 for ; Wed, 1 Aug 2018 09:39:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4xL+EFBMspFgUIuxnmfF/dRP9BoKvPEuUXVSRFFro1w=; b=FUEDj+g9iI/IQD VdAPbRQ00ZRP1JSeru9Xp25zLE8EgYjsT6dynr15ii58FiyP5FN9tNnCQM+a0B8Dfz6kBZ03/Meq0 VpWuSkqdnoBdqkirDGqETVLxC4OUEf5d9hMLPmnBh+Ogz8LeccN+lu5BJ8AqWGsqBR8xiyG8SS+wp ncAi/c46ZVpFO1aasRMs0OaJps/DFK++V8EO6Von1THi9RjTbpwY/bLctYxoZ1cW5cRsoIuT/jH1e aBGHOUNkPysNKF7FDGBA1cJqJpq7L0k882vzKtHSmtBhD4JH1oYkC7xUqWCcggpBjY+C2FoSU1ZpO wvx1DlNp95ZDXMabazIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fknb5-0003Vd-2Z; Wed, 01 Aug 2018 09:39:11 +0000 Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fknZb-0001dB-PD for linux-arm-kernel@lists.infradead.org; Wed, 01 Aug 2018 09:37:46 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w719SXdo016573; Wed, 1 Aug 2018 11:37:26 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2kgdxvjux7-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 01 Aug 2018 11:37:26 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F26D931; Wed, 1 Aug 2018 09:37:25 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DB999288E; Wed, 1 Aug 2018 09:37:24 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 1 Aug 2018 11:37:24 +0200 Received: from lmecxl0923.lme.st.com (10.48.0.237) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 1 Aug 2018 11:37:24 +0200 From: Ludovic Barre To: Ulf Hansson , Rob Herring Subject: [PATCH 02/14] mmc: mmci: internalize dma map/unmap into mmci dma functions Date: Wed, 1 Aug 2018 11:36:49 +0200 Message-ID: <1533116221-380-3-git-send-email-ludovic.Barre@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533116221-380-1-git-send-email-ludovic.Barre@st.com> References: <1533116221-380-1-git-send-email-ludovic.Barre@st.com> MIME-Version: 1.0 X-Originating-IP: [10.48.0.237] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-08-01_03:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180801_023740_230323_83BBE12E X-CRM114-Status: GOOD ( 14.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Alexandre Torgue , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Ludovic Barre , Maxime Coquelin , Gerald Baeza , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ludovic Barre This patch internalizes the management of dma map/unmap into mmci dma interfaces. This allows to simplify and prepare the next dma callbacks for mmci host ops. mmci_dma_unmap was called in mmci_data_irq & mmci_cmd_irq functions and can be integrated in mmci_dma_data_error. Signed-off-by: Ludovic Barre --- drivers/mmc/host/mmci.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 1841d250..d8fa178 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -482,17 +482,7 @@ static inline void mmci_dma_release(struct mmci_host *host) host->dma_rx_channel = host->dma_tx_channel = NULL; } -static void mmci_dma_data_error(struct mmci_host *host) -{ - dev_err(mmc_dev(host->mmc), "error during DMA transfer!\n"); - dmaengine_terminate_all(host->dma_current); - host->dma_in_progress = false; - host->dma_current = NULL; - host->dma_desc_current = NULL; - host->data->host_cookie = 0; -} - -static void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data) +static void __mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data) { struct dma_chan *chan; @@ -505,6 +495,18 @@ static void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data) mmc_get_dma_dir(data)); } +static void mmci_dma_data_error(struct mmci_host *host) +{ + dev_err(mmc_dev(host->mmc), "error during DMA transfer!\n"); + dmaengine_terminate_all(host->dma_current); + host->dma_in_progress = false; + host->dma_current = NULL; + host->dma_desc_current = NULL; + host->data->host_cookie = 0; + + __mmci_dma_unmap(host, host->data); +} + static void mmci_dma_finalize(struct mmci_host *host, struct mmc_data *data) { u32 status; @@ -528,11 +530,10 @@ static void mmci_dma_finalize(struct mmci_host *host, struct mmc_data *data) mmci_dma_data_error(host); if (!data->error) data->error = -EIO; + } else if (!data->host_cookie) { + __mmci_dma_unmap(host, data); } - if (!data->host_cookie) - mmci_dma_unmap(host, data); - /* * Use of DMA with scatter-gather is impossible. * Give up with DMA and switch back to PIO mode. @@ -704,7 +705,7 @@ static void mmci_post_request(struct mmc_host *mmc, struct mmc_request *mrq, if (!data || !data->host_cookie) return; - mmci_dma_unmap(host, data); + __mmci_dma_unmap(host, data); if (err) { struct mmci_host_next *next = &host->next_data; @@ -742,10 +743,6 @@ static inline void mmci_dma_release(struct mmci_host *host) { } -static inline void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data) -{ -} - static inline void mmci_dma_finalize(struct mmci_host *host, struct mmc_data *data) { @@ -906,10 +903,8 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, u32 remain, success; /* Terminate the DMA transfer */ - if (dma_inprogress(host)) { + if (dma_inprogress(host)) mmci_dma_data_error(host); - mmci_dma_unmap(host, data); - } /* * Calculate how far we are into the transfer. Note that @@ -1055,10 +1050,9 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, if ((!sbc && !cmd->data) || cmd->error) { if (host->data) { /* Terminate the DMA transfer */ - if (dma_inprogress(host)) { + if (dma_inprogress(host)) mmci_dma_data_error(host); - mmci_dma_unmap(host, host->data); - } + mmci_stop_data(host); } mmci_request_end(host, host->mrq);