Message ID | 1510925190-13103-1-git-send-email-abrodkin@synopsys.com |
---|---|
State | Accepted |
Commit | 9829ce2ff25c659ca29cd15ab773312ac4b6cfc6 |
Delegated to: | Marek Vasut |
Headers | show |
Series | [U-Boot] usb: ehci: Fix accessors for big-endian platforms and descriptors | expand |
On 11/17/2017 02:26 PM, Alexey Brodkin wrote: > Commit 9000eddbae0d ("drivers/usb/ehci: Use platform-specific accessors") > broke USB 2.0 on big-endian platforms because for them writel/readl() > does automatic conversion of BE data to LE. > > Proper implementation requires to use "raw" variant of these accessors > which read/write data without messing with endianess. > > While at it replace cpu_to_be32() to be32_to_cpu() in readl() to > keep sane semantics. > > Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> > Cc: Marek Vasut <marex@denx.de> > Reported-by: Vladimir Boroda <boroda@yahoo.com> Applied, thanks ! > --- > drivers/usb/host/ehci.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h > index 7c39becd247e..18692b732ea6 100644 > --- a/drivers/usb/host/ehci.h > +++ b/drivers/usb/host/ehci.h > @@ -101,11 +101,11 @@ struct usb_linux_config_descriptor { > } __attribute__ ((packed)); > > #if defined CONFIG_EHCI_DESC_BIG_ENDIAN > -#define ehci_readl(x) cpu_to_be32(readl(x)) > -#define ehci_writel(a, b) writel(cpu_to_be32(b), a) > +#define ehci_readl(x) be32_to_cpu(__raw_readl(x)) > +#define ehci_writel(a, b) __raw_writel(cpu_to_be32(b), a) > #else > -#define ehci_readl(x) cpu_to_le32(readl(x)) > -#define ehci_writel(a, b) writel(cpu_to_le32(b), a) > +#define ehci_readl(x) readl(x) > +#define ehci_writel(a, b) writel(b, a) > #endif > > #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN >
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 7c39becd247e..18692b732ea6 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -101,11 +101,11 @@ struct usb_linux_config_descriptor { } __attribute__ ((packed)); #if defined CONFIG_EHCI_DESC_BIG_ENDIAN -#define ehci_readl(x) cpu_to_be32(readl(x)) -#define ehci_writel(a, b) writel(cpu_to_be32(b), a) +#define ehci_readl(x) be32_to_cpu(__raw_readl(x)) +#define ehci_writel(a, b) __raw_writel(cpu_to_be32(b), a) #else -#define ehci_readl(x) cpu_to_le32(readl(x)) -#define ehci_writel(a, b) writel(cpu_to_le32(b), a) +#define ehci_readl(x) readl(x) +#define ehci_writel(a, b) writel(b, a) #endif #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN
Commit 9000eddbae0d ("drivers/usb/ehci: Use platform-specific accessors") broke USB 2.0 on big-endian platforms because for them writel/readl() does automatic conversion of BE data to LE. Proper implementation requires to use "raw" variant of these accessors which read/write data without messing with endianess. While at it replace cpu_to_be32() to be32_to_cpu() in readl() to keep sane semantics. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Cc: Marek Vasut <marex@denx.de> Reported-by: Vladimir Boroda <boroda@yahoo.com> --- drivers/usb/host/ehci.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)