From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Stephen Boyd <swboyd@chromium.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Russell King <rmk+kernel@arm.linux.org.uk>,
Rob Clark <robdclark@gmail.com>,
dri-devel <dri-devel@lists.freedesktop.org>,
Saravana Kannan <saravanak@google.com>
Subject: Re: [PATCH] component: Move host device to end of device lists on binding
Date: Mon, 10 May 2021 13:59:17 +0200 [thread overview]
Message-ID: <CAJZ5v0jX4ef+oO95dyFmKC0hnfKR7kSmHKQzD=RHgN51O1w_uQ@mail.gmail.com> (raw)
In-Reply-To: <20210508074118.1621729-1-swboyd@chromium.org>
On Sat, May 8, 2021 at 9:41 AM Stephen Boyd <swboyd@chromium.org> wrote:
>
> The device lists are poorly ordered when the component device code is
> used. This is because component_master_add_with_match() returns 0
> regardless of component devices calling component_add() first. It can
> really only fail if an allocation fails, in which case everything is
> going bad and we're out of memory. The host device (called master_dev in
> the code), can succeed at probe and be put on the device lists before
> any of the component devices are probed and put on the lists.
>
> Within the component device framework this usually isn't that bad
> because the real driver work is done at bind time via
> component{,master}_ops::bind(). It becomes a problem when the driver
> core, or host driver, wants to operate on the component device outside
> of the bind/unbind functions, e.g. via 'remove' or 'shutdown'. The
> driver core doesn't understand the relationship between the host device
> and the component devices and could possibly try to operate on component
> devices when they're already removed from the system or shut down.
>
> Normally, device links or probe defer would reorder the lists and put
> devices that depend on other devices in the lists at the correct
> location, but with component devices this doesn't happen because this
> information isn't expressed anywhere. Drivers simply succeed at
> registering their component or host with the component framework and
> wait for their bind() callback to be called once the other components
> are ready. We could make various device links between 'master_dev' and
> 'component->dev' but it's not necessary. Let's simply move the hosting
> device to the end of the device lists when the component device fully
> binds. This way we know that all components are present and have probed
> properly and now the host device has really probed so it's safe to
> assume the host driver ops can operate on any component device.
Moving a device to the end of dpm_list is generally risky in cases
when some dependency information may be missing.
For example, if there is a device depending on the hosting one, but
that dependency is not represented by a device link or a direct
ancestor-descendant relationship (or generally a path in the device
dependency graph leading from one of them to the other), then moving
it to the end of dpm_list would cause system-wide suspend to fail (the
hosting device would be suspended before the one depending on it).
That may not be a concern here, but at least it would be good to
document why it is not a concern.
WARNING: multiple messages have this Message-ID
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Stephen Boyd <swboyd@chromium.org>
Cc: Saravana Kannan <saravanak@google.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
dri-devel <dri-devel@lists.freedesktop.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Russell King <rmk+kernel@arm.linux.org.uk>
Subject: Re: [PATCH] component: Move host device to end of device lists on binding
Date: Mon, 10 May 2021 13:59:17 +0200 [thread overview]
Message-ID: <CAJZ5v0jX4ef+oO95dyFmKC0hnfKR7kSmHKQzD=RHgN51O1w_uQ@mail.gmail.com> (raw)
In-Reply-To: <20210508074118.1621729-1-swboyd@chromium.org>
On Sat, May 8, 2021 at 9:41 AM Stephen Boyd <swboyd@chromium.org> wrote:
>
> The device lists are poorly ordered when the component device code is
> used. This is because component_master_add_with_match() returns 0
> regardless of component devices calling component_add() first. It can
> really only fail if an allocation fails, in which case everything is
> going bad and we're out of memory. The host device (called master_dev in
> the code), can succeed at probe and be put on the device lists before
> any of the component devices are probed and put on the lists.
>
> Within the component device framework this usually isn't that bad
> because the real driver work is done at bind time via
> component{,master}_ops::bind(). It becomes a problem when the driver
> core, or host driver, wants to operate on the component device outside
> of the bind/unbind functions, e.g. via 'remove' or 'shutdown'. The
> driver core doesn't understand the relationship between the host device
> and the component devices and could possibly try to operate on component
> devices when they're already removed from the system or shut down.
>
> Normally, device links or probe defer would reorder the lists and put
> devices that depend on other devices in the lists at the correct
> location, but with component devices this doesn't happen because this
> information isn't expressed anywhere. Drivers simply succeed at
> registering their component or host with the component framework and
> wait for their bind() callback to be called once the other components
> are ready. We could make various device links between 'master_dev' and
> 'component->dev' but it's not necessary. Let's simply move the hosting
> device to the end of the device lists when the component device fully
> binds. This way we know that all components are present and have probed
> properly and now the host device has really probed so it's safe to
> assume the host driver ops can operate on any component device.
Moving a device to the end of dpm_list is generally risky in cases
when some dependency information may be missing.
For example, if there is a device depending on the hosting one, but
that dependency is not represented by a device link or a direct
ancestor-descendant relationship (or generally a path in the device
dependency graph leading from one of them to the other), then moving
it to the end of dpm_list would cause system-wide suspend to fail (the
hosting device would be suspended before the one depending on it).
That may not be a concern here, but at least it would be good to
document why it is not a concern.
next prev parent reply other threads:[~2021-05-10 12:50 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-08 7:41 [PATCH] component: Move host device to end of device lists on binding Stephen Boyd
2021-05-08 7:41 ` Stephen Boyd
2021-05-10 11:59 ` Rafael J. Wysocki [this message]
2021-05-10 11:59 ` Rafael J. Wysocki
2021-05-11 17:59 ` Saravana Kannan
2021-05-11 17:59 ` Saravana Kannan
2021-05-10 16:05 ` Daniel Vetter
2021-05-10 16:05 ` Daniel Vetter
2021-05-10 17:52 ` Stephen Boyd
2021-05-10 17:52 ` Stephen Boyd
2021-05-10 18:26 ` Daniel Vetter
2021-05-10 18:26 ` Daniel Vetter
2021-05-10 19:08 ` Stephen Boyd
2021-05-10 19:08 ` Stephen Boyd
2021-05-11 10:52 ` Rafael J. Wysocki
2021-05-11 10:52 ` Rafael J. Wysocki
2021-05-11 13:39 ` Daniel Vetter
2021-05-11 13:39 ` Daniel Vetter
2021-05-11 17:19 ` Stephen Boyd
2021-05-11 17:19 ` Stephen Boyd
2021-05-11 17:25 ` Daniel Vetter
2021-05-11 17:25 ` Daniel Vetter
2021-05-11 19:12 ` Saravana Kannan
2021-05-11 19:12 ` Saravana Kannan
2021-05-11 17:00 ` Stephen Boyd
2021-05-11 17:00 ` Stephen Boyd
2021-05-11 17:20 ` Rafael J. Wysocki
2021-05-11 17:20 ` Rafael J. Wysocki
2021-05-13 13:40 ` Russell King - ARM Linux admin
2021-05-13 13:40 ` Russell King - ARM Linux admin
2021-05-11 14:42 ` Russell King - ARM Linux admin
2021-05-11 14:42 ` Russell King - ARM Linux admin
2021-05-11 17:22 ` Stephen Boyd
2021-05-11 17:22 ` Stephen Boyd
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='CAJZ5v0jX4ef+oO95dyFmKC0hnfKR7kSmHKQzD=RHgN51O1w_uQ@mail.gmail.com' \
--to=rafael@kernel.org \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=robdclark@gmail.com \
--cc=saravanak@google.com \
--cc=swboyd@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.