mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] of: fix reproducible node name for legacy vs. new partition binding
@ 2018-10-17  8:47 Sascha Hauer
  2018-10-17 11:07 ` Schenk, Gavin
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2018-10-17  8:47 UTC (permalink / raw)
  To: Barebox List

the of_reproducible_name mechanism is used to find a partition node
from the barebox devicetree in the Linux devicetree. Unfortunately
we have two different partition bindings. In the legacy one the partition
nodes are directly under the hardware devicenode whereas in the new
binding the partitions are under an additional partitions subnode.
This means we get two different (not so) reproducible names when
the barebox devicetree uses the legacy binding and the Linux devicetree
uses the new binding (or the other way round). To get the same
name then for these cases we drop the partitions subnode from the
reproducible name.

This makes the partition fixup in barebox-state work when the barebox
devicetree uses another binding than the Linux devicetree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 drivers/of/base.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index fc01a99ef2..f9b1c3c4cb 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2274,6 +2274,18 @@ char *of_get_reproducible_name(struct device_node *node)
 		return basprintf("[0x%llx]", addr);
 	}
 
+	/*
+	 * Special workaround for the of partition binding. In the old binding
+	 * the partitions are directly under the hardware devicenode whereas in
+	 * the new binding the partitions are in an extra subnode with
+	 * "fixed-partitions" compatible. We skip this extra subnode from the
+	 * reproducible name to get the same name for both bindings.
+	 */
+	if (node->parent &&
+	    of_device_is_compatible(node->parent, "fixed-partitions")) {
+		node = node->parent;
+	}
+
 	na = of_n_addr_cells(node);
 
 	offset = of_read_number(reg, na);
-- 
2.19.0


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

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

* Re: [PATCH] of: fix reproducible node name for legacy vs. new partition binding
  2018-10-17  8:47 [PATCH] of: fix reproducible node name for legacy vs. new partition binding Sascha Hauer
@ 2018-10-17 11:07 ` Schenk, Gavin
  2018-10-18  7:23   ` s.hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Schenk, Gavin @ 2018-10-17 11:07 UTC (permalink / raw)
  To: s.hauer, barebox; +Cc: Götzinger, Jonathan

Hi,

On Wed, 2018-10-17 at 10:47 +0200, Sascha Hauer wrote:
> the of_reproducible_name mechanism is used to find a partition node
> from the barebox devicetree in the Linux devicetree. Unfortunately
> we have two different partition bindings. In the legacy one the partition
> nodes are directly under the hardware devicenode whereas in the new
> binding the partitions are under an additional partitions subnode.
> This means we get two different (not so) reproducible names when
> the barebox devicetree uses the legacy binding and the Linux devicetree
> uses the new binding (or the other way round). To get the same
> name then for these cases we drop the partitions subnode from the
> reproducible name.
> 
> This makes the partition fixup in barebox-state work when the barebox
> devicetree uses another binding than the Linux devicetree.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Tested-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Tested-by: Gavin Schenk <g.schenk@eckelmann.de>

What I did to test it:

1. [x] of_partition_binding=new in barebox and barebox-state in Linux is working.
2. [ ] set of_partition_binding=legacy in barebox and barebox-state in Linux fails.
3. [x] apply the patch and rebuild and install barebox
4. [x] set of_partition_binding=legacy and barebox-state in Linux is working again \o/.

Is this test sufficient?
If not what are other usefull testcases?

Thanks and Regards
Gavin Schenk


-- 
Eckelmann AG
Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
http://www.eckelmann.de
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] of: fix reproducible node name for legacy vs. new partition binding
  2018-10-17 11:07 ` Schenk, Gavin
@ 2018-10-18  7:23   ` s.hauer
  2018-10-18  9:07     ` Schenk, Gavin
  0 siblings, 1 reply; 4+ messages in thread
From: s.hauer @ 2018-10-18  7:23 UTC (permalink / raw)
  To: Schenk, Gavin; +Cc: barebox, Götzinger, Jonathan

Hi Gavin,

On Wed, Oct 17, 2018 at 11:07:45AM +0000, Schenk, Gavin wrote:
> Hi,
> 
> On Wed, 2018-10-17 at 10:47 +0200, Sascha Hauer wrote:
> > the of_reproducible_name mechanism is used to find a partition node
> > from the barebox devicetree in the Linux devicetree. Unfortunately
> > we have two different partition bindings. In the legacy one the partition
> > nodes are directly under the hardware devicenode whereas in the new
> > binding the partitions are under an additional partitions subnode.
> > This means we get two different (not so) reproducible names when
> > the barebox devicetree uses the legacy binding and the Linux devicetree
> > uses the new binding (or the other way round). To get the same
> > name then for these cases we drop the partitions subnode from the
> > reproducible name.
> > 
> > This makes the partition fixup in barebox-state work when the barebox
> > devicetree uses another binding than the Linux devicetree.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > Tested-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
> Tested-by: Gavin Schenk <g.schenk@eckelmann.de>
> 
> What I did to test it:
> 
> 1. [x] of_partition_binding=new in barebox and barebox-state in Linux is working.
> 2. [ ] set of_partition_binding=legacy in barebox and barebox-state in Linux fails.
> 3. [x] apply the patch and rebuild and install barebox
> 4. [x] set of_partition_binding=legacy and barebox-state in Linux is working again \o/.
> 
> Is this test sufficient?
> If not what are other usefull testcases?

Thanks for testing.

Another test would be if you use the legacy binding in your barebox
devicetree and then set of_partition_binding=new. Without this patch it
should fail in Linux and with it it should work. That's the less
important case though.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH] of: fix reproducible node name for legacy vs. new partition binding
  2018-10-18  7:23   ` s.hauer
@ 2018-10-18  9:07     ` Schenk, Gavin
  0 siblings, 0 replies; 4+ messages in thread
From: Schenk, Gavin @ 2018-10-18  9:07 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox, Götzinger, Jonathan

Hi Sascha,

> > 1. [x] of_partition_binding=new in barebox and barebox-state in Linux is working.
> > 2. [ ] set of_partition_binding=legacy in barebox and barebox-state in Linux fails.
> > 3. [x] apply the patch and rebuild and install barebox
> > 4. [x] set of_partition_binding=legacy and barebox-state in Linux is working again \o/.
> > 
> > Is this test sufficient?
> > If not what are other usefull testcases?
> 
> Thanks for testing.

You are welcome, thanks you for this important patch!

> 
> Another test would be if you use the legacy binding in your barebox
> devicetree and then set of_partition_binding=new. Without this patch it
> should fail in Linux and with it it should work. That's the less
> important case though.
> 

Understood. Unfortunately I do not have time to test this immediately.

Because state-framework is essential for RAUC and must not break in field, we plan to integrate tests of state-framework 
into our jenkins/labgrid. We will try to consider your testcase there.

@Jonathan: If you are back in office please remind me to talk about including this state-framework tests. Feel free to
update the task (or simply implement it :) )

Regards
Gavin
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2018-10-18  9:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-17  8:47 [PATCH] of: fix reproducible node name for legacy vs. new partition binding Sascha Hauer
2018-10-17 11:07 ` Schenk, Gavin
2018-10-18  7:23   ` s.hauer
2018-10-18  9:07     ` Schenk, Gavin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox