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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 247ABC3DA64 for ; Wed, 31 Jul 2024 17:34:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4dK3bCpcBxidKqG4EtSzEwZuH6EkLhxFW3PqeOHIow8=; b=K0vnONf5Fv6YCU392yq/u06qPF KXI0tvp2MAqGOSijVUFOl9WN+apkySY0zKqNafF/9yYfZ119AsE2e6UM7OY+PLPN2xzS7CFmIoVjb be56NNjW2hNkAuToARB+37eZAcf3OxyRuXSjkXW6QAA1ojceswIPheHsviGRmdhrJiwsDAzCh219c H5beWQ3dSi8cOBx8vv0AkSq50wbCJe6v20uDUyv92YaveVbD0MOfJYU3cBk+oMLSyepljjWD3i0bl rYlq3jz0ccYWCpftlQIaXD1LTPWDLIywUFhaeSFY86+MDiLuT+7jKoMYO4QwLxIWvL7/myGhG1/v1 IG7nJ+1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZDDe-000000022QU-2Ibj; Wed, 31 Jul 2024 17:34:34 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZDDB-000000022Kx-3FfR for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 17:34:07 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 07178CE16CA; Wed, 31 Jul 2024 17:34:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B79E6C116B1; Wed, 31 Jul 2024 17:34:00 +0000 (UTC) Date: Wed, 31 Jul 2024 18:33:58 +0100 From: Catalin Marinas To: Baruch Siach Cc: Christoph Hellwig , Marek Szyprowski , Will Deacon , Robin Murphy , iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Petr =?utf-8?B?VGVzYcWZw61r?= , Ramon Fried , Elad Nachman Subject: Re: [PATCH v3 3/3] dma-direct: use RAM start to offset zone_dma_limit Message-ID: References: <629b184354fa22cb32a90bd1fa0e1dc258251f81.1722249878.git.baruch@tkos.co.il> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <629b184354fa22cb32a90bd1fa0e1dc258251f81.1722249878.git.baruch@tkos.co.il> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240731_103406_021521_5595F460 X-CRM114-Status: GOOD ( 15.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jul 29, 2024 at 01:51:26PM +0300, Baruch Siach wrote: > diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c > index 410a7b40e496..ded3d841c88c 100644 > --- a/kernel/dma/pool.c > +++ b/kernel/dma/pool.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > > static struct gen_pool *atomic_pool_dma __ro_after_init; > static unsigned long pool_size_dma; > @@ -70,7 +71,7 @@ static bool cma_in_zone(gfp_t gfp) > /* CMA can't cross zone boundaries, see cma_activate_area() */ > end = cma_get_base(cma) + size - 1; > if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA)) > - return end <= zone_dma_limit; > + return end <= memblock_start_of_DRAM() + zone_dma_limit; I think this patch is entirely wrong. After the previous patch, zone_dma_limit is already a physical/CPU address, not some offset or range - of_dma_get_max_cpu_address() returns the absolute physical address. Adding memblock_start_of_DRAM() to it does not make any sense. It made sense when we had zone_dma_bits but since we are trying to move away from bitmasks to absolute CPU addresses, zone_dma_limit already includes the start of DRAM. What problems do you see without this patch? Is it because DMA_BIT_MASK(32) can be lower than zone_dma_limit as I mentioned on the previous patch? -- Catalin