Fri Jun 8 23:40:44 2018 UTC ()
when switching CPU speed using DFS, only use xcalls on MULTIPROCESSOR kernels


(macallan)
diff -r1.95 -r1.96 src/sys/arch/powerpc/oea/cpu_subr.c

cvs diff -r1.95 -r1.96 src/sys/arch/powerpc/oea/cpu_subr.c (expand / switch to unified diff)

--- src/sys/arch/powerpc/oea/cpu_subr.c 2018/06/01 18:06:58 1.95
+++ src/sys/arch/powerpc/oea/cpu_subr.c 2018/06/08 23:40:44 1.96
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpu_subr.c,v 1.95 2018/06/01 18:06:58 macallan Exp $ */ 1/* $NetBSD: cpu_subr.c,v 1.96 2018/06/08 23:40:44 macallan Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 Matt Thomas. 4 * Copyright (c) 2001 Matt Thomas.
5 * Copyright (c) 2001 Tsubai Masanari. 5 * Copyright (c) 2001 Tsubai Masanari.
6 * Copyright (c) 1998, 1999, 2001 Internet Research Institute, Inc. 6 * Copyright (c) 1998, 1999, 2001 Internet Research Institute, Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.95 2018/06/01 18:06:58 macallan Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.96 2018/06/08 23:40:44 macallan Exp $");
38 38
39#include "opt_ppcparam.h" 39#include "opt_ppcparam.h"
40#include "opt_ppccache.h" 40#include "opt_ppccache.h"
41#include "opt_multiprocessor.h" 41#include "opt_multiprocessor.h"
42#include "opt_altivec.h" 42#include "opt_altivec.h"
43#include "sysmon_envsys.h" 43#include "sysmon_envsys.h"
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46#include <sys/systm.h> 46#include <sys/systm.h>
47#include <sys/device.h> 47#include <sys/device.h>
48#include <sys/types.h> 48#include <sys/types.h>
49#include <sys/lwp.h> 49#include <sys/lwp.h>
50#include <sys/xcall.h> 50#include <sys/xcall.h>
@@ -1134,47 +1134,50 @@ cpu_get_dfs(void) @@ -1134,47 +1134,50 @@ cpu_get_dfs(void)
1134 case MPC7447A: 1134 case MPC7447A:
1135 if (mfspr(SPR_HID1) & HID1_DFS2) 1135 if (mfspr(SPR_HID1) & HID1_DFS2)
1136 return 2; 1136 return 2;
1137 } 1137 }
1138 return 1; 1138 return 1;
1139} 1139}
1140 1140
1141/* 1141/*
1142 * Set the Dynamic Frequency Switching divisor the same for all cpus. 1142 * Set the Dynamic Frequency Switching divisor the same for all cpus.
1143 */ 1143 */
1144void 1144void
1145cpu_set_dfs(int div) 1145cpu_set_dfs(int div)
1146{ 1146{
1147 uint64_t where; 
1148 u_int dfs_mask, pvr, vers; 1147 u_int dfs_mask, pvr, vers;
1149 1148
1150 pvr = mfpvr(); 1149 pvr = mfpvr();
1151 vers = pvr >> 16; 1150 vers = pvr >> 16;
1152 dfs_mask = 0; 1151 dfs_mask = 0;
1153 1152
1154 switch (vers) { 1153 switch (vers) {
1155 case MPC7448: 1154 case MPC7448:
1156 dfs_mask |= HID1_DFS4; 1155 dfs_mask |= HID1_DFS4;
1157 case MPC7447A: 1156 case MPC7447A:
1158 dfs_mask |= HID1_DFS2; 1157 dfs_mask |= HID1_DFS2;
1159 break; 1158 break;
1160 default: 1159 default:
1161 printf("cpu_set_dfs: DFS not supported\n"); 1160 printf("cpu_set_dfs: DFS not supported\n");
1162 return; 1161 return;
1163 1162
1164 } 1163 }
1165 1164#ifdef MULTIPROCESSOR
 1165 uint64_t where;
1166 where = xc_broadcast(0, (xcfunc_t)cpu_set_dfs_xcall, &div, &dfs_mask); 1166 where = xc_broadcast(0, (xcfunc_t)cpu_set_dfs_xcall, &div, &dfs_mask);
1167 xc_wait(where); 1167 xc_wait(where);
 1168#else
 1169 cpu_set_dfs_xcall(&div, &dfs_mask);
 1170#endif
1168} 1171}
1169 1172
1170static void 1173static void
1171cpu_set_dfs_xcall(void *arg1, void *arg2) 1174cpu_set_dfs_xcall(void *arg1, void *arg2)
1172{ 1175{
1173 u_int dfs_mask, hid1, old_hid1; 1176 u_int dfs_mask, hid1, old_hid1;
1174 int *divisor, s; 1177 int *divisor, s;
1175 1178
1176 divisor = arg1; 1179 divisor = arg1;
1177 dfs_mask = *(u_int *)arg2; 1180 dfs_mask = *(u_int *)arg2;
1178 1181
1179 s = splhigh(); 1182 s = splhigh();
1180 hid1 = old_hid1 = mfspr(SPR_HID1); 1183 hid1 = old_hid1 = mfspr(SPR_HID1);