From owner-svn-src-head@freebsd.org Sat May 5 15:48:40 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ABD8EFB1459; Sat, 5 May 2018 15:48:40 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 59DDF825C7; Sat, 5 May 2018 15:48:40 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 54BF01FA12; Sat, 5 May 2018 15:48:40 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w45Fme14009946; Sat, 5 May 2018 15:48:40 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w45Fmet6009943; Sat, 5 May 2018 15:48:40 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201805051548.w45Fmet6009943@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Sat, 5 May 2018 15:48:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333272 - in head/sys/powerpc: include powerpc X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: in head/sys/powerpc: include powerpc X-SVN-Commit-Revision: 333272 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2018 15:48:40 -0000 Author: jhibbits Date: Sat May 5 15:48:39 2018 New Revision: 333272 URL: https://svnweb.freebsd.org/changeset/base/333272 Log: Break out the cpu_features setup to its own function, to be run earlier The new POWER9 MMU configuration is slightly different from current setups. Rather than special-casing on POWER9, move the initialization of cpu_features and cpu_features2 to as early as possible, so that platform and MMU configuration can be based upon CPU features instead of specific CPUs if at all possible. Reviewed by: nwhitehorn Modified: head/sys/powerpc/include/md_var.h head/sys/powerpc/powerpc/cpu.c head/sys/powerpc/powerpc/machdep.c Modified: head/sys/powerpc/include/md_var.h ============================================================================== --- head/sys/powerpc/include/md_var.h Sat May 5 15:42:58 2018 (r333271) +++ head/sys/powerpc/include/md_var.h Sat May 5 15:48:39 2018 (r333272) @@ -63,6 +63,7 @@ void decr_init(void); void decr_ap_init(void); void decr_tc_init(void); +void cpu_feature_setup(void); void cpu_setup(u_int); struct trapframe; Modified: head/sys/powerpc/powerpc/cpu.c ============================================================================== --- head/sys/powerpc/powerpc/cpu.c Sat May 5 15:42:58 2018 (r333271) +++ head/sys/powerpc/powerpc/cpu.c Sat May 5 15:48:39 2018 (r333272) @@ -231,6 +231,8 @@ static int cpu_feature_bit(SYSCTL_HANDLER_ARGS); static char model[64]; SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, model, 0, ""); +static const struct cputab *cput; + u_long cpu_features = PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU; u_long cpu_features2 = 0; SYSCTL_OPAQUE(_hw, OID_AUTO, cpu_features, CTLFLAG_RD, @@ -245,14 +247,37 @@ SYSCTL_PROC(_hw, OID_AUTO, floatingpoint, CTLTYPE_INT SYSCTL_PROC(_hw, OID_AUTO, altivec, CTLTYPE_INT | CTLFLAG_RD, 0, PPC_FEATURE_HAS_ALTIVEC, cpu_feature_bit, "I", "CPU supports Altivec"); +/* + * Phase 1 (early) CPU setup. Setup the cpu_features/cpu_features2 variables, + * so they can be used during platform and MMU bringup. + */ void +cpu_feature_setup() +{ + u_int pvr; + uint16_t vers; + const struct cputab *cp; + + pvr = mfpvr(); + vers = pvr >> 16; + for (cp = models; cp->version != 0; cp++) { + if (cp->version == vers) + break; + } + + cput = cp; + cpu_features |= cp->features; + cpu_features2 |= cp->features2; +} + + +void cpu_setup(u_int cpuid) { - u_int pvr, maj, min; - uint16_t vers, rev, revfmt; uint64_t cps; - const struct cputab *cp; const char *name; + u_int maj, min, pvr; + uint16_t rev, revfmt, vers; pvr = mfpvr(); vers = pvr >> 16; @@ -274,13 +299,8 @@ cpu_setup(u_int cpuid) min = (pvr >> 0) & 0xf; } - for (cp = models; cp->version != 0; cp++) { - if (cp->version == vers) - break; - } - - revfmt = cp->revfmt; - name = cp->name; + revfmt = cput->revfmt; + name = cput->name; if (rev == MPC750 && pvr == 15) { name = "Motorola MPC755"; revfmt = REVFMT_HEX; @@ -305,8 +325,6 @@ cpu_setup(u_int cpuid) printf(", %jd.%02jd MHz", cps / 1000000, (cps / 10000) % 100); printf("\n"); - cpu_features |= cp->features; - cpu_features2 |= cp->features2; printf("cpu%d: Features %b\n", cpuid, (int)cpu_features, PPC_FEATURE_BITMASK); if (cpu_features2 != 0) @@ -316,8 +334,8 @@ cpu_setup(u_int cpuid) /* * Configure CPU */ - if (cp->cpu_setup != NULL) - cp->cpu_setup(cpuid, vers); + if (cput->cpu_setup != NULL) + cput->cpu_setup(cpuid, vers); } /* Get current clock frequency for the given cpu id. */ Modified: head/sys/powerpc/powerpc/machdep.c ============================================================================== --- head/sys/powerpc/powerpc/machdep.c Sat May 5 15:42:58 2018 (r333271) +++ head/sys/powerpc/powerpc/machdep.c Sat May 5 15:48:39 2018 (r333272) @@ -275,6 +275,8 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offs bzero(__bss_start, _end - __bss_start); #endif + cpu_feature_setup(); + #ifdef AIM aim_early_init(fdt, toc, ofentry, mdp, mdp_cookie); #endif