mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@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: Tue, 21 Feb 2023 11:08:18 +0100	[thread overview]
Message-ID: <20230221100818.GC10447@pengutronix.de> (raw)
In-Reply-To: <20230217203148.2902038-1-a.fatoum@pengutronix.de>

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.

> +
> +		if (enable == -1) {
> +			printf("%s(0x%p)%s\n", name, of_fixup->context,
> +			       of_fixup->disabled ? " [DISABELD]" : "");

s/DISABELD/DISABLED/

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)"?

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.

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-02-21 10:09 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 [this message]
2023-04-20 20:15   ` Ahmad Fatoum

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=20230221100818.GC10447@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=danek.brat@gmail.com \
    /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