git: 904510b2ac56 - stable/13 - powerpc: Remove flag CTLFLAG_TUN from sysctl knob hw.platform

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Tue, 18 Feb 2025 15:24:20 UTC
The branch stable/13 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=904510b2ac56900be976dbe739cfb64cb3d37a24

commit 904510b2ac56900be976dbe739cfb64cb3d37a24
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-02-13 14:42:45 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-02-18 15:23:37 +0000

    powerpc: Remove flag CTLFLAG_TUN from sysctl knob hw.platform
    
    Prior to change [1] this flag is useless but harmless. After the change
    plat_name[] will be fetched from kernel environment after invoking the
    platform probe function `platform_probe_and_attach()`. The probe function
    runs at early boot stage prior to `mi_startup()` thus it is too late and
    pointless to set plat_name[] after the probe.
    
    Nathan mentioned that the logic to specify the platform pre-dates the
    powerpc64 work, and is from the original pre-FDT Book-E bringup from
    like 2008, so it's irrelevant these days. Instead of fixing setting the
    sysctl knob hw.platform, let's clean it up now.
    
    [1] 3da1cf1e88f8 Extend the meaning of the CTLFLAG_TUN flag to ...
    
    Discussed with: nwhitehorn
    Reviewed by:    olce (previous version), jhibbits, #powerpc
    MFC after:      5 days
    Differential Revision:  https://reviews.freebsd.org/D48897
    
    (cherry picked from commit b61fbbed73ea3bf0c84589b56cca160c46a3739d)
    (cherry picked from commit 7775f4c5c75221cd9b2aadf12fb1d9a329c08be4)
---
 sys/powerpc/powerpc/platform.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/sys/powerpc/powerpc/platform.c b/sys/powerpc/powerpc/platform.c
index 0d1ab792abef..4d21ddd36b77 100644
--- a/sys/powerpc/powerpc/platform.c
+++ b/sys/powerpc/powerpc/platform.c
@@ -65,9 +65,9 @@ static platform_t	plat_obj;
 static struct kobj_ops	plat_kernel_kops;
 static struct platform_kobj	plat_kernel_obj;
 
-static char plat_name[64] = "";
-SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RDTUN,
-    plat_name, 0, "Platform currently in use");
+static char plat_name[64];
+SYSCTL_CONST_STRING(_hw, OID_AUTO, platform, CTLFLAG_RD, plat_name,
+    "Platform currently in use");
 
 static struct mem_affinity mem_info[VM_PHYSSEG_MAX + 1];
 static int vm_locality_table[MAXMEMDOM * MAXMEMDOM];
@@ -364,16 +364,7 @@ platform_probe_and_attach()
 		if (prio > 0)
 			continue;
 
-		/*
-		 * Check if this module was specifically requested through
-		 * the loader tunable we provide.
-		 */
-		if (strcmp(platp->name,plat_name) == 0) {
-			plat_def_impl = platp;
-			break;
-		}
-
-		/* Otherwise, see if it is better than our current best */
+		/* See if it is better than our current best */
 		if (plat_def_impl == NULL || prio > best_prio) {
 			best_prio = prio;
 			plat_def_impl = platp;