From patchwork Sun Nov 11 20:23:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10677863 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 3D4A8139B for ; Sun, 11 Nov 2018 20:27:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EABA296EB for ; Sun, 11 Nov 2018 20:27:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FAB5296FF; Sun, 11 Nov 2018 20:27:08 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham 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 C63FC296EB for ; Sun, 11 Nov 2018 20:27:07 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=w0gGu0RhdppnbHj+KC4eiYbqQi5jIFFj1vOCHvG7izk=; b=tSzVsJXA7bK2/gIIVp574/SFNR BgvzhxZLA/OEkfPjbtzn6g7PhFHNYCY2tQT1NfP01NxDvDzgZB5TEcCqtrdjkJY0i0hpHS4Ex0SKr oIYr7vZFZc3vcWcO/KC3Kmo+a6lT7nBNDddf/cXDJPS/+jOqm/QCf5ho2YvSATxAnxwgnSi60ZaUO pr/6gai+PjYKpQFZOL6myQ0sWfTTlc1l2KdBGjXV/FLp6EVuwbVOO3xUNJ1ZRnY8Ku/4Hq7tVTYWO oO45AJ1T+qe7lz9G/rfVbqXsnK8JZyhgubhZJXPRWAvoOGj1HIYGAwyOM4bKBfJn6LnKp6+bosthz AN9aGK6g==; 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 1gLwK1-00061u-1u; Sun, 11 Nov 2018 20:27:05 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLwHw-0002d9-OE; Sun, 11 Nov 2018 20:24:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6Y3NNECHfTEnbE17TZ4lEpf9LD6uJsc6TH5WZfUfuzk=; b=HvhoptR8U2ubhwrWMzaTVnGQy II2zx46KApZRWsxtYONLMA5cwNuCa0IlO7pyZ2xzkmkvg3l9zY9tw0FIFvHHLhMUBT2QfLdXX47QA 4IwFzcW0ZPkm1/jCaDHb+fjCb+4AHHBAae4C6MrN7+a6ykIfhqgPkEfTtZGdhAnxrTbMDTMhgqs3I bSMEifAlxhV0ZMu8SNVAZNB1lgRsdsdgdcBY/t248mQgHc6o2D2ibCGnSYHMy8xjLjNIN2UHatXZf O+ebwk3ljy5b6FcEOHgg0bOh3eTwjGlbh9jR06jAx95wa7gOJG7bJO2mLb1Q0TEg4O/jdMmSzmKZf bnQ+8cx4A==; Received: from mout.kundenserver.de ([212.227.126.135]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLwHt-0001eo-Ny; Sun, 11 Nov 2018 20:24:54 +0000 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mw9oq-1fWB8w1OlA-00s3Fm; Sun, 11 Nov 2018 21:24:34 +0100 From: Stefan Wahren To: Eric Anholt , Florian Fainelli , Ulf Hansson Subject: [PATCH V2 7/7] mmc: bcm2835: Properly handle dmaengine_prep_slave_sg Date: Sun, 11 Nov 2018 21:23:59 +0100 Message-Id: <1541967839-2847-8-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541967839-2847-1-git-send-email-stefan.wahren@i2se.com> References: <1541967839-2847-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:YHuOF9ODbnoju/fZ6GEvx8dgsERlCPgAFKTWXLdnneRYXz5Rrwv HmNp+EMMG4LCQ6yrw9geiQ8UMaSlKRlOogmYpjlT6+acj6AvpUhfV/V/QTZoIqWymmOLu00 ilWzNp6sUh0G36dYFqNQx/xxoevvSshDkQfngYwW4IylOJ5Ijw4q7mUNQJel0aDdT6VxcCF vNXPaH6x5aju6BnVQQTZw== X-UI-Out-Filterresults: notjunk:1;V01:K0:F8RnfZXOXFg=:/o9BXYY1XlPda36fnQR3pw exiC7Lebj6iLmcKcGV1N+gYxVKa++UCwnlYE52iQ3aEq2FFOYc9MIGfKSXztp6aQJLMEcJ+Nl Y6IvfEO9Wre/kOJHLSbnLgi5rdaSTR4mjKUA8jP7+hgmHvgkSbKeQPPA9NbLPN9j2p/jPQt6j wWducLkOGSbZ5YW28XqMqKiEgyxjt72W7Ulgwt1l9fzu67fxmhDdc3UWHpofqHuJQ3dTz7iyH kgg+rS8NAKZBCtm6dFRPHs5TFa1D75bGQE9WbGv828i+/KNpsIoAbBRLLRmeGAoFn+KRil/PA 2NEyeFtr8QO/DsyVQUofQeZgtDmWXquT6il4a9R21nFM8UVN72Lt47MR7dQIKfjtCewO1XhKp aCAhoeqoKuI++NlYUmTAzwHyR1AzSqbz3qFLL669z219gmvjFFlmzCiNNQuixrhw3CvbXxywa F8FFVxEdPJRjt5v5xsfEQ9kWNm/UneKmSuw+sOIM6NjTYMbCxUA8s/SReuQtco4vZ5fMk2a0E H6WbLHlCpPoxm6106p29jhQ1MkQBcRRc/Gnr283sXcshS2idax1s/BXgEYWoqn1IXoSipmSRS uO7fLBnuonw9uYoUm30LeVzea9BSFsXSJQUAXYoj0FC51hOHYQG6yaC1EoGnL13niwbOV1w3V t7MsLAFqvse4jRXAQ2daRMVsoFeXyREOFlyM2u0kJ7SlglZ7O0HJNvOHJsOTEJBUDsCQQskjd UPyZ9p8NHWMKpnE18BgSypX/UwcNIarGvkM8pe6BN+IN6YbM+3leikxVVZ7pD64qCCITVHvjt SkzE3mpbb2hZZ/3vD8VryvQAJ4A0Q== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181111_152453_987059_DF242521 X-CRM114-Status: GOOD ( 10.37 ) 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: Stefan Wahren , Phil Elwell , linux-mmc@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Michal Suchanek , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 In case dmaengine_prep_slave_sg fails we need to call dma_unmap_sg. Signed-off-by: Stefan Wahren Acked-by: Eric Anholt --- 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)