diff mbox

[U-Boot,03/18] dm: timer: handle being called before dm_root is ready

Message ID 1502904758-7562-4-git-send-email-philipp.tomsich@theobroma-systems.com
State Superseded
Delegated to: Philipp Tomsich
Headers show

Commit Message

Philipp Tomsich Aug. 16, 2017, 5:32 p.m. UTC
When used with bootstage recording, dm_timer_init may be called
surprisingly early: i.e. before dm_root is ready. To deal with
this case, we explicitly check for this condition and return
-EAGAIN to the caller (refer to drivers/timer/rockchip_timer.c
for a case where this is needed/used).

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---

 drivers/timer/timer-uclass.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Simon Glass Aug. 26, 2017, 1:39 p.m. UTC | #1
On 16 August 2017 at 11:32, Philipp Tomsich
<philipp.tomsich@theobroma-systems.com> wrote:
> When used with bootstage recording, dm_timer_init may be called
> surprisingly early: i.e. before dm_root is ready. To deal with
> this case, we explicitly check for this condition and return
> -EAGAIN to the caller (refer to drivers/timer/rockchip_timer.c
> for a case where this is needed/used).
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
>
>  drivers/timer/timer-uclass.c | 7 +++++++
>  1 file changed, 7 insertions(+)

We should be using the early timer in this situation but I suppose
this is useful for boards that don't have one.

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

Patch

diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 62d6f0b..45397b2 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -92,6 +92,13 @@  int notrace dm_timer_init(void)
 	if (gd->timer)
 		return 0;
 
+	/*
+	 * Directly access gd->dm_root to suppress error messages, if the
+	 * virtual root driver does not yet exist.
+	 */
+	if (gd->dm_root == NULL)
+		return -EAGAIN;
+
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	/* Check for a chosen timer to be used for tick */
 	node = ofnode_get_chosen_node("tick-timer");