From patchwork Sun Nov 11 13:45:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10677637 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 BB498139B for ; Sun, 11 Nov 2018 13:46:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9B2A2A7FE for ; Sun, 11 Nov 2018 13:46:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E6302A805; Sun, 11 Nov 2018 13:46:31 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 410D52A809 for ; Sun, 11 Nov 2018 13:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbeKKXfH (ORCPT ); Sun, 11 Nov 2018 18:35:07 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:59679 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728149AbeKKXfH (ORCPT ); Sun, 11 Nov 2018 18:35:07 -0500 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M7NaW-1gP8NO1Jmu-007mMT; Sun, 11 Nov 2018 14:46:06 +0100 From: Stefan Wahren To: Eric Anholt , Florian Fainelli , Ulf Hansson Cc: Phil Elwell , Michal Suchanek , linux-rpi-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/7] mmc: bcm2835: reset host on timeout Date: Sun, 11 Nov 2018 14:45:24 +0100 Message-Id: <1541943930-23873-2-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> References: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:lgrQbZyzXYrUsBpBHyKp6PXGL3aEuAUvGjwIdktVBODnetJqoOG tQ/5sBr/OzWLSD/lQpvRyR4UAE/phup+RYXqtXxq+nKugtiecCb5cRXZu6OwYg9Zna2RnUi YkfRt7kYsFQ4b+7T3XQI/SCSCpUBOYaZO7Y6IgkGZEZOuTGO1cxJvK7mpcXk7PL/icA5Ar2 vofBkgPZ/xxNhrpJ9RGmA== X-UI-Out-Filterresults: notjunk:1;V01:K0:Tj9bhOAtcSc=:Lf+y3NUKECYBYEekZvfH2O h/z8mbcM+3tSxYv1Y86s+i4eEWOMCBxrzuyAG97g3MWGeVDr90Ct4tonLrK4m5vZ57kIEJnwS FV6LsP2qJ/FXXmHkyBg+AW6eH/ey6vOe0m3Szzsu2UYvY5tpXV/Wb//Wu6X+gGjiIox8MsEF2 fcPaYjiYXaGK2OaVZJJbT8xxzjjhoSB/1pyzg/1bo9EnAucj9MXZawjLBg/3ykKpo41dHE17R r71ByhV1+S6f22NBXtKvhWbzUUziygsAZlvFPRFVqM9MNyeIHUwZFiAmbKfYuugepKoJ058Jc VKqqCwcQfG+lQCFIg0llKvy9lxvXi/q+LIW0ml4HqjRgULmJIEKmo1s2oHkyt+pV1rh5xsVS1 R8n8tsI1plhspcf1x+N3wSWcam0/jVkOwE55aoF5kTpTO8mv6Iq2r1VpHI7DI54Q0QaXVehUy uJKNy7jUUqq21IGdNtklkD5oZEUDLJn/FH0yilP4dLUF3SL3/pVnyxoG8i9ozUxhazrEhR1tP WuOuFRcyTOnAEO4FbPk/HC7xYt64wOgHo8p/XuXCl6Ta3bOSWIohZoQ7vY7GuX9iGkcRUKDz3 kLiMR/ztTD50Ao5iIMSnb7grpDXLGjHVnY0FP6wGj9kQiCjgikAAfAXLBXNFO0eDyK0rQvTSQ 1tplXktbCAFY85mugC9zSOUD9I4mzM7CU6ShsWXO6M+vU8ONPO8GWod9LbBoMkTeNaLcXU5KP Ots+3yEB4VUeWnIvbyn7CB6a43+8yQTRzhAqnAGJFIvsKyYk3xJ5Wy6hIa9cdeYCcP5Xb3IH8 0Lg5PsSYHKcP3Dlkm3GU2OO+WsIpw== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Suchanek The bcm2835 mmc host tends to lock up for unknown reason so reset it on timeout. The upper mmc block layer tries retransimitting with single blocks which tends to work out after a long wait. This is better than giving up and leaving the machine broken for no obvious reason. Fixes: 660fc733bd74 ("mmc: bcm2835: Add new driver for the sdhost controller.") Signed-off-by: Michal Suchanek --- drivers/mmc/host/bcm2835.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 768972a..f1712df 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -286,6 +286,7 @@ static void bcm2835_reset(struct mmc_host *mmc) if (host->dma_chan) dmaengine_terminate_sync(host->dma_chan); + host->dma_chan = NULL; bcm2835_reset_internal(host); } @@ -837,6 +838,8 @@ static void bcm2835_timeout(struct work_struct *work) dev_err(dev, "timeout waiting for hardware interrupt.\n"); bcm2835_dumpregs(host); + bcm2835_reset(host->mmc); + if (host->data) { host->data->error = -ETIMEDOUT; bcm2835_finish_data(host); From patchwork Sun Nov 11 13:45:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10677627 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 D2B271759 for ; Sun, 11 Nov 2018 13:46:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C35BA2A805 for ; Sun, 11 Nov 2018 13:46:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5A9B2A7FE; Sun, 11 Nov 2018 13:46:28 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 5915A2A7FE for ; Sun, 11 Nov 2018 13:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727594AbeKKXfE (ORCPT ); Sun, 11 Nov 2018 18:35:04 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:44147 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbeKKXfE (ORCPT ); Sun, 11 Nov 2018 18:35:04 -0500 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Md76B-1fnbNF2g3n-00aFcM; Sun, 11 Nov 2018 14:46:06 +0100 From: Stefan Wahren To: Eric Anholt , Florian Fainelli , Ulf Hansson Cc: Phil Elwell , Michal Suchanek , linux-rpi-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/7] mmc: bcm2835: Recover from MMC_SEND_EXT_CSD Date: Sun, 11 Nov 2018 14:45:25 +0100 Message-Id: <1541943930-23873-3-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> References: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:76f9kW/8sTA+tgiHPL430eP1IM2y6ZvGSzaTlEJK8D/yQou8Gi0 5aNVIkKlt1ZXnCl0dGdD8kl44J/XpyDx64aXAEN9Y900kKthUGHGRjIUlPs7pqlY5xYZyWY qryWkiETqueVF2t4sKAv+2YxPg/RyJDs0DQQgGp2dmsnDMSIGvLnsxdTEMrUuQTtv8SqvEn eB/WwaNygMjr+akQ9CebQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:C8VYy6LaVhA=:wO5WCfzvWze2KLB7YHlsAh TgrRc8UA2PqOcgo/z1YdpWCwnrthe3dR65qmLucQR5CQx/C2DbOt/BUs0AU6/of0vb/OK8F3G RTTHvA5hulrUQTsRs/1TQciZ8zTzgrL0PuZhKkTyTPK4NGct3qNnmKD2OUsqgVj6VROENKPDd uY0cB3ZDoBgrrPtFIClI6u9UThDunV9FR1F/hSedLJKNSF8du6H5aXDiGOYkKSESbOgykrHQC DCv5/OWhukd8WfFDmraTcAyyxVAyZZOokIGiYJLJtEYnhmy6k97ZsLHoDrxDqpsCESA/TgyJV vj5TyL5FyAguJbNJ0aPUNlFZI5bTPmg7PzNdnbckTXXRO5zrIfe0ZtJOTPsXtF5xEry/fnbyh fIxPdYluoEHxcP5pD3TUljoVCsudFaUfmgNscc0Mz+3eJrS+ECM5BOpzTGGEXEgOvm+MlRQri nnVEOYYp+ztI3NJm/64OUr/C2X6tYJCUjfb+FuIIY4QqV0uYZ54dxehjsAzYZBxJSmiPW5Ve/ AKiyjszs1iWxUxG60pTu8gkUm2FHSKt+oigfZI7ejXgw4jj9cQgKPDbucGRbDM8bv8jMNytr3 Yxt7cLrCmZPiksR4t8X7oyS/PeN9W7ROpcVlz4e4MJK6SxCfh6QjO1c16jCqCjKSnLhVK3Fyx 0Y8vsogeOaoHEgJR/LwCnkrSB1fby6cXzPvsXa1pBDOIPDeMa0Jzcobx5IDvKk+psbmSLLX8d Gr1W/UoQ8dY45pCvBjbcYfh+hWukG1acd9VZA95Y9DWRU+2jdGi+uqfkTnN7JCiIYSMTlv3lS MBYXM0MfcmX/tVgRnahpGsHZTuUQg== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Phil Elwell If the user issues an "mmc extcsd read", the SD controller receives what it thinks is a SEND_IF_COND command with an unexpected data block. The resulting operations leave the FSM stuck in READWAIT, a state which persists until the MMC framework resets the controller, by which point the root filesystem is likely to have been unmounted. A less heavyweight solution is to detect the condition and nudge the FSM by asserting the (self-clearing) FORCE_DATA_MODE bit. Link: https://github.com/raspberrypi/linux/issues/2728 Signed-off-by: Phil Elwell --- drivers/mmc/host/bcm2835.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index f1712df..a251be2 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -773,6 +773,8 @@ static void bcm2835_finish_command(struct bcm2835_host *host) if (!(sdhsts & SDHSTS_CRC7_ERROR) || (host->cmd->opcode != MMC_SEND_OP_COND)) { + u32 edm, fsm; + if (sdhsts & SDHSTS_CMD_TIME_OUT) { host->cmd->error = -ETIMEDOUT; } else { @@ -781,6 +783,13 @@ static void bcm2835_finish_command(struct bcm2835_host *host) bcm2835_dumpregs(host); host->cmd->error = -EILSEQ; } + edm = readl(host->ioaddr + SDEDM); + fsm = edm & SDEDM_FSM_MASK; + if (fsm == SDEDM_FSM_READWAIT || + fsm == SDEDM_FSM_WRITESTART1) + /* Kick the FSM out of its wait */ + writel(edm | SDEDM_FORCE_DATA_MODE, + host->ioaddr + SDEDM); bcm2835_finish_request(host); return; } From patchwork Sun Nov 11 13:45:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10677625 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 B8C4E139B for ; Sun, 11 Nov 2018 13:46:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8FF82A7FC for ; Sun, 11 Nov 2018 13:46:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99A582A809; Sun, 11 Nov 2018 13:46:28 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 3837A2A7FC for ; Sun, 11 Nov 2018 13:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728120AbeKKXfE (ORCPT ); Sun, 11 Nov 2018 18:35:04 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:46195 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727594AbeKKXfE (ORCPT ); Sun, 11 Nov 2018 18:35:04 -0500 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MqINP-1fj9On496x-00nT1i; Sun, 11 Nov 2018 14:46:07 +0100 From: Stefan Wahren To: Eric Anholt , Florian Fainelli , Ulf Hansson Cc: Phil Elwell , Michal Suchanek , linux-rpi-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH 3/7] mmc: bcm2835: Release DMA channel on driver unload Date: Sun, 11 Nov 2018 14:45:26 +0100 Message-Id: <1541943930-23873-4-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> References: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:F2LiMthsBSJ3s1DS3kJl7n5PIcWL+Ao+GBaQlR8S0uGJOiiO8Pw cJJANMzHi+H6Jk02RI/4+pRGp13kuxo/zu5Gca6kyhNwDO5dgJ+CfndbvzgFfJhIPk1bov8 2+eMpF/J2afvG2GNlrtdxVnBE6ScIYWZ4WLvsuIf/LRAnSnEx059ImmryYhNNqPbDE9pxwk Cg+WVcneQkMTHusnA4ThA== X-UI-Out-Filterresults: notjunk:1;V01:K0:BMnnZiRNwFM=:VK18LVcikWkwCb6PWU6dtZ jhso2h+IWk1AyfzelKucsqojg0Hig2iuBvh4dloZcPfLYSIgzzf3pGigEm7bTcVrn4c66Wb3a b6cmsRMakTF9KYxai93XGH5lOF7whiOquDuxUbsC78aRFJieEMYFo05jIay86AhtoE/XzwJr9 2TeUvl1qZcyQY60A1nb5Fx+CKBZVOiPbpVAGk+2t5+k7/zcmoWKWRNgsHTOiidINlWPiGettk jCnHsWb6xCeB/Vp52Kkg8B6p30sx1XgeHM9onnsMGcVqrFCoSB1/BYfriHniJ7suqCq942P/z fWCN36Nr/iFyPSO2gKJoR7XILC2yzWPqTcDx19HOKHGt8Mocmmp2GUgUC4rVWvvRlZ1e5J3Ju 0EpqkddWy2BKe5u39POlQqy1LK1xIeYVW4dlQcWfTjYsawhT/TcEbS9yst3iSd+Hrv6IzUbGL CrG4AQjYj7cLA76aRd4JlJaW/adj23QRi+EdAvhEFWiq1F+s/N4X/uXwXWO2H1SVqLGnAVmUC dknJ+0dXm9kF0puj4emLpF9QT7Ec/c87k+Y0iXDjexcjBdIJuJ3kbGGi+dmmH+qGQQ3XhW7/c H66jlf8FoxuIcaKl/kHYWrpdyq24T+4hy0/xr5OgIkf8BHTBvdNU57pDL/IIbZ5OCT0QFo8x8 PvybVElOdNwk4Rkhcmu5IFT6SyyqaPuTYyhQ4txqAoLIFBul3I4YNdyxwb7E8CQr9JbyKJgpv XNX6wsoh8yTzVNCuhgf71IkYXDHkdnNZyTblwqf+GtDkJ89t6khKXUowoZ7vqldz7JMeuMOIt V8423aPXL8FoPidUum64l0MnEmgNg== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to release the slave DMA channel during driver unload. Signed-off-by: Stefan Wahren --- drivers/mmc/host/bcm2835.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index a251be2..45724ef 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -1457,6 +1457,9 @@ static int bcm2835_remove(struct platform_device *pdev) cancel_work_sync(&host->dma_work); cancel_delayed_work_sync(&host->timeout_work); + if (host->dma_chan_rxtx) + dma_release_channel(host->dma_chan_rxtx); + mmc_free_host(host->mmc); platform_set_drvdata(pdev, NULL); From patchwork Sun Nov 11 13:45:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10677635 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 4D12114E2 for ; Sun, 11 Nov 2018 13:46:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DC2D2A7FC for ; Sun, 11 Nov 2018 13:46:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31D782A805; Sun, 11 Nov 2018 13:46:31 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 CD08F2A7FC for ; Sun, 11 Nov 2018 13:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728158AbeKKXfH (ORCPT ); Sun, 11 Nov 2018 18:35:07 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:45797 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbeKKXfH (ORCPT ); Sun, 11 Nov 2018 18:35:07 -0500 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MmyzH-1ffs9A1Vg7-00kBEY; Sun, 11 Nov 2018 14:46:07 +0100 From: Stefan Wahren To: Eric Anholt , Florian Fainelli , Ulf Hansson Cc: Phil Elwell , Michal Suchanek , linux-rpi-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH 4/7] mmc: bcm2835: Avoid possible races on data requests Date: Sun, 11 Nov 2018 14:45:27 +0100 Message-Id: <1541943930-23873-5-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> References: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:KWB6kUDC6PK+zr0Txk3LnIPqOB1mHiyDDpRX02xMmXpkye1u2ej XxLoNiy8h/6NpRX4kx4ptBvN2WnuQUbIcKRRap+SSmrJpZokC/eUZ4U3fRX00oT59JnCGTO R1CA+R56LznLPEncwoEnwrgNU6Y3Oo73Kk0ZQuYi25OnfOIIs6LhQwLFOs89NYq0oyj6mG5 3+HVT2+wsWa+1POvTSK2g== X-UI-Out-Filterresults: notjunk:1;V01:K0:GdGUkT90e2g=:lN8ROZoWnHbE4vpBdV5hcX MO4meNL5Ac62ZC0xEORLG84CMl4jD/fhf8Hbz+wmtpP57vGgVpbtLN7u2ksdXnVVSz5fcT40d igwnY9Fqo/XtLgpTT0eaJsGuwnsdVLSjcco5SJ2DVnlKnLQB4CJkS5Wr5WTTytMaM62sST9I2 Xd7XtDQf36+qSF9cfBLrGUcknYupHcoaZg4mzAU6rkYSCa5aiKJKbxUlR9TwyOGZbefBFX3hx C1Tr3HIuXKGDWJLBlXjjtyWHpCwccwN4nPUm9IaVSFSzf6paVfJe04MykTstyYl9V2u8lRfTU m+7VQW3shlXRSxg7xh63Bxz0b0qMq+UBx6a/MlSmjo5J9sgBNW1iZ9rPSlGf5vf5/xiRcM+42 dEf+Rm43UfvXLEw+yQH0FJ5sJFX4LinumJoSRIv9U0bgPBcqm9iWDZatHZZ+LyciWK7yzANyW gguGJjhaTAI/gcK7LecAAxaiT4vt2JapTVJ4ffT6E6OkyDPCRbYzX0XupBtuip59Qg84XVYko FuCwPwxeScKGjAHuB2K42MqEGOBeHWVpX1M83FzOA9MqKZruQRMwyLfJjprWoW56VQD34xE71 MHT56/QWsvC9mmOezcB5DyiRVEC0RdY5dcNnNseQCxTknsT7xvrFEmp8fwigf1ff5eciQNNrc duHGC1spzq1Us2ca5zED6OGKrFB7wSSQ0Sn7zW6IhsN0y9nLUxOlINR2cIOz4yoQWCF/poDWZ YMvHaxsPWjXfpxNn0S56akFQ01dy3vFHIbgeJ7HzR0FkqXzxtnCnJAB8V1HZX9ju1gZbsxpmu WcC4JMNYVPp3YifiYltvTZBDag4PA== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are two accesses on the data requests which are not protected by the mutex. So fix this accordingly. Signed-off-by: Stefan Wahren --- drivers/mmc/host/bcm2835.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 45724ef..1c60798 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -1064,10 +1064,12 @@ static void bcm2835_dma_complete_work(struct work_struct *work) { struct bcm2835_host *host = container_of(work, struct bcm2835_host, dma_work); - struct mmc_data *data = host->data; + struct mmc_data *data; mutex_lock(&host->mutex); + data = host->data; + if (host->dma_chan) { dma_unmap_sg(host->dma_chan->device->dev, data->sg, data->sg_len, @@ -1192,9 +1194,6 @@ static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq) return; } - if (host->use_dma && mrq->data && (mrq->data->blocks > PIO_THRESHOLD)) - bcm2835_prepare_dma(host, mrq->data); - mutex_lock(&host->mutex); WARN_ON(host->mrq); @@ -1218,6 +1217,9 @@ static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq) return; } + if (host->use_dma && mrq->data && (mrq->data->blocks > PIO_THRESHOLD)) + bcm2835_prepare_dma(host, mrq->data); + host->use_sbc = !!mrq->sbc && host->mrq->data && (host->mrq->data->flags & MMC_DATA_READ); if (host->use_sbc) { From patchwork Sun Nov 11 13:45:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10677633 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 C499B139B for ; Sun, 11 Nov 2018 13:46:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5A0D2A7FC for ; Sun, 11 Nov 2018 13:46:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9BD42A805; Sun, 11 Nov 2018 13:46:30 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 627532A7FE for ; Sun, 11 Nov 2018 13:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728131AbeKKXfG (ORCPT ); Sun, 11 Nov 2018 18:35:06 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:58957 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728138AbeKKXfG (ORCPT ); Sun, 11 Nov 2018 18:35:06 -0500 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MCXhr-1gDpSG320p-009kYQ; Sun, 11 Nov 2018 14:46:07 +0100 From: Stefan Wahren To: Eric Anholt , Florian Fainelli , Ulf Hansson Cc: Phil Elwell , Michal Suchanek , linux-rpi-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH 5/7] mmc: bcm2835: Terminate timeout work synchronously Date: Sun, 11 Nov 2018 14:45:28 +0100 Message-Id: <1541943930-23873-6-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> References: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:bMlj+GM88ahd403xW2lLcKera75DTba10rh3dFA20sdZzWmiSvS cVrCv+2GdoEOclegSlmIFf5noJ0zWdaVlIu/oqA+E0k8h8eGucns2ufBhkTVQrXl7oNdNcm RQapf7BJe/ZEV7aguWykyrEpvDWRagQyUu4lujC3cf2n1P1OKwoGd8QiXnu/4wFSfTjy5ec toy6ZAucyk36XND3epU1w== X-UI-Out-Filterresults: notjunk:1;V01:K0:TPCjt8tLY5Y=:lHXLk6d5fwxIZNxyBu6z4r OpWxogRS3MCWK6Xa/oEY3uItiMGq7XYh/Z5krFO35m78+lxYbNFWD5/i1iUT9OhZ14exuhFiP GDhVWgii87qICysYc3bfsd3+Do0ArqKBa70HWyu/86+c3heiDGiv4JvaPLnTF0BM9+6WA6wFk /KCsqSpXwiC7+PNDnU491RFcb3k+PaBrANuQbt6byOu07MfeE0SFuf8dnh9PIfoZ5cIRsRQT9 3lGuZSgCZa9P5deN7d2a3tBCg2XiwtJ0BPSttU9J3w7KSWNgDRRDrmy2MqOvnGpjihBl6jI9b TkyzB+fbaHN+ogUkKoK5JKoaXm7xOUxT2oaYfcGjgLHXC6iw4ArRge5EZywZnI7wAclkatmzR eOuSKIlekmphObOUn0z40WB5Axu38aA1cx36rt84eGDlQHiu9EakT2xZF630j5zvWnL7/j4MR GgST0KL4R7ZC8FYwfTiIRrU5EIO2Gdt51YUsgDJtNQ2M12ukscE8d1uRdibyCnNoxYJRRq1NT x+hYAhCv9O80idOeHFhjGtkO+IXeLjyfHS47FK6kufjC4Aj7701Kp7nSwqU6tn6EVXK1WbA4n RMu7vSiS1IP7KMyYU6H4a8Iso0D4YPzuw88YXOJ2+nffNqExp/qSoAn3dkdgBjHZDyqUFFnNq DnvvpIL6MtvbL6Gwh3EzodMbpFzoYp8XPC79Te9BFtbnHkgW9GmhyHeNZkKf/VkD9hwyDbd5p KV+lk9hS0K4g9+W6BNjjWMt7bvowvoE2/ajjctEr2v+Kv/ShdjeM74VdqKE1VGmPctiN/n9Yt nCQ+3ZzqvYPws1KmpiLiFKPRtaH6A== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It's better to make sure that the timeout work is really terminated before calling mmc_request_done. Signed-off-by: Stefan Wahren --- drivers/mmc/host/bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 1c60798..2c7589f 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -608,7 +608,7 @@ static void bcm2835_finish_request(struct bcm2835_host *host) struct dma_chan *terminate_chan = NULL; struct mmc_request *mrq; - cancel_delayed_work(&host->timeout_work); + cancel_delayed_work_sync(&host->timeout_work); mrq = host->mrq; From patchwork Sun Nov 11 13:45:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10677629 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 237FB14E2 for ; Sun, 11 Nov 2018 13:46:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10CAF2A7FC for ; Sun, 11 Nov 2018 13:46:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE4F12A805; Sun, 11 Nov 2018 13:46:29 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 9A5FB2A7FC for ; Sun, 11 Nov 2018 13:46:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728154AbeKKXfG (ORCPT ); Sun, 11 Nov 2018 18:35:06 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:41049 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbeKKXfF (ORCPT ); Sun, 11 Nov 2018 18:35:05 -0500 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MTw02-1fw1TO0NOs-00R0I3; Sun, 11 Nov 2018 14:46:08 +0100 From: Stefan Wahren To: Eric Anholt , Florian Fainelli , Ulf Hansson Cc: Phil Elwell , Michal Suchanek , linux-rpi-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH 6/7] mmc: bcm2835: Refactor dma_map_sg handling Date: Sun, 11 Nov 2018 14:45:29 +0100 Message-Id: <1541943930-23873-7-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> References: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:d3Tlag//fzN+r6VUXOfa/hYFl1CzjBhy4W+IJDTV99QGOCq9sMk +Qy2CwxBqWlL+khwA1mlX7upfhWqoNz1KRlqVlahzayY7b+C1hgpM8U47o7e86it2OAZDHu 4ixUwjsT2ApeKwTWodi88mSst/FERzHGCyzZ3c+5K2TvyTVaj7jhcdWoPEANdL5OPi0O0Nn i52hXDv6C5xn4i6/6/qnw== X-UI-Out-Filterresults: notjunk:1;V01:K0:90h34Am4Il4=:w3fhkSkiyYcV5tdMFDL652 pvAbOsIsX2+t7VG0KbHvis4eVv9RV4UX423+yKEz/BxwCG/liqf3utL2ZN0g8ATdEIPpJJYjI spX6YKPtGPo79GH8f13sneR0v3qhDQRXMmK7ql3hGIxeRdzQyxGzwx/fz6Nn5xfdTYD5miKaY xK5OUsuViw+i6PXXZjhqpbSF7S+8kJ02/LUf6P9NNey21J5Xm60lQpkovIEGC5up0oUpqpU46 DGwn+EGc5nU8sdF49fNSKN99+50rhuN2ztZBrYLB+XUxzem5M2JIlQbC9sCJw4oRYhGdBLCsN lbwzYaewDCTOXmC1jk9MczYAkK534H1Hzh90U987Y/fDyeTbHDb5PXWwOuYer9yaKPZwY286f elYd7eMal3oWNyJLRQ9GdL7Ay6JHPRgobndprOCVxwL/34GyVJSmtio4iCo0q1aH+vn3w/n7+ 3Ua9XtBuCrfM7cf66e1ohKvoE+2HAjuiSog7IBmpV2/IQPHusZLWMyl13nysUSav29NM61SmN D7nt5y7mJFOB3WziLwFHxxqCOAlk0+6gMGbz7LYqdy7yNS+cgi/euWNgqRrjvJGdjWj5u8aCb B6X21EvGLcrCA23tNzx7lp6eiBVeD/M8GEdOcEwtSM0OEg7ojpxVx6nhtCW0L8sI4oxgGRXOj uobE5+rEAwmtot+uZnthEHSfuTNZRc7HtB8JgNxR4g2IkXb8rHQlClLSKC7WD6oenskLP3BJt fab8gHURQTes6cekUZzWEjhOkKLMxj3rA78GLzYkbPE+rNC2IkSXW4ZTlC0Sh477d1F3DCh/m lesq6tm9XfL8wMuBfr/wDrsu5gANQ== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are two variables len within bcm2835_prepare_dma. So rename the result of dma_map_sg to sg_len. While we are at this add a bail out to simplify the following change. Signed-off-by: Stefan Wahren --- drivers/mmc/host/bcm2835.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 2c7589f..c42bdaa 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -464,7 +464,7 @@ static void bcm2835_transfer_pio(struct bcm2835_host *host) static void bcm2835_prepare_dma(struct bcm2835_host *host, struct mmc_data *data) { - int len, dir_data, dir_slave; + int sg_len, dir_data, dir_slave; struct dma_async_tx_descriptor *desc = NULL; struct dma_chan *dma_chan; @@ -510,15 +510,13 @@ void bcm2835_prepare_dma(struct bcm2835_host *host, struct mmc_data *data) &host->dma_cfg_rx : &host->dma_cfg_tx); - len = dma_map_sg(dma_chan->device->dev, data->sg, data->sg_len, - dir_data); + sg_len = dma_map_sg(dma_chan->device->dev, data->sg, data->sg_len, + dir_data); + if (!sg_len) + return; - if (len > 0) { - desc = dmaengine_prep_slave_sg(dma_chan, data->sg, - len, dir_slave, - DMA_PREP_INTERRUPT | - DMA_CTRL_ACK); - } + desc = dmaengine_prep_slave_sg(dma_chan, data->sg, sg_len, dir_slave, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); if (desc) { desc->callback = bcm2835_dma_complete; From patchwork Sun Nov 11 13:45:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10677631 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 A683E1759 for ; Sun, 11 Nov 2018 13:46:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 980732A7FC for ; Sun, 11 Nov 2018 13:46:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C9F82A809; Sun, 11 Nov 2018 13:46:30 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 3806F2A7FC for ; Sun, 11 Nov 2018 13:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728155AbeKKXfG (ORCPT ); Sun, 11 Nov 2018 18:35:06 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:50751 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728131AbeKKXfG (ORCPT ); Sun, 11 Nov 2018 18:35:06 -0500 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MzkK9-1fZuHR1vGL-00vcE0; Sun, 11 Nov 2018 14:46:08 +0100 From: Stefan Wahren To: Eric Anholt , Florian Fainelli , Ulf Hansson Cc: Phil Elwell , Michal Suchanek , linux-rpi-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH 7/7] mmc: bcm2835: Properly handle dmaengine_prep_slave_sg Date: Sun, 11 Nov 2018 14:45:30 +0100 Message-Id: <1541943930-23873-8-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> References: <1541943930-23873-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:54rqvPvEJMg6uQprsdz7iyx7yJMMG3A8m7WUuzUgaF22ruxistr WqKhCUBqaTzloC0arYM7OUjSsaGOr0/lmZtsEUAU1aj0DjB9uC4i42d5q+RU0THQrxFUVcp lTkRwH13TKmMdXlM6OvLwsaGhtxNzWLiIkk+eazut5WzBOnXE7DBduJEnINcr4RVYWxIZ5u 6nBobScxk9l+OK/AHRUxQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:6cTkia0Hcc8=:cFG2N8hCLUc3d8Au2MZAt3 d7eA6bXqOy+KzjbJlxc3JY1zDSIGUFWFrKR/yPjJzDsDz5l4y48ThVklXrhI8b/GhcGn/3uqT mGvOaDUbuCpqJsQaIEnxIKQ89x5gMq3aa8PMIHbrosTguCtjMJaBXoiXPAo+JvkRhiZBmdWDG RuPaaCAvtgEGLUzmwaRgT99V7vtKc+NNwEDXUdSpD7HTGHfL/NwAZNMcMAlmJmyuDQvLrwUJz owjI00NrtEnMDugzzl0sorCmZ/9N5KyLiLH+GMMiLGpmh/NnX9Y2i/SXwe902rf83WDmSMDSk dmUmJCxEThk+XrqNuHeknOKVmBpNENB+xWuVNoCax0q0327mfQsvaz0ijjrUuW/vFN7aQhBDQ S2/z4bqAPH3ggcXJm5hfRqpVsKDyKPwfODBjgowlfTomNphkllC2NOSJIWfwEfSrMwxsh+7RT sHMJJe7cOIMifvDnTxJV8Nw4umDgL+NX5HDpxZKrSXyRjFbVcx/O0yjtu2jgETKejrBJRtxVm zL7HbgkkjBGWtN6gAIzO1elksPev2H+bPcgIUOIgsdiy/0p09I2Jci7wfSY9jr72YDpxOoIIs ICMF963TgO5U2LmxUYcRH2X4C0asZTLyybYUOiDh8vbeJ0lYVYZdIILwqPwUV2IW16d3JnLFK kqnPAYVSeP13deUX6V1HkNJvfp8IPv0YkfYNmCtGYK0ARE4yp05iKj/2HrmerU8sZmmnC0X1G haCXGrIAv/yvX+jkG8TBgHnOY5ALbVM0z/2dfpkuMpOeYXUKM+3XY1ZOT9PrCkhuOqncOiH/C kZ/ruEv+eqnLDODL4dhNQCanjtlAw== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case dmaengine_prep_slave_sg fails we need to call dma_unmap_sg. Signed-off-by: Stefan Wahren --- drivers/mmc/host/bcm2835.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index c42bdaa..82e4b08 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -518,13 +518,16 @@ void bcm2835_prepare_dma(struct bcm2835_host *host, struct mmc_data *data) desc = dmaengine_prep_slave_sg(dma_chan, data->sg, sg_len, dir_slave, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); - if (desc) { - desc->callback = bcm2835_dma_complete; - desc->callback_param = host; - host->dma_desc = desc; - host->dma_chan = dma_chan; - host->dma_dir = dir_data; + if (!desc) { + dma_unmap_sg(dma_chan->device->dev, data->sg, sg_len, dir_data); + return; } + + desc->callback = bcm2835_dma_complete; + desc->callback_param = host; + host->dma_desc = desc; + host->dma_chan = dma_chan; + host->dma_dir = dir_data; } static void bcm2835_start_dma(struct bcm2835_host *host)