From: Faiz Abbas <faiz_abbas@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] dwc: ep0: Allocate and flush dwc->ep0_trb in a cache aligned manner
Date: Tue, 10 Oct 2017 16:15:10 +0530 [thread overview]
Message-ID: <3cee6911-e482-cc8c-424d-706be58a14f9@ti.com> (raw)
In-Reply-To: <7d9413a9-0c4f-bd07-c428-83c0925be9ee@denx.de>
Hi Marek,
On Tuesday 10 October 2017 01:30 PM, Marek Vasut wrote:
> On 10/10/2017 07:48 AM, Kishon Vijay Abraham I wrote:
>> Hi,
>
> Hi,
>
> [...]
>
>>>>>>>>>>>> - dwc3_flush_cache((uintptr_t)trb, sizeof(*trb));
>>>>>>>>>>>> + dwc3_flush_cache((uintptr_t)dwc->ep0_trb_addr, sizeof(*trb) * 2);
>>>>>>>>>>>
>>>>>>>>>>> Why *2 ?
>>>>>>>>>>
>>>>>>>>>> Because its allocated as sizeof(*dwc->ep0_trb) * 2 below. This is not
>>>>>>>>>> strictly required as dwc3_flush_cache() rounds up the size to
>>>>>>>>>> CACHELINE_SIZE but from a caller POV, flush everything we allocated.
>>>>>>>>>
>>>>>>>>> Can the other TRB be in use ? Maybe aligning the TRBs to cacheline size
>>>>>>>>> would be better ?
>>>>>>>>>
>>>>>>>> A single trb is 16 bytes in size and two of them are allocated
>>>>>>>> contiguously.
>>>>>>>
>>>>>>> Why are two allocated continuously ? (I am not dwc3 expert)
>>
>> The TRB's should be allocated contiguously for dwc3 and only the base of the
>> entire TRB table is programmed in the HW.
>> ________________ <------------------ TRB table base address
>> | TRB0 |
>> |________________|
>> | TRB1 |
>> |________________|
>> | TRB2 |
>> |________________|
>> | TRBn |
>> |________________|
>>
>>
>>>>>>
>>>>>> Neither am I. I did try to pad to the dwc_trb structure such that each
>>>>>> trb is 64 bytes in size but this leads to failures when testing. I
>>>>>> didn't get a chance to debug this though. I suspect its because the code
>>>>>> expects the trbs to be contiguous and/or 16 bytes in size.
>>
>> It's not the code but it's the HW.
>
> That'd imply we need either some sort of flushing scheme or non-cachable
> memory allocation. What does Linux do ?
> The dma_alloc_coherent in linux kernel allocates non-cachable memory.
Currently, the code is using local variable trb to flush the cache. When
the first trb is used, dwc3_flush_cache flushes the complete
CACHELINE_SIZE (including the 2nd trb).
When the 2nd trb is used to flush cache, since it is an unaligned flush,
it will issue a warning and will align it to the lower cache line
boundary (flushing the 1st trb in the process).
So with or without this patch, both trbs are getting flushed with every
call. With the patch, we can just avoid misaligned messages by always
flushing using an aligned address.
Thanks,
Faiz
next prev parent reply other threads:[~2017-10-10 10:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-19 11:15 [U-Boot] [PATCH] dwc: ep0: Allocate and flush dwc->ep0_trb in a cache aligned manner Faiz Abbas
2017-10-03 7:35 ` Faiz Abbas
2017-10-03 9:08 ` Andy Shevchenko
2017-10-03 9:43 ` Marek Vasut
2017-10-03 9:58 ` Faiz Abbas
2017-10-03 12:04 ` Marek Vasut
2017-10-03 12:18 ` Dr. Philipp Tomsich
2017-10-03 12:52 ` Marek Vasut
2017-10-03 13:17 ` Faiz Abbas
2017-10-03 13:18 ` Marek Vasut
2017-10-04 10:51 ` Faiz Abbas
2017-10-04 12:31 ` Marek Vasut
2017-10-04 13:11 ` Faiz Abbas
2017-10-05 11:27 ` Marek Vasut
2017-10-06 11:33 ` Faiz Abbas
2017-10-10 5:37 ` Faiz Abbas
2017-10-10 5:48 ` Kishon Vijay Abraham I
2017-10-10 8:00 ` Marek Vasut
2017-10-10 10:45 ` Faiz Abbas [this message]
2017-10-10 13:49 ` Marek Vasut
2017-10-11 8:23 ` Faiz Abbas
2017-10-11 8:58 ` Kishon Vijay Abraham I
2017-10-11 13:23 ` Faiz Abbas
2017-10-03 13:01 ` Marek Vasut
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=3cee6911-e482-cc8c-424d-706be58a14f9@ti.com \
--to=faiz_abbas@ti.com \
--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