mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <sha@pengutronix.de>
Cc: barebox@lists.infradead.org, "Daniel Brát" <danek.brat@gmail.com>
Subject: Re: [PATCH] commands: add new of_fixup command to list and disable DT fixups
Date: Thu, 20 Apr 2023 22:15:10 +0200	[thread overview]
Message-ID: <f54e8087-0bf2-cbc9-5ed0-df06e2027350@pengutronix.de> (raw)
In-Reply-To: <20230221100818.GC10447@pengutronix.de>

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@gmail.com>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>  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 |




      reply	other threads:[~2023-04-20 20:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 20:31 Ahmad Fatoum
2023-02-21 10:08 ` Sascha Hauer
2023-04-20 20:15   ` Ahmad Fatoum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f54e8087-0bf2-cbc9-5ed0-df06e2027350@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=danek.brat@gmail.com \
    --cc=sha@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox