Skip to contentSkip to conversation

devres: keep both device name and resource name in pretty name

PATCH Superseded Vladimir Oltean 4 participants 7 messages May 31, 2020 – Jun 1, 2020 1 message not in the archive

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 devres: keep both device name and resource name in pretty name

From: Vladimir Oltean <[email protected]>

Sometimes debugging a device is easiest using devmem on its register map, and that can be seen with /proc/iomem. But some device drivers have many memory regions. Take for example a networking switch. Its memory map used to look like this in /proc/iomem:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : sys
    1fc030000-1fc03ffff : rew
    1fc060000-1fc0603ff : s2
    1fc070000-1fc0701ff : devcpu_gcb
    1fc080000-1fc0800ff : qs
    1fc090000-1fc0900cb : ptp
    1fc100000-1fc10ffff : port0
    1fc110000-1fc11ffff : port1
    1fc120000-1fc12ffff : port2
    1fc130000-1fc13ffff : port3
    1fc140000-1fc14ffff : port4
    1fc150000-1fc15ffff : port5
    1fc200000-1fc21ffff : qsys
    1fc280000-1fc28ffff : ana

But after the patch in Fixes: was applied, the information is now presented in a much more opaque way:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : 0000:00:00.5
    1fc030000-1fc03ffff : 0000:00:00.5
    1fc060000-1fc0603ff : 0000:00:00.5
    1fc070000-1fc0701ff : 0000:00:00.5
    1fc080000-1fc0800ff : 0000:00:00.5
    1fc090000-1fc0900cb : 0000:00:00.5
    1fc100000-1fc10ffff : 0000:00:00.5
    1fc110000-1fc11ffff : 0000:00:00.5
    1fc120000-1fc12ffff : 0000:00:00.5
    1fc130000-1fc13ffff : 0000:00:00.5
    1fc140000-1fc14ffff : 0000:00:00.5
    1fc150000-1fc15ffff : 0000:00:00.5
    1fc200000-1fc21ffff : 0000:00:00.5
    1fc280000-1fc28ffff : 0000:00:00.5

That patch made a fair comment that /proc/iomem might be confusing when it shows resources without an associated device, but we can do better than just hide the resource name altogether. Namely, we can print the device name _and_ the resource name. Like this:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : 0000:00:00.5 sys
    1fc030000-1fc03ffff : 0000:00:00.5 rew
    1fc060000-1fc0603ff : 0000:00:00.5 s2
    1fc070000-1fc0701ff : 0000:00:00.5 devcpu_gcb
    1fc080000-1fc0800ff : 0000:00:00.5 qs
    1fc090000-1fc0900cb : 0000:00:00.5 ptp
    1fc100000-1fc10ffff : 0000:00:00.5 port0
    1fc110000-1fc11ffff : 0000:00:00.5 port1
    1fc120000-1fc12ffff : 0000:00:00.5 port2
    1fc130000-1fc13ffff : 0000:00:00.5 port3
    1fc140000-1fc14ffff : 0000:00:00.5 port4
    1fc150000-1fc15ffff : 0000:00:00.5 port5
    1fc200000-1fc21ffff : 0000:00:00.5 qsys
    1fc280000-1fc28ffff : 0000:00:00.5 ana
Fixes 8d84b18f5678 ("devres: always use dev_name() in devm_ioremap_resource()")
---
 lib/devres.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
lib/devres.c +16 -1
index 6ef51f159c54..3d67588c15a7 100644
@@ -119,6 +119,7 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res,
 {
 	resource_size_t size;
 	void __iomem *dest_ptr;
+	char *pretty_name;
 
 	BUG_ON(!dev);
 
@@ -129,7 +130,21 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res,
 
 	size = resource_size(res);
 
-	if (!devm_request_mem_region(dev, res->start, size, dev_name(dev))) {
+	if (res->name) {
+		int len = strlen(dev_name(dev)) + strlen(res->name) + 2;
+
+		pretty_name = devm_kzalloc(dev, len, GFP_KERNEL);
+		if (!pretty_name)
+			return IOMEM_ERR_PTR(-ENOMEM);
+
+		sprintf(pretty_name, "%s %s", dev_name(dev), res->name);
+	} else {
+		pretty_name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL);
+		if (!pretty_name)
+			return IOMEM_ERR_PTR(-ENOMEM);
+	}
+
+	if (!devm_request_mem_region(dev, res->start, size, pretty_name)) {
 		dev_err(dev, "can't request region for resource %pR\n", res);
 		return IOMEM_ERR_PTR(-EBUSY);
 	}
Signature · 1 line
2.25.1

A message that is not in the archive (sent off-list or not yet received): CAHp75Vc5NrDUZwv7uW+P=Ly+tz3a9XgEukX6ZgSccj_1sMYQaw@mail.gmail.com

#2 lore raw
Quoted 72 lines · Andy Shevchenko
Quoted 52 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

Sometimes debugging a device is easiest using devmem on its register map, and that can be seen with /proc/iomem. But some device drivers have many memory regions. Take for example a networking switch. Its memory map used to look like this in /proc/iomem:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : sys
    1fc030000-1fc03ffff : rew
    1fc060000-1fc0603ff : s2
    1fc070000-1fc0701ff : devcpu_gcb
    1fc080000-1fc0800ff : qs
    1fc090000-1fc0900cb : ptp
    1fc100000-1fc10ffff : port0
    1fc110000-1fc11ffff : port1
    1fc120000-1fc12ffff : port2
    1fc130000-1fc13ffff : port3
    1fc140000-1fc14ffff : port4
    1fc150000-1fc15ffff : port5
    1fc200000-1fc21ffff : qsys
    1fc280000-1fc28ffff : ana

But after the patch in Fixes: was applied, the information is now presented in a much more opaque way:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : 0000:00:00.5
    1fc030000-1fc03ffff : 0000:00:00.5
    1fc060000-1fc0603ff : 0000:00:00.5
    1fc070000-1fc0701ff : 0000:00:00.5
    1fc080000-1fc0800ff : 0000:00:00.5
    1fc090000-1fc0900cb : 0000:00:00.5
    1fc100000-1fc10ffff : 0000:00:00.5
    1fc110000-1fc11ffff : 0000:00:00.5
    1fc120000-1fc12ffff : 0000:00:00.5
    1fc130000-1fc13ffff : 0000:00:00.5
    1fc140000-1fc14ffff : 0000:00:00.5
    1fc150000-1fc15ffff : 0000:00:00.5
    1fc200000-1fc21ffff : 0000:00:00.5
    1fc280000-1fc28ffff : 0000:00:00.5

That patch made a fair comment that /proc/iomem might be confusing when it shows resources without an associated device, but we can do better than just hide the resource name altogether. Namely, we can print the device name _and_ the resource name. Like this:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

Quoted 15 lines
    1fc010000-1fc01ffff : 0000:00:00.5 sys
    1fc030000-1fc03ffff : 0000:00:00.5 rew
    1fc060000-1fc0603ff : 0000:00:00.5 s2
    1fc070000-1fc0701ff : 0000:00:00.5 devcpu_gcb
    1fc080000-1fc0800ff : 0000:00:00.5 qs
    1fc090000-1fc0900cb : 0000:00:00.5 ptp
    1fc100000-1fc10ffff : 0000:00:00.5 port0
    1fc110000-1fc11ffff : 0000:00:00.5 port1
    1fc120000-1fc12ffff : 0000:00:00.5 port2
    1fc130000-1fc13ffff : 0000:00:00.5 port3
    1fc140000-1fc14ffff : 0000:00:00.5 port4
    1fc150000-1fc15ffff : 0000:00:00.5 port5
    1fc200000-1fc21ffff : 0000:00:00.5 qsys
    1fc280000-1fc28ffff : 0000:00:00.5 ana
Quoted 3 lines

All of this seems an ABI change.
But also see below.

Yes, indeed. What should I understand from your comment though?

Quoted 23 lines
Quoted 23 lines
Fixes 8d84b18f5678 ("devres: always use dev_name() in devm_ioremap_resource()")
---
 lib/devres.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
lib/devres.c +1 -0
index 6ef51f159c54..3d67588c15a7 100644
@@ -119,6 +119,7 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res,
 {
        resource_size_t size;
        void __iomem *dest_ptr;
+       char *pretty_name;
 
        BUG_ON(!dev);
 
@@ -129,7 +130,21 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res,
 
        size = resource_size(res);
 
Quoted 13 lines

lib/devres.c __devm_ioremap_resource(struct device *dev, const struct resource *res, · line 140

Quoted 9 lines
lib/devres.c +8 -1
-       if (!devm_request_mem_region(dev, res->start, size, dev_name(dev))) {
+       if (res->name) {
+               int len = strlen(dev_name(dev)) + strlen(res->name) + 2;
+
+               pretty_name = devm_kzalloc(dev, len, GFP_KERNEL);
+               if (!pretty_name)
+                       return IOMEM_ERR_PTR(-ENOMEM);
+
+               sprintf(pretty_name, "%s %s", dev_name(dev), res->name);

Reimplementing devm_kasprintf(), why?

Mostly because I didn't remember how it was called, thanks for pointing it out.

Quoted 16 lines
Quoted 12 lines
lib/devres.c +7 -1
+       } else {
+               pretty_name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL);
+               if (!pretty_name)
+                       return IOMEM_ERR_PTR(-ENOMEM);
+       }
+
+       if (!devm_request_mem_region(dev, res->start, size, pretty_name)) {
                dev_err(dev, "can't request region for resource %pR\n", res);
                return IOMEM_ERR_PTR(-EBUSY);
        }
--
Quoted 2 lines

2.25.1

Quoted 5 lines

--
With Best Regards,
Andy Shevchenko

Thanks,
-Vladimir

#3 lore raw
Quoted 67 lines · Vladimir Oltean
Quoted 65 lines · Andy Shevchenko
Quoted 63 lines · Vladimir Oltean

Sometimes debugging a device is easiest using devmem on its register map, and that can be seen with /proc/iomem. But some device drivers have many memory regions. Take for example a networking switch. Its memory map used to look like this in /proc/iomem:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : sys
    1fc030000-1fc03ffff : rew
    1fc060000-1fc0603ff : s2
    1fc070000-1fc0701ff : devcpu_gcb
    1fc080000-1fc0800ff : qs
    1fc090000-1fc0900cb : ptp
    1fc100000-1fc10ffff : port0
    1fc110000-1fc11ffff : port1
    1fc120000-1fc12ffff : port2
    1fc130000-1fc13ffff : port3
    1fc140000-1fc14ffff : port4
    1fc150000-1fc15ffff : port5
    1fc200000-1fc21ffff : qsys
    1fc280000-1fc28ffff : ana

But after the patch in Fixes: was applied, the information is now presented in a much more opaque way:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : 0000:00:00.5
    1fc030000-1fc03ffff : 0000:00:00.5
    1fc060000-1fc0603ff : 0000:00:00.5
    1fc070000-1fc0701ff : 0000:00:00.5
    1fc080000-1fc0800ff : 0000:00:00.5
    1fc090000-1fc0900cb : 0000:00:00.5
    1fc100000-1fc10ffff : 0000:00:00.5
    1fc110000-1fc11ffff : 0000:00:00.5
    1fc120000-1fc12ffff : 0000:00:00.5
    1fc130000-1fc13ffff : 0000:00:00.5
    1fc140000-1fc14ffff : 0000:00:00.5
    1fc150000-1fc15ffff : 0000:00:00.5
    1fc200000-1fc21ffff : 0000:00:00.5
    1fc280000-1fc28ffff : 0000:00:00.5

That patch made a fair comment that /proc/iomem might be confusing when it shows resources without an associated device, but we can do better than just hide the resource name altogether. Namely, we can print the device name _and_ the resource name. Like this:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : 0000:00:00.5 sys
    1fc030000-1fc03ffff : 0000:00:00.5 rew
    1fc060000-1fc0603ff : 0000:00:00.5 s2
    1fc070000-1fc0701ff : 0000:00:00.5 devcpu_gcb
    1fc080000-1fc0800ff : 0000:00:00.5 qs
    1fc090000-1fc0900cb : 0000:00:00.5 ptp
    1fc100000-1fc10ffff : 0000:00:00.5 port0
    1fc110000-1fc11ffff : 0000:00:00.5 port1
    1fc120000-1fc12ffff : 0000:00:00.5 port2
    1fc130000-1fc13ffff : 0000:00:00.5 port3
    1fc140000-1fc14ffff : 0000:00:00.5 port4
    1fc150000-1fc15ffff : 0000:00:00.5 port5
    1fc200000-1fc21ffff : 0000:00:00.5 qsys
    1fc280000-1fc28ffff : 0000:00:00.5 ana
Quoted 3 lines
Quoted 1 line

All of this seems an ABI change.

Yes, indeed. What should I understand from your comment though?

You effectively break an ABI.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 71 lines · Andy Shevchenko
Quoted 68 lines · Vladimir Oltean
Quoted 67 lines · Andy Shevchenko
Quoted 49 lines · Vladimir Oltean

Sometimes debugging a device is easiest using devmem on its register map, and that can be seen with /proc/iomem. But some device drivers have many memory regions. Take for example a networking switch. Its memory map used to look like this in /proc/iomem:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : sys
    1fc030000-1fc03ffff : rew
    1fc060000-1fc0603ff : s2
    1fc070000-1fc0701ff : devcpu_gcb
    1fc080000-1fc0800ff : qs
    1fc090000-1fc0900cb : ptp
    1fc100000-1fc10ffff : port0
    1fc110000-1fc11ffff : port1
    1fc120000-1fc12ffff : port2
    1fc130000-1fc13ffff : port3
    1fc140000-1fc14ffff : port4
    1fc150000-1fc15ffff : port5
    1fc200000-1fc21ffff : qsys
    1fc280000-1fc28ffff : ana

But after the patch in Fixes: was applied, the information is now presented in a much more opaque way:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

    1fc010000-1fc01ffff : 0000:00:00.5
    1fc030000-1fc03ffff : 0000:00:00.5
    1fc060000-1fc0603ff : 0000:00:00.5
    1fc070000-1fc0701ff : 0000:00:00.5
    1fc080000-1fc0800ff : 0000:00:00.5
    1fc090000-1fc0900cb : 0000:00:00.5
    1fc100000-1fc10ffff : 0000:00:00.5
    1fc110000-1fc11ffff : 0000:00:00.5
    1fc120000-1fc12ffff : 0000:00:00.5
    1fc130000-1fc13ffff : 0000:00:00.5
    1fc140000-1fc14ffff : 0000:00:00.5
    1fc150000-1fc15ffff : 0000:00:00.5
    1fc200000-1fc21ffff : 0000:00:00.5
    1fc280000-1fc28ffff : 0000:00:00.5

That patch made a fair comment that /proc/iomem might be confusing when it shows resources without an associated device, but we can do better than just hide the resource name altogether. Namely, we can print the device name _and_ the resource name. Like this:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

Quoted 14 lines
    1fc010000-1fc01ffff : 0000:00:00.5 sys
    1fc030000-1fc03ffff : 0000:00:00.5 rew
    1fc060000-1fc0603ff : 0000:00:00.5 s2
    1fc070000-1fc0701ff : 0000:00:00.5 devcpu_gcb
    1fc080000-1fc0800ff : 0000:00:00.5 qs
    1fc090000-1fc0900cb : 0000:00:00.5 ptp
    1fc100000-1fc10ffff : 0000:00:00.5 port0
    1fc110000-1fc11ffff : 0000:00:00.5 port1
    1fc120000-1fc12ffff : 0000:00:00.5 port2
    1fc130000-1fc13ffff : 0000:00:00.5 port3
    1fc140000-1fc14ffff : 0000:00:00.5 port4
    1fc150000-1fc15ffff : 0000:00:00.5 port5
    1fc200000-1fc21ffff : 0000:00:00.5 qsys
    1fc280000-1fc28ffff : 0000:00:00.5 ana

All of this seems an ABI change.

Quoted 7 lines
Quoted 1 line

Yes, indeed. What should I understand from your comment though?

You effectively break an ABI.

--
With Best Regards,
Andy Shevchenko

I've replied to Greg about this in the v3 patch.

Regards,
-Vladimir

#5 lore raw
In reply to Vladimir Oltean

Hello!

Quoted 66 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

Sometimes debugging a device is easiest using devmem on its register map, and that can be seen with /proc/iomem. But some device drivers have many memory regions. Take for example a networking switch. Its memory map used to look like this in /proc/iomem:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

     1fc010000-1fc01ffff : sys
     1fc030000-1fc03ffff : rew
     1fc060000-1fc0603ff : s2
     1fc070000-1fc0701ff : devcpu_gcb
     1fc080000-1fc0800ff : qs
     1fc090000-1fc0900cb : ptp
     1fc100000-1fc10ffff : port0
     1fc110000-1fc11ffff : port1
     1fc120000-1fc12ffff : port2
     1fc130000-1fc13ffff : port3
     1fc140000-1fc14ffff : port4
     1fc150000-1fc15ffff : port5
     1fc200000-1fc21ffff : qsys
     1fc280000-1fc28ffff : ana

But after the patch in Fixes: was applied, the information is now presented in a much more opaque way:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

     1fc010000-1fc01ffff : 0000:00:00.5
     1fc030000-1fc03ffff : 0000:00:00.5
     1fc060000-1fc0603ff : 0000:00:00.5
     1fc070000-1fc0701ff : 0000:00:00.5
     1fc080000-1fc0800ff : 0000:00:00.5
     1fc090000-1fc0900cb : 0000:00:00.5
     1fc100000-1fc10ffff : 0000:00:00.5
     1fc110000-1fc11ffff : 0000:00:00.5
     1fc120000-1fc12ffff : 0000:00:00.5
     1fc130000-1fc13ffff : 0000:00:00.5
     1fc140000-1fc14ffff : 0000:00:00.5
     1fc150000-1fc15ffff : 0000:00:00.5
     1fc200000-1fc21ffff : 0000:00:00.5
     1fc280000-1fc28ffff : 0000:00:00.5

That patch made a fair comment that /proc/iomem might be confusing when it shows resources without an associated device, but we can do better than just hide the resource name altogether. Namely, we can print the device name _and_ the resource name. Like this:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

     1fc010000-1fc01ffff : 0000:00:00.5 sys
     1fc030000-1fc03ffff : 0000:00:00.5 rew
     1fc060000-1fc0603ff : 0000:00:00.5 s2
     1fc070000-1fc0701ff : 0000:00:00.5 devcpu_gcb
     1fc080000-1fc0800ff : 0000:00:00.5 qs
     1fc090000-1fc0900cb : 0000:00:00.5 ptp
     1fc100000-1fc10ffff : 0000:00:00.5 port0
     1fc110000-1fc11ffff : 0000:00:00.5 port1
     1fc120000-1fc12ffff : 0000:00:00.5 port2
     1fc130000-1fc13ffff : 0000:00:00.5 port3
     1fc140000-1fc14ffff : 0000:00:00.5 port4
     1fc150000-1fc15ffff : 0000:00:00.5 port5
     1fc200000-1fc21ffff : 0000:00:00.5 qsys
     1fc280000-1fc28ffff : 0000:00:00.5 ana
Quoted 2 lines
Fixes 8d84b18f5678 ("devres: always use dev_name() in devm_ioremap_resource()")

[...]

You didn't write the version log -- what changed since v1?

MBR, Sergei

#6 lore raw

Hi Sergei,

Quoted 71 lines · Sergei Shtylyov

Hello!

Quoted 66 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

Sometimes debugging a device is easiest using devmem on its register map, and that can be seen with /proc/iomem. But some device drivers have many memory regions. Take for example a networking switch. Its memory map used to look like this in /proc/iomem:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

     1fc010000-1fc01ffff : sys
     1fc030000-1fc03ffff : rew
     1fc060000-1fc0603ff : s2
     1fc070000-1fc0701ff : devcpu_gcb
     1fc080000-1fc0800ff : qs
     1fc090000-1fc0900cb : ptp
     1fc100000-1fc10ffff : port0
     1fc110000-1fc11ffff : port1
     1fc120000-1fc12ffff : port2
     1fc130000-1fc13ffff : port3
     1fc140000-1fc14ffff : port4
     1fc150000-1fc15ffff : port5
     1fc200000-1fc21ffff : qsys
     1fc280000-1fc28ffff : ana

But after the patch in Fixes: was applied, the information is now presented in a much more opaque way:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

     1fc010000-1fc01ffff : 0000:00:00.5
     1fc030000-1fc03ffff : 0000:00:00.5
     1fc060000-1fc0603ff : 0000:00:00.5
     1fc070000-1fc0701ff : 0000:00:00.5
     1fc080000-1fc0800ff : 0000:00:00.5
     1fc090000-1fc0900cb : 0000:00:00.5
     1fc100000-1fc10ffff : 0000:00:00.5
     1fc110000-1fc11ffff : 0000:00:00.5
     1fc120000-1fc12ffff : 0000:00:00.5
     1fc130000-1fc13ffff : 0000:00:00.5
     1fc140000-1fc14ffff : 0000:00:00.5
     1fc150000-1fc15ffff : 0000:00:00.5
     1fc200000-1fc21ffff : 0000:00:00.5
     1fc280000-1fc28ffff : 0000:00:00.5

That patch made a fair comment that /proc/iomem might be confusing when it shows resources without an associated device, but we can do better than just hide the resource name altogether. Namely, we can print the device name _and_ the resource name. Like this:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

     1fc010000-1fc01ffff : 0000:00:00.5 sys
     1fc030000-1fc03ffff : 0000:00:00.5 rew
     1fc060000-1fc0603ff : 0000:00:00.5 s2
     1fc070000-1fc0701ff : 0000:00:00.5 devcpu_gcb
     1fc080000-1fc0800ff : 0000:00:00.5 qs
     1fc090000-1fc0900cb : 0000:00:00.5 ptp
     1fc100000-1fc10ffff : 0000:00:00.5 port0
     1fc110000-1fc11ffff : 0000:00:00.5 port1
     1fc120000-1fc12ffff : 0000:00:00.5 port2
     1fc130000-1fc13ffff : 0000:00:00.5 port3
     1fc140000-1fc14ffff : 0000:00:00.5 port4
     1fc150000-1fc15ffff : 0000:00:00.5 port5
     1fc200000-1fc21ffff : 0000:00:00.5 qsys
     1fc280000-1fc28ffff : 0000:00:00.5 ana
Quoted 7 lines
Quoted 2 lines
Fixes 8d84b18f5678 ("devres: always use dev_name() in devm_ioremap_resource()")

[...]

You didn't write the version log -- what changed since v1?

MBR, Sergei

The changes in v2 are that I'm checking for memory allocation errors.

Thanks,
-Vladimir

#7 lore raw
Quoted 77 lines · Vladimir Oltean

Hi Sergei,

Quoted 73 lines · Sergei Shtylyov

Hello!

Quoted 68 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

Sometimes debugging a device is easiest using devmem on its register map, and that can be seen with /proc/iomem. But some device drivers have many memory regions. Take for example a networking switch. Its memory map used to look like this in /proc/iomem:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

     1fc010000-1fc01ffff : sys
     1fc030000-1fc03ffff : rew
     1fc060000-1fc0603ff : s2
     1fc070000-1fc0701ff : devcpu_gcb
     1fc080000-1fc0800ff : qs
     1fc090000-1fc0900cb : ptp
     1fc100000-1fc10ffff : port0
     1fc110000-1fc11ffff : port1
     1fc120000-1fc12ffff : port2
     1fc130000-1fc13ffff : port3
     1fc140000-1fc14ffff : port4
     1fc150000-1fc15ffff : port5
     1fc200000-1fc21ffff : qsys
     1fc280000-1fc28ffff : ana

But after the patch in Fixes: was applied, the information is now presented in a much more opaque way:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

     1fc010000-1fc01ffff : 0000:00:00.5
     1fc030000-1fc03ffff : 0000:00:00.5
     1fc060000-1fc0603ff : 0000:00:00.5
     1fc070000-1fc0701ff : 0000:00:00.5
     1fc080000-1fc0800ff : 0000:00:00.5
     1fc090000-1fc0900cb : 0000:00:00.5
     1fc100000-1fc10ffff : 0000:00:00.5
     1fc110000-1fc11ffff : 0000:00:00.5
     1fc120000-1fc12ffff : 0000:00:00.5
     1fc130000-1fc13ffff : 0000:00:00.5
     1fc140000-1fc14ffff : 0000:00:00.5
     1fc150000-1fc15ffff : 0000:00:00.5
     1fc200000-1fc21ffff : 0000:00:00.5
     1fc280000-1fc28ffff : 0000:00:00.5

That patch made a fair comment that /proc/iomem might be confusing when it shows resources without an associated device, but we can do better than just hide the resource name altogether. Namely, we can print the device name _and_ the resource name. Like this:

1fc000000-1fc3fffff : pcie@1f0000000
1fc000000-1fc3fffff : 0000:00:00.5

     1fc010000-1fc01ffff : 0000:00:00.5 sys
     1fc030000-1fc03ffff : 0000:00:00.5 rew
     1fc060000-1fc0603ff : 0000:00:00.5 s2
     1fc070000-1fc0701ff : 0000:00:00.5 devcpu_gcb
     1fc080000-1fc0800ff : 0000:00:00.5 qs
     1fc090000-1fc0900cb : 0000:00:00.5 ptp
     1fc100000-1fc10ffff : 0000:00:00.5 port0
     1fc110000-1fc11ffff : 0000:00:00.5 port1
     1fc120000-1fc12ffff : 0000:00:00.5 port2
     1fc130000-1fc13ffff : 0000:00:00.5 port3
     1fc140000-1fc14ffff : 0000:00:00.5 port4
     1fc150000-1fc15ffff : 0000:00:00.5 port5
     1fc200000-1fc21ffff : 0000:00:00.5 qsys
     1fc280000-1fc28ffff : 0000:00:00.5 ana
Fixes 8d84b18f5678 ("devres: always use dev_name() in devm_ioremap_resource()")
Quoted 7 lines
Quoted 5 lines

[...]

You didn't write the version log -- what changed since v1?

MBR, Sergei

The changes in v2 are that I'm checking for memory allocation errors.

You always need to mention that below the --- line, as the documentation says to.

Please send a v3 with that fixed up.

thanks,

greg k-h