@@ -364,6 +364,34 @@ void ufshcd_disable_irq(struct ufs_hba *hba)
364364}
365365EXPORT_SYMBOL_GPL (ufshcd_disable_irq );
366366
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+
367395static void ufshcd_configure_wb (struct ufs_hba * hba )
368396{
369397 if (!ufshcd_is_wb_allowed (hba ))
@@ -2596,6 +2624,7 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
25962624 */
25972625int ufshcd_send_uic_cmd (struct ufs_hba * hba , struct uic_command * uic_cmd )
25982626{
2627+ unsigned long flags ;
25992628 int ret ;
26002629
26012630 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)
26052634 mutex_lock (& hba -> uic_cmd_mutex );
26062635 ufshcd_add_delay_before_dme_cmd (hba );
26072636
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+
26082641 ret = __ufshcd_send_uic_cmd (hba , uic_cmd );
26092642 if (!ret )
26102643 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)
26812714 return ufshcd_crypto_fill_prdt (hba , lrbp );
26822715}
26832716
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-
27102717/**
27112718 * ufshcd_prepare_req_desc_hdr - Fill UTP Transfer request descriptor header according to request
27122719 * descriptor according to request
@@ -4318,7 +4325,6 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
43184325 unsigned long flags ;
43194326 u8 status ;
43204327 int ret ;
4321- bool reenable_intr = false;
43224328
43234329 mutex_lock (& hba -> uic_cmd_mutex );
43244330 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)
43294335 goto out_unlock ;
43304336 }
43314337 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 );
43414339 spin_unlock_irqrestore (hba -> host -> host_lock , flags );
43424340 ret = __ufshcd_send_uic_cmd (hba , cmd );
43434341 if (ret ) {
@@ -4381,8 +4379,6 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
43814379 spin_lock_irqsave (hba -> host -> host_lock , flags );
43824380 hba -> active_uic_cmd = NULL ;
43834381 hba -> uic_async_done = NULL ;
4384- if (reenable_intr )
4385- ufshcd_enable_intr (hba , UIC_COMMAND_COMPL );
43864382 if (ret && !hba -> pm_op_in_progress ) {
43874383 ufshcd_set_link_broken (hba );
43884384 ufshcd_schedule_eh_work (hba );
@@ -4413,28 +4409,17 @@ int ufshcd_send_bsg_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
44134409{
44144410 int ret ;
44154411
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+
44164416 if (hba -> quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD )
44174417 return 0 ;
44184418
44194419 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 );
44374421 ufshcd_release (hba );
4422+
44384423 return ret ;
44394424}
44404425
0 commit comments