All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] doc: dm: clarify activation.
@ 2022-08-04 17:57 Michal Suchanek
  2022-08-04 19:22 ` Simon Glass
  0 siblings, 1 reply; 6+ messages in thread
From: Michal Suchanek @ 2022-08-04 17:57 UTC (permalink / raw)
  To: u-boot; +Cc: Michal Suchanek, Marek Vasut, Simon Glass, AKASHI Takahiro

Explain when devices should get activated.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 doc/develop/driver-model/design.rst | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst
index 5f33f9fbb3..c925d21b24 100644
--- a/doc/develop/driver-model/design.rst
+++ b/doc/develop/driver-model/design.rst
@@ -794,8 +794,26 @@ fall afoul of this rule.
 Activation/probe
 ^^^^^^^^^^^^^^^^
 
-When a device needs to be used, U-Boot activates it, by first reading ofdata
-as above and then following these steps (see device_probe()):
+To save resources devices in U-Boot are probed lazily. U-Boot is a bootloader,
+not an operating system. Many devices are never used during an U-Boot run, and
+probing them takes time, requires memory, may add delays to the main loop, etc.
+
+The device should be probed by the uclass code. Different uclasses are
+different but two common use cases can be seen:
+
+   1. The uclass is asked to look up a specific device, such as SPI bus 0,
+   first chip select - in this case the returned device should be
+   activated.
+
+   2. The uclass is asked to perform a specific function on any device that
+   supports it, eg. reset the board using any sysreset that can be found -
+   for this case the core uclass code provides iterators that activate
+   each device before returning it, and the uclass typically implements a
+   walk function that iterates over all devices of the uclass and tries
+   to perform the requested function on each in turn until succesful.
+
+To activate a device U-Boot first reads ofdata as above and then follows these
+steps (see device_probe()):
 
    1. All parent devices are probed. It is not possible to activate a device
    unless its predecessors (all the way up to the root device) are activated.
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] doc: dm: clarify activation.
  2022-08-04 17:57 [PATCH] doc: dm: clarify activation Michal Suchanek
@ 2022-08-04 19:22 ` Simon Glass
  2022-08-04 19:42   ` Michal Suchánek
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2022-08-04 19:22 UTC (permalink / raw)
  To: Michal Suchanek; +Cc: U-Boot Mailing List, Marek Vasut, AKASHI Takahiro

Hi Michal,

On Thu, 4 Aug 2022 at 11:58, Michal Suchanek <msuchanek@suse.de> wrote:
>
> Explain when devices should get activated.
>
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
>  doc/develop/driver-model/design.rst | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Much appreciated!

one note below

>
> diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst
> index 5f33f9fbb3..c925d21b24 100644
> --- a/doc/develop/driver-model/design.rst
> +++ b/doc/develop/driver-model/design.rst
> @@ -794,8 +794,26 @@ fall afoul of this rule.
>  Activation/probe
>  ^^^^^^^^^^^^^^^^
>
> -When a device needs to be used, U-Boot activates it, by first reading ofdata
> -as above and then following these steps (see device_probe()):
> +To save resources devices in U-Boot are probed lazily. U-Boot is a bootloader,
> +not an operating system. Many devices are never used during an U-Boot run, and
> +probing them takes time, requires memory, may add delays to the main loop, etc.
> +
> +The device should be probed by the uclass code. Different uclasses are

or the device code (e.g. device_get_child())

BTW probing a child probes all its parents automatically (that is said
elsewhere I think).

> +different but two common use cases can be seen:
> +
> +   1. The uclass is asked to look up a specific device, such as SPI bus 0,
> +   first chip select - in this case the returned device should be
> +   activated.
> +
> +   2. The uclass is asked to perform a specific function on any device that
> +   supports it, eg. reset the board using any sysreset that can be found -
> +   for this case the core uclass code provides iterators that activate
> +   each device before returning it, and the uclass typically implements a
> +   walk function that iterates over all devices of the uclass and tries
> +   to perform the requested function on each in turn until succesful.
> +
> +To activate a device U-Boot first reads ofdata as above and then follows these
> +steps (see device_probe()):
>
>     1. All parent devices are probed. It is not possible to activate a device
>     unless its predecessors (all the way up to the root device) are activated.
> --
> 2.37.1
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] doc: dm: clarify activation.
  2022-08-04 19:22 ` Simon Glass
@ 2022-08-04 19:42   ` Michal Suchánek
  2022-08-04 20:30     ` Simon Glass
  0 siblings, 1 reply; 6+ messages in thread
From: Michal Suchánek @ 2022-08-04 19:42 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List, Marek Vasut, AKASHI Takahiro

On Thu, Aug 04, 2022 at 01:22:53PM -0600, Simon Glass wrote:
> Hi Michal,
> 
> On Thu, 4 Aug 2022 at 11:58, Michal Suchanek <msuchanek@suse.de> wrote:
> >
> > Explain when devices should get activated.
> >
> > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > ---
> >  doc/develop/driver-model/design.rst | 22 ++++++++++++++++++++--
> >  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> Much appreciated!
> 
> one note below
> 
> >
> > diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst
> > index 5f33f9fbb3..c925d21b24 100644
> > --- a/doc/develop/driver-model/design.rst
> > +++ b/doc/develop/driver-model/design.rst
> > @@ -794,8 +794,26 @@ fall afoul of this rule.
> >  Activation/probe
> >  ^^^^^^^^^^^^^^^^
> >
> > -When a device needs to be used, U-Boot activates it, by first reading ofdata
> > -as above and then following these steps (see device_probe()):
> > +To save resources devices in U-Boot are probed lazily. U-Boot is a bootloader,
> > +not an operating system. Many devices are never used during an U-Boot run, and
> > +probing them takes time, requires memory, may add delays to the main loop, etc.
> > +
> > +The device should be probed by the uclass code. Different uclasses are
> 
> or the device code (e.g. device_get_child())

Can you elaborate a bit more, please?

This change is the reasult of some previous discussion about the device
activation with Marek.

The device activation is really difficult to understand for people who
did not participate in designing the DM, and is probably quite specific
to U-Boot.

> 
> BTW probing a child probes all its parents automatically (that is said
> elsewhere I think).

Yes, right below this part.

Thanks

Michal

> 
> > +different but two common use cases can be seen:
> > +
> > +   1. The uclass is asked to look up a specific device, such as SPI bus 0,
> > +   first chip select - in this case the returned device should be
> > +   activated.
> > +
> > +   2. The uclass is asked to perform a specific function on any device that
> > +   supports it, eg. reset the board using any sysreset that can be found -
> > +   for this case the core uclass code provides iterators that activate
> > +   each device before returning it, and the uclass typically implements a
> > +   walk function that iterates over all devices of the uclass and tries
> > +   to perform the requested function on each in turn until succesful.
> > +
> > +To activate a device U-Boot first reads ofdata as above and then follows these
> > +steps (see device_probe()):
> >
> >     1. All parent devices are probed. It is not possible to activate a device
> >     unless its predecessors (all the way up to the root device) are activated.
> > --
> > 2.37.1
> >
> 
> Regards,
> Simon

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] doc: dm: clarify activation.
  2022-08-04 19:42   ` Michal Suchánek
@ 2022-08-04 20:30     ` Simon Glass
  2022-08-20  6:27       ` Heinrich Schuchardt
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2022-08-04 20:30 UTC (permalink / raw)
  To: Michal Suchánek; +Cc: U-Boot Mailing List, Marek Vasut, AKASHI Takahiro

Hi Michal,

On Thu, 4 Aug 2022 at 13:42, Michal Suchánek <msuchanek@suse.de> wrote:
>
> On Thu, Aug 04, 2022 at 01:22:53PM -0600, Simon Glass wrote:
> > Hi Michal,
> >
> > On Thu, 4 Aug 2022 at 11:58, Michal Suchanek <msuchanek@suse.de> wrote:
> > >
> > > Explain when devices should get activated.
> > >
> > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > > ---
> > >  doc/develop/driver-model/design.rst | 22 ++++++++++++++++++++--
> > >  1 file changed, 20 insertions(+), 2 deletions(-)
> >
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> >
> > Much appreciated!
> >
> > one note below
> >
> > >
> > > diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst
> > > index 5f33f9fbb3..c925d21b24 100644
> > > --- a/doc/develop/driver-model/design.rst
> > > +++ b/doc/develop/driver-model/design.rst
> > > @@ -794,8 +794,26 @@ fall afoul of this rule.
> > >  Activation/probe
> > >  ^^^^^^^^^^^^^^^^
> > >
> > > -When a device needs to be used, U-Boot activates it, by first reading ofdata
> > > -as above and then following these steps (see device_probe()):
> > > +To save resources devices in U-Boot are probed lazily. U-Boot is a bootloader,
> > > +not an operating system. Many devices are never used during an U-Boot run, and
> > > +probing them takes time, requires memory, may add delays to the main loop, etc.
> > > +
> > > +The device should be probed by the uclass code. Different uclasses are
> >
> > or the device code (e.g. device_get_child())
>
> Can you elaborate a bit more, please?

I mean that we can use 'device' code to probe, as well as the 'uclass'
code. The function I cite is an example of that, but actually a better
one is device_find_global_by_ofnode()

>
> This change is the reasult of some previous discussion about the device
> activation with Marek.
>
> The device activation is really difficult to understand for people who
> did not participate in designing the DM, and is probably quite specific
> to U-Boot.

OK, well good to have it. I wish more people would do what you have
done here, i.e. go back and update the docs to clarify things that you
found confusing / inadequate.

>
> >
> > BTW probing a child probes all its parents automatically (that is said
> > elsewhere I think).
>
> Yes, right below this part.
>
> Thanks
>
> Michal

OK

Regards,
Simon


>
> >
> > > +different but two common use cases can be seen:
> > > +
> > > +   1. The uclass is asked to look up a specific device, such as SPI bus 0,
> > > +   first chip select - in this case the returned device should be
> > > +   activated.
> > > +
> > > +   2. The uclass is asked to perform a specific function on any device that
> > > +   supports it, eg. reset the board using any sysreset that can be found -
> > > +   for this case the core uclass code provides iterators that activate
> > > +   each device before returning it, and the uclass typically implements a
> > > +   walk function that iterates over all devices of the uclass and tries
> > > +   to perform the requested function on each in turn until succesful.
> > > +
> > > +To activate a device U-Boot first reads ofdata as above and then follows these
> > > +steps (see device_probe()):
> > >
> > >     1. All parent devices are probed. It is not possible to activate a device
> > >     unless its predecessors (all the way up to the root device) are activated.
> > > --
> > > 2.37.1
> > >
> >
> > Regards,
> > Simon

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] doc: dm: clarify activation.
  2022-08-04 20:30     ` Simon Glass
@ 2022-08-20  6:27       ` Heinrich Schuchardt
  2022-08-20  6:40         ` Michal Suchánek
  0 siblings, 1 reply; 6+ messages in thread
From: Heinrich Schuchardt @ 2022-08-20  6:27 UTC (permalink / raw)
  To: Simon Glass, Michal Suchánek
  Cc: U-Boot Mailing List, Marek Vasut, AKASHI Takahiro

On 8/4/22 22:30, Simon Glass wrote:
> Hi Michal,
>
> On Thu, 4 Aug 2022 at 13:42, Michal Suchánek <msuchanek@suse.de> wrote:
>>
>> On Thu, Aug 04, 2022 at 01:22:53PM -0600, Simon Glass wrote:
>>> Hi Michal,
>>>
>>> On Thu, 4 Aug 2022 at 11:58, Michal Suchanek <msuchanek@suse.de> wrote:
>>>>
>>>> Explain when devices should get activated.
>>>>
>>>> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
>>>> ---
>>>>   doc/develop/driver-model/design.rst | 22 ++++++++++++++++++++--
>>>>   1 file changed, 20 insertions(+), 2 deletions(-)
>>>
>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>
>>> Much appreciated!
>>>
>>> one note below
>>>
>>>>
>>>> diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst
>>>> index 5f33f9fbb3..c925d21b24 100644
>>>> --- a/doc/develop/driver-model/design.rst
>>>> +++ b/doc/develop/driver-model/design.rst
>>>> @@ -794,8 +794,26 @@ fall afoul of this rule.
>>>>   Activation/probe
>>>>   ^^^^^^^^^^^^^^^^
>>>>
>>>> -When a device needs to be used, U-Boot activates it, by first reading ofdata
>>>> -as above and then following these steps (see device_probe()):
>>>> +To save resources devices in U-Boot are probed lazily. U-Boot is a bootloader,
>>>> +not an operating system. Many devices are never used during an U-Boot run, and
>>>> +probing them takes time, requires memory, may add delays to the main loop, etc.
>>>> +
>>>> +The device should be probed by the uclass code. Different uclasses are

When merging I will put the following here:

The device should be probed by the uclass code or generic device code
(e.g. device_find_global_by_ofnode()). Uclasses differ but two common
use cases can be seen:

Best regards

Heinrich

>>>
>>> or the device code (e.g. device_get_child())
>>
>> Can you elaborate a bit more, please?
>
> I mean that we can use 'device' code to probe, as well as the 'uclass'
> code. The function I cite is an example of that, but actually a better
> one is device_find_global_by_ofnode()
>
>>
>> This change is the reasult of some previous discussion about the device
>> activation with Marek.
>>
>> The device activation is really difficult to understand for people who
>> did not participate in designing the DM, and is probably quite specific
>> to U-Boot.
>
> OK, well good to have it. I wish more people would do what you have
> done here, i.e. go back and update the docs to clarify things that you
> found confusing / inadequate.
>
>>
>>>
>>> BTW probing a child probes all its parents automatically (that is said
>>> elsewhere I think).
>>
>> Yes, right below this part.
>>
>> Thanks
>>
>> Michal
>
> OK
>
> Regards,
> Simon
>
>
>>
>>>
>>>> +different but two common use cases can be seen:
>>>> +
>>>> +   1. The uclass is asked to look up a specific device, such as SPI bus 0,
>>>> +   first chip select - in this case the returned device should be
>>>> +   activated.
>>>> +
>>>> +   2. The uclass is asked to perform a specific function on any device that
>>>> +   supports it, eg. reset the board using any sysreset that can be found -
>>>> +   for this case the core uclass code provides iterators that activate
>>>> +   each device before returning it, and the uclass typically implements a
>>>> +   walk function that iterates over all devices of the uclass and tries
>>>> +   to perform the requested function on each in turn until succesful.
>>>> +
>>>> +To activate a device U-Boot first reads ofdata as above and then follows these
>>>> +steps (see device_probe()):
>>>>
>>>>      1. All parent devices are probed. It is not possible to activate a device
>>>>      unless its predecessors (all the way up to the root device) are activated.
>>>> --
>>>> 2.37.1
>>>>
>>>
>>> Regards,
>>> Simon


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] doc: dm: clarify activation.
  2022-08-20  6:27       ` Heinrich Schuchardt
@ 2022-08-20  6:40         ` Michal Suchánek
  0 siblings, 0 replies; 6+ messages in thread
From: Michal Suchánek @ 2022-08-20  6:40 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Simon Glass, U-Boot Mailing List, Marek Vasut, AKASHI Takahiro

Hello,

On Sat, Aug 20, 2022 at 08:27:05AM +0200, Heinrich Schuchardt wrote:
> On 8/4/22 22:30, Simon Glass wrote:
> > Hi Michal,
> > 
> > On Thu, 4 Aug 2022 at 13:42, Michal Suchánek <msuchanek@suse.de> wrote:
> > > 
> > > On Thu, Aug 04, 2022 at 01:22:53PM -0600, Simon Glass wrote:
> > > > Hi Michal,
> > > > 
> > > > On Thu, 4 Aug 2022 at 11:58, Michal Suchanek <msuchanek@suse.de> wrote:
> > > > > 
> > > > > Explain when devices should get activated.
> > > > > 
> > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > > > > ---
> > > > >   doc/develop/driver-model/design.rst | 22 ++++++++++++++++++++--
> > > > >   1 file changed, 20 insertions(+), 2 deletions(-)
> > > > 
> > > > Reviewed-by: Simon Glass <sjg@chromium.org>
> > > > 
> > > > Much appreciated!
> > > > 
> > > > one note below
> > > > 
> > > > > 
> > > > > diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst
> > > > > index 5f33f9fbb3..c925d21b24 100644
> > > > > --- a/doc/develop/driver-model/design.rst
> > > > > +++ b/doc/develop/driver-model/design.rst
> > > > > @@ -794,8 +794,26 @@ fall afoul of this rule.
> > > > >   Activation/probe
> > > > >   ^^^^^^^^^^^^^^^^
> > > > > 
> > > > > -When a device needs to be used, U-Boot activates it, by first reading ofdata
> > > > > -as above and then following these steps (see device_probe()):
> > > > > +To save resources devices in U-Boot are probed lazily. U-Boot is a bootloader,
> > > > > +not an operating system. Many devices are never used during an U-Boot run, and
> > > > > +probing them takes time, requires memory, may add delays to the main loop, etc.
> > > > > +
> > > > > +The device should be probed by the uclass code. Different uclasses are
> 
> When merging I will put the following here:
> 
> The device should be probed by the uclass code or generic device code
> (e.g. device_find_global_by_ofnode()). Uclasses differ but two common
> use cases can be seen:

I wanted to look at this direct device lookup, and send a v2 when I am
done with it. I am currently trying to figure out how (if at all) the
pins and clocks required by i2c devices are activated, and I suppose
this direct lookup would be related.

Noneteless, if you can fix up the patch right away that's great.

Thanks

Michal

> 
> Best regards
> 
> Heinrich
> 
> > > > 
> > > > or the device code (e.g. device_get_child())
> > > 
> > > Can you elaborate a bit more, please?
> > 
> > I mean that we can use 'device' code to probe, as well as the 'uclass'
> > code. The function I cite is an example of that, but actually a better
> > one is device_find_global_by_ofnode()
> > 
> > > 
> > > This change is the reasult of some previous discussion about the device
> > > activation with Marek.
> > > 
> > > The device activation is really difficult to understand for people who
> > > did not participate in designing the DM, and is probably quite specific
> > > to U-Boot.
> > 
> > OK, well good to have it. I wish more people would do what you have
> > done here, i.e. go back and update the docs to clarify things that you
> > found confusing / inadequate.
> > 
> > > 
> > > > 
> > > > BTW probing a child probes all its parents automatically (that is said
> > > > elsewhere I think).
> > > 
> > > Yes, right below this part.
> > > 
> > > Thanks
> > > 
> > > Michal
> > 
> > OK
> > 
> > Regards,
> > Simon
> > 
> > 
> > > 
> > > > 
> > > > > +different but two common use cases can be seen:
> > > > > +
> > > > > +   1. The uclass is asked to look up a specific device, such as SPI bus 0,
> > > > > +   first chip select - in this case the returned device should be
> > > > > +   activated.
> > > > > +
> > > > > +   2. The uclass is asked to perform a specific function on any device that
> > > > > +   supports it, eg. reset the board using any sysreset that can be found -
> > > > > +   for this case the core uclass code provides iterators that activate
> > > > > +   each device before returning it, and the uclass typically implements a
> > > > > +   walk function that iterates over all devices of the uclass and tries
> > > > > +   to perform the requested function on each in turn until succesful.
> > > > > +
> > > > > +To activate a device U-Boot first reads ofdata as above and then follows these
> > > > > +steps (see device_probe()):
> > > > > 
> > > > >      1. All parent devices are probed. It is not possible to activate a device
> > > > >      unless its predecessors (all the way up to the root device) are activated.
> > > > > --
> > > > > 2.37.1
> > > > > 
> > > > 
> > > > Regards,
> > > > Simon
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-20  6:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04 17:57 [PATCH] doc: dm: clarify activation Michal Suchanek
2022-08-04 19:22 ` Simon Glass
2022-08-04 19:42   ` Michal Suchánek
2022-08-04 20:30     ` Simon Glass
2022-08-20  6:27       ` Heinrich Schuchardt
2022-08-20  6:40         ` Michal Suchánek

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.