mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Emily Deng <Emily.Deng@amd.com>,
	amd-gfx@lists.freedesktop.org, bhelgaas@google.com,
	alex.williamson@redhat.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] PCI: Add vf reset notification for pf
Date: Mon, 5 Feb 2024 12:28:51 +0100	[thread overview]
Message-ID: <db589d23-6e15-4b54-845f-fb719e59949d@gmail.com> (raw)
In-Reply-To: <20240204061257.1408243-1-Emily.Deng@amd.com>

Am 04.02.24 um 07:12 schrieb Emily Deng:
> When a vf has been reset, the pf wants to get notification to remove the vf
> out of schedule.
>
> Solution:
> Add the callback function in pci_driver sriov_vf_reset_notification. When
> vf reset happens, then call this callback function.

Well that doesn't make much sense. As other already noted as well a VF 
should be an encapsulated representation of a physical devices 
functionality.

AMD implemented that a bit different with a hypervisor to control which 
PF functionality a VF exposes, but that doesn't mean that we can leak 
this AMD specific handling into the common Linux PCI subsystem.

Additional to that a technical blocker is that when a VF is passed into 
a VM you don't have access to the PF any more to make this reset 
notification.

Regards,
Christian.

>
> 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;


  parent reply	other threads:[~2024-02-05 11:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-04  6:12 Emily Deng
2024-02-04  7:08 ` Keith Busch
2024-02-04 11:20 ` Leon Romanovsky
2024-02-05  3:47   ` Deng, Emily
2024-02-05 11:28 ` Christian König [this message]
2024-02-05 12:22 ` Zhi Wang

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=db589d23-6e15-4b54-845f-fb719e59949d@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Emily.Deng@amd.com \
    --cc=alex.williamson@redhat.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --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

Powered by JetHome