@@ -404,12 +404,11 @@ int bnx2i_get_stats(void *handle)
404
404
405
405
406
406
/**
407
- * bnx2i_percpu_thread_create - Create a receive thread for an
408
- * online CPU
407
+ * bnx2i_cpu_online - Create a receive thread for an online CPU
409
408
*
410
409
* @cpu: cpu index for the online cpu
411
410
*/
412
- static void bnx2i_percpu_thread_create (unsigned int cpu )
411
+ static int bnx2i_cpu_online (unsigned int cpu )
413
412
{
414
413
struct bnx2i_percpu_s * p ;
415
414
struct task_struct * thread ;
@@ -419,16 +418,17 @@ static void bnx2i_percpu_thread_create(unsigned int cpu)
419
418
thread = kthread_create_on_node (bnx2i_percpu_io_thread , (void * )p ,
420
419
cpu_to_node (cpu ),
421
420
"bnx2i_thread/%d" , cpu );
421
+ if (IS_ERR (thread ))
422
+ return PTR_ERR (thread );
423
+
422
424
/* bind thread to the cpu */
423
- if (likely (!IS_ERR (thread ))) {
424
- kthread_bind (thread , cpu );
425
- p -> iothread = thread ;
426
- wake_up_process (thread );
427
- }
425
+ kthread_bind (thread , cpu );
426
+ p -> iothread = thread ;
427
+ wake_up_process (thread );
428
+ return 0 ;
428
429
}
429
430
430
-
431
- static void bnx2i_percpu_thread_destroy (unsigned int cpu )
431
+ static int bnx2i_cpu_offline (unsigned int cpu )
432
432
{
433
433
struct bnx2i_percpu_s * p ;
434
434
struct task_struct * thread ;
@@ -451,19 +451,6 @@ static void bnx2i_percpu_thread_destroy(unsigned int cpu)
451
451
spin_unlock_bh (& p -> p_work_lock );
452
452
if (thread )
453
453
kthread_stop (thread );
454
- }
455
-
456
- static int bnx2i_cpu_online (unsigned int cpu )
457
- {
458
- pr_info ("bnx2i: CPU %x online: Create Rx thread\n" , cpu );
459
- bnx2i_percpu_thread_create (cpu );
460
- return 0 ;
461
- }
462
-
463
- static int bnx2i_cpu_dead (unsigned int cpu )
464
- {
465
- pr_info ("CPU %x offline: Remove Rx thread\n" , cpu );
466
- bnx2i_percpu_thread_destroy (cpu );
467
454
return 0 ;
468
455
}
469
456
@@ -511,28 +498,14 @@ static int __init bnx2i_mod_init(void)
511
498
p -> iothread = NULL ;
512
499
}
513
500
514
- get_online_cpus ();
515
-
516
- for_each_online_cpu (cpu )
517
- bnx2i_percpu_thread_create (cpu );
518
-
519
- err = cpuhp_setup_state_nocalls_cpuslocked (CPUHP_AP_ONLINE_DYN ,
520
- "scsi/bnx2i:online" ,
521
- bnx2i_cpu_online , NULL );
501
+ err = cpuhp_setup_state (CPUHP_AP_ONLINE_DYN , "scsi/bnx2i:online" ,
502
+ bnx2i_cpu_online , bnx2i_cpu_offline );
522
503
if (err < 0 )
523
- goto remove_threads ;
504
+ goto unreg_driver ;
524
505
bnx2i_online_state = err ;
525
-
526
- cpuhp_setup_state_nocalls_cpuslocked (CPUHP_SCSI_BNX2I_DEAD ,
527
- "scsi/bnx2i:dead" ,
528
- NULL , bnx2i_cpu_dead );
529
- put_online_cpus ();
530
506
return 0 ;
531
507
532
- remove_threads :
533
- for_each_online_cpu (cpu )
534
- bnx2i_percpu_thread_destroy (cpu );
535
- put_online_cpus ();
508
+ unreg_driver :
536
509
cnic_unregister_driver (CNIC_ULP_ISCSI );
537
510
unreg_xport :
538
511
iscsi_unregister_transport (& bnx2i_iscsi_transport );
@@ -552,7 +525,6 @@ static int __init bnx2i_mod_init(void)
552
525
static void __exit bnx2i_mod_exit (void )
553
526
{
554
527
struct bnx2i_hba * hba ;
555
- unsigned cpu = 0 ;
556
528
557
529
mutex_lock (& bnx2i_dev_lock );
558
530
while (!list_empty (& adapter_list )) {
@@ -570,14 +542,7 @@ static void __exit bnx2i_mod_exit(void)
570
542
}
571
543
mutex_unlock (& bnx2i_dev_lock );
572
544
573
- get_online_cpus ();
574
-
575
- for_each_online_cpu (cpu )
576
- bnx2i_percpu_thread_destroy (cpu );
577
-
578
- cpuhp_remove_state_nocalls_cpuslocked (bnx2i_online_state );
579
- cpuhp_remove_state_nocalls_cpuslocked (CPUHP_SCSI_BNX2I_DEAD );
580
- put_online_cpus ();
545
+ cpuhp_remove_state (bnx2i_online_state );
581
546
582
547
iscsi_unregister_transport (& bnx2i_iscsi_transport );
583
548
cnic_unregister_driver (CNIC_ULP_ISCSI );
0 commit comments