public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 0/4] usb: xhci: Prepare xHCI driver for MIPS Octeon big-endian support
@ 2020-07-21  8:46 Stefan Roese
  2020-07-21  8:46 ` [PATCH v2 1/4] usb: xhci: Add missing endian conversions (cpu_to_leXX / leXX_to_cpu) Stefan Roese
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Stefan Roese @ 2020-07-21  8:46 UTC (permalink / raw)
  To: u-boot


These patches fix a few issues, found while porting the xHCI to the MIPS
Octeon platforms. The basic issues here are:

- Endianess issues: missing cpu_to_leXX() & leXX_to_cpu() conversions
- Use physical (DMA) address for the xHCI DMA controller

These patches are the groundwork for the upcoming xHCI Octeon support
that will follow soon.

Thanks,
Stefan

Changes in v2:
- Add missing (uintptr_t) cast to remove compile time warning

Stefan Roese (4):
  usb: xhci: Add missing endian conversions (cpu_to_leXX / leXX_to_cpu)
  usb: xhci: xhci_mem_init: Use cpu_to_le64() and not xhci_writeq()
  usb: usb-uclass.c: Drop le16_to_cpu() as values are already swapped
  usb: xhci: Add virt_to_phys() to support mapped platforms

 drivers/usb/host/usb-uclass.c |  8 ++++----
 drivers/usb/host/xhci-mem.c   | 30 +++++++++++++++---------------
 drivers/usb/host/xhci-ring.c  |  8 ++++----
 drivers/usb/host/xhci.c       |  3 +--
 4 files changed, 24 insertions(+), 25 deletions(-)

-- 
2.27.0

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH v1 1/4] usb: xhci: Add missing endian conversions (cpu_to_leXX / leXX_to_cpu)
@ 2020-07-17 13:46 Bin Meng
  2020-07-17 14:04 ` [PATCH v2 " Stefan Roese
  0 siblings, 1 reply; 14+ messages in thread
From: Bin Meng @ 2020-07-17 13:46 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On Fri, Jul 17, 2020 at 7:34 PM Stefan Roese <sr@denx.de> wrote:
>
> Hi Bin,
>
> On 17.07.20 13:18, Bin Meng wrote:
> > Hi Stefan,
> >
> > On Thu, Jul 2, 2020 at 4:47 PM Stefan Roese <sr@denx.de> wrote:
> >>
> >> While trying to use the U-Boot xHCI driver on the MIPS Octeon platform,
> >> which is big endian, I noticed that the driver is missing a few endian
> >> conversion calls. This patch adds these missing endian conversion
> >> calls.
> >>
> >> Signed-off-by: Stefan Roese <sr@denx.de>
> >> Cc: Bin Meng <bmeng.cn@gmail.com>
> >> Cc: Marek Vasut <marex@denx.de>
> >> ---
> >>
> >>   drivers/usb/host/xhci-mem.c | 9 +++++----
> >>   1 file changed, 5 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> >> index 2d968aafb0..bd959b4093 100644
> >> --- a/drivers/usb/host/xhci-mem.c
> >> +++ b/drivers/usb/host/xhci-mem.c
> >> @@ -110,7 +110,7 @@ static void xhci_scratchpad_free(struct xhci_ctrl *ctrl)
> >>
> >>          ctrl->dcbaa->dev_context_ptrs[0] = 0;
> >>
> >> -       free((void *)(uintptr_t)ctrl->scratchpad->sp_array[0]);
> >> +       free((void *)le64_to_cpu(ctrl->scratchpad->sp_array[0]));
> >
> > There is a build warning for this:
> >
> > drivers/usb/host/xhci-mem.c: In function 'xhci_scratchpad_free':
> > drivers/usb/host/xhci-mem.c:113:7: warning: cast to pointer from
> > integer of different size [-Wint-to-pointer-cast]
> >    free((void *)le64_to_cpu(ctrl->scratchpad->sp_array[0]));
> >         ^
>
> So we need the (uintptr_t) here as well?
>
>    free((void *)(uintptr_t)le64_to_cpu(ctrl->scratchpad->sp_array[0]));

I think so.

>
> Should I send v2 for this patch?

Yes, please.

>
> >>          free(ctrl->scratchpad->sp_array);
> >>          free(ctrl->scratchpad);
> >>          ctrl->scratchpad = NULL;
> >> @@ -225,7 +225,8 @@ static void xhci_link_segments(struct xhci_segment *prev,
> >>          prev->next = next;
> >>          if (link_trbs) {
> >>                  val_64 = (uintptr_t)next->trbs;
> >> -               prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr = val_64;
> >> +               prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr =
> >> +                       cpu_to_le64(val_64);
> >>
> >>                  /*
> >>                   * Set the last TRB in the segment to
> >> @@ -486,7 +487,7 @@ int xhci_alloc_virt_device(struct xhci_ctrl *ctrl, unsigned int slot_id)
> >>          byte_64 = (uintptr_t)(virt_dev->out_ctx->bytes);
> >>
> >>          /* Point to output device context in dcbaa. */
> >> -       ctrl->dcbaa->dev_context_ptrs[slot_id] = byte_64;
> >> +       ctrl->dcbaa->dev_context_ptrs[slot_id] = cpu_to_le64(byte_64);
> >>
> >>          xhci_flush_cache((uintptr_t)&ctrl->dcbaa->dev_context_ptrs[slot_id],
> >>                           sizeof(__le64));
> >> @@ -768,7 +769,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
> >>
> >>          debug("route string %x\n", route);
> >>   #endif
> >> -       slot_ctx->dev_info |= route;
> >> +       slot_ctx->dev_info |= cpu_to_le32(route);
> >>
> >>          switch (speed) {
> >>          case USB_SPEED_SUPER:
> >> --
> >
> > Test results on Minnowmax which has one USB 2.0 port and one 3.0 port:
> >
> > USB 2.0 flash drive inserted to USB 2.0 port: recognized, read/write OK
> > USB 2.0 flash drive inserted to USB 3.0 port: recognized, read/write OK
> >
> > USB 3.0 flash drive inserted to USB 2.0 port: recognized, read/write OK
> > USB 3.0 flash drive inserted to USB 3.0 port: recognized, read/write OK
> >
> > USB 2.0 flash drive connected to a USB 3.0 HUB inserted to USB 2.0
> > port: recognized, read/write OK
> > USB 2.0 flash drive connected to a USB 3.0 HUB inserted to USB 3.0
> > port: recognized, read/write OK
> >
> > USB 3.0 flash drive connected to a USB 3.0 HUB inserted to USB 2.0
> > port: recognized, read/write OK
> > USB 3.0 flash drive connected to a USB 3.0 HUB inserted to USB 3.0
> > port: recognized, read/write OK
> >
> > Tested-by: Bin Meng <bmeng.cn@gmail.com>
>
> Very good. :)

Regards,
Bin

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

end of thread, other threads:[~2020-08-05  7:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-21  8:46 [PATCH v2 0/4] usb: xhci: Prepare xHCI driver for MIPS Octeon big-endian support Stefan Roese
2020-07-21  8:46 ` [PATCH v2 1/4] usb: xhci: Add missing endian conversions (cpu_to_leXX / leXX_to_cpu) Stefan Roese
2020-07-21  8:46 ` [PATCH v2 2/4] usb: xhci: xhci_mem_init: Use cpu_to_le64() and not xhci_writeq() Stefan Roese
2020-07-21  8:46 ` [PATCH v2 3/4] usb: usb-uclass.c: Drop le16_to_cpu() as values are already swapped Stefan Roese
2020-07-21  8:46 ` [PATCH v2 4/4] usb: xhci: Add virt_to_phys() to support mapped platforms Stefan Roese
2020-07-30  6:32 ` [PATCH v2 0/4] usb: xhci: Prepare xHCI driver for MIPS Octeon big-endian support Stefan Roese
2020-07-30  6:59   ` Bin Meng
2020-08-05  5:57     ` Stefan Roese
2020-08-05  7:31       ` Marek Vasut
  -- strict thread matches above, loose matches on Subject: below --
2020-07-17 13:46 [PATCH v1 1/4] usb: xhci: Add missing endian conversions (cpu_to_leXX / leXX_to_cpu) Bin Meng
2020-07-17 14:04 ` [PATCH v2 " Stefan Roese
2020-07-17 14:14   ` Bin Meng
2020-07-17 18:22     ` Stefan Roese
2020-07-20  1:48       ` Bin Meng
2020-07-21  8:39         ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox