From: Arnd Bergmann <arnd@arndb.de>
To: Al Cooper <alcooperx@gmail.com>,
Alan Stern <stern@rowland.harvard.edu>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Florian Fainelli <f.fainelli@gmail.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Arnd Bergmann <arnd@arndb.de>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
linux-usb@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com,
linux-kernel@vger.kernel.org
Subject: [PATCH] usb: ehci: add struct entry for broadcom insnreg
Date: Wed, 27 May 2020 15:43:04 +0200 [thread overview]
Message-ID: <20200527134320.869042-1-arnd@arndb.de> (raw)
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
next reply other threads:[~2020-05-27 13:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-27 13:43 Arnd Bergmann [this message]
2020-05-27 14:25 ` [PATCH] usb: ehci: add struct entry for broadcom insnreg Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200527134320.869042-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=alcooperx@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=f.fainelli@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).