| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cpufunc.c,v 1.26 2020/10/22 07:31:15 skrll Exp $ */ | | 1 | /* $NetBSD: cpufunc.c,v 1.27 2021/01/11 17:12:13 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org> | | 4 | * Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | | 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | | 24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include "opt_cpuoptions.h" | | 29 | #include "opt_cpuoptions.h" |
30 | #include "opt_multiprocessor.h" | | 30 | #include "opt_multiprocessor.h" |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.26 2020/10/22 07:31:15 skrll Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.27 2021/01/11 17:12:13 skrll Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/types.h> | | 36 | #include <sys/types.h> |
37 | #include <sys/kmem.h> | | 37 | #include <sys/kmem.h> |
38 | #include <sys/cpu.h> | | 38 | #include <sys/cpu.h> |
39 | | | 39 | |
40 | #include <uvm/uvm.h> | | 40 | #include <uvm/uvm.h> |
41 | #include <uvm/uvm_page.h> | | 41 | #include <uvm/uvm_page.h> |
42 | | | 42 | |
43 | #include <arm/cpufunc.h> | | 43 | #include <arm/cpufunc.h> |
44 | | | 44 | |
45 | u_int cputype; /* compat arm */ | | 45 | u_int cputype; /* compat arm */ |
46 | u_int arm_dcache_align; /* compat arm */ | | 46 | u_int arm_dcache_align; /* compat arm */ |
| @@ -429,50 +429,51 @@ aarch64_dcache_wb_all(void) | | | @@ -429,50 +429,51 @@ aarch64_dcache_wb_all(void) |
429 | | | 429 | |
430 | dsb(ish); | | 430 | dsb(ish); |
431 | ln_dcache_wb_all(level, &cinfo[level].dcache); | | 431 | ln_dcache_wb_all(level, &cinfo[level].dcache); |
432 | } | | 432 | } |
433 | dsb(ish); | | 433 | dsb(ish); |
434 | } | | 434 | } |
435 | | | 435 | |
436 | int | | 436 | int |
437 | set_cpufuncs(void) | | 437 | set_cpufuncs(void) |
438 | { | | 438 | { |
439 | struct cpu_info * const ci = curcpu(); | | 439 | struct cpu_info * const ci = curcpu(); |
440 | const uint64_t ctr = reg_ctr_el0_read(); | | 440 | const uint64_t ctr = reg_ctr_el0_read(); |
441 | const uint64_t clidr = reg_clidr_el1_read(); | | 441 | const uint64_t clidr = reg_clidr_el1_read(); |
442 | const uint32_t midr __unused = reg_midr_el1_read(); | | | |
443 | | | 442 | |
444 | /* install default functions */ | | 443 | /* install default functions */ |
445 | ci->ci_cpufuncs.cf_set_ttbr0 = aarch64_set_ttbr0; | | 444 | ci->ci_cpufuncs.cf_set_ttbr0 = aarch64_set_ttbr0; |
446 | ci->ci_cpufuncs.cf_icache_sync_range = aarch64_icache_sync_range; | | 445 | ci->ci_cpufuncs.cf_icache_sync_range = aarch64_icache_sync_range; |
447 | | | 446 | |
448 | /* | | 447 | /* |
449 | * install core/cluster specific functions | | 448 | * install core/cluster specific functions |
450 | */ | | 449 | */ |
451 | | | 450 | |
452 | /* Icache sync op */ | | 451 | /* Icache sync op */ |
453 | if (__SHIFTOUT(ctr, CTR_EL0_DIC) == 1) { | | 452 | if (__SHIFTOUT(ctr, CTR_EL0_DIC) == 1) { |
454 | /* Icache invalidation to the PoU is not required */ | | 453 | /* Icache invalidation to the PoU is not required */ |
455 | ci->ci_cpufuncs.cf_icache_sync_range = | | 454 | ci->ci_cpufuncs.cf_icache_sync_range = |
456 | aarch64_icache_barrier_range; | | 455 | aarch64_icache_barrier_range; |
457 | } else if (__SHIFTOUT(ctr, CTR_EL0_IDC) == 1 || | | 456 | } else if (__SHIFTOUT(ctr, CTR_EL0_IDC) == 1 || |
458 | __SHIFTOUT(clidr, CLIDR_LOC) == 0 || | | 457 | __SHIFTOUT(clidr, CLIDR_LOC) == 0 || |
459 | (__SHIFTOUT(clidr, CLIDR_LOUIS) == 0 && __SHIFTOUT(clidr, CLIDR_LOUU) == 0)) { | | 458 | (__SHIFTOUT(clidr, CLIDR_LOUIS) == 0 && __SHIFTOUT(clidr, CLIDR_LOUU) == 0)) { |
460 | /* Dcache clean to the PoU is not required for Icache */ | | 459 | /* Dcache clean to the PoU is not required for Icache */ |
461 | ci->ci_cpufuncs.cf_icache_sync_range = | | 460 | ci->ci_cpufuncs.cf_icache_sync_range = |
462 | aarch64_icache_inv_range; | | 461 | aarch64_icache_inv_range; |
463 | } | | 462 | } |
464 | | | 463 | |
465 | #ifdef CPU_THUNDERX | | 464 | #ifdef CPU_THUNDERX |
| | | 465 | const uint32_t midr = reg_midr_el1_read(); |
| | | 466 | |
466 | /* Cavium erratum 27456 */ | | 467 | /* Cavium erratum 27456 */ |
467 | if ((midr == CPU_ID_THUNDERXP1d0) || | | 468 | if ((midr == CPU_ID_THUNDERXP1d0) || |
468 | (midr == CPU_ID_THUNDERXP1d1) || | | 469 | (midr == CPU_ID_THUNDERXP1d1) || |
469 | (midr == CPU_ID_THUNDERXP2d1) || | | 470 | (midr == CPU_ID_THUNDERXP2d1) || |
470 | (midr == CPU_ID_THUNDERX81XXRX)) { | | 471 | (midr == CPU_ID_THUNDERX81XXRX)) { |
471 | ci->ci_cpufuncs.cf_set_ttbr0 = aarch64_set_ttbr0_thunderx; | | 472 | ci->ci_cpufuncs.cf_set_ttbr0 = aarch64_set_ttbr0_thunderx; |
472 | } | | 473 | } |
473 | #endif | | 474 | #endif |
474 | | | 475 | |
475 | return 0; | | 476 | return 0; |
476 | } | | 477 | } |
477 | | | 478 | |
478 | void | | 479 | void |