@@ -364,6 +364,34 @@ void ufshcd_disable_irq(struct ufs_hba *hba)
364
364
}
365
365
EXPORT_SYMBOL_GPL (ufshcd_disable_irq );
366
366
367
+ /**
368
+ * ufshcd_enable_intr - enable interrupts
369
+ * @hba: per adapter instance
370
+ * @intrs: interrupt bits
371
+ */
372
+ static void ufshcd_enable_intr (struct ufs_hba * hba , u32 intrs )
373
+ {
374
+ u32 old_val = ufshcd_readl (hba , REG_INTERRUPT_ENABLE );
375
+ u32 new_val = old_val | intrs ;
376
+
377
+ if (new_val != old_val )
378
+ ufshcd_writel (hba , new_val , REG_INTERRUPT_ENABLE );
379
+ }
380
+
381
+ /**
382
+ * ufshcd_disable_intr - disable interrupts
383
+ * @hba: per adapter instance
384
+ * @intrs: interrupt bits
385
+ */
386
+ static void ufshcd_disable_intr (struct ufs_hba * hba , u32 intrs )
387
+ {
388
+ u32 old_val = ufshcd_readl (hba , REG_INTERRUPT_ENABLE );
389
+ u32 new_val = old_val & ~intrs ;
390
+
391
+ if (new_val != old_val )
392
+ ufshcd_writel (hba , new_val , REG_INTERRUPT_ENABLE );
393
+ }
394
+
367
395
static void ufshcd_configure_wb (struct ufs_hba * hba )
368
396
{
369
397
if (!ufshcd_is_wb_allowed (hba ))
@@ -2596,6 +2624,7 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
2596
2624
*/
2597
2625
int ufshcd_send_uic_cmd (struct ufs_hba * hba , struct uic_command * uic_cmd )
2598
2626
{
2627
+ unsigned long flags ;
2599
2628
int ret ;
2600
2629
2601
2630
if (hba -> quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD )
@@ -2605,6 +2634,10 @@ int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
2605
2634
mutex_lock (& hba -> uic_cmd_mutex );
2606
2635
ufshcd_add_delay_before_dme_cmd (hba );
2607
2636
2637
+ spin_lock_irqsave (hba -> host -> host_lock , flags );
2638
+ ufshcd_enable_intr (hba , UIC_COMMAND_COMPL );
2639
+ spin_unlock_irqrestore (hba -> host -> host_lock , flags );
2640
+
2608
2641
ret = __ufshcd_send_uic_cmd (hba , uic_cmd );
2609
2642
if (!ret )
2610
2643
ret = ufshcd_wait_for_uic_cmd (hba , uic_cmd );
@@ -2681,32 +2714,6 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
2681
2714
return ufshcd_crypto_fill_prdt (hba , lrbp );
2682
2715
}
2683
2716
2684
- /**
2685
- * ufshcd_enable_intr - enable interrupts
2686
- * @hba: per adapter instance
2687
- * @intrs: interrupt bits
2688
- */
2689
- static void ufshcd_enable_intr (struct ufs_hba * hba , u32 intrs )
2690
- {
2691
- u32 set = ufshcd_readl (hba , REG_INTERRUPT_ENABLE );
2692
-
2693
- set |= intrs ;
2694
- ufshcd_writel (hba , set , REG_INTERRUPT_ENABLE );
2695
- }
2696
-
2697
- /**
2698
- * ufshcd_disable_intr - disable interrupts
2699
- * @hba: per adapter instance
2700
- * @intrs: interrupt bits
2701
- */
2702
- static void ufshcd_disable_intr (struct ufs_hba * hba , u32 intrs )
2703
- {
2704
- u32 set = ufshcd_readl (hba , REG_INTERRUPT_ENABLE );
2705
-
2706
- set &= ~intrs ;
2707
- ufshcd_writel (hba , set , REG_INTERRUPT_ENABLE );
2708
- }
2709
-
2710
2717
/**
2711
2718
* ufshcd_prepare_req_desc_hdr - Fill UTP Transfer request descriptor header according to request
2712
2719
* descriptor according to request
@@ -4318,7 +4325,6 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
4318
4325
unsigned long flags ;
4319
4326
u8 status ;
4320
4327
int ret ;
4321
- bool reenable_intr = false;
4322
4328
4323
4329
mutex_lock (& hba -> uic_cmd_mutex );
4324
4330
ufshcd_add_delay_before_dme_cmd (hba );
@@ -4329,15 +4335,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
4329
4335
goto out_unlock ;
4330
4336
}
4331
4337
hba -> uic_async_done = & uic_async_done ;
4332
- if (ufshcd_readl (hba , REG_INTERRUPT_ENABLE ) & UIC_COMMAND_COMPL ) {
4333
- ufshcd_disable_intr (hba , UIC_COMMAND_COMPL );
4334
- /*
4335
- * Make sure UIC command completion interrupt is disabled before
4336
- * issuing UIC command.
4337
- */
4338
- ufshcd_readl (hba , REG_INTERRUPT_ENABLE );
4339
- reenable_intr = true;
4340
- }
4338
+ ufshcd_disable_intr (hba , UIC_COMMAND_COMPL );
4341
4339
spin_unlock_irqrestore (hba -> host -> host_lock , flags );
4342
4340
ret = __ufshcd_send_uic_cmd (hba , cmd );
4343
4341
if (ret ) {
@@ -4381,8 +4379,6 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
4381
4379
spin_lock_irqsave (hba -> host -> host_lock , flags );
4382
4380
hba -> active_uic_cmd = NULL ;
4383
4381
hba -> uic_async_done = NULL ;
4384
- if (reenable_intr )
4385
- ufshcd_enable_intr (hba , UIC_COMMAND_COMPL );
4386
4382
if (ret && !hba -> pm_op_in_progress ) {
4387
4383
ufshcd_set_link_broken (hba );
4388
4384
ufshcd_schedule_eh_work (hba );
@@ -4413,28 +4409,17 @@ int ufshcd_send_bsg_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
4413
4409
{
4414
4410
int ret ;
4415
4411
4412
+ if (uic_cmd -> argument1 != UIC_ARG_MIB (PA_PWRMODE ) ||
4413
+ uic_cmd -> command != UIC_CMD_DME_SET )
4414
+ return ufshcd_send_uic_cmd (hba , uic_cmd );
4415
+
4416
4416
if (hba -> quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD )
4417
4417
return 0 ;
4418
4418
4419
4419
ufshcd_hold (hba );
4420
-
4421
- if (uic_cmd -> argument1 == UIC_ARG_MIB (PA_PWRMODE ) &&
4422
- uic_cmd -> command == UIC_CMD_DME_SET ) {
4423
- ret = ufshcd_uic_pwr_ctrl (hba , uic_cmd );
4424
- goto out ;
4425
- }
4426
-
4427
- mutex_lock (& hba -> uic_cmd_mutex );
4428
- ufshcd_add_delay_before_dme_cmd (hba );
4429
-
4430
- ret = __ufshcd_send_uic_cmd (hba , uic_cmd );
4431
- if (!ret )
4432
- ret = ufshcd_wait_for_uic_cmd (hba , uic_cmd );
4433
-
4434
- mutex_unlock (& hba -> uic_cmd_mutex );
4435
-
4436
- out :
4420
+ ret = ufshcd_uic_pwr_ctrl (hba , uic_cmd );
4437
4421
ufshcd_release (hba );
4422
+
4438
4423
return ret ;
4439
4424
}
4440
4425
0 commit comments