@@ -823,7 +823,8 @@ static int qeth_set_thread_start_bit(struct qeth_card *card,
823
823
return 0 ;
824
824
}
825
825
826
- void qeth_clear_thread_start_bit (struct qeth_card * card , unsigned long thread )
826
+ static void qeth_clear_thread_start_bit (struct qeth_card * card ,
827
+ unsigned long thread )
827
828
{
828
829
unsigned long flags ;
829
830
@@ -832,9 +833,9 @@ void qeth_clear_thread_start_bit(struct qeth_card *card, unsigned long thread)
832
833
spin_unlock_irqrestore (& card -> thread_mask_lock , flags );
833
834
wake_up (& card -> wait_q );
834
835
}
835
- EXPORT_SYMBOL_GPL (qeth_clear_thread_start_bit );
836
836
837
- void qeth_clear_thread_running_bit (struct qeth_card * card , unsigned long thread )
837
+ static void qeth_clear_thread_running_bit (struct qeth_card * card ,
838
+ unsigned long thread )
838
839
{
839
840
unsigned long flags ;
840
841
@@ -843,7 +844,6 @@ void qeth_clear_thread_running_bit(struct qeth_card *card, unsigned long thread)
843
844
spin_unlock_irqrestore (& card -> thread_mask_lock , flags );
844
845
wake_up_all (& card -> wait_q );
845
846
}
846
- EXPORT_SYMBOL_GPL (qeth_clear_thread_running_bit );
847
847
848
848
static int __qeth_do_run_thread (struct qeth_card * card , unsigned long thread )
849
849
{
@@ -864,23 +864,21 @@ static int __qeth_do_run_thread(struct qeth_card *card, unsigned long thread)
864
864
return rc ;
865
865
}
866
866
867
- int qeth_do_run_thread (struct qeth_card * card , unsigned long thread )
867
+ static int qeth_do_run_thread (struct qeth_card * card , unsigned long thread )
868
868
{
869
869
int rc = 0 ;
870
870
871
871
wait_event (card -> wait_q ,
872
872
(rc = __qeth_do_run_thread (card , thread )) >= 0 );
873
873
return rc ;
874
874
}
875
- EXPORT_SYMBOL_GPL (qeth_do_run_thread );
876
875
877
876
void qeth_schedule_recovery (struct qeth_card * card )
878
877
{
879
878
QETH_CARD_TEXT (card , 2 , "startrec" );
880
879
if (qeth_set_thread_start_bit (card , QETH_RECOVER_THREAD ) == 0 )
881
880
schedule_work (& card -> kernel_thread_starter );
882
881
}
883
- EXPORT_SYMBOL_GPL (qeth_schedule_recovery );
884
882
885
883
static int qeth_get_problem (struct qeth_card * card , struct ccw_device * cdev ,
886
884
struct irb * irb )
@@ -1287,6 +1285,7 @@ static int qeth_do_start_thread(struct qeth_card *card, unsigned long thread)
1287
1285
return rc ;
1288
1286
}
1289
1287
1288
+ static int qeth_do_reset (void * data );
1290
1289
static void qeth_start_kernel_thread (struct work_struct * work )
1291
1290
{
1292
1291
struct task_struct * ts ;
@@ -1298,8 +1297,7 @@ static void qeth_start_kernel_thread(struct work_struct *work)
1298
1297
card -> write .state != CH_STATE_UP )
1299
1298
return ;
1300
1299
if (qeth_do_start_thread (card , QETH_RECOVER_THREAD )) {
1301
- ts = kthread_run (card -> discipline -> recover , (void * )card ,
1302
- "qeth_recover" );
1300
+ ts = kthread_run (qeth_do_reset , card , "qeth_recover" );
1303
1301
if (IS_ERR (ts )) {
1304
1302
qeth_clear_thread_start_bit (card , QETH_RECOVER_THREAD );
1305
1303
qeth_clear_thread_running_bit (card ,
@@ -3095,7 +3093,6 @@ int qeth_hw_trap(struct qeth_card *card, enum qeth_diags_trap_action action)
3095
3093
}
3096
3094
return qeth_send_ipa_cmd (card , iob , qeth_hw_trap_cb , NULL );
3097
3095
}
3098
- EXPORT_SYMBOL_GPL (qeth_hw_trap );
3099
3096
3100
3097
static int qeth_check_qdio_errors (struct qeth_card * card ,
3101
3098
struct qdio_buffer * buf ,
@@ -5041,6 +5038,89 @@ int qeth_core_hardsetup_card(struct qeth_card *card, bool *carrier_ok)
5041
5038
}
5042
5039
EXPORT_SYMBOL_GPL (qeth_core_hardsetup_card );
5043
5040
5041
+ static int qeth_set_online (struct qeth_card * card )
5042
+ {
5043
+ int rc ;
5044
+
5045
+ mutex_lock (& card -> discipline_mutex );
5046
+ mutex_lock (& card -> conf_mutex );
5047
+ QETH_CARD_TEXT (card , 2 , "setonlin" );
5048
+
5049
+ rc = card -> discipline -> set_online (card );
5050
+
5051
+ mutex_unlock (& card -> conf_mutex );
5052
+ mutex_unlock (& card -> discipline_mutex );
5053
+
5054
+ return rc ;
5055
+ }
5056
+
5057
+ int qeth_set_offline (struct qeth_card * card , bool resetting )
5058
+ {
5059
+ int rc , rc2 , rc3 ;
5060
+
5061
+ mutex_lock (& card -> discipline_mutex );
5062
+ mutex_lock (& card -> conf_mutex );
5063
+ QETH_CARD_TEXT (card , 3 , "setoffl" );
5064
+
5065
+ if ((!resetting && card -> info .hwtrap ) || card -> info .hwtrap == 2 ) {
5066
+ qeth_hw_trap (card , QETH_DIAGS_TRAP_DISARM );
5067
+ card -> info .hwtrap = 1 ;
5068
+ }
5069
+
5070
+ rtnl_lock ();
5071
+ card -> info .open_when_online = card -> dev -> flags & IFF_UP ;
5072
+ dev_close (card -> dev );
5073
+ netif_device_detach (card -> dev );
5074
+ netif_carrier_off (card -> dev );
5075
+ rtnl_unlock ();
5076
+
5077
+ card -> discipline -> set_offline (card );
5078
+
5079
+ rc = qeth_stop_channel (& card -> data );
5080
+ rc2 = qeth_stop_channel (& card -> write );
5081
+ rc3 = qeth_stop_channel (& card -> read );
5082
+ if (!rc )
5083
+ rc = (rc2 ) ? rc2 : rc3 ;
5084
+ if (rc )
5085
+ QETH_CARD_TEXT_ (card , 2 , "1err%d" , rc );
5086
+ qdio_free (CARD_DDEV (card ));
5087
+
5088
+ /* let user_space know that device is offline */
5089
+ kobject_uevent (& card -> gdev -> dev .kobj , KOBJ_CHANGE );
5090
+
5091
+ mutex_unlock (& card -> conf_mutex );
5092
+ mutex_unlock (& card -> discipline_mutex );
5093
+ return 0 ;
5094
+ }
5095
+ EXPORT_SYMBOL_GPL (qeth_set_offline );
5096
+
5097
+ static int qeth_do_reset (void * data )
5098
+ {
5099
+ struct qeth_card * card = data ;
5100
+ int rc ;
5101
+
5102
+ QETH_CARD_TEXT (card , 2 , "recover1" );
5103
+ if (!qeth_do_run_thread (card , QETH_RECOVER_THREAD ))
5104
+ return 0 ;
5105
+ QETH_CARD_TEXT (card , 2 , "recover2" );
5106
+ dev_warn (& card -> gdev -> dev ,
5107
+ "A recovery process has been started for the device\n" );
5108
+
5109
+ qeth_set_offline (card , true);
5110
+ rc = qeth_set_online (card );
5111
+ if (!rc ) {
5112
+ dev_info (& card -> gdev -> dev ,
5113
+ "Device successfully recovered!\n" );
5114
+ } else {
5115
+ ccwgroup_set_offline (card -> gdev );
5116
+ dev_warn (& card -> gdev -> dev ,
5117
+ "The qeth device driver failed to recover an error on the device\n" );
5118
+ }
5119
+ qeth_clear_thread_start_bit (card , QETH_RECOVER_THREAD );
5120
+ qeth_clear_thread_running_bit (card , QETH_RECOVER_THREAD );
5121
+ return 0 ;
5122
+ }
5123
+
5044
5124
#if IS_ENABLED (CONFIG_QETH_L3 )
5045
5125
static void qeth_l3_rebuild_skb (struct qeth_card * card , struct sk_buff * skb ,
5046
5126
struct qeth_hdr * hdr )
@@ -5977,15 +6057,17 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev)
5977
6057
goto err ;
5978
6058
}
5979
6059
}
5980
- rc = card -> discipline -> set_online (gdev );
6060
+
6061
+ rc = qeth_set_online (card );
5981
6062
err :
5982
6063
return rc ;
5983
6064
}
5984
6065
5985
6066
static int qeth_core_set_offline (struct ccwgroup_device * gdev )
5986
6067
{
5987
6068
struct qeth_card * card = dev_get_drvdata (& gdev -> dev );
5988
- return card -> discipline -> set_offline (gdev );
6069
+
6070
+ return qeth_set_offline (card , false);
5989
6071
}
5990
6072
5991
6073
static void qeth_core_shutdown (struct ccwgroup_device * gdev )
@@ -6008,7 +6090,7 @@ static int qeth_suspend(struct ccwgroup_device *gdev)
6008
6090
if (gdev -> state == CCWGROUP_OFFLINE )
6009
6091
return 0 ;
6010
6092
6011
- card -> discipline -> set_offline ( gdev );
6093
+ qeth_set_offline ( card , false );
6012
6094
return 0 ;
6013
6095
}
6014
6096
@@ -6017,7 +6099,7 @@ static int qeth_resume(struct ccwgroup_device *gdev)
6017
6099
struct qeth_card * card = dev_get_drvdata (& gdev -> dev );
6018
6100
int rc ;
6019
6101
6020
- rc = card -> discipline -> set_online ( gdev );
6102
+ rc = qeth_set_online ( card );
6021
6103
6022
6104
qeth_set_allowed_threads (card , 0xffffffff , 0 );
6023
6105
if (rc )
0 commit comments