All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v1 1/4] usb: xhci: Add missing endian conversions (cpu_to_leXX / leXX_to_cpu)
Date: Fri, 17 Jul 2020 13:34:36 +0200	[thread overview]
Message-ID: <5b33fcf3-e120-8153-6b83-f5034cee52c3@denx.de> (raw)
In-Reply-To: <CAEUhbmWr4mEt=HepF8zm7OJ7X2ENYUVLKoOVye=e_1596T0CiQ@mail.gmail.com>

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]));

Should I send v2 for this patch?

>>          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. :)

Thanks,
Stefan

  reply	other threads:[~2020-07-17 11:34 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02  8:47 [PATCH v1 0/4] Stefan Roese
2020-07-02  8:47 ` [PATCH v1 1/4] usb: xhci: Add missing endian conversions (cpu_to_leXX / leXX_to_cpu) Stefan Roese
2020-07-16  9:24   ` Stefan Roese
2020-07-16  9:39     ` Bin Meng
2020-07-17  5:15   ` Bin Meng
2020-07-17  9:57     ` Stefan Roese
2020-07-17 11:18   ` Bin Meng
2020-07-17 11:34     ` Stefan Roese [this message]
2020-07-17 13:46       ` 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
2020-07-02  8:47 ` [PATCH v1 2/4] usb: xhci: xhci_mem_init: Use cpu_to_le64() and not xhci_writeq() Stefan Roese
2020-07-17  5:24   ` Bin Meng
2020-07-17 10:04     ` Stefan Roese
2020-07-17 10:09       ` Bin Meng
2020-07-17 10:11         ` Stefan Roese
2020-07-17 10:13           ` Bin Meng
2020-07-17 11:19   ` Bin Meng
2020-07-02  8:47 ` [PATCH v1 3/4] usb: usb-uclass.c: Drop le16_to_cpu() as values are already swapped Stefan Roese
2020-07-17  5:33   ` Bin Meng
2020-07-17 10:08     ` Stefan Roese
2020-07-17 10:11       ` Bin Meng
2020-07-17 11:19   ` Bin Meng
2020-07-02  8:47 ` [PATCH v1 4/4] usb: xhci: Add virt_to_phys() to support mapped platforms Stefan Roese
2020-07-17  5:57   ` Bin Meng
2020-07-17 10:17     ` Stefan Roese
2020-07-17 10:23       ` Bin Meng
2020-07-17 10:28         ` Stefan Roese
2020-07-17 10:29           ` Bin Meng
2020-07-17 10:31             ` Stefan Roese
2020-07-17 11:19   ` Bin Meng

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=5b33fcf3-e120-8153-6b83-f5034cee52c3@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.