From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A49D1C4338F for ; Mon, 26 Jul 2021 07:01:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 894F3603E7 for ; Mon, 26 Jul 2021 07:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232009AbhGZGUs (ORCPT ); Mon, 26 Jul 2021 02:20:48 -0400 Received: from verein.lst.de ([213.95.11.211]:43954 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbhGZGUd (ORCPT ); Mon, 26 Jul 2021 02:20:33 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id B117C68BEB; Mon, 26 Jul 2021 09:01:00 +0200 (CEST) Date: Mon, 26 Jul 2021 09:01:00 +0200 From: Christoph Hellwig To: Atish Patra Cc: linux-kernel@vger.kernel.org, Albert Ou , Christoph Hellwig , devicetree@vger.kernel.org, Dmitry Vyukov , Frank Rowand , Guo Ren , iommu@lists.linux-foundation.org, linux-riscv@lists.infradead.org, Marek Szyprowski , Palmer Dabbelt , Paul Walmsley , Rob Herring , Robin Murphy , Tobias Klauser Subject: Re: [RFC 4/5] dma-direct: Allocate dma pages directly if global pool allocation fails Message-ID: <20210726070100.GC9035@lst.de> References: <20210723214031.3251801-1-atish.patra@wdc.com> <20210723214031.3251801-5-atish.patra@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210723214031.3251801-5-atish.patra@wdc.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 23, 2021 at 02:40:30PM -0700, Atish Patra wrote: > DMA_GLOBAL_POOL config may be enabled for platforms where global pool is > not supported because a generic defconfig is expected to boot on different > platforms. Specifically, some RISC-V platforms may use global pool for > non-coherent devices while some other platforms are completely coherent. > However, it is expected that single kernel image must boot on all the > platforms. > > Continue the dma direct allocation if a allocation from global pool failed. > This indicates that the platform is relying on some other method (direct > remap) or just have coherent devices. > > Signed-off-by: Atish Patra > --- > kernel/dma/direct.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > index d1d0258ed6d0..984ea776f099 100644 > --- a/kernel/dma/direct.c > +++ b/kernel/dma/direct.c > @@ -161,8 +161,11 @@ void *dma_direct_alloc(struct device *dev, size_t size, > return arch_dma_alloc(dev, size, dma_handle, gfp, attrs); > > if (IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) && > - !dev_is_dma_coherent(dev)) > - return dma_alloc_from_global_coherent(dev, size, dma_handle); > + !dev_is_dma_coherent(dev)) { > + ret = dma_alloc_from_global_coherent(dev, size, dma_handle); > + if (ret) > + return ret; This will now silently return normal non-cache coherent memory when the global pool allocation fails, and thus is completely broken.