Skip to content

Commit b4c0cab

Browse files
ahunter6martinkpetersen
authored andcommitted
scsi: ufs: core: Set and clear UIC Completion interrupt as needed
Currently the UIC Completion interrupt is left enabled except for when issuing link hibernate commands, in which case the interrupt is disabled and then re-enabled. Instead, set and clear the interrupt enable bit as needed. That is slightly simpler and less error prone, but also avoids side effects of accessing the interrupt enable register after entering link hibernation. Specifically, for some host controllers like Intel MTL, doing so disrupts the link state transition. Note also, the interrupt register is not read back anymore after it is updated. No other code does that, so it is assumed to be no longer necessary if it ever was. Signed-off-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent c5977c4 commit b4c0cab

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,7 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
26222622
*/
26232623
int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
26242624
{
2625+
unsigned long flags;
26252626
int ret;
26262627

26272628
if (hba->quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD)
@@ -2631,6 +2632,10 @@ int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
26312632
mutex_lock(&hba->uic_cmd_mutex);
26322633
ufshcd_add_delay_before_dme_cmd(hba);
26332634

2635+
spin_lock_irqsave(hba->host->host_lock, flags);
2636+
ufshcd_enable_intr(hba, UIC_COMMAND_COMPL);
2637+
spin_unlock_irqrestore(hba->host->host_lock, flags);
2638+
26342639
ret = __ufshcd_send_uic_cmd(hba, uic_cmd);
26352640
if (!ret)
26362641
ret = ufshcd_wait_for_uic_cmd(hba, uic_cmd);
@@ -4275,7 +4280,6 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
42754280
unsigned long flags;
42764281
u8 status;
42774282
int ret;
4278-
bool reenable_intr = false;
42794283

42804284
mutex_lock(&hba->uic_cmd_mutex);
42814285
ufshcd_add_delay_before_dme_cmd(hba);
@@ -4286,15 +4290,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
42864290
goto out_unlock;
42874291
}
42884292
hba->uic_async_done = &uic_async_done;
4289-
if (ufshcd_readl(hba, REG_INTERRUPT_ENABLE) & UIC_COMMAND_COMPL) {
4290-
ufshcd_disable_intr(hba, UIC_COMMAND_COMPL);
4291-
/*
4292-
* Make sure UIC command completion interrupt is disabled before
4293-
* issuing UIC command.
4294-
*/
4295-
ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
4296-
reenable_intr = true;
4297-
}
4293+
ufshcd_disable_intr(hba, UIC_COMMAND_COMPL);
42984294
spin_unlock_irqrestore(hba->host->host_lock, flags);
42994295
ret = __ufshcd_send_uic_cmd(hba, cmd);
43004296
if (ret) {
@@ -4338,8 +4334,6 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
43384334
spin_lock_irqsave(hba->host->host_lock, flags);
43394335
hba->active_uic_cmd = NULL;
43404336
hba->uic_async_done = NULL;
4341-
if (reenable_intr)
4342-
ufshcd_enable_intr(hba, UIC_COMMAND_COMPL);
43434337
if (ret) {
43444338
ufshcd_set_link_broken(hba);
43454339
ufshcd_schedule_eh_work(hba);

0 commit comments

Comments
 (0)