@@ -479,12 +479,25 @@ static void loongson3_smp_finish(void)
479
479
static void __init loongson3_smp_setup (void )
480
480
{
481
481
int i = 0 , num = 0 ; /* i: physical id, num: logical id */
482
+ int max_cpus = 0 ;
482
483
483
484
init_cpu_possible (cpu_none_mask );
484
485
486
+ for (i = 0 ; i < ARRAY_SIZE (smp_group ); i ++ ) {
487
+ if (!smp_group [i ])
488
+ break ;
489
+ max_cpus += loongson_sysconf .cores_per_node ;
490
+ }
491
+
492
+ if (max_cpus < loongson_sysconf .nr_cpus ) {
493
+ pr_err ("SMP Groups are less than the number of CPUs\n" );
494
+ loongson_sysconf .nr_cpus = max_cpus ? max_cpus : 1 ;
495
+ }
496
+
485
497
/* For unified kernel, NR_CPUS is the maximum possible value,
486
498
* loongson_sysconf.nr_cpus is the really present value
487
499
*/
500
+ i = 0 ;
488
501
while (i < loongson_sysconf .nr_cpus ) {
489
502
if (loongson_sysconf .reserved_cpus_mask & (1 <<i )) {
490
503
/* Reserved physical CPU cores */
@@ -505,14 +518,14 @@ static void __init loongson3_smp_setup(void)
505
518
__cpu_logical_map [num ] = -1 ;
506
519
num ++ ;
507
520
}
508
-
509
521
csr_ipi_probe ();
510
522
ipi_set0_regs_init ();
511
523
ipi_clear0_regs_init ();
512
524
ipi_status0_regs_init ();
513
525
ipi_en0_regs_init ();
514
526
ipi_mailbox_buf_init ();
515
- ipi_write_enable (0 );
527
+ if (smp_group [0 ])
528
+ ipi_write_enable (0 );
516
529
517
530
cpu_set_core (& cpu_data [0 ],
518
531
cpu_logical_map (0 ) % loongson_sysconf .cores_per_package );
@@ -830,6 +843,9 @@ static int loongson3_disable_clock(unsigned int cpu)
830
843
uint64_t core_id = cpu_core (& cpu_data [cpu ]);
831
844
uint64_t package_id = cpu_data [cpu ].package ;
832
845
846
+ if (!loongson_chipcfg [package_id ] || !loongson_freqctrl [package_id ])
847
+ return 0 ;
848
+
833
849
if ((read_c0_prid () & PRID_REV_MASK ) == PRID_REV_LOONGSON3A_R1 ) {
834
850
LOONGSON_CHIPCFG (package_id ) &= ~(1 << (12 + core_id ));
835
851
} else {
@@ -844,6 +860,9 @@ static int loongson3_enable_clock(unsigned int cpu)
844
860
uint64_t core_id = cpu_core (& cpu_data [cpu ]);
845
861
uint64_t package_id = cpu_data [cpu ].package ;
846
862
863
+ if (!loongson_chipcfg [package_id ] || !loongson_freqctrl [package_id ])
864
+ return 0 ;
865
+
847
866
if ((read_c0_prid () & PRID_REV_MASK ) == PRID_REV_LOONGSON3A_R1 ) {
848
867
LOONGSON_CHIPCFG (package_id ) |= 1 << (12 + core_id );
849
868
} else {
0 commit comments