@@ -268,7 +268,7 @@ struct microcode_ctrl {
268268};
269269
270270static DEFINE_PER_CPU (struct microcode_ctrl , ucode_ctrl ) ;
271- static atomic_t late_cpus_in , late_cpus_out ;
271+ static atomic_t late_cpus_in ;
272272
273273static bool wait_for_cpus (atomic_t * cnt )
274274{
@@ -304,7 +304,7 @@ static bool wait_for_ctrl(void)
304304 return false;
305305}
306306
307- static __maybe_unused void load_secondary (unsigned int cpu )
307+ static void load_secondary (unsigned int cpu )
308308{
309309 unsigned int ctrl_cpu = this_cpu_read (ucode_ctrl .ctrl_cpu );
310310 enum ucode_state ret ;
@@ -339,7 +339,7 @@ static __maybe_unused void load_secondary(unsigned int cpu)
339339 this_cpu_write (ucode_ctrl .ctrl , SCTRL_DONE );
340340}
341341
342- static __maybe_unused void load_primary (unsigned int cpu )
342+ static void load_primary (unsigned int cpu )
343343{
344344 struct cpumask * secondaries = topology_sibling_cpumask (cpu );
345345 enum sibling_ctrl ctrl ;
@@ -376,46 +376,14 @@ static __maybe_unused void load_primary(unsigned int cpu)
376376
377377static int load_cpus_stopped (void * unused )
378378{
379- int cpu = smp_processor_id ();
380- enum ucode_state ret ;
381-
382- /*
383- * Wait for all CPUs to arrive. A load will not be attempted unless all
384- * CPUs show up.
385- * */
386- if (!wait_for_cpus (& late_cpus_in )) {
387- this_cpu_write (ucode_ctrl .result , UCODE_TIMEOUT );
388- return 0 ;
389- }
390-
391- /*
392- * On an SMT system, it suffices to load the microcode on one sibling of
393- * the core because the microcode engine is shared between the threads.
394- * Synchronization still needs to take place so that no concurrent
395- * loading attempts happen on multiple threads of an SMT core. See
396- * below.
397- */
398- if (cpumask_first (topology_sibling_cpumask (cpu )) != cpu )
399- goto wait_for_siblings ;
379+ unsigned int cpu = smp_processor_id ();
400380
401- ret = microcode_ops -> apply_microcode (cpu );
402- this_cpu_write (ucode_ctrl .result , ret );
403-
404- wait_for_siblings :
405- if (!wait_for_cpus (& late_cpus_out ))
406- panic ("Timeout during microcode update!\n" );
407-
408- /*
409- * At least one thread has completed update on each core.
410- * For others, simply call the update to make sure the
411- * per-cpu cpuinfo can be updated with right microcode
412- * revision.
413- */
414- if (cpumask_first (topology_sibling_cpumask (cpu )) == cpu )
415- return 0 ;
381+ if (this_cpu_read (ucode_ctrl .ctrl_cpu ) == cpu )
382+ load_primary (cpu );
383+ else
384+ load_secondary (cpu );
416385
417- ret = microcode_ops -> apply_microcode (cpu );
418- this_cpu_write (ucode_ctrl .result , ret );
386+ /* No point to wait here. The CPUs will all wait in stop_machine(). */
419387 return 0 ;
420388}
421389
@@ -429,7 +397,6 @@ static int load_late_stop_cpus(void)
429397 pr_err ("You should switch to early loading, if possible.\n" );
430398
431399 atomic_set (& late_cpus_in , num_online_cpus ());
432- atomic_set (& late_cpus_out , num_online_cpus ());
433400
434401 /*
435402 * Take a snapshot before the microcode update in order to compare and
0 commit comments