Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3289320pxv; Mon, 26 Jul 2021 00:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyKdc2WdpCH8i+Fj8tV3VtBJFhhWKvDzmNxWyVyq6YiuAVsLkEsR0RkKaweoW7P/bwZbmK X-Received: by 2002:a6b:3bc3:: with SMTP id i186mr13435973ioa.64.1627282939872; Mon, 26 Jul 2021 00:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627282939; cv=none; d=google.com; s=arc-20160816; b=FKs2ef9o/6KggnXzCOwMzIVcA4mmMDq/pwabl4+b62XUyraxF0JSNJ9zyfw7XdqB0h 4/jyRhWhbDSztY5yqVQFBJYbZ1bIVmyQm9zdfIhkh9uz/pFsV3m1B0mDkLkCowt0Ojyt DDFnduvSAo9foz8oByRByIBe1L9yHeyrolJ/IfK8Sp5CwjMECVgucF9l6DPDccS3Xudo 6NkesOQM42CkdjyOCGKS3UFTbaQOSj11gwTL6e8sCIMQMCQ4sTt/wOyoIBtEHHbM00iL fXrBZyFyFrk6jRNx/yRpeRpSfc/zDhMLrlYB6Cahjf7X3gQeztACxLZwCs8l+h4OX4bm vZRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=o6T4VeLRH/vei3GnvyX1TCFWbsWBjpZ5SbSmrvG+B3M=; b=VQSmJUyuou+dKCCb+n/0wPj8ZUjWpFk4zFSpvzDhTf7MC3ALd7Uoia/YAxXMAS2Ywe hlXRPERzfaBQ2wfQxoNn5s21YoQZEyPIbaXInynn121N+XHX/Tfh4/xrhv8vlu3KTxYt 2G3fZJ0HT+swffZCNBkZO74TdE8lnKLWlCH7z6P9B25qekKjAZC9b25AFhjKJDpJnLOe TpIiDIt6yPD2/7ckM0u+8Yz7GuyY72dQ4nTyaf8+joBToPgFLTXoFu8pC4xeW7X+lNf3 3oLk10/7gSQPI57Y3B+kYfdRQmwlgTiHxWLIV5u2PwEYhuCXP2HeJIkwoZYinnnYt2Ri xlKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l20si18319379ion.36.2021.07.26.00.02.07; Mon, 26 Jul 2021 00:02:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231909AbhGZGUf (ORCPT + 99 others); Mon, 26 Jul 2021 02:20:35 -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.