@@ -186,7 +186,7 @@ static void unmap_cpu_from_node(unsigned long cpu)
186186 dbg ("removing cpu %lu from node %d\n" , cpu , node );
187187
188188 if (cpumask_test_cpu (cpu , node_to_cpumask_map [node ])) {
189- cpumask_set_cpu (cpu , node_to_cpumask_map [node ]);
189+ cpumask_clear_cpu (cpu , node_to_cpumask_map [node ]);
190190 } else {
191191 printk (KERN_ERR "WARNING: cpu %lu not found in node %d\n" ,
192192 cpu , node );
@@ -1289,10 +1289,9 @@ u64 memory_hotplug_max(void)
12891289}
12901290#endif /* CONFIG_MEMORY_HOTPLUG */
12911291
1292- /* Vrtual Processor Home Node (VPHN) support */
1292+ /* Virtual Processor Home Node (VPHN) support */
12931293#ifdef CONFIG_PPC_SPLPAR
1294- #define VPHN_NR_CHANGE_CTRS (8)
1295- static u8 vphn_cpu_change_counts [NR_CPUS ][VPHN_NR_CHANGE_CTRS ];
1294+ static u8 vphn_cpu_change_counts [NR_CPUS ][MAX_DISTANCE_REF_POINTS ];
12961295static cpumask_t cpu_associativity_changes_mask ;
12971296static int vphn_enabled ;
12981297static void set_topology_timer (void );
@@ -1303,16 +1302,18 @@ static void set_topology_timer(void);
13031302 */
13041303static void setup_cpu_associativity_change_counters (void )
13051304{
1306- int cpu = 0 ;
1305+ int cpu ;
1306+
1307+ /* The VPHN feature supports a maximum of 8 reference points */
1308+ BUILD_BUG_ON (MAX_DISTANCE_REF_POINTS > 8 );
13071309
13081310 for_each_possible_cpu (cpu ) {
1309- int i = 0 ;
1311+ int i ;
13101312 u8 * counts = vphn_cpu_change_counts [cpu ];
13111313 volatile u8 * hypervisor_counts = lppaca [cpu ].vphn_assoc_counts ;
13121314
1313- for (i = 0 ; i < VPHN_NR_CHANGE_CTRS ; i ++ ) {
1315+ for (i = 0 ; i < distance_ref_points_depth ; i ++ )
13141316 counts [i ] = hypervisor_counts [i ];
1315- }
13161317 }
13171318}
13181319
@@ -1329,7 +1330,7 @@ static void setup_cpu_associativity_change_counters(void)
13291330 */
13301331static int update_cpu_associativity_changes_mask (void )
13311332{
1332- int cpu = 0 , nr_cpus = 0 ;
1333+ int cpu , nr_cpus = 0 ;
13331334 cpumask_t * changes = & cpu_associativity_changes_mask ;
13341335
13351336 cpumask_clear (changes );
@@ -1339,8 +1340,8 @@ static int update_cpu_associativity_changes_mask(void)
13391340 u8 * counts = vphn_cpu_change_counts [cpu ];
13401341 volatile u8 * hypervisor_counts = lppaca [cpu ].vphn_assoc_counts ;
13411342
1342- for (i = 0 ; i < VPHN_NR_CHANGE_CTRS ; i ++ ) {
1343- if (hypervisor_counts [i ] > counts [i ]) {
1343+ for (i = 0 ; i < distance_ref_points_depth ; i ++ ) {
1344+ if (hypervisor_counts [i ] != counts [i ]) {
13441345 counts [i ] = hypervisor_counts [i ];
13451346 changed = 1 ;
13461347 }
@@ -1354,39 +1355,39 @@ static int update_cpu_associativity_changes_mask(void)
13541355 return nr_cpus ;
13551356}
13561357
1357- /* 6 64-bit registers unpacked into 12 32-bit associativity values */
1358- #define VPHN_ASSOC_BUFSIZE (6*sizeof(u64)/sizeof(u32))
1358+ /*
1359+ * 6 64-bit registers unpacked into 12 32-bit associativity values. To form
1360+ * the complete property we have to add the length in the first cell.
1361+ */
1362+ #define VPHN_ASSOC_BUFSIZE (6*sizeof(u64)/sizeof(u32) + 1)
13591363
13601364/*
13611365 * Convert the associativity domain numbers returned from the hypervisor
13621366 * to the sequence they would appear in the ibm,associativity property.
13631367 */
13641368static int vphn_unpack_associativity (const long * packed , unsigned int * unpacked )
13651369{
1366- int i = 0 ;
1367- int nr_assoc_doms = 0 ;
1370+ int i , nr_assoc_doms = 0 ;
13681371 const u16 * field = (const u16 * ) packed ;
13691372
13701373#define VPHN_FIELD_UNUSED (0xffff)
13711374#define VPHN_FIELD_MSB (0x8000)
13721375#define VPHN_FIELD_MASK (~VPHN_FIELD_MSB)
13731376
1374- for (i = 0 ; i < VPHN_ASSOC_BUFSIZE ; i ++ ) {
1377+ for (i = 1 ; i < VPHN_ASSOC_BUFSIZE ; i ++ ) {
13751378 if (* field == VPHN_FIELD_UNUSED ) {
13761379 /* All significant fields processed, and remaining
13771380 * fields contain the reserved value of all 1's.
13781381 * Just store them.
13791382 */
13801383 unpacked [i ] = * ((u32 * )field );
13811384 field += 2 ;
1382- }
1383- else if (* field & VPHN_FIELD_MSB ) {
1385+ } else if (* field & VPHN_FIELD_MSB ) {
13841386 /* Data is in the lower 15 bits of this field */
13851387 unpacked [i ] = * field & VPHN_FIELD_MASK ;
13861388 field ++ ;
13871389 nr_assoc_doms ++ ;
1388- }
1389- else {
1390+ } else {
13901391 /* Data is in the lower 15 bits of this field
13911392 * concatenated with the next 16 bit field
13921393 */
@@ -1396,6 +1397,9 @@ static int vphn_unpack_associativity(const long *packed, unsigned int *unpacked)
13961397 }
13971398 }
13981399
1400+ /* The first cell contains the length of the property */
1401+ unpacked [0 ] = nr_assoc_doms ;
1402+
13991403 return nr_assoc_doms ;
14001404}
14011405
@@ -1405,7 +1409,7 @@ static int vphn_unpack_associativity(const long *packed, unsigned int *unpacked)
14051409 */
14061410static long hcall_vphn (unsigned long cpu , unsigned int * associativity )
14071411{
1408- long rc = 0 ;
1412+ long rc ;
14091413 long retbuf [PLPAR_HCALL9_BUFSIZE ] = {0 };
14101414 u64 flags = 1 ;
14111415 int hwcpu = get_hard_smp_processor_id (cpu );
@@ -1419,7 +1423,7 @@ static long hcall_vphn(unsigned long cpu, unsigned int *associativity)
14191423static long vphn_get_associativity (unsigned long cpu ,
14201424 unsigned int * associativity )
14211425{
1422- long rc = 0 ;
1426+ long rc ;
14231427
14241428 rc = hcall_vphn (cpu , associativity );
14251429
@@ -1445,9 +1449,9 @@ static long vphn_get_associativity(unsigned long cpu,
14451449 */
14461450int arch_update_cpu_topology (void )
14471451{
1448- int cpu = 0 , nid = 0 , old_nid = 0 ;
1452+ int cpu , nid , old_nid ;
14491453 unsigned int associativity [VPHN_ASSOC_BUFSIZE ] = {0 };
1450- struct sys_device * sysdev = NULL ;
1454+ struct sys_device * sysdev ;
14511455
14521456 for_each_cpu_mask (cpu , cpu_associativity_changes_mask ) {
14531457 vphn_get_associativity (cpu , associativity );
@@ -1512,7 +1516,8 @@ int start_topology_update(void)
15121516{
15131517 int rc = 0 ;
15141518
1515- if (firmware_has_feature (FW_FEATURE_VPHN )) {
1519+ if (firmware_has_feature (FW_FEATURE_VPHN ) &&
1520+ get_lppaca ()-> shared_proc ) {
15161521 vphn_enabled = 1 ;
15171522 setup_cpu_associativity_change_counters ();
15181523 init_timer_deferrable (& topology_timer );
0 commit comments