From: Gerd Bayer <gbayer@linux.ibm.com>
To: Niklas Schnelle <schnelle@linux.ibm.com>,
Bjorn Helgaas <helgaas@kernel.org>
Cc: Lukas Wunner <lukas@wunner.de>, Keith Busch <kbusch@kernel.org>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Benjamin Block <bblock@linux.ibm.com>,
Halil Pasic <pasic@linux.ibm.com>,
Farhan Ali <alifm@linux.ibm.com>,
Julian Ruess <julianr@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] Revert "PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV"
Date: Wed, 10 Dec 2025 18:35:21 +0100 [thread overview]
Message-ID: <f16e3e775a5e46672351f03a00295b7c71d6b69a.camel@linux.ibm.com> (raw)
In-Reply-To: <20251119-revert_sriov_lock-v2-1-ea50eb1e8f96@linux.ibm.com>
On Wed, 2025-11-19 at 13:34 +0100, Niklas Schnelle wrote:
> This reverts commit 05703271c3cd ("PCI/IOV: Add PCI rescan-remove
> locking when enabling/disabling SR-IOV") which causes a deadlock by
> recursively taking pci_rescan_remove_lock when sriov_del_vfs() is called
> as part of pci_stop_and_remove_bus_device(). For example with the
> following sequence of commands:
>
> $ echo <NUM> > /sys/bus/pci/devices/<pf>/sriov_numvfs
> $ echo 1 > /sys/bus/pci/devices/<pf>/remove
>
> A trimmed trace of the deadlock on a mlx5 device is as below:
>
> mutex_lock_nested+0x3c/0x50
> sriov_disable+0x34/0x140
> mlx5_sriov_disable+0x50/0x80 [mlx5_core]
> remove_one+0x5e/0xf0 [mlx5_core]
> pci_device_remove+0x3c/0xa0
> device_release_driver_internal+0x18e/0x280
> pci_stop_bus_device+0x82/0xa0
> pci_stop_and_remove_bus_device_locked+0x5e/0x80
> remove_store+0x72/0x90
I just hit this recursive lock issue when running "reset" instead of
"remove"
$ echo <NUM> > /sys/bus/pci/devices/<pf>/sriov_numvfs
$ echo 1 > /sys/bus/pci/devices/<pf>/reset
> This is not a complete fix as it restores the issue the cited commit
> tried to solve.
>
> Cc: stable@vger.kernel.org
> Fixes: 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV")
> Reported-by: Benjamin Block <bblock@linux.ibm.com>
> Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
> drivers/pci/iov.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> index 77dee43b785838d215b58db2d22088e9346e0583..ac4375954c9479b5f4a0e666b5215094fdaeefc2 100644
> --- a/drivers/pci/iov.c
> +++ b/drivers/pci/iov.c
> @@ -629,18 +629,15 @@ static int sriov_add_vfs(struct pci_dev *dev, u16 num_vfs)
> if (dev->no_vf_scan)
> return 0;
>
> - pci_lock_rescan_remove();
> for (i = 0; i < num_vfs; i++) {
> rc = pci_iov_add_virtfn(dev, i);
> if (rc)
> goto failed;
> }
> - pci_unlock_rescan_remove();
> return 0;
> failed:
> while (i--)
> pci_iov_remove_virtfn(dev, i);
> - pci_unlock_rescan_remove();
>
> return rc;
> }
> @@ -765,10 +762,8 @@ static void sriov_del_vfs(struct pci_dev *dev)
> struct pci_sriov *iov = dev->sriov;
> int i;
>
> - pci_lock_rescan_remove();
> for (i = 0; i < iov->num_VFs; i++)
> pci_iov_remove_virtfn(dev, i);
> - pci_unlock_rescan_remove();
> }
>
> static void sriov_disable(struct pci_dev *dev)
Feel free to add my
Acked-by: Gerd Bayer <gbayer@linux.ibm.com>
next prev parent reply other threads:[~2025-12-10 17:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 12:34 [PATCH v2 0/2] PCI/IOV: Fix deadlock when removing PF with enabled SR-IOV Niklas Schnelle
2025-11-19 12:34 ` [PATCH v2 1/2] Revert "PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV" Niklas Schnelle
2025-12-10 17:35 ` Gerd Bayer [this message]
2025-11-19 12:34 ` [PATCH v2 2/2] PCI/IOV: Fix race between SR-IOV enable/disable and hotplug Niklas Schnelle
2025-12-10 18:05 ` Gerd Bayer
2025-11-19 12:43 ` [PATCH v2 0/2] PCI/IOV: Fix deadlock when removing PF with enabled SR-IOV Niklas Schnelle
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=f16e3e775a5e46672351f03a00295b7c71d6b69a.camel@linux.ibm.com \
--to=gbayer@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=alifm@linux.ibm.com \
--cc=bblock@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=helgaas@kernel.org \
--cc=julianr@linux.ibm.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=schnelle@linux.ibm.com \
/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®