From: Alex Williamson <alex.williamson@redhat.com>
To: Emily Deng <Emily.Deng@amd.com>
Cc: <bhelgaas@google.com>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>,
<Jerry.Jiang@amd.com>, <Andy.Zhang@amd.com>,
<HaiJun.Chang@amd.com>, <Monk.Liu@amd.com>, <Horace.Chen@amd.com>,
<ZhenGuo.Yin@amd.com>
Subject: Re: [PATCH 1/2] PCI: Add VF reset notification to PF's VFIO user mode driver
Date: Mon, 5 Feb 2024 09:43:30 -0700 [thread overview]
Message-ID: <20240205094330.59ca4c0a.alex.williamson@redhat.com> (raw)
In-Reply-To: <20240205071538.2665628-1-Emily.Deng@amd.com>
On Mon, 5 Feb 2024 15:15:37 +0800
Emily Deng <Emily.Deng@amd.com> wrote:
> 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.
The solution that already exists for this sort of issue is a vfio-pci
variant driver for the VF which communicates with an in-kernel PF
driver to coordinate the VF FLR with the PF driver. This can be done
by intercepting the userspace access to the VF FLR config space region.
This solution of involving PCI-core and extending the vfio-pci interface
only exists for userspace PF drivers. I don't see that facilitating
vendors to implement their PF drivers in userspace to avoid upstreaming
is a compelling reason to extend the vfio-pci interface. Thanks,
Alex
> Signed-off-by: Emily Deng <Emily.Deng@amd.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;
next prev parent reply other threads:[~2024-02-05 16:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-05 7:15 Emily Deng
2024-02-05 7:15 ` [PATCH 2/2] VFIO/PCI: " Emily Deng
2024-02-05 9:04 ` [PATCH 1/2] PCI: " Leon Romanovsky
[not found] ` <BL1PR12MB526972B4E7CF6B2C993A2E6984462@BL1PR12MB5269.namprd12.prod.outlook.com>
2024-02-06 20:06 ` Alex Williamson
2024-02-05 16:43 ` Alex Williamson [this message]
[not found] ` <BL1PR12MB52695A24DBFFDB9809444D2284462@BL1PR12MB5269.namprd12.prod.outlook.com>
2024-02-06 19:38 ` Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240205094330.59ca4c0a.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=Andy.Zhang@amd.com \
--cc=Emily.Deng@amd.com \
--cc=HaiJun.Chang@amd.com \
--cc=Horace.Chen@amd.com \
--cc=Jerry.Jiang@amd.com \
--cc=Monk.Liu@amd.com \
--cc=ZhenGuo.Yin@amd.com \
--cc=bhelgaas@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®