|
10 | 10 | #include <linux/spinlock.h> |
11 | 11 |
|
12 | 12 | #include <asm/mips-cps.h> |
| 13 | +#include <asm/smp-cps.h> |
13 | 14 | #include <asm/mipsregs.h> |
14 | 15 |
|
15 | 16 | void __iomem *mips_gcr_base; |
@@ -534,39 +535,23 @@ void mips_cm_error_report(void) |
534 | 535 | write_gcr_error_cause(cm_error); |
535 | 536 | } |
536 | 537 |
|
537 | | -unsigned int mips_cps_first_online_in_cluster(void) |
| 538 | +unsigned int mips_cps_first_online_in_cluster(int *first_cpu) |
538 | 539 | { |
539 | | - unsigned int local_cl; |
540 | | - int i; |
541 | | - |
542 | | - local_cl = cpu_cluster(¤t_cpu_data); |
| 540 | + unsigned int local_cl = cpu_cluster(¤t_cpu_data); |
| 541 | + struct cpumask *local_cl_mask; |
543 | 542 |
|
544 | 543 | /* |
545 | | - * We rely upon knowledge that CPUs are numbered sequentially by |
546 | | - * cluster - ie. CPUs 0..X will be in cluster 0, CPUs X+1..Y in cluster |
547 | | - * 1, CPUs Y+1..Z in cluster 2 etc. This means that CPUs in the same |
548 | | - * cluster will immediately precede or follow one another. |
549 | | - * |
550 | | - * First we scan backwards, until we find an online CPU in the cluster |
551 | | - * or we move on to another cluster. |
| 544 | + * mips_cps_cluster_bootcfg is allocated in cps_prepare_cpus. If it is |
| 545 | + * not yet done, then we are so early that only one CPU is running, so |
| 546 | + * it is the first online CPU in the cluster. |
552 | 547 | */ |
553 | | - for (i = smp_processor_id() - 1; i >= 0; i--) { |
554 | | - if (cpu_cluster(&cpu_data[i]) != local_cl) |
555 | | - break; |
556 | | - if (!cpu_online(i)) |
557 | | - continue; |
558 | | - return false; |
559 | | - } |
560 | | - |
561 | | - /* Then do the same for higher numbered CPUs */ |
562 | | - for (i = smp_processor_id() + 1; i < nr_cpu_ids; i++) { |
563 | | - if (cpu_cluster(&cpu_data[i]) != local_cl) |
564 | | - break; |
565 | | - if (!cpu_online(i)) |
566 | | - continue; |
567 | | - return false; |
568 | | - } |
569 | | - |
570 | | - /* We found no online CPUs in the local cluster */ |
571 | | - return true; |
| 548 | + if (IS_ENABLED(CONFIG_MIPS_CPS) && mips_cps_cluster_bootcfg) |
| 549 | + local_cl_mask = &mips_cps_cluster_bootcfg[local_cl].cpumask; |
| 550 | + else |
| 551 | + return true; |
| 552 | + |
| 553 | + *first_cpu = cpumask_any_and_but(local_cl_mask, |
| 554 | + cpu_online_mask, |
| 555 | + smp_processor_id()); |
| 556 | + return (*first_cpu >= nr_cpu_ids); |
572 | 557 | } |
0 commit comments