wifi: brcmfmac: Detect corner error case earlier with log
PATCH v3 1/1 wifi: brcmfmac: Detect corner error case earlier with log
In brcmf_chip_recognition, the return value from an MMIO read is interpreted as various fields without checking if it failed, which is harmless today, as the interpreted fields are checked for validity a few lines below. However, in corner cases (on my MacbookPro 14,1, sometimes after waking from sleep or soft reboot), when this happens, it causes the logging to be misleading, because the message indicates an unsupported chip type ("brcmfmac: brcmf_chip_recognition: chip backplane type 15 is not supported"). This patch detects this case slightly earlier and logs an appropriate message, with the same return result as is the case today.
---
v3: Fix indentation and add context to commit message
v2: Add const to variable holding error code & fix patch submission
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +6 -0
@@ -972,6 +972,7 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci)u32 regdata;u32 socitype;int ret; +const u32 READ_FAILED =0xFFFFFFFF ;/* Get CC core rev * Chipid is assume to be at offset 0 from SI_ENUM_BASE
@@ -980,6 +981,11 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci)*/ regdata = ci->ops->read32 (ci->ctx,CORE_CC_REG (ci->pub.enum_base, chipid)); +if (regdata ==READ_FAILED ) { +brcmf_err ("MMIO read failed: 0x%08x\n" , regdata); +return -ENODEV ; + } + ci->pub.chip = regdata &CID_ID_MASK ; ci->pub.chiprev = (regdata &CID_REV_MASK ) >>CID_REV_SHIFT ; socitype = (regdata &CID_TYPE_MASK ) >>CID_TYPE_SHIFT ;
--
2.40.1
Quoted 11 lines · Neal Sidhwaney
In
brcmf_chip_recognition(), the return value from an MMIO read is interpreted as various fields without checking if it failed, which is harmless today, as the interpreted fields are checked for validity a few lines below. However, in corner cases (on my MacbookPro 14,1, sometimes after waking from sleep or soft reboot), when this happens, it causes the logging to be misleading, because the message indicates an unsupported chip type ("brcmfmac:brcmf_chip_recognition: chip backplane type 15 is not supported"). This patch detects this case slightly earlier and logs an appropriate message, with the same return result as is the case today.
Quoted 1 line
Signed-off-by Neal Sidhwaney <[email protected]>
Patch applied to wireless-next.git, thanks.
f8f912bf69a0 wifi: brcmfmac: Detect corner error case earlier with log
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches