All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] Add nvmem support for dynamic partitions
@ 2022-05-18 23:32 ` Ansuel Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-05-18 23:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Ansuel Smith,
	Greg Kroah-Hartman, Manivannan Sadhasivam, linux-mtd, devicetree,
	linux-kernel

This very small series comes to fix the very annyoing problem of
partitions declared by parser at runtime NOT supporting nvmem cells
definition.

The current implementation is very generic. The idea is to provide an of
node if defined for everyone and not strictly limit this to nvmem stuff.
But still the actual change is done only for nvmem-cells mtd. (just to
make sure) This can totally change by removing the compatible check.

The idea here is that a user can still use these dynamic parsers
instead of declaring a fixed-partition and also declare how nvmem-cells
are defined for the partition.
This live with the assumption that dynamic partition have always the
same name and they are known. (this is the case for smem-part partition
that would require a bootloader reflash to change and for parsers like
cmdlinepart where the name is always the same.)
With this assumption, it's easy to fix this problem. Just introduce a
new partition node that will declare just these special partition.
Mtdcore then will check if these special declaration are present and
connect the dynamic partition with the OF node present in the dts. Nvmem
will automagically fin the OF node and cells will be works based on the
data provided by the parser.

The initial idea was to create a special nvmem driver with a special
compatible where a user would declare the mtd partition name and this
driver would search it and register the nvmem cells but that became
difficult really fast, mtd notifier system is problematic for this kind
of stuff. So here is the better implementation. A variant of this is
already tested on openwrt where we have devices that use cmdlinepart.
(that current variant have defined in the dts the exact copy of
cmdlinepart in the fixed-partition scheme and we patched the cmdlinepart
parser to scan this fixed-partition node (that is ignored as cmdlinepart
have priority) and connect the dynamic partition with the dts node)

I provided an example of this in the documentation commit.
In short it's needed to add to the partitions where the compatible parser
is declared, a partition with just the label declared (instead of the reg).
Then declare some nvmem-cells and it will all work at runtime.
Mtdcore will check if a node with the same label is present and assign an
OF node to the MTD.

I currently tested this on my device that have smem-part and the
gmac driver use nvmem to get the mac-address. This works correctly and
the same address is provided.

v4:
- Make it simple. No suffix. Make label mandatory again.
- Update Documentation with new implementation.
- Rename files to a better and correct name
v3:
- Fix warning from bot (function not declared as static)
- Updated code to support also node name
- Made partition label optional
v2:
- Simplify this. Drop dynamic-partition
- Fix problem with parser with ko
- Do not pollude mtd_get_of_node
- Fix problem with Documentation

Ansuel Smith (2):
  dt-bindings: mtd: partitions: Document new dynamic-partition nodes
  mtd: core: introduce of support for dynamic partitions

 .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
 .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
 drivers/mtd/mtdcore.c                         | 49 ++++++++++++++++
 3 files changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml

-- 
2.34.1


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

* [PATCH v4 0/2] Add nvmem support for dynamic partitions
@ 2022-05-18 23:32 ` Ansuel Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-05-18 23:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Ansuel Smith,
	Greg Kroah-Hartman, Manivannan Sadhasivam, linux-mtd, devicetree,
	linux-kernel

This very small series comes to fix the very annyoing problem of
partitions declared by parser at runtime NOT supporting nvmem cells
definition.

The current implementation is very generic. The idea is to provide an of
node if defined for everyone and not strictly limit this to nvmem stuff.
But still the actual change is done only for nvmem-cells mtd. (just to
make sure) This can totally change by removing the compatible check.

The idea here is that a user can still use these dynamic parsers
instead of declaring a fixed-partition and also declare how nvmem-cells
are defined for the partition.
This live with the assumption that dynamic partition have always the
same name and they are known. (this is the case for smem-part partition
that would require a bootloader reflash to change and for parsers like
cmdlinepart where the name is always the same.)
With this assumption, it's easy to fix this problem. Just introduce a
new partition node that will declare just these special partition.
Mtdcore then will check if these special declaration are present and
connect the dynamic partition with the OF node present in the dts. Nvmem
will automagically fin the OF node and cells will be works based on the
data provided by the parser.

The initial idea was to create a special nvmem driver with a special
compatible where a user would declare the mtd partition name and this
driver would search it and register the nvmem cells but that became
difficult really fast, mtd notifier system is problematic for this kind
of stuff. So here is the better implementation. A variant of this is
already tested on openwrt where we have devices that use cmdlinepart.
(that current variant have defined in the dts the exact copy of
cmdlinepart in the fixed-partition scheme and we patched the cmdlinepart
parser to scan this fixed-partition node (that is ignored as cmdlinepart
have priority) and connect the dynamic partition with the dts node)

I provided an example of this in the documentation commit.
In short it's needed to add to the partitions where the compatible parser
is declared, a partition with just the label declared (instead of the reg).
Then declare some nvmem-cells and it will all work at runtime.
Mtdcore will check if a node with the same label is present and assign an
OF node to the MTD.

I currently tested this on my device that have smem-part and the
gmac driver use nvmem to get the mac-address. This works correctly and
the same address is provided.

v4:
- Make it simple. No suffix. Make label mandatory again.
- Update Documentation with new implementation.
- Rename files to a better and correct name
v3:
- Fix warning from bot (function not declared as static)
- Updated code to support also node name
- Made partition label optional
v2:
- Simplify this. Drop dynamic-partition
- Fix problem with parser with ko
- Do not pollude mtd_get_of_node
- Fix problem with Documentation

Ansuel Smith (2):
  dt-bindings: mtd: partitions: Document new dynamic-partition nodes
  mtd: core: introduce of support for dynamic partitions

 .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
 .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
 drivers/mtd/mtdcore.c                         | 49 ++++++++++++++++
 3 files changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml

-- 
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH v4 1/2] dt-bindings: mtd: partitions: Document new dynamic-partition nodes
  2022-05-18 23:32 ` Ansuel Smith
@ 2022-05-18 23:32   ` Ansuel Smith
  -1 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-05-18 23:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Ansuel Smith,
	Greg Kroah-Hartman, Manivannan Sadhasivam, linux-mtd, devicetree,
	linux-kernel

Document new dynamic-partition nodes used to provide an OF node for
partition registred at runtime by parsers. This is required for nvmem
system to declare and detect nvmem-cells.

With these special partitions, the reg / offset is not required.
The label binding is used to match the partition allocated by the
parser at runtime and the parser will provide reg and offset of the mtd.

NVMEM will use the data from the parser and provide the NVMEM cells
declared in the DTS, "connecting" the dynamic partition with a
static declaration of cells in them.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
 .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
 2 files changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml

diff --git a/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
new file mode 100644
index 000000000000..f57d7b9cae7f
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/dynamic-partition.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Dynamic Partition
+
+description: |
+  This binding describes a single flash partition that is dynamically allocated
+  by a dedicated parser that is not a fixed-partition parser.
+
+  Each child of the parser partition node is then compared and if a match with
+  the provided label is found then the OF node is assigned.
+
+  These special partition definition can be used to give a dynamic partition
+  an OF node to declare NVMEM cells. An example is declaring the partition
+  label and all the NVMEM cells in it. The parser will detect the correct reg
+  and offset and the NVMEM will register the cells in it based on the data
+  extracted by the parser.
+
+maintainers:
+  - Ansuel Smith <ansuelsmth@gmail.com>
+
+properties:
+  label:
+    description: The label / name for the partition assigned by the parser at
+      runtime. This is needed for sybsystem like NVMEM to define cells and
+      register with this OF node.
+
+required:
+  - label
+
+additionalProperties: true
+
+examples:
+  - |
+    flash {
+      partitions {
+        compatible = "qcom,smem-part";
+
+        partition-art {
+          compatible = "nvmem-cells";
+          #address-cells = <1>;
+          #size-cells = <1>;
+          label = "0:art";
+
+          macaddr_art_0: macaddr@0 {
+            reg = <0x0 0x6>;
+          };
+
+          macaddr_art_6: macaddr@6 {
+            reg = <0x6 0x6>;
+          };
+        };
+      };
+    };
diff --git a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
index cf3f8c1e035d..b6fa25949fe2 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
@@ -19,6 +19,10 @@ properties:
   compatible:
     const: qcom,smem-part
 
+patternProperties:
+  "^partition-[0-9a-z]+$":
+    $ref: dynamic-partition.yaml#
+
 required:
   - compatible
 
-- 
2.34.1


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

* [PATCH v4 1/2] dt-bindings: mtd: partitions: Document new dynamic-partition nodes
@ 2022-05-18 23:32   ` Ansuel Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-05-18 23:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Ansuel Smith,
	Greg Kroah-Hartman, Manivannan Sadhasivam, linux-mtd, devicetree,
	linux-kernel

Document new dynamic-partition nodes used to provide an OF node for
partition registred at runtime by parsers. This is required for nvmem
system to declare and detect nvmem-cells.

With these special partitions, the reg / offset is not required.
The label binding is used to match the partition allocated by the
parser at runtime and the parser will provide reg and offset of the mtd.

NVMEM will use the data from the parser and provide the NVMEM cells
declared in the DTS, "connecting" the dynamic partition with a
static declaration of cells in them.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
 .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
 2 files changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml

diff --git a/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
new file mode 100644
index 000000000000..f57d7b9cae7f
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/dynamic-partition.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Dynamic Partition
+
+description: |
+  This binding describes a single flash partition that is dynamically allocated
+  by a dedicated parser that is not a fixed-partition parser.
+
+  Each child of the parser partition node is then compared and if a match with
+  the provided label is found then the OF node is assigned.
+
+  These special partition definition can be used to give a dynamic partition
+  an OF node to declare NVMEM cells. An example is declaring the partition
+  label and all the NVMEM cells in it. The parser will detect the correct reg
+  and offset and the NVMEM will register the cells in it based on the data
+  extracted by the parser.
+
+maintainers:
+  - Ansuel Smith <ansuelsmth@gmail.com>
+
+properties:
+  label:
+    description: The label / name for the partition assigned by the parser at
+      runtime. This is needed for sybsystem like NVMEM to define cells and
+      register with this OF node.
+
+required:
+  - label
+
+additionalProperties: true
+
+examples:
+  - |
+    flash {
+      partitions {
+        compatible = "qcom,smem-part";
+
+        partition-art {
+          compatible = "nvmem-cells";
+          #address-cells = <1>;
+          #size-cells = <1>;
+          label = "0:art";
+
+          macaddr_art_0: macaddr@0 {
+            reg = <0x0 0x6>;
+          };
+
+          macaddr_art_6: macaddr@6 {
+            reg = <0x6 0x6>;
+          };
+        };
+      };
+    };
diff --git a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
index cf3f8c1e035d..b6fa25949fe2 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
@@ -19,6 +19,10 @@ properties:
   compatible:
     const: qcom,smem-part
 
+patternProperties:
+  "^partition-[0-9a-z]+$":
+    $ref: dynamic-partition.yaml#
+
 required:
   - compatible
 
-- 
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH v4 2/2] mtd: core: introduce of support for dynamic partitions
  2022-05-18 23:32 ` Ansuel Smith
@ 2022-05-18 23:32   ` Ansuel Smith
  -1 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-05-18 23:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Ansuel Smith,
	Greg Kroah-Hartman, Manivannan Sadhasivam, linux-mtd, devicetree,
	linux-kernel

We have many parser that register mtd partitions at runtime. One example
is the cmdlinepart or the smem-part parser where the compatible is defined
in the dts and the partitions gets detected and registered by the
parser. This is problematic for the NVMEM subsystem that requires an OF node
to detect NVMEM cells.

To fix this problem, introduce an additional logic that will try to
assign an OF node to the MTD if declared.

On MTD addition, it will be checked if the MTD has an OF node and if
not declared will check if a partition with the same label is
declared in DTS. If an exact match is found, the partition dynamically
allocated by the parser will have a connected OF node.

The NVMEM subsystem will detect the OF node and register any NVMEM cells
declared statically in the DTS.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 drivers/mtd/mtdcore.c | 49 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 7731796024e0..807194efb580 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -546,6 +546,54 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
 	return 0;
 }
 
+static void mtd_check_of_node(struct mtd_info *mtd)
+{
+	struct device_node *partitions, *parent_dn, *mtd_dn = NULL;
+	struct mtd_info *parent;
+	const char *mtd_name;
+	bool found = false;
+	int plen;
+
+	/* Check if MTD already has a device node */
+	if (dev_of_node(&mtd->dev))
+		return;
+
+	/* Check if a partitions node exist */
+	parent = mtd->parent;
+	parent_dn = dev_of_node(&parent->dev);
+	if (!parent_dn)
+		return;
+
+	partitions = of_get_child_by_name(parent_dn, "partitions");
+	if (!partitions)
+		goto exit_parent;
+
+	/* Search if a partition is defined with the same name */
+	for_each_child_of_node(partitions, mtd_dn) {
+		/* Skip partition with no label */
+		mtd_name = of_get_property(mtd_dn, "label", &plen);
+		if (!mtd_name)
+			continue;
+
+		if (!strncmp(mtd->name, mtd_name, plen)) {
+			found = true;
+			break;
+		}
+	}
+
+	if (!found)
+		goto exit_partitions;
+
+	/* Set of_node only for nvmem */
+	if (of_device_is_compatible(mtd_dn, "nvmem-cells"))
+		mtd_set_of_node(mtd, mtd_dn);
+
+exit_partitions:
+	of_node_put(partitions);
+exit_parent:
+	of_node_put(parent_dn);
+}
+
 /**
  *	add_mtd_device - register an MTD device
  *	@mtd: pointer to new MTD device info structure
@@ -651,6 +699,7 @@ int add_mtd_device(struct mtd_info *mtd)
 	mtd->dev.devt = MTD_DEVT(i);
 	dev_set_name(&mtd->dev, "mtd%d", i);
 	dev_set_drvdata(&mtd->dev, mtd);
+	mtd_check_of_node(mtd);
 	of_node_get(mtd_get_of_node(mtd));
 	error = device_register(&mtd->dev);
 	if (error)
-- 
2.34.1


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

* [PATCH v4 2/2] mtd: core: introduce of support for dynamic partitions
@ 2022-05-18 23:32   ` Ansuel Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-05-18 23:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rob Herring, Krzysztof Kozlowski, Ansuel Smith,
	Greg Kroah-Hartman, Manivannan Sadhasivam, linux-mtd, devicetree,
	linux-kernel

We have many parser that register mtd partitions at runtime. One example
is the cmdlinepart or the smem-part parser where the compatible is defined
in the dts and the partitions gets detected and registered by the
parser. This is problematic for the NVMEM subsystem that requires an OF node
to detect NVMEM cells.

To fix this problem, introduce an additional logic that will try to
assign an OF node to the MTD if declared.

On MTD addition, it will be checked if the MTD has an OF node and if
not declared will check if a partition with the same label is
declared in DTS. If an exact match is found, the partition dynamically
allocated by the parser will have a connected OF node.

The NVMEM subsystem will detect the OF node and register any NVMEM cells
declared statically in the DTS.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 drivers/mtd/mtdcore.c | 49 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 7731796024e0..807194efb580 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -546,6 +546,54 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
 	return 0;
 }
 
+static void mtd_check_of_node(struct mtd_info *mtd)
+{
+	struct device_node *partitions, *parent_dn, *mtd_dn = NULL;
+	struct mtd_info *parent;
+	const char *mtd_name;
+	bool found = false;
+	int plen;
+
+	/* Check if MTD already has a device node */
+	if (dev_of_node(&mtd->dev))
+		return;
+
+	/* Check if a partitions node exist */
+	parent = mtd->parent;
+	parent_dn = dev_of_node(&parent->dev);
+	if (!parent_dn)
+		return;
+
+	partitions = of_get_child_by_name(parent_dn, "partitions");
+	if (!partitions)
+		goto exit_parent;
+
+	/* Search if a partition is defined with the same name */
+	for_each_child_of_node(partitions, mtd_dn) {
+		/* Skip partition with no label */
+		mtd_name = of_get_property(mtd_dn, "label", &plen);
+		if (!mtd_name)
+			continue;
+
+		if (!strncmp(mtd->name, mtd_name, plen)) {
+			found = true;
+			break;
+		}
+	}
+
+	if (!found)
+		goto exit_partitions;
+
+	/* Set of_node only for nvmem */
+	if (of_device_is_compatible(mtd_dn, "nvmem-cells"))
+		mtd_set_of_node(mtd, mtd_dn);
+
+exit_partitions:
+	of_node_put(partitions);
+exit_parent:
+	of_node_put(parent_dn);
+}
+
 /**
  *	add_mtd_device - register an MTD device
  *	@mtd: pointer to new MTD device info structure
@@ -651,6 +699,7 @@ int add_mtd_device(struct mtd_info *mtd)
 	mtd->dev.devt = MTD_DEVT(i);
 	dev_set_name(&mtd->dev, "mtd%d", i);
 	dev_set_drvdata(&mtd->dev, mtd);
+	mtd_check_of_node(mtd);
 	of_node_get(mtd_get_of_node(mtd));
 	error = device_register(&mtd->dev);
 	if (error)
-- 
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v4 1/2] dt-bindings: mtd: partitions: Document new dynamic-partition nodes
  2022-05-18 23:32   ` Ansuel Smith
@ 2022-06-01 21:06     ` Rob Herring
  -1 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2022-06-01 21:06 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Krzysztof Kozlowski, Greg Kroah-Hartman, Manivannan Sadhasivam,
	linux-mtd, devicetree, linux-kernel

On Thu, May 19, 2022 at 01:32:57AM +0200, Ansuel Smith wrote:
> Document new dynamic-partition nodes used to provide an OF node for
> partition registred at runtime by parsers. This is required for nvmem
> system to declare and detect nvmem-cells.
> 
> With these special partitions, the reg / offset is not required.
> The label binding is used to match the partition allocated by the
> parser at runtime and the parser will provide reg and offset of the mtd.
> 
> NVMEM will use the data from the parser and provide the NVMEM cells
> declared in the DTS, "connecting" the dynamic partition with a
> static declaration of cells in them.
> 
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
>  .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
>  2 files changed, 61 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> new file mode 100644
> index 000000000000..f57d7b9cae7f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> @@ -0,0 +1,57 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mtd/partitions/dynamic-partition.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Dynamic Partition
> +
> +description: |
> +  This binding describes a single flash partition that is dynamically allocated
> +  by a dedicated parser that is not a fixed-partition parser.
> +
> +  Each child of the parser partition node is then compared and if a match with
> +  the provided label is found then the OF node is assigned.
> +
> +  These special partition definition can be used to give a dynamic partition
> +  an OF node to declare NVMEM cells. An example is declaring the partition
> +  label and all the NVMEM cells in it. The parser will detect the correct reg
> +  and offset and the NVMEM will register the cells in it based on the data
> +  extracted by the parser.
> +
> +maintainers:
> +  - Ansuel Smith <ansuelsmth@gmail.com>
> +
> +properties:
> +  label:
> +    description: The label / name for the partition assigned by the parser at
> +      runtime. This is needed for sybsystem like NVMEM to define cells and

typo

> +      register with this OF node.
> +
> +required:
> +  - label
> +
> +additionalProperties: true
> +
> +examples:
> +  - |
> +    flash {
> +      partitions {
> +        compatible = "qcom,smem-part";
> +
> +        partition-art {
> +          compatible = "nvmem-cells";
> +          #address-cells = <1>;
> +          #size-cells = <1>;
> +          label = "0:art";
> +
> +          macaddr_art_0: macaddr@0 {
> +            reg = <0x0 0x6>;
> +          };
> +
> +          macaddr_art_6: macaddr@6 {
> +            reg = <0x6 0x6>;
> +          };

There's a problem with the schema structure for this which is a common 
problem where we have parent and child nodes with parent defined 
properties in the child nodes (label in this case). The issue is that 
there is not a single schema applied to the child node which contains 
all possible properties sub-node names. This is necessary to check for 
extra, undocumented properties using unevaluatedProperties. The creation 
of spi-periphera-props.yaml is an example of how to address this. I 
suspect that all the partition schemas may need similar restructuring.

The nvmem-cells schema may happen to already have 'label', so it happens 
to work (that and unevaluatedProperties is probably missing in places).

Given this schema is really just one property which is already 
documented for 'partition' nodes, all we really need is to say is if 
'reg' is not present, then 'label' is required:

if:
  not:
    required: [ reg ]
then:
  required: [ label ]


> +        };
> +      };
> +    };
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> index cf3f8c1e035d..b6fa25949fe2 100644
> --- a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> +++ b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> @@ -19,6 +19,10 @@ properties:
>    compatible:
>      const: qcom,smem-part
>  
> +patternProperties:
> +  "^partition-[0-9a-z]+$":
> +    $ref: dynamic-partition.yaml#
> +
>  required:
>    - compatible
>  
> -- 
> 2.34.1
> 
> 

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

* Re: [PATCH v4 1/2] dt-bindings: mtd: partitions: Document new dynamic-partition nodes
@ 2022-06-01 21:06     ` Rob Herring
  0 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2022-06-01 21:06 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Krzysztof Kozlowski, Greg Kroah-Hartman, Manivannan Sadhasivam,
	linux-mtd, devicetree, linux-kernel

On Thu, May 19, 2022 at 01:32:57AM +0200, Ansuel Smith wrote:
> Document new dynamic-partition nodes used to provide an OF node for
> partition registred at runtime by parsers. This is required for nvmem
> system to declare and detect nvmem-cells.
> 
> With these special partitions, the reg / offset is not required.
> The label binding is used to match the partition allocated by the
> parser at runtime and the parser will provide reg and offset of the mtd.
> 
> NVMEM will use the data from the parser and provide the NVMEM cells
> declared in the DTS, "connecting" the dynamic partition with a
> static declaration of cells in them.
> 
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
>  .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
>  2 files changed, 61 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> new file mode 100644
> index 000000000000..f57d7b9cae7f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> @@ -0,0 +1,57 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mtd/partitions/dynamic-partition.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Dynamic Partition
> +
> +description: |
> +  This binding describes a single flash partition that is dynamically allocated
> +  by a dedicated parser that is not a fixed-partition parser.
> +
> +  Each child of the parser partition node is then compared and if a match with
> +  the provided label is found then the OF node is assigned.
> +
> +  These special partition definition can be used to give a dynamic partition
> +  an OF node to declare NVMEM cells. An example is declaring the partition
> +  label and all the NVMEM cells in it. The parser will detect the correct reg
> +  and offset and the NVMEM will register the cells in it based on the data
> +  extracted by the parser.
> +
> +maintainers:
> +  - Ansuel Smith <ansuelsmth@gmail.com>
> +
> +properties:
> +  label:
> +    description: The label / name for the partition assigned by the parser at
> +      runtime. This is needed for sybsystem like NVMEM to define cells and

typo

> +      register with this OF node.
> +
> +required:
> +  - label
> +
> +additionalProperties: true
> +
> +examples:
> +  - |
> +    flash {
> +      partitions {
> +        compatible = "qcom,smem-part";
> +
> +        partition-art {
> +          compatible = "nvmem-cells";
> +          #address-cells = <1>;
> +          #size-cells = <1>;
> +          label = "0:art";
> +
> +          macaddr_art_0: macaddr@0 {
> +            reg = <0x0 0x6>;
> +          };
> +
> +          macaddr_art_6: macaddr@6 {
> +            reg = <0x6 0x6>;
> +          };

There's a problem with the schema structure for this which is a common 
problem where we have parent and child nodes with parent defined 
properties in the child nodes (label in this case). The issue is that 
there is not a single schema applied to the child node which contains 
all possible properties sub-node names. This is necessary to check for 
extra, undocumented properties using unevaluatedProperties. The creation 
of spi-periphera-props.yaml is an example of how to address this. I 
suspect that all the partition schemas may need similar restructuring.

The nvmem-cells schema may happen to already have 'label', so it happens 
to work (that and unevaluatedProperties is probably missing in places).

Given this schema is really just one property which is already 
documented for 'partition' nodes, all we really need is to say is if 
'reg' is not present, then 'label' is required:

if:
  not:
    required: [ reg ]
then:
  required: [ label ]


> +        };
> +      };
> +    };
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> index cf3f8c1e035d..b6fa25949fe2 100644
> --- a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> +++ b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> @@ -19,6 +19,10 @@ properties:
>    compatible:
>      const: qcom,smem-part
>  
> +patternProperties:
> +  "^partition-[0-9a-z]+$":
> +    $ref: dynamic-partition.yaml#
> +
>  required:
>    - compatible
>  
> -- 
> 2.34.1
> 
> 

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v4 1/2] dt-bindings: mtd: partitions: Document new dynamic-partition nodes
  2022-06-01 21:06     ` Rob Herring
@ 2022-06-03 22:57       ` Ansuel Smith
  -1 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-06-03 22:57 UTC (permalink / raw)
  To: Rob Herring
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Krzysztof Kozlowski, Greg Kroah-Hartman, Manivannan Sadhasivam,
	linux-mtd, devicetree, linux-kernel

On Wed, Jun 01, 2022 at 04:06:55PM -0500, Rob Herring wrote:
> On Thu, May 19, 2022 at 01:32:57AM +0200, Ansuel Smith wrote:
> > Document new dynamic-partition nodes used to provide an OF node for
> > partition registred at runtime by parsers. This is required for nvmem
> > system to declare and detect nvmem-cells.
> > 
> > With these special partitions, the reg / offset is not required.
> > The label binding is used to match the partition allocated by the
> > parser at runtime and the parser will provide reg and offset of the mtd.
> > 
> > NVMEM will use the data from the parser and provide the NVMEM cells
> > declared in the DTS, "connecting" the dynamic partition with a
> > static declaration of cells in them.
> > 
> > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > ---
> >  .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
> >  .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
> >  2 files changed, 61 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > new file mode 100644
> > index 000000000000..f57d7b9cae7f
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > @@ -0,0 +1,57 @@
> > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/mtd/partitions/dynamic-partition.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Dynamic Partition
> > +
> > +description: |
> > +  This binding describes a single flash partition that is dynamically allocated
> > +  by a dedicated parser that is not a fixed-partition parser.
> > +
> > +  Each child of the parser partition node is then compared and if a match with
> > +  the provided label is found then the OF node is assigned.
> > +
> > +  These special partition definition can be used to give a dynamic partition
> > +  an OF node to declare NVMEM cells. An example is declaring the partition
> > +  label and all the NVMEM cells in it. The parser will detect the correct reg
> > +  and offset and the NVMEM will register the cells in it based on the data
> > +  extracted by the parser.
> > +
> > +maintainers:
> > +  - Ansuel Smith <ansuelsmth@gmail.com>
> > +
> > +properties:
> > +  label:
> > +    description: The label / name for the partition assigned by the parser at
> > +      runtime. This is needed for sybsystem like NVMEM to define cells and
> 
> typo
> 
> > +      register with this OF node.
> > +
> > +required:
> > +  - label
> > +
> > +additionalProperties: true
> > +
> > +examples:
> > +  - |
> > +    flash {
> > +      partitions {
> > +        compatible = "qcom,smem-part";
> > +
> > +        partition-art {
> > +          compatible = "nvmem-cells";
> > +          #address-cells = <1>;
> > +          #size-cells = <1>;
> > +          label = "0:art";
> > +
> > +          macaddr_art_0: macaddr@0 {
> > +            reg = <0x0 0x6>;
> > +          };
> > +
> > +          macaddr_art_6: macaddr@6 {
> > +            reg = <0x6 0x6>;
> > +          };
> 
> There's a problem with the schema structure for this which is a common 
> problem where we have parent and child nodes with parent defined 
> properties in the child nodes (label in this case). The issue is that 
> there is not a single schema applied to the child node which contains 
> all possible properties sub-node names. This is necessary to check for 
> extra, undocumented properties using unevaluatedProperties. The creation 
> of spi-periphera-props.yaml is an example of how to address this. I 
> suspect that all the partition schemas may need similar restructuring.
> 
> The nvmem-cells schema may happen to already have 'label', so it happens 
> to work (that and unevaluatedProperties is probably missing in places).
> 
> Given this schema is really just one property which is already 
> documented for 'partition' nodes, all we really need is to say is if 
> 'reg' is not present, then 'label' is required:
> 
> if:
>   not:
>     required: [ reg ]
> then:
>   required: [ label ]
> 
>

Just to make sure. The correct way to implement this would be drop the
current dynamic-partition schema and expand the partition.yaml with the
additional if and the extra stuff in the description.
Wanted to keep the 2 thing separated but if necessary I will follow this
path.

> > +        };
> > +      };
> > +    };
> > diff --git a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> > index cf3f8c1e035d..b6fa25949fe2 100644
> > --- a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> > +++ b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> > @@ -19,6 +19,10 @@ properties:
> >    compatible:
> >      const: qcom,smem-part
> >  
> > +patternProperties:
> > +  "^partition-[0-9a-z]+$":
> > +    $ref: dynamic-partition.yaml#
> > +
> >  required:
> >    - compatible
> >  
> > -- 
> > 2.34.1
> > 
> > 

-- 
	Ansuel

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

* Re: [PATCH v4 1/2] dt-bindings: mtd: partitions: Document new dynamic-partition nodes
@ 2022-06-03 22:57       ` Ansuel Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-06-03 22:57 UTC (permalink / raw)
  To: Rob Herring
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Krzysztof Kozlowski, Greg Kroah-Hartman, Manivannan Sadhasivam,
	linux-mtd, devicetree, linux-kernel

On Wed, Jun 01, 2022 at 04:06:55PM -0500, Rob Herring wrote:
> On Thu, May 19, 2022 at 01:32:57AM +0200, Ansuel Smith wrote:
> > Document new dynamic-partition nodes used to provide an OF node for
> > partition registred at runtime by parsers. This is required for nvmem
> > system to declare and detect nvmem-cells.
> > 
> > With these special partitions, the reg / offset is not required.
> > The label binding is used to match the partition allocated by the
> > parser at runtime and the parser will provide reg and offset of the mtd.
> > 
> > NVMEM will use the data from the parser and provide the NVMEM cells
> > declared in the DTS, "connecting" the dynamic partition with a
> > static declaration of cells in them.
> > 
> > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > ---
> >  .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
> >  .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
> >  2 files changed, 61 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > new file mode 100644
> > index 000000000000..f57d7b9cae7f
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > @@ -0,0 +1,57 @@
> > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/mtd/partitions/dynamic-partition.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Dynamic Partition
> > +
> > +description: |
> > +  This binding describes a single flash partition that is dynamically allocated
> > +  by a dedicated parser that is not a fixed-partition parser.
> > +
> > +  Each child of the parser partition node is then compared and if a match with
> > +  the provided label is found then the OF node is assigned.
> > +
> > +  These special partition definition can be used to give a dynamic partition
> > +  an OF node to declare NVMEM cells. An example is declaring the partition
> > +  label and all the NVMEM cells in it. The parser will detect the correct reg
> > +  and offset and the NVMEM will register the cells in it based on the data
> > +  extracted by the parser.
> > +
> > +maintainers:
> > +  - Ansuel Smith <ansuelsmth@gmail.com>
> > +
> > +properties:
> > +  label:
> > +    description: The label / name for the partition assigned by the parser at
> > +      runtime. This is needed for sybsystem like NVMEM to define cells and
> 
> typo
> 
> > +      register with this OF node.
> > +
> > +required:
> > +  - label
> > +
> > +additionalProperties: true
> > +
> > +examples:
> > +  - |
> > +    flash {
> > +      partitions {
> > +        compatible = "qcom,smem-part";
> > +
> > +        partition-art {
> > +          compatible = "nvmem-cells";
> > +          #address-cells = <1>;
> > +          #size-cells = <1>;
> > +          label = "0:art";
> > +
> > +          macaddr_art_0: macaddr@0 {
> > +            reg = <0x0 0x6>;
> > +          };
> > +
> > +          macaddr_art_6: macaddr@6 {
> > +            reg = <0x6 0x6>;
> > +          };
> 
> There's a problem with the schema structure for this which is a common 
> problem where we have parent and child nodes with parent defined 
> properties in the child nodes (label in this case). The issue is that 
> there is not a single schema applied to the child node which contains 
> all possible properties sub-node names. This is necessary to check for 
> extra, undocumented properties using unevaluatedProperties. The creation 
> of spi-periphera-props.yaml is an example of how to address this. I 
> suspect that all the partition schemas may need similar restructuring.
> 
> The nvmem-cells schema may happen to already have 'label', so it happens 
> to work (that and unevaluatedProperties is probably missing in places).
> 
> Given this schema is really just one property which is already 
> documented for 'partition' nodes, all we really need is to say is if 
> 'reg' is not present, then 'label' is required:
> 
> if:
>   not:
>     required: [ reg ]
> then:
>   required: [ label ]
> 
>

Just to make sure. The correct way to implement this would be drop the
current dynamic-partition schema and expand the partition.yaml with the
additional if and the extra stuff in the description.
Wanted to keep the 2 thing separated but if necessary I will follow this
path.

> > +        };
> > +      };
> > +    };
> > diff --git a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> > index cf3f8c1e035d..b6fa25949fe2 100644
> > --- a/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> > +++ b/Documentation/devicetree/bindings/mtd/partitions/qcom,smem-part.yaml
> > @@ -19,6 +19,10 @@ properties:
> >    compatible:
> >      const: qcom,smem-part
> >  
> > +patternProperties:
> > +  "^partition-[0-9a-z]+$":
> > +    $ref: dynamic-partition.yaml#
> > +
> >  required:
> >    - compatible
> >  
> > -- 
> > 2.34.1
> > 
> > 

-- 
	Ansuel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v4 1/2] dt-bindings: mtd: partitions: Document new dynamic-partition nodes
  2022-06-03 22:57       ` Ansuel Smith
@ 2022-06-06 13:36         ` Rob Herring
  -1 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2022-06-06 13:36 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Krzysztof Kozlowski, Greg Kroah-Hartman, Manivannan Sadhasivam,
	linux-mtd, devicetree, linux-kernel

On Sat, Jun 04, 2022 at 12:57:58AM +0200, Ansuel Smith wrote:
> On Wed, Jun 01, 2022 at 04:06:55PM -0500, Rob Herring wrote:
> > On Thu, May 19, 2022 at 01:32:57AM +0200, Ansuel Smith wrote:
> > > Document new dynamic-partition nodes used to provide an OF node for
> > > partition registred at runtime by parsers. This is required for nvmem
> > > system to declare and detect nvmem-cells.
> > > 
> > > With these special partitions, the reg / offset is not required.
> > > The label binding is used to match the partition allocated by the
> > > parser at runtime and the parser will provide reg and offset of the mtd.
> > > 
> > > NVMEM will use the data from the parser and provide the NVMEM cells
> > > declared in the DTS, "connecting" the dynamic partition with a
> > > static declaration of cells in them.
> > > 
> > > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > > ---
> > >  .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
> > >  .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
> > >  2 files changed, 61 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > > 
> > > diff --git a/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > > new file mode 100644
> > > index 000000000000..f57d7b9cae7f
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > > @@ -0,0 +1,57 @@
> > > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/mtd/partitions/dynamic-partition.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Dynamic Partition
> > > +
> > > +description: |
> > > +  This binding describes a single flash partition that is dynamically allocated
> > > +  by a dedicated parser that is not a fixed-partition parser.
> > > +
> > > +  Each child of the parser partition node is then compared and if a match with
> > > +  the provided label is found then the OF node is assigned.
> > > +
> > > +  These special partition definition can be used to give a dynamic partition
> > > +  an OF node to declare NVMEM cells. An example is declaring the partition
> > > +  label and all the NVMEM cells in it. The parser will detect the correct reg
> > > +  and offset and the NVMEM will register the cells in it based on the data
> > > +  extracted by the parser.
> > > +
> > > +maintainers:
> > > +  - Ansuel Smith <ansuelsmth@gmail.com>
> > > +
> > > +properties:
> > > +  label:
> > > +    description: The label / name for the partition assigned by the parser at
> > > +      runtime. This is needed for sybsystem like NVMEM to define cells and
> > 
> > typo
> > 
> > > +      register with this OF node.
> > > +
> > > +required:
> > > +  - label
> > > +
> > > +additionalProperties: true
> > > +
> > > +examples:
> > > +  - |
> > > +    flash {
> > > +      partitions {
> > > +        compatible = "qcom,smem-part";
> > > +
> > > +        partition-art {
> > > +          compatible = "nvmem-cells";
> > > +          #address-cells = <1>;
> > > +          #size-cells = <1>;
> > > +          label = "0:art";
> > > +
> > > +          macaddr_art_0: macaddr@0 {
> > > +            reg = <0x0 0x6>;
> > > +          };
> > > +
> > > +          macaddr_art_6: macaddr@6 {
> > > +            reg = <0x6 0x6>;
> > > +          };
> > 
> > There's a problem with the schema structure for this which is a common 
> > problem where we have parent and child nodes with parent defined 
> > properties in the child nodes (label in this case). The issue is that 
> > there is not a single schema applied to the child node which contains 
> > all possible properties sub-node names. This is necessary to check for 
> > extra, undocumented properties using unevaluatedProperties. The creation 
> > of spi-periphera-props.yaml is an example of how to address this. I 
> > suspect that all the partition schemas may need similar restructuring.
> > 
> > The nvmem-cells schema may happen to already have 'label', so it happens 
> > to work (that and unevaluatedProperties is probably missing in places).
> > 
> > Given this schema is really just one property which is already 
> > documented for 'partition' nodes, all we really need is to say is if 
> > 'reg' is not present, then 'label' is required:
> > 
> > if:
> >   not:
> >     required: [ reg ]
> > then:
> >   required: [ label ]
> > 
> >
> 
> Just to make sure. The correct way to implement this would be drop the
> current dynamic-partition schema and expand the partition.yaml with the
> additional if and the extra stuff in the description.
> Wanted to keep the 2 thing separated but if necessary I will follow this
> path.

Yes. I agree separate would have been nice documentation wise, 
but the schema has ended having such a small difference it doesn't 
make sense anymore.

Rob

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

* Re: [PATCH v4 1/2] dt-bindings: mtd: partitions: Document new dynamic-partition nodes
@ 2022-06-06 13:36         ` Rob Herring
  0 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2022-06-06 13:36 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Krzysztof Kozlowski, Greg Kroah-Hartman, Manivannan Sadhasivam,
	linux-mtd, devicetree, linux-kernel

On Sat, Jun 04, 2022 at 12:57:58AM +0200, Ansuel Smith wrote:
> On Wed, Jun 01, 2022 at 04:06:55PM -0500, Rob Herring wrote:
> > On Thu, May 19, 2022 at 01:32:57AM +0200, Ansuel Smith wrote:
> > > Document new dynamic-partition nodes used to provide an OF node for
> > > partition registred at runtime by parsers. This is required for nvmem
> > > system to declare and detect nvmem-cells.
> > > 
> > > With these special partitions, the reg / offset is not required.
> > > The label binding is used to match the partition allocated by the
> > > parser at runtime and the parser will provide reg and offset of the mtd.
> > > 
> > > NVMEM will use the data from the parser and provide the NVMEM cells
> > > declared in the DTS, "connecting" the dynamic partition with a
> > > static declaration of cells in them.
> > > 
> > > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > > ---
> > >  .../mtd/partitions/dynamic-partition.yaml     | 57 +++++++++++++++++++
> > >  .../mtd/partitions/qcom,smem-part.yaml        |  4 ++
> > >  2 files changed, 61 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > > 
> > > diff --git a/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > > new file mode 100644
> > > index 000000000000..f57d7b9cae7f
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/mtd/partitions/dynamic-partition.yaml
> > > @@ -0,0 +1,57 @@
> > > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/mtd/partitions/dynamic-partition.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Dynamic Partition
> > > +
> > > +description: |
> > > +  This binding describes a single flash partition that is dynamically allocated
> > > +  by a dedicated parser that is not a fixed-partition parser.
> > > +
> > > +  Each child of the parser partition node is then compared and if a match with
> > > +  the provided label is found then the OF node is assigned.
> > > +
> > > +  These special partition definition can be used to give a dynamic partition
> > > +  an OF node to declare NVMEM cells. An example is declaring the partition
> > > +  label and all the NVMEM cells in it. The parser will detect the correct reg
> > > +  and offset and the NVMEM will register the cells in it based on the data
> > > +  extracted by the parser.
> > > +
> > > +maintainers:
> > > +  - Ansuel Smith <ansuelsmth@gmail.com>
> > > +
> > > +properties:
> > > +  label:
> > > +    description: The label / name for the partition assigned by the parser at
> > > +      runtime. This is needed for sybsystem like NVMEM to define cells and
> > 
> > typo
> > 
> > > +      register with this OF node.
> > > +
> > > +required:
> > > +  - label
> > > +
> > > +additionalProperties: true
> > > +
> > > +examples:
> > > +  - |
> > > +    flash {
> > > +      partitions {
> > > +        compatible = "qcom,smem-part";
> > > +
> > > +        partition-art {
> > > +          compatible = "nvmem-cells";
> > > +          #address-cells = <1>;
> > > +          #size-cells = <1>;
> > > +          label = "0:art";
> > > +
> > > +          macaddr_art_0: macaddr@0 {
> > > +            reg = <0x0 0x6>;
> > > +          };
> > > +
> > > +          macaddr_art_6: macaddr@6 {
> > > +            reg = <0x6 0x6>;
> > > +          };
> > 
> > There's a problem with the schema structure for this which is a common 
> > problem where we have parent and child nodes with parent defined 
> > properties in the child nodes (label in this case). The issue is that 
> > there is not a single schema applied to the child node which contains 
> > all possible properties sub-node names. This is necessary to check for 
> > extra, undocumented properties using unevaluatedProperties. The creation 
> > of spi-periphera-props.yaml is an example of how to address this. I 
> > suspect that all the partition schemas may need similar restructuring.
> > 
> > The nvmem-cells schema may happen to already have 'label', so it happens 
> > to work (that and unevaluatedProperties is probably missing in places).
> > 
> > Given this schema is really just one property which is already 
> > documented for 'partition' nodes, all we really need is to say is if 
> > 'reg' is not present, then 'label' is required:
> > 
> > if:
> >   not:
> >     required: [ reg ]
> > then:
> >   required: [ label ]
> > 
> >
> 
> Just to make sure. The correct way to implement this would be drop the
> current dynamic-partition schema and expand the partition.yaml with the
> additional if and the extra stuff in the description.
> Wanted to keep the 2 thing separated but if necessary I will follow this
> path.

Yes. I agree separate would have been nice documentation wise, 
but the schema has ended having such a small difference it doesn't 
make sense anymore.

Rob

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2022-06-06 13:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18 23:32 [PATCH v4 0/2] Add nvmem support for dynamic partitions Ansuel Smith
2022-05-18 23:32 ` Ansuel Smith
2022-05-18 23:32 ` [PATCH v4 1/2] dt-bindings: mtd: partitions: Document new dynamic-partition nodes Ansuel Smith
2022-05-18 23:32   ` Ansuel Smith
2022-06-01 21:06   ` Rob Herring
2022-06-01 21:06     ` Rob Herring
2022-06-03 22:57     ` Ansuel Smith
2022-06-03 22:57       ` Ansuel Smith
2022-06-06 13:36       ` Rob Herring
2022-06-06 13:36         ` Rob Herring
2022-05-18 23:32 ` [PATCH v4 2/2] mtd: core: introduce of support for dynamic partitions Ansuel Smith
2022-05-18 23:32   ` Ansuel Smith

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.