From patchwork Wed Jul 31 04:58:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1966854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=HisWnL89; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=KkbfD+kC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WYhKc2D7Xz1yYq for ; Wed, 31 Jul 2024 16:00:52 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UiWAIPbkanIiTCR5/KE0kiW62FVKEaPl8waNIGjgcTU=; b=HisWnL89xZMSh+ p1R5I3uf8+2xWRorWQBJfKmm86pA7l7vGXPtlwlsgPq6Qur9CA/f0fGSvcj69dZS4TSve+o2rmOqk 474073ZSKgzsjhkgMtwNpksRdVYEIo2asYzD0FkjHmxKiyOA8NU03M/vy4zFQo4gWENHw6Acp+Y2g Rr8KqiUOj+1cWLkzxHM6e1hVb+o0O1b8vOBLwv5GxE+Db3Mr5y9LEaOd8Rmmyvlgh0wTZiwxM6mK5 wsbt1Iru/za9f5QhFr4uu/U1oQrGca3xxSRckseQA0NB6yk3mPgtebnclZIUd3l4NhpwOF/q+vcmK MZWDMVRnpuAZjjox4Z2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ2O9-0000000HRxh-2Vjd; Wed, 31 Jul 2024 06:00:41 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ1RG-0000000HKUp-1Ft1 for opensbi@lists.infradead.org; Wed, 31 Jul 2024 05:00:00 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1fec34f94abso38873285ad.2 for ; Tue, 30 Jul 2024 21:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1722401989; x=1723006789; darn=lists.infradead.org; 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=TtRaMAlK5ohqAO0Qo4chWKt28YRYZM1PvvUhxiH/Vuk=; b=KkbfD+kCUDv7/G58MoGUVh3pJP6QixqsZK9Y1gD+ssBEpyf02hXfd5vZlCcakSXtmc qydg6TCmw6cxeE0iUZA2qLP6qy7m62702QEsBCNVOJLwrncbtE3d6GrZqjfQB8mpdWlW 5pNkfNwTXVHdGCSEIBTwGoEn17bkLP2xe0DbuF4uLqKHUrFeMyF7S4tRB3gPTNSYz4Fm 2VEXwpEU6WnB9Ks0BxkmpA7ELaYkKYRn0hbQTbSMabUEjsN9QOCzg2A1k8UcBI9eYcai FYOLzlqpwqLjqz0TUvYaCKOHF8uzmLRxSQ71W0LVZp8DL7muvxKVuugfzk5bS6c1N1w0 eTdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722401989; x=1723006789; 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=TtRaMAlK5ohqAO0Qo4chWKt28YRYZM1PvvUhxiH/Vuk=; b=hw5l5y/5a26pzsQg3EpityxrVHjjQXzgeh7rFNZnmSd+AfmQCEPi2hVdVyTBZrRh4N 9mmdhY+Ej6PvURQCV2tZdwnMdNizuvN5thHxpTOcohouGrE/tH3r7ysO/ppGAspG/m3j /a5ZSPwJNPU/m3Vges48JibfTP8gdUIF9GkzC2URCz3GgHwAYd43XweFBWSCV9wGjXeY 6SvT+g3FpwaVk0jqIiajEmzwbEb81FYRmhCMVoKn423gy9V4iAY0gnD1+9ooCWLh5nLW Q9bT/wQQz87qmNRsWa/7smVEZogJc1lXa3LSRAFmGVv8ckNrMYG4nS+tYvezsEc8fwdK NtfA== X-Gm-Message-State: AOJu0YyP4SxUbZQt5+TDlZHTf2ottPpTCUHkrRZP1brUCP2LN/EjGcUY KIa1FklyyLO08Zj7uhHuZ9lQU1mq9ivl2OfHHoquf2mCiunisBL9zyxwT8GvEFBjMUpPPMOeC/r v4jC/VoRutX9GJ9O23KKzieJfOYmXIGorfRxm6lJekCvwE8w7c1Fk7dseEgLksSb4az4N2uXze4 nYRNOPQEydKVN+KhRdXFBPraBIsbmq3Y6waXHiQuB7PzunlaBiZi4= X-Google-Smtp-Source: AGHT+IEk/OyMV7svwgF7kVedVWb/QYUMexrGN3bpqurAgyTh8jZ2NBOHFQAu8H24sJ2AMv1PxRModg== X-Received: by 2002:a17:902:f341:b0:1fb:8a61:129d with SMTP id d9443c01a7336-1ff0492d613mr88161065ad.56.1722401988498; Tue, 30 Jul 2024 21:59:48 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7ccd777sm110569535ad.75.2024.07.30.21.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 21:59:48 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 13/16] platform: generic: Pass FDT to early/final_init overrides Date: Tue, 30 Jul 2024 21:58:54 -0700 Message-ID: <20240731045931.2446799-14-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240731045931.2446799-1-samuel.holland@sifive.com> References: <20240731045931.2446799-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240730_215950_762570_43CE9551 X-CRM114-Status: GOOD ( 18.00 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Several of these override functions access the FDT blob. Explicitly indicate which callbacks are allowed to modify the FDT blob by passing the parameter as a possibly-const pointer. This also reduces [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:62b listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Several of these override functions access the FDT blob. Explicitly indicate which callbacks are allowed to modify the FDT blob by passing the parameter as a possibly-const pointer. This also reduces code size by deduplicating the call to fdt_get_address(). Signed-off-by: Samuel Holland --- platform/generic/allwinner/sun20i-d1.c | 3 ++- platform/generic/andes/ae350.c | 10 ++++------ platform/generic/andes/andes_pma.c | 6 ++---- platform/generic/include/andes/andes_pma.h | 3 ++- platform/generic/include/platform_override.h | 4 ++-- platform/generic/platform.c | 9 ++++----- platform/generic/renesas/rzfive/rzfive.c | 8 +++++--- platform/generic/sifive/fu740.c | 3 +-- platform/generic/sophgo/sg2042.c | 2 +- platform/generic/starfive/jh7110.c | 4 +--- platform/generic/thead/thead-generic.c | 2 +- 11 files changed, 25 insertions(+), 29 deletions(-) diff --git a/platform/generic/allwinner/sun20i-d1.c b/platform/generic/allwinner/sun20i-d1.c index ab2eee55..9b1d5559 100644 --- a/platform/generic/allwinner/sun20i-d1.c +++ b/platform/generic/allwinner/sun20i-d1.c @@ -187,7 +187,8 @@ static const struct sbi_hsm_device sun20i_d1_ppu = { .hart_resume = sun20i_d1_hart_resume, }; -static int sun20i_d1_final_init(bool cold_boot, const struct fdt_match *match) +static int sun20i_d1_final_init(bool cold_boot, void *fdt, + const struct fdt_match *match) { if (cold_boot) { sun20i_d1_riscv_cfg_init(); diff --git a/platform/generic/andes/ae350.c b/platform/generic/andes/ae350.c index 63c10bc4..efe36927 100644 --- a/platform/generic/andes/ae350.c +++ b/platform/generic/andes/ae350.c @@ -87,12 +87,9 @@ static const struct sbi_hsm_device andes_smu = { .hart_stop = ae350_hart_stop, }; -static void ae350_hsm_device_init(void) +static void ae350_hsm_device_init(const void *fdt) { int rc; - void *fdt; - - fdt = fdt_get_address(); rc = fdt_parse_compat_addr(fdt, (uint64_t *)&smu.addr, "andestech,atcsmu"); @@ -102,10 +99,11 @@ static void ae350_hsm_device_init(void) } } -static int ae350_final_init(bool cold_boot, const struct fdt_match *match) +static int ae350_final_init(bool cold_boot, void *fdt, + const struct fdt_match *match) { if (cold_boot) - ae350_hsm_device_init(); + ae350_hsm_device_init(fdt); return 0; } diff --git a/platform/generic/andes/andes_pma.c b/platform/generic/andes/andes_pma.c index 9c37720b..035f9ec9 100644 --- a/platform/generic/andes/andes_pma.c +++ b/platform/generic/andes/andes_pma.c @@ -238,14 +238,14 @@ static int andes_fdt_reserved_memory_fixup(void *fdt, return andes_fdt_pma_resv(fdt, pma, entry, parent); } -int andes_pma_setup_regions(const struct andes_pma_region *pma_regions, +int andes_pma_setup_regions(void *fdt, + const struct andes_pma_region *pma_regions, unsigned int pma_regions_count) { unsigned long mmsc = csr_read(CSR_MMSC_CFG); unsigned int dt_populate_cnt; unsigned int i, j; unsigned long pa; - void *fdt; int ret; if (!pma_regions || !pma_regions_count) @@ -270,8 +270,6 @@ int andes_pma_setup_regions(const struct andes_pma_region *pma_regions, if (!dt_populate_cnt) return 0; - fdt = fdt_get_address(); - ret = fdt_open_into(fdt, fdt, fdt_totalsize(fdt) + (64 * dt_populate_cnt)); if (ret < 0) diff --git a/platform/generic/include/andes/andes_pma.h b/platform/generic/include/andes/andes_pma.h index 5ea12475..1bcda788 100644 --- a/platform/generic/include/andes/andes_pma.h +++ b/platform/generic/include/andes/andes_pma.h @@ -44,7 +44,8 @@ struct andes_pma_region { bool dma_default; }; -int andes_pma_setup_regions(const struct andes_pma_region *pma_regions, +int andes_pma_setup_regions(void *fdt, + const struct andes_pma_region *pma_regions, unsigned int pma_regions_count); #endif /* _ANDES_PMA_H_ */ diff --git a/platform/generic/include/platform_override.h b/platform/generic/include/platform_override.h index bd6fdacc..946fb8f7 100644 --- a/platform/generic/include/platform_override.h +++ b/platform/generic/include/platform_override.h @@ -21,8 +21,8 @@ struct platform_override { u64 (*tlbr_flush_limit)(const struct fdt_match *match); u32 (*tlb_num_entries)(const struct fdt_match *match); bool (*cold_boot_allowed)(u32 hartid, const struct fdt_match *match); - int (*early_init)(bool cold_boot, const struct fdt_match *match); - int (*final_init)(bool cold_boot, const struct fdt_match *match); + int (*early_init)(bool cold_boot, const void *fdt, const struct fdt_match *match); + int (*final_init)(bool cold_boot, void *fdt, const struct fdt_match *match); void (*early_exit)(const struct fdt_match *match); void (*final_exit)(const struct fdt_match *match); int (*fdt_fixup)(void *fdt, const struct fdt_match *match); diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 4d26ae7c..6f9fb4db 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -221,6 +221,7 @@ static int generic_nascent_init(void) static int generic_early_init(bool cold_boot) { + const void *fdt = fdt_get_address(); int rc; if (cold_boot) { @@ -237,16 +238,16 @@ static int generic_early_init(bool cold_boot) if (!generic_plat || !generic_plat->early_init) return 0; - return generic_plat->early_init(cold_boot, generic_plat_match); + return generic_plat->early_init(cold_boot, fdt, generic_plat_match); } static int generic_final_init(bool cold_boot) { - void *fdt; + void *fdt = fdt_get_address(); int rc; if (generic_plat && generic_plat->final_init) { - rc = generic_plat->final_init(cold_boot, generic_plat_match); + rc = generic_plat->final_init(cold_boot, fdt, generic_plat_match); if (rc) return rc; } @@ -254,8 +255,6 @@ static int generic_final_init(bool cold_boot) if (!cold_boot) return 0; - fdt = fdt_get_address(); - fdt_cpu_fixup(fdt); fdt_fixups(fdt); fdt_domain_fixup(fdt); diff --git a/platform/generic/renesas/rzfive/rzfive.c b/platform/generic/renesas/rzfive/rzfive.c index 515bcd76..59084c41 100644 --- a/platform/generic/renesas/rzfive/rzfive.c +++ b/platform/generic/renesas/rzfive/rzfive.c @@ -24,13 +24,15 @@ static const struct andes_pma_region renesas_rzfive_pma_regions[] = { }, }; -static int renesas_rzfive_final_init(bool cold_boot, const struct fdt_match *match) +static int renesas_rzfive_final_init(bool cold_boot, void *fdt, + const struct fdt_match *match) { - return andes_pma_setup_regions(renesas_rzfive_pma_regions, + return andes_pma_setup_regions(fdt, renesas_rzfive_pma_regions, array_size(renesas_rzfive_pma_regions)); } -static int renesas_rzfive_early_init(bool cold_boot, const struct fdt_match *match) +static int renesas_rzfive_early_init(bool cold_boot, const void *fdt, + const struct fdt_match *match) { /* * Renesas RZ/Five RISC-V SoC has Instruction local memory and diff --git a/platform/generic/sifive/fu740.c b/platform/generic/sifive/fu740.c index ce83a050..46dc02ae 100644 --- a/platform/generic/sifive/fu740.c +++ b/platform/generic/sifive/fu740.c @@ -226,11 +226,10 @@ static u64 sifive_fu740_tlbr_flush_limit(const struct fdt_match *match) return 0; } -static int sifive_fu740_final_init(bool cold_boot, +static int sifive_fu740_final_init(bool cold_boot, void *fdt, const struct fdt_match *match) { int rc; - void *fdt = fdt_get_address(); if (cold_boot) { rc = fdt_reset_driver_init(fdt, &fdt_reset_da9063); diff --git a/platform/generic/sophgo/sg2042.c b/platform/generic/sophgo/sg2042.c index ae2d702e..eca9afb7 100644 --- a/platform/generic/sophgo/sg2042.c +++ b/platform/generic/sophgo/sg2042.c @@ -21,7 +21,7 @@ #define SOPHGO_SG2042_TIMER_SIZE 0x10000UL #define SOPHGO_SG2042_TIMER_NUM 16 -static int sophgo_sg2042_early_init(bool cold_boot, +static int sophgo_sg2042_early_init(bool cold_boot, const void *fdt, const struct fdt_match *match) { thead_register_tlb_flush_trap_handler(); diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index 48451895..264fe99c 100644 --- a/platform/generic/starfive/jh7110.c +++ b/platform/generic/starfive/jh7110.c @@ -277,11 +277,9 @@ err: return rc; } -static int starfive_jh7110_final_init(bool cold_boot, +static int starfive_jh7110_final_init(bool cold_boot, void *fdt, const struct fdt_match *match) { - void *fdt = fdt_get_address(); - if (cold_boot) { fdt_reset_driver_init(fdt, &fdt_reset_pmic); } diff --git a/platform/generic/thead/thead-generic.c b/platform/generic/thead/thead-generic.c index c82e0c1b..be64831c 100644 --- a/platform/generic/thead/thead-generic.c +++ b/platform/generic/thead/thead-generic.c @@ -19,7 +19,7 @@ struct thead_generic_quirks { u64 errata; }; -static int thead_generic_early_init(bool cold_boot, +static int thead_generic_early_init(bool cold_boot, const void *fdt, const struct fdt_match *match) { struct thead_generic_quirks *quirks = (void *)match->data;