lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6g32g3zqzsdoo3h6d232jbtatp34tm3s5m6huc37h5sfir2bnf@syyou6tqyuxy>
Date: Fri, 22 Aug 2025 22:49:39 +0530
From: Manivannan Sadhasivam <mani@...nel.org>
To: Vivek.Pernamitta@...cinc.com
Cc: mhi@...ts.linux.dev, linux-arm-msm@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Vivek Pernamitta <quic_vpernami@...cinc.com>
Subject: Re: [PATCH] bus: mhi: host: Add uevent support in MHI driver

On Fri, Aug 22, 2025 at 10:22:03AM GMT, Vivek.Pernamitta@...cinc.com wrote:
> From: Vivek Pernamitta <quic_vpernami@...cinc.com>
> 
> 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@...cinc.com>
> ---
> 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.
> 
> Signed-off-by:
> ---
> Usage:
> 
> Enabling 16 virtual fucntions for SRIOV device QDU100 once device reached
> mission mode from systemd service file
> 
> SUBSYSTEM=="mhi", ENV{EXEC_ENV}=="MISSION MODE", SUBSYSTEMS=="pci", ATTRS{device}=="0x0601",ATTR{../sriov_numvfs}="16"
> ---
> 
> ---
>  drivers/bus/mhi/host/internal.h |  1 +
>  drivers/bus/mhi/host/main.c     |  1 +
>  drivers/bus/mhi/host/pm.c       | 22 ++++++++++++++++++++++
>  3 files changed, 24 insertions(+)
> 
> diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/internal.h
> index 034be33565b78eff9bdefd93faa4f3ce93825bad..d455f0bf00133775fa23882a727782275640e43b 100644
> --- a/drivers/bus/mhi/host/internal.h
> +++ b/drivers/bus/mhi/host/internal.h
> @@ -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);
> diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c
> index 52bef663e182de157e50f64c1764a52545c70865..8615512743199a59a58c3756d9cc3407079cee7e 100644
> --- a/drivers/bus/mhi/host/main.c
> +++ b/drivers/bus/mhi/host/main.c
> @@ -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;
> diff --git a/drivers/bus/mhi/host/pm.c b/drivers/bus/mhi/host/pm.c
> index 33d92bf2fc3ed48db5f7fe80e4f0ef9fe2d2f2ab..1b849f334c49e52636821ed7587865a9254e9118 100644
> --- a/drivers/bus/mhi/host/pm.c
> +++ b/drivers/bus/mhi/host/pm.c
> @@ -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,17 @@ 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;
> +
> +	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));

You are leaking buf[0] here.

- Mani

-- 
மணிவண்ணன் சதாசிவம்

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ