* Re: [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral
2022-08-17 18:40 [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral Isaac J. Manjarres
@ 2022-08-25 22:20 ` Saravana Kannan
2022-08-30 11:39 ` Linus Walleij
2022-08-31 20:21 ` Russell King (Oracle)
2 siblings, 0 replies; 6+ messages in thread
From: Saravana Kannan @ 2022-08-25 22:20 UTC (permalink / raw)
To: Isaac J. Manjarres
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Russell King, Ulf Hansson,
Marek Szyprowski, Tomeu Vizoso, stable, Guenter Roeck,
kernel-team, linux-kernel
On Wed, Aug 17, 2022 at 11:40 AM Isaac J. Manjarres
<isaacmanjarres@google.com> wrote:
>
> Both __device_attach_driver() and __driver_attach() check the return
> code of the bus_type.match() function to see if the device needs to be
> added to the deferred probe list. After adding the device to the list,
> the logic attempts to bind the device to the driver anyway, as if the
> device had matched with the driver, which is not correct.
>
> If __device_attach_driver() detects that the device in question is not
> ready to match with a driver on the bus, then it doesn't make sense for
> the device to attempt to bind with the current driver or continue
> attempting to match with any of the other drivers on the bus. So, update
> the logic in __device_attach_driver() to reflect this.
>
> If __driver_attach() detects that a driver tried to match with a device
> that is not ready to match yet, then the driver should not attempt to bind
> with the device. However, the driver can still attempt to match and bind
> with other devices on the bus, as drivers can be bound to multiple
> devices. So, update the logic in __driver_attach() to reflect this.
>
> Cc: stable@vger.kernel.org
> Cc: Saravana Kannan <saravanak@google.com>
> Fixes: 656b8035b0ee ("ARM: 8524/1: driver cohandle -EPROBE_DEFER from bus_type.match()")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
> Tested-by: Guenter Roeck <linux@roeck-us.net>
> Reviewed-by: Saravana Kannan <saravanak@google.com>
> ---
> drivers/base/dd.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> v1 -> v2:
> - Fixed the logic in __driver_attach() to allow a driver to continue
> attempting to match and bind with devices in case of any error, not
> just probe deferral.
>
> v2 -> v3:
> - Restored the patch back to v1.
> - Added Guenter's Tested-by tag.
> - Added Saravana's Reviewed-by tag.
> - Cc'd stable@vger.kernel.org
>
> Greg,
>
> This is the final version of this patch. Can you please pick this up?
>
> Thanks,
> Isaac
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 70f79fc71539..90b31fb141a5 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -881,6 +881,11 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
> dev_dbg(dev, "Device match requests probe deferral\n");
> dev->can_match = true;
> driver_deferred_probe_add(dev);
> + /*
> + * Device can't match with a driver right now, so don't attempt
> + * to match or bind with other drivers on the bus.
> + */
> + return ret;
> } else if (ret < 0) {
> dev_dbg(dev, "Bus failed to match device: %d\n", ret);
> return ret;
> @@ -1120,6 +1125,11 @@ static int __driver_attach(struct device *dev, void *data)
> dev_dbg(dev, "Device match requests probe deferral\n");
> dev->can_match = true;
> driver_deferred_probe_add(dev);
> + /*
> + * Driver could not match with device, but may match with
> + * another device on the bus.
> + */
> + return 0;
> } else if (ret < 0) {
> dev_dbg(dev, "Bus failed to match device: %d\n", ret);
> return ret;
> --
> 2.37.1.595.g718a3a8f04-goog
>
Greg,
Can you pull this in for 6.0-rcX please? This is fixing a long
standing bug that was exposed by my amba code cleanup.
-Saravana
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral
2022-08-17 18:40 [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral Isaac J. Manjarres
2022-08-25 22:20 ` Saravana Kannan
@ 2022-08-30 11:39 ` Linus Walleij
2022-08-31 20:21 ` Russell King (Oracle)
2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2022-08-30 11:39 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki, Russell King, Ulf Hansson,
Marek Szyprowski, Tomeu Vizoso
Cc: Isaac J . Manjarres, stable, Saravana Kannan, Guenter Roeck,
kernel-team, linux-kernel, Linus Walleij
> Both __device_attach_driver() and __driver_attach() check the return
> code of the bus_type.match() function to see if the device needs to be
> added to the deferred probe list. After adding the device to the list,
> the logic attempts to bind the device to the driver anyway, as if the
> device had matched with the driver, which is not correct.
>
> If __device_attach_driver() detects that the device in question is not
> ready to match with a driver on the bus, then it doesn't make sense for
> the device to attempt to bind with the current driver or continue
> attempting to match with any of the other drivers on the bus. So, update
> the logic in __device_attach_driver() to reflect this.
>
> If __driver_attach() detects that a driver tried to match with a device
> that is not ready to match yet, then the driver should not attempt to bind
> with the device. However, the driver can still attempt to match and bind
> with other devices on the bus, as drivers can be bound to multiple
> devices. So, update the logic in __driver_attach() to reflect this.
>
> Cc: stable@vger.kernel.org
> Cc: Saravana Kannan <saravanak@google.com>
> Fixes: 656b8035b0ee ("ARM: 8524/1: driver cohandle -EPROBE_DEFER from bus_type.match()")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
> Tested-by: Guenter Roeck <linux@roeck-us.net>
> Reviewed-by: Saravana Kannan <saravanak@google.com>
This fixes a QEMU regression for me:
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral
2022-08-17 18:40 [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral Isaac J. Manjarres
2022-08-25 22:20 ` Saravana Kannan
2022-08-30 11:39 ` Linus Walleij
@ 2022-08-31 20:21 ` Russell King (Oracle)
2022-09-01 5:28 ` Greg Kroah-Hartman
2 siblings, 1 reply; 6+ messages in thread
From: Russell King (Oracle) @ 2022-08-31 20:21 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Isaac J. Manjarres, Rafael J. Wysocki, Ulf Hansson,
Marek Szyprowski, Tomeu Vizoso, stable, Saravana Kannan,
Guenter Roeck, kernel-team, linux-kernel
Greg,
Are you happy for me to pick up this patch as part of the fixes for the
AMBA changes? The original patch that it is fixing is a patch that was
part of a series that was merged through my tree.
It's fixing a problem that has been noticed by several people and the
fix is now a few weeks old.
Thanks.
On Wed, Aug 17, 2022 at 11:40:26AM -0700, Isaac J. Manjarres wrote:
> Both __device_attach_driver() and __driver_attach() check the return
> code of the bus_type.match() function to see if the device needs to be
> added to the deferred probe list. After adding the device to the list,
> the logic attempts to bind the device to the driver anyway, as if the
> device had matched with the driver, which is not correct.
>
> If __device_attach_driver() detects that the device in question is not
> ready to match with a driver on the bus, then it doesn't make sense for
> the device to attempt to bind with the current driver or continue
> attempting to match with any of the other drivers on the bus. So, update
> the logic in __device_attach_driver() to reflect this.
>
> If __driver_attach() detects that a driver tried to match with a device
> that is not ready to match yet, then the driver should not attempt to bind
> with the device. However, the driver can still attempt to match and bind
> with other devices on the bus, as drivers can be bound to multiple
> devices. So, update the logic in __driver_attach() to reflect this.
>
> Cc: stable@vger.kernel.org
> Cc: Saravana Kannan <saravanak@google.com>
> Fixes: 656b8035b0ee ("ARM: 8524/1: driver cohandle -EPROBE_DEFER from bus_type.match()")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
> Tested-by: Guenter Roeck <linux@roeck-us.net>
> Reviewed-by: Saravana Kannan <saravanak@google.com>
> ---
> drivers/base/dd.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> v1 -> v2:
> - Fixed the logic in __driver_attach() to allow a driver to continue
> attempting to match and bind with devices in case of any error, not
> just probe deferral.
>
> v2 -> v3:
> - Restored the patch back to v1.
> - Added Guenter's Tested-by tag.
> - Added Saravana's Reviewed-by tag.
> - Cc'd stable@vger.kernel.org
>
> Greg,
>
> This is the final version of this patch. Can you please pick this up?
>
> Thanks,
> Isaac
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 70f79fc71539..90b31fb141a5 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -881,6 +881,11 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
> dev_dbg(dev, "Device match requests probe deferral\n");
> dev->can_match = true;
> driver_deferred_probe_add(dev);
> + /*
> + * Device can't match with a driver right now, so don't attempt
> + * to match or bind with other drivers on the bus.
> + */
> + return ret;
> } else if (ret < 0) {
> dev_dbg(dev, "Bus failed to match device: %d\n", ret);
> return ret;
> @@ -1120,6 +1125,11 @@ static int __driver_attach(struct device *dev, void *data)
> dev_dbg(dev, "Device match requests probe deferral\n");
> dev->can_match = true;
> driver_deferred_probe_add(dev);
> + /*
> + * Driver could not match with device, but may match with
> + * another device on the bus.
> + */
> + return 0;
> } else if (ret < 0) {
> dev_dbg(dev, "Bus failed to match device: %d\n", ret);
> return ret;
> --
> 2.37.1.595.g718a3a8f04-goog
>
>
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral
2022-08-31 20:21 ` Russell King (Oracle)
@ 2022-09-01 5:28 ` Greg Kroah-Hartman
2022-09-01 13:57 ` Greg Kroah-Hartman
0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2022-09-01 5:28 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Isaac J. Manjarres, Rafael J. Wysocki, Ulf Hansson,
Marek Szyprowski, Tomeu Vizoso, stable, Saravana Kannan,
Guenter Roeck, kernel-team, linux-kernel
On Wed, Aug 31, 2022 at 09:21:29PM +0100, Russell King (Oracle) wrote:
> Greg,
>
> Are you happy for me to pick up this patch as part of the fixes for the
> AMBA changes? The original patch that it is fixing is a patch that was
> part of a series that was merged through my tree.
>
> It's fixing a problem that has been noticed by several people and the
> fix is now a few weeks old.
Sorry, I'm behind in driver core stuff. I'll pick it up later today.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral
2022-09-01 5:28 ` Greg Kroah-Hartman
@ 2022-09-01 13:57 ` Greg Kroah-Hartman
0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2022-09-01 13:57 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Isaac J. Manjarres, Rafael J. Wysocki, Ulf Hansson,
Marek Szyprowski, Tomeu Vizoso, stable, Saravana Kannan,
Guenter Roeck, kernel-team, linux-kernel
On Thu, Sep 01, 2022 at 07:28:59AM +0200, Greg Kroah-Hartman wrote:
> On Wed, Aug 31, 2022 at 09:21:29PM +0100, Russell King (Oracle) wrote:
> > Greg,
> >
> > Are you happy for me to pick up this patch as part of the fixes for the
> > AMBA changes? The original patch that it is fixing is a patch that was
> > part of a series that was merged through my tree.
> >
> > It's fixing a problem that has been noticed by several people and the
> > fix is now a few weeks old.
>
> Sorry, I'm behind in driver core stuff. I'll pick it up later today.
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread