@@ -6410,18 +6410,17 @@ static void lcb_shutdown(struct hfi1_devdata *dd, int abort)
6410
6410
*
6411
6411
* The expectation is that the caller of this routine would have taken
6412
6412
* care of properly transitioning the link into the correct state.
6413
+ * NOTE: the caller needs to acquire the dd->dc8051_lock lock
6414
+ * before calling this function.
6413
6415
*/
6414
- static void dc_shutdown (struct hfi1_devdata * dd )
6416
+ static void _dc_shutdown (struct hfi1_devdata * dd )
6415
6417
{
6416
- unsigned long flags ;
6418
+ lockdep_assert_held ( & dd -> dc8051_lock ) ;
6417
6419
6418
- spin_lock_irqsave (& dd -> dc8051_lock , flags );
6419
- if (dd -> dc_shutdown ) {
6420
- spin_unlock_irqrestore (& dd -> dc8051_lock , flags );
6420
+ if (dd -> dc_shutdown )
6421
6421
return ;
6422
- }
6422
+
6423
6423
dd -> dc_shutdown = 1 ;
6424
- spin_unlock_irqrestore (& dd -> dc8051_lock , flags );
6425
6424
/* Shutdown the LCB */
6426
6425
lcb_shutdown (dd , 1 );
6427
6426
/*
@@ -6432,35 +6431,45 @@ static void dc_shutdown(struct hfi1_devdata *dd)
6432
6431
write_csr (dd , DC_DC8051_CFG_RST , 0x1 );
6433
6432
}
6434
6433
6434
+ static void dc_shutdown (struct hfi1_devdata * dd )
6435
+ {
6436
+ mutex_lock (& dd -> dc8051_lock );
6437
+ _dc_shutdown (dd );
6438
+ mutex_unlock (& dd -> dc8051_lock );
6439
+ }
6440
+
6435
6441
/*
6436
6442
* Calling this after the DC has been brought out of reset should not
6437
6443
* do any damage.
6444
+ * NOTE: the caller needs to acquire the dd->dc8051_lock lock
6445
+ * before calling this function.
6438
6446
*/
6439
- static void dc_start (struct hfi1_devdata * dd )
6447
+ static void _dc_start (struct hfi1_devdata * dd )
6440
6448
{
6441
- unsigned long flags ;
6442
- int ret ;
6449
+ lockdep_assert_held (& dd -> dc8051_lock );
6443
6450
6444
- spin_lock_irqsave (& dd -> dc8051_lock , flags );
6445
6451
if (!dd -> dc_shutdown )
6446
- goto done ;
6447
- spin_unlock_irqrestore ( & dd -> dc8051_lock , flags );
6452
+ return ;
6453
+
6448
6454
/* Take the 8051 out of reset */
6449
6455
write_csr (dd , DC_DC8051_CFG_RST , 0ull );
6450
6456
/* Wait until 8051 is ready */
6451
- ret = wait_fm_ready (dd , TIMEOUT_8051_START );
6452
- if (ret ) {
6457
+ if (wait_fm_ready (dd , TIMEOUT_8051_START ))
6453
6458
dd_dev_err (dd , "%s: timeout starting 8051 firmware\n" ,
6454
6459
__func__ );
6455
- }
6460
+
6456
6461
/* Take away reset for LCB and RX FPE (set in lcb_shutdown). */
6457
6462
write_csr (dd , DCC_CFG_RESET , 0x10 );
6458
6463
/* lcb_shutdown() with abort=1 does not restore these */
6459
6464
write_csr (dd , DC_LCB_ERR_EN , dd -> lcb_err_en );
6460
- spin_lock_irqsave (& dd -> dc8051_lock , flags );
6461
6465
dd -> dc_shutdown = 0 ;
6462
- done :
6463
- spin_unlock_irqrestore (& dd -> dc8051_lock , flags );
6466
+ }
6467
+
6468
+ static void dc_start (struct hfi1_devdata * dd )
6469
+ {
6470
+ mutex_lock (& dd -> dc8051_lock );
6471
+ _dc_start (dd );
6472
+ mutex_unlock (& dd -> dc8051_lock );
6464
6473
}
6465
6474
6466
6475
/*
@@ -8513,16 +8522,11 @@ static int do_8051_command(
8513
8522
{
8514
8523
u64 reg , completed ;
8515
8524
int return_code ;
8516
- unsigned long flags ;
8517
8525
unsigned long timeout ;
8518
8526
8519
8527
hfi1_cdbg (DC8051 , "type %d, data 0x%012llx" , type , in_data );
8520
8528
8521
- /*
8522
- * Alternative to holding the lock for a long time:
8523
- * - keep busy wait - have other users bounce off
8524
- */
8525
- spin_lock_irqsave (& dd -> dc8051_lock , flags );
8529
+ mutex_lock (& dd -> dc8051_lock );
8526
8530
8527
8531
/* We can't send any commands to the 8051 if it's in reset */
8528
8532
if (dd -> dc_shutdown ) {
@@ -8548,10 +8552,8 @@ static int do_8051_command(
8548
8552
return_code = - ENXIO ;
8549
8553
goto fail ;
8550
8554
}
8551
- spin_unlock_irqrestore (& dd -> dc8051_lock , flags );
8552
- dc_shutdown (dd );
8553
- dc_start (dd );
8554
- spin_lock_irqsave (& dd -> dc8051_lock , flags );
8555
+ _dc_shutdown (dd );
8556
+ _dc_start (dd );
8555
8557
}
8556
8558
8557
8559
/*
@@ -8632,8 +8634,7 @@ static int do_8051_command(
8632
8634
write_csr (dd , DC_DC8051_CFG_HOST_CMD_0 , 0 );
8633
8635
8634
8636
fail :
8635
- spin_unlock_irqrestore (& dd -> dc8051_lock , flags );
8636
-
8637
+ mutex_unlock (& dd -> dc8051_lock );
8637
8638
return return_code ;
8638
8639
}
8639
8640
@@ -12007,6 +12008,10 @@ static void free_cntrs(struct hfi1_devdata *dd)
12007
12008
dd -> scntrs = NULL ;
12008
12009
kfree (dd -> cntrnames );
12009
12010
dd -> cntrnames = NULL ;
12011
+ if (dd -> update_cntr_wq ) {
12012
+ destroy_workqueue (dd -> update_cntr_wq );
12013
+ dd -> update_cntr_wq = NULL ;
12014
+ }
12010
12015
}
12011
12016
12012
12017
static u64 read_dev_port_cntr (struct hfi1_devdata * dd , struct cntr_entry * entry ,
@@ -12162,7 +12167,7 @@ u64 write_port_cntr(struct hfi1_pportdata *ppd, int index, int vl, u64 data)
12162
12167
return write_dev_port_cntr (ppd -> dd , entry , sval , ppd , vl , data );
12163
12168
}
12164
12169
12165
- static void update_synth_timer ( unsigned long opaque )
12170
+ static void do_update_synth_timer ( struct work_struct * work )
12166
12171
{
12167
12172
u64 cur_tx ;
12168
12173
u64 cur_rx ;
@@ -12171,8 +12176,8 @@ static void update_synth_timer(unsigned long opaque)
12171
12176
int i , j , vl ;
12172
12177
struct hfi1_pportdata * ppd ;
12173
12178
struct cntr_entry * entry ;
12174
-
12175
- struct hfi1_devdata * dd = ( struct hfi1_devdata * ) opaque ;
12179
+ struct hfi1_devdata * dd = container_of ( work , struct hfi1_devdata ,
12180
+ update_cntr_work ) ;
12176
12181
12177
12182
/*
12178
12183
* Rather than keep beating on the CSRs pick a minimal set that we can
@@ -12255,7 +12260,13 @@ static void update_synth_timer(unsigned long opaque)
12255
12260
} else {
12256
12261
hfi1_cdbg (CNTR , "[%d] No update necessary" , dd -> unit );
12257
12262
}
12263
+ }
12258
12264
12265
+ static void update_synth_timer (unsigned long opaque )
12266
+ {
12267
+ struct hfi1_devdata * dd = (struct hfi1_devdata * )opaque ;
12268
+
12269
+ queue_work (dd -> update_cntr_wq , & dd -> update_cntr_work );
12259
12270
mod_timer (& dd -> synth_stats_timer , jiffies + HZ * SYNTH_CNT_TIME );
12260
12271
}
12261
12272
@@ -12491,6 +12502,13 @@ static int init_cntrs(struct hfi1_devdata *dd)
12491
12502
if (init_cpu_counters (dd ))
12492
12503
goto bail ;
12493
12504
12505
+ dd -> update_cntr_wq = alloc_ordered_workqueue ("hfi1_update_cntr_%d" ,
12506
+ WQ_MEM_RECLAIM , dd -> unit );
12507
+ if (!dd -> update_cntr_wq )
12508
+ goto bail ;
12509
+
12510
+ INIT_WORK (& dd -> update_cntr_work , do_update_synth_timer );
12511
+
12494
12512
mod_timer (& dd -> synth_stats_timer , jiffies + HZ * SYNTH_CNT_TIME );
12495
12513
return 0 ;
12496
12514
bail :
0 commit comments