devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] mtd: improve block2mtd + airoha parser
@ 2024-08-04 11:41 Christian Marangi
  2024-08-04 11:41 ` [PATCH 1/6] dt-bindings: nvme: Document nvme-card compatible Christian Marangi
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Christian Marangi @ 2024-08-04 11:41 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Joern Engel, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, Christian Marangi, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme

This small series handle 2 problems.

It does try to ""standardize"" the usage of block2mtd module with
MTD OF nodes.

It is very easy to add support for MTD parser by just adding an
OF node to the mtd created for block2mtd.

This apply only if the root block is used for block2mtd to allow
scenario where the full eMMC or an NVME is used for MTD and it doesn't
have any partition table.

To also support NVME, similar to how it's done with eMMC, we introduce
a subnode to the NVME controller that needs to have the "nvme-card"
compatible where a dev can define fixed-paritions for MTD parser usage.

This series also add support for the Airoha partition table where
the last partition is always ART and is placed at the end of the flash.

This require dynamic calculation of the offset as some dedicated
driver for bad block management might be used that reserve some space
at the end of the flash for block accounting.

New aarch64 Airoha SoC make use of this partition table and use block2mtd
for eMMC to treat them as MTD with custom bad block management and block
tracking.

Christian Marangi (6):
  dt-bindings: nvme: Document nvme-card compatible
  nvme: assign of_node to nvme device
  dt-bindings: mmc: add property for partitions node in mmc-card node
  block2mtd: attach device OF node to MTD device
  dt-bindings: mtd: Add Documentation for Airoha fixed-partitions
  mtd: parser: add support for Airoha parser

 .../devicetree/bindings/mmc/mmc-card.yaml     | 40 ++++++++++
 .../partitions/airoha,fixed-partitions.yaml   | 80 +++++++++++++++++++
 .../devicetree/bindings/nvme/nvme-card.yaml   | 78 ++++++++++++++++++
 drivers/mtd/devices/block2mtd.c               | 11 +++
 drivers/mtd/parsers/Kconfig                   | 10 +++
 drivers/mtd/parsers/Makefile                  |  1 +
 drivers/mtd/parsers/ofpart_airoha.c           | 56 +++++++++++++
 drivers/mtd/parsers/ofpart_airoha.h           | 18 +++++
 drivers/mtd/parsers/ofpart_core.c             |  6 ++
 drivers/nvme/host/core.c                      |  3 +
 10 files changed, 303 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml
 create mode 100644 Documentation/devicetree/bindings/nvme/nvme-card.yaml
 create mode 100644 drivers/mtd/parsers/ofpart_airoha.c
 create mode 100644 drivers/mtd/parsers/ofpart_airoha.h

-- 
2.45.2


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

* [PATCH 1/6] dt-bindings: nvme: Document nvme-card compatible
  2024-08-04 11:41 [PATCH 0/6] mtd: improve block2mtd + airoha parser Christian Marangi
@ 2024-08-04 11:41 ` Christian Marangi
  2024-08-04 11:41 ` [PATCH 2/6] nvme: assign of_node to nvme device Christian Marangi
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Christian Marangi @ 2024-08-04 11:41 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Joern Engel, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, Christian Marangi, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme

Document new nvme-card compatible to permit defining fixed-partition in
DT by the use of the block2mtd module to use block devices as MTD.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 .../devicetree/bindings/nvme/nvme-card.yaml   | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvme/nvme-card.yaml

diff --git a/Documentation/devicetree/bindings/nvme/nvme-card.yaml b/Documentation/devicetree/bindings/nvme/nvme-card.yaml
new file mode 100644
index 000000000000..20e9a877fac4
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvme/nvme-card.yaml
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvme/nvme-card.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVME Card
+
+maintainers:
+  - Christian Marangi <ansuelsmth@gmail.com>
+
+description: |
+  This documents describes the devicetree bindings for a NVME controller
+  child node describing a nvme-card.
+
+properties:
+  compatible:
+    const: nvme-card
+
+  partitions:
+    $ref: /schemas/mtd/partitions/partitions.yaml
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    pcie {
+        #address-cells = <3>;
+        #size-cells = <2>;
+
+        bridge@0,0 {
+            reg = <0x00000000 0 0 0 0>;
+            #address-cells = <3>;
+            #size-cells = <2>;
+            ranges;
+
+            nvme@1,0 {
+                compatible = "pci144d,a809";
+
+                reg = <0x00010000 0 0 0 0>;
+                #address-cells = <1>;
+                #size-cells = <1>;
+
+                card {
+                    compatible = "nvme-card";
+
+                    partitions {
+                        compatible = "fixed-partitions";
+                        #address-cells = <1>;
+                        #size-cells = <1>;
+
+                        bootloader@0 {
+                          label = "bootloader";
+                          reg = <0x00000000 0x00080000>;
+                        };
+
+                        tclinux@80000 {
+                          label = "tclinux";
+                          reg = <0x00080000 0x02800000>;
+                        };
+
+                        tclinux_slave@2880000 {
+                          label = "tclinux_slave";
+                          reg = <0x02880000 0x02800000>;
+                        };
+
+                        rootfs_data@5080000 {
+                          label = "rootfs_data";
+                          reg = <0x5080000 0x00800000>;
+                        };
+                    };
+                };
+            };
+        };
+    };
-- 
2.45.2


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

* [PATCH 2/6] nvme: assign of_node to nvme device
  2024-08-04 11:41 [PATCH 0/6] mtd: improve block2mtd + airoha parser Christian Marangi
  2024-08-04 11:41 ` [PATCH 1/6] dt-bindings: nvme: Document nvme-card compatible Christian Marangi
@ 2024-08-04 11:41 ` Christian Marangi
  2024-08-04 13:48   ` kernel test robot
  2024-08-04 15:21   ` kernel test robot
  2024-08-04 11:41 ` [PATCH 3/6] dt-bindings: mmc: add property for partitions node in mmc-card node Christian Marangi
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 11+ messages in thread
From: Christian Marangi @ 2024-08-04 11:41 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Joern Engel, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, Christian Marangi, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme

Introduce support for a dedicated node for a nvme card. This will be a
subnode of the nvme controller node that will have the "nvme-card"
compatible.

This follow a similar implementation done for mmc where the specific mmc
card have a dedicated of_node.

This can be used for scenario where block2mtd module is used to declare
partition in DT and block2mtd is called on the root block of the nvme
card, permitting the usage of fixed-partition parser or alternative
ones.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/nvme/host/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 053d5b4909cd..b9553bb8fade 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4651,6 +4651,7 @@ void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
 	nvme_hwmon_exit(ctrl);
 	nvme_fault_inject_fini(&ctrl->fault_inject);
 	dev_pm_qos_hide_latency_tolerance(ctrl->device);
+	of_node_put(ctrl->device->of_node);
 	cdev_device_del(&ctrl->cdev, ctrl->device);
 	nvme_put_ctrl(ctrl);
 }
@@ -4771,6 +4772,8 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
 	else
 		ctrl->device->groups = nvme_dev_attr_groups;
 	ctrl->device->release = nvme_free_ctrl;
+	ctrl->device->of_node = of_get_compatible_child(ctrl->dev->of_node,
+							"nvme-card");
 	dev_set_drvdata(ctrl->device, ctrl);
 
 	return ret;
-- 
2.45.2


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

* [PATCH 3/6] dt-bindings: mmc: add property for partitions node in mmc-card node
  2024-08-04 11:41 [PATCH 0/6] mtd: improve block2mtd + airoha parser Christian Marangi
  2024-08-04 11:41 ` [PATCH 1/6] dt-bindings: nvme: Document nvme-card compatible Christian Marangi
  2024-08-04 11:41 ` [PATCH 2/6] nvme: assign of_node to nvme device Christian Marangi
@ 2024-08-04 11:41 ` Christian Marangi
  2024-08-04 11:41 ` [PATCH 4/6] block2mtd: attach device OF node to MTD device Christian Marangi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Christian Marangi @ 2024-08-04 11:41 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Joern Engel, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, Christian Marangi, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme

Add property for defining partitions node in mmc-card node to define
partitions in DT by the use of the block2mtd module to use block
devices as MTD.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 .../devicetree/bindings/mmc/mmc-card.yaml     | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.yaml b/Documentation/devicetree/bindings/mmc/mmc-card.yaml
index fd347126449a..0f32d24417bc 100644
--- a/Documentation/devicetree/bindings/mmc/mmc-card.yaml
+++ b/Documentation/devicetree/bindings/mmc/mmc-card.yaml
@@ -26,6 +26,9 @@ properties:
       Use this to indicate that the mmc-card has a broken hpi
       implementation, and that hpi should not be used.
 
+  partitions:
+    $ref: /schemas/mtd/partitions/partitions.yaml
+
 required:
   - compatible
   - reg
@@ -45,4 +48,41 @@ examples:
         };
     };
 
+    mmc1 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        card@0 {
+            compatible = "mmc-card";
+            reg = <0>;
+            broken-hpi;
+
+            partitions {
+                compatible = "fixed-partitions";
+                #address-cells = <1>;
+                #size-cells = <1>;
+
+                bootloader@0 {
+                  label = "bootloader";
+                  reg = <0x00000000 0x00080000>;
+                };
+
+                tclinux@80000 {
+                  label = "tclinux";
+                  reg = <0x00080000 0x02800000>;
+                };
+
+                tclinux_slave@2880000 {
+                  label = "tclinux_slave";
+                  reg = <0x02880000 0x02800000>;
+                };
+
+                rootfs_data@5080000 {
+                  label = "rootfs_data";
+                  reg = <0x5080000 0x00800000>;
+                };
+            };
+        };
+    };
+
 ...
-- 
2.45.2


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

* [PATCH 4/6] block2mtd: attach device OF node to MTD device
  2024-08-04 11:41 [PATCH 0/6] mtd: improve block2mtd + airoha parser Christian Marangi
                   ` (2 preceding siblings ...)
  2024-08-04 11:41 ` [PATCH 3/6] dt-bindings: mmc: add property for partitions node in mmc-card node Christian Marangi
@ 2024-08-04 11:41 ` Christian Marangi
  2024-08-04 13:58   ` kernel test robot
  2024-08-04 11:41 ` [PATCH 5/6] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions Christian Marangi
  2024-08-04 11:41 ` [PATCH 6/6] mtd: parser: add support for Airoha parser Christian Marangi
  5 siblings, 1 reply; 11+ messages in thread
From: Christian Marangi @ 2024-08-04 11:41 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Joern Engel, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, Christian Marangi, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme

Attach device OF node to MTD device if defined and the root blockdev is
being used to add support for partitions defined in DT node.

This permits the usage of fixed-partition or alternative parser with the
use of block2mtd module.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/mtd/devices/block2mtd.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index b06c8dd51562..0c4ecea51717 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -324,6 +324,15 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size,
 	dev->mtd.priv = dev;
 	dev->mtd.owner = THIS_MODULE;
 
+	/*
+	 * Check if we are using root blockdev.
+	 * If it's the case, connect the MTD of_node to the ddev parent
+	 * to support providing partition in DT node.
+	 */
+	ddev = disk_to_dev(dev->blkdev->bd_disk);
+	if (ddev == &dev->blkdev->bd_device)
+		dev->mtd.dev.of_node = of_node_get(ddev->parent->of_node);
+
 	if (mtd_device_register(&dev->mtd, NULL, 0)) {
 		/* Device didn't get added, so free the entry */
 		goto err_destroy_mutex;
@@ -337,6 +346,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size,
 	return dev;
 
 err_destroy_mutex:
+	of_node_put(dev->mtd.dev.of_node);
 	mutex_destroy(&dev->write_mutex);
 err_free_block2mtd:
 	block2mtd_free_device(dev);
@@ -515,6 +525,7 @@ static void block2mtd_exit(void)
 		struct block2mtd_dev *dev = list_entry(pos, typeof(*dev), list);
 		block2mtd_sync(&dev->mtd);
 		mtd_device_unregister(&dev->mtd);
+		of_node_put(dev->mtd.dev.of_node);
 		mutex_destroy(&dev->write_mutex);
 		pr_info("mtd%d: [%s] removed\n",
 			dev->mtd.index,
-- 
2.45.2


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

* [PATCH 5/6] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions
  2024-08-04 11:41 [PATCH 0/6] mtd: improve block2mtd + airoha parser Christian Marangi
                   ` (3 preceding siblings ...)
  2024-08-04 11:41 ` [PATCH 4/6] block2mtd: attach device OF node to MTD device Christian Marangi
@ 2024-08-04 11:41 ` Christian Marangi
  2024-08-04 12:24   ` Rob Herring (Arm)
  2024-08-04 11:41 ` [PATCH 6/6] mtd: parser: add support for Airoha parser Christian Marangi
  5 siblings, 1 reply; 11+ messages in thread
From: Christian Marangi @ 2024-08-04 11:41 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Joern Engel, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, Christian Marangi, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme

Add Documentation for Airoha fixed-partitions compatibles.

Airoha based SoC declare a dedicated partition at the end of the flash to
store calibration and device specific data, in addition to fixed
partitions.
The offset of this special partition is not well defined as it depends on
flash bad block management that might require reserving additional space
at the end of the flash.

This binding allows defining all fixed partitions and marking the last one
to detect the correct offset.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 .../partitions/airoha,fixed-partitions.yaml   | 80 +++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml

diff --git a/Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml
new file mode 100644
index 000000000000..da7879c98317
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml
@@ -0,0 +1,80 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/airoha,fixed-partitions.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Airoha SoC partitioning
+
+description: |
+  Airoha based SoC declare a dedicated partition at the end of the flash to
+  store calibration and device specific data, in addition to fixed partitions.
+  The offset of this special partition is not well defined as it depends on
+  flash bad block management that might require reserving additional space at the
+  end of the flash.
+
+  This binding allows defining all fixed partitions and marking the last one to
+  detect the correct offset.
+
+maintainers:
+  - Christian Marangi <ansuelsmth@gmail.com>
+
+select: false
+
+properties:
+  compatible:
+    const: airoha,fixed-partition
+
+  "#address-cells":
+    enum: [ 1, 2 ]
+
+  "#size-cells":
+    enum: [ 1, 2 ]
+
+patternProperties:
+  "^partition@[0-9a-f]+$":
+    $ref: partition.yaml#
+    properties:
+      compatible:
+        const: airoha,dynamic-art
+    unevaluatedProperties: false
+
+required:
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    partitions {
+        compatible = "airoha,fixed-partitions";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        partition@0 {
+          label = "bootloader";
+          reg = <0x00000000 0x00080000>;
+        };
+
+        partition@80000 {
+          label = "tclinux";
+          reg = <0x00080000 0x02800000>;
+        };
+
+        partition@2880000 {
+          label = "tclinux_slave";
+          reg = <0x02880000 0x02800000>;
+        };
+
+        partition@5080000 {
+          label = "rootfs_data";
+          reg = <0x5080000 0x00800000>;
+        };
+
+        partition@ffffffff {
+          compatible = "airoha,dynamic-art";
+          label = "art";
+          reg = <0xffffffff 0x00300000>;
+        };
+    };
-- 
2.45.2


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

* [PATCH 6/6] mtd: parser: add support for Airoha parser
  2024-08-04 11:41 [PATCH 0/6] mtd: improve block2mtd + airoha parser Christian Marangi
                   ` (4 preceding siblings ...)
  2024-08-04 11:41 ` [PATCH 5/6] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions Christian Marangi
@ 2024-08-04 11:41 ` Christian Marangi
  5 siblings, 0 replies; 11+ messages in thread
From: Christian Marangi @ 2024-08-04 11:41 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Joern Engel, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, Christian Marangi, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme

Add support for Airoha parser based on a post parse ofpart function.

Airoha partition table follow normal fixed-partition implementation
with a special implementation for the ART partition. This is always the
last partition and is placed from the end of the flash - the partition
size.

To enable this special implementation for ART partition, the relevant
node require the "airoha,dynamic-art" compatible. With that declared,
offset value is ignored and real offset is updated with the calculated
value.

Due to usage of specific bad block management driver, the MTD size might
vary hence the ART partition offset needs to be dynamically parsed and
can't be declared statically.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/mtd/parsers/Kconfig         | 10 ++++++
 drivers/mtd/parsers/Makefile        |  1 +
 drivers/mtd/parsers/ofpart_airoha.c | 56 +++++++++++++++++++++++++++++
 drivers/mtd/parsers/ofpart_airoha.h | 18 ++++++++++
 drivers/mtd/parsers/ofpart_core.c   |  6 ++++
 5 files changed, 91 insertions(+)
 create mode 100644 drivers/mtd/parsers/ofpart_airoha.c
 create mode 100644 drivers/mtd/parsers/ofpart_airoha.h

diff --git a/drivers/mtd/parsers/Kconfig b/drivers/mtd/parsers/Kconfig
index da03ab6efe04..d6c53aa16ea6 100644
--- a/drivers/mtd/parsers/Kconfig
+++ b/drivers/mtd/parsers/Kconfig
@@ -72,6 +72,16 @@ config MTD_OF_PARTS
 	  flash memory node, as described in
 	  Documentation/devicetree/bindings/mtd/mtd.yaml.
 
+config MTD_OF_PARTS_AIROHA
+	bool "Airoha EN7815 partitioning support"
+	depends on MTD_OF_PARTS && (ARCH_AIROHA || COMPILE_TEST)
+	default ARCH_AIROHA
+	help
+	  This provides partitions parser for Airoha EN7815 family devices
+	  that can have dynamic "ART" partition at the end of the flash.
+	  It takes care of finding the correct offset and update property
+	  with it.
+
 config MTD_OF_PARTS_BCM4908
 	bool "BCM4908 partitioning support"
 	depends on MTD_OF_PARTS && (ARCH_BCMBCA || COMPILE_TEST)
diff --git a/drivers/mtd/parsers/Makefile b/drivers/mtd/parsers/Makefile
index 9b00c62b837a..d67f9b4d39ac 100644
--- a/drivers/mtd/parsers/Makefile
+++ b/drivers/mtd/parsers/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_MTD_BRCM_U_BOOT)		+= brcm_u-boot.o
 obj-$(CONFIG_MTD_CMDLINE_PARTS)		+= cmdlinepart.o
 obj-$(CONFIG_MTD_OF_PARTS)		+= ofpart.o
 ofpart-y				+= ofpart_core.o
+ofpart-$(CONFIG_MTD_OF_PARTS_AIROHA)	+= ofpart_airoha.o
 ofpart-$(CONFIG_MTD_OF_PARTS_BCM4908)	+= ofpart_bcm4908.o
 ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS)+= ofpart_linksys_ns.o
 obj-$(CONFIG_MTD_PARSER_IMAGETAG)	+= parser_imagetag.o
diff --git a/drivers/mtd/parsers/ofpart_airoha.c b/drivers/mtd/parsers/ofpart_airoha.c
new file mode 100644
index 000000000000..905df53f7716
--- /dev/null
+++ b/drivers/mtd/parsers/ofpart_airoha.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2024 Christian Marangi <ansuelsmth@gmail.com>
+ */
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#include "ofpart_airoha.h"
+
+int airoha_partitions_post_parse(struct mtd_info *mtd,
+				 struct mtd_partition *parts,
+				 int nr_parts)
+{
+	struct mtd_partition *part;
+	int len, a_cells, s_cells;
+	struct device_node *pp;
+	struct property *prop;
+	const __be32 *reg;
+	__be32 *new_reg;
+
+	part = &parts[nr_parts - 1];
+	pp = part->of_node;
+
+	/* Skip if ART partition have a valid offset instead of a dynamic one */
+	if (!of_device_is_compatible(pp, "airoha,dynamic-art"))
+		return 0;
+
+	/* ART partition is set at the end of flash - size */
+	part->offset = mtd->size - part->size;
+
+	/* Update the offset with the new calculate value in DT */
+	prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+	if (!prop)
+		return -ENOMEM;
+
+	/* Reg already validated by fixed-partition parser */
+	reg = of_get_property(pp, "reg", &len);
+
+	/* Fixed partition */
+	a_cells = of_n_addr_cells(pp);
+	s_cells = of_n_size_cells(pp);
+
+	prop->name = "reg";
+	prop->length = (a_cells + s_cells) * sizeof(__be32);
+	prop->value = kmemdup(reg, (a_cells + s_cells) * sizeof(__be32),
+			      GFP_KERNEL);
+	new_reg = prop->value;
+	memset(new_reg, 0, a_cells * sizeof(__be32));
+	new_reg[a_cells - 1] = cpu_to_be32(part->offset);
+	if (a_cells > 1)
+		new_reg[0] = cpu_to_be32(part->offset >> 32);
+	of_update_property(pp, prop);
+
+	return 0;
+}
diff --git a/drivers/mtd/parsers/ofpart_airoha.h b/drivers/mtd/parsers/ofpart_airoha.h
new file mode 100644
index 000000000000..3e8a8456c13a
--- /dev/null
+++ b/drivers/mtd/parsers/ofpart_airoha.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __OFPART_AIROHA_H
+#define __OFPART_AIROHA_H
+
+#ifdef CONFIG_MTD_OF_PARTS_AIROHA
+int airoha_partitions_post_parse(struct mtd_info *mtd,
+				 struct mtd_partition *parts,
+				 int nr_parts);
+#else
+static inline int airoha_partitions_post_parse(struct mtd_info *mtd,
+					       struct mtd_partition *parts,
+					       int nr_parts)
+{
+	return -EOPNOTSUPP;
+}
+#endif
+
+#endif
diff --git a/drivers/mtd/parsers/ofpart_core.c b/drivers/mtd/parsers/ofpart_core.c
index e7b8e9d0a910..9e078636d158 100644
--- a/drivers/mtd/parsers/ofpart_core.c
+++ b/drivers/mtd/parsers/ofpart_core.c
@@ -16,6 +16,7 @@
 #include <linux/slab.h>
 #include <linux/mtd/partitions.h>
 
+#include "ofpart_airoha.h"
 #include "ofpart_bcm4908.h"
 #include "ofpart_linksys_ns.h"
 
@@ -23,6 +24,10 @@ struct fixed_partitions_quirks {
 	int (*post_parse)(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
 };
 
+static struct fixed_partitions_quirks airoha_partitions_quirks = {
+	.post_parse = airoha_partitions_post_parse,
+};
+
 static struct fixed_partitions_quirks bcm4908_partitions_quirks = {
 	.post_parse = bcm4908_partitions_post_parse,
 };
@@ -192,6 +197,7 @@ static const struct of_device_id parse_ofpart_match_table[] = {
 	/* Generic */
 	{ .compatible = "fixed-partitions" },
 	/* Customized */
+	{ .compatible = "airoha,fixed-partitions", .data = &airoha_partitions_quirks, },
 	{ .compatible = "brcm,bcm4908-partitions", .data = &bcm4908_partitions_quirks, },
 	{ .compatible = "linksys,ns-partitions", .data = &linksys_ns_partitions_quirks, },
 	{},
-- 
2.45.2


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

* Re: [PATCH 5/6] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions
  2024-08-04 11:41 ` [PATCH 5/6] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions Christian Marangi
@ 2024-08-04 12:24   ` Rob Herring (Arm)
  0 siblings, 0 replies; 11+ messages in thread
From: Rob Herring (Arm) @ 2024-08-04 12:24 UTC (permalink / raw)
  To: Christian Marangi
  Cc: Krzysztof Kozlowski, Joern Engel, linux-nvme, Ulf Hansson,
	linux-mtd, linux-mmc, Florian Fainelli, Jens Axboe, devicetree,
	Thomas Bogendoerfer, Christoph Hellwig, Wolfram Sang,
	Richard Weinberger, linux-kernel, Keith Busch, Sagi Grimberg,
	Conor Dooley, Vignesh Raghavendra, Miquel Raynal


On Sun, 04 Aug 2024 13:41:05 +0200, Christian Marangi wrote:
> Add Documentation for Airoha fixed-partitions compatibles.
> 
> Airoha based SoC declare a dedicated partition at the end of the flash to
> store calibration and device specific data, in addition to fixed
> partitions.
> The offset of this special partition is not well defined as it depends on
> flash bad block management that might require reserving additional space
> at the end of the flash.
> 
> This binding allows defining all fixed partitions and marking the last one
> to detect the correct offset.
> 
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
>  .../partitions/airoha,fixed-partitions.yaml   | 80 +++++++++++++++++++
>  1 file changed, 80 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.example.dtb: /example-0/partitions: failed to match any schema with compatible: ['airoha,fixed-partitions']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20240804114108.1893-6-ansuelsmth@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


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

* Re: [PATCH 2/6] nvme: assign of_node to nvme device
  2024-08-04 11:41 ` [PATCH 2/6] nvme: assign of_node to nvme device Christian Marangi
@ 2024-08-04 13:48   ` kernel test robot
  2024-08-04 15:21   ` kernel test robot
  1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-08-04 13:48 UTC (permalink / raw)
  To: Christian Marangi, Ulf Hansson, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Joern Engel, Keith Busch, Jens Axboe,
	Christoph Hellwig, Sagi Grimberg, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme
  Cc: oe-kbuild-all

Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.11-rc1 next-20240802]
[cannot apply to mtd/mtd/next mtd/mtd/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-nvme-Document-nvme-card-compatible/20240804-194357
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20240804114108.1893-3-ansuelsmth%40gmail.com
patch subject: [PATCH 2/6] nvme: assign of_node to nvme device
config: i386-buildonly-randconfig-002-20240804 (https://download.01.org/0day-ci/archive/20240804/202408042134.wVQ7VdU6-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240804/202408042134.wVQ7VdU6-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408042134.wVQ7VdU6-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/nvme/host/core.c: In function 'nvme_uninit_ctrl':
>> drivers/nvme/host/core.c:4654:9: error: implicit declaration of function 'of_node_put'; did you mean 'bpf_token_put'? [-Werror=implicit-function-declaration]
    4654 |         of_node_put(ctrl->device->of_node);
         |         ^~~~~~~~~~~
         |         bpf_token_put
   drivers/nvme/host/core.c: In function 'nvme_init_ctrl':
>> drivers/nvme/host/core.c:4775:33: error: implicit declaration of function 'of_get_compatible_child' [-Werror=implicit-function-declaration]
    4775 |         ctrl->device->of_node = of_get_compatible_child(ctrl->dev->of_node,
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/nvme/host/core.c:4775:31: warning: assignment to 'struct device_node *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    4775 |         ctrl->device->of_node = of_get_compatible_child(ctrl->dev->of_node,
         |                               ^
   cc1: some warnings being treated as errors


vim +4654 drivers/nvme/host/core.c

  4648	
  4649	void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
  4650	{
  4651		nvme_hwmon_exit(ctrl);
  4652		nvme_fault_inject_fini(&ctrl->fault_inject);
  4653		dev_pm_qos_hide_latency_tolerance(ctrl->device);
> 4654		of_node_put(ctrl->device->of_node);
  4655		cdev_device_del(&ctrl->cdev, ctrl->device);
  4656		nvme_put_ctrl(ctrl);
  4657	}
  4658	EXPORT_SYMBOL_GPL(nvme_uninit_ctrl);
  4659	
  4660	static void nvme_free_cels(struct nvme_ctrl *ctrl)
  4661	{
  4662		struct nvme_effects_log	*cel;
  4663		unsigned long i;
  4664	
  4665		xa_for_each(&ctrl->cels, i, cel) {
  4666			xa_erase(&ctrl->cels, i);
  4667			kfree(cel);
  4668		}
  4669	
  4670		xa_destroy(&ctrl->cels);
  4671	}
  4672	
  4673	static void nvme_free_ctrl(struct device *dev)
  4674	{
  4675		struct nvme_ctrl *ctrl =
  4676			container_of(dev, struct nvme_ctrl, ctrl_device);
  4677		struct nvme_subsystem *subsys = ctrl->subsys;
  4678	
  4679		if (!subsys || ctrl->instance != subsys->instance)
  4680			ida_free(&nvme_instance_ida, ctrl->instance);
  4681		key_put(ctrl->tls_key);
  4682		nvme_free_cels(ctrl);
  4683		nvme_mpath_uninit(ctrl);
  4684		cleanup_srcu_struct(&ctrl->srcu);
  4685		nvme_auth_stop(ctrl);
  4686		nvme_auth_free(ctrl);
  4687		__free_page(ctrl->discard_page);
  4688		free_opal_dev(ctrl->opal_dev);
  4689	
  4690		if (subsys) {
  4691			mutex_lock(&nvme_subsystems_lock);
  4692			list_del(&ctrl->subsys_entry);
  4693			sysfs_remove_link(&subsys->dev.kobj, dev_name(ctrl->device));
  4694			mutex_unlock(&nvme_subsystems_lock);
  4695		}
  4696	
  4697		ctrl->ops->free_ctrl(ctrl);
  4698	
  4699		if (subsys)
  4700			nvme_put_subsystem(subsys);
  4701	}
  4702	
  4703	/*
  4704	 * Initialize a NVMe controller structures.  This needs to be called during
  4705	 * earliest initialization so that we have the initialized structured around
  4706	 * during probing.
  4707	 *
  4708	 * On success, the caller must use the nvme_put_ctrl() to release this when
  4709	 * needed, which also invokes the ops->free_ctrl() callback.
  4710	 */
  4711	int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
  4712			const struct nvme_ctrl_ops *ops, unsigned long quirks)
  4713	{
  4714		int ret;
  4715	
  4716		WRITE_ONCE(ctrl->state, NVME_CTRL_NEW);
  4717		ctrl->passthru_err_log_enabled = false;
  4718		clear_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags);
  4719		spin_lock_init(&ctrl->lock);
  4720		mutex_init(&ctrl->namespaces_lock);
  4721	
  4722		ret = init_srcu_struct(&ctrl->srcu);
  4723		if (ret)
  4724			return ret;
  4725	
  4726		mutex_init(&ctrl->scan_lock);
  4727		INIT_LIST_HEAD(&ctrl->namespaces);
  4728		xa_init(&ctrl->cels);
  4729		ctrl->dev = dev;
  4730		ctrl->ops = ops;
  4731		ctrl->quirks = quirks;
  4732		ctrl->numa_node = NUMA_NO_NODE;
  4733		INIT_WORK(&ctrl->scan_work, nvme_scan_work);
  4734		INIT_WORK(&ctrl->async_event_work, nvme_async_event_work);
  4735		INIT_WORK(&ctrl->fw_act_work, nvme_fw_act_work);
  4736		INIT_WORK(&ctrl->delete_work, nvme_delete_ctrl_work);
  4737		init_waitqueue_head(&ctrl->state_wq);
  4738	
  4739		INIT_DELAYED_WORK(&ctrl->ka_work, nvme_keep_alive_work);
  4740		INIT_DELAYED_WORK(&ctrl->failfast_work, nvme_failfast_work);
  4741		memset(&ctrl->ka_cmd, 0, sizeof(ctrl->ka_cmd));
  4742		ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;
  4743		ctrl->ka_last_check_time = jiffies;
  4744	
  4745		BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
  4746				PAGE_SIZE);
  4747		ctrl->discard_page = alloc_page(GFP_KERNEL);
  4748		if (!ctrl->discard_page) {
  4749			ret = -ENOMEM;
  4750			goto out;
  4751		}
  4752	
  4753		ret = ida_alloc(&nvme_instance_ida, GFP_KERNEL);
  4754		if (ret < 0)
  4755			goto out;
  4756		ctrl->instance = ret;
  4757	
  4758		ret = nvme_auth_init_ctrl(ctrl);
  4759		if (ret)
  4760			goto out_release_instance;
  4761	
  4762		nvme_mpath_init_ctrl(ctrl);
  4763	
  4764		device_initialize(&ctrl->ctrl_device);
  4765		ctrl->device = &ctrl->ctrl_device;
  4766		ctrl->device->devt = MKDEV(MAJOR(nvme_ctrl_base_chr_devt),
  4767				ctrl->instance);
  4768		ctrl->device->class = &nvme_class;
  4769		ctrl->device->parent = ctrl->dev;
  4770		if (ops->dev_attr_groups)
  4771			ctrl->device->groups = ops->dev_attr_groups;
  4772		else
  4773			ctrl->device->groups = nvme_dev_attr_groups;
  4774		ctrl->device->release = nvme_free_ctrl;
> 4775		ctrl->device->of_node = of_get_compatible_child(ctrl->dev->of_node,
  4776								"nvme-card");
  4777		dev_set_drvdata(ctrl->device, ctrl);
  4778	
  4779		return ret;
  4780	
  4781	out_release_instance:
  4782		ida_free(&nvme_instance_ida, ctrl->instance);
  4783	out:
  4784		if (ctrl->discard_page)
  4785			__free_page(ctrl->discard_page);
  4786		cleanup_srcu_struct(&ctrl->srcu);
  4787		return ret;
  4788	}
  4789	EXPORT_SYMBOL_GPL(nvme_init_ctrl);
  4790	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH 4/6] block2mtd: attach device OF node to MTD device
  2024-08-04 11:41 ` [PATCH 4/6] block2mtd: attach device OF node to MTD device Christian Marangi
@ 2024-08-04 13:58   ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-08-04 13:58 UTC (permalink / raw)
  To: Christian Marangi, Ulf Hansson, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Joern Engel, Keith Busch, Jens Axboe,
	Christoph Hellwig, Sagi Grimberg, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme
  Cc: oe-kbuild-all

Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.11-rc1 next-20240802]
[cannot apply to mtd/mtd/next mtd/mtd/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-nvme-Document-nvme-card-compatible/20240804-194357
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20240804114108.1893-5-ansuelsmth%40gmail.com
patch subject: [PATCH 4/6] block2mtd: attach device OF node to MTD device
config: i386-buildonly-randconfig-001-20240804 (https://download.01.org/0day-ci/archive/20240804/202408042135.nXaBv2UM-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240804/202408042135.nXaBv2UM-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408042135.nXaBv2UM-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/mtd/devices/block2mtd.c: In function 'add_device':
>> drivers/mtd/devices/block2mtd.c:332:9: error: 'ddev' undeclared (first use in this function); did you mean 'dev'?
     332 |         ddev = disk_to_dev(dev->blkdev->bd_disk);
         |         ^~~~
         |         dev
   drivers/mtd/devices/block2mtd.c:332:9: note: each undeclared identifier is reported only once for each function it appears in
   In file included from drivers/mtd/devices/block2mtd.c:22:
>> drivers/mtd/devices/block2mtd.c:332:31: error: 'struct block2mtd_dev' has no member named 'blkdev'
     332 |         ddev = disk_to_dev(dev->blkdev->bd_disk);
         |                               ^~
   include/linux/blkdev.h:258:13: note: in definition of macro 'disk_to_dev'
     258 |         (&((disk)->part0->bd_device))
         |             ^~~~
   drivers/mtd/devices/block2mtd.c:333:25: error: 'struct block2mtd_dev' has no member named 'blkdev'
     333 |         if (ddev == &dev->blkdev->bd_device)
         |                         ^~


vim +332 drivers/mtd/devices/block2mtd.c

   260	
   261	static struct block2mtd_dev *add_device(char *devname, int erase_size,
   262			char *label, int timeout)
   263	{
   264		const blk_mode_t mode = BLK_OPEN_READ | BLK_OPEN_WRITE;
   265		struct file *bdev_file;
   266		struct block_device *bdev;
   267		struct block2mtd_dev *dev;
   268		loff_t size;
   269		char *name;
   270	
   271		if (!devname)
   272			return NULL;
   273	
   274		dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
   275		if (!dev)
   276			return NULL;
   277	
   278		/* Get a handle on the device */
   279		bdev_file = bdev_file_open_by_path(devname, mode, dev, NULL);
   280		if (IS_ERR(bdev_file))
   281			bdev_file = mdtblock_early_get_bdev(devname, mode, timeout,
   282							      dev);
   283		if (IS_ERR(bdev_file)) {
   284			pr_err("error: cannot open device %s\n", devname);
   285			goto err_free_block2mtd;
   286		}
   287		dev->bdev_file = bdev_file;
   288		bdev = file_bdev(bdev_file);
   289	
   290		if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
   291			pr_err("attempting to use an MTD device as a block device\n");
   292			goto err_free_block2mtd;
   293		}
   294	
   295		size = bdev_nr_bytes(bdev);
   296		if ((long)size % erase_size) {
   297			pr_err("erasesize must be a divisor of device size\n");
   298			goto err_free_block2mtd;
   299		}
   300	
   301		mutex_init(&dev->write_mutex);
   302	
   303		/* Setup the MTD structure */
   304		/* make the name contain the block device in */
   305		if (!label)
   306			name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname);
   307		else
   308			name = kstrdup(label, GFP_KERNEL);
   309		if (!name)
   310			goto err_destroy_mutex;
   311	
   312		dev->mtd.name = name;
   313	
   314		dev->mtd.size = size & PAGE_MASK;
   315		dev->mtd.erasesize = erase_size;
   316		dev->mtd.writesize = 1;
   317		dev->mtd.writebufsize = PAGE_SIZE;
   318		dev->mtd.type = MTD_RAM;
   319		dev->mtd.flags = MTD_CAP_RAM;
   320		dev->mtd._erase = block2mtd_erase;
   321		dev->mtd._write = block2mtd_write;
   322		dev->mtd._sync = block2mtd_sync;
   323		dev->mtd._read = block2mtd_read;
   324		dev->mtd.priv = dev;
   325		dev->mtd.owner = THIS_MODULE;
   326	
   327		/*
   328		 * Check if we are using root blockdev.
   329		 * If it's the case, connect the MTD of_node to the ddev parent
   330		 * to support providing partition in DT node.
   331		 */
 > 332		ddev = disk_to_dev(dev->blkdev->bd_disk);
   333		if (ddev == &dev->blkdev->bd_device)
   334			dev->mtd.dev.of_node = of_node_get(ddev->parent->of_node);
   335	
   336		if (mtd_device_register(&dev->mtd, NULL, 0)) {
   337			/* Device didn't get added, so free the entry */
   338			goto err_destroy_mutex;
   339		}
   340	
   341		list_add(&dev->list, &blkmtd_device_list);
   342		pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n",
   343			dev->mtd.index,
   344			label ? label : dev->mtd.name + strlen("block2mtd: "),
   345			dev->mtd.erasesize >> 10, dev->mtd.erasesize);
   346		return dev;
   347	
   348	err_destroy_mutex:
   349		of_node_put(dev->mtd.dev.of_node);
   350		mutex_destroy(&dev->write_mutex);
   351	err_free_block2mtd:
   352		block2mtd_free_device(dev);
   353		return NULL;
   354	}
   355	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH 2/6] nvme: assign of_node to nvme device
  2024-08-04 11:41 ` [PATCH 2/6] nvme: assign of_node to nvme device Christian Marangi
  2024-08-04 13:48   ` kernel test robot
@ 2024-08-04 15:21   ` kernel test robot
  1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-08-04 15:21 UTC (permalink / raw)
  To: Christian Marangi, Ulf Hansson, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Joern Engel, Keith Busch, Jens Axboe,
	Christoph Hellwig, Sagi Grimberg, Florian Fainelli,
	Thomas Bogendoerfer, Wolfram Sang, linux-mmc, devicetree,
	linux-kernel, linux-mtd, linux-nvme
  Cc: llvm, oe-kbuild-all

Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.11-rc1 next-20240802]
[cannot apply to mtd/mtd/next mtd/mtd/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-nvme-Document-nvme-card-compatible/20240804-194357
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20240804114108.1893-3-ansuelsmth%40gmail.com
patch subject: [PATCH 2/6] nvme: assign of_node to nvme device
config: i386-buildonly-randconfig-005-20240804 (https://download.01.org/0day-ci/archive/20240804/202408042203.CNpuv8Wt-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240804/202408042203.CNpuv8Wt-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408042203.CNpuv8Wt-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/nvme/host/core.c:4654:2: error: call to undeclared function 'of_node_put'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    4654 |         of_node_put(ctrl->device->of_node);
         |         ^
>> drivers/nvme/host/core.c:4775:26: error: call to undeclared function 'of_get_compatible_child'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    4775 |         ctrl->device->of_node = of_get_compatible_child(ctrl->dev->of_node,
         |                                 ^
>> drivers/nvme/host/core.c:4775:24: error: incompatible integer to pointer conversion assigning to 'struct device_node *' from 'int' [-Wint-conversion]
    4775 |         ctrl->device->of_node = of_get_compatible_child(ctrl->dev->of_node,
         |                               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    4776 |                                                         "nvme-card");
         |                                                         ~~~~~~~~~~~~
   3 errors generated.


vim +/of_node_put +4654 drivers/nvme/host/core.c

  4648	
  4649	void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
  4650	{
  4651		nvme_hwmon_exit(ctrl);
  4652		nvme_fault_inject_fini(&ctrl->fault_inject);
  4653		dev_pm_qos_hide_latency_tolerance(ctrl->device);
> 4654		of_node_put(ctrl->device->of_node);
  4655		cdev_device_del(&ctrl->cdev, ctrl->device);
  4656		nvme_put_ctrl(ctrl);
  4657	}
  4658	EXPORT_SYMBOL_GPL(nvme_uninit_ctrl);
  4659	
  4660	static void nvme_free_cels(struct nvme_ctrl *ctrl)
  4661	{
  4662		struct nvme_effects_log	*cel;
  4663		unsigned long i;
  4664	
  4665		xa_for_each(&ctrl->cels, i, cel) {
  4666			xa_erase(&ctrl->cels, i);
  4667			kfree(cel);
  4668		}
  4669	
  4670		xa_destroy(&ctrl->cels);
  4671	}
  4672	
  4673	static void nvme_free_ctrl(struct device *dev)
  4674	{
  4675		struct nvme_ctrl *ctrl =
  4676			container_of(dev, struct nvme_ctrl, ctrl_device);
  4677		struct nvme_subsystem *subsys = ctrl->subsys;
  4678	
  4679		if (!subsys || ctrl->instance != subsys->instance)
  4680			ida_free(&nvme_instance_ida, ctrl->instance);
  4681		key_put(ctrl->tls_key);
  4682		nvme_free_cels(ctrl);
  4683		nvme_mpath_uninit(ctrl);
  4684		cleanup_srcu_struct(&ctrl->srcu);
  4685		nvme_auth_stop(ctrl);
  4686		nvme_auth_free(ctrl);
  4687		__free_page(ctrl->discard_page);
  4688		free_opal_dev(ctrl->opal_dev);
  4689	
  4690		if (subsys) {
  4691			mutex_lock(&nvme_subsystems_lock);
  4692			list_del(&ctrl->subsys_entry);
  4693			sysfs_remove_link(&subsys->dev.kobj, dev_name(ctrl->device));
  4694			mutex_unlock(&nvme_subsystems_lock);
  4695		}
  4696	
  4697		ctrl->ops->free_ctrl(ctrl);
  4698	
  4699		if (subsys)
  4700			nvme_put_subsystem(subsys);
  4701	}
  4702	
  4703	/*
  4704	 * Initialize a NVMe controller structures.  This needs to be called during
  4705	 * earliest initialization so that we have the initialized structured around
  4706	 * during probing.
  4707	 *
  4708	 * On success, the caller must use the nvme_put_ctrl() to release this when
  4709	 * needed, which also invokes the ops->free_ctrl() callback.
  4710	 */
  4711	int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
  4712			const struct nvme_ctrl_ops *ops, unsigned long quirks)
  4713	{
  4714		int ret;
  4715	
  4716		WRITE_ONCE(ctrl->state, NVME_CTRL_NEW);
  4717		ctrl->passthru_err_log_enabled = false;
  4718		clear_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags);
  4719		spin_lock_init(&ctrl->lock);
  4720		mutex_init(&ctrl->namespaces_lock);
  4721	
  4722		ret = init_srcu_struct(&ctrl->srcu);
  4723		if (ret)
  4724			return ret;
  4725	
  4726		mutex_init(&ctrl->scan_lock);
  4727		INIT_LIST_HEAD(&ctrl->namespaces);
  4728		xa_init(&ctrl->cels);
  4729		ctrl->dev = dev;
  4730		ctrl->ops = ops;
  4731		ctrl->quirks = quirks;
  4732		ctrl->numa_node = NUMA_NO_NODE;
  4733		INIT_WORK(&ctrl->scan_work, nvme_scan_work);
  4734		INIT_WORK(&ctrl->async_event_work, nvme_async_event_work);
  4735		INIT_WORK(&ctrl->fw_act_work, nvme_fw_act_work);
  4736		INIT_WORK(&ctrl->delete_work, nvme_delete_ctrl_work);
  4737		init_waitqueue_head(&ctrl->state_wq);
  4738	
  4739		INIT_DELAYED_WORK(&ctrl->ka_work, nvme_keep_alive_work);
  4740		INIT_DELAYED_WORK(&ctrl->failfast_work, nvme_failfast_work);
  4741		memset(&ctrl->ka_cmd, 0, sizeof(ctrl->ka_cmd));
  4742		ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;
  4743		ctrl->ka_last_check_time = jiffies;
  4744	
  4745		BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
  4746				PAGE_SIZE);
  4747		ctrl->discard_page = alloc_page(GFP_KERNEL);
  4748		if (!ctrl->discard_page) {
  4749			ret = -ENOMEM;
  4750			goto out;
  4751		}
  4752	
  4753		ret = ida_alloc(&nvme_instance_ida, GFP_KERNEL);
  4754		if (ret < 0)
  4755			goto out;
  4756		ctrl->instance = ret;
  4757	
  4758		ret = nvme_auth_init_ctrl(ctrl);
  4759		if (ret)
  4760			goto out_release_instance;
  4761	
  4762		nvme_mpath_init_ctrl(ctrl);
  4763	
  4764		device_initialize(&ctrl->ctrl_device);
  4765		ctrl->device = &ctrl->ctrl_device;
  4766		ctrl->device->devt = MKDEV(MAJOR(nvme_ctrl_base_chr_devt),
  4767				ctrl->instance);
  4768		ctrl->device->class = &nvme_class;
  4769		ctrl->device->parent = ctrl->dev;
  4770		if (ops->dev_attr_groups)
  4771			ctrl->device->groups = ops->dev_attr_groups;
  4772		else
  4773			ctrl->device->groups = nvme_dev_attr_groups;
  4774		ctrl->device->release = nvme_free_ctrl;
> 4775		ctrl->device->of_node = of_get_compatible_child(ctrl->dev->of_node,
  4776								"nvme-card");
  4777		dev_set_drvdata(ctrl->device, ctrl);
  4778	
  4779		return ret;
  4780	
  4781	out_release_instance:
  4782		ida_free(&nvme_instance_ida, ctrl->instance);
  4783	out:
  4784		if (ctrl->discard_page)
  4785			__free_page(ctrl->discard_page);
  4786		cleanup_srcu_struct(&ctrl->srcu);
  4787		return ret;
  4788	}
  4789	EXPORT_SYMBOL_GPL(nvme_init_ctrl);
  4790	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2024-08-04 15:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-04 11:41 [PATCH 0/6] mtd: improve block2mtd + airoha parser Christian Marangi
2024-08-04 11:41 ` [PATCH 1/6] dt-bindings: nvme: Document nvme-card compatible Christian Marangi
2024-08-04 11:41 ` [PATCH 2/6] nvme: assign of_node to nvme device Christian Marangi
2024-08-04 13:48   ` kernel test robot
2024-08-04 15:21   ` kernel test robot
2024-08-04 11:41 ` [PATCH 3/6] dt-bindings: mmc: add property for partitions node in mmc-card node Christian Marangi
2024-08-04 11:41 ` [PATCH 4/6] block2mtd: attach device OF node to MTD device Christian Marangi
2024-08-04 13:58   ` kernel test robot
2024-08-04 11:41 ` [PATCH 5/6] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions Christian Marangi
2024-08-04 12:24   ` Rob Herring (Arm)
2024-08-04 11:41 ` [PATCH 6/6] mtd: parser: add support for Airoha parser Christian Marangi

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).