Skip to content

Commit d5411ed

Browse files
Vivek PernamittaManivannan Sadhasivam
authored andcommitted
bus: mhi: host: Notify EE change via uevent
Notify the MHI device's Execution Environment (EE) state via uevent, enabling applications to receive real-time updates and take appropriate actions based on the current state of MHI. Signed-off-by: Vivek Pernamitta <[email protected]> [mani: Reworded subject, removed error print, fixed indentation] Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://patch.msgid.link/20250912-b4-uevent_vdev_next-20250911-v2-1-89440407bf7e@quicinc.com
1 parent d0856a6 commit d5411ed

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

drivers/bus/mhi/host/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl,
403403
struct mhi_event *mhi_event, u32 event_quota);
404404
int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
405405
struct mhi_event *mhi_event, u32 event_quota);
406+
void mhi_uevent_notify(struct mhi_controller *mhi_cntrl, enum mhi_ee_type ee);
406407

407408
/* ISR handlers */
408409
irqreturn_t mhi_irq_handler(int irq_number, void *dev);

drivers/bus/mhi/host/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ irqreturn_t mhi_intvec_threaded_handler(int irq_number, void *priv)
512512
if (mhi_cntrl->rddm_image && mhi_is_active(mhi_cntrl)) {
513513
mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_EE_RDDM);
514514
mhi_cntrl->ee = ee;
515+
mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
515516
wake_up_all(&mhi_cntrl->state_event);
516517
}
517518
break;

drivers/bus/mhi/host/pm.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
418418
device_for_each_child(&mhi_cntrl->mhi_dev->dev, &current_ee,
419419
mhi_destroy_device);
420420
mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_EE_MISSION_MODE);
421+
mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
421422

422423
/* Force MHI to be in M0 state before continuing */
423424
ret = __mhi_device_get_sync(mhi_cntrl);
@@ -631,6 +632,8 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
631632
/* Wake up threads waiting for state transition */
632633
wake_up_all(&mhi_cntrl->state_event);
633634

635+
mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
636+
634637
if (MHI_REG_ACCESS_VALID(prev_state)) {
635638
/*
636639
* If the device is in PBL or SBL, it will only respond to
@@ -829,6 +832,8 @@ void mhi_pm_st_worker(struct work_struct *work)
829832
mhi_create_devices(mhi_cntrl);
830833
if (mhi_cntrl->fbc_download)
831834
mhi_download_amss_image(mhi_cntrl);
835+
836+
mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
832837
break;
833838
case DEV_ST_TRANSITION_MISSION_MODE:
834839
mhi_pm_mission_mode_transition(mhi_cntrl);
@@ -838,6 +843,7 @@ void mhi_pm_st_worker(struct work_struct *work)
838843
mhi_cntrl->ee = MHI_EE_FP;
839844
write_unlock_irq(&mhi_cntrl->pm_lock);
840845
mhi_create_devices(mhi_cntrl);
846+
mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
841847
break;
842848
case DEV_ST_TRANSITION_READY:
843849
mhi_ready_state_transition(mhi_cntrl);
@@ -1240,6 +1246,8 @@ static void __mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful,
12401246
write_unlock_irq(&mhi_cntrl->pm_lock);
12411247
mutex_unlock(&mhi_cntrl->pm_mutex);
12421248

1249+
mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
1250+
12431251
if (destroy_device)
12441252
mhi_queue_state_transition(mhi_cntrl,
12451253
DEV_ST_TRANSITION_DISABLE_DESTROY_DEVICE);
@@ -1338,3 +1346,22 @@ void mhi_device_put(struct mhi_device *mhi_dev)
13381346
read_unlock_bh(&mhi_cntrl->pm_lock);
13391347
}
13401348
EXPORT_SYMBOL_GPL(mhi_device_put);
1349+
1350+
void mhi_uevent_notify(struct mhi_controller *mhi_cntrl, enum mhi_ee_type ee)
1351+
{
1352+
struct device *dev = &mhi_cntrl->mhi_dev->dev;
1353+
char *buf[2];
1354+
int ret;
1355+
1356+
buf[0] = kasprintf(GFP_KERNEL, "EXEC_ENV=%s", TO_MHI_EXEC_STR(ee));
1357+
buf[1] = NULL;
1358+
1359+
if (!buf[0])
1360+
return;
1361+
1362+
ret = kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, buf);
1363+
if (ret)
1364+
dev_err(dev, "Failed to send %s uevent\n", TO_MHI_EXEC_STR(ee));
1365+
1366+
kfree(buf[0]);
1367+
}

0 commit comments

Comments
 (0)