All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] arm: properly handle a missing /chosen node in the DT
@ 2016-03-31 15:30 Alban Bedel
  2016-03-31 15:30 ` [PATCH 2/3] zImage-arm: Fix a return value check that use the wrong variable Alban Bedel
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Alban Bedel @ 2016-03-31 15:30 UTC (permalink / raw)
  To: kexec; +Cc: Nikolaus Schulz, horms, Alban Bedel

From: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>

When adding a new node to the DT in the setup_dtb_prop function, the
parent offset need be passed to fdt_add_subnode.  Currently a bogus
error code is used.  Fix that by adding the parent offset as an extra
function argument to setup_dtb_prop, and change the handling of the
/chosen node to operate on a relative path plus (zero) offset instead of
an absolute path.

Signed-off-by: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
---
 kexec/arch/arm/kexec-zImage-arm.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index d85ab9b..78518fd 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -257,8 +257,9 @@ int atag_arm_load(struct kexec_info *info, unsigned long base,
 	return 0;
 }
 
-static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
-		const char *prop_name, const void *val, int len)
+static int setup_dtb_prop(char **bufp, off_t *sizep, int parentoffset,
+		const char *node_name, const char *prop_name,
+		const void *val, int len)
 {
 	char *dtb_buf;
 	off_t dtb_size;
@@ -273,14 +274,14 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
 	dtb_size = *sizep;
 
 	/* check if the subnode has already exist */
-	off = fdt_path_offset(dtb_buf, node_name);
+	off = fdt_subnode_offset(dtb_buf, parentoffset, node_name);
 	if (off == -FDT_ERR_NOTFOUND) {
 		dtb_size += fdt_node_len(node_name);
 		fdt_set_totalsize(dtb_buf, dtb_size);
 		dtb_buf = xrealloc(dtb_buf, dtb_size);
 		if (dtb_buf == NULL)
 			die("xrealloc failed\n");
-		off = fdt_add_subnode(dtb_buf, off, node_name);
+		off = fdt_add_subnode(dtb_buf, parentoffset, node_name);
 	}
 
 	if (off < 0) {
@@ -496,7 +497,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 				 *  Error should have been reported so
 				 *  directly return -1
 				 */
-				if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
+				if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
 						"bootargs", command_line,
 						strlen(command_line) + 1))
 					return -1;
@@ -542,11 +543,11 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 			start = cpu_to_be32((unsigned long)(initrd_base));
 			end = cpu_to_be32((unsigned long)(initrd_base + initrd_size));
 
-			if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
+			if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
 					"linux,initrd-start", &start,
 					sizeof(start)))
 				return -1;
-			if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
+			if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
 					"linux,initrd-end", &end,
 					sizeof(end)))
 				return -1;
-- 
2.8.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] zImage-arm: Fix a return value check that use the wrong variable
  2016-03-31 15:30 [PATCH 1/3] arm: properly handle a missing /chosen node in the DT Alban Bedel
@ 2016-03-31 15:30 ` Alban Bedel
  2016-03-31 15:31 ` [PATCH 3/3] zImage-arm: Add support for booting android images Alban Bedel
  2016-04-05  6:33 ` [PATCH 1/3] arm: properly handle a missing /chosen node in the DT Simon Horman
  2 siblings, 0 replies; 7+ messages in thread
From: Alban Bedel @ 2016-03-31 15:30 UTC (permalink / raw)
  To: kexec; +Cc: Nikolaus Schulz, horms, Alban Bedel

When looking for a hole to put the initrd in the error check used the
wrong variable.

Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
---
 kexec/arch/arm/kexec-zImage-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index 78518fd..c436b83 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -530,7 +530,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 			unsigned long initrd_base_new = locate_hole(info,
 					hole_size, page_size,
 					initrd_base, ULONG_MAX, INT_MAX);
-			if (base == ULONG_MAX)
+			if (initrd_base_new == ULONG_MAX)
 				return -1;
 			initrd_base = initrd_base_new;
 		}
-- 
2.8.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] zImage-arm: Add support for booting android images
  2016-03-31 15:30 [PATCH 1/3] arm: properly handle a missing /chosen node in the DT Alban Bedel
  2016-03-31 15:30 ` [PATCH 2/3] zImage-arm: Fix a return value check that use the wrong variable Alban Bedel
@ 2016-03-31 15:31 ` Alban Bedel
  2016-04-05  6:33 ` [PATCH 1/3] arm: properly handle a missing /chosen node in the DT Simon Horman
  2 siblings, 0 replies; 7+ messages in thread
From: Alban Bedel @ 2016-03-31 15:31 UTC (permalink / raw)
  To: kexec; +Cc: Nikolaus Schulz, horms, Alban Bedel

Add very basic support for booting an android image. The ramdisk and
command line from the image are only used if none has been given on
the command line.

Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
---
 kexec/arch/arm/kexec-zImage-arm.c | 56 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 54 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
index c436b83..6b548c3 100644
--- a/kexec/arch/arm/kexec-zImage-arm.c
+++ b/kexec/arch/arm/kexec-zImage-arm.c
@@ -27,6 +27,23 @@ off_t initrd_base = 0, initrd_size = 0;
 unsigned int kexec_arm_image_size = 0;
 unsigned long long user_page_offset = (-1ULL);
 
+struct android_image {
+	char magic[8];
+	uint32_t kernel_size;
+	uint32_t kernel_addr;
+	uint32_t ramdisk_size;
+	uint32_t ramdisk_addr;
+	uint32_t stage2_size;
+	uint32_t stage2_addr;
+	uint32_t tags_addr;
+	uint32_t page_size;
+	uint32_t reserved1;
+	uint32_t reserved2;
+	char name[16];
+	char command_line[512];
+	uint32_t chksum[8];
+};
+
 struct tag_header {
 	uint32_t size;
 	uint32_t tag;
@@ -329,7 +346,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 	char *modified_cmdline = NULL;
 	off_t command_line_len;
 	const char *ramdisk;
-	char *ramdisk_buf;
+	const char *ramdisk_buf;
 	int opt;
 	int use_atags;
 	char *dtb_buf;
@@ -416,6 +433,41 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 	if (dtb_file)
 		dtb_buf = slurp_file(dtb_file, &dtb_length);
 
+	/* Handle android images, 2048 is the minimum page size */
+	if (len > 2048 && !strncmp(buf, "ANDROID!", 8)) {
+		const struct android_image *aimg = (const void *)buf;
+		uint32_t page_size = le32_to_cpu(aimg->page_size);
+		uint32_t kernel_size = le32_to_cpu(aimg->kernel_size);
+		uint32_t ramdisk_size = le32_to_cpu(aimg->ramdisk_size);
+		uint32_t stage2_size = le32_to_cpu(aimg->stage2_size);
+		off_t aimg_size = page_size + _ALIGN(kernel_size, page_size) +
+			_ALIGN(ramdisk_size, page_size) + stage2_size;
+
+		if (len < aimg_size) {
+			fprintf(stderr, "Android image size is incorrect\n");
+			return -1;
+		}
+
+		/* Get the kernel */
+		buf = buf + page_size;
+		len = kernel_size;
+
+		/* And the ramdisk if none was given on the command line */
+		if (!ramdisk && ramdisk_size) {
+			initrd_size = ramdisk_size;
+			ramdisk_buf = buf + _ALIGN(kernel_size, page_size);
+		}
+
+		/* Likewise for the command line */
+		if (!command_line && aimg->command_line[0]) {
+			command_line = aimg->command_line;
+			if (command_line[sizeof(aimg->command_line) - 1])
+				command_line_len = sizeof(aimg->command_line);
+			else
+				command_line_len = strlen(command_line) + 1;
+		}
+	}
+
 	/*
 	 * If we are loading a dump capture kernel, we need to update kernel
 	 * command line and also add some additional segments.
@@ -535,7 +587,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
 			initrd_base = initrd_base_new;
 		}
 
-		if (ramdisk) {
+		if (ramdisk_buf) {
 			add_segment(info, ramdisk_buf, initrd_size,
 			            initrd_base, initrd_size);
 
-- 
2.8.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] arm: properly handle a missing /chosen node in the DT
  2016-03-31 15:30 [PATCH 1/3] arm: properly handle a missing /chosen node in the DT Alban Bedel
  2016-03-31 15:30 ` [PATCH 2/3] zImage-arm: Fix a return value check that use the wrong variable Alban Bedel
  2016-03-31 15:31 ` [PATCH 3/3] zImage-arm: Add support for booting android images Alban Bedel
@ 2016-04-05  6:33 ` Simon Horman
  2016-04-05  9:34   ` Nikolaus Schulz
  2 siblings, 1 reply; 7+ messages in thread
From: Simon Horman @ 2016-04-05  6:33 UTC (permalink / raw)
  To: Alban Bedel; +Cc: Nikolaus Schulz, kexec

On Thu, Mar 31, 2016 at 05:30:58PM +0200, Alban Bedel wrote:
> From: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
> 
> When adding a new node to the DT in the setup_dtb_prop function, the
> parent offset need be passed to fdt_add_subnode.  Currently a bogus
> error code is used.  Fix that by adding the parent offset as an extra
> function argument to setup_dtb_prop, and change the handling of the
> /chosen node to operate on a relative path plus (zero) offset instead of
> an absolute path.
> 
> Signed-off-by: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>

Hi,

I am struggling to see the problem that this patch tries to solve.

* Where and when is a bogus error code used?
* Why is a new parameter added to fdt_add_subnode and always passed as zero?
* If it is inappropriate to pass off to fdt_add_subnode() can
  that be resolved by simply passing 0 instead?

> ---
>  kexec/arch/arm/kexec-zImage-arm.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
> index d85ab9b..78518fd 100644
> --- a/kexec/arch/arm/kexec-zImage-arm.c
> +++ b/kexec/arch/arm/kexec-zImage-arm.c
> @@ -257,8 +257,9 @@ int atag_arm_load(struct kexec_info *info, unsigned long base,
>  	return 0;
>  }
>  
> -static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
> -		const char *prop_name, const void *val, int len)
> +static int setup_dtb_prop(char **bufp, off_t *sizep, int parentoffset,
> +		const char *node_name, const char *prop_name,
> +		const void *val, int len)
>  {
>  	char *dtb_buf;
>  	off_t dtb_size;
> @@ -273,14 +274,14 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
>  	dtb_size = *sizep;
>  
>  	/* check if the subnode has already exist */
> -	off = fdt_path_offset(dtb_buf, node_name);
> +	off = fdt_subnode_offset(dtb_buf, parentoffset, node_name);
>  	if (off == -FDT_ERR_NOTFOUND) {
>  		dtb_size += fdt_node_len(node_name);
>  		fdt_set_totalsize(dtb_buf, dtb_size);
>  		dtb_buf = xrealloc(dtb_buf, dtb_size);
>  		if (dtb_buf == NULL)
>  			die("xrealloc failed\n");
> -		off = fdt_add_subnode(dtb_buf, off, node_name);
> +		off = fdt_add_subnode(dtb_buf, parentoffset, node_name);
>  	}
>  
>  	if (off < 0) {
> @@ -496,7 +497,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
>  				 *  Error should have been reported so
>  				 *  directly return -1
>  				 */
> -				if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
> +				if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
>  						"bootargs", command_line,
>  						strlen(command_line) + 1))
>  					return -1;
> @@ -542,11 +543,11 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
>  			start = cpu_to_be32((unsigned long)(initrd_base));
>  			end = cpu_to_be32((unsigned long)(initrd_base + initrd_size));
>  
> -			if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
> +			if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
>  					"linux,initrd-start", &start,
>  					sizeof(start)))
>  				return -1;
> -			if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
> +			if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
>  					"linux,initrd-end", &end,
>  					sizeof(end)))
>  				return -1;
> -- 
> 2.8.0
> 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] arm: properly handle a missing /chosen node in the DT
  2016-04-05  6:33 ` [PATCH 1/3] arm: properly handle a missing /chosen node in the DT Simon Horman
@ 2016-04-05  9:34   ` Nikolaus Schulz
  2016-04-05  9:37     ` Nikolaus Schulz
  2016-04-06  0:30     ` Simon Horman
  0 siblings, 2 replies; 7+ messages in thread
From: Nikolaus Schulz @ 2016-04-05  9:34 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec, Alban Bedel

On Tue, Apr 05, 2016 at 03:33:06PM +0900, Simon Horman wrote:
> On Thu, Mar 31, 2016 at 05:30:58PM +0200, Alban Bedel wrote:
> > From: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
> > 
> > When adding a new node to the DT in the setup_dtb_prop function, the
> > parent offset need be passed to fdt_add_subnode.  Currently a bogus
> > error code is used.  Fix that by adding the parent offset as an extra
> > function argument to setup_dtb_prop, and change the handling of the
> > /chosen node to operate on a relative path plus (zero) offset instead of
> > an absolute path.
> > 
> > Signed-off-by: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
> 
> Hi,
> 
> I am struggling to see the problem that this patch tries to solve.
> 
> * Where and when is a bogus error code used?

Hi Simon!

The bogus error code is passed to fdt_add_subnode, see comment inline in
the patch below.

> * Why is a new parameter added to fdt_add_subnode and always passed as zero?

Yeah, this might look irritating... the point is, setup_dtb_prop looks
like a generic function that could be used for finding/adding any nodes,
which need not be top-level in the DT.  In practice though, the function
is only used for the top-level /chosen node, and currently it can't add
nodes that aren't top-level.

So, one could either a) make the function non-generic, handling
top-level nodes only, or b) pass it the offset of the parent node, or c)
let it operate on aribtrary DT paths with possibly multiple components.
a) and b) are trivial to do.  libfdt typically does b) for similar
functions, so I added that extra parameter to fdt_add_subnode.

> * If it is inappropriate to pass off to fdt_add_subnode() can
>   that be resolved by simply passing 0 instead?

If we know that we're adding a top-level node, then yes.  Basically,
one can do that either in fdt_add_subnode, or when calling it in
zImage_arm_load.  My patch does the latter.

Best regards,
Nikolaus

> > ---
> >  kexec/arch/arm/kexec-zImage-arm.c | 15 ++++++++-------
> >  1 file changed, 8 insertions(+), 7 deletions(-)
> > 
> > diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c
> > index d85ab9b..78518fd 100644
> > --- a/kexec/arch/arm/kexec-zImage-arm.c
> > +++ b/kexec/arch/arm/kexec-zImage-arm.c
> > @@ -257,8 +257,9 @@ int atag_arm_load(struct kexec_info *info, unsigned long base,
> >  	return 0;
> >  }
> >  
> > -static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
> > -		const char *prop_name, const void *val, int len)
> > +static int setup_dtb_prop(char **bufp, off_t *sizep, int parentoffset,
> > +		const char *node_name, const char *prop_name,
> > +		const void *val, int len)
> >  {
> >  	char *dtb_buf;
> >  	off_t dtb_size;
> > @@ -273,14 +274,14 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, const char *node_name,
> >  	dtb_size = *sizep;
> >  
> >  	/* check if the subnode has already exist */
> > -	off = fdt_path_offset(dtb_buf, node_name);
> > +	off = fdt_subnode_offset(dtb_buf, parentoffset, node_name);
> >  	if (off == -FDT_ERR_NOTFOUND) {
> >  		dtb_size += fdt_node_len(node_name);
> >  		fdt_set_totalsize(dtb_buf, dtb_size);
> >  		dtb_buf = xrealloc(dtb_buf, dtb_size);
> >  		if (dtb_buf == NULL)
> >  			die("xrealloc failed\n");
> > -		off = fdt_add_subnode(dtb_buf, off, node_name);

Here, off == -FDT_ERR_NOTFOUND, which makes no sense.

> > +		off = fdt_add_subnode(dtb_buf, parentoffset, node_name);
> >  	}
> >  
> >  	if (off < 0) {
> > @@ -496,7 +497,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
> >  				 *  Error should have been reported so
> >  				 *  directly return -1
> >  				 */
> > -				if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
> > +				if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
> >  						"bootargs", command_line,
> >  						strlen(command_line) + 1))
> >  					return -1;
> > @@ -542,11 +543,11 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
> >  			start = cpu_to_be32((unsigned long)(initrd_base));
> >  			end = cpu_to_be32((unsigned long)(initrd_base + initrd_size));
> >  
> > -			if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
> > +			if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
> >  					"linux,initrd-start", &start,
> >  					sizeof(start)))
> >  				return -1;
> > -			if (setup_dtb_prop(&dtb_buf, &dtb_length, "/chosen",
> > +			if (setup_dtb_prop(&dtb_buf, &dtb_length, 0, "chosen",
> >  					"linux,initrd-end", &end,
> >  					sizeof(end)))
> >  				return -1;
> > -- 
> > 2.8.0
> > 

-- 
Avionic Design GmbH
Nikolaus Schulz
Wragekamp 10
D-22397 Hamburg
Germany

Tel.:  +49 40 88187-163
Fax:   +49 40 88187-150
Email: nikolaus.schulz@avionic-design.de

Avionic Design GmbH
Amtsgericht Hamburg HRB 82598
Geschäftsführung: Cornelis Broers
Ust.-Ident-Nr.: DE813378254

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] arm: properly handle a missing /chosen node in the DT
  2016-04-05  9:34   ` Nikolaus Schulz
@ 2016-04-05  9:37     ` Nikolaus Schulz
  2016-04-06  0:30     ` Simon Horman
  1 sibling, 0 replies; 7+ messages in thread
From: Nikolaus Schulz @ 2016-04-05  9:37 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec, Alban Bedel

On Tue, Apr 05, 2016 at 11:34:33AM +0200, Nikolaus Schulz wrote:
> > * If it is inappropriate to pass off to fdt_add_subnode() can
> >   that be resolved by simply passing 0 instead?
> 
> If we know that we're adding a top-level node, then yes.  Basically,
> one can do that either in fdt_add_subnode, or when calling it in
> zImage_arm_load.  My patch does the latter.

s/fdt_add_subnode/setup_dtb_prop/ in the above paragraph

Nikolaus

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] arm: properly handle a missing /chosen node in the DT
  2016-04-05  9:34   ` Nikolaus Schulz
  2016-04-05  9:37     ` Nikolaus Schulz
@ 2016-04-06  0:30     ` Simon Horman
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Horman @ 2016-04-06  0:30 UTC (permalink / raw)
  To: Nikolaus Schulz; +Cc: Alban Bedel, kexec

On Tue, Apr 05, 2016 at 11:34:33AM +0200, Nikolaus Schulz wrote:
> On Tue, Apr 05, 2016 at 03:33:06PM +0900, Simon Horman wrote:
> > On Thu, Mar 31, 2016 at 05:30:58PM +0200, Alban Bedel wrote:
> > > From: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
> > > 
> > > When adding a new node to the DT in the setup_dtb_prop function, the
> > > parent offset need be passed to fdt_add_subnode.  Currently a bogus
> > > error code is used.  Fix that by adding the parent offset as an extra
> > > function argument to setup_dtb_prop, and change the handling of the
> > > /chosen node to operate on a relative path plus (zero) offset instead of
> > > an absolute path.
> > > 
> > > Signed-off-by: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
> > 
> > Hi,
> > 
> > I am struggling to see the problem that this patch tries to solve.
> > 
> > * Where and when is a bogus error code used?
> 
> Hi Simon!
> 
> The bogus error code is passed to fdt_add_subnode, see comment inline in
> the patch below.

Thanks, I see that clearly now.

For some reason I inverted the "if (off == -FDT_ERR_NOTFOUND)" in my
mind when I was reviewing your patch yesterday.

> > * Why is a new parameter added to fdt_add_subnode and always passed as zero?
> 
> Yeah, this might look irritating... the point is, setup_dtb_prop looks
> like a generic function that could be used for finding/adding any nodes,
> which need not be top-level in the DT.  In practice though, the function
> is only used for the top-level /chosen node, and currently it can't add
> nodes that aren't top-level.
> 
> So, one could either a) make the function non-generic, handling
> top-level nodes only, or b) pass it the offset of the parent node, or c)
> let it operate on aribtrary DT paths with possibly multiple components.
> a) and b) are trivial to do.  libfdt typically does b) for similar
> functions, so I added that extra parameter to fdt_add_subnode.

Thanks, I understand now.
With the above explanation in mind I prefer b).

Could you re-work the changelog to explain things as you have done so above
and then resubmit the entire series?

> > * If it is inappropriate to pass off to fdt_add_subnode() can
> >   that be resolved by simply passing 0 instead?
> 
> If we know that we're adding a top-level node, then yes.  Basically,
> one can do that either in fdt_add_subnode, or when calling it in
> zImage_arm_load.  My patch does the latter.

Understood.

> Best regards,
> Nikolaus

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-04-06  0:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-31 15:30 [PATCH 1/3] arm: properly handle a missing /chosen node in the DT Alban Bedel
2016-03-31 15:30 ` [PATCH 2/3] zImage-arm: Fix a return value check that use the wrong variable Alban Bedel
2016-03-31 15:31 ` [PATCH 3/3] zImage-arm: Add support for booting android images Alban Bedel
2016-04-05  6:33 ` [PATCH 1/3] arm: properly handle a missing /chosen node in the DT Simon Horman
2016-04-05  9:34   ` Nikolaus Schulz
2016-04-05  9:37     ` Nikolaus Schulz
2016-04-06  0:30     ` Simon Horman

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.