Skip to contentSkip to conversation

mmc: sdhci-brcmstb: don't log an error for missing BOOT registers

PATCH In review Karl Mehltretter 7 participants 7 messages Oct 9 – Oct 30

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

PATCH 1/1 mmc: sdhci-brcmstb: don't log an error for missing BOOT registers

The BOOT register range is optional: the probe function ignores a failure to map it and the suspend/resume code checks for NULL. It is mapped with devm_platform_get_and_ioremap_resource(), though, which calls dev_err_probe() when the resource does not exist. Every non-removable host without a third reg entry therefore logs an error at probe time and then works normally.

The binding only describes the "host" and "cfg" ranges, so this is the case for the in-tree users. On the Raspberry Pi 5 family (BCM2712), where the SDIO host of the Wi-Fi module is non-removable, each boot prints:

sdhci-brcmstb 1001100000.mmc: error -EINVAL: invalid resource (null)

Look the resource up with platform_get_resource() first and map it only when it is present. Hosts that do have the range are mapped by the same two calls as before.

Fixes b7e614802e3f ("mmc: sdhci-brcmstb: save and restore registers during PM")
Assisted-by LLM

---
Tested on a Raspberry Pi 500+ with v7.3-rc4: the message is gone, the SDIO card is detected as before and Wi-Fi works. Suspend/resume, the only user of these registers, was not tested.

 drivers/mmc/host/sdhci-brcmstb.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-brcmstb.c +8 -3
index 1de2f05..7c17a3c 100644
@@ -491,6 +491,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	struct sdhci_brcmstb_priv *priv;
 	u32 actual_clock_mhz;
 	struct sdhci_host *host;
+	struct resource *boot_res;
 	struct clk *clk;
 	struct clk *base_clk = NULL;
 	int res;
@@ -534,9 +535,13 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 
 	/* map non-standard BOOT registers if present */
 	if (host->mmc->caps & MMC_CAP_NONREMOVABLE) {
-		priv->boot_regs = devm_platform_get_and_ioremap_resource(pdev, 2, NULL);
-		if (IS_ERR(priv->boot_regs))
-			priv->boot_regs = NULL;
+		boot_res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+		if (boot_res) {
+			priv->boot_regs = devm_ioremap_resource(&pdev->dev,
+								boot_res);
+			if (IS_ERR(priv->boot_regs))
+				priv->boot_regs = NULL;
+		}
 	}
 
 	/*

base-commit: 6c377d19d4a5116d9bec5203aa3c6c11523e7898

Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 14 lines · Karl Mehltretter

The BOOT register range is optional: the probe function ignores a failure to map it and the suspend/resume code checks for NULL. It is mapped with devm_platform_get_and_ioremap_resource(), though, which calls dev_err_probe() when the resource does not exist. Every non-removable host without a third reg entry therefore logs an error at probe time and then works normally.

The binding only describes the "host" and "cfg" ranges, so this is the case for the in-tree users. On the Raspberry Pi 5 family (BCM2712), where the SDIO host of the Wi-Fi module is non-removable, each boot prints:

sdhci-brcmstb 1001100000.mmc: error -EINVAL: invalid resource (null)

Quoted 7 lines

Look the resource up with platform_get_resource() first and map it only when it is present. Hosts that do have the range are mapped by the same two calls as before.

Fixes b7e614802e3f ("mmc: sdhci-brcmstb: save and restore registers during PM")
Assisted-by LLM
Quoted 4 lines

---
Tested on a Raspberry Pi 500+ with v7.3-rc4: the message is gone, the SDIO card is detected as before and Wi-Fi works. Suspend/resume, the only user of these registers, was not tested.

I have seen this error a few times but newer looked into it. Thanks for the fix.

Quoted 35 lines
 drivers/mmc/host/sdhci-brcmstb.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-brcmstb.c +8 -3
index 1de2f05..7c17a3c 100644
@@ -491,6 +491,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	struct sdhci_brcmstb_priv *priv;
 	u32 actual_clock_mhz;
 	struct sdhci_host *host;
+	struct resource *boot_res;
 	struct clk *clk;
 	struct clk *base_clk = NULL;
 	int res;
@@ -534,9 +535,13 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 
 	/* map non-standard BOOT registers if present */
 	if (host->mmc->caps & MMC_CAP_NONREMOVABLE) {
-		priv->boot_regs = devm_platform_get_and_ioremap_resource(pdev, 2, NULL);
-		if (IS_ERR(priv->boot_regs))
-			priv->boot_regs = NULL;
+		boot_res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+		if (boot_res) {
+			priv->boot_regs = devm_ioremap_resource(&pdev->dev,
+								boot_res);
+			if (IS_ERR(priv->boot_regs))
+				priv->boot_regs = NULL;
+		}
 	}
 
 	/*

base-commit: 6c377d19d4a5116d9bec5203aa3c6c11523e7898

Signature · 11 lines
Gregor Herburger
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 35; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/legal/data-protection.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Dr. Wilfried Wessner, 
Katharina Kopp, Alexander Gieringer
#2 lore raw
In reply to Karl Mehltretter

…

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 494

Quoted 6 lines

+++ b/drivers/mmc/host/sdhci-brcmstb.c

drivers/mmc/host/sdhci-brcmstb.c +1 -0
@@ -491,6 +491,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	struct sdhci_brcmstb_priv *priv;
 	u32 actual_clock_mhz;
 	struct sdhci_host *host;
+	struct resource *boot_res;

…

I suggest to reduce the scope for this local variable because you would like to use it only within a selected if branch.
https://elixir.bootlin.com/linux/v7.3-rc6/source/drivers/mmc/host/sdhci-brcmstb.c#L535-L540

Regards,
Markus

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Karl Mehltretter
Quoted 14 lines · Karl Mehltretter

The BOOT register range is optional: the probe function ignores a failure to map it and the suspend/resume code checks for NULL. It is mapped with devm_platform_get_and_ioremap_resource(), though, which calls dev_err_probe() when the resource does not exist. Every non-removable host without a third reg entry therefore logs an error at probe time and then works normally.

The binding only describes the "host" and "cfg" ranges, so this is the case for the in-tree users. On the Raspberry Pi 5 family (BCM2712), where the SDIO host of the Wi-Fi module is non-removable, each boot prints:

sdhci-brcmstb 1001100000.mmc: error -EINVAL: invalid resource (null)

Quoted 7 lines

Look the resource up with platform_get_resource() first and map it only when it is present. Hosts that do have the range are mapped by the same two calls as before.

Fixes b7e614802e3f ("mmc: sdhci-brcmstb: save and restore registers during PM")
Assisted-by LLM
Quoted 39 lines

---
Tested on a Raspberry Pi 500+ with v7.3-rc4: the message is gone, the SDIO card is detected as before and Wi-Fi works. Suspend/resume, the only user of these registers, was not tested.

 drivers/mmc/host/sdhci-brcmstb.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-brcmstb.c +8 -3
index 1de2f05..7c17a3c 100644
@@ -491,6 +491,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	struct sdhci_brcmstb_priv *priv;
 	u32 actual_clock_mhz;
 	struct sdhci_host *host;
+	struct resource *boot_res;
 	struct clk *clk;
 	struct clk *base_clk = NULL;
 	int res;
@@ -534,9 +535,13 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 
 	/* map non-standard BOOT registers if present */
 	if (host->mmc->caps & MMC_CAP_NONREMOVABLE) {
-		priv->boot_regs = devm_platform_get_and_ioremap_resource(pdev, 2, NULL);
-		if (IS_ERR(priv->boot_regs))
-			priv->boot_regs = NULL;
+		boot_res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+		if (boot_res) {
+			priv->boot_regs = devm_ioremap_resource(&pdev->dev,
+								boot_res);
+			if (IS_ERR(priv->boot_regs))
+				priv->boot_regs = NULL;
+		}
 	}
 
 	/*

base-commit: 6c377d19d4a5116d9bec5203aa3c6c11523e7898

maintainer Reviewed-by on v1 1/1
#4 lore raw
In reply to Karl Mehltretter
Quoted 14 lines · Karl Mehltretter

The BOOT register range is optional: the probe function ignores a failure to map it and the suspend/resume code checks for NULL. It is mapped with devm_platform_get_and_ioremap_resource(), though, which calls dev_err_probe() when the resource does not exist. Every non-removable host without a third reg entry therefore logs an error at probe time and then works normally.

The binding only describes the "host" and "cfg" ranges, so this is the case for the in-tree users. On the Raspberry Pi 5 family (BCM2712), where the SDIO host of the Wi-Fi module is non-removable, each boot prints:

sdhci-brcmstb 1001100000.mmc: error -EINVAL: invalid resource (null)

Quoted 7 lines

Look the resource up with platform_get_resource() first and map it only when it is present. Hosts that do have the range are mapped by the same two calls as before.

Fixes b7e614802e3f ("mmc: sdhci-brcmstb: save and restore registers during PM")
Assisted-by LLM
Signature · 1 line
Florian
maintainer Reviewed-by on v1 1/1
#5 lore raw
In reply to Karl Mehltretter
Quoted 15 lines · Karl Mehltretter

The BOOT register range is optional: the probe function ignores a failure to map it and the suspend/resume code checks for NULL. It is mapped with devm_platform_get_and_ioremap_resource(), though, which calls dev_err_probe() when the resource does not exist. Every non-removable host without a third reg entry therefore logs an error at probe time and then works normally.

The binding only describes the "host" and "cfg" ranges, so this is the case for the in-tree users. On the Raspberry Pi 5 family (BCM2712), where the SDIO host of the Wi-Fi module is non-removable, each boot prints:

sdhci-brcmstb 1001100000.mmc: error -EINVAL: invalid resource (null)

Quoted 7 lines

Look the resource up with platform_get_resource() first and map it only when it is present. Hosts that do have the range are mapped by the same two calls as before.

Fixes b7e614802e3f ("mmc: sdhci-brcmstb: save and restore registers during PM")
Assisted-by LLM

LGTM

#6 lore raw
In reply to Karl Mehltretter
Quoted 15 lines · Karl Mehltretter

The BOOT register range is optional: the probe function ignores a failure to map it and the suspend/resume code checks for NULL. It is mapped with devm_platform_get_and_ioremap_resource(), though, which calls dev_err_probe() when the resource does not exist. Every non-removable host without a third reg entry therefore logs an error at probe time and then works normally.

The binding only describes the "host" and "cfg" ranges, so this is the case for the in-tree users. On the Raspberry Pi 5 family (BCM2712), where the SDIO host of the Wi-Fi module is non-removable, each boot prints:

sdhci-brcmstb 1001100000.mmc: error -EINVAL: invalid resource (null)

Quoted 7 lines

Look the resource up with platform_get_resource() first and map it only when it is present. Hosts that do have the range are mapped by the same two calls as before.

Fixes b7e614802e3f ("mmc: sdhci-brcmstb: save and restore registers during PM")
Assisted-by LLM

Applied for fixes, thanks!

Kind regards
Uffe

Quoted 39 lines

---
Tested on a Raspberry Pi 500+ with v7.3-rc4: the message is gone, the SDIO card is detected as before and Wi-Fi works. Suspend/resume, the only user of these registers, was not tested.

 drivers/mmc/host/sdhci-brcmstb.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-brcmstb.c +8 -3
index 1de2f05..7c17a3c 100644
@@ -491,6 +491,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
        struct sdhci_brcmstb_priv *priv;
        u32 actual_clock_mhz;
        struct sdhci_host *host;
+       struct resource *boot_res;
        struct clk *clk;
        struct clk *base_clk = NULL;
        int res;
@@ -534,9 +535,13 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 
        /* map non-standard BOOT registers if present */
        if (host->mmc->caps & MMC_CAP_NONREMOVABLE) {
-               priv->boot_regs = devm_platform_get_and_ioremap_resource(pdev, 2, NULL);
-               if (IS_ERR(priv->boot_regs))
-                       priv->boot_regs = NULL;
+               boot_res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+               if (boot_res) {
+                       priv->boot_regs = devm_ioremap_resource(&pdev->dev,
+                                                               boot_res);
+                       if (IS_ERR(priv->boot_regs))
+                               priv->boot_regs = NULL;
+               }
        }
 
        /*

base-commit: 6c377d19d4a5116d9bec5203aa3c6c11523e7898