Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1330998rwl; Fri, 24 Mar 2023 09:08:10 -0700 (PDT) X-Google-Smtp-Source: AKy350YzTEDDYefjItYatagw6Fg3yc+R/3MZYUPChWJk4/0DB1M5PMTg++372WOOmGtGlSGV2x7y X-Received: by 2002:aa7:d758:0:b0:502:233e:af49 with SMTP id a24-20020aa7d758000000b00502233eaf49mr2108084eds.4.1679674090707; Fri, 24 Mar 2023 09:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679674090; cv=none; d=google.com; s=arc-20160816; b=w6RTl61u73okGh1nl5tWwrYjeGI/P9VnZr5r5RAIO8IOfmBmDMp/Of1CyYcgWUvQtR pBihtZ80KZVLdg3zWpzS+y4kd9577SsXQROqYTWX8TH0Uq3mTAmN0mV0zfSMHiwVPQYB 4CsZlbGAx/1R3JpkFPVEQlR7YxIUMOTy6D+0AH9ee7slr3D+OEAQ6Ag8Ytdb+mR1POj7 u97s7lmYiqXo3SrHurY1W9E+GyQhZytn650HBXXCFXU3LmVn13lashEvB6aJMjrTugq+ Vw3zGw8JFQ6QE+8NUcEEOv4i7TGuxmJeeSjiHoS6WS9jLd71xVtB96P0shJeegiYz1d7 Byqg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Tp3HoPN4Gc82+RijS+v6sxY9JgB+vr3DxCDQErkACNI=; b=erw0x4kY3B6rtctC0+KExqeeG0BPPiTkCnr0mDbdwizuWSYk2FWaaUKaWC88DyYti2 c7fp5biTwCyiArZNDoE+H+QwtL51TH/EiGlBwXThHRwyDEjV7OandAfy5qxSiDNVo0Ho BNPKHZ8jN3j9ounEFYB+1rXf4XlQW5uNXQhaGvZWfK4lKQq+d3OMRzLncd2P2ZbE5G4L ktdKPqLTmQsa7ZjQ8X/++ZjIPPFhfPaorll9SukuzvOIVz61SPk30nqWSfQXsWbD6CBy l98NtYC1d2h8SS/Uxx9KHHMzv3FSws5eK4OXIAXf189sQ4jofvDc7v+CwK7p5m53Fu7M Cglg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=ZWNhHoXs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z12-20020aa7d40c000000b005021f0d574dsi2345794edq.660.2023.03.24.09.07.46; Fri, 24 Mar 2023 09:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=ZWNhHoXs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbjCXPze (ORCPT + 99 others); Fri, 24 Mar 2023 11:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbjCXPzc (ORCPT ); Fri, 24 Mar 2023 11:55:32 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAE8B1E5E1 for ; Fri, 24 Mar 2023 08:55:31 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id h17so2287376wrt.8 for ; Fri, 24 Mar 2023 08:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1679673330; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tp3HoPN4Gc82+RijS+v6sxY9JgB+vr3DxCDQErkACNI=; b=ZWNhHoXsX43350iih+wD2VNFUpSmPZg3GoR5+pdNWLoUbl7wO5tfkt7YCB3poRYl8m QKSnyLjo+RRmDEJN3/k3T0mFwzkstsnUrvxIbT4zvwl2sHXeUOWBGBxGM6CCneBRAH8h hInUCCtT4YIpqv1pG3b1V7EMYdJI+JHKt+HkFcEiECEXJJ7Eac3jDBUEciRtu5JnJ9P2 3TQpRwkH2qpr9pW05hvbeHJLEoYl76Gd8emmbghk/tOJF2k3L8T45BKZZ36DMpuM/iRo hEy9lrCMYSMC1vVFvsPgI289oVnGc80AOZvfRdGJURQiohqSFW+zGiatqjGAAD8L8js3 Mv5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679673330; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tp3HoPN4Gc82+RijS+v6sxY9JgB+vr3DxCDQErkACNI=; b=EzM85cNMkDTqWILfoPiZ9/qypkN3lnmV+gINqTbXtrFnVVyLE7YXxgRijJmU+HSoPp 3lT2jeN6AE0XPYo5jz6AJvyVToTy0l+wAjKkKyVPFx3bqVmPpyXMq/OBfDwtH//9N1FX gpMjZEFLJgpuVD8udENWt4+JC2x9oo5W2FScXX6ARc6aqAxki19tJyHoBK0Z1Ywel0M9 RVaw97HEvP0vbBHq8EMYQhU+D3f8Y0EglZy0716K2RyOreqINUnoUsujwiPDlZuhlCyh Ld/fUc59BMFNRuWoI+BFxgIOXWpHr5XSMDAuSKg0r4MOmnZtyRj24CerVJRjeMOLVrNf ebLQ== X-Gm-Message-State: AAQBX9fwUdkuke1yG5YM8nZNCx7qdVQ+6/hMRIuqB+z7+0YymXf0IXep 3PqBzHkCdFI3G1+GMSEkK5YL1g== X-Received: by 2002:a5d:4809:0:b0:2ce:ae4c:c424 with SMTP id l9-20020a5d4809000000b002ceae4cc424mr3047287wrq.4.1679673330170; Fri, 24 Mar 2023 08:55:30 -0700 (PDT) Received: from alex-rivos.home (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id m8-20020a5d4a08000000b002c3f03d8851sm18571070wrq.16.2023.03.24.08.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 08:55:29 -0700 (PDT) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Rob Herring , Frank Rowand , Andrew Jones , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH v9 1/3] riscv: Get rid of riscv_pfn_base variable Date: Fri, 24 Mar 2023 16:54:19 +0100 Message-Id: <20230324155421.271544-2-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230324155421.271544-1-alexghiti@rivosinc.com> References: <20230324155421.271544-1-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use directly phys_ram_base instead, riscv_pfn_base is just the pfn of the address contained in phys_ram_base. Even if there is no functional change intended in this patch, actually setting phys_ram_base that early changes the behaviour of kernel_mapping_pa_to_va during the early boot: phys_ram_base used to be zero before this patch and now it is set to the physical start address of the kernel. But it does not break the conversion of a kernel physical address into a virtual address since kernel_mapping_pa_to_va should only be used on kernel physical addresses, i.e. addresses greater than the physical start address of the kernel. Signed-off-by: Alexandre Ghiti Reviewed-by: Andrew Jones Reviewed-by: Anup Patel Tested-by: Anup Patel --- arch/riscv/include/asm/page.h | 3 +-- arch/riscv/mm/init.c | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h index 7fed7c431928..8dc686f549b6 100644 --- a/arch/riscv/include/asm/page.h +++ b/arch/riscv/include/asm/page.h @@ -91,8 +91,7 @@ typedef struct page *pgtable_t; #endif #ifdef CONFIG_MMU -extern unsigned long riscv_pfn_base; -#define ARCH_PFN_OFFSET (riscv_pfn_base) +#define ARCH_PFN_OFFSET (PFN_DOWN((unsigned long)phys_ram_base)) #else #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT) #endif /* CONFIG_MMU */ diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 87f6a5d475a6..cc558d94559a 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -271,9 +271,6 @@ static void __init setup_bootmem(void) #ifdef CONFIG_MMU struct pt_alloc_ops pt_ops __initdata; -unsigned long riscv_pfn_base __ro_after_init; -EXPORT_SYMBOL(riscv_pfn_base); - pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss; static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss; @@ -285,7 +282,6 @@ static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAG #ifdef CONFIG_XIP_KERNEL #define pt_ops (*(struct pt_alloc_ops *)XIP_FIXUP(&pt_ops)) -#define riscv_pfn_base (*(unsigned long *)XIP_FIXUP(&riscv_pfn_base)) #define trampoline_pg_dir ((pgd_t *)XIP_FIXUP(trampoline_pg_dir)) #define fixmap_pte ((pte_t *)XIP_FIXUP(fixmap_pte)) #define early_pg_dir ((pgd_t *)XIP_FIXUP(early_pg_dir)) @@ -985,7 +981,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) kernel_map.va_pa_offset = PAGE_OFFSET - kernel_map.phys_addr; kernel_map.va_kernel_pa_offset = kernel_map.virt_addr - kernel_map.phys_addr; - riscv_pfn_base = PFN_DOWN(kernel_map.phys_addr); + phys_ram_base = kernel_map.phys_addr; /* * The default maximal physical memory size is KERN_VIRT_SIZE for 32-bit -- 2.37.2