linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: ehci: add struct entry for broadcom insnreg
@ 2020-05-27 13:43 Arnd Bergmann
  2020-05-27 14:25 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2020-05-27 13:43 UTC (permalink / raw)
  To: Al Cooper, Alan Stern, Greg Kroah-Hartman, Florian Fainelli,
	Andy Shevchenko, Arnd Bergmann
  Cc: Yoshihiro Shimoda, linux-usb, bcm-kernel-feedback-list, linux-kernel

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.

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 <arnd@arndb.de>
---
 drivers/usb/host/ehci-brcm.c | 13 ++++++-------
 include/linux/usb/ehci_def.h |  1 +
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/ehci-brcm.c b/drivers/usb/host/ehci-brcm.c
index 3e0ebe8cc649..bafb3f4db170 100644
--- a/drivers/usb/host/ehci-brcm.c
+++ b/drivers/usb/host/ehci-brcm.c
@@ -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);
 
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h
index 99481bbcc8f7..cf4bfbbdc8a3 100644
--- a/include/linux/usb/ehci_def.h
+++ b/include/linux/usb/ehci_def.h
@@ -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];
 	};
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: ehci: add struct entry for broadcom insnreg
  2020-05-27 13:43 [PATCH] usb: ehci: add struct entry for broadcom insnreg Arnd Bergmann
@ 2020-05-27 14:25 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2020-05-27 14:25 UTC (permalink / raw)
  To: Al Cooper, Alan Stern, Greg Kroah-Hartman, Florian Fainelli,
	Andy Shevchenko, Arnd Bergmann
  Cc: Yoshihiro Shimoda, USB list, bcm-kernel-feedback-list, linux-kernel

On Wed, May 27, 2020 at 3:43 PM Arnd Bergmann <arnd@arndb.de> wrote:

>
> 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 <arnd@arndb.de>


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-27 14:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 13:43 [PATCH] usb: ehci: add struct entry for broadcom insnreg Arnd Bergmann
2020-05-27 14:25 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).