Skip to content

Commit 12543f4

Browse files
Vivek PernamittaManivannan Sadhasivam
authored andcommitted
bus: mhi: host: pci_generic: Reset QDU100 while the MHI driver is removed
So, When the MHI driver is removed from the host side, it is essential to ensure a clean and stable recovery of the device. This commit introduces the following steps to achieve that: 1. Disable SR-IOV for any SR-IOV-enabled devices on the Physical Function. 2. Perform a SOC_RESET on the PF to fully reset the device. Disabling SR-IOV ensures all Virtual Functions (VFs) are properly shutdown, preventing issues during the reset process. The SOC_RESET guarantees that the PF is restored to a known good state. If soc_reset is not performed device at driver remove, device will be stuck in mission mode state and subsequent driver insert/power_up will not proceed further. Signed-off-by: Vivek Pernamitta <[email protected]> [mani: reworded subject] Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent fd6e050 commit 12543f4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/bus/mhi/host/pci_generic.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* @sideband_wake: Devices using dedicated sideband GPIO for wakeup instead
4646
* of inband wake support (such as sdx24)
4747
* @no_m3: M3 not supported
48+
* @reset_on_remove: Set true for devices that require SoC during driver removal
4849
*/
4950
struct mhi_pci_dev_info {
5051
const struct mhi_controller_config *config;
@@ -58,6 +59,7 @@ struct mhi_pci_dev_info {
5859
unsigned int mru_default;
5960
bool sideband_wake;
6061
bool no_m3;
62+
bool reset_on_remove;
6163
};
6264

6365
#define MHI_CHANNEL_CONFIG_UL(ch_num, ch_name, el_count, ev_ring) \
@@ -300,6 +302,7 @@ static const struct mhi_pci_dev_info mhi_qcom_qdu100_info = {
300302
.dma_data_width = 32,
301303
.sideband_wake = false,
302304
.no_m3 = true,
305+
.reset_on_remove = true,
303306
};
304307

305308
static const struct mhi_channel_config mhi_qcom_sa8775p_channels[] = {
@@ -1027,6 +1030,7 @@ struct mhi_pci_device {
10271030
struct work_struct recovery_work;
10281031
struct timer_list health_check_timer;
10291032
unsigned long status;
1033+
bool reset_on_remove;
10301034
};
10311035

10321036
static int mhi_pci_read_reg(struct mhi_controller *mhi_cntrl,
@@ -1332,6 +1336,9 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
13321336
mhi_cntrl->mru = info->mru_default;
13331337
mhi_cntrl->name = info->name;
13341338

1339+
if (pdev->is_physfn)
1340+
mhi_pdev->reset_on_remove = info->reset_on_remove;
1341+
13351342
if (info->edl_trigger)
13361343
mhi_cntrl->edl_trigger = mhi_pci_generic_edl_trigger;
13371344

@@ -1404,6 +1411,8 @@ static void mhi_pci_remove(struct pci_dev *pdev)
14041411
struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
14051412
struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
14061413

1414+
pci_disable_sriov(pdev);
1415+
14071416
if (pdev->is_physfn)
14081417
timer_delete_sync(&mhi_pdev->health_check_timer);
14091418
cancel_work_sync(&mhi_pdev->recovery_work);
@@ -1417,6 +1426,9 @@ static void mhi_pci_remove(struct pci_dev *pdev)
14171426
if (pci_pme_capable(pdev, PCI_D3hot))
14181427
pm_runtime_get_noresume(&pdev->dev);
14191428

1429+
if (mhi_pdev->reset_on_remove)
1430+
mhi_soc_reset(mhi_cntrl);
1431+
14201432
mhi_unregister_controller(mhi_cntrl);
14211433
}
14221434

0 commit comments

Comments
 (0)