dm: core: Report bootph-pre-ram/sram node as pre-reloc after relocation
RFC 1/1 dm: core: Report bootph-pre-ram/sram node as pre-reloc after relocation
Devices for nodes with e.g. bootph-pre-ram are initialized three times.
1. At SPL stage (always bind and probe only if used)
2. At U-Boot proper pre-reloc (always bind and probe)
3. At U-Boot proper normal (always bind and probe only if used)
Change ofnode_pre_reloc to report a node with bootph-pre-ram/sram prop with a pre-reloc status only after U-Boot proper pre-relocation stage. This prevents the device from being probed at U-Boot proper pre-reloc.
---
I am not sure if U-Boot proper pre-reloc behaves like this by design and if there is some other way to signal that a device should not be probed during U-Boot proper pre-reloc stage if it has been probed at SPL stage.
For my use-case I added bootph-pre-ram prop to my RK8xx device node to make the PMIC usable in SPL. However, I have no need for this device to probe at U-Boot proper pre-reloc stage just after jumping out of TF-A. And moments later bind and probe yet again at U-Boot proper normal stage.
The bootph-pre-ram prop was used to have the device usable in SPL, else I could have used bootph-all or added bootph-some-ram prop to indicate use at U-Boot proper pre-reloc stage.
drivers/core/ofnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/core/ofnode.c +1 -1
@@ -1353,7 +1353,7 @@ bool ofnode_pre_reloc(ofnode node)*/ if (ofnode_read_bool (node,"bootph-pre-ram" ) ||ofnode_read_bool (node,"bootph-pre-sram" )) -return true; +return !!(gd->flags &GD_FLG_RELOC );if (IS_ENABLED (CONFIG_OF_TAG_MIGRATE )) {/* detect and handle old tags */
Signature · 1 line
2.41.0
Hi Jonas,
Quoted 16 lines · Jonas Karlman
Devices for nodes with e.g. bootph-pre-ram are initialized three times.
1. At SPL stage (always bind and probe only if used)
2. At U-Boot proper pre-reloc (always bind and probe)
3. At U-Boot proper normal (always bind and probe only if used)Change
ofnode_pre_relocto report a node with bootph-pre-ram/sram prop with a pre-reloc status only after U-Boot proper pre-relocation stage. This prevents the device from being probed at U-Boot proper pre-reloc.Signed-off-by Jonas Karlman <[email protected]>---
I am not sure if U-Boot proper pre-reloc behaves like this by design and if there is some other way to signal that a device should not be probed during U-Boot proper pre-reloc stage if it has been probed at SPL stage.
Quoted 8 lines
For my use-case I added bootph-pre-ram prop to my RK8xx device node to make the PMIC usable in SPL. However, I have no need for this device to probe at U-Boot proper pre-reloc stage just after jumping out of TF-A. And moments later bind and probe yet again at U-Boot proper normal stage.
The bootph-pre-ram prop was used to have the device usable in SPL, else I could have used bootph-all or added bootph-some-ram prop to indicate use at U-Boot proper pre-reloc stage.
This is changing how things work...we really need to have something explicit to use this new behaviour. Perhaps we can augment the binding in some way?
Quoted 9 lines
drivers/core/ofnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/core/ofnode.c +0
-0
drivers/core/ofnode.c bool ofnode_pre_reloc(ofnode node) · line 1356
Quoted 5 lines
drivers/core/ofnode.c +1
-1@@ -1353,7 +1353,7 @@ bool ofnode_pre_reloc(ofnode node)*/ if (ofnode_read_bool (node,"bootph-pre-ram" ) ||ofnode_read_bool (node,"bootph-pre-sram" )) -return true; +return !!(gd->flags &GD_FLG_RELOC );
I believe that the compiler knows how to convert 'gd->flags & GD_FLG_RELOC' into a bool, so !! is not needed.
Quoted 6 lines
drivers/core/ofnode.c +0
-1if (IS_ENABLED (CONFIG_OF_TAG_MIGRATE )) {/* detect and handle old tags */ --2.41.0
Regards,
Simon
Simon Glass
Reviewed-byHi Jonas,
Quoted 25 lines · Simon Glass
Hi Jonas,
Quoted 21 lines · Jonas Karlman
Devices for nodes with e.g. bootph-pre-ram are initialized three times.
1. At SPL stage (always bind and probe only if used)
2. At U-Boot proper pre-reloc (always bind and probe)
3. At U-Boot proper normal (always bind and probe only if used)Change
ofnode_pre_relocto report a node with bootph-pre-ram/sram prop with a pre-reloc status only after U-Boot proper pre-relocation stage. This prevents the device from being probed at U-Boot proper pre-reloc.Signed-off-by Jonas Karlman <[email protected]>---
I am not sure if U-Boot proper pre-reloc behaves like this by design and if there is some other way to signal that a device should not be probed during U-Boot proper pre-reloc stage if it has been probed at SPL stage.For my use-case I added bootph-pre-ram prop to my RK8xx device node to make the PMIC usable in SPL. However, I have no need for this device to probe at U-Boot proper pre-reloc stage just after jumping out of TF-A. And moments later bind and probe yet again at U-Boot proper normal stage.
Quoted 7 lines
Quoted 3 lines
The bootph-pre-ram prop was used to have the device usable in SPL, else I could have used bootph-all or added bootph-some-ram prop to indicate use at U-Boot proper pre-reloc stage.
This is changing how things work...we really need to have something explicit to use this new behaviour. Perhaps we can augment the binding in some way?
I had another look at this. The binding seems to be silent on this point, so I believe this patch is correct.
Quoted 5 lines
Quoted 5 lines
drivers/core/ofnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 20 lines
drivers/core/ofnode.c bool ofnode_pre_reloc(ofnode node) · line 1356
Quoted 10 lines
drivers/core/ofnode.c +1
-1@@ -1353,7 +1353,7 @@ bool ofnode_pre_reloc(ofnode node)*/ if (ofnode_read_bool (node,"bootph-pre-ram" ) ||ofnode_read_bool (node,"bootph-pre-sram" )) -return true; +return !!(gd->flags &GD_FLG_RELOC );I believe that the compiler knows how to convert '
gd->flags&GD_FLG_RELOC' into a bool, so !! is not needed.Quoted 6 lines
drivers/core/ofnode.c +0
-1if (IS_ENABLED (CONFIG_OF_TAG_MIGRATE )) {/* detect and handle old tags */ --2.41.0
Regards,
Simon
Hi Simon,
Quoted 32 lines · Simon Glass
Hi Jonas,
Quoted 29 lines · Simon Glass
Hi Jonas,
Quoted 24 lines · Jonas Karlman
Devices for nodes with e.g. bootph-pre-ram are initialized three times.
1. At SPL stage (always bind and probe only if used)
2. At U-Boot proper pre-reloc (always bind and probe)
3. At U-Boot proper normal (always bind and probe only if used)Change
ofnode_pre_relocto report a node with bootph-pre-ram/sram prop with a pre-reloc status only after U-Boot proper pre-relocation stage. This prevents the device from being probed at U-Boot proper pre-reloc.Signed-off-by Jonas Karlman <[email protected]>---
I am not sure if U-Boot proper pre-reloc behaves like this by design and if there is some other way to signal that a device should not be probed during U-Boot proper pre-reloc stage if it has been probed at SPL stage.For my use-case I added bootph-pre-ram prop to my RK8xx device node to make the PMIC usable in SPL. However, I have no need for this device to probe at U-Boot proper pre-reloc stage just after jumping out of TF-A. And moments later bind and probe yet again at U-Boot proper normal stage.
The bootph-pre-ram prop was used to have the device usable in SPL, else I could have used bootph-all or added bootph-some-ram prop to indicate use at U-Boot proper pre-reloc stage.
Quoted 6 lines
Quoted 3 lines
This is changing how things work...we really need to have something explicit to use this new behaviour. Perhaps we can augment the binding in some way?
I had another look at this. The binding seems to be silent on this point, so I believe this patch is correct.
I agree, the documentation for binding and also for driver model make this a little bit unclear:
"""
... Only drivers marked with DM_FLAG_PRE_RELOC or the device tree ‘bootph-all’ property are initialised prior to relocation. ...
...
It is possible to limit this to specific relocation steps, by using the more specialized ‘bootph-pre-ram’ and ‘bootph-pre-sram’ flags in the device tree node. For U-Boot proper you can use ‘bootph-some-ram’ which means that it will be processed (and a driver bound) in U-Boot proper prior to relocation, but will not be available in SPL or TPL. """
However the documentation for ofnode_pre_reloc contradict this a little:
"""
There are 4 settings currently in use
- bootph-some-ram: U-Boot proper pre-relocation only
- bootph-all: all phases
Existing platforms only use it to indicate nodes needed in SPL. Should probably be replaced by bootph-pre-ram for new platforms.
- bootph-pre-ram: SPL and U-Boot pre-relocation
- bootph-pre-sram: TPL and U-Boot pre-relocation
"""
Should I send a v2 of this and drop the "and U-Boot pre-relocation" from function doc comment? And do we need a new Kconfig option to enable or opt-out of this new/changed/fixed behavior?
Regards,
Jonas
Quoted 32 lines
Reviewed-by Simon Glass <[email protected]>Quoted 5 lines
Quoted 5 lines
drivers/core/ofnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 20 lines
drivers/core/ofnode.c bool ofnode_pre_reloc(ofnode node) · line 1356
Quoted 10 lines
drivers/core/ofnode.c +1
-1@@ -1353,7 +1353,7 @@ bool ofnode_pre_reloc(ofnode node)*/ if (ofnode_read_bool (node,"bootph-pre-ram" ) ||ofnode_read_bool (node,"bootph-pre-sram" )) -return true; +return !!(gd->flags &GD_FLG_RELOC );I believe that the compiler knows how to convert '
gd->flags&GD_FLG_RELOC' into a bool, so !! is not needed.Quoted 6 lines
drivers/core/ofnode.c +0
-1if (IS_ENABLED (CONFIG_OF_TAG_MIGRATE )) {/* detect and handle old tags */ --2.41.0
Regards,
Simon
Hi Jonas,
Quoted 71 lines · Jonas Karlman
Hi Simon,
Quoted 32 lines · Simon Glass
Hi Jonas,
Quoted 29 lines · Simon Glass
Hi Jonas,
Quoted 24 lines · Jonas Karlman
Devices for nodes with e.g. bootph-pre-ram are initialized three times.
1. At SPL stage (always bind and probe only if used)
2. At U-Boot proper pre-reloc (always bind and probe)
3. At U-Boot proper normal (always bind and probe only if used)Change
ofnode_pre_relocto report a node with bootph-pre-ram/sram prop with a pre-reloc status only after U-Boot proper pre-relocation stage. This prevents the device from being probed at U-Boot proper pre-reloc.Signed-off-by Jonas Karlman <[email protected]>---
I am not sure if U-Boot proper pre-reloc behaves like this by design and if there is some other way to signal that a device should not be probed during U-Boot proper pre-reloc stage if it has been probed at SPL stage.For my use-case I added bootph-pre-ram prop to my RK8xx device node to make the PMIC usable in SPL. However, I have no need for this device to probe at U-Boot proper pre-reloc stage just after jumping out of TF-A. And moments later bind and probe yet again at U-Boot proper normal stage.
The bootph-pre-ram prop was used to have the device usable in SPL, else I could have used bootph-all or added bootph-some-ram prop to indicate use at U-Boot proper pre-reloc stage.
Quoted 6 lines
Quoted 3 lines
This is changing how things work...we really need to have something explicit to use this new behaviour. Perhaps we can augment the binding in some way?
I had another look at this. The binding seems to be silent on this point, so I believe this patch is correct.
I agree, the documentation for binding and also for driver model make this a little bit unclear:
"""
... Only drivers marked withDM_FLAG_PRE_RELOCor the device tree ‘bootph-all’ property are initialised prior to relocation. ......
It is possible to limit this to specific relocation steps, by using the more specialized ‘bootph-pre-ram’ and ‘bootph-pre-sram’ flags in the device tree node. For U-Boot proper you can use ‘bootph-some-ram’ which means that it will be processed (and a driver bound) in U-Boot proper prior to relocation, but will not be available in SPL or TPL. """
However the documentation for
ofnode_pre_reloccontradict this a little:"""
There are 4 settings currently in use
- bootph-some-ram: U-Boot proper pre-relocation only
- bootph-all: all phases
Existing platforms only use it to indicate nodes needed in SPL. Should probably be replaced by bootph-pre-ram for new platforms.
- bootph-pre-ram: SPL and U-Boot pre-relocation
- bootph-pre-sram: TPL and U-Boot pre-relocation
"""
Quoted 3 lines
Should I send a v2 of this and drop the "and U-Boot pre-relocation" from function doc comment? And do we need a new
Kconfigoption to enable or opt-out of this new/changed/fixed behavior?
Yes it needs doc updates but I don't think a new Kconfig option is warranted at this point. We just need to clearly document how these options are used.
Regards,
SImon