[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240205071538.2665628-1-Emily.Deng@amd.com>
Date: Mon, 5 Feb 2024 15:15:37 +0800
From: Emily Deng <Emily.Deng@....com>
To: <bhelgaas@...gle.com>, <alex.williamson@...hat.com>,
<linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<kvm@...r.kernel.org>
CC: <Jerry.Jiang@....com>, <Andy.Zhang@....com>, <HaiJun.Chang@....com>,
<Monk.Liu@....com>, <Horace.Chen@....com>, <ZhenGuo.Yin@....com>, Emily Deng
<Emily.Deng@....com>
Subject: [PATCH 1/2] PCI: Add VF reset notification to PF's VFIO user mode driver
VF doesn't have the ability to reset itself completely which will cause the
hardware in unstable state. So notify PF driver when the VF has been reset
to let the PF resets the VF completely, and remove the VF out of schedule.
How to implement this?
Add the reset callback function in pci_driver
Implement the callback functin in VFIO_PCI driver.
Add the VF RESET IRQ for user mode driver to let the user mode driver
know the VF has been reset.
Signed-off-by: Emily Deng <Emily.Deng@....com>
---
drivers/pci/pci.c | 8 ++++++++
include/linux/pci.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 60230da957e0..aca937b05531 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4780,6 +4780,14 @@ EXPORT_SYMBOL_GPL(pcie_flr);
*/
int pcie_reset_flr(struct pci_dev *dev, bool probe)
{
+ struct pci_dev *pf_dev;
+
+ if (dev->is_virtfn) {
+ pf_dev = dev->physfn;
+ if (pf_dev->driver->sriov_vf_reset_notification)
+ pf_dev->driver->sriov_vf_reset_notification(pf_dev, dev);
+ }
+
if (dev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET)
return -ENOTTY;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c69a2cc1f412..4fa31d9b0aa7 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -926,6 +926,7 @@ struct pci_driver {
int (*sriov_configure)(struct pci_dev *dev, int num_vfs); /* On PF */
int (*sriov_set_msix_vec_count)(struct pci_dev *vf, int msix_vec_count); /* On PF */
u32 (*sriov_get_vf_total_msix)(struct pci_dev *pf);
+ void (*sriov_vf_reset_notification)(struct pci_dev *pf, struct pci_dev *vf);
const struct pci_error_handlers *err_handler;
const struct attribute_group **groups;
const struct attribute_group **dev_groups;
--
2.36.1
Powered by blists - more mailing lists