mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: "Isaac J. Manjarres" <isaacmanjarres@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Saravana Kannan <saravanak@google.com>,
	stable@kernel.org, Guenter Roeck <linux@roeck-us.net>,
	kernel-team@android.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] driver core: Fix bus_type.match() error handling
Date: Thu, 25 Aug 2022 11:22:51 +0200	[thread overview]
Message-ID: <b1100fe9-9cf4-26e0-7fa5-b40f6a25ef44@samsung.com> (raw)
In-Reply-To: <20220815211919.2028890-1-isaacmanjarres@google.com>

On 15.08.2022 23:19, 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
> and that results in any error, 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: Saravana Kannan <saravanak@google.com>
> Cc: stable@kernel.org
> 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>

This fixes the boot issue observed on Qualcomm APQ8016 based DragonBoard 
410c, which I've missed while testing the "amba: Remove deferred device 
addition" patch. Feel free to add:

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>   drivers/base/dd.c | 16 +++++++++++++++-
>   1 file changed, 15 insertions(+), 1 deletion(-)
>
> 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.
>
> Guenter,
>
> Can you please give test this patch to make sure it still works for you?
>
> Thanks,
> Isaac
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 70f79fc71539..453eb19a9a27 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,9 +1125,18 @@ 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 right now, 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;
> +		/*
> +		 * Driver could not match with device, but may match with
> +		 * another device on the bus.
> +		 */
> +		return 0;
>   	} /* ret > 0 means positive match */
>   
>   	if (driver_allows_async_probing(drv)) {

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


      parent reply	other threads:[~2022-08-25  9:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220815211927eucas1p275ed3f63f1baf76b319a828c214c651f@eucas1p2.samsung.com>
2022-08-15 21:19 ` Isaac J. Manjarres
2022-08-16  4:25   ` Guenter Roeck
2022-08-16  5:17     ` Isaac Manjarres
2022-08-16 11:13       ` Guenter Roeck
2022-08-16 17:13         ` Isaac Manjarres
2022-08-17  1:05           ` Guenter Roeck
2022-08-17  1:12             ` Isaac Manjarres
2022-08-18 22:59               ` Guenter Roeck
2022-08-19  0:38                 ` Isaac Manjarres
2022-08-19 11:28                   ` Guenter Roeck
2022-08-19 17:45                     ` Isaac Manjarres
2022-08-19 20:01                       ` Bart Van Assche
2022-08-19 20:55                         ` Guenter Roeck
2022-08-19 22:08                         ` Guenter Roeck
2022-08-20  0:07                           ` Bart Van Assche
2022-08-20 11:48                             ` Guenter Roeck
2022-08-21 21:39                               ` Bart Van Assche
2022-08-25  9:22   ` Marek Szyprowski [this message]

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=b1100fe9-9cf4-26e0-7fa5-b40f6a25ef44@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=isaacmanjarres@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rafael@kernel.org \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=saravanak@google.com \
    --cc=stable@kernel.org \
    --cc=tomeu.vizoso@collabora.com \
    --cc=ulf.hansson@linaro.org \
    /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®