devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] mtd: ubi: behave like a good MTD citizen
@ 2023-05-02 16:47 Daniel Golle
  2023-05-02 16:48 ` [PATCH 3/4] dt-bindings: mtd: partitions: add linux,ubi compatible Daniel Golle
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Golle @ 2023-05-02 16:47 UTC (permalink / raw)
  To: linux-mtd, devicetree, linux-kernel, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Rob Herring,
	Krzysztof Kozlowski, Zhihao Cheng, Rafał Miłecki

As of now one can easily trigger the existence of "ghost" UBI devices
or even worse by removing e.g. the SPI bus driver which previously
provided access to an SPI-NAND chip.

Make UBI behave more like other MTD users and create/remove UBI devices
based on MTD notifications. As removing could previously fail in case
of an ubiblock device still being in use, make sure there are no
excuses preventing release of an already gone MTD partition.

This makes it possible to attach UBI devices immediately after the MTD
partition becomes available, which will allow using UBI volumes as
nvmem-cells provider in the future [1]. Introduce new device tree
compatible "linux,ubi" to be used on MTD partitions which should be
attached.

In order to make sure ubiblock devices are still created according to
the module or kernel parameters, let ubiblock creation from parameters
be triggered by UBI_VOLUME_ADDED notifications instead of trying only
once during boot.

[1]: https://forum.openwrt.org/t/asus-tuf-ax4200-support/155738/44?u=daniel

Daniel Golle (4):
  mtd: ubi: block: don't return on error when removing
  mtd: ubi: block: use notifier to create ubiblock from parameter
  dt-bindings: mtd: partitions: add linux,ubi
  mtd: ubi: attach MTD partition from device-tree

 .../bindings/mtd/partitions/ubi.yaml          |  49 +++++
 drivers/mtd/ubi/block.c                       | 158 ++++++++-------
 drivers/mtd/ubi/build.c                       | 189 ++++++++++++------
 drivers/mtd/ubi/cdev.c                        |   4 +-
 drivers/mtd/ubi/ubi.h                         |   6 +-
 5 files changed, 271 insertions(+), 135 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/ubi.yaml


base-commit: b5fda08ef213352ac2df7447611eb4d383cce929
-- 
2.40.1


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

* [PATCH 3/4] dt-bindings: mtd: partitions: add linux,ubi compatible
  2023-05-02 16:47 [PATCH 0/4] mtd: ubi: behave like a good MTD citizen Daniel Golle
@ 2023-05-02 16:48 ` Daniel Golle
  2023-05-05 21:56   ` Rob Herring
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Golle @ 2023-05-02 16:48 UTC (permalink / raw)
  To: linux-mtd, devicetree, linux-kernel, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Rob Herring,
	Krzysztof Kozlowski, Zhihao Cheng, Rafał Miłecki

Add bindings for MTD partitions to be attached as UBI devices.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 .../bindings/mtd/partitions/ubi.yaml          | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/ubi.yaml

diff --git a/Documentation/devicetree/bindings/mtd/partitions/ubi.yaml b/Documentation/devicetree/bindings/mtd/partitions/ubi.yaml
new file mode 100644
index 0000000000000..aa02fbbd50716
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partitions/ubi.yaml
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/ubi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Unsorted Block Images (UBI)
+
+description: |
+ Unsorted Block Images (UBI) is a volume management system typically
+ used on NAND flash providing bad block management as well as
+ wear-leveling.
+ Any partition containing the compatible "linux,ubi" will be attached
+ as UBI device.
+
+maintainers:
+  - Daniel Golle <daniel@makrotopia.org>
+
+allOf:
+  - $ref: /schemas/mtd/partitions/partition.yaml#
+
+properties:
+  compatible:
+    const: linux,ubi
+
+required:
+  - compatible
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    partitions {
+        compatible = "fixed-partitions";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        partition@0 {
+            label = "bootloader";
+            reg = <0x000000 0x100000>;
+            read-only;
+        };
+
+        ubi@100000 {
+            compatible = "linux,ubi";
+            label = "ubi";
+            reg = <0x100000 0x7f00000>;
+        };
+    };
-- 
2.40.1


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

* Re: [PATCH 3/4] dt-bindings: mtd: partitions: add linux,ubi compatible
  2023-05-02 16:48 ` [PATCH 3/4] dt-bindings: mtd: partitions: add linux,ubi compatible Daniel Golle
@ 2023-05-05 21:56   ` Rob Herring
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Herring @ 2023-05-05 21:56 UTC (permalink / raw)
  To: Daniel Golle
  Cc: linux-mtd, devicetree, linux-kernel, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Krzysztof Kozlowski,
	Zhihao Cheng, Rafał Miłecki

On Tue, May 02, 2023 at 05:48:39PM +0100, Daniel Golle wrote:
> Add bindings for MTD partitions to be attached as UBI devices.
> 
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
>  .../bindings/mtd/partitions/ubi.yaml          | 49 +++++++++++++++++++

linux,ubi.yaml

>  1 file changed, 49 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mtd/partitions/ubi.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/ubi.yaml b/Documentation/devicetree/bindings/mtd/partitions/ubi.yaml
> new file mode 100644
> index 0000000000000..aa02fbbd50716
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/partitions/ubi.yaml
> @@ -0,0 +1,49 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mtd/partitions/ubi.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Unsorted Block Images (UBI)
> +
> +description: |
> + Unsorted Block Images (UBI) is a volume management system typically
> + used on NAND flash providing bad block management as well as
> + wear-leveling.
> + Any partition containing the compatible "linux,ubi" will be attached
> + as UBI device.
> +
> +maintainers:
> +  - Daniel Golle <daniel@makrotopia.org>
> +
> +allOf:
> +  - $ref: /schemas/mtd/partitions/partition.yaml#
> +
> +properties:
> +  compatible:
> +    const: linux,ubi
> +
> +required:
> +  - compatible
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    partitions {
> +        compatible = "fixed-partitions";
> +        #address-cells = <1>;
> +        #size-cells = <1>;
> +
> +        partition@0 {
> +            label = "bootloader";
> +            reg = <0x000000 0x100000>;
> +            read-only;
> +        };
> +
> +        ubi@100000 {
> +            compatible = "linux,ubi";
> +            label = "ubi";
> +            reg = <0x100000 0x7f00000>;
> +        };
> +    };
> -- 
> 2.40.1
> 

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

end of thread, other threads:[~2023-05-05 21:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02 16:47 [PATCH 0/4] mtd: ubi: behave like a good MTD citizen Daniel Golle
2023-05-02 16:48 ` [PATCH 3/4] dt-bindings: mtd: partitions: add linux,ubi compatible Daniel Golle
2023-05-05 21:56   ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).