public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Benjamin Block <bblock@linux.ibm.com>
Cc: Benjamin Block <lkml@mageta.org>,
	Guenter Roeck <linux@roeck-us.net>,
	Niklas Schnelle <schnelle@linux.ibm.com>,
	Ionut Nechita <ionut.nechita@windriver.com>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Keith Busch <kbusch@kernel.org>,
	Gerd Bayer <gbayer@linux.ibm.com>,
	Matthew Rosato <mjrosato@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 v3 2/2] PCI/IOV: Fix race between SR-IOV enable/disable and hotplug
Date: Tue, 17 Mar 2026 14:08:11 +0100	[thread overview]
Message-ID: <ablSO1rA8D2blipG@wunner.de> (raw)
In-Reply-To: <20260317113334.GJ2161595@p1gen4-pw042f0m>

On Tue, Mar 17, 2026 at 12:33:34PM +0100, Benjamin Block wrote:
> @@ -518,8 +520,13 @@ static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
>  	if (kstrtoul(buf, 0, &val) < 0)
>  		return -EINVAL;
>  
> -	if (val && device_remove_file_self(dev, attr))
> +	if (val && device_remove_file_self(dev, attr)) {
> +		device_lock(dev);
> +		kill_device(dev);
> +		device_unlock(dev);
> +		device_driver_detach(dev);
>  		pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
> +	}
>  	return count;
>  }
>  static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0220, NULL,
> 
> Marking the device dead prevents re-binding after the unbind.

That can also be achieved through the PCI_DEV_ALLOW_BINDING flag,
though you'd have to add a pci_dev_disallow_binding() helper in
drivers/pci/pci.h to go alongside the existing
pci_dev_allow_binding() and pci_dev_binding_disallowed() helpers.

However pci_stop_and_remove_bus_device() implicitly unbinds the
driver before removing the device.  Remind me, what's the need
to unbind before calling that function?

Thanks,

Lukas

  reply	other threads:[~2026-03-17 13:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-16 22:14 [PATCH v3 0/2] PCI/IOV: Fix deadlock when removing PF with enabled SR-IOV Niklas Schnelle
2025-12-16 22:14 ` [PATCH v3 1/2] Revert "PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV" Niklas Schnelle
2025-12-16 22:14 ` [PATCH v3 2/2] PCI/IOV: Fix race between SR-IOV enable/disable and hotplug Niklas Schnelle
2026-03-17  1:57   ` Guenter Roeck
2026-03-17  9:01     ` Benjamin Block
2026-03-17  9:46       ` Benjamin Block
2026-03-17 11:33         ` Benjamin Block
2026-03-17 13:08           ` Lukas Wunner [this message]
2026-03-17 13:18             ` Lukas Wunner
2026-03-17 17:09               ` Benjamin Block
2026-02-01 15:56 ` [PATCH v3 0/2] PCI/IOV: Fix deadlock when removing PF with enabled SR-IOV Thorsten Leemhuis
2026-02-02 15:47   ` Niklas Schnelle
2026-02-03  0:48 ` Bjorn Helgaas
2026-02-23 14:10   ` Dragos Tatulea
2026-02-23 17:33     ` Benjamin Block
2026-02-23 18:34       ` Dragos Tatulea
2026-02-25 14:59         ` Dragos Tatulea
2026-02-25 18:32           ` 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=ablSO1rA8D2blipG@wunner.de \
    --to=lukas@wunner.de \
    --cc=agordeev@linux.ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=bblock@linux.ibm.com \
    --cc=gbayer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=helgaas@kernel.org \
    --cc=ionut.nechita@windriver.com \
    --cc=julianr@linux.ibm.com \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lkml@mageta.org \
    --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