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>
Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.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 7d0ac1c34ddf95ace2a85e5f08884f51604d9b0f..4bafe93b56c54e2b091786e7fcd68a36c8247b8e 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
On Thu, Jul 10, 2025 at 02:28:33PM GMT, 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. > > Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com> > Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.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 7d0ac1c34ddf95ace2a85e5f08884f51604d9b0f..4bafe93b56c54e2b091786e7fcd68a36c8247b8e 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); You should not read the sub Vendor ID for VF. PCIe spec suggests reading the PF Vendor ID for VF. So you should just use pci_physfn() API as below: pci_read_config_word(pci_physfn(pdev), PCI_VENDOR_ID, &vendor); This will work for both PF and VF. - Mani -- மணிவண்ணன் சதாசிவம்
On 8/6/2025 10:29 PM, Manivannan Sadhasivam wrote: > On Thu, Jul 10, 2025 at 02:28:33PM GMT, 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. >> >> Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com> >> Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.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 7d0ac1c34ddf95ace2a85e5f08884f51604d9b0f..4bafe93b56c54e2b091786e7fcd68a36c8247b8e 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); > > You should not read the sub Vendor ID for VF. PCIe spec suggests reading the PF > Vendor ID for VF. So you should just use pci_physfn() API as below: > > pci_read_config_word(pci_physfn(pdev), PCI_VENDOR_ID, &vendor); > > This will work for both PF and VF. > This will defeat the purpose of having health check monitor for VF, as we are always reading PF vendor ID and will not know VF status at all. - Krishna Chaitanya. > - Mani >
On Thu, Aug 07, 2025 at 12:39:26PM GMT, Krishna Chaitanya Chundru wrote: > > > On 8/6/2025 10:29 PM, Manivannan Sadhasivam wrote: > > On Thu, Jul 10, 2025 at 02:28:33PM GMT, 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. > > > > > > Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com> > > > Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.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 7d0ac1c34ddf95ace2a85e5f08884f51604d9b0f..4bafe93b56c54e2b091786e7fcd68a36c8247b8e 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); > > > > You should not read the sub Vendor ID for VF. PCIe spec suggests reading the PF > > Vendor ID for VF. So you should just use pci_physfn() API as below: > > > > pci_read_config_word(pci_physfn(pdev), PCI_VENDOR_ID, &vendor); > > > > This will work for both PF and VF. > > > This will defeat the purpose of having health check monitor for VF, > as we are always reading PF vendor ID and will not know VF status at all. Do we really have a usecase to perform health check for VFs? Health check is supposed to happen for devices that can fail abruptly. - Mani -- மணிவண்ணன் சதாசிவம்
On 8/7/2025 1:43 PM, Manivannan Sadhasivam wrote: > On Thu, Aug 07, 2025 at 12:39:26PM GMT, Krishna Chaitanya Chundru wrote: >> >> >> On 8/6/2025 10:29 PM, Manivannan Sadhasivam wrote: >>> On Thu, Jul 10, 2025 at 02:28:33PM GMT, 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. >>>> >>>> Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com> >>>> Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.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 7d0ac1c34ddf95ace2a85e5f08884f51604d9b0f..4bafe93b56c54e2b091786e7fcd68a36c8247b8e 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); >>> >>> You should not read the sub Vendor ID for VF. PCIe spec suggests reading the PF >>> Vendor ID for VF. So you should just use pci_physfn() API as below: >>> >>> pci_read_config_word(pci_physfn(pdev), PCI_VENDOR_ID, &vendor); >>> >>> This will work for both PF and VF. >>> >> This will defeat the purpose of having health check monitor for VF, >> as we are always reading PF vendor ID and will not know VF status at all. > > Do we really have a usecase to perform health check for VFs? Health check is > supposed to happen for devices that can fail abruptly. > yeah as VF is not a physical link we can disable health check monitor for VF's in the probe itself. - Krishna Chaitanya. > - Mani >
On Thu, Aug 07, 2025 at 01:45:42PM GMT, Krishna Chaitanya Chundru wrote: > > > On 8/7/2025 1:43 PM, Manivannan Sadhasivam wrote: > > On Thu, Aug 07, 2025 at 12:39:26PM GMT, Krishna Chaitanya Chundru wrote: > > > > > > > > > On 8/6/2025 10:29 PM, Manivannan Sadhasivam wrote: > > > > On Thu, Jul 10, 2025 at 02:28:33PM GMT, 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. > > > > > > > > > > Signed-off-by: Vivek Pernamitta <quic_vpernami@quicinc.com> > > > > > Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.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 7d0ac1c34ddf95ace2a85e5f08884f51604d9b0f..4bafe93b56c54e2b091786e7fcd68a36c8247b8e 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); > > > > > > > > You should not read the sub Vendor ID for VF. PCIe spec suggests reading the PF > > > > Vendor ID for VF. So you should just use pci_physfn() API as below: > > > > > > > > pci_read_config_word(pci_physfn(pdev), PCI_VENDOR_ID, &vendor); > > > > > > > > This will work for both PF and VF. > > > > > > > This will defeat the purpose of having health check monitor for VF, > > > as we are always reading PF vendor ID and will not know VF status at all. > > > > Do we really have a usecase to perform health check for VFs? Health check is > > supposed to happen for devices that can fail abruptly. > > > yeah as VF is not a physical link we can disable health check monitor > for VF's in the probe itself. > Oh well yes. Otherwise, we will end up with 'num_vfs' number of health monitor threads eating up the CPU time for no good reason. - Mani -- மணிவண்ணன் சதாசிவம்
© 2016 - 2025 Red Hat, Inc.