Commit 8b53087c authored by Bhaumik Bhatt's avatar Bhaumik Bhatt Committed by Greg Kroah-Hartman

bus: mhi: core: Use helper API to trigger a non-blocking host resume

Autonomous low power mode support requires the MHI host to resume from
multiple places and post a wakeup source to exit system suspend. This
needs to be done in a non-blocking manner. Introduce a helper API to
trigger the host resume for data transfers and other non-blocking use
cases while supporting implementation of autonomous low power modes.
Reviewed-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: default avatarBhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20200929175218.8178-5-manivannan.sadhasivam@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 515847c5
...@@ -599,6 +599,13 @@ int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl); ...@@ -599,6 +599,13 @@ int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl);
int mhi_send_cmd(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, int mhi_send_cmd(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
enum mhi_cmd_type cmd); enum mhi_cmd_type cmd);
static inline void mhi_trigger_resume(struct mhi_controller *mhi_cntrl)
{
pm_wakeup_event(&mhi_cntrl->mhi_dev->dev, 0);
mhi_cntrl->runtime_get(mhi_cntrl);
mhi_cntrl->runtime_put(mhi_cntrl);
}
/* Register access methods */ /* Register access methods */
void mhi_db_brstmode(struct mhi_controller *mhi_cntrl, struct db_cfg *db_cfg, void mhi_db_brstmode(struct mhi_controller *mhi_cntrl, struct db_cfg *db_cfg,
void __iomem *db_addr, dma_addr_t db_val); void __iomem *db_addr, dma_addr_t db_val);
......
...@@ -909,8 +909,7 @@ void mhi_ctrl_ev_task(unsigned long data) ...@@ -909,8 +909,7 @@ void mhi_ctrl_ev_task(unsigned long data)
* process it since we are probably in a suspended state, * process it since we are probably in a suspended state,
* so trigger a resume. * so trigger a resume.
*/ */
mhi_cntrl->runtime_get(mhi_cntrl); mhi_trigger_resume(mhi_cntrl);
mhi_cntrl->runtime_put(mhi_cntrl);
return; return;
} }
...@@ -971,10 +970,8 @@ int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir, ...@@ -971,10 +970,8 @@ int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir,
} }
/* we're in M3 or transitioning to M3 */ /* we're in M3 or transitioning to M3 */
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
mhi_cntrl->runtime_get(mhi_cntrl); mhi_trigger_resume(mhi_cntrl);
mhi_cntrl->runtime_put(mhi_cntrl);
}
/* Toggle wake to exit out of M2 */ /* Toggle wake to exit out of M2 */
mhi_cntrl->wake_toggle(mhi_cntrl); mhi_cntrl->wake_toggle(mhi_cntrl);
...@@ -1032,10 +1029,8 @@ int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir, ...@@ -1032,10 +1029,8 @@ int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir,
} }
/* we're in M3 or transitioning to M3 */ /* we're in M3 or transitioning to M3 */
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
mhi_cntrl->runtime_get(mhi_cntrl); mhi_trigger_resume(mhi_cntrl);
mhi_cntrl->runtime_put(mhi_cntrl);
}
/* Toggle wake to exit out of M2 */ /* Toggle wake to exit out of M2 */
mhi_cntrl->wake_toggle(mhi_cntrl); mhi_cntrl->wake_toggle(mhi_cntrl);
...@@ -1147,10 +1142,8 @@ int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir, ...@@ -1147,10 +1142,8 @@ int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,
read_lock_irqsave(&mhi_cntrl->pm_lock, flags); read_lock_irqsave(&mhi_cntrl->pm_lock, flags);
/* we're in M3 or transitioning to M3 */ /* we're in M3 or transitioning to M3 */
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
mhi_cntrl->runtime_get(mhi_cntrl); mhi_trigger_resume(mhi_cntrl);
mhi_cntrl->runtime_put(mhi_cntrl);
}
/* Toggle wake to exit out of M2 */ /* Toggle wake to exit out of M2 */
mhi_cntrl->wake_toggle(mhi_cntrl); mhi_cntrl->wake_toggle(mhi_cntrl);
......
...@@ -824,11 +824,8 @@ int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl) ...@@ -824,11 +824,8 @@ int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl)
/* Wake up the device */ /* Wake up the device */
read_lock_bh(&mhi_cntrl->pm_lock); read_lock_bh(&mhi_cntrl->pm_lock);
mhi_cntrl->wake_get(mhi_cntrl, true); mhi_cntrl->wake_get(mhi_cntrl, true);
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
pm_wakeup_event(&mhi_cntrl->mhi_dev->dev, 0); mhi_trigger_resume(mhi_cntrl);
mhi_cntrl->runtime_get(mhi_cntrl);
mhi_cntrl->runtime_put(mhi_cntrl);
}
read_unlock_bh(&mhi_cntrl->pm_lock); read_unlock_bh(&mhi_cntrl->pm_lock);
ret = wait_event_timeout(mhi_cntrl->state_event, ret = wait_event_timeout(mhi_cntrl->state_event,
...@@ -1139,10 +1136,8 @@ void mhi_device_put(struct mhi_device *mhi_dev) ...@@ -1139,10 +1136,8 @@ void mhi_device_put(struct mhi_device *mhi_dev)
mhi_dev->dev_wake--; mhi_dev->dev_wake--;
read_lock_bh(&mhi_cntrl->pm_lock); read_lock_bh(&mhi_cntrl->pm_lock);
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
mhi_cntrl->runtime_get(mhi_cntrl); mhi_trigger_resume(mhi_cntrl);
mhi_cntrl->runtime_put(mhi_cntrl);
}
mhi_cntrl->wake_put(mhi_cntrl, false); mhi_cntrl->wake_put(mhi_cntrl, false);
read_unlock_bh(&mhi_cntrl->pm_lock); read_unlock_bh(&mhi_cntrl->pm_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment