From patchwork Wed Aug 28 09:51:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 13781010 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 5AF00C54E62 for ; Wed, 28 Aug 2024 09:53:03 +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:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=ud4j0vfa4RFTLG9vAmsl3mpsUl70F6iMPkVca3G4xjA=; b=4SGn/cXlSzUb330z5xgpOJyLbr TeDbhcvwyRg42HZlkd8fGcCP4o1TLoXgKEkLaCF5jo1GZuWfyAeLoSkrpe+kGejoqH2+cXoFTgcqH EuI/7QFTImlFMCt9vgX/KISaYud+/GvyGanWhD3T9DktwUALsH11CMB5gHqWye7JGwa4J+Vhiy55X TUR5Je8ZLIG/VioMA5uaQCjOQvpd20O9EQlH3Jgq1Gqxk/fbXC7lIOiNCpCTVbLsQb0MW5pCz7C5S q8o9aqGMczinLtOCSNoSHxm6wi+Yfins4ru25MgZIaOTqEkbezXkw7lAjFex4PTo8iC63BdTdGtw/ xVVf+qWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjFMB-0000000Eo64-3zHg; Wed, 28 Aug 2024 09:52:51 +0000 Received: from guitar.tkos.co.il ([84.110.109.230] helo=mail.tkos.co.il) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjFLL-0000000EnsG-0qQE for linux-arm-kernel@lists.infradead.org; Wed, 28 Aug 2024 09:52:01 +0000 Received: from tarshish.tkos.co.il (unknown [10.0.8.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.tkos.co.il (Postfix) with ESMTPS id 54713440F93; Wed, 28 Aug 2024 12:49:59 +0300 (IDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tkos.co.il; s=default; t=1724838599; bh=CkIxrkLCCGkoStR7ogXz+1oYN4x3zeBo4yxb898ywa8=; h=From:To:Cc:Subject:Date:From; b=xyJwhkBumQtVPuky9qrM2RlOpE96CTV3GKGLzpr/pJjszRvzaiaorfoHBAEVjk5AC Y+UBUU4dHM1l2KN+5+EqNPAOsIdo0WmFhISu5ELDUKdxuqFiIEJxgAj3/8OqIbkc1A i5Kb28hXJTu0MIJf7uC8D/LBWEiZo/hw1u9gaR98KAlbvb+DTYcHnxtMDp9R5cj/R3 JmxAMlPxVw6RKc3K21FAfHiRLCea697ExJTOyqgmu3qH5xxFqumgLVWqji74YH9Yz/ 27r3T4M5o1l5x7Hd3bwaySlNGm3wa9bYyUKtotc8n7vNC2MLxHQk3FV8o6h/M67oFr 6Ze/90xzLzgIg== From: Baruch Siach To: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Catalin Marinas , Will Deacon Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, =?utf-8?b?UGV0ciBUZXNhxZnDrWs=?= , Ramon Fried , Elad Nachman , Baruch Siach Subject: [PATCH v2] arm64: mm: fix DMA zone when dma-ranges is missing Date: Wed, 28 Aug 2024 12:51:24 +0300 Message-ID: X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240828_025159_775347_DB8AEBC1 X-CRM114-Status: GOOD ( 12.81 ) 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 Some platforms, like Rockchip RK3568 based Odroid M1, do not provide DMA limits information in device-tree dma-ranges property. Still some device drivers set DMA limit that relies on DMA zone at low 4GB memory area. Until commit ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by zone_dma_limit"), zone_sizes_init() restricted DMA zone to low 32-bit. Restore DMA zone 32-bit limit when the platform provides no DMA bus limit information. Fixes: ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by zone_dma_limit") Reported-by: Marek Szyprowski Link: https://lore.kernel.org/r/53d988b1-bdce-422a-ae4e-158f305ad703@samsung.com Suggested-by: Robin Murphy Reviewed-by: Catalin Marinas Signed-off-by: Baruch Siach Tested-by: Marek Szyprowski --- This should go via the dma-mapping tree that contains the fixed commit. Marek, can you test on Odroid M1? Thanks. v2: * Directly check whether platform provides DMA bus limit (Robin) * Add Link tag --- arch/arm64/mm/init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index bfb10969cbf0..5710129b8033 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -116,6 +116,9 @@ static void __init arch_reserve_crashkernel(void) static phys_addr_t __init max_zone_phys(phys_addr_t zone_limit) { + if (zone_limit == PHYS_ADDR_MAX) + zone_limit = U32_MAX; + return min(zone_limit, memblock_end_of_DRAM() - 1) + 1; }