Skip to contentSkip to conversation

dt-binding: mtd: Document gpio-addr-flash

PATCH In review Ricardo Ribalda Delgado 2 participants 23 messages Oct 4, 2018 – Oct 8, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v10 9/10 dt-binding: mtd: Document gpio-addr-flash

Add documentation for gpio-addr-flash. This binding allow creating flash devices that are paged using GPIOs.

---
 Documentation/devicetree/bindings/mtd/mtd-physmap.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mtd/mtd-physmap.txt +2 -0
index 232fa12e90ef..7df0dcaccb7d 100644
@@ -29,6 +29,8 @@ file systems on embedded devices.
  - use-advanced-sector-protection: boolean to enable support for the
    advanced sector protection (Spansion: PPB - Persistent Protection
    Bits) locking.
+ - addr-gpios : (optional) List of GPIO descriptors that will be used to
+   address the MSBs address lines. The order goes from LSB to MSB.
 
 For JEDEC compatible devices, the following additional properties
 are defined:
Signature · 1 line
2.19.0
#1 lore raw

PATCH v10 10/10 mtd: maps: gpio-addr-flash: Add support for device-tree devices

Allow creating gpio-addr-flash via device-tree and not just via platform data.

Mimic what physmap_of_versatile and physmap_of_gemini does to reduce code duplicity.

---
 drivers/mtd/maps/Kconfig           |  8 +++
 drivers/mtd/maps/Makefile          |  3 +-
 drivers/mtd/maps/gpio-addr-flash.c | 95 +++++++++++++++++++-----------
 drivers/mtd/maps/gpio-addr-flash.h | 34 +++++++++++
 drivers/mtd/maps/physmap_of_core.c |  5 ++
 drivers/mtd/maps/physmap_of_gpio.c | 21 +++++++
 6 files changed, 129 insertions(+), 37 deletions(-)
 create mode 100644 drivers/mtd/maps/gpio-addr-flash.h
 create mode 100644 drivers/mtd/maps/physmap_of_gpio.c
drivers/mtd/maps/Kconfig +8 -0
index afb36bff13a7..427143d42168 100644
@@ -94,6 +94,14 @@ config MTD_PHYSMAP_OF_GEMINI
 	  platforms, some detection and setting up parallel mode on the
 	  external interface.
 
+config MTD_PHYSMAP_OF_GPIO
+	bool "GPIO-assisted OF-based physical memory map handling"
+	depends on MTD_PHYSMAP_OF
+	depends on MTD_GPIO_ADDR
+	help
+	  This provides some extra DT physmap parsing for flashes that are
+	  partially physically addressed and assisted by GPIOs.
+
 config MTD_PMC_MSP_EVM
 	tristate "CFI Flash device mapped on PMC-Sierra MSP"
 	depends on PMC_MSP && MTD_CFI
drivers/mtd/maps/Makefile +2 -1
index 51acf1fec19b..c232ccf05bee 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_MTD_PHYSMAP)	+= physmap.o
 physmap_of-objs-y		+= physmap_of_core.o
 physmap_of-objs-$(CONFIG_MTD_PHYSMAP_OF_VERSATILE) += physmap_of_versatile.o
 physmap_of-objs-$(CONFIG_MTD_PHYSMAP_OF_GEMINI) += physmap_of_gemini.o
+physmap_of-objs-$(CONFIG_MTD_PHYSMAP_OF_GPIO) += physmap_of_gpio.o
 physmap_of-objs			:= $(physmap_of-objs-y)
 obj-$(CONFIG_MTD_PHYSMAP_OF)	+= physmap_of.o
 obj-$(CONFIG_MTD_PISMO)		+= pismo.o
@@ -44,6 +45,6 @@ obj-$(CONFIG_MTD_PLATRAM)	+= plat-ram.o
 obj-$(CONFIG_MTD_INTEL_VR_NOR)	+= intel_vr_nor.o
 obj-$(CONFIG_MTD_RBTX4939)	+= rbtx4939-flash.o
 obj-$(CONFIG_MTD_VMU)		+= vmu-flash.o
-obj-$(CONFIG_MTD_GPIO_ADDR)	+= gpio-addr-flash.o
+obj-$(CONFIG_MTD_GPIO_ADDR)    += gpio-addr-flash.o
 obj-$(CONFIG_MTD_LATCH_ADDR)	+= latch-addr-flash.o
 obj-$(CONFIG_MTD_LANTIQ)	+= lantiq-flash.o
drivers/mtd/maps/gpio-addr-flash.c +59 -36

147 lines not on this page · raw message

drivers/mtd/maps/gpio-addr-flash.h new file +34 -0
new file mode 100644
index 000000000000..443577f7fdfd
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/of.h>
+#include <linux/mtd/map.h>
+
+/**
+ * struct async_state - keep GPIO flash state
+ *	@gpios:       Struct containing the array of GPIO descriptors
+ *	@gpio_values: cached GPIO values
+ *	@win_order:   dedicated memory size (if no GPIOs)
+ */
+struct async_state {
+	struct gpio_descs *gpios;
+	unsigned int gpio_values;
+	unsigned int win_order;
+};
+
+int gpio_flash_probe_common(struct device *dev,
+				   struct async_state *state,
+				   struct map_info *map);
+
+#ifdef CONFIG_MTD_PHYSMAP_OF_GPIO
+int of_flash_probe_gpio(struct platform_device *pdev, struct device_node *np,
+			struct map_info *map);
+#else
+static inline
+int of_flash_probe_gpio(struct platform_device *pdev, struct device_node *np,
+			struct map_info *map)
+{
+	if (of_find_property(np, "addr-gpios", NULL))
+		return -EINVAL;
+
+	return 0;
+}
+#endif
drivers/mtd/maps/physmap_of_core.c +5 -0
index ece605d78c21..c187b6ff873d 100644
@@ -27,6 +27,7 @@
 #include <linux/slab.h>
 #include "physmap_of_gemini.h"
 #include "physmap_of_versatile.h"
+#include "gpio-addr-flash.h"
 
 struct of_flash_list {
 	struct mtd_info *mtd;
@@ -240,6 +241,10 @@ static int of_flash_probe(struct platform_device *dev)
 
 		simple_map_init(&info->list[i].map);
 
+		err = of_flash_probe_gpio(dev, dp, &info->list[i].map);
+		if (err)
+			goto err_out;
+
 		/*
 		 * On some platforms (e.g. MPC5200) a direct 1:1 mapping
 		 * may cause problems with JFFS2 usage, as the local bus (LPB)
drivers/mtd/maps/physmap_of_gpio.c new file +21 -0
new file mode 100644
index 000000000000..c84c5e96e592
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2018 Qtechnology A/S
+ *
+ * Ricardo Ribalda <[email protected]>
+ *
+ */
+#include <linux/platform_device.h>
+#include "gpio-addr-flash.h"
+
+int of_flash_probe_gpio(struct platform_device *pdev, struct device_node *np,
+			struct map_info *map)
+{
+	struct async_state *state;
+
+	state = devm_kzalloc(&pdev->dev, sizeof(*state), GFP_KERNEL);
+	if (!state)
+		return -ENOMEM;
+
+	return gpio_flash_probe_common(&pdev->dev, state, map);
+}
Signature · 1 line
2.19.0
#2 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Hi Ricardo,

Quoted 24 lines · On Thu, 4 Oct 2018 16:29:42 +0200 Ricardo Ribalda Delgado…

Allow creating gpio-addr-flash via device-tree and not just via platform data.

Mimic what physmap_of_versatile and physmap_of_gemini does to reduce code duplicity.

---
 drivers/mtd/maps/Kconfig           |  8 +++
 drivers/mtd/maps/Makefile          |  3 +-
 drivers/mtd/maps/gpio-addr-flash.c | 95 +++++++++++++++++++-----------
 drivers/mtd/maps/gpio-addr-flash.h | 34 +++++++++++
 drivers/mtd/maps/physmap_of_core.c |  5 ++
 drivers/mtd/maps/physmap_of_gpio.c | 21 +++++++
 6 files changed, 129 insertions(+), 37 deletions(-)
 create mode 100644 drivers/mtd/maps/gpio-addr-flash.h
 create mode 100644 drivers/mtd/maps/physmap_of_gpio.c
drivers/mtd/maps/Kconfig +0 -0
index afb36bff13a7..427143d42168 100644
@@ -94,6 +94,14 @@ config MTD_PHYSMAP_OF_GEMINI
 	  platforms, some detection and setting up parallel mode on the

drivers/mtd/maps/Kconfig config MTD_PHYSMAP_OF_GEMINI · line 104

Quoted 10 lines
drivers/mtd/maps/Kconfig +8 -0
 	  external interface.
 
+config MTD_PHYSMAP_OF_GPIO
+	bool "GPIO-assisted OF-based physical memory map handling"
+	depends on MTD_PHYSMAP_OF
+	depends on MTD_GPIO_ADDR
+	help
+	  This provides some extra DT physmap parsing for flashes that are
+	  partially physically addressed and assisted by GPIOs.
+

Hm, so now we have the physmap_of driver which uses a function exposed by the gpio-addr-flash module, but this module is also declaring a platform_driver. It's probably working fine, but it's hard to follow.

So, I decided to give it a try and started to rework a bit the physmap, physmap_of and gpio-addr-flash drivers. Here is the result [1] (it's only been compile tested). With this rework we now have a single driver which supports DT and !DT init and can also use GPIOs to extend the physical memory range in case it's not large enough to address the whole memory dev.

Let me know what you think of this approach.

Regards,

Boris

[1]https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

#3 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Hi Boris

Quoted 45 lines · Boris Brezillon

Hi Ricardo,

Quoted 24 lines · On Thu, 4 Oct 2018 16:29:42 +0200 Ricardo Ribalda Delgado…

Allow creating gpio-addr-flash via device-tree and not just via platform data.

Mimic what physmap_of_versatile and physmap_of_gemini does to reduce code duplicity.

---
 drivers/mtd/maps/Kconfig           |  8 +++
 drivers/mtd/maps/Makefile          |  3 +-
 drivers/mtd/maps/gpio-addr-flash.c | 95 +++++++++++++++++++-----------
 drivers/mtd/maps/gpio-addr-flash.h | 34 +++++++++++
 drivers/mtd/maps/physmap_of_core.c |  5 ++
 drivers/mtd/maps/physmap_of_gpio.c | 21 +++++++
 6 files changed, 129 insertions(+), 37 deletions(-)
 create mode 100644 drivers/mtd/maps/gpio-addr-flash.h
 create mode 100644 drivers/mtd/maps/physmap_of_gpio.c
drivers/mtd/maps/Kconfig +0 -0
index afb36bff13a7..427143d42168 100644
@@ -94,6 +94,14 @@ config MTD_PHYSMAP_OF_GEMINI
        platforms, some detection and setting up parallel mode on the

drivers/mtd/maps/Kconfig config MTD_PHYSMAP_OF_GEMINI · line 104

Quoted 10 lines
drivers/mtd/maps/Kconfig +8 -0
        external interface.
 
+config MTD_PHYSMAP_OF_GPIO
+     bool "GPIO-assisted OF-based physical memory map handling"
+     depends on MTD_PHYSMAP_OF
+     depends on MTD_GPIO_ADDR
+     help
+       This provides some extra DT physmap parsing for flashes that are
+       partially physically addressed and assisted by GPIOs.
+

Hm, so now we have the physmap_of driver which uses a function exposed by the gpio-addr-flash module, but this module is also declaring a platform_driver. It's probably working fine, but it's hard to follow.

Quoted 9 lines

So, I decided to give it a try and started to rework a bit the physmap, physmap_of and gpio-addr-flash drivers. Here is the result [1] (it's only been compile tested). With this rework we now have a single driver which supports DT and !DT init and can also use GPIOs to extend the physical memory range in case it's not large enough to address the whole memory dev.

Let me know what you think of this approach.

The code is definitely easier to follow. But I believe you should rebase your changes on mines (1-9) and instead of 10 apply your patch-set.:
- "mtd: maps: Merge gpio-addr-flash.c into physmap-core.c" includes all my changes and some of them are not obvious:( Port to gpiod, gpio_values, win_order, use new apis....)
- Also there would be 1 (or 2) fixes that should be included in stable that we lose using your approach "mtd: maps: gpio-addr-flash: Fix ioremapped size", "mtd: physmap_of: Release resources on error"
- And last, but not least, I want some credit for all this work ;) After 10 iterations I guess that I deserve more than a Documentation change, specially when my code would be on the tree.

My other concern is that maybe we are giving too much entity to gpio-addr by including it in the core. But if you are fine with it, I am fine with it.

If you want i can do the rebase and start testing on my board. What do you think?

Regards!

Quoted 5 lines

Regards,

Boris

[1]https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

--
Ricardo Ribalda

#4 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Hi Ricardo,

Quoted 60 lines · On Fri, 5 Oct 2018 08:31:35 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 45 lines · Boris Brezillon

Hi Ricardo,

Quoted 24 lines · On Thu, 4 Oct 2018 16:29:42 +0200 Ricardo Ribalda Delgado…

Allow creating gpio-addr-flash via device-tree and not just via platform data.

Mimic what physmap_of_versatile and physmap_of_gemini does to reduce code duplicity.

---
 drivers/mtd/maps/Kconfig           |  8 +++
 drivers/mtd/maps/Makefile          |  3 +-
 drivers/mtd/maps/gpio-addr-flash.c | 95 +++++++++++++++++++-----------
 drivers/mtd/maps/gpio-addr-flash.h | 34 +++++++++++
 drivers/mtd/maps/physmap_of_core.c |  5 ++
 drivers/mtd/maps/physmap_of_gpio.c | 21 +++++++
 6 files changed, 129 insertions(+), 37 deletions(-)
 create mode 100644 drivers/mtd/maps/gpio-addr-flash.h
 create mode 100644 drivers/mtd/maps/physmap_of_gpio.c
drivers/mtd/maps/Kconfig +0 -0
index afb36bff13a7..427143d42168 100644
@@ -94,6 +94,14 @@ config MTD_PHYSMAP_OF_GEMINI
        platforms, some detection and setting up parallel mode on the

drivers/mtd/maps/Kconfig config MTD_PHYSMAP_OF_GEMINI · line 104

Quoted 10 lines
drivers/mtd/maps/Kconfig +8 -0
        external interface.
 
+config MTD_PHYSMAP_OF_GPIO
+     bool "GPIO-assisted OF-based physical memory map handling"
+     depends on MTD_PHYSMAP_OF
+     depends on MTD_GPIO_ADDR
+     help
+       This provides some extra DT physmap parsing for flashes that are
+       partially physically addressed and assisted by GPIOs.
+  

Hm, so now we have the physmap_of driver which uses a function exposed by the gpio-addr-flash module, but this module is also declaring a platform_driver. It's probably working fine, but it's hard to follow.

Quoted 9 lines

So, I decided to give it a try and started to rework a bit the physmap, physmap_of and gpio-addr-flash drivers. Here is the result [1] (it's only been compile tested). With this rework we now have a single driver which supports DT and !DT init and can also use GPIOs to extend the physical memory range in case it's not large enough to address the whole memory dev.

Let me know what you think of this approach.

Quoted 6 lines

The code is definitely easier to follow. But I believe you should rebase your changes on mines (1-9) and instead of 10 apply your patch-set.:
- "mtd: maps: Merge gpio-addr-flash.c into physmap-core.c" includes all my changes and some of them are not obvious:( Port to gpiod, gpio_values, win_order, use new apis....)

True.

Quoted 3 lines

- Also there would be 1 (or 2) fixes that should be included in stable that we lose using your approach "mtd: maps: gpio-addr-flash: Fix ioremapped size", "mtd: physmap_of: Release resources on error"

I'm not sure this is really useful to backport them to stable since blackfin users never complained about it (plus, blackin arch is now gone), but okay.

Quoted 3 lines

- And last, but not least, I want some credit for all this work ;) After 10 iterations I guess that I deserve more than a Documentation change, specially when my code would be on the tree.

Fair enough.

Quoted 4 lines

My other concern is that maybe we are giving too much entity to gpio-addr by including it in the core. But if you are fine with it, I am fine with it.

Well, the gpio-addr stuff is just here to support platforms that do not have enough ADDR lines (or iomem address space) to address the whole device. I see it as an 'extension' of the physmap logic, which is why I think it makes sense to have this logic in the physmap driver instead of creating a completely new driver.

Quoted 3 lines

If you want i can do the rebase and start testing on my board. What do you think?

That'd be great!

Thanks,

Boris

#5 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Quoted 101 lines · Boris Brezillon

Hi Ricardo,

Quoted 60 lines · On Fri, 5 Oct 2018 08:31:35 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 45 lines · Boris Brezillon

Hi Ricardo,

Quoted 24 lines · On Thu, 4 Oct 2018 16:29:42 +0200 Ricardo Ribalda Delgado…

Allow creating gpio-addr-flash via device-tree and not just via platform data.

Mimic what physmap_of_versatile and physmap_of_gemini does to reduce code duplicity.

---
 drivers/mtd/maps/Kconfig           |  8 +++
 drivers/mtd/maps/Makefile          |  3 +-
 drivers/mtd/maps/gpio-addr-flash.c | 95 +++++++++++++++++++-----------
 drivers/mtd/maps/gpio-addr-flash.h | 34 +++++++++++
 drivers/mtd/maps/physmap_of_core.c |  5 ++
 drivers/mtd/maps/physmap_of_gpio.c | 21 +++++++
 6 files changed, 129 insertions(+), 37 deletions(-)
 create mode 100644 drivers/mtd/maps/gpio-addr-flash.h
 create mode 100644 drivers/mtd/maps/physmap_of_gpio.c
drivers/mtd/maps/Kconfig +0 -0
index afb36bff13a7..427143d42168 100644
@@ -94,6 +94,14 @@ config MTD_PHYSMAP_OF_GEMINI
        platforms, some detection and setting up parallel mode on the

drivers/mtd/maps/Kconfig config MTD_PHYSMAP_OF_GEMINI · line 104

Quoted 10 lines
drivers/mtd/maps/Kconfig +8 -0
        external interface.
 
+config MTD_PHYSMAP_OF_GPIO
+     bool "GPIO-assisted OF-based physical memory map handling"
+     depends on MTD_PHYSMAP_OF
+     depends on MTD_GPIO_ADDR
+     help
+       This provides some extra DT physmap parsing for flashes that are
+       partially physically addressed and assisted by GPIOs.
+

Hm, so now we have the physmap_of driver which uses a function exposed by the gpio-addr-flash module, but this module is also declaring a platform_driver. It's probably working fine, but it's hard to follow.

Quoted 9 lines

So, I decided to give it a try and started to rework a bit the physmap, physmap_of and gpio-addr-flash drivers. Here is the result [1] (it's only been compile tested). With this rework we now have a single driver which supports DT and !DT init and can also use GPIOs to extend the physical memory range in case it's not large enough to address the whole memory dev.

Let me know what you think of this approach.

Quoted 6 lines

The code is definitely easier to follow. But I believe you should rebase your changes on mines (1-9) and instead of 10 apply your patch-set.:
- "mtd: maps: Merge gpio-addr-flash.c into physmap-core.c" includes all my changes and some of them are not obvious:( Port to gpiod, gpio_values, win_order, use new apis....)

True.

Quoted 3 lines

- Also there would be 1 (or 2) fixes that should be included in stable that we lose using your approach "mtd: maps: gpio-addr-flash: Fix ioremapped size", "mtd: physmap_of: Release resources on error"

I'm not sure this is really useful to backport them to stable since blackfin users never complained about it (plus, blackin arch is now gone), but okay.

Quoted 3 lines

- And last, but not least, I want some credit for all this work ;) After 10 iterations I guess that I deserve more than a Documentation change, specially when my code would be on the tree.

Fair enough.

Quoted 4 lines

My other concern is that maybe we are giving too much entity to gpio-addr by including it in the core. But if you are fine with it, I am fine with it.

Well, the gpio-addr stuff is just here to support platforms that do not have enough ADDR lines (or iomem address space) to address the whole device. I see it as an 'extension' of the physmap logic, which is why I think it makes sense to have this logic in the physmap driver instead of creating a completely new driver.

Quoted 1 line
Quoted 4 lines
Quoted 2 lines

If you want i can do the rebase and start testing on my board. What do you think?

That'd be great!

Can you start by picking 1-8 from my patchset so i do not have to resend it again and again while we work on your changes?

Thanks!

Quoted 4 lines

Thanks,

Boris

Signature · 1 line
Ricardo Ribalda
#6 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Quoted 103 lines · On Fri, 5 Oct 2018 10:10:22 +0200 Ricardo Ribalda Delgado…
Quoted 101 lines · Boris Brezillon

Hi Ricardo,

Quoted 60 lines · On Fri, 5 Oct 2018 08:31:35 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 45 lines · Boris Brezillon

Hi Ricardo,

Quoted 24 lines · On Thu, 4 Oct 2018 16:29:42 +0200 Ricardo Ribalda Delgado…

Allow creating gpio-addr-flash via device-tree and not just via platform data.

Mimic what physmap_of_versatile and physmap_of_gemini does to reduce code duplicity.

---
 drivers/mtd/maps/Kconfig           |  8 +++
 drivers/mtd/maps/Makefile          |  3 +-
 drivers/mtd/maps/gpio-addr-flash.c | 95 +++++++++++++++++++-----------
 drivers/mtd/maps/gpio-addr-flash.h | 34 +++++++++++
 drivers/mtd/maps/physmap_of_core.c |  5 ++
 drivers/mtd/maps/physmap_of_gpio.c | 21 +++++++
 6 files changed, 129 insertions(+), 37 deletions(-)
 create mode 100644 drivers/mtd/maps/gpio-addr-flash.h
 create mode 100644 drivers/mtd/maps/physmap_of_gpio.c
drivers/mtd/maps/Kconfig +0 -0
index afb36bff13a7..427143d42168 100644
@@ -94,6 +94,14 @@ config MTD_PHYSMAP_OF_GEMINI
        platforms, some detection and setting up parallel mode on the

drivers/mtd/maps/Kconfig config MTD_PHYSMAP_OF_GEMINI · line 104

Quoted 10 lines
drivers/mtd/maps/Kconfig +8 -0
        external interface.
 
+config MTD_PHYSMAP_OF_GPIO
+     bool "GPIO-assisted OF-based physical memory map handling"
+     depends on MTD_PHYSMAP_OF
+     depends on MTD_GPIO_ADDR
+     help
+       This provides some extra DT physmap parsing for flashes that are
+       partially physically addressed and assisted by GPIOs.
+  

Hm, so now we have the physmap_of driver which uses a function exposed by the gpio-addr-flash module, but this module is also declaring a platform_driver. It's probably working fine, but it's hard to follow.

Quoted 9 lines

So, I decided to give it a try and started to rework a bit the physmap, physmap_of and gpio-addr-flash drivers. Here is the result [1] (it's only been compile tested). With this rework we now have a single driver which supports DT and !DT init and can also use GPIOs to extend the physical memory range in case it's not large enough to address the whole memory dev.

Let me know what you think of this approach.

Quoted 6 lines

The code is definitely easier to follow. But I believe you should rebase your changes on mines (1-9) and instead of 10 apply your patch-set.:
- "mtd: maps: Merge gpio-addr-flash.c into physmap-core.c" includes all my changes and some of them are not obvious:( Port to gpiod, gpio_values, win_order, use new apis....)

True.

Quoted 3 lines

- Also there would be 1 (or 2) fixes that should be included in stable that we lose using your approach "mtd: maps: gpio-addr-flash: Fix ioremapped size", "mtd: physmap_of: Release resources on error"

I'm not sure this is really useful to backport them to stable since blackfin users never complained about it (plus, blackin arch is now gone), but okay.

Quoted 3 lines

- And last, but not least, I want some credit for all this work ;) After 10 iterations I guess that I deserve more than a Documentation change, specially when my code would be on the tree.

Fair enough.

Quoted 4 lines

My other concern is that maybe we are giving too much entity to gpio-addr by including it in the core. But if you are fine with it, I am fine with it.

Well, the gpio-addr stuff is just here to support platforms that do not have enough ADDR lines (or iomem address space) to address the whole device. I see it as an 'extension' of the physmap logic, which is why I think it makes sense to have this logic in the physmap driver instead of creating a completely new driver.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

If you want i can do the rebase and start testing on my board. What do you think?

That'd be great!

Can you start by picking 1-8 from my patchset so i do not have to resend it again and again while we work on your changes?

Done.

#7 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

I am about to test it in real hw (unless you want me wait)

Cheers!

Quoted 116 lines · Boris Brezillon
Quoted 103 lines · On Fri, 5 Oct 2018 10:10:22 +0200 Ricardo Ribalda Delgado…
Quoted 101 lines · Boris Brezillon

Hi Ricardo,

Quoted 60 lines · On Fri, 5 Oct 2018 08:31:35 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 45 lines · Boris Brezillon

Hi Ricardo,

Quoted 24 lines · On Thu, 4 Oct 2018 16:29:42 +0200 Ricardo Ribalda Delgado…

Allow creating gpio-addr-flash via device-tree and not just via platform data.

Mimic what physmap_of_versatile and physmap_of_gemini does to reduce code duplicity.

---
 drivers/mtd/maps/Kconfig           |  8 +++
 drivers/mtd/maps/Makefile          |  3 +-
 drivers/mtd/maps/gpio-addr-flash.c | 95 +++++++++++++++++++-----------
 drivers/mtd/maps/gpio-addr-flash.h | 34 +++++++++++
 drivers/mtd/maps/physmap_of_core.c |  5 ++
 drivers/mtd/maps/physmap_of_gpio.c | 21 +++++++
 6 files changed, 129 insertions(+), 37 deletions(-)
 create mode 100644 drivers/mtd/maps/gpio-addr-flash.h
 create mode 100644 drivers/mtd/maps/physmap_of_gpio.c
drivers/mtd/maps/Kconfig +0 -0
index afb36bff13a7..427143d42168 100644
@@ -94,6 +94,14 @@ config MTD_PHYSMAP_OF_GEMINI
        platforms, some detection and setting up parallel mode on the

drivers/mtd/maps/Kconfig config MTD_PHYSMAP_OF_GEMINI · line 104

Quoted 10 lines
drivers/mtd/maps/Kconfig +8 -0
        external interface.
 
+config MTD_PHYSMAP_OF_GPIO
+     bool "GPIO-assisted OF-based physical memory map handling"
+     depends on MTD_PHYSMAP_OF
+     depends on MTD_GPIO_ADDR
+     help
+       This provides some extra DT physmap parsing for flashes that are
+       partially physically addressed and assisted by GPIOs.
+

Hm, so now we have the physmap_of driver which uses a function exposed by the gpio-addr-flash module, but this module is also declaring a platform_driver. It's probably working fine, but it's hard to follow.

Quoted 9 lines

So, I decided to give it a try and started to rework a bit the physmap, physmap_of and gpio-addr-flash drivers. Here is the result [1] (it's only been compile tested). With this rework we now have a single driver which supports DT and !DT init and can also use GPIOs to extend the physical memory range in case it's not large enough to address the whole memory dev.

Let me know what you think of this approach.

Quoted 6 lines

The code is definitely easier to follow. But I believe you should rebase your changes on mines (1-9) and instead of 10 apply your patch-set.:
- "mtd: maps: Merge gpio-addr-flash.c into physmap-core.c" includes all my changes and some of them are not obvious:( Port to gpiod, gpio_values, win_order, use new apis....)

True.

Quoted 3 lines

- Also there would be 1 (or 2) fixes that should be included in stable that we lose using your approach "mtd: maps: gpio-addr-flash: Fix ioremapped size", "mtd: physmap_of: Release resources on error"

I'm not sure this is really useful to backport them to stable since blackfin users never complained about it (plus, blackin arch is now gone), but okay.

Quoted 3 lines

- And last, but not least, I want some credit for all this work ;) After 10 iterations I guess that I deserve more than a Documentation change, specially when my code would be on the tree.

Fair enough.

Quoted 4 lines

My other concern is that maybe we are giving too much entity to gpio-addr by including it in the core. But if you are fine with it, I am fine with it.

Well, the gpio-addr stuff is just here to support platforms that do not have enough ADDR lines (or iomem address space) to address the whole device. I see it as an 'extension' of the physmap logic, which is why I think it makes sense to have this logic in the physmap driver instead of creating a completely new driver.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

If you want i can do the rebase and start testing on my board. What do you think?

That'd be great!

Can you start by picking 1-8 from my patchset so i do not have to resend it again and again while we work on your changes?

Done.

Signature · 1 line
Ricardo Ribalda
#9 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Hi Boris

Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

Quoted 7 lines
Quoted 1 line

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

If you send the patchset to the mailing list I can review it patch by patch.

Also
mtd: maps: Prepare merging of physmap and physmap_of

I do not think that can be bisected. (Not sure, I have to test it)

I add the diff to the mail, but gmail will probably scramble the lines(yes I know I have to use other mail client)

Thanks!

drivers/mtd/maps/physmap-core.c +4 -6
index 2e236ef60e04..d7a902afc9a7 100644
@@ -69,8 +69,6 @@ static int physmap_flash_remove(struct platform_device *dev)
  if (!info)
  return 0;
 
- physmap_data = dev_get_platdata(&dev->dev);
-
  if (info->cmtd) {
  err = mtd_device_unregister(info->cmtd);
  if (err)
@@ -80,12 +78,12 @@ static int physmap_flash_remove(struct platform_device *dev)
  mtd_concat_destroy(info->cmtd);
  }
 
- for (i = 0; i < info->nmaps; i++) {
- if (!info->mtds[i])
+ for (i = 0; i < info->nmaps; i++)
+ if (info->mtds[i])
  map_destroy(info->mtds[i]);
- }
 
- if (physmap_data->exit)
+ physmap_data = dev_get_platdata(&dev->dev);
+ if (physmap_data && physmap_data->exit)
  physmap_data->exit(dev);
 
  return 0;
@@ -456,18 +454,18 @@ static int physmap_flash_probe(struct

platform_device *dev)
info->maps = devm_kzalloc(&dev->dev,

    sizeof(*info->maps) * info->nmaps,
    GFP_KERNEL);

- if (info->maps)
+ if (!info->maps)
return -ENOMEM;

info->mtds = devm_kzalloc(&dev->dev,

    sizeof(*info->mtds) * info->nmaps,
    GFP_KERNEL);

- if (info->mtds)
+ if (!info->mtds)
return -ENOMEM;

  platform_set_drvdata(dev, info);

- info->gpios = devm_gpiod_get_array_optional(&dev->dev, "addr-gpios",
+ info->gpios = devm_gpiod_get_array_optional(&dev->dev, "addr",

      GPIOD_OUT_LOW);

if (IS_ERR(info->gpios))
return PTR_ERR(info->gpios);
@@ -480,14 +478,6 @@ static int physmap_flash_probe(struct platform_device *dev)
err = physmap_flash_of_init(dev);
if (err)
err = physmap_flash_pdata_init(dev);
-
- if (err)
- return err;
-
- err = physmap_flash_of_init(dev);
- if (err)
- err = physmap_flash_pdata_init(dev);
-
if (err)
return err;

@@ -509,7 +499,6 @@ static int physmap_flash_probe(struct platform_device *dev)
if (!info->maps[i].phys)
info->maps[i].phys = res->start;

- info->maps[i].size = resource_size(res); info->win_order = get_bitmask_order(resource_size(res)) - 1; info->maps[i].size = BIT(info->win_order + (info->gpios ?

Signature · 1 line
Ricardo Ribalda
#10 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Quoted 24 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

Quoted 7 lines
Quoted 1 line

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

Quoted 6 lines

If you send the patchset to the mailing list I can review it patch by patch.

Also
mtd: maps: Prepare merging of physmap and physmap_of

I do not think that can be bisected. (Not sure, I have to test it)

Okay, I'll have a look.

Quoted 3 lines

I add the diff to the mail, but gmail will probably scramble the lines(yes I know I have to use other mail client)

The diff looks good, I'll fix that an send a push a new version.

Thanks,

Boris

#11 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Hi again Boris

Quoted 35 lines · Boris Brezillon
Quoted 24 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

Quoted 7 lines
Quoted 1 line

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

Quoted 6 lines

If you send the patchset to the mailing list I can review it patch by patch.

Also
mtd: maps: Prepare merging of physmap and physmap_of

I do not think that can be bisected. (Not sure, I have to test it)

Quoted 7 lines

Okay, I'll have a look.

Quoted 3 lines

I add the diff to the mail, but gmail will probably scramble the lines(yes I know I have to use other mail client)

The diff looks good, I'll fix that an send a push a new version.

Also fix on physmap_flash_remove

physmap_data->exit(dev); must be called BEFORE
map_destroy(info->mtds[i]);

otherwise OOPS

Cheers!

[  162.700421] Unable to handle kernel paging request at virtual
address 7974696e6966a6
[  162.705461] Mem abort info:
[  162.713171]   Exception class = DABT (current EL), IL = 32 bits
[  162.715678]   SET = 0, FnV = 0
[  162.721588]   EA = 0, S1PTW = 0
[  162.724703] Data abort info:
[  162.727767]   ISV = 0, ISS = 0x00000004
[  162.730879]   CM = 0, WnR = 0
[  162.734436] [007974696e6966a6] address between user and kernel address ranges
[  162.737567] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[  162.744674] Modules linked in: qtec_m43 qtec_mem qt5023_video

qtec_white qtec_cmosis arc4 snd_soc_hdmi_codec ath10k_pci ath10k_core venus_dec venus_enc ath mac80211 q6asm_dai cfi_cmdset_0002 q6routing q6afe_dai cfi_probe q6adm cfi_util q6asm gen_probe q6afe q6dsp_common q6core physmap gpio_xilinx qtec_pcie qtec_clk apr qrtr_smd rpmsg_char imx214 ad5820 v4l2_common joydev cfg80211 msm venus_core hci_uart qt5023 qcom_camss btqca v4l2_mem2mem drm_kms_helper videobuf2_dma_sg v4l2_fwnode videobuf2_memops videobuf2_v4l2 bluetooth drm videobuf2_core videodev ecdh_generic i2c_qcom_cci media rtc_pm8xxx leds_qcom_lpg qrtr crc32_ce qcom_adsp_pil crct10dif_ce qcom_common snd_soc_apq8096 qcom_glink_smem qcom_sysmon remoteproc qmi_helpers rmtfs_mem mdt_loader sch_fq_codel

[  162.795188] CPU: 2 PID: 1 Comm: systemd-shutdow Not tainted
4.14.53-qtec-linaro #34
[  162.817417] Hardware name: Qtechnology QT5506 (DT)
[  162.824793] task: ffff8000baac8000 task.stack: ffff000008058000
[  162.829671] PC is at cfi_amdstd_reset+0xb4/0x188 [cfi_cmdset_0002]
[  162.835474] LR is at cfi_amdstd_reset+0xb4/0x188 [cfi_cmdset_0002]
[  162.841721] pc : [<ffff00000107fe44>] lr : [<ffff00000107fe44>]
pstate: 40000145
[  162.847885] sp : ffff00000805bc80
[  162.855433] x29: ffff00000805bc80 x28: ffff8000baac8000
[  162.858648] x27: ffff000008b51000 x26: 000000000000008e
[  162.864030] x25: 0000000000000124 x24: 0000000000000014
[  162.869324] x23: 0000000000000000 x22: 0000000000000000
[  162.874619] x21: 5f7974696e696666 x20: ffff8000b3178a18
[  162.879915] x19: ffff8000b5215800 x18: 0000000000000000
[  162.885209] x17: 0000ffffa46d1768 x16: ffff0000080f9960
[  162.890504] x15: 0000000000000010 x14: ffffffffffffffff
[  162.895800] x13: ffff0000896355e7 x12: ffff0000096355ef
[  162.901094] x11: ffff00000944a000 x10: ffff00000805b9b0
[  162.906389] x9 : 0000000000000039 x8 : 000000000000000d
[  162.911686] x7 : ffff00000805ba2c x6 : 0000000000000491
[  162.916980] x5 : 0000000000000000 x4 : 0000000000000000
[  162.922275] x3 : ffffffffffffffff x2 : ffff00000944a278
[  162.927570] x1 : ffff8000baac8000 x0 : 0000000000000028
[  162.932867] Process systemd-shutdow (pid: 1, stack limit =
0xffff000008058000)
[  162.938164] Call trace:
[  162.945191] Exception stack(0xffff00000805bb40 to 0xffff00000805bc80)
[  162.947538] bb40: 0000000000000028 ffff8000baac8000
ffff00000944a278 ffffffffffffffff
[  162.954136] bb60: 0000000000000000 0000000000000000
0000000000000491 ffff00000805ba2c
[  162.961949] bb80: 000000000000000d 0000000000000039
ffff00000805b9b0 ffff00000944a000
[  162.969762] bba0: ffff0000096355ef ffff0000896355e7
ffffffffffffffff 0000000000000010
[  162.977574] bbc0: ffff0000080f9960 0000ffffa46d1768
0000000000000000 ffff8000b5215800
[  162.985386] bbe0: ffff8000b3178a18 5f7974696e696666
0000000000000000 0000000000000000
[  162.993200] bc00: 0000000000000014 0000000000000124
000000000000008e ffff000008b51000
[  163.001011] bc20: ffff8000baac8000 ffff00000805bc80
ffff00000107fe44 ffff00000805bc80
[  163.008823] bc40: ffff00000107fe44 0000000040000145
0000000000000b5b ffffffffffffffff
[  163.016637] bc60: 0000ffffffffffff 0000000000000000
ffff00000805bc80 ffff00000107fe44
[  163.024454] [<ffff00000107fe44>] cfi_amdstd_reset+0xb4/0x188
[cfi_cmdset_0002]
[  163.032264] [<ffff00000107ff78>] cfi_amdstd_reboot+0x10/0x98
[cfi_cmdset_0002]
[  163.039386] [<ffff0000080f7d0c>] notifier_call_chain+0x54/0x90
[  163.046583] [<ffff0000080f85d4>] blocking_notifier_call_chain+0x54/0x78
[  163.052399] [<ffff0000080f96ac>] kernel_restart_prepare+0x1c/0x40
[  163.058910] [<ffff0000080f97a4>] kernel_restart+0x14/0x60
[  163.065158] [<ffff0000080f9b68>] SyS_reboot+0x208/0x230
Quoted 4 lines

Thanks,

Boris

Signature · 1 line
Ricardo Ribalda
#19 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

In reply to Ricardo Ribalda Delgado
Quoted 20 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 17 lines · Boris Brezillon
Quoted 8 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Quoted 8 lines
Quoted 1 line

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

If you send the patchset to the mailing list I can review it patch by patch.

Also
mtd: maps: Prepare merging of physmap and physmap_of

It seems to compile just fine here. Is there a problem at runtime?

#12 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

In reply to Ricardo Ribalda Delgado
Quoted 46 lines · On Fri, 5 Oct 2018 16:06:57 +0200 Ricardo Ribalda Delgado…

Hi again Boris

Quoted 41 lines · Boris Brezillon
Quoted 24 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

Quoted 7 lines
Quoted 1 line

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

Quoted 6 lines

If you send the patchset to the mailing list I can review it patch by patch.

Also
mtd: maps: Prepare merging of physmap and physmap_of

I do not think that can be bisected. (Not sure, I have to test it)

Okay, I'll have a look.

Quoted 3 lines

I add the diff to the mail, but gmail will probably scramble the lines(yes I know I have to use other mail client)

Quoted 6 lines
Quoted 1 line

The diff looks good, I'll fix that an send a push a new version.

Also fix on physmap_flash_remove

physmap_data->exit(dev); must be called BEFORE
map_destroy(info->mtds[i]);

Hm, that's weird. That shouldn't happen. Do you have a non-NULL ->exit()? Can you detail why you think ->exit() call is the cause of this OOPS?

Quoted 85 lines

otherwise OOPS

Cheers!

[  162.700421] Unable to handle kernel paging request at virtual
address 7974696e6966a6
[  162.705461] Mem abort info:
[  162.713171]   Exception class = DABT (current EL), IL = 32 bits
[  162.715678]   SET = 0, FnV = 0
[  162.721588]   EA = 0, S1PTW = 0
[  162.724703] Data abort info:
[  162.727767]   ISV = 0, ISS = 0x00000004
[  162.730879]   CM = 0, WnR = 0
[  162.734436] [007974696e6966a6] address between user and kernel address ranges
[  162.737567] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[  162.744674] Modules linked in: qtec_m43 qtec_mem qt5023_video

qtec_white qtec_cmosis arc4 snd_soc_hdmi_codec ath10k_pci ath10k_core venus_dec venus_enc ath mac80211 q6asm_dai cfi_cmdset_0002 q6routing q6afe_dai cfi_probe q6adm cfi_util q6asm gen_probe q6afe q6dsp_common q6core physmap gpio_xilinx qtec_pcie qtec_clk apr qrtr_smd rpmsg_char imx214 ad5820 v4l2_common joydev cfg80211 msm venus_core hci_uart qt5023 qcom_camss btqca v4l2_mem2mem drm_kms_helper videobuf2_dma_sg v4l2_fwnode videobuf2_memops videobuf2_v4l2 bluetooth drm videobuf2_core videodev ecdh_generic i2c_qcom_cci media rtc_pm8xxx leds_qcom_lpg qrtr crc32_ce qcom_adsp_pil crct10dif_ce qcom_common snd_soc_apq8096 qcom_glink_smem qcom_sysmon remoteproc qmi_helpers rmtfs_mem mdt_loader sch_fq_codel

[  162.795188] CPU: 2 PID: 1 Comm: systemd-shutdow Not tainted
4.14.53-qtec-linaro #34
[  162.817417] Hardware name: Qtechnology QT5506 (DT)
[  162.824793] task: ffff8000baac8000 task.stack: ffff000008058000
[  162.829671] PC is at cfi_amdstd_reset+0xb4/0x188 [cfi_cmdset_0002]
[  162.835474] LR is at cfi_amdstd_reset+0xb4/0x188 [cfi_cmdset_0002]
[  162.841721] pc : [<ffff00000107fe44>] lr : [<ffff00000107fe44>]
pstate: 40000145
[  162.847885] sp : ffff00000805bc80
[  162.855433] x29: ffff00000805bc80 x28: ffff8000baac8000
[  162.858648] x27: ffff000008b51000 x26: 000000000000008e
[  162.864030] x25: 0000000000000124 x24: 0000000000000014
[  162.869324] x23: 0000000000000000 x22: 0000000000000000
[  162.874619] x21: 5f7974696e696666 x20: ffff8000b3178a18
[  162.879915] x19: ffff8000b5215800 x18: 0000000000000000
[  162.885209] x17: 0000ffffa46d1768 x16: ffff0000080f9960
[  162.890504] x15: 0000000000000010 x14: ffffffffffffffff
[  162.895800] x13: ffff0000896355e7 x12: ffff0000096355ef
[  162.901094] x11: ffff00000944a000 x10: ffff00000805b9b0
[  162.906389] x9 : 0000000000000039 x8 : 000000000000000d
[  162.911686] x7 : ffff00000805ba2c x6 : 0000000000000491
[  162.916980] x5 : 0000000000000000 x4 : 0000000000000000
[  162.922275] x3 : ffffffffffffffff x2 : ffff00000944a278
[  162.927570] x1 : ffff8000baac8000 x0 : 0000000000000028
[  162.932867] Process systemd-shutdow (pid: 1, stack limit =
0xffff000008058000)
[  162.938164] Call trace:
[  162.945191] Exception stack(0xffff00000805bb40 to 0xffff00000805bc80)
[  162.947538] bb40: 0000000000000028 ffff8000baac8000
ffff00000944a278 ffffffffffffffff
[  162.954136] bb60: 0000000000000000 0000000000000000
0000000000000491 ffff00000805ba2c
[  162.961949] bb80: 000000000000000d 0000000000000039
ffff00000805b9b0 ffff00000944a000
[  162.969762] bba0: ffff0000096355ef ffff0000896355e7
ffffffffffffffff 0000000000000010
[  162.977574] bbc0: ffff0000080f9960 0000ffffa46d1768
0000000000000000 ffff8000b5215800
[  162.985386] bbe0: ffff8000b3178a18 5f7974696e696666
0000000000000000 0000000000000000
[  162.993200] bc00: 0000000000000014 0000000000000124
000000000000008e ffff000008b51000
[  163.001011] bc20: ffff8000baac8000 ffff00000805bc80
ffff00000107fe44 ffff00000805bc80
[  163.008823] bc40: ffff00000107fe44 0000000040000145
0000000000000b5b ffffffffffffffff
[  163.016637] bc60: 0000ffffffffffff 0000000000000000
ffff00000805bc80 ffff00000107fe44
[  163.024454] [<ffff00000107fe44>] cfi_amdstd_reset+0xb4/0x188
[cfi_cmdset_0002]
[  163.032264] [<ffff00000107ff78>] cfi_amdstd_reboot+0x10/0x98
[cfi_cmdset_0002]
[  163.039386] [<ffff0000080f7d0c>] notifier_call_chain+0x54/0x90
[  163.046583] [<ffff0000080f85d4>] blocking_notifier_call_chain+0x54/0x78
[  163.052399] [<ffff0000080f96ac>] kernel_restart_prepare+0x1c/0x40
[  163.058910] [<ffff0000080f97a4>] kernel_restart+0x14/0x60
[  163.065158] [<ffff0000080f9b68>] SyS_reboot+0x208/0x230
#21 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

In reply to Ricardo Ribalda Delgado
Quoted 16 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 13 lines · Boris Brezillon
Quoted 8 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

I am about to test it in real hw (unless you want me wait)

Quoted 7 lines
Quoted 5 lines

Sure, go ahead and test it.

Thanks,

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

I pushed a new version to my branch. Can you test it? The reboot notifier bug should still be present, but I don't think this is something we introduced.

#20 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

In reply to Boris Brezillon

Hi Boris

Quoted 28 lines · Boris Brezillon
Quoted 24 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

Quoted 7 lines
Quoted 1 line

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

Quoted 6 lines
Quoted 4 lines

If you send the patchset to the mailing list I can review it patch by patch.

Also
mtd: maps: Prepare merging of physmap and physmap_of

It seems to compile just fine here. Is there a problem at runtime?

Sorry, my fault, that is just me trying to review in github. I saw the cahnge on the Makefile but not the rename. Ignore this comment

Signature · 1 line
Ricardo Ribalda
#13 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

In reply to Boris Brezillon

Hi Boris

Quoted 52 lines · Boris Brezillon
Quoted 48 lines · On Fri, 5 Oct 2018 16:06:57 +0200 Ricardo Ribalda Delgado…

Hi again Boris

Quoted 42 lines · Boris Brezillon
Quoted 24 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

Quoted 7 lines
Quoted 1 line

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

Quoted 6 lines

If you send the patchset to the mailing list I can review it patch by patch.

Also
mtd: maps: Prepare merging of physmap and physmap_of

I do not think that can be bisected. (Not sure, I have to test it)

Okay, I'll have a look.

Quoted 3 lines

I add the diff to the mail, but gmail will probably scramble the lines(yes I know I have to use other mail client)

The diff looks good, I'll fix that an send a push a new version.

Quoted 9 lines
Quoted 4 lines

Also fix on physmap_flash_remove

physmap_data->exit(dev); must be called BEFORE
map_destroy(info->mtds[i]);

Hm, that's weird. That shouldn't happen. Do you have a non-NULL ->exit()? Can you detail why you think ->exit() call is the cause of this OOPS?

No idea. It was crashing at:
https://github.com/bbrezillon/linux-0day/blob/mtd/physmap-cleanup/drivers/mtd/chips/cfi_cmdset_0002.c#L2839
cfi_cmdset_0002.c seesm to play with cfi->chips on its reset callback

I added some printfs:

if (!cfi),
if (!chip)
if (!cfi->chips)

sometimes it crashed on one place, sometimes in another :S. Reading back our patch it seemed more logical (semantically :P) to destroy after exit and not the other way around.

I made that change and it stopped OOPsing at reboot.

Havent had the time to dig deeper. But if it does not break anything on your side to invert destroy and exit please do so. It was not oopsing with my patchset.

Cheers

Quoted 85 lines
Quoted 85 lines

otherwise OOPS

Cheers!

[  162.700421] Unable to handle kernel paging request at virtual
address 7974696e6966a6
[  162.705461] Mem abort info:
[  162.713171]   Exception class = DABT (current EL), IL = 32 bits
[  162.715678]   SET = 0, FnV = 0
[  162.721588]   EA = 0, S1PTW = 0
[  162.724703] Data abort info:
[  162.727767]   ISV = 0, ISS = 0x00000004
[  162.730879]   CM = 0, WnR = 0
[  162.734436] [007974696e6966a6] address between user and kernel address ranges
[  162.737567] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[  162.744674] Modules linked in: qtec_m43 qtec_mem qt5023_video

qtec_white qtec_cmosis arc4 snd_soc_hdmi_codec ath10k_pci ath10k_core venus_dec venus_enc ath mac80211 q6asm_dai cfi_cmdset_0002 q6routing q6afe_dai cfi_probe q6adm cfi_util q6asm gen_probe q6afe q6dsp_common q6core physmap gpio_xilinx qtec_pcie qtec_clk apr qrtr_smd rpmsg_char imx214 ad5820 v4l2_common joydev cfg80211 msm venus_core hci_uart qt5023 qcom_camss btqca v4l2_mem2mem drm_kms_helper videobuf2_dma_sg v4l2_fwnode videobuf2_memops videobuf2_v4l2 bluetooth drm videobuf2_core videodev ecdh_generic i2c_qcom_cci media rtc_pm8xxx leds_qcom_lpg qrtr crc32_ce qcom_adsp_pil crct10dif_ce qcom_common snd_soc_apq8096 qcom_glink_smem qcom_sysmon remoteproc qmi_helpers rmtfs_mem mdt_loader sch_fq_codel

[  162.795188] CPU: 2 PID: 1 Comm: systemd-shutdow Not tainted
4.14.53-qtec-linaro #34
[  162.817417] Hardware name: Qtechnology QT5506 (DT)
[  162.824793] task: ffff8000baac8000 task.stack: ffff000008058000
[  162.829671] PC is at cfi_amdstd_reset+0xb4/0x188 [cfi_cmdset_0002]
[  162.835474] LR is at cfi_amdstd_reset+0xb4/0x188 [cfi_cmdset_0002]
[  162.841721] pc : [<ffff00000107fe44>] lr : [<ffff00000107fe44>]
pstate: 40000145
[  162.847885] sp : ffff00000805bc80
[  162.855433] x29: ffff00000805bc80 x28: ffff8000baac8000
[  162.858648] x27: ffff000008b51000 x26: 000000000000008e
[  162.864030] x25: 0000000000000124 x24: 0000000000000014
[  162.869324] x23: 0000000000000000 x22: 0000000000000000
[  162.874619] x21: 5f7974696e696666 x20: ffff8000b3178a18
[  162.879915] x19: ffff8000b5215800 x18: 0000000000000000
[  162.885209] x17: 0000ffffa46d1768 x16: ffff0000080f9960
[  162.890504] x15: 0000000000000010 x14: ffffffffffffffff
[  162.895800] x13: ffff0000896355e7 x12: ffff0000096355ef
[  162.901094] x11: ffff00000944a000 x10: ffff00000805b9b0
[  162.906389] x9 : 0000000000000039 x8 : 000000000000000d
[  162.911686] x7 : ffff00000805ba2c x6 : 0000000000000491
[  162.916980] x5 : 0000000000000000 x4 : 0000000000000000
[  162.922275] x3 : ffffffffffffffff x2 : ffff00000944a278
[  162.927570] x1 : ffff8000baac8000 x0 : 0000000000000028
[  162.932867] Process systemd-shutdow (pid: 1, stack limit =
0xffff000008058000)
[  162.938164] Call trace:
[  162.945191] Exception stack(0xffff00000805bb40 to 0xffff00000805bc80)
[  162.947538] bb40: 0000000000000028 ffff8000baac8000
ffff00000944a278 ffffffffffffffff
[  162.954136] bb60: 0000000000000000 0000000000000000
0000000000000491 ffff00000805ba2c
[  162.961949] bb80: 000000000000000d 0000000000000039
ffff00000805b9b0 ffff00000944a000
[  162.969762] bba0: ffff0000096355ef ffff0000896355e7
ffffffffffffffff 0000000000000010
[  162.977574] bbc0: ffff0000080f9960 0000ffffa46d1768
0000000000000000 ffff8000b5215800
[  162.985386] bbe0: ffff8000b3178a18 5f7974696e696666
0000000000000000 0000000000000000
[  162.993200] bc00: 0000000000000014 0000000000000124
000000000000008e ffff000008b51000
[  163.001011] bc20: ffff8000baac8000 ffff00000805bc80
ffff00000107fe44 ffff00000805bc80
[  163.008823] bc40: ffff00000107fe44 0000000040000145
0000000000000b5b ffffffffffffffff
[  163.016637] bc60: 0000ffffffffffff 0000000000000000
ffff00000805bc80 ffff00000107fe44
[  163.024454] [<ffff00000107fe44>] cfi_amdstd_reset+0xb4/0x188
[cfi_cmdset_0002]
[  163.032264] [<ffff00000107ff78>] cfi_amdstd_reboot+0x10/0x98
[cfi_cmdset_0002]
[  163.039386] [<ffff0000080f7d0c>] notifier_call_chain+0x54/0x90
[  163.046583] [<ffff0000080f85d4>] blocking_notifier_call_chain+0x54/0x78
[  163.052399] [<ffff0000080f96ac>] kernel_restart_prepare+0x1c/0x40
[  163.058910] [<ffff0000080f97a4>] kernel_restart+0x14/0x60
[  163.065158] [<ffff0000080f9b68>] SyS_reboot+0x208/0x230
Signature · 1 line
Ricardo Ribalda
#22 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

In reply to Boris Brezillon

HI again!

Quoted 24 lines · Boris Brezillon
Quoted 20 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 17 lines · Boris Brezillon
Quoted 8 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

I pushed a new version to my branch. Can you test it? The reboot notifier bug should still be present, but I don't think this is something we introduced.

I will do it next week, I already left the office and this weekend I have a big 2 year old bday party .

Have a very nice weekend and thanks for your help!

Signature · 1 line
Ricardo Ribalda
#14 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

In reply to Ricardo Ribalda Delgado
Quoted 71 lines · On Fri, 5 Oct 2018 17:40:44 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 52 lines · Boris Brezillon
Quoted 48 lines · On Fri, 5 Oct 2018 16:06:57 +0200 Ricardo Ribalda Delgado…

Hi again Boris

Quoted 42 lines · Boris Brezillon
Quoted 24 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

Quoted 7 lines
Quoted 1 line

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

Quoted 6 lines

If you send the patchset to the mailing list I can review it patch by patch.

Also
mtd: maps: Prepare merging of physmap and physmap_of

I do not think that can be bisected. (Not sure, I have to test it)

Okay, I'll have a look.

Quoted 3 lines

I add the diff to the mail, but gmail will probably scramble the lines(yes I know I have to use other mail client)

The diff looks good, I'll fix that an send a push a new version.

Quoted 9 lines
Quoted 4 lines

Also fix on physmap_flash_remove

physmap_data->exit(dev); must be called BEFORE
map_destroy(info->mtds[i]);

Hm, that's weird. That shouldn't happen. Do you have a non-NULL ->exit()? Can you detail why you think ->exit() call is the cause of this OOPS?

No idea. It was crashing at:
https://github.com/bbrezillon/linux-0day/blob/mtd/physmap-cleanup/drivers/mtd/chips/cfi_cmdset_0002.c#L2839
cfi_cmdset_0002.c seesm to play with cfi->chips on its reset callback

I added some printfs:

Quoted 7 lines

if (!cfi),
if (!chip)
if (!cfi->chips)

sometimes it crashed on one place, sometimes in another :S. Reading back our patch it seemed more logical (semantically :P) to destroy after exit and not the other way around.

Actually no, it makes more sense to call ->exit() after destroying the maps, because the platform-specific ->exit() implem might release resources that are used during the destroy_map() operation. Another reason to keep it in this order is that operations in the remove path should be in the reverse order of those done in the probe path, and ->init() is definitely called before map_probe().

Quoted 2 lines

I made that change and it stopped OOPsing at reboot.

Maybe it's just a side effect, especially since I'm pretty sure your physmap_data->exit() is NULL (assuming you do use DT to declare your flash).

Quoted 4 lines

Havent had the time to dig deeper. But if it does not break anything on your side to invert destroy and exit please do so. It was not oopsing with my patchset.

I'd like to understand what's happening before doing this change. As I said, I fear this reordering just hides something else.

#15 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Hi Boris

Quoted 83 lines · Boris Brezillon
Quoted 71 lines · On Fri, 5 Oct 2018 17:40:44 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 52 lines · Boris Brezillon
Quoted 48 lines · On Fri, 5 Oct 2018 16:06:57 +0200 Ricardo Ribalda Delgado…

Hi again Boris

Quoted 42 lines · Boris Brezillon
Quoted 24 lines · On Fri, 5 Oct 2018 14:04:52 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Fri, 5 Oct 2018 11:54:18 +0200 Ricardo Ribalda Delgado…

Hi Boris

Just seen that you already did the rebase at
https://github.com/bbrezillon/linux-0day/commits/mtd/physmap-cleanup

Thanks for that.

Quoted 7 lines
Quoted 1 line

I am about to test it in real hw (unless you want me wait)

Sure, go ahead and test it.

Thanks,

Boris

I had to change this on your patchset to have it working on hw:
https://pastebin.com/78A7yhJ9

Quoted 6 lines

If you send the patchset to the mailing list I can review it patch by patch.

Also
mtd: maps: Prepare merging of physmap and physmap_of

I do not think that can be bisected. (Not sure, I have to test it)

Okay, I'll have a look.

Quoted 3 lines

I add the diff to the mail, but gmail will probably scramble the lines(yes I know I have to use other mail client)

The diff looks good, I'll fix that an send a push a new version.

Quoted 9 lines
Quoted 4 lines

Also fix on physmap_flash_remove

physmap_data->exit(dev); must be called BEFORE
map_destroy(info->mtds[i]);

Hm, that's weird. That shouldn't happen. Do you have a non-NULL ->exit()? Can you detail why you think ->exit() call is the cause of this OOPS?

No idea. It was crashing at:
https://github.com/bbrezillon/linux-0day/blob/mtd/physmap-cleanup/drivers/mtd/chips/cfi_cmdset_0002.c#L2839
cfi_cmdset_0002.c seesm to play with cfi->chips on its reset callback

I added some printfs:

Quoted 7 lines

if (!cfi),
if (!chip)
if (!cfi->chips)

sometimes it crashed on one place, sometimes in another :S. Reading back our patch it seemed more logical (semantically :P) to destroy after exit and not the other way around.

Quoted 7 lines

Actually no, it makes more sense to call ->exit() after destroying the maps, because the platform-specific ->exit() implem might release resources that are used during the destroy_map() operation. Another reason to keep it in this order is that operations in the remove path should be in the reverse order of those done in the probe path, and ->init() is definitely called before map_probe().

I think I know what might be the issue. on cfi_cmdset_002.c cfi_amdstd_reset can be called in parrallel to cfi_amdstd_destroy.

maybe we should call unregister_reboot_notifier(&mtd->reboot_notifier); before
cfi_amdstd_reset(mtd)

need to try that on real hw with some strategical printfs :P. But that will ahve to wait til Monday

Cheers

Quoted 14 lines
Quoted 2 lines

I made that change and it stopped OOPsing at reboot.

Maybe it's just a side effect, especially since I'm pretty sure your physmap_data->exit() is NULL (assuming you do use DT to declare your flash).

Quoted 4 lines

Havent had the time to dig deeper. But if it does not break anything on your side to invert destroy and exit please do so. It was not oopsing with my patchset.

I'd like to understand what's happening before doing this change. As I said, I fear this reordering just hides something else.

Signature · 1 line
Ricardo Ribalda
#16 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Quoted 11 lines · On Fri, 5 Oct 2018 20:12:43 +0200 Ricardo Ribalda Delgado…

I think I know what might be the issue. on cfi_cmdset_002.c cfi_amdstd_reset can be called in parrallel to cfi_amdstd_destroy.

maybe we should call unregister_reboot_notifier(&mtd->reboot_notifier); before
cfi_amdstd_reset(mtd)

need to try that on real hw with some strategical printfs :P. But that will ahve to wait til Monday

No problem, nothing urgent here. Have a nice weekend.

#17 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Hi Boris

Quoted 13 lines · Boris Brezillon
Quoted 9 lines · On Fri, 5 Oct 2018 20:12:43 +0200 Ricardo Ribalda Delgado…

I think I know what might be the issue. on cfi_cmdset_002.c cfi_amdstd_reset can be called in parrallel to cfi_amdstd_destroy.

maybe we should call unregister_reboot_notifier(&mtd->reboot_notifier); before
cfi_amdstd_reset(mtd)

Quoted 4 lines
Quoted 2 lines

need to try that on real hw with some strategical printfs :P. But that will ahve to wait til Monday

No problem, nothing urgent here. Have a nice weekend.

Just updated my kernel version (4.14.53 -> 4.14.69) with you last github and I do not see the crash anymore. So I guess we are good to go.

Thanks!

Signature · 1 line
Ricardo Ribalda
#18 lore raw

Re: [PATCH v10 10/10] mtd: maps: gpio-addr-flash: Add support for device-tree devices

Quoted 16 lines · On Mon, 8 Oct 2018 09:40:09 +0200 Ricardo Ribalda Delgado…

Hi Boris

Quoted 13 lines · Boris Brezillon
Quoted 9 lines · On Fri, 5 Oct 2018 20:12:43 +0200 Ricardo Ribalda Delgado…

I think I know what might be the issue. on cfi_cmdset_002.c cfi_amdstd_reset can be called in parrallel to cfi_amdstd_destroy.

maybe we should call unregister_reboot_notifier(&mtd->reboot_notifier); before
cfi_amdstd_reset(mtd)

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

need to try that on real hw with some strategical printfs :P. But that will ahve to wait til Monday

No problem, nothing urgent here. Have a nice weekend.

Just updated my kernel version (4.14.53 -> 4.14.69) with you last github and I do not see the crash anymore. So I guess we are good to go.

Okay, I'll try to send the patch series. Don't hesitate to ping me if I forget.

Thanks,

Boris