Skip to contentSkip to conversation

platform: Print the resource range if device failed to claim

PATCH In review Chen Yu 3 participants 4 messages Dec 21, 2016 – Dec 22, 2016

Subsystems (2)
lore
Share & tools
lore

Chen Yu

author
#0 lore raw

PATCH 1/1 platform: Print the resource range if device failed to claim

Sometimes we have the following error message:
platform MSFT0101:00: failed to claim resource 1
acpi MSFT0101:00: platform device creation failed: -16
But there is not enough information to figure out which resource range failed to claim.

Thus print the resource range at first-place thus /proc/iomem or ioports should tell us who already claimed this resource, then the driver bug or incorrect resource assignment which is running into this conflict can be diagnosed:
platform MSFT0101:00: failed to claim resource 1: [mem 0xfed40000-0xfed40fff] acpi MSFT0101:00: platform device creation failed: -16

---
 drivers/base/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +1 -1
index c4af003..22a6430 100644
@@ -396,7 +396,7 @@ int platform_device_add(struct platform_device *pdev)
 		}
 
 		if (p && insert_resource(p, r)) {
-			dev_err(&pdev->dev, "failed to claim resource %d\n", i);
+			dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r);
 			ret = -EBUSY;
 			goto failed;
 		}
Signature · 1 line
2.7.4
#1 lore raw

[CC Mika and linux-acpi]

Quoted 25 lines · Chen Yu

Sometimes we have the following error message:
platform MSFT0101:00: failed to claim resource 1
acpi MSFT0101:00: platform device creation failed: -16
But there is not enough information to figure out which resource range failed to claim.

Thus print the resource range at first-place thus /proc/iomem or ioports should tell us who already claimed this resource, then the driver bug or incorrect resource assignment which is running into this conflict can be diagnosed:
platform MSFT0101:00: failed to claim resource 1: [mem 0xfed40000-0xfed40fff] acpi MSFT0101:00: platform device creation failed: -16

---
 drivers/base/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +0 -0
index c4af003..22a6430 100644

drivers/base/platform.c int platform_device_add(struct platform_device *pdev) · line 399

Quoted 5 lines
drivers/base/platform.c +1 -1
@@ -396,7 +396,7 @@ int platform_device_add(struct platform_device *pdev)
 		}
 
 		if (p && insert_resource(p, r)) {
-			dev_err(&pdev->dev, "failed to claim resource %d\n", i);
+			dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r);

Do we still need the resource number?

drivers/base/platform.c int platform_device_add(struct platform_device *pdev) · line 402

Quoted 4 lines
drivers/base/platform.c +0 -0
 			ret = -EBUSY;
 			goto failed;
 		}

Thanks,
Rafael

author
#2 lore raw

Hi,

Quoted 30 lines · Rafael J. Wysocki

[CC Mika and linux-acpi]

Quoted 27 lines · Chen Yu

Sometimes we have the following error message:
platform MSFT0101:00: failed to claim resource 1
acpi MSFT0101:00: platform device creation failed: -16
But there is not enough information to figure out which resource range failed to claim.

Thus print the resource range at first-place thus /proc/iomem or ioports should tell us who already claimed this resource, then the driver bug or incorrect resource assignment which is running into this conflict can be diagnosed:
platform MSFT0101:00: failed to claim resource 1: [mem 0xfed40000-0xfed40fff] acpi MSFT0101:00: platform device creation failed: -16

---
 drivers/base/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +0 -0
index c4af003..22a6430 100644
@@ -396,7 +396,7 @@ int platform_device_add(struct platform_device *pdev)
 		}
 
Quoted 6 lines

drivers/base/platform.c int platform_device_add(struct platform_device *pdev) · line 399

Quoted 3 lines
drivers/base/platform.c +1 -1
 		if (p && insert_resource(p, r)) {
-			dev_err(&pdev->dev, "failed to claim resource %d\n", i);
+			dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r);

Do we still need the resource number?

Seems we don't need the resource number anymore.
(As platform.c was written earlier than 2005, and the support of %pR was introduced later in 2008.)

Quoted 8 lines

drivers/base/platform.c int platform_device_add(struct platform_device *pdev) · line 402

Quoted 4 lines
drivers/base/platform.c +0 -0
 			ret = -EBUSY;
 			goto failed;
 		}

Thanks,
Rafael

Thanks,
Yu

Reviewed-by
#3 lore raw
In reply to Rafael J. Wysocki
Quoted 30 lines · Rafael J. Wysocki

[CC Mika and linux-acpi]

Quoted 27 lines · Chen Yu

Sometimes we have the following error message:
platform MSFT0101:00: failed to claim resource 1
acpi MSFT0101:00: platform device creation failed: -16
But there is not enough information to figure out which resource range failed to claim.

Thus print the resource range at first-place thus /proc/iomem or ioports should tell us who already claimed this resource, then the driver bug or incorrect resource assignment which is running into this conflict can be diagnosed:
platform MSFT0101:00: failed to claim resource 1: [mem 0xfed40000-0xfed40fff] acpi MSFT0101:00: platform device creation failed: -16

---
 drivers/base/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +0 -0
index c4af003..22a6430 100644
@@ -396,7 +396,7 @@ int platform_device_add(struct platform_device *pdev)
 		}
 
Quoted 5 lines

drivers/base/platform.c int platform_device_add(struct platform_device *pdev) · line 399

Quoted 3 lines
drivers/base/platform.c +1 -1
 		if (p && insert_resource(p, r)) {
-			dev_err(&pdev->dev, "failed to claim resource %d\n", i);
+			dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r);

Do we still need the resource number?

It may still be useful. For example some BIOSes fill MMIO resources based on variables in memory in which case the resource in DSDT is filled with zeroes when disassembled. With the number you can find out the right MMIO resource.

Either way, this is a good change. I had it on my list as well but never got a chance to write a patch.