]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bus: mhi: host: Notify EE change via uevent
authorVivek Pernamitta <quic_vpernami@quicinc.com>
Fri, 12 Sep 2025 04:59:16 +0000 (10:29 +0530)
committerManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Fri, 12 Sep 2025 10:02:22 +0000 (15:32 +0530)
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 <quic_vpernami@quicinc.com>
[mani: Reworded subject, removed error print, fixed indentation]
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/20250912-b4-uevent_vdev_next-20250911-v2-1-89440407bf7e@quicinc.com
drivers/bus/mhi/host/internal.h
drivers/bus/mhi/host/main.c
drivers/bus/mhi/host/pm.c

index 034be33565b78eff9bdefd93faa4f3ce93825bad..d455f0bf00133775fa23882a727782275640e43b 100644 (file)
@@ -403,6 +403,7 @@ int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl,
                                struct mhi_event *mhi_event, u32 event_quota);
 int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
                             struct mhi_event *mhi_event, u32 event_quota);
+void mhi_uevent_notify(struct mhi_controller *mhi_cntrl, enum mhi_ee_type ee);
 
 /* ISR handlers */
 irqreturn_t mhi_irq_handler(int irq_number, void *dev);
index 52bef663e182de157e50f64c1764a52545c70865..8615512743199a59a58c3756d9cc3407079cee7e 100644 (file)
@@ -512,6 +512,7 @@ irqreturn_t mhi_intvec_threaded_handler(int irq_number, void *priv)
                if (mhi_cntrl->rddm_image && mhi_is_active(mhi_cntrl)) {
                        mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_EE_RDDM);
                        mhi_cntrl->ee = ee;
+                       mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
                        wake_up_all(&mhi_cntrl->state_event);
                }
                break;
index 33d92bf2fc3ed48db5f7fe80e4f0ef9fe2d2f2ab..9a5ca903d7581d5776ac392b16ddb46195863186 100644 (file)
@@ -418,6 +418,7 @@ static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
        device_for_each_child(&mhi_cntrl->mhi_dev->dev, &current_ee,
                              mhi_destroy_device);
        mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_EE_MISSION_MODE);
+       mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
 
        /* Force MHI to be in M0 state before continuing */
        ret = __mhi_device_get_sync(mhi_cntrl);
@@ -631,6 +632,8 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
        /* Wake up threads waiting for state transition */
        wake_up_all(&mhi_cntrl->state_event);
 
+       mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
+
        if (MHI_REG_ACCESS_VALID(prev_state)) {
                /*
                 * 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)
                        mhi_create_devices(mhi_cntrl);
                        if (mhi_cntrl->fbc_download)
                                mhi_download_amss_image(mhi_cntrl);
+
+                       mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
                        break;
                case DEV_ST_TRANSITION_MISSION_MODE:
                        mhi_pm_mission_mode_transition(mhi_cntrl);
@@ -838,6 +843,7 @@ void mhi_pm_st_worker(struct work_struct *work)
                        mhi_cntrl->ee = MHI_EE_FP;
                        write_unlock_irq(&mhi_cntrl->pm_lock);
                        mhi_create_devices(mhi_cntrl);
+                       mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
                        break;
                case DEV_ST_TRANSITION_READY:
                        mhi_ready_state_transition(mhi_cntrl);
@@ -1240,6 +1246,8 @@ static void __mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful,
        write_unlock_irq(&mhi_cntrl->pm_lock);
        mutex_unlock(&mhi_cntrl->pm_mutex);
 
+       mhi_uevent_notify(mhi_cntrl, mhi_cntrl->ee);
+
        if (destroy_device)
                mhi_queue_state_transition(mhi_cntrl,
                                           DEV_ST_TRANSITION_DISABLE_DESTROY_DEVICE);
@@ -1338,3 +1346,22 @@ void mhi_device_put(struct mhi_device *mhi_dev)
        read_unlock_bh(&mhi_cntrl->pm_lock);
 }
 EXPORT_SYMBOL_GPL(mhi_device_put);
+
+void mhi_uevent_notify(struct mhi_controller *mhi_cntrl, enum mhi_ee_type ee)
+{
+       struct device *dev = &mhi_cntrl->mhi_dev->dev;
+       char *buf[2];
+       int ret;
+
+       buf[0] = kasprintf(GFP_KERNEL, "EXEC_ENV=%s", TO_MHI_EXEC_STR(ee));
+       buf[1] = NULL;
+
+       if (!buf[0])
+               return;
+
+       ret = kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, buf);
+       if (ret)
+               dev_err(dev, "Failed to send %s uevent\n", TO_MHI_EXEC_STR(ee));
+
+       kfree(buf[0]);
+}