Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751353AbdIQMfG (ORCPT ); Sun, 17 Sep 2017 08:35:06 -0400 Received: from mail-eopbgr50075.outbound.protection.outlook.com ([40.107.5.75]:18688 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750860AbdIQMfE (ORCPT ); Sun, 17 Sep 2017 08:35:04 -0400 From: Roy Pledge To: Arnd Bergmann , Christoph Hellwig , "Marek Szyprowski" , Greg Kroah-Hartman CC: Robin Murphy , Vladimir Murzin , "George G. Davis" , "Mark Craske" , Bastian Hecht , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] dma-coherent: fix rmem_dma_device_init regression Thread-Topic: [PATCH] dma-coherent: fix rmem_dma_device_init regression Thread-Index: AQHTLjSEoe2eBM6E3EeigPhYfyZNNA== Date: Sun, 17 Sep 2017 12:35:00 +0000 Message-ID: References: <20170915150824.3805217-1-arnd@arndb.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=roy.pledge@nxp.com; x-originating-ip: [192.88.168.49] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB6PR04MB3303;6:9Jw1Lvy1mvWqKmRXzvD7fCHlTHiddTJRjgmVjylsQSPjIN2tBWRnvRpNszCzWvr0XWBjrzqN+e61TLH4R5F6xkc2Z+ChVDvk7pmx+ow5V+V9BOdlRh7WSWRgoIOdUamWFmbfzN1og4VI+5uBn76xMcVQ7KosVKEIpYGo9oRF7Cito6y8j0PD4EKo/4gyiVfUIvx5koYlB09hx4Yw9vV1f8y7JR3ACCBC5c9JbfujJ3q+PGd2v57y+z64gQci/O0SdvPagoK2vZdzz/Y297e7GSGOreE+wn4umuyFcNDIRXX0B5By/3YNN8fwedKK5NVLo1xWZYzJ+mpsUmeectOP5w==;5:Seeae2o+CV5f2GMskWu2k5Nm64QKaxa3qkE/3B1G79Ziri+Q4pRE2Qxh6yBnqqD1yK8iQQjsIACsHSG8KVdTr+wfXV0H/KPw3Pi6ErO9AYXCgRqN2O0577o+2bR4ZLHAEmKZ6rGYWUt+gCfug6h/Dw==;24:5KAVcxPnBPqOEz/5vzYwI8+kDCLuf0c3ZQXpcgVueXGv5nxWiJDApiliJdW0iLZNo6gP7EVddMtFQKPZa5Zfksa07kusp/t4hxUvsOOVITg=;7:JCPzZZFR46viJEQ7OgKQ1jqHiFefknQFzIXSj5EWSsNw/tPgwZr3OazqOgOlRECpHdZIg6aDrZ0bumohYBzYu/qgNqUy+6TK6A7dfownv0v2rlkVg3WYdLl3POGuog9wGTro5To0m3FJfSPrQ/c26WA4ze3khhoAJoY2FeDEbBgQ0qYdPyD0JNJo2CWFJ722RgGnN9t8isbaiIAKD7Wl2Orqpi/6bNZRERL41pjsnfc= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 508a9aef-262a-44b1-35e4-08d4fdc88351 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DB6PR04MB3303; x-ms-traffictypediagnostic: DB6PR04MB3303: x-exchange-antispam-report-test: UriScan:(185117386973197); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DB6PR04MB3303;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DB6PR04MB3303; x-forefront-prvs: 0433DB2766 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(346002)(376002)(199003)(377454003)(24454002)(189002)(51914003)(25786009)(6506006)(6436002)(189998001)(478600001)(74316002)(8936002)(7416002)(305945005)(33656002)(2906002)(14454004)(7736002)(106356001)(105586002)(66066001)(5660300001)(8676002)(229853002)(6246003)(5250100002)(316002)(99286003)(55016002)(53936002)(3660700001)(81166006)(4326008)(81156014)(97736004)(3280700002)(101416001)(54356999)(7696004)(54906002)(9686003)(50986999)(76176999)(3846002)(102836003)(6116002)(68736007)(2900100001)(86362001)(53546010);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR04MB3303;H:DB6PR04MB2999.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2017 12:35:00.3569 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB3303 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v8HCZAGR002029 Content-Length: 1841 Lines: 51 On 9/15/2017 11:08 AM, Arnd Bergmann wrote: > 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; > I tried this and it solves the issue I was seeing. Thanks for the quick fix. Tested-by: Roy Pledge