mhi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] bus: mhi: host: Enable SRIOV support in MHI driver
@ 2025-07-03 15:09 Vivek.Pernamitta
  2025-07-03 15:09 ` [PATCH 1/5] bus: mhi: host: pci_generic: Add SRIOV support for PCIe device Vivek.Pernamitta
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Vivek.Pernamitta @ 2025-07-03 15:09 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta

This patch introduces several enhancements for the SRIOV support in MHI driver
focusing on enabling SRIOV and improving the MHI driver removal process.

- Add support to enable SRIOV.

- Add support to read SUBSYSTEM_VENDOR_ID for VF's to check status.

- Implement support for separate controller configurations for both
  Virtual Functions (VF) and Physical Functions (PF).
  The PF takes on a supervisory role and will have bootup information
  such as SAHARA, DIAG, and NDB (for file system sync data, etc.).
  VFs can handle function-specific data transfers, such as data plane
  or hardware data.

- Perform a graceful removal of the MHI driver. Upon driver removal,
  the host driver will perform a SOC_RESET on the driver remove callback.
  This ensures device reset gracefully.
  
- honor sys_err at power_up state
  In mhi_sync_power_up() host waits for device to enter in to mission mode
  but SYS_ERR is an valid state, If device sends an SYS_ERR host will bail
  out for wait_event_timeout() as MHI is in error state and calls
  mhi_power_down which will teardown MHI driver probe.
  If there is any SYS_ERR, sys_err handler needs to process SYS_ERR state
  and queues the next state transition for device to bring in to Mission
  mode, so mhi_sync_power_up() will wait for device to enter in to
  mission mode.

Signed-off-by: 

---
Vivek Pernamitta (5):
      bus: mhi: host: pci_generic: Add SRIOV support for PCIe device
      bus: mhi: host: Add support for separate controller configurations for VF and PF
      bus: mhi: host: pci_generic: Read SUBSYSTEM_VENDOR_ID for VF's to check status
      bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery
      bus: host: mhi: Need to honor sys_err at power_up state

 drivers/bus/mhi/host/internal.h    |  2 ++
 drivers/bus/mhi/host/pci_generic.c | 51 +++++++++++++++++++++++++++++++++-----
 drivers/bus/mhi/host/pm.c          |  2 +-
 3 files changed, 48 insertions(+), 7 deletions(-)
---
base-commit: 1343433ed38923a21425c602e92120a1f1db5f7a
change-id: 20250701-sriov_vdev_next-20250630-0ee75f15d03b

Best regards,
-- 
Vivek Pernamitta <<quic_vpernami@quicinc.com>>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/5] bus: mhi: host: pci_generic: Add SRIOV support for PCIe device
  2025-07-03 15:09 [PATCH 0/5] bus: mhi: host: Enable SRIOV support in MHI driver Vivek.Pernamitta
@ 2025-07-03 15:09 ` Vivek.Pernamitta
  2025-07-03 15:32   ` Konrad Dybcio
  2025-07-09 12:35   ` Krishna Chaitanya Chundru
  2025-07-03 15:09 ` [PATCH 2/5] bus: mhi: host: Add support for separate controller configurations for VF and PF Vivek.Pernamitta
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 13+ messages in thread
From: Vivek.Pernamitta @ 2025-07-03 15:09 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta

From: Vivek Pernamitta <quic_vpernami@quicinc.com>

Add SRIOV support for PCIe devices.

Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
---
 drivers/bus/mhi/host/pci_generic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
index 5c01c23d0bcfedd23f975e99845d5fa88940ccde..3e6e2d38935927cf3352c039266cae7cadb4c118 100644
--- a/drivers/bus/mhi/host/pci_generic.c
+++ b/drivers/bus/mhi/host/pci_generic.c
@@ -1607,7 +1607,8 @@ static struct pci_driver mhi_pci_driver = {
 	.remove		= mhi_pci_remove,
 	.shutdown	= mhi_pci_shutdown,
 	.err_handler	= &mhi_pci_err_handler,
-	.driver.pm	= &mhi_pci_pm_ops
+	.driver.pm	= &mhi_pci_pm_ops,
+	.sriov_configure = pci_sriov_configure_simple
 };
 module_pci_driver(mhi_pci_driver);
 

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/5] bus: mhi: host: Add support for separate controller configurations for VF and PF
  2025-07-03 15:09 [PATCH 0/5] bus: mhi: host: Enable SRIOV support in MHI driver Vivek.Pernamitta
  2025-07-03 15:09 ` [PATCH 1/5] bus: mhi: host: pci_generic: Add SRIOV support for PCIe device Vivek.Pernamitta
@ 2025-07-03 15:09 ` Vivek.Pernamitta
  2025-07-09 12:38   ` Krishna Chaitanya Chundru
  2025-07-03 15:09 ` [PATCH 3/5] bus: mhi: host: pci_generic: Read SUBSYSTEM_VENDOR_ID for VF's to check status Vivek.Pernamitta
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Vivek.Pernamitta @ 2025-07-03 15:09 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta

From: Vivek Pernamitta <quic_vpernami@quicinc.com>

Implement support for separate controller configurations for both
Virtual Functions (VF) and Physical Functions (PF).

This enhancement allows for more flexible and efficient management of
resources. The PF takes on a supervisory role and will have bootup
information such as SAHARA, DIAG, and NDB (for file system sync data,
etc.). VFs can handle function-specific data transfers, such as data plane
or hardware data.

Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
---
 drivers/bus/mhi/host/pci_generic.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
index 3e6e2d38935927cf3352c039266cae7cadb4c118..22de02c26ceb946fb618d962ac8882d2db1be6b4 100644
--- a/drivers/bus/mhi/host/pci_generic.c
+++ b/drivers/bus/mhi/host/pci_generic.c
@@ -34,6 +34,7 @@
 /**
  * struct mhi_pci_dev_info - MHI PCI device specific information
  * @config: MHI controller configuration
+ * @vf_config: MHI controller configuration for Virtual function (optional)
  * @name: name of the PCI module
  * @fw: firmware path (if any)
  * @edl: emergency download mode firmware path (if any)
@@ -47,6 +48,7 @@
  */
 struct mhi_pci_dev_info {
 	const struct mhi_controller_config *config;
+	const struct mhi_controller_config *vf_config;
 	const char *name;
 	const char *fw;
 	const char *edl;
@@ -1242,9 +1244,14 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		return -ENOMEM;
 
 	INIT_WORK(&mhi_pdev->recovery_work, mhi_pci_recovery_work);
+
+	if (pdev->is_virtfn && info->vf_config)
+		mhi_cntrl_config = info->vf_config;
+	else
+		mhi_cntrl_config = info->config;
+
 	timer_setup(&mhi_pdev->health_check_timer, health_check, 0);
 
-	mhi_cntrl_config = info->config;
 	mhi_cntrl = &mhi_pdev->mhi_cntrl;
 
 	mhi_cntrl->cntrl_dev = &pdev->dev;

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/5] bus: mhi: host: pci_generic: Read SUBSYSTEM_VENDOR_ID for VF's to check status
  2025-07-03 15:09 [PATCH 0/5] bus: mhi: host: Enable SRIOV support in MHI driver Vivek.Pernamitta
  2025-07-03 15:09 ` [PATCH 1/5] bus: mhi: host: pci_generic: Add SRIOV support for PCIe device Vivek.Pernamitta
  2025-07-03 15:09 ` [PATCH 2/5] bus: mhi: host: Add support for separate controller configurations for VF and PF Vivek.Pernamitta
@ 2025-07-03 15:09 ` Vivek.Pernamitta
  2025-07-09 12:39   ` Krishna Chaitanya Chundru
  2025-07-03 15:09 ` [PATCH 4/5] bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery Vivek.Pernamitta
  2025-07-03 15:09 ` [PATCH 5/5] bus: host: mhi: Need to honor sys_err at power_up state Vivek.Pernamitta
  4 siblings, 1 reply; 13+ messages in thread
From: Vivek.Pernamitta @ 2025-07-03 15:09 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta

From: Vivek Pernamitta <quic_vpernami@quicinc.com>

In SRIOV enabled devices, the VF DEVICE/VENDOR ID register returns FFFFh
when read (PCIe SRIOV spec-3.4.1.1). Therefore, read the PCIe
SUBSYSTEM_VENDOR_ID to check if the device is active.

Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
---
 drivers/bus/mhi/host/pci_generic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
index 22de02c26ceb946fb618d962ac8882d2db1be6b4..938f37d306a18b9a47f302df85697f837c225f0d 100644
--- a/drivers/bus/mhi/host/pci_generic.c
+++ b/drivers/bus/mhi/host/pci_generic.c
@@ -1025,8 +1025,10 @@ static bool mhi_pci_is_alive(struct mhi_controller *mhi_cntrl)
 	struct pci_dev *pdev = to_pci_dev(mhi_cntrl->cntrl_dev);
 	u16 vendor = 0;
 
-	if (pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor))
-		return false;
+	if (pdev->is_virtfn)
+		pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &vendor);
+	else
+		pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor);
 
 	if (vendor == (u16) ~0 || vendor == 0)
 		return false;

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/5] bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery
  2025-07-03 15:09 [PATCH 0/5] bus: mhi: host: Enable SRIOV support in MHI driver Vivek.Pernamitta
                   ` (2 preceding siblings ...)
  2025-07-03 15:09 ` [PATCH 3/5] bus: mhi: host: pci_generic: Read SUBSYSTEM_VENDOR_ID for VF's to check status Vivek.Pernamitta
@ 2025-07-03 15:09 ` Vivek.Pernamitta
  2025-07-04  9:15   ` kernel test robot
  2025-07-09 12:45   ` Krishna Chaitanya Chundru
  2025-07-03 15:09 ` [PATCH 5/5] bus: host: mhi: Need to honor sys_err at power_up state Vivek.Pernamitta
  4 siblings, 2 replies; 13+ messages in thread
From: Vivek.Pernamitta @ 2025-07-03 15:09 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta

From: Vivek Pernamitta <quic_vpernami@quicinc.com>

When the MHI driver is removed from the host side, it is crucial to ensure
graceful recovery of the device. To achieve this, the host driver will
perform the following steps:

1. Disable SRIOV for any SRIOV-enabled devices on the Physical Function.
2. Perform a SOC_RESET on Physical Function (PF).

Disabling SRIOV ensures that all virtual functions are properly shut down,
preventing any potential issues during the reset process. Performing
SOC_RESET on each physical function guarantees that the device is fully
reset and ready for subsequent operations.

Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
---
 drivers/bus/mhi/host/pci_generic.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
index 938f37d306a18b9a47f302df85697f837c225f0d..ff9263d5dc4b54956c6ca4403e7b0b2429d0700e 100644
--- a/drivers/bus/mhi/host/pci_generic.c
+++ b/drivers/bus/mhi/host/pci_generic.c
@@ -45,6 +45,8 @@
  * @sideband_wake: Devices using dedicated sideband GPIO for wakeup instead
  *		   of inband wake support (such as sdx24)
  * @no_m3: M3 not supported
+ * @bool reset_on_driver_unbind: Set true for devices support SOC reset and
+ *				 perform it when unbinding driver
  */
 struct mhi_pci_dev_info {
 	const struct mhi_controller_config *config;
@@ -58,6 +60,7 @@ struct mhi_pci_dev_info {
 	unsigned int mru_default;
 	bool sideband_wake;
 	bool no_m3;
+	bool reset_on_driver_unbind;
 };
 
 #define MHI_CHANNEL_CONFIG_UL(ch_num, ch_name, el_count, ev_ring) \
@@ -300,6 +303,7 @@ static const struct mhi_pci_dev_info mhi_qcom_qdu100_info = {
 	.dma_data_width = 32,
 	.sideband_wake = false,
 	.no_m3 = true,
+	.reset_on_driver_unbind = true,
 };
 
 static const struct mhi_channel_config mhi_qcom_sa8775p_channels[] = {
@@ -970,6 +974,7 @@ struct mhi_pci_device {
 	struct work_struct recovery_work;
 	struct timer_list health_check_timer;
 	unsigned long status;
+	bool reset_on_driver_unbind;
 };
 
 static int mhi_pci_read_reg(struct mhi_controller *mhi_cntrl,
@@ -1270,6 +1275,11 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	mhi_cntrl->mru = info->mru_default;
 	mhi_cntrl->name = info->name;
 
+	/* Assign reset functionalities only for PF */
+	if (pdev->is_physfn)
+		mhi_pdev->reset_on_driver_unbind = info->reset_on_driver_unbind;
+
+
 	if (info->edl_trigger)
 		mhi_cntrl->edl_trigger = mhi_pci_generic_edl_trigger;
 
@@ -1336,7 +1346,7 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	return err;
 }
 
-static void mhi_pci_remove(struct pci_dev *pdev)
+static void mhi_pci_resource_deinit(struct pci_dev *pdev)
 {
 	struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
 	struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
@@ -1352,13 +1362,32 @@ static void mhi_pci_remove(struct pci_dev *pdev)
 	/* balancing probe put_noidle */
 	if (pci_pme_capable(pdev, PCI_D3hot))
 		pm_runtime_get_noresume(&pdev->dev);
+}
 
+static void mhi_pci_remove(struct pci_dev *pdev)
+{
+	struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
+	struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
+
+	/* Disable SRIOV */
+	pci_disable_sriov(pdev);
+	mhi_pci_resource_deinit(pdev);
+	if (mhi_pdev->reset_on_driver_unbind) {
+		dev_info(&pdev->dev, "perform SOC reset\n");
+		mhi_soc_reset(mhi_cntrl);
+	}
+
+	/* Perform FLR if supported*/
 	mhi_unregister_controller(mhi_cntrl);
 }
 
 static void mhi_pci_shutdown(struct pci_dev *pdev)
 {
-	mhi_pci_remove(pdev);
+	struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
+	struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
+
+	mhi_pci_resource_deinit(pdev);
+	mhi_unregister_controller(mhi_cntrl);
 	pci_set_power_state(pdev, PCI_D3hot);
 }
 

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/5] bus: host: mhi: Need to honor sys_err at power_up state
  2025-07-03 15:09 [PATCH 0/5] bus: mhi: host: Enable SRIOV support in MHI driver Vivek.Pernamitta
                   ` (3 preceding siblings ...)
  2025-07-03 15:09 ` [PATCH 4/5] bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery Vivek.Pernamitta
@ 2025-07-03 15:09 ` Vivek.Pernamitta
  2025-07-09 12:50   ` Krishna Chaitanya Chundru
  4 siblings, 1 reply; 13+ messages in thread
From: Vivek.Pernamitta @ 2025-07-03 15:09 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta

From: Vivek Pernamitta <quic_vpernami@quicinc.com>

In mhi_sync_power_up() host waits for device to enter in to mission mode
but SYS_ERR is an valid state, If device sends an SYS_ERR host will bail
out for wait_event_timeout() as MHI is in error state and calls
mhi_power_down which will teardown MHI driver probe.

If there is any SYS_ERR, sys_err handler needs to process SYS_ERR state
and queues the next state transition for device to bring in to Mission
mode, so mhi_sync_power_up() will wait for device to enter in to
mission mode.

Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
---
 drivers/bus/mhi/host/internal.h | 2 ++
 drivers/bus/mhi/host/pm.c       | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/internal.h
index 1054e67bb450d2634771d092ed42bbdd63380472..00e46176654d8dc2f28b1535d9ef68233266ff3b 100644
--- a/drivers/bus/mhi/host/internal.h
+++ b/drivers/bus/mhi/host/internal.h
@@ -170,6 +170,8 @@ enum mhi_pm_state {
 							MHI_PM_IN_ERROR_STATE(pm_state))
 #define MHI_PM_IN_SUSPEND_STATE(pm_state)		(pm_state & \
 							(MHI_PM_M3_ENTER | MHI_PM_M3))
+#define MHI_PM_IN_BAD_STATE(pm_state)			((pm_state == MHI_PM_FW_DL_ERR) || \
+							(pm_state >= MHI_PM_SYS_ERR_FAIL))
 
 #define NR_OF_CMD_RINGS					1
 #define CMD_EL_PER_RING					128
diff --git a/drivers/bus/mhi/host/pm.c b/drivers/bus/mhi/host/pm.c
index 2af34980e14250cada75c981b690bc9581715212..ee50efc57cf713a7cf38a670cb49ab09a83b30ee 100644
--- a/drivers/bus/mhi/host/pm.c
+++ b/drivers/bus/mhi/host/pm.c
@@ -1280,7 +1280,7 @@ int mhi_sync_power_up(struct mhi_controller *mhi_cntrl)
 		mhi_cntrl->ready_timeout_ms : mhi_cntrl->timeout_ms;
 	wait_event_timeout(mhi_cntrl->state_event,
 			   MHI_IN_MISSION_MODE(mhi_cntrl->ee) ||
-			   MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state),
+			   MHI_PM_IN_BAD_STATE(mhi_cntrl->pm_state),
 			   msecs_to_jiffies(timeout_ms));
 
 	ret = (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) ? 0 : -ETIMEDOUT;

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/5] bus: mhi: host: pci_generic: Add SRIOV support for PCIe device
  2025-07-03 15:09 ` [PATCH 1/5] bus: mhi: host: pci_generic: Add SRIOV support for PCIe device Vivek.Pernamitta
@ 2025-07-03 15:32   ` Konrad Dybcio
  2025-07-09 12:35   ` Krishna Chaitanya Chundru
  1 sibling, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2025-07-03 15:32 UTC (permalink / raw)
  To: Vivek.Pernamitta, Manivannan Sadhasivam
  Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta



On 03-Jul-25 17:09, Vivek.Pernamitta@quicinc.com wrote:
> From: Vivek Pernamitta <quic_vpernami@quicinc.com>
> 
> Add SRIOV support for PCIe devices.
> 
> Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
> ---
>  drivers/bus/mhi/host/pci_generic.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
> index 5c01c23d0bcfedd23f975e99845d5fa88940ccde..3e6e2d38935927cf3352c039266cae7cadb4c118 100644
> --- a/drivers/bus/mhi/host/pci_generic.c
> +++ b/drivers/bus/mhi/host/pci_generic.c
> @@ -1607,7 +1607,8 @@ static struct pci_driver mhi_pci_driver = {
>  	.remove		= mhi_pci_remove,
>  	.shutdown	= mhi_pci_shutdown,
>  	.err_handler	= &mhi_pci_err_handler,
> -	.driver.pm	= &mhi_pci_pm_ops
> +	.driver.pm	= &mhi_pci_pm_ops,
> +	.sriov_configure = pci_sriov_configure_simple

If I read things correctly, patches 2-4 are strictly necessary
for the device to work under SR-IOV, so this patch should come
*after* all of these fixes

Konrad

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/5] bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery
  2025-07-03 15:09 ` [PATCH 4/5] bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery Vivek.Pernamitta
@ 2025-07-04  9:15   ` kernel test robot
  2025-07-09 12:45   ` Krishna Chaitanya Chundru
  1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2025-07-04  9:15 UTC (permalink / raw)
  To: Vivek.Pernamitta, Manivannan Sadhasivam
  Cc: oe-kbuild-all, mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 1343433ed38923a21425c602e92120a1f1db5f7a]

url:    https://github.com/intel-lab-lkp/linux/commits/Vivek-Pernamitta-quicinc-com/bus-mhi-host-pci_generic-Add-SRIOV-support-for-PCIe-device/20250703-231724
base:   1343433ed38923a21425c602e92120a1f1db5f7a
patch link:    https://lore.kernel.org/r/20250703-sriov_vdev_next-20250630-v1-4-87071d1047e3%40quicinc.com
patch subject: [PATCH 4/5] bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery
config: i386-buildonly-randconfig-001-20250704 (https://download.01.org/0day-ci/archive/20250704/202507041755.evB3U2Ju-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250704/202507041755.evB3U2Ju-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507041755.evB3U2Ju-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> Warning: drivers/bus/mhi/host/pci_generic.c:63 struct member 'reset_on_driver_unbind' not described in 'mhi_pci_dev_info'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/5] bus: mhi: host: pci_generic: Add SRIOV support for PCIe device
  2025-07-03 15:09 ` [PATCH 1/5] bus: mhi: host: pci_generic: Add SRIOV support for PCIe device Vivek.Pernamitta
  2025-07-03 15:32   ` Konrad Dybcio
@ 2025-07-09 12:35   ` Krishna Chaitanya Chundru
  1 sibling, 0 replies; 13+ messages in thread
From: Krishna Chaitanya Chundru @ 2025-07-09 12:35 UTC (permalink / raw)
  To: Vivek.Pernamitta, Manivannan Sadhasivam
  Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta



On 7/3/2025 8:39 PM, Vivek.Pernamitta@quicinc.com wrote:
> From: Vivek Pernamitta <quic_vpernami@quicinc.com>
> 
> Add SRIOV support for PCIe devices.
> 
May be better to explain about why adding sriov_configure
helps to enable SRIOV in the commit text.

With that fixed,

Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>

- Krishna Chaitanya.
> Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
> ---
>   drivers/bus/mhi/host/pci_generic.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
> index 5c01c23d0bcfedd23f975e99845d5fa88940ccde..3e6e2d38935927cf3352c039266cae7cadb4c118 100644
> --- a/drivers/bus/mhi/host/pci_generic.c
> +++ b/drivers/bus/mhi/host/pci_generic.c
> @@ -1607,7 +1607,8 @@ static struct pci_driver mhi_pci_driver = {
>   	.remove		= mhi_pci_remove,
>   	.shutdown	= mhi_pci_shutdown,
>   	.err_handler	= &mhi_pci_err_handler,
> -	.driver.pm	= &mhi_pci_pm_ops
> +	.driver.pm	= &mhi_pci_pm_ops,
> +	.sriov_configure = pci_sriov_configure_simple
>   };
>   module_pci_driver(mhi_pci_driver);
>   
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/5] bus: mhi: host: Add support for separate controller configurations for VF and PF
  2025-07-03 15:09 ` [PATCH 2/5] bus: mhi: host: Add support for separate controller configurations for VF and PF Vivek.Pernamitta
@ 2025-07-09 12:38   ` Krishna Chaitanya Chundru
  0 siblings, 0 replies; 13+ messages in thread
From: Krishna Chaitanya Chundru @ 2025-07-09 12:38 UTC (permalink / raw)
  To: Vivek.Pernamitta, Manivannan Sadhasivam
  Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta



On 7/3/2025 8:39 PM, Vivek.Pernamitta@quicinc.com wrote:
> From: Vivek Pernamitta <quic_vpernami@quicinc.com>
> 
> Implement support for separate controller configurations for both
> Virtual Functions (VF) and Physical Functions (PF).
> 
> This enhancement allows for more flexible and efficient management of
> resources. The PF takes on a supervisory role and will have bootup
> information such as SAHARA, DIAG, and NDB (for file system sync data,
> etc.). VFs can handle function-specific data transfers, such as data plane
> or hardware data.
Better cite the spec which points PF takes supervisory role.

With that added.

Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>

- Krishna Chaitanya
> 
> Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
> ---
>   drivers/bus/mhi/host/pci_generic.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
> index 3e6e2d38935927cf3352c039266cae7cadb4c118..22de02c26ceb946fb618d962ac8882d2db1be6b4 100644
> --- a/drivers/bus/mhi/host/pci_generic.c
> +++ b/drivers/bus/mhi/host/pci_generic.c
> @@ -34,6 +34,7 @@
>   /**
>    * struct mhi_pci_dev_info - MHI PCI device specific information
>    * @config: MHI controller configuration
> + * @vf_config: MHI controller configuration for Virtual function (optional)
>    * @name: name of the PCI module
>    * @fw: firmware path (if any)
>    * @edl: emergency download mode firmware path (if any)
> @@ -47,6 +48,7 @@
>    */
>   struct mhi_pci_dev_info {
>   	const struct mhi_controller_config *config;
> +	const struct mhi_controller_config *vf_config;
>   	const char *name;
>   	const char *fw;
>   	const char *edl;
> @@ -1242,9 +1244,14 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   		return -ENOMEM;
>   
>   	INIT_WORK(&mhi_pdev->recovery_work, mhi_pci_recovery_work);
> +
> +	if (pdev->is_virtfn && info->vf_config)
> +		mhi_cntrl_config = info->vf_config;
> +	else
> +		mhi_cntrl_config = info->config;
> +
>   	timer_setup(&mhi_pdev->health_check_timer, health_check, 0);
>   
> -	mhi_cntrl_config = info->config;
>   	mhi_cntrl = &mhi_pdev->mhi_cntrl;
>   
>   	mhi_cntrl->cntrl_dev = &pdev->dev;
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/5] bus: mhi: host: pci_generic: Read SUBSYSTEM_VENDOR_ID for VF's to check status
  2025-07-03 15:09 ` [PATCH 3/5] bus: mhi: host: pci_generic: Read SUBSYSTEM_VENDOR_ID for VF's to check status Vivek.Pernamitta
@ 2025-07-09 12:39   ` Krishna Chaitanya Chundru
  0 siblings, 0 replies; 13+ messages in thread
From: Krishna Chaitanya Chundru @ 2025-07-09 12:39 UTC (permalink / raw)
  To: Vivek.Pernamitta, Manivannan Sadhasivam
  Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta



On 7/3/2025 8:39 PM, Vivek.Pernamitta@quicinc.com wrote:
> From: Vivek Pernamitta <quic_vpernami@quicinc.com>
> 
> In SRIOV enabled devices, the VF DEVICE/VENDOR ID register returns FFFFh
> when read (PCIe SRIOV spec-3.4.1.1). Therefore, read the PCIe
> SUBSYSTEM_VENDOR_ID to check if the device is active.
> 
Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>

- Krishna Chaitanya.
> Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
> ---
>   drivers/bus/mhi/host/pci_generic.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
> index 22de02c26ceb946fb618d962ac8882d2db1be6b4..938f37d306a18b9a47f302df85697f837c225f0d 100644
> --- a/drivers/bus/mhi/host/pci_generic.c
> +++ b/drivers/bus/mhi/host/pci_generic.c
> @@ -1025,8 +1025,10 @@ static bool mhi_pci_is_alive(struct mhi_controller *mhi_cntrl)
>   	struct pci_dev *pdev = to_pci_dev(mhi_cntrl->cntrl_dev);
>   	u16 vendor = 0;
>   
> -	if (pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor))
> -		return false;
> +	if (pdev->is_virtfn)
> +		pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &vendor);
> +	else
> +		pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor);
>   
>   	if (vendor == (u16) ~0 || vendor == 0)
>   		return false;
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/5] bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery
  2025-07-03 15:09 ` [PATCH 4/5] bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery Vivek.Pernamitta
  2025-07-04  9:15   ` kernel test robot
@ 2025-07-09 12:45   ` Krishna Chaitanya Chundru
  1 sibling, 0 replies; 13+ messages in thread
From: Krishna Chaitanya Chundru @ 2025-07-09 12:45 UTC (permalink / raw)
  To: Vivek.Pernamitta, Manivannan Sadhasivam
  Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta



On 7/3/2025 8:39 PM, Vivek.Pernamitta@quicinc.com wrote:
> From: Vivek Pernamitta <quic_vpernami@quicinc.com>
> 
> When the MHI driver is removed from the host side, it is crucial to ensure
> graceful recovery of the device. To achieve this, the host driver will
> perform the following steps:
> 
> 1. Disable SRIOV for any SRIOV-enabled devices on the Physical Function.
> 2. Perform a SOC_RESET on Physical Function (PF).
> 
> Disabling SRIOV ensures that all virtual functions are properly shut down,
> preventing any potential issues during the reset process. Performing
> SOC_RESET on each physical function guarantees that the device is fully
> reset and ready for subsequent operations.
> 
> Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
> ---
>   drivers/bus/mhi/host/pci_generic.c | 33 +++++++++++++++++++++++++++++++--
>   1 file changed, 31 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
> index 938f37d306a18b9a47f302df85697f837c225f0d..ff9263d5dc4b54956c6ca4403e7b0b2429d0700e 100644
> --- a/drivers/bus/mhi/host/pci_generic.c
> +++ b/drivers/bus/mhi/host/pci_generic.c
> @@ -45,6 +45,8 @@
>    * @sideband_wake: Devices using dedicated sideband GPIO for wakeup instead
>    *		   of inband wake support (such as sdx24)
>    * @no_m3: M3 not supported
> + * @bool reset_on_driver_unbind: Set true for devices support SOC reset and
> + *				 perform it when unbinding driver
>    */
>   struct mhi_pci_dev_info {
>   	const struct mhi_controller_config *config;
> @@ -58,6 +60,7 @@ struct mhi_pci_dev_info {
>   	unsigned int mru_default;
>   	bool sideband_wake;
>   	bool no_m3;
> +	bool reset_on_driver_unbind;
>   };
>   
>   #define MHI_CHANNEL_CONFIG_UL(ch_num, ch_name, el_count, ev_ring) \
> @@ -300,6 +303,7 @@ static const struct mhi_pci_dev_info mhi_qcom_qdu100_info = {
>   	.dma_data_width = 32,
>   	.sideband_wake = false,
>   	.no_m3 = true,
> +	.reset_on_driver_unbind = true,
>   };
>   
>   static const struct mhi_channel_config mhi_qcom_sa8775p_channels[] = {
> @@ -970,6 +974,7 @@ struct mhi_pci_device {
>   	struct work_struct recovery_work;
>   	struct timer_list health_check_timer;
>   	unsigned long status;
> +	bool reset_on_driver_unbind;
>   };
>   
>   static int mhi_pci_read_reg(struct mhi_controller *mhi_cntrl,
> @@ -1270,6 +1275,11 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   	mhi_cntrl->mru = info->mru_default;
>   	mhi_cntrl->name = info->name;
>   
> +	/* Assign reset functionalities only for PF */
> +	if (pdev->is_physfn)
> +		mhi_pdev->reset_on_driver_unbind = info->reset_on_driver_unbind;
> +
> +
>   	if (info->edl_trigger)
>   		mhi_cntrl->edl_trigger = mhi_pci_generic_edl_trigger;
>   
> @@ -1336,7 +1346,7 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   	return err;
>   }
>   
> -static void mhi_pci_remove(struct pci_dev *pdev)
> +static void mhi_pci_resource_deinit(struct pci_dev *pdev)
>   {
>   	struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
>   	struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
> @@ -1352,13 +1362,32 @@ static void mhi_pci_remove(struct pci_dev *pdev)
>   	/* balancing probe put_noidle */
>   	if (pci_pme_capable(pdev, PCI_D3hot))
>   		pm_runtime_get_noresume(&pdev->dev);
> +}
>   
> +static void mhi_pci_remove(struct pci_dev *pdev)
> +{
> +	struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
> +	struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
> +
> +	/* Disable SRIOV */
> +	pci_disable_sriov(pdev);
> +	mhi_pci_resource_deinit(pdev);
> +	if (mhi_pdev->reset_on_driver_unbind) {
> +		dev_info(&pdev->dev, "perform SOC reset\n");
> +		mhi_soc_reset(mhi_cntrl);
> +	}
> +
> +	/* Perform FLR if supported*/
Misleading comment.
>   	mhi_unregister_controller(mhi_cntrl);
>   }
>   
>   static void mhi_pci_shutdown(struct pci_dev *pdev)
>   {
> -	mhi_pci_remove(pdev);
why can't we use this same as mhi_pci_remove.

- Krishna Chaitanya.
> +	struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
> +	struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
> +
> +	mhi_pci_resource_deinit(pdev);
> +	mhi_unregister_controller(mhi_cntrl);
>   	pci_set_power_state(pdev, PCI_D3hot);
>   }
>   
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/5] bus: host: mhi: Need to honor sys_err at power_up state
  2025-07-03 15:09 ` [PATCH 5/5] bus: host: mhi: Need to honor sys_err at power_up state Vivek.Pernamitta
@ 2025-07-09 12:50   ` Krishna Chaitanya Chundru
  0 siblings, 0 replies; 13+ messages in thread
From: Krishna Chaitanya Chundru @ 2025-07-09 12:50 UTC (permalink / raw)
  To: Vivek.Pernamitta, Manivannan Sadhasivam
  Cc: mhi, linux-arm-msm, linux-kernel, Vivek Pernamitta



On 7/3/2025 8:39 PM, Vivek.Pernamitta@quicinc.com wrote:
> From: Vivek Pernamitta <quic_vpernami@quicinc.com>
> 
> In mhi_sync_power_up() host waits for device to enter in to mission mode
> but SYS_ERR is an valid state, If device sends an SYS_ERR host will bail
> out for wait_event_timeout() as MHI is in error state and calls
> mhi_power_down which will teardown MHI driver probe.
Add "if MHI is tear downed sys err can't be serviced and mhi can't
be recovered".
> 
> If there is any SYS_ERR, sys_err handler needs to process SYS_ERR state
> and queues the next state transition for device to bring in to Mission
> mode, so mhi_sync_power_up() will wait for device to enter in to
s/will wait for/needs to wait for
> mission mode.
> 
> Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com>
> ---
>   drivers/bus/mhi/host/internal.h | 2 ++
>   drivers/bus/mhi/host/pm.c       | 2 +-
>   2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/internal.h
> index 1054e67bb450d2634771d092ed42bbdd63380472..00e46176654d8dc2f28b1535d9ef68233266ff3b 100644
> --- a/drivers/bus/mhi/host/internal.h
> +++ b/drivers/bus/mhi/host/internal.h
> @@ -170,6 +170,8 @@ enum mhi_pm_state {
>   							MHI_PM_IN_ERROR_STATE(pm_state))
>   #define MHI_PM_IN_SUSPEND_STATE(pm_state)		(pm_state & \
>   							(MHI_PM_M3_ENTER | MHI_PM_M3))
> +#define MHI_PM_IN_BAD_STATE(pm_state)			((pm_state == MHI_PM_FW_DL_ERR) || \
> +							(pm_state >= MHI_PM_SYS_ERR_FAIL))
MHI_PM_IN_UNRECOVERABLE_ERROR ?

- Krishna Chaitanya.
>   
>   #define NR_OF_CMD_RINGS					1
>   #define CMD_EL_PER_RING					128
> diff --git a/drivers/bus/mhi/host/pm.c b/drivers/bus/mhi/host/pm.c
> index 2af34980e14250cada75c981b690bc9581715212..ee50efc57cf713a7cf38a670cb49ab09a83b30ee 100644
> --- a/drivers/bus/mhi/host/pm.c
> +++ b/drivers/bus/mhi/host/pm.c
> @@ -1280,7 +1280,7 @@ int mhi_sync_power_up(struct mhi_controller *mhi_cntrl)
>   		mhi_cntrl->ready_timeout_ms : mhi_cntrl->timeout_ms;
>   	wait_event_timeout(mhi_cntrl->state_event,
>   			   MHI_IN_MISSION_MODE(mhi_cntrl->ee) ||
> -			   MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state),
> +			   MHI_PM_IN_BAD_STATE(mhi_cntrl->pm_state),
>   			   msecs_to_jiffies(timeout_ms));
>   
>   	ret = (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) ? 0 : -ETIMEDOUT;
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-07-09 12:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03 15:09 [PATCH 0/5] bus: mhi: host: Enable SRIOV support in MHI driver Vivek.Pernamitta
2025-07-03 15:09 ` [PATCH 1/5] bus: mhi: host: pci_generic: Add SRIOV support for PCIe device Vivek.Pernamitta
2025-07-03 15:32   ` Konrad Dybcio
2025-07-09 12:35   ` Krishna Chaitanya Chundru
2025-07-03 15:09 ` [PATCH 2/5] bus: mhi: host: Add support for separate controller configurations for VF and PF Vivek.Pernamitta
2025-07-09 12:38   ` Krishna Chaitanya Chundru
2025-07-03 15:09 ` [PATCH 3/5] bus: mhi: host: pci_generic: Read SUBSYSTEM_VENDOR_ID for VF's to check status Vivek.Pernamitta
2025-07-09 12:39   ` Krishna Chaitanya Chundru
2025-07-03 15:09 ` [PATCH 4/5] bus: mhi: host: pci_generic: Remove MHI driver and ensure graceful device recovery Vivek.Pernamitta
2025-07-04  9:15   ` kernel test robot
2025-07-09 12:45   ` Krishna Chaitanya Chundru
2025-07-03 15:09 ` [PATCH 5/5] bus: host: mhi: Need to honor sys_err at power_up state Vivek.Pernamitta
2025-07-09 12:50   ` Krishna Chaitanya Chundru

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).