Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1709336pxb; Mon, 8 Mar 2021 04:36:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8K5nJqqzfTGbLg/4G41qWq1Eda8XxDh136J3SW6AKZ5QdNUnHu1MdEjSKpAgzYtMcB4ex X-Received: by 2002:a17:907:b06:: with SMTP id h6mr14732282ejl.144.1615206996405; Mon, 08 Mar 2021 04:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615206996; cv=none; d=google.com; s=arc-20160816; b=nzYMgmqrVuCJDubHBNKHfDTLWzdl1v55PgYlw8Ohgt1sK72fwVDs4+e9IyySPPLepq l7HPIlWl8rbNGyLdT2R+pQOXZGwc/ODDUM0GZKn3Pa+/IzqfRyV3U/Wr0Eivb4gqVbky OG7DtvYUHRf95F835PoQo+aJ8UPL4B9Z69nq061jmE3ZdG/QDXYIH90XdYMRyWFlGz5K CiB6PKpsV6wUfAxVAlNNzy7ggtXdeORHTL9QRHIl9+5CoDBLhBs/ohyChnNuD8SeL43Y PpNyjHtfkl5iN7BHJDLciw6DPmRFbBFdxPtCinDsd2ALswQmxaft55Yn/d7t67m4hhj7 PbbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sMUsrl8WUGX2K3WKybAA5n5JkHasaQUbENNHYMc15RM=; b=TndekqLWCG0HjAcVsYMBJ653pcQWp10zNJvLhVpDCvtg43gttKZFPqJ0yClal4Dwm/ MnLhQIY15ynkY0xt61qkYQPkFe+5FKWgYq0t+9gi2SwjhztBwWvc6rT9T8pVM4r4opMi Ulx3eGMtdaSkgHnMkLNjB5oWOsRGqmdeAdAjB4MidFy4qfeI94xzJQk4Lc/aNpDZe/eL BYWjtvwRk3ICfNPGs6fkTMB23MDTOHH/0CCjnxJMdkkxkXZnTsTTNLiIitu9YmauCn12 OvaQHdNQH0jN5iQXJ52GqEAaCPKTlX7xT46DItXPZc8DzHlFrnN0YqYdTzmvVMdCw0L9 IZtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U4yZZx+E; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a14si2651400edr.155.2021.03.08.04.36.13; Mon, 08 Mar 2021 04:36:36 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U4yZZx+E; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230341AbhCHMes (ORCPT + 99 others); Mon, 8 Mar 2021 07:34:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:42874 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbhCHMeN (ORCPT ); Mon, 8 Mar 2021 07:34:13 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B858651D1; Mon, 8 Mar 2021 12:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615206851; bh=8iR7wemeM4wSb13AjnWFg/Ans3Zsw2ImwmPO6slR+Yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U4yZZx+EAIbQZpe4yo6mB0DZ0/yjzFjN8KXJSszFwf504Mrs2F+8DgNoqkhfjjjkX S111BXKZMUA5CK5NfqKrEoOhouVreGiQA5VtCRrq5pl6DdpxomFv6uc2bzbk6V7E/j IEldTUr3P3v2zvKjVwdhpCGoBjdHMinRQiIot8WY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Saenz Julienne , Catalin Marinas , Jing Xiangfeng Subject: [PATCH 5.10 28/42] arm64: mm: Set ZONE_DMA size based on devicetrees dma-ranges Date: Mon, 8 Mar 2021 13:30:54 +0100 Message-Id: <20210308122719.511291371@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308122718.120213856@linuxfoundation.org> References: <20210308122718.120213856@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicolas Saenz Julienne commit 8424ecdde7df99d5426e1a1fd9f0fb36f4183032 upstream We recently introduced a 1 GB sized ZONE_DMA to cater for platforms incorporating masters that can address less than 32 bits of DMA, in particular the Raspberry Pi 4, which has 4 or 8 GB of DRAM, but has peripherals that can only address up to 1 GB (and its PCIe host bridge can only access the bottom 3 GB) The DMA layer also needs to be able to allocate memory that is guaranteed to meet those DMA constraints, for bounce buffering as well as allocating the backing for consistent mappings. This is why the 1 GB ZONE_DMA was introduced recently. Unfortunately, it turns out the having a 1 GB ZONE_DMA as well as a ZONE_DMA32 causes problems with kdump, and potentially in other places where allocations cannot cross zone boundaries. Therefore, we should avoid having two separate DMA zones when possible. So, with the help of of_dma_get_max_cpu_address() get the topmost physical address accessible to all DMA masters in system and use that information to fine-tune ZONE_DMA's size. In the absence of addressing limited masters ZONE_DMA will span the whole 32-bit address space, otherwise, in the case of the Raspberry Pi 4 it'll only span the 30-bit address space, and have ZONE_DMA32 cover the rest of the 32-bit address space. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20201119175400.9995-6-nsaenzjulienne@suse.de Signed-off-by: Catalin Marinas Cc: Signed-off-by: Jing Xiangfeng Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -42,8 +42,6 @@ #include #include -#define ARM64_ZONE_DMA_BITS 30 - /* * We need to be able to catch inadvertent references to memstart_addr * that occur (potentially in generic code) before arm64_memblock_init() @@ -188,9 +186,11 @@ static phys_addr_t __init max_zone_phys( static void __init zone_sizes_init(unsigned long min, unsigned long max) { unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; + unsigned int __maybe_unused dt_zone_dma_bits; #ifdef CONFIG_ZONE_DMA - zone_dma_bits = ARM64_ZONE_DMA_BITS; + dt_zone_dma_bits = fls64(of_dma_get_max_cpu_address(NULL)); + zone_dma_bits = min(32U, dt_zone_dma_bits); arm64_dma_phys_limit = max_zone_phys(zone_dma_bits); max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); #endif