Message ID | 20220104072658.69756-23-marcan@marcan.st (mailing list archive) |
---|---|
State | Awaiting Upstream |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | brcmfmac: Support Apple T2 and M1 platforms | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On 1/4/2022 8:26 AM, Hector Martin wrote: > BCM4387 has trailing odd-sized blocks as part of TCM which have > their size described as a multiple of 1024 instead of 8192. Handle this > so we can compute the TCM size properly. Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org> > Signed-off-by: Hector Martin <marcan@marcan.st> > --- > .../wireless/broadcom/brcm80211/brcmfmac/chip.c | 17 ++++++++++++----- > 1 file changed, 12 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c > index 713546cebd5a..cfa93e3ef1a1 100644 > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c > @@ -212,8 +212,8 @@ struct sbsocramregs { > #define ARMCR4_TCBANB_MASK 0xf > #define ARMCR4_TCBANB_SHIFT 0 > > -#define ARMCR4_BSZ_MASK 0x3f > -#define ARMCR4_BSZ_MULT 8192 > +#define ARMCR4_BSZ_MASK 0x7f > +#define ARMCR4_BLK_1K_MASK 0x200 > > struct brcmf_core_priv { > struct brcmf_core pub; > @@ -675,7 +675,8 @@ static u32 brcmf_chip_sysmem_ramsize(struct brcmf_core_priv *sysmem) > } > > /** Return the TCM-RAM size of the ARMCR4 core. */ > -static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4) > +static u32 brcmf_chip_tcm_ramsize(struct brcmf_chip_priv *ci, > + struct brcmf_core_priv *cr4) Not sure why you add ci parameter here. It is not used below or am I overlooking something. > { > u32 corecap; > u32 memsize = 0; > @@ -683,6 +684,7 @@ static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4) > u32 nbb; > u32 totb; > u32 bxinfo; > + u32 blksize; > u32 idx; > > corecap = brcmf_chip_core_read32(cr4, ARMCR4_CAP); > @@ -694,7 +696,12 @@ static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4) > for (idx = 0; idx < totb; idx++) { > brcmf_chip_core_write32(cr4, ARMCR4_BANKIDX, idx); > bxinfo = brcmf_chip_core_read32(cr4, ARMCR4_BANKINFO); > - memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * ARMCR4_BSZ_MULT; > + if (bxinfo & ARMCR4_BLK_1K_MASK) > + blksize = 1024; > + else > + blksize = 8192; > + > + memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * blksize; > } > > return memsize;
On 1/19/2022 1:36 PM, Arend van Spriel wrote: > On 1/4/2022 8:26 AM, Hector Martin wrote: >> BCM4387 has trailing odd-sized blocks as part of TCM which have >> their size described as a multiple of 1024 instead of 8192. Handle this >> so we can compute the TCM size properly. So that is the deal. Wish someone over here told me about that :-p Gave my blessing already, but do have some remarks. > Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com> >> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> >> Signed-off-by: Hector Martin <marcan@marcan.st> >> --- >> .../wireless/broadcom/brcm80211/brcmfmac/chip.c | 17 ++++++++++++----- >> 1 file changed, 12 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c >> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c >> index 713546cebd5a..cfa93e3ef1a1 100644 >> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c >> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c >> @@ -212,8 +212,8 @@ struct sbsocramregs { >> #define ARMCR4_TCBANB_MASK 0xf >> #define ARMCR4_TCBANB_SHIFT 0 >> -#define ARMCR4_BSZ_MASK 0x3f >> -#define ARMCR4_BSZ_MULT 8192 Instead of deleting can we leave it here and... >> +#define ARMCR4_BSZ_MASK 0x7f >> +#define ARMCR4_BLK_1K_MASK 0x200 >> struct brcmf_core_priv { >> struct brcmf_core pub; >> @@ -675,7 +675,8 @@ static u32 brcmf_chip_sysmem_ramsize(struct >> brcmf_core_priv *sysmem) >> } >> /** Return the TCM-RAM size of the ARMCR4 core. */ >> -static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4) >> +static u32 brcmf_chip_tcm_ramsize(struct brcmf_chip_priv *ci, >> + struct brcmf_core_priv *cr4) > > Not sure why you add ci parameter here. It is not used below or am I > overlooking something. > >> { >> u32 corecap; >> u32 memsize = 0; >> @@ -683,6 +684,7 @@ static u32 brcmf_chip_tcm_ramsize(struct >> brcmf_core_priv *cr4) >> u32 nbb; >> u32 totb; >> u32 bxinfo; >> + u32 blksize; >> u32 idx; >> corecap = brcmf_chip_core_read32(cr4, ARMCR4_CAP); >> @@ -694,7 +696,12 @@ static u32 brcmf_chip_tcm_ramsize(struct >> brcmf_core_priv *cr4) >> for (idx = 0; idx < totb; idx++) { >> brcmf_chip_core_write32(cr4, ARMCR4_BANKIDX, idx); >> bxinfo = brcmf_chip_core_read32(cr4, ARMCR4_BANKINFO); >> - memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * ARMCR4_BSZ_MULT; >> + if (bxinfo & ARMCR4_BLK_1K_MASK) >> + blksize = 1024; >> + else >> + blksize = 8192; ... do following here instead: blksize = 8192; if (bxinfo & ARMCR4_BLK_1K_MASK) blksize >>= 3; [not sure if mailreader is screwing with indentation or what] >> + >> + memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * blksize; >> } >> return memsize;
On 19/01/2022 21.36, Arend van Spriel wrote: >> /** Return the TCM-RAM size of the ARMCR4 core. */ >> -static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4) >> +static u32 brcmf_chip_tcm_ramsize(struct brcmf_chip_priv *ci, >> + struct brcmf_core_priv *cr4) > > Not sure why you add ci parameter here. It is not used below or am I > overlooking something. Oops, looks like junk left behind from when I was trying to figure this out. Removed. Sorry about that.
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c index 713546cebd5a..cfa93e3ef1a1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c @@ -212,8 +212,8 @@ struct sbsocramregs { #define ARMCR4_TCBANB_MASK 0xf #define ARMCR4_TCBANB_SHIFT 0 -#define ARMCR4_BSZ_MASK 0x3f -#define ARMCR4_BSZ_MULT 8192 +#define ARMCR4_BSZ_MASK 0x7f +#define ARMCR4_BLK_1K_MASK 0x200 struct brcmf_core_priv { struct brcmf_core pub; @@ -675,7 +675,8 @@ static u32 brcmf_chip_sysmem_ramsize(struct brcmf_core_priv *sysmem) } /** Return the TCM-RAM size of the ARMCR4 core. */ -static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4) +static u32 brcmf_chip_tcm_ramsize(struct brcmf_chip_priv *ci, + struct brcmf_core_priv *cr4) { u32 corecap; u32 memsize = 0; @@ -683,6 +684,7 @@ static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4) u32 nbb; u32 totb; u32 bxinfo; + u32 blksize; u32 idx; corecap = brcmf_chip_core_read32(cr4, ARMCR4_CAP); @@ -694,7 +696,12 @@ static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4) for (idx = 0; idx < totb; idx++) { brcmf_chip_core_write32(cr4, ARMCR4_BANKIDX, idx); bxinfo = brcmf_chip_core_read32(cr4, ARMCR4_BANKINFO); - memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * ARMCR4_BSZ_MULT; + if (bxinfo & ARMCR4_BLK_1K_MASK) + blksize = 1024; + else + blksize = 8192; + + memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * blksize; } return memsize; @@ -752,7 +759,7 @@ int brcmf_chip_get_raminfo(struct brcmf_chip *pub) mem = brcmf_chip_get_core(&ci->pub, BCMA_CORE_ARM_CR4); if (mem) { mem_core = container_of(mem, struct brcmf_core_priv, pub); - ci->pub.ramsize = brcmf_chip_tcm_ramsize(mem_core); + ci->pub.ramsize = brcmf_chip_tcm_ramsize(ci, mem_core); ci->pub.rambase = brcmf_chip_tcm_rambase(ci); if (ci->pub.rambase == INVALID_RAMBASE) { brcmf_err("RAM base not provided with ARM CR4 core\n");