@@ -248,7 +248,7 @@ struct gsm_mux {
248
248
bool constipated ; /* Asked by remote to shut up */
249
249
bool has_devices ; /* Devices were registered */
250
250
251
- spinlock_t tx_lock ;
251
+ struct mutex tx_mutex ;
252
252
unsigned int tx_bytes ; /* TX data outstanding */
253
253
#define TX_THRESH_HI 8192
254
254
#define TX_THRESH_LO 2048
@@ -680,7 +680,6 @@ static int gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
680
680
struct gsm_msg * msg ;
681
681
u8 * dp ;
682
682
int ocr ;
683
- unsigned long flags ;
684
683
685
684
msg = gsm_data_alloc (gsm , addr , 0 , control );
686
685
if (!msg )
@@ -702,10 +701,10 @@ static int gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
702
701
703
702
gsm_print_packet ("Q->" , addr , cr , control , NULL , 0 );
704
703
705
- spin_lock_irqsave (& gsm -> tx_lock , flags );
704
+ mutex_lock (& gsm -> tx_mutex );
706
705
list_add_tail (& msg -> list , & gsm -> tx_ctrl_list );
707
706
gsm -> tx_bytes += msg -> len ;
708
- spin_unlock_irqrestore (& gsm -> tx_lock , flags );
707
+ mutex_unlock (& gsm -> tx_mutex );
709
708
gsmld_write_trigger (gsm );
710
709
711
710
return 0 ;
@@ -730,15 +729,15 @@ static void gsm_dlci_clear_queues(struct gsm_mux *gsm, struct gsm_dlci *dlci)
730
729
spin_unlock_irqrestore (& dlci -> lock , flags );
731
730
732
731
/* Clear data packets in MUX write queue */
733
- spin_lock_irqsave (& gsm -> tx_lock , flags );
732
+ mutex_lock (& gsm -> tx_mutex );
734
733
list_for_each_entry_safe (msg , nmsg , & gsm -> tx_data_list , list ) {
735
734
if (msg -> addr != addr )
736
735
continue ;
737
736
gsm -> tx_bytes -= msg -> len ;
738
737
list_del (& msg -> list );
739
738
kfree (msg );
740
739
}
741
- spin_unlock_irqrestore (& gsm -> tx_lock , flags );
740
+ mutex_unlock (& gsm -> tx_mutex );
742
741
}
743
742
744
743
/**
@@ -1024,10 +1023,9 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
1024
1023
1025
1024
static void gsm_data_queue (struct gsm_dlci * dlci , struct gsm_msg * msg )
1026
1025
{
1027
- unsigned long flags ;
1028
- spin_lock_irqsave (& dlci -> gsm -> tx_lock , flags );
1026
+ mutex_lock (& dlci -> gsm -> tx_mutex );
1029
1027
__gsm_data_queue (dlci , msg );
1030
- spin_unlock_irqrestore (& dlci -> gsm -> tx_lock , flags );
1028
+ mutex_unlock (& dlci -> gsm -> tx_mutex );
1031
1029
}
1032
1030
1033
1031
/**
@@ -1039,7 +1037,7 @@ static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
1039
1037
* is data. Keep to the MRU of the mux. This path handles the usual tty
1040
1038
* interface which is a byte stream with optional modem data.
1041
1039
*
1042
- * Caller must hold the tx_lock of the mux.
1040
+ * Caller must hold the tx_mutex of the mux.
1043
1041
*/
1044
1042
1045
1043
static int gsm_dlci_data_output (struct gsm_mux * gsm , struct gsm_dlci * dlci )
@@ -1099,7 +1097,7 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
1099
1097
* is data. Keep to the MRU of the mux. This path handles framed data
1100
1098
* queued as skbuffs to the DLCI.
1101
1099
*
1102
- * Caller must hold the tx_lock of the mux.
1100
+ * Caller must hold the tx_mutex of the mux.
1103
1101
*/
1104
1102
1105
1103
static int gsm_dlci_data_output_framed (struct gsm_mux * gsm ,
@@ -1115,7 +1113,7 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
1115
1113
if (dlci -> adaption == 4 )
1116
1114
overhead = 1 ;
1117
1115
1118
- /* dlci->skb is locked by tx_lock */
1116
+ /* dlci->skb is locked by tx_mutex */
1119
1117
if (dlci -> skb == NULL ) {
1120
1118
dlci -> skb = skb_dequeue_tail (& dlci -> skb_list );
1121
1119
if (dlci -> skb == NULL )
@@ -1169,7 +1167,7 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
1169
1167
* Push an empty frame in to the transmit queue to update the modem status
1170
1168
* bits and to transmit an optional break.
1171
1169
*
1172
- * Caller must hold the tx_lock of the mux.
1170
+ * Caller must hold the tx_mutex of the mux.
1173
1171
*/
1174
1172
1175
1173
static int gsm_dlci_modem_output (struct gsm_mux * gsm , struct gsm_dlci * dlci ,
@@ -1283,13 +1281,12 @@ static int gsm_dlci_data_sweep(struct gsm_mux *gsm)
1283
1281
1284
1282
static void gsm_dlci_data_kick (struct gsm_dlci * dlci )
1285
1283
{
1286
- unsigned long flags ;
1287
1284
int sweep ;
1288
1285
1289
1286
if (dlci -> constipated )
1290
1287
return ;
1291
1288
1292
- spin_lock_irqsave (& dlci -> gsm -> tx_lock , flags );
1289
+ mutex_lock (& dlci -> gsm -> tx_mutex );
1293
1290
/* If we have nothing running then we need to fire up */
1294
1291
sweep = (dlci -> gsm -> tx_bytes < TX_THRESH_LO );
1295
1292
if (dlci -> gsm -> tx_bytes == 0 ) {
@@ -1300,7 +1297,7 @@ static void gsm_dlci_data_kick(struct gsm_dlci *dlci)
1300
1297
}
1301
1298
if (sweep )
1302
1299
gsm_dlci_data_sweep (dlci -> gsm );
1303
- spin_unlock_irqrestore (& dlci -> gsm -> tx_lock , flags );
1300
+ mutex_unlock (& dlci -> gsm -> tx_mutex );
1304
1301
}
1305
1302
1306
1303
/*
@@ -1994,14 +1991,13 @@ static void gsm_dlci_command(struct gsm_dlci *dlci, const u8 *data, int len)
1994
1991
static void gsm_kick_timeout (struct work_struct * work )
1995
1992
{
1996
1993
struct gsm_mux * gsm = container_of (work , struct gsm_mux , kick_timeout .work );
1997
- unsigned long flags ;
1998
1994
int sent = 0 ;
1999
1995
2000
- spin_lock_irqsave (& gsm -> tx_lock , flags );
1996
+ mutex_lock (& gsm -> tx_mutex );
2001
1997
/* If we have nothing running then we need to fire up */
2002
1998
if (gsm -> tx_bytes < TX_THRESH_LO )
2003
1999
sent = gsm_dlci_data_sweep (gsm );
2004
- spin_unlock_irqrestore (& gsm -> tx_lock , flags );
2000
+ mutex_unlock (& gsm -> tx_mutex );
2005
2001
2006
2002
if (sent && debug & 4 )
2007
2003
pr_info ("%s TX queue stalled\n" , __func__ );
@@ -2531,6 +2527,7 @@ static void gsm_free_mux(struct gsm_mux *gsm)
2531
2527
break ;
2532
2528
}
2533
2529
}
2530
+ mutex_destroy (& gsm -> tx_mutex );
2534
2531
mutex_destroy (& gsm -> mutex );
2535
2532
kfree (gsm -> txframe );
2536
2533
kfree (gsm -> buf );
@@ -2602,6 +2599,7 @@ static struct gsm_mux *gsm_alloc_mux(void)
2602
2599
}
2603
2600
spin_lock_init (& gsm -> lock );
2604
2601
mutex_init (& gsm -> mutex );
2602
+ mutex_init (& gsm -> tx_mutex );
2605
2603
kref_init (& gsm -> ref );
2606
2604
INIT_LIST_HEAD (& gsm -> tx_ctrl_list );
2607
2605
INIT_LIST_HEAD (& gsm -> tx_data_list );
@@ -2610,7 +2608,6 @@ static struct gsm_mux *gsm_alloc_mux(void)
2610
2608
INIT_WORK (& gsm -> tx_work , gsmld_write_task );
2611
2609
init_waitqueue_head (& gsm -> event );
2612
2610
spin_lock_init (& gsm -> control_lock );
2613
- spin_lock_init (& gsm -> tx_lock );
2614
2611
2615
2612
gsm -> t1 = T1 ;
2616
2613
gsm -> t2 = T2 ;
@@ -2635,6 +2632,7 @@ static struct gsm_mux *gsm_alloc_mux(void)
2635
2632
}
2636
2633
spin_unlock (& gsm_mux_lock );
2637
2634
if (i == MAX_MUX ) {
2635
+ mutex_destroy (& gsm -> tx_mutex );
2638
2636
mutex_destroy (& gsm -> mutex );
2639
2637
kfree (gsm -> txframe );
2640
2638
kfree (gsm -> buf );
@@ -2790,17 +2788,16 @@ static void gsmld_write_trigger(struct gsm_mux *gsm)
2790
2788
static void gsmld_write_task (struct work_struct * work )
2791
2789
{
2792
2790
struct gsm_mux * gsm = container_of (work , struct gsm_mux , tx_work );
2793
- unsigned long flags ;
2794
2791
int i , ret ;
2795
2792
2796
2793
/* All outstanding control channel and control messages and one data
2797
2794
* frame is sent.
2798
2795
*/
2799
2796
ret = - ENODEV ;
2800
- spin_lock_irqsave (& gsm -> tx_lock , flags );
2797
+ mutex_lock (& gsm -> tx_mutex );
2801
2798
if (gsm -> tty )
2802
2799
ret = gsm_data_kick (gsm );
2803
- spin_unlock_irqrestore (& gsm -> tx_lock , flags );
2800
+ mutex_unlock (& gsm -> tx_mutex );
2804
2801
2805
2802
if (ret >= 0 )
2806
2803
for (i = 0 ; i < NUM_DLCI ; i ++ )
@@ -3008,21 +3005,20 @@ static ssize_t gsmld_write(struct tty_struct *tty, struct file *file,
3008
3005
const unsigned char * buf , size_t nr )
3009
3006
{
3010
3007
struct gsm_mux * gsm = tty -> disc_data ;
3011
- unsigned long flags ;
3012
3008
int space ;
3013
3009
int ret ;
3014
3010
3015
3011
if (!gsm )
3016
3012
return - ENODEV ;
3017
3013
3018
3014
ret = - ENOBUFS ;
3019
- spin_lock_irqsave (& gsm -> tx_lock , flags );
3015
+ mutex_lock (& gsm -> tx_mutex );
3020
3016
space = tty_write_room (tty );
3021
3017
if (space >= nr )
3022
3018
ret = tty -> ops -> write (tty , buf , nr );
3023
3019
else
3024
3020
set_bit (TTY_DO_WRITE_WAKEUP , & tty -> flags );
3025
- spin_unlock_irqrestore (& gsm -> tx_lock , flags );
3021
+ mutex_unlock (& gsm -> tx_mutex );
3026
3022
3027
3023
return ret ;
3028
3024
}
@@ -3319,14 +3315,13 @@ static struct tty_ldisc_ops tty_ldisc_packet = {
3319
3315
static void gsm_modem_upd_via_data (struct gsm_dlci * dlci , u8 brk )
3320
3316
{
3321
3317
struct gsm_mux * gsm = dlci -> gsm ;
3322
- unsigned long flags ;
3323
3318
3324
3319
if (dlci -> state != DLCI_OPEN || dlci -> adaption != 2 )
3325
3320
return ;
3326
3321
3327
- spin_lock_irqsave (& gsm -> tx_lock , flags );
3322
+ mutex_lock (& gsm -> tx_mutex );
3328
3323
gsm_dlci_modem_output (gsm , dlci , brk );
3329
- spin_unlock_irqrestore (& gsm -> tx_lock , flags );
3324
+ mutex_unlock (& gsm -> tx_mutex );
3330
3325
}
3331
3326
3332
3327
/**
0 commit comments