Skip to content

Improve logging on missing uclass

Julien Stephan u-boot 2 versions – In review

Get series with b4
b4 am 20260824-improve-logging-on-missing-uclass-v2-0-4bee2cdff72b@baylibre.com change-id 20260806-improve-logging-on-missing-uclass-a76c46acfa13

Versions newest first

  1. v2 Latest3 patches 5 repliesIn review
  2. v12 patches 6 repliesSuperseded

Changes in v2 from the cover letter

- dm: replace the boolean DM_WARN option with a per-stage log verbosity
choice (DM_NONE / DM_ERR / DM_WARN) and add a dm_err() helper, rather
than logging the missing-uclass message with a hardcoded log() call
(suggested by Simon)
- dm: de-duplicate the util.h helpers to only select the log level
(suggested by Simon)
- dm: split the change into the generic mechanism and its user in uclass.c
- dm: shorten the missing-uclass message to limit the SPL/TPL size overhead
- initcall: use the %dE format so no dangling ": " is printed when
ERRNO_STR is disabled, and give INITCALL_EVT() the same treatment
- Link to v1: https://patch.msgid.link/20260806-improve-logging-on-missing-uclass-v1-0-d477f0054f48@baylibre.com

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3dm: add dm_err() and a driver model log verbosity choicedrivers/core/Kconfig include/dm/util.h+79 -151 reply
2/3dm: uclass: use dm_err() for a missing uclassdrivers/core/uclass.c+1 -21 reply
3/3initcall: initcall_evt: display error code on errorinclude/initcall.h+8 -61 reply

Reviews trailers per patch

2 of 3 patches have a Reviewed-by or Acked-by.

PatchSimon Glass
1/3R-b
2/3
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/3] Improve logging on missing uclass

While writing a MISC driver, I forgot to enable CONFIG_MISC. The only thing I got at boot was the following obscure error, with no hint about the root cause:

initcall_run_r(): initcall initr_dm() failed
### ERROR ### Please RESET the board ###

Commit 3346c87625b8 ("dm: Improve handling of a missing uclass") already tried to improve this case by returning a strange error code and adding a debug message. But since neither the debug message nor the return code are displayed by default, it was not very helpful in practice.

This series improves the situation in a few ways:
- a new dm_err() helper logs driver model errors at ERROR level, and the boolean DM_WARN option becomes a per-stage log verbosity choice (DM_NONE / DM_ERR / DM_WARN) with errors emitted by default. Note that a disabled level is not removed entirely but degraded to DEBUG level, which is compiled out by default, so even DM_NONE can still emit these messages as debug output when debug logging is enabled;
- the missing-uclass message now uses dm_err(), so it shows up by default, with a shorter string to limit the code-size overhead;
- the initcall failure now prints the actual error code (and its string when ERRNO_STR is enabled), for both INITCALL() and INITCALL_EVT().

The existing DM_DEBUG option is left as-is for now: it works differently (it adds -DDEBUG to drivers/core/ via the Makefile and is not phase-aware). Unifying it into the new choice, along with converting the DM core debug() statements to log() as suggested in the "To Do" section of doc/develop/logging.rst, could be a follow-up series.

---
Changes in v2:
- dm: replace the boolean DM_WARN option with a per-stage log verbosity
choice (DM_NONE / DM_ERR / DM_WARN) and add a dm_err() helper, rather
than logging the missing-uclass message with a hardcoded log() call
(suggested by Simon)
- dm: de-duplicate the util.h helpers to only select the log level
(suggested by Simon)
- dm: split the change into the generic mechanism and its user in uclass.c
- dm: shorten the missing-uclass message to limit the SPL/TPL size overhead
- initcall: use the %dE format so no dangling ": " is printed when
ERRNO_STR is disabled, and give INITCALL_EVT() the same treatment
- Link to v1: https://patch.msgid.link/20260806-improve-logging-on-missing-uclass-v1-0-d477f0054f48@baylibre.com

To: [email protected]
Cc: GSS_MTK_Uboot_upstream <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: "Markus Schneider-Pargmann (TI)" <[email protected]>
Cc: Julien Stephan <[email protected]>

---
Julien Stephan (3):
dm: add dm_err() and a driver model log verbosity choice
dm: uclass: use dm_err() for a missing uclass
initcall: initcall_evt: display error code on error

 drivers/core/Kconfig  | 75 ++++++++++++++++++++++++++++++++++++++++++---------
 drivers/core/uclass.c |  3 +--
 include/dm/util.h     | 19 +++++++++++--
 include/initcall.h    | 14 +++++-----
 4 files changed, 88 insertions(+), 23 deletions(-)

---
base-commit: f562ed02aa7ae4dc2775d90d2e6c40bab82e2715
change-id: 20260806-improve-logging-on-missing-uclass-a76c46acfa13

Best regards,

Signature · 1 line
Julien Stephan <[email protected]>