[LEDE-DEV] [PATCH] kexec-tools: fix non-device tree devices on mips

John Crispin john at phrozen.org
Mon Jan 1 03:22:31 PST 2018



On 26/12/17 12:47, Konstantin Kuzov wrote:
> Add additional argument '--no-dtb' which disables device tree
> search in currently loaded kernel.
>
> Signed-off-by: Konstantin Kuzov <master.nosferatu at gmail.com>
Hi,

could you please rework this patch such that 
140-mips_disable_devicetree_support.patch is fully annotated. also 
please send this patch upstream first.

    John

> ---
>   .../140-mips_disable_devicetree_support.patch      | 147 +++++++++++++++++++++
>   1 file changed, 147 insertions(+)
>   create mode 100644 package/boot/kexec-tools/patches/140-mips_disable_devicetree_support.patch
>
> diff --git a/package/boot/kexec-tools/patches/140-mips_disable_devicetree_support.patch b/package/boot/kexec-tools/patches/140-mips_disable_devicetree_support.patch
> new file mode 100644
> index 0000000000..f862e2f58b
> --- /dev/null
> +++ b/package/boot/kexec-tools/patches/140-mips_disable_devicetree_support.patch
> @@ -0,0 +1,147 @@
> +diff -urN a/kexec/arch/mips/include/arch/options.h b/kexec/arch/mips/include/arch/options.h
> +--- a/kexec/arch/mips/include/arch/options.h	2016-12-09 12:42:06.000000000 +0300
> ++++ b/kexec/arch/mips/include/arch/options.h	2017-12-20 13:19:37.327807439 +0300
> +@@ -5,6 +5,7 @@
> + #define OPT_APPEND	(OPT_ARCH_MAX+0)
> + #define OPT_DTB		(OPT_ARCH_MAX+1)
> + #define OPT_RAMDISK	(OPT_ARCH_MAX+2)
> ++#define OPT_NO_DTB	(OPT_ARCH_MAX+3)
> +
> + /* Options relevant to the architecture (excluding loader-specific ones),
> +  * in this case none:
> +@@ -14,7 +15,8 @@
> + 	{"command-line", 1, 0, OPT_APPEND}, \
> + 	{"append",	 1, 0, OPT_APPEND}, \
> + 	{"dtb",		1, 0, OPT_DTB }, \
> +-	{"initrd",	1, 0, OPT_RAMDISK },
> ++	{"initrd",	1, 0, OPT_RAMDISK }, \
> ++	{"no-dtb",	0, 0, OPT_NO_DTB },
> +
> +
> + #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""
> +diff -urN a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
> +--- a/kexec/arch/mips/kexec-elf-mips.c	2016-12-09 12:42:06.000000000 +0300
> ++++ b/kexec/arch/mips/kexec-elf-mips.c	2017-12-14 09:08:28.793909864 +0300
> +@@ -141,45 +141,49 @@
> + 	else
> + 		cmdline_addr = 0;
> +
> +-	/* MIPS systems that have been converted to use device tree
> +-	 * passed through UHI will use commandline in the DTB and
> +-	 * the DTB passed as a separate buffer. Note that
> +-	 * CMDLINE_PREFIX is skipped here intentionally, as it is
> +-	 * used only in the legacy method */
> +-
> +-	if (arch_options.dtb_file) {
> +-		dtb_buf = slurp_file(arch_options.dtb_file, &dtb_length);
> +-	} else {
> +-		create_flatten_tree(&dtb_buf, &dtb_length, cmdline_buf + strlen(CMDLINE_PREFIX));
> +-	}
> +-
> +-	if (arch_options.initrd_file) {
> +-		initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size);
> +
> +-		/* Create initrd entries in dtb - although at this time
> +-		 * they would not point to the correct location */
> +-		dtb_set_initrd(&dtb_buf, &dtb_length, initrd_buf, initrd_buf + initrd_size);
> +-
> +-		initrd_base = add_buffer(info, initrd_buf, initrd_size,
> +-					initrd_size, sizeof(void *),
> +-					_ALIGN_UP(kernel_addr + kernel_size + dtb_length,
> +-						pagesize), 0x0fffffff, 1);
> +-
> +-		/* Now that the buffer for initrd is prepared, update the dtb
> +-		 * with an appropriate location */
> +-		dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size);
> ++	if (!arch_options.no_dtb) {
> ++		/* MIPS systems that have been converted to use device tree
> ++		 * passed through UHI will use commandline in the DTB and
> ++		 * the DTB passed as a separate buffer. Note that
> ++		 * CMDLINE_PREFIX is skipped here intentionally, as it is
> ++		 * used only in the legacy method */
> ++
> ++		if (arch_options.dtb_file) {
> ++			dtb_buf = slurp_file(arch_options.dtb_file, &dtb_length);
> ++		} else {
> ++			create_flatten_tree(&dtb_buf, &dtb_length, cmdline_buf + strlen(CMDLINE_PREFIX));
> ++		}
> ++
> ++		if (arch_options.initrd_file) {
> ++			initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size);
> ++
> ++			/* Create initrd entries in dtb - although at this time
> ++			 * they would not point to the correct location */
> ++			dtb_set_initrd(&dtb_buf, &dtb_length, initrd_buf, initrd_buf + initrd_size);
> ++
> ++			initrd_base = add_buffer(info, initrd_buf, initrd_size,
> ++						initrd_size, sizeof(void *),
> ++						_ALIGN_UP(kernel_addr + kernel_size + dtb_length,
> ++							pagesize), 0x0fffffff, 1);
> ++
> ++			/* Now that the buffer for initrd is prepared, update the dtb
> ++			 * with an appropriate location */
> ++			dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size);
> ++		}
> + 	}
> +
> +-
> + 	/* This is a legacy method for commandline passing used
> + 	 * currently by Octeon CPUs only */
> + 	add_buffer(info, cmdline_buf, sizeof(cmdline_buf),
> + 			sizeof(cmdline_buf), sizeof(void *),
> + 			cmdline_addr, 0x0fffffff, 1);
> +
> +-	add_buffer(info, dtb_buf, dtb_length, dtb_length, 0,
> +-		_ALIGN_UP(kernel_addr + kernel_size, pagesize),
> +-		0x0fffffff, 1);
> ++	if (!arch_options.no_dtb) {
> ++		add_buffer(info, dtb_buf, dtb_length, dtb_length, 0,
> ++			_ALIGN_UP(kernel_addr + kernel_size, pagesize),
> ++			0x0fffffff, 1);
> ++	}
> +
> + 	return 0;
> + }
> +diff -urN a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
> +--- a/kexec/arch/mips/kexec-mips.c	2017-12-14 09:07:45.775790753 +0300
> ++++ b/kexec/arch/mips/kexec-mips.c	2017-12-20 13:19:57.362395864 +0300
> +@@ -83,6 +83,7 @@
> + 	"    --append=STRING       Set the kernel command line to STRING.\n"
> + 	"    --dtb=FILE            Use FILE as the device tree blob.\n"
> + 	"    --initrd=FILE         Use FILE as initial ramdisk.\n"
> ++	"    --no-dtb              Don't try to find device tree\n"
> + 	);
> + }
> +
> +@@ -115,6 +116,9 @@
> + 		case OPT_RAMDISK:
> + 			arch_options.initrd_file = optarg;
> + 			break;
> ++		case OPT_NO_DTB:
> ++			arch_options.no_dtb = 1;
> ++			break;
> + 		default:
> + 			break;
> + 		}
> +diff -urN a/kexec/arch/mips/kexec-mips.h b/kexec/arch/mips/kexec-mips.h
> +--- a/kexec/arch/mips/kexec-mips.h	2016-12-09 12:42:06.000000000 +0300
> ++++ b/kexec/arch/mips/kexec-mips.h	2017-12-14 09:08:28.794909844 +0300
> +@@ -22,6 +22,7 @@
> + 	char *dtb_file;
> + 	char *initrd_file;
> + 	int core_header_type;
> ++	int no_dtb;
> + };
> +
> + extern struct memory_ranges usablemem_rgns;
> +diff -urN a/kexec/arch/ppc/ops.h b/kexec/arch/ppc/ops.h
> +--- a/kexec/arch/ppc/ops.h	2016-12-09 12:42:06.000000000 +0300
> ++++ b/kexec/arch/ppc/ops.h	2017-12-20 13:19:12.232322959 +0300
> +@@ -14,7 +14,6 @@
> +
> + #define	COMMAND_LINE_SIZE	512
> + #define	MAX_PATH_LEN		256
> +-#define	MAX_PROP_LEN		256 /* What should this be? */
> +
> + typedef void (*kernel_entry_t)(unsigned long r3, unsigned long r4, void *r5);
> +




More information about the Lede-dev mailing list