@@ -1531,33 +1531,57 @@ static void update_cpu_capabilities(u16 scope_mask)
1531
1531
}
1532
1532
}
1533
1533
1534
- static int __enable_cpu_capability (void * arg )
1534
+ /*
1535
+ * Enable all the available capabilities on this CPU. The capabilities
1536
+ * with BOOT_CPU scope are handled separately and hence skipped here.
1537
+ */
1538
+ static int cpu_enable_non_boot_scope_capabilities (void * __unused )
1535
1539
{
1536
- const struct arm64_cpu_capabilities * cap = arg ;
1540
+ int i ;
1541
+ u16 non_boot_scope = SCOPE_ALL & ~SCOPE_BOOT_CPU ;
1542
+
1543
+ for_each_available_cap (i ) {
1544
+ const struct arm64_cpu_capabilities * cap = cpu_hwcaps_ptrs [i ];
1545
+
1546
+ if (WARN_ON (!cap ))
1547
+ continue ;
1548
+
1549
+ if (!(cap -> type & non_boot_scope ))
1550
+ continue ;
1537
1551
1538
- cap -> cpu_enable (cap );
1552
+ if (cap -> cpu_enable )
1553
+ cap -> cpu_enable (cap );
1554
+ }
1539
1555
return 0 ;
1540
1556
}
1541
1557
1542
1558
/*
1543
1559
* Run through the enabled capabilities and enable() it on all active
1544
1560
* CPUs
1545
1561
*/
1546
- static void __init
1547
- __enable_cpu_capabilities (const struct arm64_cpu_capabilities * caps ,
1548
- u16 scope_mask )
1562
+ static void __init enable_cpu_capabilities (u16 scope_mask )
1549
1563
{
1564
+ int i ;
1565
+ const struct arm64_cpu_capabilities * caps ;
1566
+ bool boot_scope ;
1567
+
1550
1568
scope_mask &= ARM64_CPUCAP_SCOPE_MASK ;
1551
- for (; caps -> matches ; caps ++ ) {
1552
- unsigned int num = caps -> capability ;
1569
+ boot_scope = !!(scope_mask & SCOPE_BOOT_CPU );
1570
+
1571
+ for (i = 0 ; i < ARM64_NCAPS ; i ++ ) {
1572
+ unsigned int num ;
1553
1573
1554
- if (!(caps -> type & scope_mask ) || !cpus_have_cap (num ))
1574
+ caps = cpu_hwcaps_ptrs [i ];
1575
+ if (!caps || !(caps -> type & scope_mask ))
1576
+ continue ;
1577
+ num = caps -> capability ;
1578
+ if (!cpus_have_cap (num ))
1555
1579
continue ;
1556
1580
1557
1581
/* Ensure cpus_have_const_cap(num) works */
1558
1582
static_branch_enable (& cpu_hwcap_keys [num ]);
1559
1583
1560
- if (caps -> cpu_enable ) {
1584
+ if (boot_scope && caps -> cpu_enable )
1561
1585
/*
1562
1586
* Capabilities with SCOPE_BOOT_CPU scope are finalised
1563
1587
* before any secondary CPU boots. Thus, each secondary
@@ -1566,25 +1590,19 @@ __enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
1566
1590
* the boot CPU, for which the capability must be
1567
1591
* enabled here. This approach avoids costly
1568
1592
* stop_machine() calls for this case.
1569
- *
1570
- * Otherwise, use stop_machine() as it schedules the
1571
- * work allowing us to modify PSTATE, instead of
1572
- * on_each_cpu() which uses an IPI, giving us a PSTATE
1573
- * that disappears when we return.
1574
1593
*/
1575
- if (scope_mask & SCOPE_BOOT_CPU )
1576
- caps -> cpu_enable (caps );
1577
- else
1578
- stop_machine (__enable_cpu_capability ,
1579
- (void * )caps , cpu_online_mask );
1580
- }
1594
+ caps -> cpu_enable (caps );
1581
1595
}
1582
- }
1583
1596
1584
- static void __init enable_cpu_capabilities (u16 scope_mask )
1585
- {
1586
- __enable_cpu_capabilities (arm64_errata , scope_mask );
1587
- __enable_cpu_capabilities (arm64_features , scope_mask );
1597
+ /*
1598
+ * For all non-boot scope capabilities, use stop_machine()
1599
+ * as it schedules the work allowing us to modify PSTATE,
1600
+ * instead of on_each_cpu() which uses an IPI, giving us a
1601
+ * PSTATE that disappears when we return.
1602
+ */
1603
+ if (!boot_scope )
1604
+ stop_machine (cpu_enable_non_boot_scope_capabilities ,
1605
+ NULL , cpu_online_mask );
1588
1606
}
1589
1607
1590
1608
/*
0 commit comments