* Re: [PATCH] driver core: PCI: Check drivers_autoprobe for all added devices
[not found] ` <2025100209-hefty-catalyst-e5b2@gregkh>
@ 2025-10-02 12:04 ` Vincent Liu
0 siblings, 0 replies; 12+ messages in thread
From: Vincent Liu @ 2025-10-02 12:04 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Rafael J. Wysocki, Danilo Krummrich, linux-kernel@vger.kernel.org,
bhelgaas@google.com, linux-pci@vger.kernel.org
On 2 Oct 2025, at 06:55, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
>
> If this is a PCI-specific issue, why not cc: the pci developers and
> maintainer as well?
>
> Also, a PCI patch shouldn't be for the driver-core only, I think the
> subject line needs to have "driver core" in it.
You are right, this won’t be PCI-specific. And will affect all (future) callers of
device_initial_probe. Currently there are only two callers, bus_probe_device
and pci_bus_add_device, hence this change only affects PCI devices for
now. But in the future if there are more callers, then those devices will get
this behaviour as well. I’ll make this clear in the commit message, and the
subject.
Also ccing the pci developers.
> I don't see why this is specific to PCI VF devices.
I included PCI VF devices and hot-plugged PCIe devices here because
those are the only two examples that I can think of that supports
“hot-plugging” (at least on the PCI bus), as cold-plugged PCI devices
will still use the default value of drivers_autoprobe, so will not be
affected by this patch. Devices on other buses should maintain their
current behaviour, as explained above.
> Did you see the
> recent PCI patch for not probing VF devices that was sent out yesterday?
> I think that might fix this instead:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20251002020010.315944-2D1-2Djhubbard-40nvidia.com&d=DwIBAg&c=s883GpUCOChKOHiocYtGcg&r=C7C0cxreo6ySFXxtT1zeCPCXI1KQm0FvA2Qq3148J_o&m=2oab-T75r4KLDtgw7uMI8jSQdHz-AKdHuTf2hLRfs7NKcDaAE-FbL5ejYixSNw6E&s=7dPLQqzutOX8VN5aZmpoliZk10DYGPzrmWGQhTKC6ec&e=
>
As far as I can tell, patch above is about an optimisation on avoiding
checking a driver for VF device if it doesn’t support VFs at all? This patch
is about respecting the drivers_autoprobe sysfs knob.
Here is a rephrased commit message (no code change), happy to send a
v2 if needed.
Thanks,
Vincent
-- >8 --
Subject: [PATCH] driver core: PCI: Check drivers_autoprobe for all added
devices
When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
not checked. This means that drivers_autoprobe is not working as
intended, e.g. hot-plugged PCIe devices will still be autoprobed and
bound to drivers even with drivers_autoprobe disabled.
Make sure all devices check drivers_autoprobe by pushing the
drivers_autoprobe check into device_initial_probe. This will only
affect devices on the PCI bus for now as device_initial_probe is only
called by pci_bus_add_device and bus_probe_device (but bus_probe_device
already checks for autoprobe). In particular for the PCI devices, only
hot-plugged PCIe devices/VFs should be affected as the default value of
pci/drivers_autoprobe remains 1 and can only be cleared from userland.
Any future callers of device_initial_probe will respsect the
drivers_autoprobe sysfs attribute, but this should be the intended
purpose of drivers_autoprobe.
Signed-off-by: Vincent Liu <vincent.liu@nutanix.com>
Link: https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
---
drivers/base/bus.c | 3 +--
drivers/base/dd.c | 10 +++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 5e75e1bce551..320e155c6be7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -533,8 +533,7 @@ void bus_probe_device(struct device *dev)
if (!sp)
return;
- if (sp->drivers_autoprobe)
- device_initial_probe(dev);
+ device_initial_probe(dev);
mutex_lock(&sp->mutex);
list_for_each_entry(sif, &sp->interfaces, node)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 13ab98e033ea..37fc57e44e54 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1077,7 +1077,15 @@ EXPORT_SYMBOL_GPL(device_attach);
void device_initial_probe(struct device *dev)
{
- __device_attach(dev, true);
+ struct subsys_private *sp = bus_to_subsys(dev->bus);
+
+ if (!sp)
+ return;
+
+ if (sp->drivers_autoprobe)
+ __device_attach(dev, true);
+
+ subsys_put(sp);
}
/*
--
2.43.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2] driver core: Check drivers_autoprobe for all added devices
[not found] <20251001151508.1684592-1-vincent.liu@nutanix.com>
[not found] ` <2025100209-hefty-catalyst-e5b2@gregkh>
@ 2025-10-13 18:14 ` Vincent Liu
2025-10-14 5:14 ` Greg KH
2025-10-14 20:07 ` Bjorn Helgaas
2025-10-22 12:07 ` [PATCH v3] " Vincent Liu
2025-11-20 17:00 ` [PATCH v3 RESEND] " Vincent Liu
3 siblings, 2 replies; 12+ messages in thread
From: Vincent Liu @ 2025-10-13 18:14 UTC (permalink / raw)
To: gregkh, dakr, linux-kernel; +Cc: rafael, bhelgaas, linux-pci, vincent.liu
When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
not checked. This means that drivers_autoprobe is not working as
intended, e.g. hot-plugged PCIe devices will still be autoprobed and
bound to drivers even with drivers_autoprobe disabled.
Make sure all devices check drivers_autoprobe by pushing the
drivers_autoprobe check into device_initial_probe. This will only
affect devices on the PCI bus for now as device_initial_probe is only
called by pci_bus_add_device and bus_probe_device (but bus_probe_device
already checks for autoprobe). In particular for the PCI devices, only
hot-plugged PCIe devices/VFs should be affected as the default value of
pci/drivers_autoprobe remains 1 and can only be cleared from userland.
Any future callers of device_initial_probe will respsect the
drivers_autoprobe sysfs attribute, but this should be the intended
purpose of drivers_autoprobe.
Signed-off-by: Vincent Liu <vincent.liu@nutanix.com>
---
v1->v2: Change commit subject to include driver core (no code change)
https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
---
drivers/base/bus.c | 3 +--
drivers/base/dd.c | 10 +++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 5e75e1bce551..320e155c6be7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -533,8 +533,7 @@ void bus_probe_device(struct device *dev)
if (!sp)
return;
- if (sp->drivers_autoprobe)
- device_initial_probe(dev);
+ device_initial_probe(dev);
mutex_lock(&sp->mutex);
list_for_each_entry(sif, &sp->interfaces, node)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 13ab98e033ea..37fc57e44e54 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1077,7 +1077,15 @@ EXPORT_SYMBOL_GPL(device_attach);
void device_initial_probe(struct device *dev)
{
- __device_attach(dev, true);
+ struct subsys_private *sp = bus_to_subsys(dev->bus);
+
+ if (!sp)
+ return;
+
+ if (sp->drivers_autoprobe)
+ __device_attach(dev, true);
+
+ subsys_put(sp);
}
/*
--
2.43.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2] driver core: Check drivers_autoprobe for all added devices
2025-10-13 18:14 ` [PATCH v2] driver core: " Vincent Liu
@ 2025-10-14 5:14 ` Greg KH
2025-10-14 12:10 ` Vincent Liu
2025-10-14 20:07 ` Bjorn Helgaas
1 sibling, 1 reply; 12+ messages in thread
From: Greg KH @ 2025-10-14 5:14 UTC (permalink / raw)
To: Vincent Liu; +Cc: dakr, linux-kernel, rafael, bhelgaas, linux-pci
On Mon, Oct 13, 2025 at 07:14:59PM +0100, Vincent Liu wrote:
> When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
> not checked. This means that drivers_autoprobe is not working as
> intended, e.g. hot-plugged PCIe devices will still be autoprobed and
> bound to drivers even with drivers_autoprobe disabled.
>
> Make sure all devices check drivers_autoprobe by pushing the
> drivers_autoprobe check into device_initial_probe. This will only
> affect devices on the PCI bus for now as device_initial_probe is only
> called by pci_bus_add_device and bus_probe_device (but bus_probe_device
> already checks for autoprobe). In particular for the PCI devices, only
> hot-plugged PCIe devices/VFs should be affected as the default value of
> pci/drivers_autoprobe remains 1 and can only be cleared from userland.
>
> Any future callers of device_initial_probe will respsect the
> drivers_autoprobe sysfs attribute, but this should be the intended
> purpose of drivers_autoprobe.
>
> Signed-off-by: Vincent Liu <vincent.liu@nutanix.com>
> ---
> v1->v2: Change commit subject to include driver core (no code change)
> https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
What commit id does this fix? What devices cause this to happen today
that are seeing this issue? Should this be backported to older kernels?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] driver core: Check drivers_autoprobe for all added devices
2025-10-14 5:14 ` Greg KH
@ 2025-10-14 12:10 ` Vincent Liu
2025-10-21 12:49 ` Vincent Liu
0 siblings, 1 reply; 12+ messages in thread
From: Vincent Liu @ 2025-10-14 12:10 UTC (permalink / raw)
To: Greg KH
Cc: dakr@kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org,
bhelgaas@google.com, linux-pci@vger.kernel.org
On 14 Oct 2025, at 06:14, Greg KH <gregkh@linuxfoundation.org> wrote:
> What commit id does this fix?
I am not entirely sure if there is a particular commit that causes this issue,
the device_attach call was added in pci/bus.c 58d9a38f6fac, and then the
device_add was removed in 4f535093cf8f6. At this point I think the
drivers_autoprobe stopped working because driver_attach that’s left in
pci_bus_add_device does not check for that.
The drivers_autoprobe check in base/bus.c has been there a long time
since b8c5cec23d5c.
> What devices cause this to happen today that are seeing this issue?
I am observing this for hot-plugged PCIe devices and VFs.
> Should this be backported to older kernels?
I suppose not since this was not working for a long time?
Thanks,
Vincent
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] driver core: Check drivers_autoprobe for all added devices
2025-10-13 18:14 ` [PATCH v2] driver core: " Vincent Liu
2025-10-14 5:14 ` Greg KH
@ 2025-10-14 20:07 ` Bjorn Helgaas
2025-10-15 10:23 ` Vincent Liu
1 sibling, 1 reply; 12+ messages in thread
From: Bjorn Helgaas @ 2025-10-14 20:07 UTC (permalink / raw)
To: Vincent Liu; +Cc: gregkh, dakr, linux-kernel, rafael, bhelgaas, linux-pci
On Mon, Oct 13, 2025 at 07:14:59PM +0100, Vincent Liu wrote:
> When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
> not checked. This means that drivers_autoprobe is not working as
> intended, e.g. hot-plugged PCIe devices will still be autoprobed and
> bound to drivers even with drivers_autoprobe disabled.
>
> Make sure all devices check drivers_autoprobe by pushing the
> drivers_autoprobe check into device_initial_probe. This will only
> affect devices on the PCI bus for now as device_initial_probe is only
> called by pci_bus_add_device and bus_probe_device (but bus_probe_device
> already checks for autoprobe).
> In particular for the PCI devices, only
> hot-plugged PCIe devices/VFs should be affected as the default value of
> pci/drivers_autoprobe remains 1 and can only be cleared from userland.
I'm not sure what this last sentence is telling us. Does
"pci/drivers_autoprobe" refer to struct pci_sriov.drivers_autoprobe?
If so, can you elaborate on the connection with struct
subsys_private.drivers_autoprobe, which this patch tests? I don't see
anything in this patch related to pci_sriov.
As far as I can tell, this patch is generic with respect to
conventional PCI vs PCIe. If so, I'd use "PCI" everywhere instead of
a mix of PCI and PCIe.
> Any future callers of device_initial_probe will respsect the
> drivers_autoprobe sysfs attribute, but this should be the intended
> purpose of drivers_autoprobe.
Add "()" after function names to make them easily recognizable as
functions.
s/respsect/respect/
s/but this should be the/which is the/ # maybe? not sure what you intend
> Signed-off-by: Vincent Liu <vincent.liu@nutanix.com>
> ---
> v1->v2: Change commit subject to include driver core (no code change)
> https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
> ---
> drivers/base/bus.c | 3 +--
> drivers/base/dd.c | 10 +++++++++-
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 5e75e1bce551..320e155c6be7 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -533,8 +533,7 @@ void bus_probe_device(struct device *dev)
> if (!sp)
> return;
>
> - if (sp->drivers_autoprobe)
> - device_initial_probe(dev);
> + device_initial_probe(dev);
>
> mutex_lock(&sp->mutex);
> list_for_each_entry(sif, &sp->interfaces, node)
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 13ab98e033ea..37fc57e44e54 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -1077,7 +1077,15 @@ EXPORT_SYMBOL_GPL(device_attach);
>
> void device_initial_probe(struct device *dev)
> {
> - __device_attach(dev, true);
> + struct subsys_private *sp = bus_to_subsys(dev->bus);
> +
> + if (!sp)
> + return;
> +
> + if (sp->drivers_autoprobe)
> + __device_attach(dev, true);
> +
> + subsys_put(sp);
> }
>
> /*
> --
> 2.43.7
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] driver core: Check drivers_autoprobe for all added devices
2025-10-14 20:07 ` Bjorn Helgaas
@ 2025-10-15 10:23 ` Vincent Liu
2025-10-15 16:53 ` Bjorn Helgaas
0 siblings, 1 reply; 12+ messages in thread
From: Vincent Liu @ 2025-10-15 10:23 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: gregkh@linuxfoundation.org, dakr@kernel.org,
linux-kernel@vger.kernel.org, rafael@kernel.org,
bhelgaas@google.com, linux-pci@vger.kernel.org
On 14 Oct 2025, at 21:07, Bjorn Helgaas <helgaas@kernel.org> wrote:
>
>> In particular for the PCI devices, only
>> hot-plugged PCIe devices/VFs should be affected as the default value of
>> pci/drivers_autoprobe remains 1 and can only be cleared from userland.
>
> I'm not sure what this last sentence is telling us. Does
> "pci/drivers_autoprobe" refer to struct pci_sriov.drivers_autoprobe?
> If so, can you elaborate on the connection with struct
> subsys_private.drivers_autoprobe, which this patch tests? I don't see
> anything in this patch related to pci_sriov.
No this patch has nothing to do with pci_sriov.drivers_autoprobe, this is
generic for all (pci) devices. pci/drivers_autoprobe refers to the
drivers_autoprobe sysfs attribute on the pci bus.
The last sentence is saying that this setting should only affect hot-plugged
devices because I think there is no way for pci/drivers_autoprobe to be 0
for cold plugged devices? But thinking more about this, I don’t think this
adds much value to the commit message because the drivers_autoprobe
is not intended for cold-plugged devices anyway. I’ll remove it.
> As far as I can tell, this patch is generic with respect to
> conventional PCI vs PCIe. If so, I'd use "PCI" everywhere instead of
> a mix of PCI and PCIe.
Yes you are right, this is generic. I used PCIe purely because of the
“hot-plugging”, but happy to use PCI everywhere.
> Add "()" after function names to make them easily recognizable as
> functions.
>
> s/respsect/respect/
> s/but this should be the/which is the/ # maybe? not sure what you intend
Ok.
Below is a rephrased commit message to incorporate the feedback.
Thanks,
Vincent
-- >8 --
Subject: [PATCH v2] driver core: Check drivers_autoprobe for all added devices
When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
not checked (at least for PCI devices). This means that
drivers_autoprobe is not working as intended, e.g. hot-plugged PCI
devices will still be autoprobed and bound to drivers even with
drivers_autoprobe disabled.
Make sure all devices check drivers_autoprobe by pushing the
drivers_autoprobe check into device_initial_probe(). This will only
affect devices on the PCI bus for now as device_initial_probe() is only
called by pci_bus_add_device() and bus_probe_device(), but
bus_probe_device() already checks for autoprobe, so callers of
bus_probe_device() should not observe changes on autoprobing.
Any future callers of device_initial_probe() will respect the
drivers_autoprobe sysfs attribute, which is the intended purpose of
drivers_autoprobe.
Signed-off-by: Vincent Liu <vincent.liu@nutanix.com>
Link: https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] driver core: Check drivers_autoprobe for all added devices
2025-10-15 10:23 ` Vincent Liu
@ 2025-10-15 16:53 ` Bjorn Helgaas
0 siblings, 0 replies; 12+ messages in thread
From: Bjorn Helgaas @ 2025-10-15 16:53 UTC (permalink / raw)
To: Vincent Liu
Cc: gregkh@linuxfoundation.org, dakr@kernel.org,
linux-kernel@vger.kernel.org, rafael@kernel.org,
bhelgaas@google.com, linux-pci@vger.kernel.org
On Wed, Oct 15, 2025 at 10:23:20AM +0000, Vincent Liu wrote:
> On 14 Oct 2025, at 21:07, Bjorn Helgaas <helgaas@kernel.org> wrote:
> >
> >> In particular for the PCI devices, only
> >> hot-plugged PCIe devices/VFs should be affected as the default value of
> >> pci/drivers_autoprobe remains 1 and can only be cleared from userland.
> >
> > I'm not sure what this last sentence is telling us. Does
> > "pci/drivers_autoprobe" refer to struct pci_sriov.drivers_autoprobe?
> > If so, can you elaborate on the connection with struct
> > subsys_private.drivers_autoprobe, which this patch tests? I don't see
> > anything in this patch related to pci_sriov.
>
> No this patch has nothing to do with pci_sriov.drivers_autoprobe, this is
> generic for all (pci) devices. pci/drivers_autoprobe refers to the
> drivers_autoprobe sysfs attribute on the pci bus.
>
> The last sentence is saying that this setting should only affect hot-plugged
> devices because I think there is no way for pci/drivers_autoprobe to be 0
> for cold plugged devices? But thinking more about this, I don’t think this
> adds much value to the commit message because the drivers_autoprobe
> is not intended for cold-plugged devices anyway. I’ll remove it.
>
> > As far as I can tell, this patch is generic with respect to
> > conventional PCI vs PCIe. If so, I'd use "PCI" everywhere instead of
> > a mix of PCI and PCIe.
>
> Yes you are right, this is generic. I used PCIe purely because of the
> “hot-plugging”, but happy to use PCI everywhere.
>
> > Add "()" after function names to make them easily recognizable as
> > functions.
> >
> > s/respsect/respect/
> > s/but this should be the/which is the/ # maybe? not sure what you intend
>
> Ok.
>
> Below is a rephrased commit message to incorporate the feedback.
>
> Thanks,
> Vincent
>
> -- >8 --
>
> Subject: [PATCH v2] driver core: Check drivers_autoprobe for all added devices
>
> When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
> not checked (at least for PCI devices). This means that
> drivers_autoprobe is not working as intended, e.g. hot-plugged PCI
> devices will still be autoprobed and bound to drivers even with
> drivers_autoprobe disabled.
>
> Make sure all devices check drivers_autoprobe by pushing the
> drivers_autoprobe check into device_initial_probe(). This will only
> affect devices on the PCI bus for now as device_initial_probe() is only
> called by pci_bus_add_device() and bus_probe_device(), but
> bus_probe_device() already checks for autoprobe, so callers of
> bus_probe_device() should not observe changes on autoprobing.
>
> Any future callers of device_initial_probe() will respect the
> drivers_autoprobe sysfs attribute, which is the intended purpose of
> drivers_autoprobe.
>
> Signed-off-by: Vincent Liu <vincent.liu@nutanix.com>
>
> Link: https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
Thanks, that reads much better to me.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] driver core: Check drivers_autoprobe for all added devices
2025-10-14 12:10 ` Vincent Liu
@ 2025-10-21 12:49 ` Vincent Liu
2025-10-22 10:32 ` Greg KH
0 siblings, 1 reply; 12+ messages in thread
From: Vincent Liu @ 2025-10-21 12:49 UTC (permalink / raw)
To: Greg KH
Cc: dakr@kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org,
bhelgaas@google.com, linux-pci@vger.kernel.org
> On 14 Oct 2025, at 13:10, Vincent Liu <vincent.liu@nutanix.com> wrote:
>
> On 14 Oct 2025, at 06:14, Greg KH <gregkh@linuxfoundation.org> wrote:
>
>> What commit id does this fix?
>
> I am not entirely sure if there is a particular commit that causes this issue,
> the device_attach call was added in pci/bus.c 58d9a38f6fac, and then the
> device_add was removed in 4f535093cf8f6. At this point I think the
> drivers_autoprobe stopped working because driver_attach that’s left in
> pci_bus_add_device does not check for that.
>
> The drivers_autoprobe check in base/bus.c has been there a long time
> since b8c5cec23d5c.
>
>> What devices cause this to happen today that are seeing this issue?
>
> I am observing this for hot-plugged PCIe devices and VFs.
>
>> Should this be backported to older kernels?
>
> I suppose not since this was not working for a long time?
>
Are you happy with this reply Greg? Do you want me to update the commit
message to include some of these commit ids?
Thanks,
Vincent
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] driver core: Check drivers_autoprobe for all added devices
2025-10-21 12:49 ` Vincent Liu
@ 2025-10-22 10:32 ` Greg KH
0 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2025-10-22 10:32 UTC (permalink / raw)
To: Vincent Liu
Cc: dakr@kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org,
bhelgaas@google.com, linux-pci@vger.kernel.org
On Tue, Oct 21, 2025 at 12:49:21PM +0000, Vincent Liu wrote:
> > On 14 Oct 2025, at 13:10, Vincent Liu <vincent.liu@nutanix.com> wrote:
> >
> > On 14 Oct 2025, at 06:14, Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> >> What commit id does this fix?
> >
> > I am not entirely sure if there is a particular commit that causes this issue,
> > the device_attach call was added in pci/bus.c 58d9a38f6fac, and then the
> > device_add was removed in 4f535093cf8f6. At this point I think the
> > drivers_autoprobe stopped working because driver_attach that’s left in
> > pci_bus_add_device does not check for that.
> >
> > The drivers_autoprobe check in base/bus.c has been there a long time
> > since b8c5cec23d5c.
> >
> >> What devices cause this to happen today that are seeing this issue?
> >
> > I am observing this for hot-plugged PCIe devices and VFs.
> >
> >> Should this be backported to older kernels?
> >
> > I suppose not since this was not working for a long time?
> >
>
> Are you happy with this reply Greg? Do you want me to update the commit
> message to include some of these commit ids?
Please do.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3] driver core: Check drivers_autoprobe for all added devices
[not found] <20251001151508.1684592-1-vincent.liu@nutanix.com>
[not found] ` <2025100209-hefty-catalyst-e5b2@gregkh>
2025-10-13 18:14 ` [PATCH v2] driver core: " Vincent Liu
@ 2025-10-22 12:07 ` Vincent Liu
2025-11-04 13:16 ` Vincent Liu
2025-11-20 17:00 ` [PATCH v3 RESEND] " Vincent Liu
3 siblings, 1 reply; 12+ messages in thread
From: Vincent Liu @ 2025-10-22 12:07 UTC (permalink / raw)
To: gregkh; +Cc: dakr, linux-kernel, rafael, bhelgaas, linux-pci, vincent.liu
When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
not checked (at least for PCI devices). This means that
drivers_autoprobe is not working as intended, e.g. hot-plugged PCI
devices will still be autoprobed and bound to drivers even with
drivers_autoprobe disabled.
The problem likely started when device_add() was removed from
pci_bus_add_device() in commit 4f535093cf8f ("PCI: Put pci_dev in device
tree as early as possible") which means that the check for
drivers_autoprobe which used to happen in bus_probe_device() is no
longer present (previously bus_add_device() calls bus_probe_device()).
Conveniently, in commit 91703041697c ("PCI: Allow built-in drivers to
use async initial probing") device_attach() was replaced with
device_initial_probe() which faciliates this change to push the check
for drivers_autoprobe into device_initial_probe().
Make sure all devices check drivers_autoprobe by pushing the
drivers_autoprobe check into device_initial_probe(). This will only
affect devices on the PCI bus for now as device_initial_probe() is only
called by pci_bus_add_device() and bus_probe_device(), but
bus_probe_device() already checks for autoprobe, so callers of
bus_probe_device() should not observe changes on autoprobing.
Note also that pushing this check into device_initial_probe() rather
than device_attach() makes it only affect automatic probing of
drivers (e.g. when a device is hot-plugged), userspace can still choose
to manually bind a driver by writing to drivers_probe sysfs attribute,
even with autoprobe disabled.
Any future callers of device_initial_probe() will respect the
drivers_autoprobe sysfs attribute, which is the intended purpose of
drivers_autoprobe.
Signed-off-by: Vincent Liu <vincent.liu@nutanix.com>
Link: https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
---
v1->v2: Change commit subject to include driver core (no code change)
https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
v2->v3: Updated commit message to use PCI and include history (no code change)
https://lore.kernel.org/20251013181459.517736-1-vincent.liu@nutanix.com/
---
drivers/base/bus.c | 3 +--
drivers/base/dd.c | 10 +++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 5e75e1bce551..320e155c6be7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -533,8 +533,7 @@ void bus_probe_device(struct device *dev)
if (!sp)
return;
- if (sp->drivers_autoprobe)
- device_initial_probe(dev);
+ device_initial_probe(dev);
mutex_lock(&sp->mutex);
list_for_each_entry(sif, &sp->interfaces, node)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 13ab98e033ea..37fc57e44e54 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1077,7 +1077,15 @@ EXPORT_SYMBOL_GPL(device_attach);
void device_initial_probe(struct device *dev)
{
- __device_attach(dev, true);
+ struct subsys_private *sp = bus_to_subsys(dev->bus);
+
+ if (!sp)
+ return;
+
+ if (sp->drivers_autoprobe)
+ __device_attach(dev, true);
+
+ subsys_put(sp);
}
/*
--
2.43.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3] driver core: Check drivers_autoprobe for all added devices
2025-10-22 12:07 ` [PATCH v3] " Vincent Liu
@ 2025-11-04 13:16 ` Vincent Liu
0 siblings, 0 replies; 12+ messages in thread
From: Vincent Liu @ 2025-11-04 13:16 UTC (permalink / raw)
To: gregkh@linuxfoundation.org
Cc: dakr@kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org,
bhelgaas@google.com, linux-pci@vger.kernel.org
On 22 Oct 2025, at 13:07, Vincent Liu <vincent.liu@nutanix.com> wrote:
>
> When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
> not checked (at least for PCI devices). This means that
> drivers_autoprobe is not working as intended, e.g. hot-plugged PCI
> devices will still be autoprobed and bound to drivers even with
> drivers_autoprobe disabled.
>
> The problem likely started when device_add() was removed from
> pci_bus_add_device() in commit 4f535093cf8f ("PCI: Put pci_dev in device
> tree as early as possible") which means that the check for
> drivers_autoprobe which used to happen in bus_probe_device() is no
> longer present (previously bus_add_device() calls bus_probe_device()).
> Conveniently, in commit 91703041697c ("PCI: Allow built-in drivers to
> use async initial probing") device_attach() was replaced with
> device_initial_probe() which faciliates this change to push the check
> for drivers_autoprobe into device_initial_probe().
>
> Make sure all devices check drivers_autoprobe by pushing the
> drivers_autoprobe check into device_initial_probe(). This will only
> affect devices on the PCI bus for now as device_initial_probe() is only
> called by pci_bus_add_device() and bus_probe_device(), but
> bus_probe_device() already checks for autoprobe, so callers of
> bus_probe_device() should not observe changes on autoprobing.
> Note also that pushing this check into device_initial_probe() rather
> than device_attach() makes it only affect automatic probing of
> drivers (e.g. when a device is hot-plugged), userspace can still choose
> to manually bind a driver by writing to drivers_probe sysfs attribute,
> even with autoprobe disabled.
>
> Any future callers of device_initial_probe() will respect the
> drivers_autoprobe sysfs attribute, which is the intended purpose of
> drivers_autoprobe.
>
> Signed-off-by: Vincent Liu <vincent.liu@nutanix.com>
>
> Link: https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
> ---
> v1->v2: Change commit subject to include driver core (no code change)
> https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
> v2->v3: Updated commit message to use PCI and include history (no code change)
> https://lore.kernel.org/20251013181459.517736-1-vincent.liu@nutanix.com/
> ---
> drivers/base/bus.c | 3 +--
> drivers/base/dd.c | 10 +++++++++-
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 5e75e1bce551..320e155c6be7 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -533,8 +533,7 @@ void bus_probe_device(struct device *dev)
> if (!sp)
> return;
>
> - if (sp->drivers_autoprobe)
> - device_initial_probe(dev);
> + device_initial_probe(dev);
>
> mutex_lock(&sp->mutex);
> list_for_each_entry(sif, &sp->interfaces, node)
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 13ab98e033ea..37fc57e44e54 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -1077,7 +1077,15 @@ EXPORT_SYMBOL_GPL(device_attach);
>
> void device_initial_probe(struct device *dev)
> {
> - __device_attach(dev, true);
> + struct subsys_private *sp = bus_to_subsys(dev->bus);
> +
> + if (!sp)
> + return;
> +
> + if (sp->drivers_autoprobe)
> + __device_attach(dev, true);
> +
> + subsys_put(sp);
> }
>
> /*
> --
> 2.43.7
>
Any further comments regarding this new commit message?
Thanks,
Vincent
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 RESEND] driver core: Check drivers_autoprobe for all added devices
[not found] <20251001151508.1684592-1-vincent.liu@nutanix.com>
` (2 preceding siblings ...)
2025-10-22 12:07 ` [PATCH v3] " Vincent Liu
@ 2025-11-20 17:00 ` Vincent Liu
3 siblings, 0 replies; 12+ messages in thread
From: Vincent Liu @ 2025-11-20 17:00 UTC (permalink / raw)
To: gregkh; +Cc: dakr, linux-kernel, rafael, bhelgaas, linux-pci, vincent.liu
When a device is hot-plugged, the drivers_autoprobe sysfs attribute is
not checked (at least for PCI devices). This means that
drivers_autoprobe is not working as intended, e.g. hot-plugged PCI
devices will still be autoprobed and bound to drivers even with
drivers_autoprobe disabled.
The problem likely started when device_add() was removed from
pci_bus_add_device() in commit 4f535093cf8f ("PCI: Put pci_dev in device
tree as early as possible") which means that the check for
drivers_autoprobe which used to happen in bus_probe_device() is no
longer present (previously bus_add_device() calls bus_probe_device()).
Conveniently, in commit 91703041697c ("PCI: Allow built-in drivers to
use async initial probing") device_attach() was replaced with
device_initial_probe() which faciliates this change to push the check
for drivers_autoprobe into device_initial_probe().
Make sure all devices check drivers_autoprobe by pushing the
drivers_autoprobe check into device_initial_probe(). This will only
affect devices on the PCI bus for now as device_initial_probe() is only
called by pci_bus_add_device() and bus_probe_device(), but
bus_probe_device() already checks for autoprobe, so callers of
bus_probe_device() should not observe changes on autoprobing.
Note also that pushing this check into device_initial_probe() rather
than device_attach() makes it only affect automatic probing of
drivers (e.g. when a device is hot-plugged), userspace can still choose
to manually bind a driver by writing to drivers_probe sysfs attribute,
even with autoprobe disabled.
Any future callers of device_initial_probe() will respect the
drivers_autoprobe sysfs attribute, which is the intended purpose of
drivers_autoprobe.
Signed-off-by: Vincent Liu <vincent.liu@nutanix.com>
Link: https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
---
v1->v2: Change commit subject to include driver core (no code change)
https://lore.kernel.org/20251001151508.1684592-1-vincent.liu@nutanix.com
v2->v3: Updated commit message to use PCI and include history (no code change)
https://lore.kernel.org/20251013181459.517736-1-vincent.liu@nutanix.com/
---
drivers/base/bus.c | 3 +--
drivers/base/dd.c | 10 +++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 5e75e1bce551..320e155c6be7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -533,8 +533,7 @@ void bus_probe_device(struct device *dev)
if (!sp)
return;
- if (sp->drivers_autoprobe)
- device_initial_probe(dev);
+ device_initial_probe(dev);
mutex_lock(&sp->mutex);
list_for_each_entry(sif, &sp->interfaces, node)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 13ab98e033ea..37fc57e44e54 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1077,7 +1077,15 @@ EXPORT_SYMBOL_GPL(device_attach);
void device_initial_probe(struct device *dev)
{
- __device_attach(dev, true);
+ struct subsys_private *sp = bus_to_subsys(dev->bus);
+
+ if (!sp)
+ return;
+
+ if (sp->drivers_autoprobe)
+ __device_attach(dev, true);
+
+ subsys_put(sp);
}
/*
--
2.43.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-11-20 17:01 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251001151508.1684592-1-vincent.liu@nutanix.com>
[not found] ` <2025100209-hefty-catalyst-e5b2@gregkh>
2025-10-02 12:04 ` [PATCH] driver core: PCI: Check drivers_autoprobe for all added devices Vincent Liu
2025-10-13 18:14 ` [PATCH v2] driver core: " Vincent Liu
2025-10-14 5:14 ` Greg KH
2025-10-14 12:10 ` Vincent Liu
2025-10-21 12:49 ` Vincent Liu
2025-10-22 10:32 ` Greg KH
2025-10-14 20:07 ` Bjorn Helgaas
2025-10-15 10:23 ` Vincent Liu
2025-10-15 16:53 ` Bjorn Helgaas
2025-10-22 12:07 ` [PATCH v3] " Vincent Liu
2025-11-04 13:16 ` Vincent Liu
2025-11-20 17:00 ` [PATCH v3 RESEND] " Vincent Liu
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).