All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] mtd: phram improvements
@ 2022-04-12 13:52 ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:52 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

v3:
- Fix build error on some configs.
- Reword binding.
- Added note about alternatives in cover letter (see below)

v2:
- Add note on what "phram" means in binding.
- Use /schemas/mtd/mtd.yaml instead of relative pathUse /schemas/mtd/mtd.yaml
  instead of relative path in binding.

The phram driver in the MTD subsystem can be used to allow the kernel to use an
MTD or (via mtdblock) a block device in RAM (with the contents loaded by a
bootloader for example).  This series has some improvements to make it more
usable by adding device tree support and to significantly improve its
performance by using cached mappings when possible.

I use this feature to pass the squashfs rootfs to the kernel when booting from
RAM.  The boot is much faster and requires less memory than initrd (which is on
top of that being deprecated), and it allows the same disk images to be used
when booting from RAM, unlike initramfs.

If there is no interest in extending the phram driver to support this, an
option is to use a new custom block driver.  I have patches for that too.  That
will not support MTDs of course, but it works for block devices and it is
faster and smaller than mtdblock + MTD + phram.

Cc: linux-mtd@lists.infradead.org

Cc: devicetree@vger.kernel.org
Cc: robh+dt@kernel.org
Cc: krzk+dt@kernel.org
Cc: frowand.list@gmail.com

Cc: linux-kernel@vger.kernel.org

Vincent Whitchurch (4):
  mtd: core: Check devicetree alias for index
  dt-bindings: reserved-memory: Support MTD/block device
  mtd: phram: Allow probing via reserved-memory
  mtd: phram: Allow cached mappings

 .../bindings/reserved-memory/phram.yaml       | 47 +++++++++++
 drivers/mtd/devices/phram.c                   | 78 +++++++++++++++++--
 drivers/mtd/mtdcore.c                         | 11 ++-
 drivers/of/platform.c                         |  1 +
 4 files changed, 129 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/reserved-memory/phram.yaml

-- 
2.34.1


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

* [PATCH v3 0/4] mtd: phram improvements
@ 2022-04-12 13:52 ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:52 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

v3:
- Fix build error on some configs.
- Reword binding.
- Added note about alternatives in cover letter (see below)

v2:
- Add note on what "phram" means in binding.
- Use /schemas/mtd/mtd.yaml instead of relative pathUse /schemas/mtd/mtd.yaml
  instead of relative path in binding.

The phram driver in the MTD subsystem can be used to allow the kernel to use an
MTD or (via mtdblock) a block device in RAM (with the contents loaded by a
bootloader for example).  This series has some improvements to make it more
usable by adding device tree support and to significantly improve its
performance by using cached mappings when possible.

I use this feature to pass the squashfs rootfs to the kernel when booting from
RAM.  The boot is much faster and requires less memory than initrd (which is on
top of that being deprecated), and it allows the same disk images to be used
when booting from RAM, unlike initramfs.

If there is no interest in extending the phram driver to support this, an
option is to use a new custom block driver.  I have patches for that too.  That
will not support MTDs of course, but it works for block devices and it is
faster and smaller than mtdblock + MTD + phram.

Cc: linux-mtd@lists.infradead.org

Cc: devicetree@vger.kernel.org
Cc: robh+dt@kernel.org
Cc: krzk+dt@kernel.org
Cc: frowand.list@gmail.com

Cc: linux-kernel@vger.kernel.org

Vincent Whitchurch (4):
  mtd: core: Check devicetree alias for index
  dt-bindings: reserved-memory: Support MTD/block device
  mtd: phram: Allow probing via reserved-memory
  mtd: phram: Allow cached mappings

 .../bindings/reserved-memory/phram.yaml       | 47 +++++++++++
 drivers/mtd/devices/phram.c                   | 78 +++++++++++++++++--
 drivers/mtd/mtdcore.c                         | 11 ++-
 drivers/of/platform.c                         |  1 +
 4 files changed, 129 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/reserved-memory/phram.yaml

-- 
2.34.1


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

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

* [PATCH v3 1/4] mtd: core: Check devicetree alias for index
  2022-04-12 13:52 ` Vincent Whitchurch
@ 2022-04-12 13:52   ` Vincent Whitchurch
  -1 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:52 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

Allow the MTD index to be specified via a devicetree alias, so that the
number does not just depend on probe order.  This is useful to allow
pseudo-devices like phram to be optionally used on systems, without
having this affect the numbering of the real hardware MTD devices.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 drivers/mtd/mtdcore.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 7731796024e0..9eb0680db312 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -557,9 +557,10 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
 
 int add_mtd_device(struct mtd_info *mtd)
 {
+	struct device_node *np = mtd_get_of_node(mtd);
 	struct mtd_info *master = mtd_get_master(mtd);
 	struct mtd_notifier *not;
-	int i, error;
+	int i, error, ofidx;
 
 	/*
 	 * May occur, for instance, on buggy drivers which call
@@ -598,7 +599,13 @@ int add_mtd_device(struct mtd_info *mtd)
 
 	mutex_lock(&mtd_table_mutex);
 
-	i = idr_alloc(&mtd_idr, mtd, 0, 0, GFP_KERNEL);
+	ofidx = -1;
+	if (np)
+		ofidx = of_alias_get_id(np, "mtd");
+	if (ofidx >= 0)
+		i = idr_alloc(&mtd_idr, mtd, ofidx, ofidx + 1, GFP_KERNEL);
+	else
+		i = idr_alloc(&mtd_idr, mtd, 0, 0, GFP_KERNEL);
 	if (i < 0) {
 		error = i;
 		goto fail_locked;
-- 
2.34.1


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

* [PATCH v3 1/4] mtd: core: Check devicetree alias for index
@ 2022-04-12 13:52   ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:52 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

Allow the MTD index to be specified via a devicetree alias, so that the
number does not just depend on probe order.  This is useful to allow
pseudo-devices like phram to be optionally used on systems, without
having this affect the numbering of the real hardware MTD devices.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 drivers/mtd/mtdcore.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 7731796024e0..9eb0680db312 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -557,9 +557,10 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
 
 int add_mtd_device(struct mtd_info *mtd)
 {
+	struct device_node *np = mtd_get_of_node(mtd);
 	struct mtd_info *master = mtd_get_master(mtd);
 	struct mtd_notifier *not;
-	int i, error;
+	int i, error, ofidx;
 
 	/*
 	 * May occur, for instance, on buggy drivers which call
@@ -598,7 +599,13 @@ int add_mtd_device(struct mtd_info *mtd)
 
 	mutex_lock(&mtd_table_mutex);
 
-	i = idr_alloc(&mtd_idr, mtd, 0, 0, GFP_KERNEL);
+	ofidx = -1;
+	if (np)
+		ofidx = of_alias_get_id(np, "mtd");
+	if (ofidx >= 0)
+		i = idr_alloc(&mtd_idr, mtd, ofidx, ofidx + 1, GFP_KERNEL);
+	else
+		i = idr_alloc(&mtd_idr, mtd, 0, 0, GFP_KERNEL);
 	if (i < 0) {
 		error = i;
 		goto fail_locked;
-- 
2.34.1


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

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

* [PATCH v3 2/4] dt-bindings: reserved-memory: Support MTD/block device
  2022-04-12 13:52 ` Vincent Whitchurch
@ 2022-04-12 13:53   ` Vincent Whitchurch
  -1 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:53 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

Add bindings to allow MTD/block devices to be used in reserved-memory
regions using the "phram" (MTD in PHysical RAM) driver.

This allows things like partitioning to be specified via the existing
devicetree bindings.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---

Notes:
    v3:
    - Reword description.
    
    v2:
    - Add note on what "phram" means.
    - Use /schemas/mtd/mtd.yaml instead of relative pathUse /schemas/mtd/mtd.yaml instead of relative path.

 .../bindings/reserved-memory/phram.yaml       | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reserved-memory/phram.yaml

diff --git a/Documentation/devicetree/bindings/reserved-memory/phram.yaml b/Documentation/devicetree/bindings/reserved-memory/phram.yaml
new file mode 100644
index 000000000000..6c4db28015f1
--- /dev/null
+++ b/Documentation/devicetree/bindings/reserved-memory/phram.yaml
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/reserved-memory/phram.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MTD/block device in RAM
+
+description: |
+  Specifies that the reserved memory region can be used as an MTD or block
+  device.
+
+  The "phram" node is named after the "MTD in PHysical RAM" driver which
+  provides an implementation of this functionality in Linux.
+
+maintainers:
+  - Vincent Whitchurch <vincent.whitchurch@axis.com>
+
+allOf:
+  - $ref: "reserved-memory.yaml"
+  - $ref: "/schemas/mtd/mtd.yaml"
+
+properties:
+  compatible:
+    const: phram
+
+  reg:
+    description: region of memory that can be used as an MTD/block device
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    reserved-memory {
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        phram: flash@12340000 {
+            compatible = "phram";
+            label = "rootfs";
+            reg = <0x12340000 0x00800000>;
+        };
+    };
-- 
2.34.1


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

* [PATCH v3 2/4] dt-bindings: reserved-memory: Support MTD/block device
@ 2022-04-12 13:53   ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:53 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

Add bindings to allow MTD/block devices to be used in reserved-memory
regions using the "phram" (MTD in PHysical RAM) driver.

This allows things like partitioning to be specified via the existing
devicetree bindings.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---

Notes:
    v3:
    - Reword description.
    
    v2:
    - Add note on what "phram" means.
    - Use /schemas/mtd/mtd.yaml instead of relative pathUse /schemas/mtd/mtd.yaml instead of relative path.

 .../bindings/reserved-memory/phram.yaml       | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reserved-memory/phram.yaml

diff --git a/Documentation/devicetree/bindings/reserved-memory/phram.yaml b/Documentation/devicetree/bindings/reserved-memory/phram.yaml
new file mode 100644
index 000000000000..6c4db28015f1
--- /dev/null
+++ b/Documentation/devicetree/bindings/reserved-memory/phram.yaml
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/reserved-memory/phram.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MTD/block device in RAM
+
+description: |
+  Specifies that the reserved memory region can be used as an MTD or block
+  device.
+
+  The "phram" node is named after the "MTD in PHysical RAM" driver which
+  provides an implementation of this functionality in Linux.
+
+maintainers:
+  - Vincent Whitchurch <vincent.whitchurch@axis.com>
+
+allOf:
+  - $ref: "reserved-memory.yaml"
+  - $ref: "/schemas/mtd/mtd.yaml"
+
+properties:
+  compatible:
+    const: phram
+
+  reg:
+    description: region of memory that can be used as an MTD/block device
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    reserved-memory {
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        phram: flash@12340000 {
+            compatible = "phram";
+            label = "rootfs";
+            reg = <0x12340000 0x00800000>;
+        };
+    };
-- 
2.34.1


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

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

* [PATCH v3 3/4] mtd: phram: Allow probing via reserved-memory
  2022-04-12 13:52 ` Vincent Whitchurch
@ 2022-04-12 13:53   ` Vincent Whitchurch
  -1 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:53 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

Allow phram to be probed from the devicetree.  It expects to be in a
reserved-memory node as documented by the bindings.  This allows things
like partitioning to be specified via the devicetree.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---

Notes:
    v3:
    - Add missing semicolon after MODULE_DEVICE_TABLE causing build errors on some
      configs.

 drivers/mtd/devices/phram.c | 67 ++++++++++++++++++++++++++++++++++---
 drivers/of/platform.c       |  1 +
 2 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index d503821a3e60..506e9edf5c85 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -27,6 +27,9 @@
 #include <linux/slab.h>
 #include <linux/mtd/mtd.h>
 #include <asm/div64.h>
+#include <linux/platform_device.h>
+#include <linux/of_address.h>
+#include <linux/of.h>
 
 struct phram_mtd_list {
 	struct mtd_info mtd;
@@ -89,8 +92,10 @@ static void unregister_devices(void)
 	}
 }
 
-static int register_device(char *name, phys_addr_t start, size_t len, uint32_t erasesize)
+static int register_device(struct platform_device *pdev, const char *name,
+			   phys_addr_t start, size_t len, uint32_t erasesize)
 {
+	struct device_node *np = pdev ? pdev->dev.of_node : NULL;
 	struct phram_mtd_list *new;
 	int ret = -ENOMEM;
 
@@ -119,13 +124,19 @@ static int register_device(char *name, phys_addr_t start, size_t len, uint32_t e
 	new->mtd.erasesize = erasesize;
 	new->mtd.writesize = 1;
 
+	mtd_set_of_node(&new->mtd, np);
+
 	ret = -EAGAIN;
 	if (mtd_device_register(&new->mtd, NULL, 0)) {
 		pr_err("Failed to register new device\n");
 		goto out2;
 	}
 
-	list_add_tail(&new->list, &phram_list);
+	if (pdev)
+		platform_set_drvdata(pdev, new);
+	else
+		list_add_tail(&new->list, &phram_list);
+
 	return 0;
 
 out2:
@@ -278,7 +289,7 @@ static int phram_setup(const char *val)
 		goto error;
 	}
 
-	ret = register_device(name, start, len, (uint32_t)erasesize);
+	ret = register_device(NULL, name, start, len, (uint32_t)erasesize);
 	if (ret)
 		goto error;
 
@@ -325,10 +336,54 @@ static int phram_param_call(const char *val, const struct kernel_param *kp)
 module_param_call(phram, phram_param_call, NULL, NULL, 0200);
 MODULE_PARM_DESC(phram, "Memory region to map. \"phram=<name>,<start>,<length>[,<erasesize>]\"");
 
+#ifdef CONFIG_OF
+static const struct of_device_id phram_of_match[] = {
+	{ .compatible = "phram" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, phram_of_match);
+#endif
+
+static int phram_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENOMEM;
+
+	/* mtd_set_of_node() reads name from "label" */
+	return register_device(pdev, NULL, res->start, resource_size(res),
+			       PAGE_SIZE);
+}
+
+static int phram_remove(struct platform_device *pdev)
+{
+	struct phram_mtd_list *phram = platform_get_drvdata(pdev);
+
+	mtd_device_unregister(&phram->mtd);
+	iounmap(phram->mtd.priv);
+	kfree(phram);
+
+	return 0;
+}
+
+static struct platform_driver phram_driver = {
+	.probe		= phram_probe,
+	.remove		= phram_remove,
+	.driver		= {
+		.name		= "phram",
+		.of_match_table	= of_match_ptr(phram_of_match),
+	},
+};
 
 static int __init init_phram(void)
 {
-	int ret = 0;
+	int ret;
+
+	ret = platform_driver_register(&phram_driver);
+	if (ret)
+		return ret;
 
 #ifndef MODULE
 	if (phram_paramline[0])
@@ -336,12 +391,16 @@ static int __init init_phram(void)
 	phram_init_called = 1;
 #endif
 
+	if (ret)
+		platform_driver_unregister(&phram_driver);
+
 	return ret;
 }
 
 static void __exit cleanup_phram(void)
 {
 	unregister_devices();
+	platform_driver_unregister(&phram_driver);
 }
 
 module_init(init_phram);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index a16b74f32aa9..55d62b82c650 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -509,6 +509,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);
 
 #ifndef CONFIG_PPC
 static const struct of_device_id reserved_mem_matches[] = {
+	{ .compatible = "phram" },
 	{ .compatible = "qcom,rmtfs-mem" },
 	{ .compatible = "qcom,cmd-db" },
 	{ .compatible = "qcom,smem" },
-- 
2.34.1


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

* [PATCH v3 3/4] mtd: phram: Allow probing via reserved-memory
@ 2022-04-12 13:53   ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:53 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

Allow phram to be probed from the devicetree.  It expects to be in a
reserved-memory node as documented by the bindings.  This allows things
like partitioning to be specified via the devicetree.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---

Notes:
    v3:
    - Add missing semicolon after MODULE_DEVICE_TABLE causing build errors on some
      configs.

 drivers/mtd/devices/phram.c | 67 ++++++++++++++++++++++++++++++++++---
 drivers/of/platform.c       |  1 +
 2 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index d503821a3e60..506e9edf5c85 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -27,6 +27,9 @@
 #include <linux/slab.h>
 #include <linux/mtd/mtd.h>
 #include <asm/div64.h>
+#include <linux/platform_device.h>
+#include <linux/of_address.h>
+#include <linux/of.h>
 
 struct phram_mtd_list {
 	struct mtd_info mtd;
@@ -89,8 +92,10 @@ static void unregister_devices(void)
 	}
 }
 
-static int register_device(char *name, phys_addr_t start, size_t len, uint32_t erasesize)
+static int register_device(struct platform_device *pdev, const char *name,
+			   phys_addr_t start, size_t len, uint32_t erasesize)
 {
+	struct device_node *np = pdev ? pdev->dev.of_node : NULL;
 	struct phram_mtd_list *new;
 	int ret = -ENOMEM;
 
@@ -119,13 +124,19 @@ static int register_device(char *name, phys_addr_t start, size_t len, uint32_t e
 	new->mtd.erasesize = erasesize;
 	new->mtd.writesize = 1;
 
+	mtd_set_of_node(&new->mtd, np);
+
 	ret = -EAGAIN;
 	if (mtd_device_register(&new->mtd, NULL, 0)) {
 		pr_err("Failed to register new device\n");
 		goto out2;
 	}
 
-	list_add_tail(&new->list, &phram_list);
+	if (pdev)
+		platform_set_drvdata(pdev, new);
+	else
+		list_add_tail(&new->list, &phram_list);
+
 	return 0;
 
 out2:
@@ -278,7 +289,7 @@ static int phram_setup(const char *val)
 		goto error;
 	}
 
-	ret = register_device(name, start, len, (uint32_t)erasesize);
+	ret = register_device(NULL, name, start, len, (uint32_t)erasesize);
 	if (ret)
 		goto error;
 
@@ -325,10 +336,54 @@ static int phram_param_call(const char *val, const struct kernel_param *kp)
 module_param_call(phram, phram_param_call, NULL, NULL, 0200);
 MODULE_PARM_DESC(phram, "Memory region to map. \"phram=<name>,<start>,<length>[,<erasesize>]\"");
 
+#ifdef CONFIG_OF
+static const struct of_device_id phram_of_match[] = {
+	{ .compatible = "phram" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, phram_of_match);
+#endif
+
+static int phram_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENOMEM;
+
+	/* mtd_set_of_node() reads name from "label" */
+	return register_device(pdev, NULL, res->start, resource_size(res),
+			       PAGE_SIZE);
+}
+
+static int phram_remove(struct platform_device *pdev)
+{
+	struct phram_mtd_list *phram = platform_get_drvdata(pdev);
+
+	mtd_device_unregister(&phram->mtd);
+	iounmap(phram->mtd.priv);
+	kfree(phram);
+
+	return 0;
+}
+
+static struct platform_driver phram_driver = {
+	.probe		= phram_probe,
+	.remove		= phram_remove,
+	.driver		= {
+		.name		= "phram",
+		.of_match_table	= of_match_ptr(phram_of_match),
+	},
+};
 
 static int __init init_phram(void)
 {
-	int ret = 0;
+	int ret;
+
+	ret = platform_driver_register(&phram_driver);
+	if (ret)
+		return ret;
 
 #ifndef MODULE
 	if (phram_paramline[0])
@@ -336,12 +391,16 @@ static int __init init_phram(void)
 	phram_init_called = 1;
 #endif
 
+	if (ret)
+		platform_driver_unregister(&phram_driver);
+
 	return ret;
 }
 
 static void __exit cleanup_phram(void)
 {
 	unregister_devices();
+	platform_driver_unregister(&phram_driver);
 }
 
 module_init(init_phram);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index a16b74f32aa9..55d62b82c650 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -509,6 +509,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);
 
 #ifndef CONFIG_PPC
 static const struct of_device_id reserved_mem_matches[] = {
+	{ .compatible = "phram" },
 	{ .compatible = "qcom,rmtfs-mem" },
 	{ .compatible = "qcom,cmd-db" },
 	{ .compatible = "qcom,smem" },
-- 
2.34.1


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

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

* [PATCH v3 4/4] mtd: phram: Allow cached mappings
  2022-04-12 13:52 ` Vincent Whitchurch
@ 2022-04-12 13:53   ` Vincent Whitchurch
  -1 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:53 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

Currently phram always uses ioremap(), but this is unnecessary when
normal memory is used.  If the reserved-memory node does not specify the
no-map property, indicating it should be mapped as system RAM and
ioremap() cannot be used on it, use a cached mapping using
memremap(MEMREMAP_WB) instead.

On one of my systems this improves read performance by ~70%.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 drivers/mtd/devices/phram.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 506e9edf5c85..89d74a1eff4f 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -34,6 +34,7 @@
 struct phram_mtd_list {
 	struct mtd_info mtd;
 	struct list_head list;
+	bool cached;
 };
 
 static LIST_HEAD(phram_list);
@@ -96,6 +97,7 @@ static int register_device(struct platform_device *pdev, const char *name,
 			   phys_addr_t start, size_t len, uint32_t erasesize)
 {
 	struct device_node *np = pdev ? pdev->dev.of_node : NULL;
+	bool cached = np ? !of_property_read_bool(np, "no-map") : false;
 	struct phram_mtd_list *new;
 	int ret = -ENOMEM;
 
@@ -103,8 +105,13 @@ static int register_device(struct platform_device *pdev, const char *name,
 	if (!new)
 		goto out0;
 
+	new->cached = cached;
+
 	ret = -EIO;
-	new->mtd.priv = ioremap(start, len);
+	if (cached)
+		new->mtd.priv = memremap(start, len, MEMREMAP_WB);
+	else
+		new->mtd.priv = ioremap(start, len);
 	if (!new->mtd.priv) {
 		pr_err("ioremap failed\n");
 		goto out1;
@@ -140,7 +147,7 @@ static int register_device(struct platform_device *pdev, const char *name,
 	return 0;
 
 out2:
-	iounmap(new->mtd.priv);
+	cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
 out1:
 	kfree(new);
 out0:
@@ -362,7 +369,7 @@ static int phram_remove(struct platform_device *pdev)
 	struct phram_mtd_list *phram = platform_get_drvdata(pdev);
 
 	mtd_device_unregister(&phram->mtd);
-	iounmap(phram->mtd.priv);
+	phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
 	kfree(phram);
 
 	return 0;
-- 
2.34.1


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

* [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-04-12 13:53   ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-12 13:53 UTC (permalink / raw)
  To: vigneshr, richard, miquel.raynal, joern
  Cc: kernel, Vincent Whitchurch, linux-mtd, devicetree, robh+dt,
	krzk+dt, frowand.list, linux-kernel

Currently phram always uses ioremap(), but this is unnecessary when
normal memory is used.  If the reserved-memory node does not specify the
no-map property, indicating it should be mapped as system RAM and
ioremap() cannot be used on it, use a cached mapping using
memremap(MEMREMAP_WB) instead.

On one of my systems this improves read performance by ~70%.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 drivers/mtd/devices/phram.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 506e9edf5c85..89d74a1eff4f 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -34,6 +34,7 @@
 struct phram_mtd_list {
 	struct mtd_info mtd;
 	struct list_head list;
+	bool cached;
 };
 
 static LIST_HEAD(phram_list);
@@ -96,6 +97,7 @@ static int register_device(struct platform_device *pdev, const char *name,
 			   phys_addr_t start, size_t len, uint32_t erasesize)
 {
 	struct device_node *np = pdev ? pdev->dev.of_node : NULL;
+	bool cached = np ? !of_property_read_bool(np, "no-map") : false;
 	struct phram_mtd_list *new;
 	int ret = -ENOMEM;
 
@@ -103,8 +105,13 @@ static int register_device(struct platform_device *pdev, const char *name,
 	if (!new)
 		goto out0;
 
+	new->cached = cached;
+
 	ret = -EIO;
-	new->mtd.priv = ioremap(start, len);
+	if (cached)
+		new->mtd.priv = memremap(start, len, MEMREMAP_WB);
+	else
+		new->mtd.priv = ioremap(start, len);
 	if (!new->mtd.priv) {
 		pr_err("ioremap failed\n");
 		goto out1;
@@ -140,7 +147,7 @@ static int register_device(struct platform_device *pdev, const char *name,
 	return 0;
 
 out2:
-	iounmap(new->mtd.priv);
+	cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
 out1:
 	kfree(new);
 out0:
@@ -362,7 +369,7 @@ static int phram_remove(struct platform_device *pdev)
 	struct phram_mtd_list *phram = platform_get_drvdata(pdev);
 
 	mtd_device_unregister(&phram->mtd);
-	iounmap(phram->mtd.priv);
+	phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
 	kfree(phram);
 
 	return 0;
-- 
2.34.1


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

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
  2022-04-12 13:53   ` Vincent Whitchurch
@ 2022-04-13  6:45     ` kernel test robot
  -1 siblings, 0 replies; 36+ messages in thread
From: kernel test robot @ 2022-04-13  6:45 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kbuild-all, kernel, Vincent Whitchurch, linux-mtd, devicetree,
	robh+dt, krzk+dt, frowand.list, linux-kernel

Hi Vincent,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mtd/mtd/next]
[also build test ERROR on mtd/mtd/fixes robh/for-next v5.18-rc2 next-20220412]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Vincent-Whitchurch/mtd-phram-improvements/20220412-215547
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20220413/202204131446.omJ5mC54-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/188069fe016214c257926df29c84b97859850720
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Vincent-Whitchurch/mtd-phram-improvements/20220412-215547
        git checkout 188069fe016214c257926df29c84b97859850720
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sh SHELL=/bin/bash drivers/mtd/devices/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/io.h:13,
                    from drivers/mtd/devices/phram.c:21:
   drivers/mtd/devices/phram.c: In function 'register_device':
>> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
     274 | #define iounmap(addr)           do { } while (0)
         |                                 ^~
   drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
     150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
         |                                            ^~~~~~~
   drivers/mtd/devices/phram.c: In function 'phram_remove':
>> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
     274 | #define iounmap(addr)           do { } while (0)
         |                                 ^~
   drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
     372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
         |                                                     ^~~~~~~


vim +/do +274 arch/sh/include/asm/io.h

d57d64080ddc0f Paul Mundt        2010-01-19  272  
13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
d627a2ebd1a303 Paul Mundt        2010-01-28  277  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-04-13  6:45     ` kernel test robot
  0 siblings, 0 replies; 36+ messages in thread
From: kernel test robot @ 2022-04-13  6:45 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kbuild-all, kernel, Vincent Whitchurch, linux-mtd, devicetree,
	robh+dt, krzk+dt, frowand.list, linux-kernel

Hi Vincent,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mtd/mtd/next]
[also build test ERROR on mtd/mtd/fixes robh/for-next v5.18-rc2 next-20220412]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Vincent-Whitchurch/mtd-phram-improvements/20220412-215547
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20220413/202204131446.omJ5mC54-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/188069fe016214c257926df29c84b97859850720
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Vincent-Whitchurch/mtd-phram-improvements/20220412-215547
        git checkout 188069fe016214c257926df29c84b97859850720
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sh SHELL=/bin/bash drivers/mtd/devices/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/io.h:13,
                    from drivers/mtd/devices/phram.c:21:
   drivers/mtd/devices/phram.c: In function 'register_device':
>> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
     274 | #define iounmap(addr)           do { } while (0)
         |                                 ^~
   drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
     150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
         |                                            ^~~~~~~
   drivers/mtd/devices/phram.c: In function 'phram_remove':
>> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
     274 | #define iounmap(addr)           do { } while (0)
         |                                 ^~
   drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
     372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
         |                                                     ^~~~~~~


vim +/do +274 arch/sh/include/asm/io.h

d57d64080ddc0f Paul Mundt        2010-01-19  272  
13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
d627a2ebd1a303 Paul Mundt        2010-01-28  277  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
  2022-04-13  6:45     ` kernel test robot
  (?)
@ 2022-04-14  9:04       ` Vincent Whitchurch
  -1 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-14  9:04 UTC (permalink / raw)
  To: kernel test robot
  Cc: vigneshr, richard, miquel.raynal, joern, kbuild-all, kernel,
	linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Wed, Apr 13, 2022 at 08:45:59AM +0200, kernel test robot wrote:
> All errors (new ones prefixed by >>):
> 
>    In file included from include/linux/io.h:13,
>                     from drivers/mtd/devices/phram.c:21:
>    drivers/mtd/devices/phram.c: In function 'register_device':
> >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
>      274 | #define iounmap(addr)           do { } while (0)
>          |                                 ^~
>    drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
>      150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
>          |                                            ^~~~~~~
>    drivers/mtd/devices/phram.c: In function 'phram_remove':
> >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
>      274 | #define iounmap(addr)           do { } while (0)
>          |                                 ^~
>    drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
>      372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
>          |                                                     ^~~~~~~
> 
> 
> vim +/do +274 arch/sh/include/asm/io.h
> 
> d57d64080ddc0f Paul Mundt        2010-01-19  272  
> 13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
> 13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
> 13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
> 13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
> d627a2ebd1a303 Paul Mundt        2010-01-28  277  

Thank you for the report.  This patch could certainly be changed to work
around this, but ISTM that the right fix is in the SH header file, since
the problem could hit in other cases too.  I've posted a fix here now:

 https://lore.kernel.org/lkml/20220414081257.1487499-1-vincent.whitchurch@axis.com/

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-04-14  9:04       ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-14  9:04 UTC (permalink / raw)
  To: kernel test robot
  Cc: vigneshr, richard, miquel.raynal, joern, kbuild-all, kernel,
	linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Wed, Apr 13, 2022 at 08:45:59AM +0200, kernel test robot wrote:
> All errors (new ones prefixed by >>):
> 
>    In file included from include/linux/io.h:13,
>                     from drivers/mtd/devices/phram.c:21:
>    drivers/mtd/devices/phram.c: In function 'register_device':
> >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
>      274 | #define iounmap(addr)           do { } while (0)
>          |                                 ^~
>    drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
>      150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
>          |                                            ^~~~~~~
>    drivers/mtd/devices/phram.c: In function 'phram_remove':
> >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
>      274 | #define iounmap(addr)           do { } while (0)
>          |                                 ^~
>    drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
>      372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
>          |                                                     ^~~~~~~
> 
> 
> vim +/do +274 arch/sh/include/asm/io.h
> 
> d57d64080ddc0f Paul Mundt        2010-01-19  272  
> 13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
> 13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
> 13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
> 13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
> d627a2ebd1a303 Paul Mundt        2010-01-28  277  

Thank you for the report.  This patch could certainly be changed to work
around this, but ISTM that the right fix is in the SH header file, since
the problem could hit in other cases too.  I've posted a fix here now:

 https://lore.kernel.org/lkml/20220414081257.1487499-1-vincent.whitchurch@axis.com/

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

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-04-14  9:04       ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-04-14  9:04 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2047 bytes --]

On Wed, Apr 13, 2022 at 08:45:59AM +0200, kernel test robot wrote:
> All errors (new ones prefixed by >>):
> 
>    In file included from include/linux/io.h:13,
>                     from drivers/mtd/devices/phram.c:21:
>    drivers/mtd/devices/phram.c: In function 'register_device':
> >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
>      274 | #define iounmap(addr)           do { } while (0)
>          |                                 ^~
>    drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
>      150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
>          |                                            ^~~~~~~
>    drivers/mtd/devices/phram.c: In function 'phram_remove':
> >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'
>      274 | #define iounmap(addr)           do { } while (0)
>          |                                 ^~
>    drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
>      372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
>          |                                                     ^~~~~~~
> 
> 
> vim +/do +274 arch/sh/include/asm/io.h
> 
> d57d64080ddc0f Paul Mundt        2010-01-19  272  
> 13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
> 13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
> 13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
> 13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
> d627a2ebd1a303 Paul Mundt        2010-01-28  277  

Thank you for the report.  This patch could certainly be changed to work
around this, but ISTM that the right fix is in the SH header file, since
the problem could hit in other cases too.  I've posted a fix here now:

 https://lore.kernel.org/lkml/20220414081257.1487499-1-vincent.whitchurch(a)axis.com/

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

* Re: [PATCH v3 2/4] dt-bindings: reserved-memory: Support MTD/block device
  2022-04-12 13:53   ` Vincent Whitchurch
@ 2022-04-14 16:00     ` Rob Herring
  -1 siblings, 0 replies; 36+ messages in thread
From: Rob Herring @ 2022-04-14 16:00 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: richard, joern, linux-mtd, frowand.list, vigneshr, krzk+dt,
	linux-kernel, robh+dt, kernel, miquel.raynal, devicetree

On Tue, 12 Apr 2022 15:53:00 +0200, Vincent Whitchurch wrote:
> Add bindings to allow MTD/block devices to be used in reserved-memory
> regions using the "phram" (MTD in PHysical RAM) driver.
> 
> This allows things like partitioning to be specified via the existing
> devicetree bindings.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
> 
> Notes:
>     v3:
>     - Reword description.
> 
>     v2:
>     - Add note on what "phram" means.
>     - Use /schemas/mtd/mtd.yaml instead of relative pathUse /schemas/mtd/mtd.yaml instead of relative path.
> 
>  .../bindings/reserved-memory/phram.yaml       | 47 +++++++++++++++++++
>  1 file changed, 47 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/reserved-memory/phram.yaml
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

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

* Re: [PATCH v3 2/4] dt-bindings: reserved-memory: Support MTD/block device
@ 2022-04-14 16:00     ` Rob Herring
  0 siblings, 0 replies; 36+ messages in thread
From: Rob Herring @ 2022-04-14 16:00 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: richard, joern, linux-mtd, frowand.list, vigneshr, krzk+dt,
	linux-kernel, robh+dt, kernel, miquel.raynal, devicetree

On Tue, 12 Apr 2022 15:53:00 +0200, Vincent Whitchurch wrote:
> Add bindings to allow MTD/block devices to be used in reserved-memory
> regions using the "phram" (MTD in PHysical RAM) driver.
> 
> This allows things like partitioning to be specified via the existing
> devicetree bindings.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
> 
> Notes:
>     v3:
>     - Reword description.
> 
>     v2:
>     - Add note on what "phram" means.
>     - Use /schemas/mtd/mtd.yaml instead of relative pathUse /schemas/mtd/mtd.yaml instead of relative path.
> 
>  .../bindings/reserved-memory/phram.yaml       | 47 +++++++++++++++++++
>  1 file changed, 47 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/reserved-memory/phram.yaml
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v3 3/4] mtd: phram: Allow probing via reserved-memory
  2022-04-12 13:53   ` Vincent Whitchurch
@ 2022-04-14 16:02     ` Rob Herring
  -1 siblings, 0 replies; 36+ messages in thread
From: Rob Herring @ 2022-04-14 16:02 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: vigneshr, richard, miquel.raynal, joern, kernel, linux-mtd,
	devicetree, krzk+dt, frowand.list, linux-kernel

On Tue, Apr 12, 2022 at 03:53:01PM +0200, Vincent Whitchurch wrote:
> Allow phram to be probed from the devicetree.  It expects to be in a
> reserved-memory node as documented by the bindings.  This allows things
> like partitioning to be specified via the devicetree.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
> 
> Notes:
>     v3:
>     - Add missing semicolon after MODULE_DEVICE_TABLE causing build errors on some
>       configs.
> 
>  drivers/mtd/devices/phram.c | 67 ++++++++++++++++++++++++++++++++++---
>  drivers/of/platform.c       |  1 +

For DT,

Acked-by: Rob Herring <robh@kernel.org>

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

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

* Re: [PATCH v3 3/4] mtd: phram: Allow probing via reserved-memory
@ 2022-04-14 16:02     ` Rob Herring
  0 siblings, 0 replies; 36+ messages in thread
From: Rob Herring @ 2022-04-14 16:02 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: vigneshr, richard, miquel.raynal, joern, kernel, linux-mtd,
	devicetree, krzk+dt, frowand.list, linux-kernel

On Tue, Apr 12, 2022 at 03:53:01PM +0200, Vincent Whitchurch wrote:
> Allow phram to be probed from the devicetree.  It expects to be in a
> reserved-memory node as documented by the bindings.  This allows things
> like partitioning to be specified via the devicetree.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
> 
> Notes:
>     v3:
>     - Add missing semicolon after MODULE_DEVICE_TABLE causing build errors on some
>       configs.
> 
>  drivers/mtd/devices/phram.c | 67 ++++++++++++++++++++++++++++++++++---
>  drivers/of/platform.c       |  1 +

For DT,

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
  2022-04-12 13:53   ` Vincent Whitchurch
@ 2022-04-21  7:35     ` Miquel Raynal
  -1 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-21  7:35 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kernel, linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Tue, 2022-04-12 at 13:53:02 UTC, Vincent Whitchurch wrote:
> Currently phram always uses ioremap(), but this is unnecessary when
> normal memory is used.  If the reserved-memory node does not specify the
> no-map property, indicating it should be mapped as system RAM and
> ioremap() cannot be used on it, use a cached mapping using
> memremap(MEMREMAP_WB) instead.
> 
> On one of my systems this improves read performance by ~70%.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> Reported-by: kernel test robot <lkp@intel.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-04-21  7:35     ` Miquel Raynal
  0 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-21  7:35 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kernel, linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Tue, 2022-04-12 at 13:53:02 UTC, Vincent Whitchurch wrote:
> Currently phram always uses ioremap(), but this is unnecessary when
> normal memory is used.  If the reserved-memory node does not specify the
> no-map property, indicating it should be mapped as system RAM and
> ioremap() cannot be used on it, use a cached mapping using
> memremap(MEMREMAP_WB) instead.
> 
> On one of my systems this improves read performance by ~70%.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> Reported-by: kernel test robot <lkp@intel.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

* Re: [PATCH v3 3/4] mtd: phram: Allow probing via reserved-memory
  2022-04-12 13:53   ` Vincent Whitchurch
@ 2022-04-21  7:36     ` Miquel Raynal
  -1 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-21  7:36 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kernel, linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Tue, 2022-04-12 at 13:53:01 UTC, Vincent Whitchurch wrote:
> Allow phram to be probed from the devicetree.  It expects to be in a
> reserved-memory node as documented by the bindings.  This allows things
> like partitioning to be specified via the devicetree.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> Acked-by: Rob Herring <robh@kernel.org>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

* Re: [PATCH v3 3/4] mtd: phram: Allow probing via reserved-memory
@ 2022-04-21  7:36     ` Miquel Raynal
  0 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-21  7:36 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kernel, linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Tue, 2022-04-12 at 13:53:01 UTC, Vincent Whitchurch wrote:
> Allow phram to be probed from the devicetree.  It expects to be in a
> reserved-memory node as documented by the bindings.  This allows things
> like partitioning to be specified via the devicetree.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> Acked-by: Rob Herring <robh@kernel.org>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

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

* Re: [PATCH v3 2/4] dt-bindings: reserved-memory: Support MTD/block device
  2022-04-12 13:53   ` Vincent Whitchurch
@ 2022-04-21  7:36     ` Miquel Raynal
  -1 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-21  7:36 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kernel, linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Tue, 2022-04-12 at 13:53:00 UTC, Vincent Whitchurch wrote:
> Add bindings to allow MTD/block devices to be used in reserved-memory
> regions using the "phram" (MTD in PHysical RAM) driver.
> 
> This allows things like partitioning to be specified via the existing
> devicetree bindings.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> Reviewed-by: Rob Herring <robh@kernel.org>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

* Re: [PATCH v3 2/4] dt-bindings: reserved-memory: Support MTD/block device
@ 2022-04-21  7:36     ` Miquel Raynal
  0 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-21  7:36 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kernel, linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Tue, 2022-04-12 at 13:53:00 UTC, Vincent Whitchurch wrote:
> Add bindings to allow MTD/block devices to be used in reserved-memory
> regions using the "phram" (MTD in PHysical RAM) driver.
> 
> This allows things like partitioning to be specified via the existing
> devicetree bindings.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> Reviewed-by: Rob Herring <robh@kernel.org>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

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

* Re: [PATCH v3 1/4] mtd: core: Check devicetree alias for index
  2022-04-12 13:52   ` Vincent Whitchurch
@ 2022-04-21  7:36     ` Miquel Raynal
  -1 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-21  7:36 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kernel, linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Tue, 2022-04-12 at 13:52:59 UTC, Vincent Whitchurch wrote:
> Allow the MTD index to be specified via a devicetree alias, so that the
> number does not just depend on probe order.  This is useful to allow
> pseudo-devices like phram to be optionally used on systems, without
> having this affect the numbering of the real hardware MTD devices.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

* Re: [PATCH v3 1/4] mtd: core: Check devicetree alias for index
@ 2022-04-21  7:36     ` Miquel Raynal
  0 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-21  7:36 UTC (permalink / raw)
  To: Vincent Whitchurch, vigneshr, richard, miquel.raynal, joern
  Cc: kernel, linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Tue, 2022-04-12 at 13:52:59 UTC, Vincent Whitchurch wrote:
> Allow the MTD index to be specified via a devicetree alias, so that the
> number does not just depend on probe order.  This is useful to allow
> pseudo-devices like phram to be optionally used on systems, without
> having this affect the numbering of the real hardware MTD devices.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
  2022-04-14  9:04       ` Vincent Whitchurch
  (?)
@ 2022-04-25  8:28         ` Miquel Raynal
  -1 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-25  8:28 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: kernel test robot, vigneshr, richard, joern, kbuild-all, kernel,
	linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

Hi Vincent,

vincent.whitchurch@axis.com wrote on Thu, 14 Apr 2022 11:04:02 +0200:

> On Wed, Apr 13, 2022 at 08:45:59AM +0200, kernel test robot wrote:
> > All errors (new ones prefixed by >>):
> > 
> >    In file included from include/linux/io.h:13,
> >                     from drivers/mtd/devices/phram.c:21:
> >    drivers/mtd/devices/phram.c: In function 'register_device':  
> > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'  
> >      274 | #define iounmap(addr)           do { } while (0)
> >          |                                 ^~
> >    drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
> >      150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
> >          |                                            ^~~~~~~
> >    drivers/mtd/devices/phram.c: In function 'phram_remove':  
> > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'  
> >      274 | #define iounmap(addr)           do { } while (0)
> >          |                                 ^~
> >    drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
> >      372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
> >          |                                                     ^~~~~~~
> > 
> > 
> > vim +/do +274 arch/sh/include/asm/io.h
> > 
> > d57d64080ddc0f Paul Mundt        2010-01-19  272  
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
> > d627a2ebd1a303 Paul Mundt        2010-01-28  277    
> 
> Thank you for the report.  This patch could certainly be changed to work
> around this, but ISTM that the right fix is in the SH header file, since
> the problem could hit in other cases too.  I've posted a fix here now:
> 
>  https://lore.kernel.org/lkml/20220414081257.1487499-1-vincent.whitchurch@axis.com/

Looks good to me but I don't want to be the one "carrying" new compile
errors so I'll drop the series for now, until you get this patch
applied. Please then just resend the series with this thread mentioned
and I'll take it back.

Thanks,
Miquèl

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-04-25  8:28         ` Miquel Raynal
  0 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-25  8:28 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: kernel test robot, vigneshr, richard, joern, kbuild-all, kernel,
	linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

Hi Vincent,

vincent.whitchurch@axis.com wrote on Thu, 14 Apr 2022 11:04:02 +0200:

> On Wed, Apr 13, 2022 at 08:45:59AM +0200, kernel test robot wrote:
> > All errors (new ones prefixed by >>):
> > 
> >    In file included from include/linux/io.h:13,
> >                     from drivers/mtd/devices/phram.c:21:
> >    drivers/mtd/devices/phram.c: In function 'register_device':  
> > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'  
> >      274 | #define iounmap(addr)           do { } while (0)
> >          |                                 ^~
> >    drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
> >      150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
> >          |                                            ^~~~~~~
> >    drivers/mtd/devices/phram.c: In function 'phram_remove':  
> > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'  
> >      274 | #define iounmap(addr)           do { } while (0)
> >          |                                 ^~
> >    drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
> >      372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
> >          |                                                     ^~~~~~~
> > 
> > 
> > vim +/do +274 arch/sh/include/asm/io.h
> > 
> > d57d64080ddc0f Paul Mundt        2010-01-19  272  
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
> > d627a2ebd1a303 Paul Mundt        2010-01-28  277    
> 
> Thank you for the report.  This patch could certainly be changed to work
> around this, but ISTM that the right fix is in the SH header file, since
> the problem could hit in other cases too.  I've posted a fix here now:
> 
>  https://lore.kernel.org/lkml/20220414081257.1487499-1-vincent.whitchurch@axis.com/

Looks good to me but I don't want to be the one "carrying" new compile
errors so I'll drop the series for now, until you get this patch
applied. Please then just resend the series with this thread mentioned
and I'll take it back.

Thanks,
Miquèl

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

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-04-25  8:28         ` Miquel Raynal
  0 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-25  8:28 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2473 bytes --]

Hi Vincent,

vincent.whitchurch(a)axis.com wrote on Thu, 14 Apr 2022 11:04:02 +0200:

> On Wed, Apr 13, 2022 at 08:45:59AM +0200, kernel test robot wrote:
> > All errors (new ones prefixed by >>):
> > 
> >    In file included from include/linux/io.h:13,
> >                     from drivers/mtd/devices/phram.c:21:
> >    drivers/mtd/devices/phram.c: In function 'register_device':  
> > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'  
> >      274 | #define iounmap(addr)           do { } while (0)
> >          |                                 ^~
> >    drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
> >      150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
> >          |                                            ^~~~~~~
> >    drivers/mtd/devices/phram.c: In function 'phram_remove':  
> > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'  
> >      274 | #define iounmap(addr)           do { } while (0)
> >          |                                 ^~
> >    drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
> >      372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
> >          |                                                     ^~~~~~~
> > 
> > 
> > vim +/do +274 arch/sh/include/asm/io.h
> > 
> > d57d64080ddc0f Paul Mundt        2010-01-19  272  
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
> > 13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
> > d627a2ebd1a303 Paul Mundt        2010-01-28  277    
> 
> Thank you for the report.  This patch could certainly be changed to work
> around this, but ISTM that the right fix is in the SH header file, since
> the problem could hit in other cases too.  I've posted a fix here now:
> 
>  https://lore.kernel.org/lkml/20220414081257.1487499-1-vincent.whitchurch(a)axis.com/

Looks good to me but I don't want to be the one "carrying" new compile
errors so I'll drop the series for now, until you get this patch
applied. Please then just resend the series with this thread mentioned
and I'll take it back.

Thanks,
Miquèl

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
  2022-04-25  8:28         ` Miquel Raynal
  (?)
@ 2022-04-25  8:30           ` Miquel Raynal
  -1 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-25  8:30 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: kernel test robot, vigneshr, richard, joern, kbuild-all, kernel,
	linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel


miquel.raynal@bootlin.com wrote on Mon, 25 Apr 2022 10:28:16 +0200:

> Hi Vincent,
> 
> vincent.whitchurch@axis.com wrote on Thu, 14 Apr 2022 11:04:02 +0200:
> 
> > On Wed, Apr 13, 2022 at 08:45:59AM +0200, kernel test robot wrote:  
> > > All errors (new ones prefixed by >>):
> > > 
> > >    In file included from include/linux/io.h:13,
> > >                     from drivers/mtd/devices/phram.c:21:
> > >    drivers/mtd/devices/phram.c: In function 'register_device':    
> > > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'    
> > >      274 | #define iounmap(addr)           do { } while (0)
> > >          |                                 ^~
> > >    drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
> > >      150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
> > >          |                                            ^~~~~~~
> > >    drivers/mtd/devices/phram.c: In function 'phram_remove':    
> > > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'    
> > >      274 | #define iounmap(addr)           do { } while (0)
> > >          |                                 ^~
> > >    drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
> > >      372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
> > >          |                                                     ^~~~~~~
> > > 
> > > 
> > > vim +/do +274 arch/sh/include/asm/io.h
> > > 
> > > d57d64080ddc0f Paul Mundt        2010-01-19  272  
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
> > > d627a2ebd1a303 Paul Mundt        2010-01-28  277      
> > 
> > Thank you for the report.  This patch could certainly be changed to work
> > around this, but ISTM that the right fix is in the SH header file, since
> > the problem could hit in other cases too.  I've posted a fix here now:
> > 
> >  https://lore.kernel.org/lkml/20220414081257.1487499-1-vincent.whitchurch@axis.com/  
> 
> Looks good to me but I don't want to be the one "carrying" new compile
> errors so I'll drop the series for now, until you get this patch
> applied. Please then just resend the series with this thread mentioned
> and I'll take it back.

BTW, I'm only talking about this improvement, patches 1-3 will remain.


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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-04-25  8:30           ` Miquel Raynal
  0 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-25  8:30 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: kernel test robot, vigneshr, richard, joern, kbuild-all, kernel,
	linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel


miquel.raynal@bootlin.com wrote on Mon, 25 Apr 2022 10:28:16 +0200:

> Hi Vincent,
> 
> vincent.whitchurch@axis.com wrote on Thu, 14 Apr 2022 11:04:02 +0200:
> 
> > On Wed, Apr 13, 2022 at 08:45:59AM +0200, kernel test robot wrote:  
> > > All errors (new ones prefixed by >>):
> > > 
> > >    In file included from include/linux/io.h:13,
> > >                     from drivers/mtd/devices/phram.c:21:
> > >    drivers/mtd/devices/phram.c: In function 'register_device':    
> > > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'    
> > >      274 | #define iounmap(addr)           do { } while (0)
> > >          |                                 ^~
> > >    drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
> > >      150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
> > >          |                                            ^~~~~~~
> > >    drivers/mtd/devices/phram.c: In function 'phram_remove':    
> > > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'    
> > >      274 | #define iounmap(addr)           do { } while (0)
> > >          |                                 ^~
> > >    drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
> > >      372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
> > >          |                                                     ^~~~~~~
> > > 
> > > 
> > > vim +/do +274 arch/sh/include/asm/io.h
> > > 
> > > d57d64080ddc0f Paul Mundt        2010-01-19  272  
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
> > > d627a2ebd1a303 Paul Mundt        2010-01-28  277      
> > 
> > Thank you for the report.  This patch could certainly be changed to work
> > around this, but ISTM that the right fix is in the SH header file, since
> > the problem could hit in other cases too.  I've posted a fix here now:
> > 
> >  https://lore.kernel.org/lkml/20220414081257.1487499-1-vincent.whitchurch@axis.com/  
> 
> Looks good to me but I don't want to be the one "carrying" new compile
> errors so I'll drop the series for now, until you get this patch
> applied. Please then just resend the series with this thread mentioned
> and I'll take it back.

BTW, I'm only talking about this improvement, patches 1-3 will remain.


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

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-04-25  8:30           ` Miquel Raynal
  0 siblings, 0 replies; 36+ messages in thread
From: Miquel Raynal @ 2022-04-25  8:30 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2706 bytes --]


miquel.raynal(a)bootlin.com wrote on Mon, 25 Apr 2022 10:28:16 +0200:

> Hi Vincent,
> 
> vincent.whitchurch(a)axis.com wrote on Thu, 14 Apr 2022 11:04:02 +0200:
> 
> > On Wed, Apr 13, 2022 at 08:45:59AM +0200, kernel test robot wrote:  
> > > All errors (new ones prefixed by >>):
> > > 
> > >    In file included from include/linux/io.h:13,
> > >                     from drivers/mtd/devices/phram.c:21:
> > >    drivers/mtd/devices/phram.c: In function 'register_device':    
> > > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'    
> > >      274 | #define iounmap(addr)           do { } while (0)
> > >          |                                 ^~
> > >    drivers/mtd/devices/phram.c:150:44: note: in expansion of macro 'iounmap'
> > >      150 |         cached ? memunmap(new->mtd.priv) : iounmap(new->mtd.priv);
> > >          |                                            ^~~~~~~
> > >    drivers/mtd/devices/phram.c: In function 'phram_remove':    
> > > >> arch/sh/include/asm/io.h:274:33: error: expected expression before 'do'    
> > >      274 | #define iounmap(addr)           do { } while (0)
> > >          |                                 ^~
> > >    drivers/mtd/devices/phram.c:372:53: note: in expansion of macro 'iounmap'
> > >      372 |         phram->cached ? memunmap(phram->mtd.priv) : iounmap(phram->mtd.priv);
> > >          |                                                     ^~~~~~~
> > > 
> > > 
> > > vim +/do +274 arch/sh/include/asm/io.h
> > > 
> > > d57d64080ddc0f Paul Mundt        2010-01-19  272  
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14  273  #else /* CONFIG_MMU */
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14 @274  #define iounmap(addr)		do { } while (0)
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14  275  #define ioremap(offset, size)	((void __iomem *)(unsigned long)(offset))
> > > 13f1fc870dd747 Christoph Hellwig 2020-07-14  276  #endif /* CONFIG_MMU */
> > > d627a2ebd1a303 Paul Mundt        2010-01-28  277      
> > 
> > Thank you for the report.  This patch could certainly be changed to work
> > around this, but ISTM that the right fix is in the SH header file, since
> > the problem could hit in other cases too.  I've posted a fix here now:
> > 
> >  https://lore.kernel.org/lkml/20220414081257.1487499-1-vincent.whitchurch(a)axis.com/  
> 
> Looks good to me but I don't want to be the one "carrying" new compile
> errors so I'll drop the series for now, until you get this patch
> applied. Please then just resend the series with this thread mentioned
> and I'll take it back.

BTW, I'm only talking about this improvement, patches 1-3 will remain.

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
  2022-04-25  8:30           ` Miquel Raynal
  (?)
@ 2022-05-10 15:26             ` Vincent Whitchurch
  -1 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-05-10 15:26 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: kernel test robot, vigneshr, richard, joern, kbuild-all, kernel,
	linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Mon, Apr 25, 2022 at 10:30:15AM +0200, Miquel Raynal wrote:
> miquel.raynal@bootlin.com wrote on Mon, 25 Apr 2022 10:28:16 +0200:
> > Looks good to me but I don't want to be the one "carrying" new compile
> > errors so I'll drop the series for now, until you get this patch
> > applied. Please then just resend the series with this thread mentioned
> > and I'll take it back.
> 
> BTW, I'm only talking about this improvement, patches 1-3 will remain.

Thank you.  I've now refactored this patch and send it out separately as
a v4, primarily to avoid the SH build problems (which look like they're
going to take a while[0] to get fixed) but also to remove some code
duplication.

[0] https://lore.kernel.org/lkml/CAMuHMdW-8HaQip+DT5W2Owq8M8kbYwHsf8_Zd-5rRfSjSjK0=g@mail.gmail.com/

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

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-05-10 15:26             ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-05-10 15:26 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: kernel test robot, vigneshr, richard, joern, kbuild-all, kernel,
	linux-mtd, devicetree, robh+dt, krzk+dt, frowand.list,
	linux-kernel

On Mon, Apr 25, 2022 at 10:30:15AM +0200, Miquel Raynal wrote:
> miquel.raynal@bootlin.com wrote on Mon, 25 Apr 2022 10:28:16 +0200:
> > Looks good to me but I don't want to be the one "carrying" new compile
> > errors so I'll drop the series for now, until you get this patch
> > applied. Please then just resend the series with this thread mentioned
> > and I'll take it back.
> 
> BTW, I'm only talking about this improvement, patches 1-3 will remain.

Thank you.  I've now refactored this patch and send it out separately as
a v4, primarily to avoid the SH build problems (which look like they're
going to take a while[0] to get fixed) but also to remove some code
duplication.

[0] https://lore.kernel.org/lkml/CAMuHMdW-8HaQip+DT5W2Owq8M8kbYwHsf8_Zd-5rRfSjSjK0=g@mail.gmail.com/

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

* Re: [PATCH v3 4/4] mtd: phram: Allow cached mappings
@ 2022-05-10 15:26             ` Vincent Whitchurch
  0 siblings, 0 replies; 36+ messages in thread
From: Vincent Whitchurch @ 2022-05-10 15:26 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 801 bytes --]

On Mon, Apr 25, 2022 at 10:30:15AM +0200, Miquel Raynal wrote:
> miquel.raynal(a)bootlin.com wrote on Mon, 25 Apr 2022 10:28:16 +0200:
> > Looks good to me but I don't want to be the one "carrying" new compile
> > errors so I'll drop the series for now, until you get this patch
> > applied. Please then just resend the series with this thread mentioned
> > and I'll take it back.
> 
> BTW, I'm only talking about this improvement, patches 1-3 will remain.

Thank you.  I've now refactored this patch and send it out separately as
a v4, primarily to avoid the SH build problems (which look like they're
going to take a while[0] to get fixed) but also to remove some code
duplication.

[0] https://lore.kernel.org/lkml/CAMuHMdW-8HaQip+DT5W2Owq8M8kbYwHsf8_Zd-5rRfSjSjK0=g(a)mail.gmail.com/

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

end of thread, other threads:[~2022-05-10 15:29 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 13:52 [PATCH v3 0/4] mtd: phram improvements Vincent Whitchurch
2022-04-12 13:52 ` Vincent Whitchurch
2022-04-12 13:52 ` [PATCH v3 1/4] mtd: core: Check devicetree alias for index Vincent Whitchurch
2022-04-12 13:52   ` Vincent Whitchurch
2022-04-21  7:36   ` Miquel Raynal
2022-04-21  7:36     ` Miquel Raynal
2022-04-12 13:53 ` [PATCH v3 2/4] dt-bindings: reserved-memory: Support MTD/block device Vincent Whitchurch
2022-04-12 13:53   ` Vincent Whitchurch
2022-04-14 16:00   ` Rob Herring
2022-04-14 16:00     ` Rob Herring
2022-04-21  7:36   ` Miquel Raynal
2022-04-21  7:36     ` Miquel Raynal
2022-04-12 13:53 ` [PATCH v3 3/4] mtd: phram: Allow probing via reserved-memory Vincent Whitchurch
2022-04-12 13:53   ` Vincent Whitchurch
2022-04-14 16:02   ` Rob Herring
2022-04-14 16:02     ` Rob Herring
2022-04-21  7:36   ` Miquel Raynal
2022-04-21  7:36     ` Miquel Raynal
2022-04-12 13:53 ` [PATCH v3 4/4] mtd: phram: Allow cached mappings Vincent Whitchurch
2022-04-12 13:53   ` Vincent Whitchurch
2022-04-13  6:45   ` kernel test robot
2022-04-13  6:45     ` kernel test robot
2022-04-14  9:04     ` Vincent Whitchurch
2022-04-14  9:04       ` Vincent Whitchurch
2022-04-14  9:04       ` Vincent Whitchurch
2022-04-25  8:28       ` Miquel Raynal
2022-04-25  8:28         ` Miquel Raynal
2022-04-25  8:28         ` Miquel Raynal
2022-04-25  8:30         ` Miquel Raynal
2022-04-25  8:30           ` Miquel Raynal
2022-04-25  8:30           ` Miquel Raynal
2022-05-10 15:26           ` Vincent Whitchurch
2022-05-10 15:26             ` Vincent Whitchurch
2022-05-10 15:26             ` Vincent Whitchurch
2022-04-21  7:35   ` Miquel Raynal
2022-04-21  7:35     ` Miquel Raynal

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.