All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Daniel Walker <danielwa@cisco.com>, Will Deacon <will@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>,
	Andrew Morton <akpm@linux-foundation.org>,
	Pratyush Brahma <quic_pbrahma@quicinc.com>,
	Tomas Mudrunka <tomas.mudrunka@gmail.com>,
	Sean Anderson <sean.anderson@seco.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>
Cc: "xe-linux-external@cisco.com" <xe-linux-external@cisco.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 7/8] of: replace command line handling
Date: Thu, 23 Nov 2023 06:39:23 +0000	[thread overview]
Message-ID: <4fa98c8f-076f-4503-b46d-515b8c56bb6d@csgroup.eu> (raw)
In-Reply-To: <20231110013817.2378507-8-danielwa@cisco.com>



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> Rob Herring has complained about this section of code. I removed the

This kind of considerations shouldn't appear in the commit message, it 
may appear after the --- so that it gets dropped when applying.

> command line handling code to the cmdline.h header. This hopefully makes
> it easier for Rob to maintain it (at least he doesn't have to look at it
> directly anymore). I would like to add a Kconfig option called
> OF_DEPRECATED_CMDLINE which an architecture would set if it uses this code.

Not sure to understand what you want to do and why that is needed. Why 
can't that work for everyone ? Avoid unnecessary options.

> This would allow a platform to use the cmdline.h and the added function
> directly and remove the Kconfig option. This change would be in a subsequent
> patch.

would or will ? Not sure it is worth mentioning if it won't.

> 
> This code was boot tested on powerpc 32bit, powerpc 64bit without
> any generic command line conversion.
> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Daniel Walker <danielwa@cisco.com>
> ---
>   drivers/of/fdt.c        | 22 +++-------------------
>   include/linux/cmdline.h | 31 +++++++++++++++++++++++++++++++
>   2 files changed, 34 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index bf502ba8da95..1fc1b17d04dc 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -26,6 +26,7 @@
>   #include <linux/serial_core.h>
>   #include <linux/sysfs.h>
>   #include <linux/random.h>
> +#include <linux/cmdline.h>
>   
>   #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
>   #include <asm/page.h>
> @@ -1183,27 +1184,10 @@ int __init early_init_dt_scan_chosen(char *cmdline)
>   
>   	/* Retrieve command line */
>   	p = of_get_flat_dt_prop(node, "bootargs", &l);
> -	if (p != NULL && l > 0)
> -		strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
>   
>   handle_cmdline:
> -	/*
> -	 * CONFIG_CMDLINE is meant to be a default in case nothing else
> -	 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
> -	 * is set in which case we override whatever was found earlier.
> -	 */
> -#ifdef CONFIG_CMDLINE
> -#if defined(CONFIG_CMDLINE_EXTEND)
> -	strlcat(cmdline, " ", COMMAND_LINE_SIZE);
> -	strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#elif defined(CONFIG_CMDLINE_FORCE)
> -	strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#else
> -	/* No arguments from boot loader, use kernel's  cmdl*/
> -	if (!((char *)cmdline)[0])
> -		strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#endif
> -#endif /* CONFIG_CMDLINE */
> +
> +	of_deprecated_cmdline_update(cmdline, p, l);
>   
>   	pr_debug("Command line is: %s\n", (char *)cmdline);
>   
> diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
> index a94758a0f257..c772afb7340f 100644
> --- a/include/linux/cmdline.h
> +++ b/include/linux/cmdline.h
> @@ -103,4 +103,35 @@ __cmdline_add_builtin(
>   
>   #define cmdline_get_static_builtin(dest) \
>   	(CMDLINE_STATIC_PREPEND CMDLINE_STATIC_APPEND)
> +
> +#ifndef CONFIG_GENERIC_CMDLINE
> +static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length)

Add a comment explaining why it is deprecated.

> +{
> +	if (dt_bootargs != NULL && length > 0)
> +		strlcpy(cmdline, dt_bootargs, min(length, COMMAND_LINE_SIZE));
> +	/*
> +	 * CONFIG_CMDLINE is meant to be a default in case nothing else
> +	 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
> +	 * is set in which case we override whatever was found earlier.
> +	 */
> +
> +#ifdef CONFIG_CMDLINE
> +#if defined(CONFIG_CMDLINE_EXTEND)
> +	strlcat(cmdline, " ", COMMAND_LINE_SIZE);
> +	strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> +#elif defined(CONFIG_CMDLINE_FORCE)
> +	strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> +#else
> +	/* No arguments from boot loader, use kernel's  cmdl*/
> +	if (!((char *)cmdline)[0])
> +		strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
>   #endif
> +#endif /* CONFIG_CMDLINE */
> +	return true;
> +}
> +#else
> +static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length) { return false; }
> +#endif /* CONFIG_GENERIC_CMDLINE */
> +
> +
> +#endif /* _LINUX_CMDLINE_H */

WARNING: multiple messages have this Message-ID (diff)
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Daniel Walker <danielwa@cisco.com>, Will Deacon <will@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>,
	Andrew Morton <akpm@linux-foundation.org>,
	Pratyush Brahma <quic_pbrahma@quicinc.com>,
	Tomas Mudrunka <tomas.mudrunka@gmail.com>,
	Sean Anderson <sean.anderson@seco.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"xe-linux-external@cisco.com" <xe-linux-external@cisco.com>
Subject: Re: [PATCH 7/8] of: replace command line handling
Date: Thu, 23 Nov 2023 06:39:23 +0000	[thread overview]
Message-ID: <4fa98c8f-076f-4503-b46d-515b8c56bb6d@csgroup.eu> (raw)
In-Reply-To: <20231110013817.2378507-8-danielwa@cisco.com>



Le 10/11/2023 à 02:38, Daniel Walker a écrit :
> Rob Herring has complained about this section of code. I removed the

This kind of considerations shouldn't appear in the commit message, it 
may appear after the --- so that it gets dropped when applying.

> command line handling code to the cmdline.h header. This hopefully makes
> it easier for Rob to maintain it (at least he doesn't have to look at it
> directly anymore). I would like to add a Kconfig option called
> OF_DEPRECATED_CMDLINE which an architecture would set if it uses this code.

Not sure to understand what you want to do and why that is needed. Why 
can't that work for everyone ? Avoid unnecessary options.

> This would allow a platform to use the cmdline.h and the added function
> directly and remove the Kconfig option. This change would be in a subsequent
> patch.

would or will ? Not sure it is worth mentioning if it won't.

> 
> This code was boot tested on powerpc 32bit, powerpc 64bit without
> any generic command line conversion.
> 
> Cc: xe-linux-external@cisco.com
> Signed-off-by: Daniel Walker <danielwa@cisco.com>
> ---
>   drivers/of/fdt.c        | 22 +++-------------------
>   include/linux/cmdline.h | 31 +++++++++++++++++++++++++++++++
>   2 files changed, 34 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index bf502ba8da95..1fc1b17d04dc 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -26,6 +26,7 @@
>   #include <linux/serial_core.h>
>   #include <linux/sysfs.h>
>   #include <linux/random.h>
> +#include <linux/cmdline.h>
>   
>   #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
>   #include <asm/page.h>
> @@ -1183,27 +1184,10 @@ int __init early_init_dt_scan_chosen(char *cmdline)
>   
>   	/* Retrieve command line */
>   	p = of_get_flat_dt_prop(node, "bootargs", &l);
> -	if (p != NULL && l > 0)
> -		strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
>   
>   handle_cmdline:
> -	/*
> -	 * CONFIG_CMDLINE is meant to be a default in case nothing else
> -	 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
> -	 * is set in which case we override whatever was found earlier.
> -	 */
> -#ifdef CONFIG_CMDLINE
> -#if defined(CONFIG_CMDLINE_EXTEND)
> -	strlcat(cmdline, " ", COMMAND_LINE_SIZE);
> -	strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#elif defined(CONFIG_CMDLINE_FORCE)
> -	strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#else
> -	/* No arguments from boot loader, use kernel's  cmdl*/
> -	if (!((char *)cmdline)[0])
> -		strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> -#endif
> -#endif /* CONFIG_CMDLINE */
> +
> +	of_deprecated_cmdline_update(cmdline, p, l);
>   
>   	pr_debug("Command line is: %s\n", (char *)cmdline);
>   
> diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h
> index a94758a0f257..c772afb7340f 100644
> --- a/include/linux/cmdline.h
> +++ b/include/linux/cmdline.h
> @@ -103,4 +103,35 @@ __cmdline_add_builtin(
>   
>   #define cmdline_get_static_builtin(dest) \
>   	(CMDLINE_STATIC_PREPEND CMDLINE_STATIC_APPEND)
> +
> +#ifndef CONFIG_GENERIC_CMDLINE
> +static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length)

Add a comment explaining why it is deprecated.

> +{
> +	if (dt_bootargs != NULL && length > 0)
> +		strlcpy(cmdline, dt_bootargs, min(length, COMMAND_LINE_SIZE));
> +	/*
> +	 * CONFIG_CMDLINE is meant to be a default in case nothing else
> +	 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
> +	 * is set in which case we override whatever was found earlier.
> +	 */
> +
> +#ifdef CONFIG_CMDLINE
> +#if defined(CONFIG_CMDLINE_EXTEND)
> +	strlcat(cmdline, " ", COMMAND_LINE_SIZE);
> +	strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> +#elif defined(CONFIG_CMDLINE_FORCE)
> +	strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> +#else
> +	/* No arguments from boot loader, use kernel's  cmdl*/
> +	if (!((char *)cmdline)[0])
> +		strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
>   #endif
> +#endif /* CONFIG_CMDLINE */
> +	return true;
> +}
> +#else
> +static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length) { return false; }
> +#endif /* CONFIG_GENERIC_CMDLINE */
> +
> +
> +#endif /* _LINUX_CMDLINE_H */

  parent reply	other threads:[~2023-11-23  6:39 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10  1:38 [PATCH 0/8] generic command line v6 Daniel Walker
2023-11-10  1:38 ` Daniel Walker
2023-11-10  1:38 ` [PATCH 1/8] CMDLINE: add generic builtin command line Daniel Walker
2023-11-10  1:38   ` Daniel Walker
2023-11-10 16:12   ` kernel test robot
2023-11-10 16:12     ` kernel test robot
2023-11-23  6:32   ` Christophe Leroy
2023-11-23  6:32     ` Christophe Leroy
2023-12-04 11:11   ` Jaskaran Singh
2023-12-04 11:11     ` Jaskaran Singh
2023-11-10  1:38 ` [PATCH 2/8] scripts: insert-sys-cert: add command line insert capability Daniel Walker
2023-11-10  1:38   ` Daniel Walker
2023-11-23  6:33   ` Christophe Leroy
2023-11-23  6:33     ` Christophe Leroy
2023-11-10  1:38 ` [PATCH 3/8] scripts: insert-sys-cert: change name to insert-symbol Daniel Walker
2023-11-10  1:38   ` Daniel Walker
2023-11-23  6:34   ` Christophe Leroy
2023-11-23  6:34     ` Christophe Leroy
2023-11-10  1:38 ` [PATCH 4/8] CMDLINE: mips: convert to generic builtin command line Daniel Walker
2023-11-10  1:38   ` Daniel Walker
2023-11-23  6:36   ` Christophe Leroy
2023-11-23  6:36     ` Christophe Leroy
2023-11-10  1:38 ` [PATCH 5/8] drivers: firmware: efi: libstub: enable generic commandline Daniel Walker
2023-11-10  1:38   ` Daniel Walker
2023-11-10  4:23   ` kernel test robot
2023-11-10  4:23     ` kernel test robot
2023-11-23  6:37   ` Christophe Leroy
2023-11-23  6:37     ` Christophe Leroy
2023-12-12  9:55   ` Ard Biesheuvel
2023-12-12  9:55     ` Ard Biesheuvel
2023-12-12 17:25     ` Daniel Walker (danielwa)
2023-12-12 17:25       ` Daniel Walker (danielwa)
2023-11-10  1:38 ` [PATCH 6/8] CMDLINE: x86: convert to generic builtin command line Daniel Walker
2023-11-10  1:38   ` Daniel Walker
2023-11-10  7:17   ` kernel test robot
2023-11-10  7:17     ` kernel test robot
2023-11-10  1:38 ` [PATCH 7/8] of: replace command line handling Daniel Walker
2023-11-10  1:38   ` Daniel Walker
2023-11-16 16:09   ` Rob Herring
2023-11-16 16:09     ` Rob Herring
2023-11-16 16:33     ` Daniel Walker (danielwa)
2023-11-16 16:33       ` Daniel Walker (danielwa)
2023-11-23  6:39   ` Christophe Leroy [this message]
2023-11-23  6:39     ` Christophe Leroy
2023-11-10  1:38 ` [PATCH 8/8] CMDLINE: arm64: convert to generic builtin command line Daniel Walker
2023-11-10  1:38   ` Daniel Walker
2023-11-10  1:38   ` Daniel Walker
2023-11-23  6:39   ` Christophe Leroy
2023-11-23  6:39     ` Christophe Leroy
2023-11-23  6:39     ` Christophe Leroy
2023-11-10  1:51 ` [PATCH 0/8] generic command line v6 Andrew Morton
2023-11-10  1:51   ` Andrew Morton
2023-11-10  1:51   ` Andrew Morton
2023-11-10  2:22   ` Daniel Walker (danielwa)
2023-11-10  2:22     ` Daniel Walker (danielwa)
2023-11-10  2:22     ` Daniel Walker (danielwa)
2023-11-10  2:40     ` Andrew Morton
2023-11-10  2:40       ` Andrew Morton
2023-11-10  2:40       ` Andrew Morton
2023-11-23  6:23 ` Christophe Leroy
2023-11-23  6:23   ` Christophe Leroy
  -- strict thread matches above, loose matches on Subject: below --
2022-09-29  2:32 [PATCH 0/8] generic command line v5 Daniel Walker
2022-09-29  2:32 ` [PATCH 7/8] of: replace command line handling Daniel Walker

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=4fa98c8f-076f-4503-b46d-515b8c56bb6d@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=akpm@linux-foundation.org \
    --cc=daniel@gimpelevich.san-francisco.ca.us \
    --cc=danielwa@cisco.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=quic_pbrahma@quicinc.com \
    --cc=robh+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=sean.anderson@seco.com \
    --cc=tomas.mudrunka@gmail.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=xe-linux-external@cisco.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.