From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v1 4/4] usb: xhci: Add virt_to_phys() to support mapped platforms
Date: Fri, 17 Jul 2020 12:28:10 +0200 [thread overview]
Message-ID: <3e8c9dda-d0af-ba89-d4cd-7fa05a23fe8a@denx.de> (raw)
In-Reply-To: <CAEUhbmXEqnBOD34wpW3xdz8d2HgtdYERr2=bq_O6pFhdvRc=4A@mail.gmail.com>
Hi Bin,
On 17.07.20 12:23, Bin Meng wrote:
> Hi Stefan,
>
> On Fri, Jul 17, 2020 at 6:17 PM Stefan Roese <sr@denx.de> wrote:
>>
>> Hi Bin,
>>
>> On 17.07.20 07:57, Bin Meng wrote:
>>> Hi Stefan,
>>>
>>> On Thu, Jul 2, 2020 at 4:47 PM Stefan Roese <sr@denx.de> wrote:
>>>>
>>>> Some platforms, like MIPS Octeon, use mapped addresses (virtual address
>>>> != physical address). On these platforms we need to make sure, that the
>>>> local virtual addresses are converted to physical (DMA) addresses for
>>>> the xHCI controller. This patch adds the missing virt_to_phys() calls,
>>>> so that the correct addresses are used.
>>>>
>>>> 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 | 19 +++++++++----------
>>>> drivers/usb/host/xhci-ring.c | 8 ++++----
>>>> drivers/usb/host/xhci.c | 3 +--
>>>> 3 files changed, 14 insertions(+), 16 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
>>>> index 3b805ecb9e..874caf4761 100644
>>>> --- a/drivers/usb/host/xhci-mem.c
>>>> +++ b/drivers/usb/host/xhci-mem.c
>>>> @@ -224,7 +224,7 @@ static void xhci_link_segments(struct xhci_segment *prev,
>>>> return;
>>>> prev->next = next;
>>>> if (link_trbs) {
>>>> - val_64 = (uintptr_t)next->trbs;
>>>> + val_64 = virt_to_phys(next->trbs);
>>>> prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr =
>>>> cpu_to_le64(val_64);
>>>>
>>>> @@ -484,7 +484,7 @@ int xhci_alloc_virt_device(struct xhci_ctrl *ctrl, unsigned int slot_id)
>>>> /* Allocate endpoint 0 ring */
>>>> virt_dev->eps[0].ring = xhci_ring_alloc(1, true);
>>>>
>>>> - byte_64 = (uintptr_t)(virt_dev->out_ctx->bytes);
>>>> + byte_64 = virt_to_phys(virt_dev->out_ctx->bytes);
>>>>
>>>> /* Point to output device context in dcbaa. */
>>>> ctrl->dcbaa->dev_context_ptrs[slot_id] = cpu_to_le64(byte_64);
>>>> @@ -509,7 +509,7 @@ int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr *hccr,
>>>> uint64_t val_64;
>>>> uint64_t trb_64;
>>>> uint32_t val;
>>>> - unsigned long deq;
>>>> + uint64_t deq;
>>>
>>> This change seems unnecessary?
>>
>> In most (all other?) places, the variable containing these 64 bit
>> addresses has the type uint64_t in this driver. So I wanted to make the
>> code more consistant here. Or do you see a problem with this change?
>
> No, just wondering if you see something is wrong with (unsigned long)
> on a 32-bit platform.
I see. Thanks for checking.
Do you have a (little-endian) platform that you could use to test this
patchset on? I currently do not have such a board on my desk and would
very much like to see it tested on little-endian systems before being
applied.
Thanks,
Stefan
next prev parent reply other threads:[~2020-07-17 10:28 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
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 [this message]
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=3e8c9dda-d0af-ba89-d4cd-7fa05a23fe8a@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox