From patchwork Tue Aug 27 08:44:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 13779220 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 733C8C52D6F for ; Tue, 27 Aug 2024 10:00:43 +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=Ybr1mN8ycfvP7HvoCOT8Thfo5D6LaJo0GrV/fcP+6gw=; b=q9a89kb1u8JAM6QeQy3JSxEThg zgU1AXdhcMt5hdfZCAg385F7qWRAbktWiJkWoLKdfwo8xD1raH0YR+i+levnU4U443vRvxW5fsTFg qNzXB1TG1TjbTQszxiAyk2Ervj+f5ekGZ2rH9fkHFByokMWc4vWzdx0g5C9N2Sh3M+3tPbTbtSS4j ukbPxIhQBVAh66XKfogKOw3oexWyS4qk9XCbwOAExed+hn8o6UuPsXnYipCa2tkOcPv9ScOM+OgmJ axIpuhDwOEPmUbiQR9duGTy7sKVeEw5PmmqZpW8YpjIXTyJzQBn7G/JDM6hJ1l0GYG7UymRui+sKx 6CtLORpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sit01-0000000AhpW-2kOY; Tue, 27 Aug 2024 10:00:29 +0000 Received: from mail.tkos.co.il ([84.110.109.230]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sirrY-0000000ASKe-0Rz9 for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 08:47:42 +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 8CFA1440A74; Tue, 27 Aug 2024 11:45:43 +0300 (IDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tkos.co.il; s=default; t=1724748343; bh=izAiWkQ0QMIJvlh6hdlTFfx3RH9ZwdClVZ50FgkP8I8=; h=From:To:Cc:Subject:Date:From; b=orrfsr2tQ9kfounZs5tm1ACHAeuMnhfIZGNsAZEf/48xdD9q/qp/3ukiHqvD0YP0Z fQOHwHdSFt2bWdZ313Q1FHuEyEJ2TmubxFoKyGPgEvnfYpc3xkctXnTlRFhdUqzVKh jrKnRln4lS8hICFwUz0aGL3sV7Y8Ob3WSwC7tgHjciS1VeOrfQyFmSRFIBTXBwKy8r Wl2zomJlhWteN12/ztOlBkCOWO9CXbT1gf3y5A3gnE17wnKhuxKLEWhEAm86zXCig7 Z6LCf6wpaQRpQi1fV87FTJuV5DFkdoc7Zii6EiAe+Ef5fQOqmD1d6eWWhnVyDQWMAC 5cO1OtO9Mmk8w== 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] arm64: mm: fix DMA zone when dma-ranges is missing Date: Tue, 27 Aug 2024 11:44:09 +0300 Message-ID: <731d204f5f556ad61bbaf004b1d984f83c90b4f5.1724748249.git.baruch@tkos.co.il> 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-20240827_014740_626402_69500976 X-CRM114-Status: GOOD ( 12.89 ) 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 when there is RAM there. Restore DMA zone 32-bit limit for platforms that have RAM in this area. Fixes: ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by zone_dma_limit") Reported-by: Marek Szyprowski Tested-by: Marek Szyprowski Signed-off-by: Baruch Siach Reviewed-by: Catalin Marinas --- This should go via the dma-mapping tree that contains the fixed commit. --- 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..7fcd0aaa9bb6 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 (memblock_start_of_DRAM() < U32_MAX) + zone_limit = min(zone_limit, U32_MAX); + return min(zone_limit, memblock_end_of_DRAM() - 1) + 1; }