@@ -2624,12 +2624,11 @@ static struct fcoe_transport bnx2fc_transport = {
2624
2624
};
2625
2625
2626
2626
/**
2627
- * bnx2fc_percpu_thread_create - Create a receive thread for an
2628
- * online CPU
2627
+ * bnx2fc_cpu_online - Create a receive thread for an online CPU
2629
2628
*
2630
2629
* @cpu: cpu index for the online cpu
2631
2630
*/
2632
- static void bnx2fc_percpu_thread_create (unsigned int cpu )
2631
+ static int bnx2fc_cpu_online (unsigned int cpu )
2633
2632
{
2634
2633
struct bnx2fc_percpu_s * p ;
2635
2634
struct task_struct * thread ;
@@ -2639,15 +2638,17 @@ static void bnx2fc_percpu_thread_create(unsigned int cpu)
2639
2638
thread = kthread_create_on_node (bnx2fc_percpu_io_thread ,
2640
2639
(void * )p , cpu_to_node (cpu ),
2641
2640
"bnx2fc_thread/%d" , cpu );
2641
+ if (IS_ERR (thread ))
2642
+ return PTR_ERR (thread );
2643
+
2642
2644
/* bind thread to the cpu */
2643
- if (likely (!IS_ERR (thread ))) {
2644
- kthread_bind (thread , cpu );
2645
- p -> iothread = thread ;
2646
- wake_up_process (thread );
2647
- }
2645
+ kthread_bind (thread , cpu );
2646
+ p -> iothread = thread ;
2647
+ wake_up_process (thread );
2648
+ return 0 ;
2648
2649
}
2649
2650
2650
- static void bnx2fc_percpu_thread_destroy (unsigned int cpu )
2651
+ static int bnx2fc_cpu_offline (unsigned int cpu )
2651
2652
{
2652
2653
struct bnx2fc_percpu_s * p ;
2653
2654
struct task_struct * thread ;
@@ -2661,7 +2662,6 @@ static void bnx2fc_percpu_thread_destroy(unsigned int cpu)
2661
2662
thread = p -> iothread ;
2662
2663
p -> iothread = NULL ;
2663
2664
2664
-
2665
2665
/* Free all work in the list */
2666
2666
list_for_each_entry_safe (work , tmp , & p -> work_list , list ) {
2667
2667
list_del_init (& work -> list );
@@ -2673,20 +2673,6 @@ static void bnx2fc_percpu_thread_destroy(unsigned int cpu)
2673
2673
2674
2674
if (thread )
2675
2675
kthread_stop (thread );
2676
- }
2677
-
2678
-
2679
- static int bnx2fc_cpu_online (unsigned int cpu )
2680
- {
2681
- printk (PFX "CPU %x online: Create Rx thread\n" , cpu );
2682
- bnx2fc_percpu_thread_create (cpu );
2683
- return 0 ;
2684
- }
2685
-
2686
- static int bnx2fc_cpu_dead (unsigned int cpu )
2687
- {
2688
- printk (PFX "CPU %x offline: Remove Rx thread\n" , cpu );
2689
- bnx2fc_percpu_thread_destroy (cpu );
2690
2676
return 0 ;
2691
2677
}
2692
2678
@@ -2761,31 +2747,16 @@ static int __init bnx2fc_mod_init(void)
2761
2747
spin_lock_init (& p -> fp_work_lock );
2762
2748
}
2763
2749
2764
- get_online_cpus ();
2765
-
2766
- for_each_online_cpu (cpu )
2767
- bnx2fc_percpu_thread_create (cpu );
2768
-
2769
- rc = cpuhp_setup_state_nocalls_cpuslocked (CPUHP_AP_ONLINE_DYN ,
2770
- "scsi/bnx2fc:online" ,
2771
- bnx2fc_cpu_online , NULL );
2750
+ rc = cpuhp_setup_state (CPUHP_AP_ONLINE_DYN , "scsi/bnx2fc:online" ,
2751
+ bnx2fc_cpu_online , bnx2fc_cpu_offline );
2772
2752
if (rc < 0 )
2773
- goto stop_threads ;
2753
+ goto stop_thread ;
2774
2754
bnx2fc_online_state = rc ;
2775
2755
2776
- cpuhp_setup_state_nocalls_cpuslocked (CPUHP_SCSI_BNX2FC_DEAD ,
2777
- "scsi/bnx2fc:dead" ,
2778
- NULL , bnx2fc_cpu_dead );
2779
- put_online_cpus ();
2780
-
2781
2756
cnic_register_driver (CNIC_ULP_FCOE , & bnx2fc_cnic_cb );
2782
-
2783
2757
return 0 ;
2784
2758
2785
- stop_threads :
2786
- for_each_online_cpu (cpu )
2787
- bnx2fc_percpu_thread_destroy (cpu );
2788
- put_online_cpus ();
2759
+ stop_thread :
2789
2760
kthread_stop (l2_thread );
2790
2761
free_wq :
2791
2762
destroy_workqueue (bnx2fc_wq );
@@ -2804,7 +2775,6 @@ static void __exit bnx2fc_mod_exit(void)
2804
2775
struct fcoe_percpu_s * bg ;
2805
2776
struct task_struct * l2_thread ;
2806
2777
struct sk_buff * skb ;
2807
- unsigned int cpu = 0 ;
2808
2778
2809
2779
/*
2810
2780
* NOTE: Since cnic calls register_driver routine rtnl_lock,
@@ -2845,16 +2815,7 @@ static void __exit bnx2fc_mod_exit(void)
2845
2815
if (l2_thread )
2846
2816
kthread_stop (l2_thread );
2847
2817
2848
- get_online_cpus ();
2849
- /* Destroy per cpu threads */
2850
- for_each_online_cpu (cpu ) {
2851
- bnx2fc_percpu_thread_destroy (cpu );
2852
- }
2853
-
2854
- cpuhp_remove_state_nocalls_cpuslocked (bnx2fc_online_state );
2855
- cpuhp_remove_state_nocalls_cpuslocked (CPUHP_SCSI_BNX2FC_DEAD );
2856
-
2857
- put_online_cpus ();
2818
+ cpuhp_remove_state (bnx2fc_online_state );
2858
2819
2859
2820
destroy_workqueue (bnx2fc_wq );
2860
2821
/*
0 commit comments