Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp286144rwl; Wed, 29 Mar 2023 01:35:15 -0700 (PDT) X-Google-Smtp-Source: AKy350bJ19TxJmZg8AXCyPZG2DHLBHvOauxHIAWTrBoO4gMDNYwlFIxZlNjZnHKZFyZK88rdPdzf X-Received: by 2002:aa7:cd42:0:b0:4fb:994d:42c9 with SMTP id v2-20020aa7cd42000000b004fb994d42c9mr17908271edw.24.1680078915373; Wed, 29 Mar 2023 01:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680078915; cv=none; d=google.com; s=arc-20160816; b=oxs9uZ+ZNqTqiyOBBqK8cs6tl4MXA7Dd9Glz07YEjdKSmtBnpm2g0/ehJDsTDb9nc/ Dcfyp8cvKzsJrHqKT2SytncFj/vTzxiFC/o1i8P5WNf/4TwYykeHE2vIq9JupOY8ux3W kbkRDdAbwKvhKzk+z92sYjIt4AUdfxqenPbnlMy2BIBd83Kx9799gsiXGLyUHcXZ8s60 NknEPVxn1iRE/Jdhix2n5O5Urb2lnF4uFwXCV3+SbUVQWa8fZdhGG5dAo+VbcI2DHtSu EHQiL3NZHI5hQnrYii2yO/iKqWtsJQkXc0BTm4IPqzWhJEAAx5xsB2c2CB15yTVtyEAS o72g== 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=tkd1yySkMZCjQpFk/I00/AFBZMzwvjb6fzx+RcYU4u8=; b=wnQtPgS0DIi+sLfoTMEpSmGaPY2Ylx/aRjvg/9m2LkGEYSv1naNcViGwsqzutOupNc 8iPalbZhGlJrGn2Gxc2mLHgTI9pGreq/RhfXX+ppjp44ZlCF3S3tIe53lbjzlb+SvqeV 0d6WR2nuceovkbpe6DD5gar23B27MAkOKGxXHXlewEVlrPYkN1YEdaWPHQO3+m20OGF8 yUU6YqUFBeKwT8kZ9ovdelOa5LcmkOzwludffC1+JOSuPqFHe5NNxRFEHk3/qaFRIr2Y FBF5ctUn4Nug8LS1LKbKfM8gIXEIk/Yg2uAIhGpQ/8tbW4e2DlnoLAvtC3aLpToH2cxc f7xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=h5xChJSm; 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 e21-20020a50fb95000000b004fb3426ea95si33948833edq.322.2023.03.29.01.34.50; Wed, 29 Mar 2023 01:35:15 -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=h5xChJSm; 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 S231153AbjC2IYE (ORCPT + 99 others); Wed, 29 Mar 2023 04:24:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbjC2IXo (ORCPT ); Wed, 29 Mar 2023 04:23:44 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25D9055B8 for ; Wed, 29 Mar 2023 01:22:39 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id y14so14768304wrq.4 for ; Wed, 29 Mar 2023 01:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1680078157; 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=tkd1yySkMZCjQpFk/I00/AFBZMzwvjb6fzx+RcYU4u8=; b=h5xChJSmqqdKg1QSgQom43LhcMDU0XiEsWSGiNAEWStm39CVorzpPFv0ONnnnIzsF9 Ty9fCdH2xUz2wOZR3NKor67Qdex16pDFGgwBHihecdqsxLGSk+HTgbwfoT7RYQekKSxu SbmuwSNFsjGFqHbtDD6ksJRWX27fdpcnLkWqD3UW1R5E7gBu7qHO15F//p+2aDSW2ZPJ 3XfGMZn7kWWzAn00jE4Xlv2bopw4A0wydAb2rWVMI7SGd4F+bM+QTGAHlxcNNsqJ80D2 U2GBrATYMSRGj1vmfr96jLrF4tREftjHjgSGNdVyO36HJXh94p23JlkJWCxZ3yplJUqT 117Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680078157; 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=tkd1yySkMZCjQpFk/I00/AFBZMzwvjb6fzx+RcYU4u8=; b=qzgZNMIVuQbypnhzuYSnK/lZE9tXs2bOQWo1BPkeov4va8von3B0tpVjiSaEr6O4Q0 N4SVAeFdGMf140WiLuk3NQw5mEkvYtq/ps6gMqtYnq5jxis2fhM/4Gqw5THP/SMsa7lF cEVrhPC/hnfVS91/V83/Wv6W2ebbRbMMMQAHGPODfrnu5paZDyfyF7IJ7mEzUWUYrVK/ yqYjYTBvBdgln6z7nJ25bVN7OnIhJRqs4/rxE4A2SZrOqWpv/vvJfBei/oaWQnsgfzNx lMaknWeRfByEje0+yFG6jd2PYI+oQxcPmqGVv73/asD+dq5lzzgVZNyETBfyRPx2146T 3/qg== X-Gm-Message-State: AAQBX9ci2uQrOSaaC6vNwUauRb8pUza5Sbl+Rr9X7ghwhuSV9cXpSrl+ oN6RRFm0NTnBJ2q091NvAPawtGexGGc4O8cetkc= X-Received: by 2002:adf:f8c2:0:b0:2c3:e7d8:245c with SMTP id f2-20020adff8c2000000b002c3e7d8245cmr13699207wrq.13.1680078157521; Wed, 29 Mar 2023 01:22:37 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id w2-20020a5d6082000000b002c6d0462163sm29468263wrt.100.2023.03.29.01.22.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 01:22:37 -0700 (PDT) From: Alexandre Ghiti To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH -fixes v2 3/3] riscv: No need to relocate the dtb as it lies in the fixmap region Date: Wed, 29 Mar 2023 10:19:32 +0200 Message-Id: <20230329081932.79831-4-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230329081932.79831-1-alexghiti@rivosinc.com> References: <20230329081932.79831-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 We used to access the dtb via its linear mapping address but now that the dtb early mapping was moved in the fixmap region, we can keep using this address since it is present in swapper_pg_dir, and remove the dtb relocation. Note that the relocation was wrong anyway since early_memremap() is restricted to 256K whereas the maximum fdt size is 2MB. Signed-off-by: Alexandre Ghiti --- arch/riscv/mm/init.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index fb78d6bbabae..0f14f4a8d179 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -249,25 +249,8 @@ static void __init setup_bootmem(void) * early_init_fdt_reserve_self() since __pa() does * not work for DTB pointers that are fixmap addresses */ - if (!IS_ENABLED(CONFIG_BUILTIN_DTB)) { - /* - * In case the DTB is not located in a memory region we won't - * be able to locate it later on via the linear mapping and - * get a segfault when accessing it via __va(dtb_early_pa). - * To avoid this situation copy DTB to a memory region. - * Note that memblock_phys_alloc will also reserve DTB region. - */ - if (!memblock_is_memory(dtb_early_pa)) { - size_t fdt_size = fdt_totalsize(dtb_early_va); - phys_addr_t new_dtb_early_pa = memblock_phys_alloc(fdt_size, PAGE_SIZE); - void *new_dtb_early_va = early_memremap(new_dtb_early_pa, fdt_size); - - memcpy(new_dtb_early_va, dtb_early_va, fdt_size); - early_memunmap(new_dtb_early_va, fdt_size); - _dtb_early_pa = new_dtb_early_pa; - } else - memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); - } + if (!IS_ENABLED(CONFIG_BUILTIN_DTB)) + memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); dma_contiguous_reserve(dma32_phys_limit); if (IS_ENABLED(CONFIG_64BIT)) -- 2.37.2