Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751385AbdIOPIs (ORCPT ); Fri, 15 Sep 2017 11:08:48 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:58210 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbdIOPIq (ORCPT ); Fri, 15 Sep 2017 11:08:46 -0400 From: Arnd Bergmann To: Christoph Hellwig , Marek Szyprowski , Greg Kroah-Hartman Cc: Roy Pledge , Arnd Bergmann , Robin Murphy , Vladimir Murzin , "George G. Davis" , Mark Craske , Bastian Hecht , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] dma-coherent: fix rmem_dma_device_init regression Date: Fri, 15 Sep 2017 17:08:16 +0200 Message-Id: <20170915150824.3805217-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:LIk799ldb23w58dzIaJxTw2Q4gIvJx+kMBuD4JsqOqT33127qER O3CCq4zaiRxCCGHBXbcOLfN1ZsMQuxUG9WYpMoZvAKgHoOsIF6Y+6IHV85k0lNVRSsAr/e5 oItq9x+PtXHZeIhvbuDwLnIQy1XZiAEGotjkX14WWMoRxLyPVps6DjlEqL9lB93j6rZwU6q K1DzOyj9wwfUPql8cXfNg== X-UI-Out-Filterresults: notjunk:1;V01:K0:BuB196o1Pcs=:HcYbOozEFh6faCPF/iFMxO 5hVVEF75JiANLyrQrCDYxtul6yowbkdYYetqdn5MIMtUUBVTlvG/4JbJukM0miFseGrQzbmrC EJyxlk8LQoSXFe2iREWONKyelR67twKNE3W2MUuAG8lQI03O1N5Gc9W8Q5ukeAKZ68dLm0g1z eEMBDrg/vRgsnQyqIA4PvvCIrP22YekEbqwaI7RTXdugNro+ZWFoHmMH2p2xO1mHtlzsn6H/f UGYcYNrAK4gG5i2f6iLSFuzeiygktoU0OQz5wMkj7d4+TzKA1BqdLe+an2+TM5aJKzz8Q0wga wvJ4ieU3aOUDxWJaZE0WtRXLUE/8UAq6bDOkM38UKGRjugKI0lbsob6E/hYZTgvzeDAl5ti/L aUQQiTnhVRdkHEuvo065+LgBaeDoaIMKBJTkSjdmpnJsFkWDcgVvti4rp/fTePpg/ISX3u7va TWsT/bckSxw19gmRjrpeafuazbXyN+dr/8Hgrvgnu/cngIqBq68CKq5Wgc7PxE6MlDNrfwacn mBAGUAPtz0vhfIO8of2hVqhbC2oHdcXhIirx+CVuan8eulRqeCNBchwAXvsd6Wu4a2Av93eNL o4iNrsBTFp2yKtOKLhJw/e9DqrYIjVFnthTAAsXfM0gpV0/3ZxJpCrwAU+DCttYSjC08GdHRS h5JufWVEzZgOr8kdzxiJ2KxVWiT4KjkDjjhm+ysx4/YUPZfTr+MUMKFlSHHj89+rK8EipKDfK +lNj/cB3VgnhuaJ1KEPQF3yDKj1FLWbzRaG0rw== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1583 Lines: 47 My recent bug fix introduced another bug, which caused rmem_dma_device_init to always fail, as rmem->priv is never set to anything. This restores the previous behavior, calling dma_init_coherent_memory() whenever ->priv is NULL. Fixes: d35b0996fef3 ("dma-coherent: fix dma_declare_coherent_memory() logic error") Reported-by: Roy Pledge Signed-off-by: Arnd Bergmann --- Roy, can you test this new fix? --- drivers/base/dma-coherent.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index a39b2166b145..744f64f43454 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -348,16 +348,15 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) struct dma_coherent_mem *mem = rmem->priv; int ret; - if (!mem) - return -ENODEV; - - ret = dma_init_coherent_memory(rmem->base, rmem->base, rmem->size, - DMA_MEMORY_EXCLUSIVE, &mem); - - if (ret) { - pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n", - &rmem->base, (unsigned long)rmem->size / SZ_1M); - return ret; + if (!mem) { + ret = dma_init_coherent_memory(rmem->base, rmem->base, + rmem->size, + DMA_MEMORY_EXCLUSIVE, &mem); + if (ret) { + pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n", + &rmem->base, (unsigned long)rmem->size / SZ_1M); + return ret; + } } mem->use_dev_dma_pfn_offset = true; rmem->priv = mem; -- 2.9.0