usb: ehci: add struct entry for broadcom insnreg
Subsystems (3)
PATCH 1/1 usb: ehci: add struct entry for broadcom insnreg
The newly added broadcom ehci driver triggered another array overflow warning after I had fixed up a bunch of others. In this case, the driver intentionally abuses the port_status[] array to access a register that does not have an official name:
drivers/usb/host/ehci-brcm.c:113:33: error: array index 16 is past the end of the array (which contains 15 elements) [-Werror,-Warray-bounds]
ehci_writel(ehci, 0x00800040, &ehci->regs->port_status[0x10]);
^ ~~~~include/linux/usb/ehci_def.h:131:3: note: array 'port_status' declared here
u32 port_status[15]; /* up to N_PORTS */
^
There is already a hack for Intel specific registers at the same location, so extend that hack to also cover the Broadcom registers.
I'm a little confused about the register offset, as the code comment says @0x90 while the actual offset seems to be at offset 0x84, please confirm that the behavior is still correct.
--- drivers/usb/host/ehci-brcm.c | 13 ++++++------- include/linux/usb/ehci_def.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/usb/host/ehci-brcm.c +6 -7
@@ -108,10 +108,10 @@ static int ehci_brcm_reset(struct usb_hcd *hcd)/* * SWLINUX-1705: Avoid OUT packet underflows during high memory * bus usage -* port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90 +* Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90 */ -ehci_writel (ehci,0x00800040 , &ehci->regs->port_status[0x10 ]); -ehci_writel (ehci,0x00000001 , &ehci->regs->port_status[0x12 ]); +ehci_writel (ehci,0x00800040 , &ehci->regs->brcm_insnreg[0 ]); +ehci_writel (ehci,0x00000001 , &ehci->regs->brcm_insnreg[2 ]);return ehci_setup (hcd); }
@@ -223,11 +223,10 @@ static int __maybe_unused ehci_brcm_resume(struct device *dev)/* * SWLINUX-1705: Avoid OUT packet underflows during high memory * bus usage -* port_status[0x0f] = Broadcom-proprietary USB_EHCI_INSNREG00 -* @ 0x90 +* Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x90 */ -ehci_writel (ehci,0x00800040 , &ehci->regs->port_status[0x10 ]); -ehci_writel (ehci,0x00000001 , &ehci->regs->port_status[0x12 ]); +ehci_writel (ehci,0x00800040 , &ehci->regs->brcm_insnreg[0 ]); +ehci_writel (ehci,0x00000001 , &ehci->regs->brcm_insnreg[2 ]);ehci_resume (hcd, false);
include/linux/usb/ehci_def.h +1 -0
@@ -190,6 +190,7 @@ struct ehci_regs {#define HOSTPC_PHCD (1<<22)/* Phy clock disable */ #define HOSTPC_PSPD (3<<25)/* Port speed detection */ +u32 brcm_insnreg[3 ];/* Broadcom specific */ u32 reserved6[17 ]; };
Signature · 1 line
2.26.2
Quoted 4 lines · Arnd Bergmann
Fixes 9df231511bd6 ("usb: ehci: Add new EHCI driver for Broadcom STB SoC's")Fixes 88aa39691cea ("usb: ehci: avoid gcc-10 zero-length-bounds warning")Signed-off-by Arnd Bergmann <[email protected]>
Please disregard this submission, I just noticed that the 88aa39691cea commit I referenced is one in my local tree, not in linux-next. I'll make sure they are both good and then resubmit them as a series or a combined patch.
Arnd