From: David Vrabel <david.vrabel@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
<bhelgaas@google.com>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <xen-devel@lists.xenproject.org>,
<boris.ostrovsky@oracle.com>
Cc: Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH v5 8/9] xen-pciback: drop SR-IOV VFs when PF driver unloads
Date: Thu, 4 Dec 2014 11:07:43 +0000 [thread overview]
Message-ID: <5480407F.7070402@citrix.com> (raw)
In-Reply-To: <1417642834-20350-9-git-send-email-konrad.wilk@oracle.com>
On 03/12/14 21:40, Konrad Rzeszutek Wilk wrote:
> From: Jan Beulich <JBeulich@suse.com>
>
> When a PF driver unloads, it may find it necessary to leave the VFs
> around simply because of pciback having marked them as assigned to a
> guest. Utilize a suitable notification to let go of the VFs, thus
> allowing the PF to go back into the state it was before its driver
> loaded (which in particular allows the driver to be loaded again with
> it being able to create the VFs anew, but which also allows to then
> pass through the PF instead of the VFs).
>
> Don't do this however for any VFs currently in active use by a guest.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> [v2: Removed the switch statement, moved it about]
> [v3: Redid it a bit differently]
Jan, are you happy with Konrad's change now?
David
> --- a/drivers/xen/xen-pciback/pci_stub.c
> +++ b/drivers/xen/xen-pciback/pci_stub.c
> @@ -1518,6 +1518,53 @@ parse_error:
> fs_initcall(pcistub_init);
> #endif
>
> +#ifdef CONFIG_PCI_IOV
> +static struct pcistub_device *find_vfs(const struct pci_dev *pdev)
> +{
> + struct pcistub_device *psdev = NULL;
> + unsigned long flags;
> + bool found = false;
> +
> + spin_lock_irqsave(&pcistub_devices_lock, flags);
> + list_for_each_entry(psdev, &pcistub_devices, dev_list) {
> + if (!psdev->pdev && psdev->dev != pdev
> + && pci_physfn(psdev->dev) == pdev) {
> + found = true;
> + break;
> + }
> + }
> + spin_unlock_irqrestore(&pcistub_devices_lock, flags);
> + if (found)
> + return psdev;
> + return NULL;
> +}
> +
> +static int pci_stub_notifier(struct notifier_block *nb,
> + unsigned long action, void *data)
> +{
> + struct device *dev = data;
> + const struct pci_dev *pdev = to_pci_dev(dev);
> +
> + if (action != BUS_NOTIFY_UNBIND_DRIVER)
> + return NOTIFY_DONE;
> +
> + if (!pdev->is_physfn)
> + return NOTIFY_DONE;
> +
> + for (;;) {
> + struct pcistub_device *psdev = find_vfs(pdev);
> + if (!psdev)
> + break;
> + device_release_driver(&psdev->dev->dev);
> + }
> + return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block pci_stub_nb = {
> + .notifier_call = pci_stub_notifier,
> +};
> +#endif
> +
> static int __init xen_pcibk_init(void)
> {
> int err;
> @@ -1539,12 +1586,19 @@ static int __init xen_pcibk_init(void)
> err = xen_pcibk_xenbus_register();
> if (err)
> pcistub_exit();
> +#ifdef CONFIG_PCI_IOV
> + else
> + bus_register_notifier(&pci_bus_type, &pci_stub_nb);
> +#endif
>
> return err;
> }
>
> static void __exit xen_pcibk_cleanup(void)
> {
> +#ifdef CONFIG_PCI_IOV
> + bus_unregister_notifier(&pci_bus_type, &pci_stub_nb);
> +#endif
> xen_pcibk_xenbus_unregister();
> pcistub_exit();
> }
>
next prev parent reply other threads:[~2014-12-04 11:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-03 21:40 [PATCH v5] Fixes for PCI backend for 3.19 Konrad Rzeszutek Wilk
2014-12-03 21:40 ` [PATCH v5 1/9] xen/pciback: Don't deadlock when unbinding Konrad Rzeszutek Wilk
2014-12-03 21:40 ` [PATCH v5 2/9] driver core: Provide an wrapper around the mutex to do lockdep warnings Konrad Rzeszutek Wilk
2014-12-03 21:40 ` [PATCH v5 3/9] xen/pciback: Include the domain id if removing the device whilst still in use Konrad Rzeszutek Wilk
2014-12-03 21:40 ` [PATCH v5 4/9] xen/pciback: Print out the domain owning the device Konrad Rzeszutek Wilk
2014-12-03 21:40 ` [PATCH v5 5/9] xen/pciback: Remove tons of dereferences Konrad Rzeszutek Wilk
2014-12-03 21:40 ` [PATCH v5 6/9] PCI: Expose pci_load_saved_state for public consumption Konrad Rzeszutek Wilk
2014-12-03 23:49 ` Bjorn Helgaas
2014-12-03 21:40 ` [PATCH v5 7/9] xen/pciback: Restore configuration space when detaching from a guest Konrad Rzeszutek Wilk
2014-12-03 21:40 ` [PATCH v5 8/9] xen-pciback: drop SR-IOV VFs when PF driver unloads Konrad Rzeszutek Wilk
2014-12-04 11:07 ` David Vrabel [this message]
2014-12-04 11:36 ` Jan Beulich
2014-12-03 21:40 ` [PATCH v5 9/9] xen/pciback: Implement PCI reset slot or bus with 'do_flr' SysFS attribute Konrad Rzeszutek Wilk
2014-12-04 11:30 ` David Vrabel
2014-12-04 15:46 ` [PATCH v5] Fixes for PCI backend for 3.19 David Vrabel
2014-12-04 17:59 ` Konrad Rzeszutek Wilk
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=5480407F.7070402@citrix.com \
--to=david.vrabel@citrix.com \
--cc=JBeulich@suse.com \
--cc=bhelgaas@google.com \
--cc=boris.ostrovsky@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).