Hello Sascha, On 21.02.23 11:08, Sascha Hauer wrote: > On Fri, Feb 17, 2023 at 09:31:48PM +0100, Ahmad Fatoum wrote: >> For debugging, it can be useful to disable a fixup to rule out it causing >> issues. For platforms supporting kallsyms, we can readily allow enabling >> and disabling fixups by name, so let's add a command that does just that. >> >> Suggested-by: Daniel Brát <danek.brat@xxxxxxxxx> >> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> >> --- >> commands/Kconfig | 15 ++++++++ >> commands/Makefile | 1 + >> commands/of_fixup.c | 86 +++++++++++++++++++++++++++++++++++++++++++++ >> common/kallsyms.c | 8 ++--- >> common/oftree.c | 17 +++++---- >> drivers/of/Kconfig | 6 ++++ >> include/kallsyms.h | 4 +++ >> include/of.h | 10 ++++++ >> 8 files changed, 137 insertions(+), 10 deletions(-) >> create mode 100644 commands/of_fixup.c >> >> +static int do_of_fixup(int argc, char *argv[]) >> +{ >> + struct of_fixup *of_fixup; >> + int opt, enable = -1; >> + >> + while ((opt = getopt(argc, argv, "ed")) > 0) { >> + switch (opt) { >> + case 'e': >> + enable = 1; >> + break; >> + case 'd': >> + enable = 0; >> + break; >> + default: >> + return COMMAND_ERROR_USAGE; >> + } >> + } >> + >> + argv += optind; >> + argc -= optind; >> + >> + if ((enable < 0 && argc > 0) || (enable >= 0 && argc == 0)) >> + return COMMAND_ERROR_USAGE; >> + >> + list_for_each_entry(of_fixup, &of_fixup_list, list) { >> + int i; >> + ulong addr = (ulong)of_fixup->fixup; >> + char sym[KSYM_SYMBOL_LEN]; >> + const char *name; >> + >> + name = kallsyms_lookup(addr, NULL, NULL, NULL, sym); >> + if (!name) { >> + sprintf(sym, "<0x%lx>", addr); >> + name = sym; >> + } > > Does this fallback make sense? kallsyms_lookup() should always return a > name, otherwise something is really wrong. Fixup may be registered within a module, which barebox kallsyms doesn't yet support. > >> + >> + if (enable == -1) { >> + printf("%s(0x%p)%s\n", name, of_fixup->context, >> + of_fixup->disabled ? " [DISABELD]" : ""); > > s/DISABELD/DISABLED/ Will fix. > We can have the same fixup function with different contexts, that's why > you print the context pointer here. Shouldn't we then have a way to > disable a specific fixup, like "of_fixup -d mtd_partition_fixup(0x2fed7a00)"? The command is meant for quick testing. To make sense of context pointers, a map file or an instrumented barebox is needed, so it's not that useful to be able to filter by context pointer IMO. > > Sascha > >> +config OF_FIXUP_TOGGLE >> + bool >> + help >> + This is selected when some device tree fixups may be selectively >> + disabled. > > Why does this have an extra config option? It doesn't look like it's > saving a lot of binary space. I can drop it, sure. Cheers, Ahmad > > Sascha > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |