mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 01:24:12 +08:00
bus: mhi: core: Handle firmware load using state worker
Upon power up, driver queues firmware worker thread if the execution environment is PBL. Firmware worker is blocked with a timeout until state worker gets a chance to run and unblock firmware worker. An endpoint power up failure can be seen if state worker gets a chance to run after firmware worker has timed out. Remove this dependency and handle firmware load directly using state worker thread. Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org> Reviewed-by: Jeffrey Hugo <jhugo@codeaurora.org> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Link: https://lore.kernel.org/r/20200521170249.21795-6-manivannan.sadhasivam@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ee75cedf82
commit
560e3a0459
@ -377,30 +377,18 @@ static void mhi_firmware_copy(struct mhi_controller *mhi_cntrl,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mhi_fw_load_worker(struct work_struct *work)
|
void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
|
||||||
{
|
{
|
||||||
struct mhi_controller *mhi_cntrl;
|
|
||||||
const struct firmware *firmware = NULL;
|
const struct firmware *firmware = NULL;
|
||||||
struct image_info *image_info;
|
struct image_info *image_info;
|
||||||
struct device *dev;
|
struct device *dev = &mhi_cntrl->mhi_dev->dev;
|
||||||
const char *fw_name;
|
const char *fw_name;
|
||||||
void *buf;
|
void *buf;
|
||||||
dma_addr_t dma_addr;
|
dma_addr_t dma_addr;
|
||||||
size_t size;
|
size_t size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mhi_cntrl = container_of(work, struct mhi_controller, fw_worker);
|
if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) {
|
||||||
dev = &mhi_cntrl->mhi_dev->dev;
|
|
||||||
|
|
||||||
dev_dbg(dev, "Waiting for device to enter PBL from: %s\n",
|
|
||||||
TO_MHI_EXEC_STR(mhi_cntrl->ee));
|
|
||||||
|
|
||||||
ret = wait_event_timeout(mhi_cntrl->state_event,
|
|
||||||
MHI_IN_PBL(mhi_cntrl->ee) ||
|
|
||||||
MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state),
|
|
||||||
msecs_to_jiffies(mhi_cntrl->timeout_ms));
|
|
||||||
|
|
||||||
if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) {
|
|
||||||
dev_err(dev, "Device MHI is not in valid state\n");
|
dev_err(dev, "Device MHI is not in valid state\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -835,7 +835,6 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,
|
|||||||
spin_lock_init(&mhi_cntrl->wlock);
|
spin_lock_init(&mhi_cntrl->wlock);
|
||||||
INIT_WORK(&mhi_cntrl->st_worker, mhi_pm_st_worker);
|
INIT_WORK(&mhi_cntrl->st_worker, mhi_pm_st_worker);
|
||||||
INIT_WORK(&mhi_cntrl->syserr_worker, mhi_pm_sys_err_worker);
|
INIT_WORK(&mhi_cntrl->syserr_worker, mhi_pm_sys_err_worker);
|
||||||
INIT_WORK(&mhi_cntrl->fw_worker, mhi_fw_load_worker);
|
|
||||||
init_waitqueue_head(&mhi_cntrl->state_event);
|
init_waitqueue_head(&mhi_cntrl->state_event);
|
||||||
|
|
||||||
mhi_cmd = mhi_cntrl->mhi_cmd;
|
mhi_cmd = mhi_cntrl->mhi_cmd;
|
||||||
|
@ -627,6 +627,7 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl);
|
|||||||
void mhi_deinit_free_irq(struct mhi_controller *mhi_cntrl);
|
void mhi_deinit_free_irq(struct mhi_controller *mhi_cntrl);
|
||||||
void mhi_rddm_prepare(struct mhi_controller *mhi_cntrl,
|
void mhi_rddm_prepare(struct mhi_controller *mhi_cntrl,
|
||||||
struct image_info *img_info);
|
struct image_info *img_info);
|
||||||
|
void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl);
|
||||||
int mhi_prepare_channel(struct mhi_controller *mhi_cntrl,
|
int mhi_prepare_channel(struct mhi_controller *mhi_cntrl,
|
||||||
struct mhi_chan *mhi_chan);
|
struct mhi_chan *mhi_chan);
|
||||||
int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl,
|
int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl,
|
||||||
|
@ -528,7 +528,6 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl,
|
|||||||
dev_dbg(dev, "Waiting for all pending threads to complete\n");
|
dev_dbg(dev, "Waiting for all pending threads to complete\n");
|
||||||
wake_up_all(&mhi_cntrl->state_event);
|
wake_up_all(&mhi_cntrl->state_event);
|
||||||
flush_work(&mhi_cntrl->st_worker);
|
flush_work(&mhi_cntrl->st_worker);
|
||||||
flush_work(&mhi_cntrl->fw_worker);
|
|
||||||
|
|
||||||
dev_dbg(dev, "Reset all active channels and remove MHI devices\n");
|
dev_dbg(dev, "Reset all active channels and remove MHI devices\n");
|
||||||
device_for_each_child(mhi_cntrl->cntrl_dev, NULL, mhi_destroy_device);
|
device_for_each_child(mhi_cntrl->cntrl_dev, NULL, mhi_destroy_device);
|
||||||
@ -643,7 +642,7 @@ void mhi_pm_st_worker(struct work_struct *work)
|
|||||||
mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl);
|
mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl);
|
||||||
write_unlock_irq(&mhi_cntrl->pm_lock);
|
write_unlock_irq(&mhi_cntrl->pm_lock);
|
||||||
if (MHI_IN_PBL(mhi_cntrl->ee))
|
if (MHI_IN_PBL(mhi_cntrl->ee))
|
||||||
wake_up_all(&mhi_cntrl->state_event);
|
mhi_fw_load_handler(mhi_cntrl);
|
||||||
break;
|
break;
|
||||||
case DEV_ST_TRANSITION_SBL:
|
case DEV_ST_TRANSITION_SBL:
|
||||||
write_lock_irq(&mhi_cntrl->pm_lock);
|
write_lock_irq(&mhi_cntrl->pm_lock);
|
||||||
@ -976,9 +975,6 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl)
|
|||||||
next_state = MHI_IN_PBL(current_ee) ?
|
next_state = MHI_IN_PBL(current_ee) ?
|
||||||
DEV_ST_TRANSITION_PBL : DEV_ST_TRANSITION_READY;
|
DEV_ST_TRANSITION_PBL : DEV_ST_TRANSITION_READY;
|
||||||
|
|
||||||
if (next_state == DEV_ST_TRANSITION_PBL)
|
|
||||||
schedule_work(&mhi_cntrl->fw_worker);
|
|
||||||
|
|
||||||
mhi_queue_state_transition(mhi_cntrl, next_state);
|
mhi_queue_state_transition(mhi_cntrl, next_state);
|
||||||
|
|
||||||
mutex_unlock(&mhi_cntrl->pm_mutex);
|
mutex_unlock(&mhi_cntrl->pm_mutex);
|
||||||
|
@ -331,7 +331,6 @@ struct mhi_controller_config {
|
|||||||
* @wlock: Lock for protecting device wakeup
|
* @wlock: Lock for protecting device wakeup
|
||||||
* @mhi_link_info: Device bandwidth info
|
* @mhi_link_info: Device bandwidth info
|
||||||
* @st_worker: State transition worker
|
* @st_worker: State transition worker
|
||||||
* @fw_worker: Firmware download worker
|
|
||||||
* @syserr_worker: System error worker
|
* @syserr_worker: System error worker
|
||||||
* @state_event: State change event
|
* @state_event: State change event
|
||||||
* @status_cb: CB function to notify power states of the device (required)
|
* @status_cb: CB function to notify power states of the device (required)
|
||||||
@ -412,7 +411,6 @@ struct mhi_controller {
|
|||||||
spinlock_t wlock;
|
spinlock_t wlock;
|
||||||
struct mhi_link_info mhi_link_info;
|
struct mhi_link_info mhi_link_info;
|
||||||
struct work_struct st_worker;
|
struct work_struct st_worker;
|
||||||
struct work_struct fw_worker;
|
|
||||||
struct work_struct syserr_worker;
|
struct work_struct syserr_worker;
|
||||||
wait_queue_head_t state_event;
|
wait_queue_head_t state_event;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user