From owner-svn-src-all@freebsd.org Mon Oct 19 19:18:04 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DF9F9A1969E; Mon, 19 Oct 2015 19:18:03 +0000 (UTC) (envelope-from ian@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 mx1.freebsd.org (Postfix) with ESMTPS id B48D26DC; Mon, 19 Oct 2015 19:18:03 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9JJI2de006704; Mon, 19 Oct 2015 19:18:02 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9JJI2eB006699; Mon, 19 Oct 2015 19:18:02 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201510191918.t9JJI2eB006699@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Mon, 19 Oct 2015 19:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289602 - in head/sys/arm: arm include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2015 19:18:04 -0000 Author: ian Date: Mon Oct 19 19:18:02 2015 New Revision: 289602 URL: https://svnweb.freebsd.org/changeset/base/289602 Log: Set the correct values in the arm aux control register, based on chip type. The bits in the aux control register vary based on the processor type. In the past we've always just set the 'smp' and "broadcast tlb/cache ops' bits, which worked fine for the first few SoCs we supported. Now that we support most of the cortex-a series processors, it's important to get the right bits set based on the processor type. Submitted by: Svatopluk Kraus Modified: head/sys/arm/arm/cpufunc.c head/sys/arm/arm/cpuinfo.c head/sys/arm/arm/mp_machdep.c head/sys/arm/arm/pmap-v6-new.c head/sys/arm/include/cpuinfo.h Modified: head/sys/arm/arm/cpufunc.c ============================================================================== --- head/sys/arm/arm/cpufunc.c Mon Oct 19 18:45:14 2015 (r289601) +++ head/sys/arm/arm/cpufunc.c Mon Oct 19 19:18:02 2015 (r289602) @@ -1294,7 +1294,7 @@ cortexa_setup(void) /* And again. */ cpu_idcache_wbinv_all(); -#ifdef SMP +#if defined(SMP) && !defined(ARM_NEW_PMAP) armv7_auxctrl((1 << 6) | (1 << 0), (1 << 6) | (1 << 0)); /* Enable SMP + TLB broadcasting */ #endif Modified: head/sys/arm/arm/cpuinfo.c ============================================================================== --- head/sys/arm/arm/cpuinfo.c Mon Oct 19 18:45:14 2015 (r289601) +++ head/sys/arm/arm/cpuinfo.c Mon Oct 19 19:18:02 2015 (r289602) @@ -145,3 +145,82 @@ cpuinfo_init(void) cpuinfo.dcache_line_mask = cpuinfo.dcache_line_size - 1; cpuinfo.icache_line_mask = cpuinfo.icache_line_size - 1; } + +/* + * Get bits that must be set or cleared in ACLR register. + * Note: Bits in ACLR register are IMPLEMENTATION DEFINED. + * Its expected that SCU is in operational state before this + * function is called. + */ +void +cpuinfo_get_actlr_modifier(uint32_t *actlr_mask, uint32_t *actlr_set) +{ + *actlr_mask = 0; + *actlr_set = 0; + + if (cpuinfo.implementer == CPU_IMPLEMENTER_ARM) { + switch (cpuinfo.part_number) { + + case CPU_ARCH_CORTEX_A17: + case CPU_ARCH_CORTEX_A12: /* A12 is merged to A17 */ + /* + * Enable SMP mode + */ + *actlr_mask = (1 << 6); + *actlr_set = (1 << 6); + break; + case CPU_ARCH_CORTEX_A15: + /* + * Enable snoop-delayed exclusive handling + * Enable SMP mode + */ + *actlr_mask = (1U << 31) |(1 << 6); + *actlr_set = (1U << 31) |(1 << 6); + break; + case CPU_ARCH_CORTEX_A9: + /* + * Disable exclusive L1/L2 cache control + * Enable SMP mode + * Enable Cache and TLB maintenance broadcast + */ + *actlr_mask = (1 << 7) | (1 << 6) | (1 << 0); + *actlr_set = (1 << 6) | (1 << 0); + break; + case CPU_ARCH_CORTEX_A8: + /* + * Enable L2 cache + * Enable L1 data cache hardware alias checks + */ + *actlr_mask = (1 << 1) | (1 << 0); + *actlr_set = (1 << 1); + break; + case CPU_ARCH_CORTEX_A7: + /* + * Enable SMP mode + */ + *actlr_mask = (1 << 6); + *actlr_set = (1 << 6); + break; + case CPU_ARCH_CORTEX_A5: + /* + * Disable exclusive L1/L2 cache control + * Enable SMP mode + * Enable Cache and TLB maintenance broadcast + */ + *actlr_mask = (1 << 7) | (1 << 6) | (1 << 0); + *actlr_set = (1 << 6) | (1 << 0); + break; + case CPU_ARCH_ARM1176: + /* + * Restrict cache size to 16KB + * Enable the return stack + * Enable dynamic branch prediction + * Enable static branch prediction + */ + *actlr_mask = (1 << 6) | (1 << 2) | (1 << 1) | (1 << 0); + *actlr_set = (1 << 6) | (1 << 2) | (1 << 1) | (1 << 0); + break; + } + return; + } +} Modified: head/sys/arm/arm/mp_machdep.c ============================================================================== --- head/sys/arm/arm/mp_machdep.c Mon Oct 19 18:45:14 2015 (r289601) +++ head/sys/arm/arm/mp_machdep.c Mon Oct 19 19:18:02 2015 (r289602) @@ -154,10 +154,12 @@ init_secondary(int cpu) #ifndef ARM_INTRNG int start = 0, end = 0; #endif - #ifdef ARM_NEW_PMAP + uint32_t actlr_mask, actlr_set; + pmap_set_tex(); - reinit_mmu(pmap_kern_ttb, (1<<6) | (1<< 0), (1<<6) | (1<< 0)); + cpuinfo_get_actlr_modifier(&actlr_mask, &actlr_set); + reinit_mmu(pmap_kern_ttb, actlr_mask, actlr_set); cpu_setup(); /* Provide stack pointers for other processor modes. */ Modified: head/sys/arm/arm/pmap-v6-new.c ============================================================================== --- head/sys/arm/arm/pmap-v6-new.c Mon Oct 19 18:45:14 2015 (r289601) +++ head/sys/arm/arm/pmap-v6-new.c Mon Oct 19 19:18:02 2015 (r289602) @@ -713,6 +713,7 @@ pmap_bootstrap_prepare(vm_paddr_t last) pt1_entry_t *pte1p; pt2_entry_t *pte2p; u_int i; + uint32_t actlr_mask, actlr_set; /* * Now, we are going to make real kernel mapping. Note that we are @@ -829,8 +830,8 @@ pmap_bootstrap_prepare(vm_paddr_t last) /* Finally, switch from 'boot_pt1' to 'kern_pt1'. */ pmap_kern_ttb = base_pt1 | ttb_flags; - reinit_mmu(pmap_kern_ttb, (1 << 6) | (1 << 0), (1 << 6) | (1 << 0)); - + cpuinfo_get_actlr_modifier(&actlr_mask, &actlr_set); + reinit_mmu(pmap_kern_ttb, actlr_mask, actlr_set); /* * Initialize the first available KVA. As kernel image is mapped by * sections, we are leaving some gap behind. Modified: head/sys/arm/include/cpuinfo.h ============================================================================== --- head/sys/arm/include/cpuinfo.h Mon Oct 19 18:45:14 2015 (r289601) +++ head/sys/arm/include/cpuinfo.h Mon Oct 19 19:18:02 2015 (r289602) @@ -32,6 +32,23 @@ #include +#define CPU_IMPLEMENTER_ARM 0x41 +#define CPU_IMPLEMENTER_QCOM 0x51 +#define CPU_IMPLEMENTER_MRVL 0x56 + +/* ARM */ +#define CPU_ARCH_ARM1176 0xB76 +#define CPU_ARCH_CORTEX_A5 0xC05 +#define CPU_ARCH_CORTEX_A7 0xC07 +#define CPU_ARCH_CORTEX_A8 0xC08 +#define CPU_ARCH_CORTEX_A9 0xC09 +#define CPU_ARCH_CORTEX_A12 0xC0D +#define CPU_ARCH_CORTEX_A15 0xC0F +#define CPU_ARCH_CORTEX_A17 0xC11 + +/* QCOM */ +#define CPU_ARCH_KRAIT_300 0x06F + struct cpuinfo { /* raw id registers */ uint32_t midr; @@ -93,5 +110,5 @@ struct cpuinfo { extern struct cpuinfo cpuinfo; void cpuinfo_init(void); - +void cpuinfo_get_actlr_modifier(uint32_t *actlr_mask, uint32_t *actlr_set); #endif /* _MACHINE_CPUINFO_H_ */