From: Bjorn Helgaas <helgaas@kernel.org>
To: Keith Busch <keith.busch@intel.com>
Cc: Linux PCI <linux-pci@vger.kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Lukas Wunner <lukas@wunner.de>
Subject: Re: [PATCH] pci/sriov: Hold rescan lock while enumerating
Date: Wed, 5 Sep 2018 15:58:40 -0500 [thread overview]
Message-ID: <20180905205840.GR107892@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <20180809163356.18650-1-keith.busch@intel.com>
[+cc Lukas, -stable]
On Thu, Aug 09, 2018 at 10:33:56AM -0600, Keith Busch wrote:
> PCI enumeration/de-enumeration needs to run single threaded to prevent
> race conditions with other threads changing the topology. Altering the
> number of virtual functions was not taking the rescan/remove lock hile
> adding or removing those virtual functions, so this patch adds that.
>
> Reported-by: Krzysztof Wierzbicki <krzysztof.wierzbicki@intel.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Keith Busch <keith.busch@intel.com>
> ---
> drivers/pci/pci-sysfs.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 9ecfe13157c0..611abe220b6f 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -591,6 +591,7 @@ static ssize_t sriov_numvfs_store(struct device *dev,
> if (num_vfs > pci_sriov_get_totalvfs(pdev))
> return -ERANGE;
>
> + pci_lock_rescan_remove();
I assume the usual path is something like this, where we end up in
pci_enable_sriov():
sriov_numvfs_store
+ pci_lock_rescan_remove
pdev->driver->sriov_configure
...
pci_enable_sriov
sriov_enable
pci_iov_add_virtfn
pci_alloc_dev
pci_device_add
But what about the other paths leading to pci_iov_add_virtfn()? Don't
we need similar locking for all of them?
> device_lock(&pdev->dev);
>
> if (num_vfs == pdev->sriov->num_VFs)
> @@ -627,6 +628,7 @@ static ssize_t sriov_numvfs_store(struct device *dev,
>
> exit:
> device_unlock(&pdev->dev);
> + pci_unlock_rescan_remove();
>
> if (ret < 0)
> return ret;
> --
> 2.14.4
>
next prev parent reply other threads:[~2018-09-06 1:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-09 16:33 [PATCH] pci/sriov: Hold rescan lock while enumerating Keith Busch
2018-08-09 17:58 ` Lukas Wunner
2018-08-09 18:05 ` Keith Busch
2018-09-05 20:58 ` Bjorn Helgaas [this message]
2018-09-05 21:12 ` Keith Busch
2018-09-05 22:13 ` Bjorn Helgaas
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=20180905205840.GR107892@bhelgaas-glaptop.roam.corp.google.com \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=keith.busch@intel.com \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
/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).