Export device_is_dependent() since the drm_kms_helper module is starting
to use it.
Signed-off-by: Liu Ying <victor.liu@nxp.com>
---
v2:
* Newly introduced as needed by patch 2.
drivers/base/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 67ba592afc77..bfd2bf0364b7 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -328,6 +328,7 @@ int device_is_dependent(struct device *dev, void *target)
}
return ret;
}
+EXPORT_SYMBOL_GPL(device_is_dependent);
static void device_link_init_status(struct device_link *link,
struct device *consumer,
--
2.37.1
Greg, Rafael, On Mon, Nov 27, 2023 at 01:14:13PM +0800, Liu Ying wrote: > Export device_is_dependent() since the drm_kms_helper module is starting > to use it. > > Signed-off-by: Liu Ying <victor.liu@nxp.com> > --- > v2: > * Newly introduced as needed by patch 2. > > drivers/base/core.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 67ba592afc77..bfd2bf0364b7 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -328,6 +328,7 @@ int device_is_dependent(struct device *dev, void *target) > } > return ret; > } > +EXPORT_SYMBOL_GPL(device_is_dependent); So, a committer just applied this to drm-misc-fixes without your approval. Could you ack it? If you don't want to, we'll fix it. Maxime
On Mon, Nov 27, 2023 at 05:38:13PM +0100, Maxime Ripard wrote: > Greg, Rafael, > > On Mon, Nov 27, 2023 at 01:14:13PM +0800, Liu Ying wrote: > > Export device_is_dependent() since the drm_kms_helper module is starting > > to use it. > > > > Signed-off-by: Liu Ying <victor.liu@nxp.com> > > --- > > v2: > > * Newly introduced as needed by patch 2. > > > > drivers/base/core.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/base/core.c b/drivers/base/core.c > > index 67ba592afc77..bfd2bf0364b7 100644 > > --- a/drivers/base/core.c > > +++ b/drivers/base/core.c > > @@ -328,6 +328,7 @@ int device_is_dependent(struct device *dev, void *target) > > } > > return ret; > > } > > +EXPORT_SYMBOL_GPL(device_is_dependent); > > So, a committer just applied this to drm-misc-fixes without your > approval. Could you ack it? If you don't want to, we'll fix it. Wait, why exactly is this needed? Nothing outside of the driver core should be needing this function, it shouldn't be public at all (I missed that before.) So please, revert it for now, let's figure out why DRM thinks this is needed for it's devices, and yet no other bus/subsystem does. thanks, greg k-h
On Mon, Nov 27, 2023 at 7:21 PM Greg KH <gregkh@linuxfoundation.org> wrote: > > On Mon, Nov 27, 2023 at 05:38:13PM +0100, Maxime Ripard wrote: > > Greg, Rafael, > > > > On Mon, Nov 27, 2023 at 01:14:13PM +0800, Liu Ying wrote: > > > Export device_is_dependent() since the drm_kms_helper module is starting > > > to use it. > > > > > > Signed-off-by: Liu Ying <victor.liu@nxp.com> > > > --- > > > v2: > > > * Newly introduced as needed by patch 2. > > > > > > drivers/base/core.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/drivers/base/core.c b/drivers/base/core.c > > > index 67ba592afc77..bfd2bf0364b7 100644 > > > --- a/drivers/base/core.c > > > +++ b/drivers/base/core.c > > > @@ -328,6 +328,7 @@ int device_is_dependent(struct device *dev, void *target) > > > } > > > return ret; > > > } > > > +EXPORT_SYMBOL_GPL(device_is_dependent); > > > > So, a committer just applied this to drm-misc-fixes without your > > approval. Could you ack it? If you don't want to, we'll fix it. > > Wait, why exactly is this needed? Nothing outside of the driver core > should be needing this function, it shouldn't be public at all (I missed > that before.) > Hi Greg! Sorry for reviving this old thread but I stumbled upon it when looking for information on whether anyone ever tried to export device_is_dependent() before. I have a use-case where I think I need to check if two devices are linked with a device link. I assume you'll prove me wrong. :) The reset-gpio driver is a reset control driver that mediates sharing a reset GPIO (defined as a standardized reference fwnode property "reset-gpios") among multiple users. reset-gpio auxiliary devices are instantiated from reset core when it detects a consumer trying to get a reset-control handle but there's no "resets" reference on the consumer's fwnode, only "reset-gpios". It makes sense for reset core to create a device link between the auxiliary reset-gpio device (the supplier) and the reset consumer because this link is not described in firmware - only the link between the consumer AND the GPIO controller. Now in order to make gpiolib-shared.c code (generic support for shared GPIOs) happy, I need to handle the side effects of interacting with reset-gpio which does a similar thing. To that end, I need to know if given GPIO controller is a supplier of the consumer described in firmware OR the auxiliary reset device which is only described with software nodes. The logical thing to do would be to use "device_is_dependent()" but this thread makes me think that won't fly. What should I do? What's the "correct" way of checking if two devices are linked? I assume that fiddling with the supplier/consumer lists in struct device is not it. Thanks, Bartosz
On Wed, Nov 26, 2025 at 02:13:03PM +0100, Bartosz Golaszewski wrote: > On Mon, Nov 27, 2023 at 7:21 PM Greg KH <gregkh@linuxfoundation.org> wrote: > > > > On Mon, Nov 27, 2023 at 05:38:13PM +0100, Maxime Ripard wrote: > > > Greg, Rafael, > > > > > > On Mon, Nov 27, 2023 at 01:14:13PM +0800, Liu Ying wrote: > > > > Export device_is_dependent() since the drm_kms_helper module is starting > > > > to use it. > > > > > > > > Signed-off-by: Liu Ying <victor.liu@nxp.com> > > > > --- > > > > v2: > > > > * Newly introduced as needed by patch 2. > > > > > > > > drivers/base/core.c | 1 + > > > > 1 file changed, 1 insertion(+) > > > > > > > > diff --git a/drivers/base/core.c b/drivers/base/core.c > > > > index 67ba592afc77..bfd2bf0364b7 100644 > > > > --- a/drivers/base/core.c > > > > +++ b/drivers/base/core.c > > > > @@ -328,6 +328,7 @@ int device_is_dependent(struct device *dev, void *target) > > > > } > > > > return ret; > > > > } > > > > +EXPORT_SYMBOL_GPL(device_is_dependent); > > > > > > So, a committer just applied this to drm-misc-fixes without your > > > approval. Could you ack it? If you don't want to, we'll fix it. > > > > Wait, why exactly is this needed? Nothing outside of the driver core > > should be needing this function, it shouldn't be public at all (I missed > > that before.) > > > > Hi Greg! > > Sorry for reviving this old thread but I stumbled upon it when looking > for information on whether anyone ever tried to export > device_is_dependent() before. > > I have a use-case where I think I need to check if two devices are > linked with a device link. I assume you'll prove me wrong. :) > > The reset-gpio driver is a reset control driver that mediates sharing > a reset GPIO (defined as a standardized reference fwnode property > "reset-gpios") among multiple users. reset-gpio auxiliary devices are > instantiated from reset core when it detects a consumer trying to get > a reset-control handle but there's no "resets" reference on the > consumer's fwnode, only "reset-gpios". > > It makes sense for reset core to create a device link between the > auxiliary reset-gpio device (the supplier) and the reset consumer > because this link is not described in firmware - only the link between > the consumer AND the GPIO controller. > > Now in order to make gpiolib-shared.c code (generic support for shared > GPIOs) happy, I need to handle the side effects of interacting with > reset-gpio which does a similar thing. To that end, I need to know if > given GPIO controller is a supplier of the consumer described in > firmware OR the auxiliary reset device which is only described with > software nodes. > > The logical thing to do would be to use "device_is_dependent()" but > this thread makes me think that won't fly. > > What should I do? What's the "correct" way of checking if two devices > are linked? I assume that fiddling with the supplier/consumer lists in > struct device is not it. fiddling with those lists is what device_is_dependent() does, but no, you really don't want to be doing that either manually or by calling this function. Who is creating this "link"? Can't that caller tell the gpio core this relationship at the same time as you are wanting to keep track of it too? thanks, greg k-h
On Thu, 27 Nov 2025 09:29:03 +0100, Greg KH <gregkh@linuxfoundation.org> said:
> On Wed, Nov 26, 2025 at 02:13:03PM +0100, Bartosz Golaszewski wrote:
>> The logical thing to do would be to use "device_is_dependent()" but
>> this thread makes me think that won't fly.
>>
>> What should I do? What's the "correct" way of checking if two devices
>> are linked? I assume that fiddling with the supplier/consumer lists in
>> struct device is not it.
>
> fiddling with those lists is what device_is_dependent() does, but no,
> you really don't want to be doing that either manually or by calling
> this function.
>
> Who is creating this "link"? Can't that caller tell the gpio core this
> relationship at the same time as you are wanting to keep track of it
> too?
>
The link would be created in reset core.
Let's consider the following:
GPIO Consumer A ---> reset-gpio ---> |
| GPIO Controller pin X
GPIO Consumer B -------------------> |
The GPIO core will scan the device tree and realize that A and B share the
same pin. The reset-gpio device is not described in firmware, it will be
created only when A requests a reset control. When it, on behalf of consumer A,
requests pin X, GPIO core can not associate the link between consumer A and
pin X with the link between reset-gpio and pin X because there's no such
reference in firmware nodes between consumer A and reset-gpio. To GPIO, these
are two separate references to the same pin. Only reset core knows about A
being the consumer of reset-gpio.
We could add a function in reset like:
struct device *reset_gpio_to_reset_device(struct device *dev);
which would return the actual consumer of pin X for a device we identified as
reset-gpio (for instance: with device_is_compatible(dev, "reset-gpio")) but
that would be adding a symbol for a corner case and a single user and for
which the relevant information already exists and could easily be retrieved
from existing device links.
I hope that explains it better.
To answer your question: the caller can't tell GPIO about this relationship,
GPIO would have to ask reset about it but having a dedicated symbol for this
doesn't really sound like the best approach.
Bartosz
On Thu, Nov 27, 2025 at 05:19:19AM -0800, Bartosz Golaszewski wrote: > On Thu, 27 Nov 2025 09:29:03 +0100, Greg KH <gregkh@linuxfoundation.org> said: > > On Wed, Nov 26, 2025 at 02:13:03PM +0100, Bartosz Golaszewski wrote: > >> The logical thing to do would be to use "device_is_dependent()" but > >> this thread makes me think that won't fly. > >> > >> What should I do? What's the "correct" way of checking if two devices > >> are linked? I assume that fiddling with the supplier/consumer lists in > >> struct device is not it. > > > > fiddling with those lists is what device_is_dependent() does, but no, > > you really don't want to be doing that either manually or by calling > > this function. > > > > Who is creating this "link"? Can't that caller tell the gpio core this > > relationship at the same time as you are wanting to keep track of it > > too? > > > > The link would be created in reset core. > > Let's consider the following: > > GPIO Consumer A ---> reset-gpio ---> | > | GPIO Controller pin X > GPIO Consumer B -------------------> | > > The GPIO core will scan the device tree and realize that A and B share the > same pin. The reset-gpio device is not described in firmware, it will be > created only when A requests a reset control. When it, on behalf of consumer A, > requests pin X, GPIO core can not associate the link between consumer A and > pin X with the link between reset-gpio and pin X because there's no such > reference in firmware nodes between consumer A and reset-gpio. To GPIO, these > are two separate references to the same pin. Only reset core knows about A > being the consumer of reset-gpio. > > We could add a function in reset like: > > struct device *reset_gpio_to_reset_device(struct device *dev); > > which would return the actual consumer of pin X for a device we identified as > reset-gpio (for instance: with device_is_compatible(dev, "reset-gpio")) but > that would be adding a symbol for a corner case and a single user and for > which the relevant information already exists and could easily be retrieved > from existing device links. > > I hope that explains it better. Yes it does, thanks. > To answer your question: the caller can't tell GPIO about this relationship, > GPIO would have to ask reset about it but having a dedicated symbol for this > doesn't really sound like the best approach. Ah, ick, no it doesn't. I really don't know what to suggest here, sorry. greg k-h
On Wed, Dec 3, 2025 at 6:01 PM Greg KH <gregkh@linuxfoundation.org> wrote: > > > > I hope that explains it better. > > Yes it does, thanks. > > > To answer your question: the caller can't tell GPIO about this relationship, > > GPIO would have to ask reset about it but having a dedicated symbol for this > > doesn't really sound like the best approach. > > Ah, ick, no it doesn't. I really don't know what to suggest here, > sorry. > I found a viable workaround inside GPIO where I create another GPIO shared proxy for the potential reset-gpio device. So that if there are two users of the same "reset-gpios", we create three proxies in total: one for user 1, one for user 2 and another one for the reset-gpio device which may or may not be instantiated. I think that the best approach would still be having access to device_is_dependent(). I don't quite get why read-only inspecting device links outside of PM or driver core should really be a bad thing, but I can live without it, I guess. Bart
On Mon, Nov 27, 2023 at 7:20 PM Greg KH <gregkh@linuxfoundation.org> wrote: [Maxime] > > So, a committer just applied this to drm-misc-fixes without your > > approval. That was me, mea culpa. I learned a lesson. Or two. > Wait, why exactly is this needed? Nothing outside of the driver core > should be needing this function, it shouldn't be public at all (I missed > that before.) > > So please, revert it for now, let's figure out why DRM thinks this is > needed for it's devices, and yet no other bus/subsystem does. I'm preparing a revert series back to the original patch causing the issue so we can clear the original bug out of the way, take a step back and fix this properly. Yours, Linus Walleij
© 2016 - 2025 Red Hat, Inc.