All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] usb: dwc3: gadget: make cache-maintenance on event buffers more robust
Date: Tue, 4 Apr 2017 22:09:58 +0200	[thread overview]
Message-ID: <0274b567-62c0-e801-2a6d-779f87c9ab9e@denx.de> (raw)
In-Reply-To: <FBEFF484-8C89-4AFD-8475-CA3E7B1E5DC6@theobroma-systems.com>

On 04/04/2017 09:56 PM, Dr. Philipp Tomsich wrote:
> 
>> On 04 Apr 2017, at 21:01, Marek Vasut <marex@denx.de> wrote:
>>
>>> Good point on the “long”, especially as I just copied this from other occurrences and it’s consistently wrong throughout DWC3 in U-Boot:
>>
>> Hrm, I thought the driver was ported over from Linux, so is this broken
>> in Linux too ?
> 
> Apparently, the dwc3_flush_cache calls (and the function itself) have been
> introduced during the porting. There’s no explicit cache-maintenance in DWC3
> for Linux. 

OK

>>> I’ll revise all of these and make a patch-series out of this.
>>
>> Maybe you should check the Linux first and see if there are some fixes
>> already.
>>
>> Thanks
> 
> Given that this seems to have been introduced with the port to U-Boot, there’s
> no applicable fixes there.

OK

>>>>> 	return evt;
>>>>> }
>>>>>
>>>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>>>>> index 1156662..61af71b 100644
>>>>> --- a/drivers/usb/dwc3/gadget.c
>>>>> +++ b/drivers/usb/dwc3/gadget.c
>>>>> @@ -2668,11 +2668,12 @@ void dwc3_gadget_uboot_handle_interrupt(struct dwc3 *dwc)
>>>>> 		int i;
>>>>> 		struct dwc3_event_buffer *evt;
>>>>>
>>>>> +		dwc3_thread_interrupt(0, dwc);
>>>>> +
>>>>> +		/* Clean + Invalidate the buffers after touching them */
>>>>> 		for (i = 0; i < dwc->num_event_buffers; i++) {
>>>>> 			evt = dwc->ev_buffs[i];
>>>>> 			dwc3_flush_cache((long)evt->buf, evt->length);
>>>>> 		}
>>>>> -
>>>>
>>>> This makes me wonder, don't you need to invalidate the event buffer
>>>> somewhere so that the new data would be fetched from RAM ?
>>>
>>> We flush the event buffer before leaving the function.
>>> So the cache line will not be present in the cache, when we enter this function again.
>>
>> Then shouldn't we invalidate it instead ? flush and invalidate are two
>> different things …
> 
> The DWC3 flush expands to a clean+invalidate. It is not wrong, as long as
> it is used as in my patch:
> a. before the first time data is expected to be written by the peripheral (i.e.
> before the peripheral is started)—to ensure that the cache line is not cached
> any longer…

So invalidate() is enough ?

> b. after the driver modifies any buffers (i.e. anything modified will be written
> back) and before it next reads the buffers expecting possibly changed data
> (i.e. invalidating).

So flush+invalidate ? Keep in mind this driver may not be used on
ARMv7/v8 only ...

-- 
Best regards,
Marek Vasut

  reply	other threads:[~2017-04-04 20:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-03 17:49 [U-Boot] [PATCH] usb: dwc3: gadget: make cache-maintenance on event buffers more robust Philipp Tomsich
2017-04-04 16:15 ` Marek Vasut
2017-04-04 17:46   ` Dr. Philipp Tomsich
2017-04-04 19:01     ` Marek Vasut
2017-04-04 19:56       ` Dr. Philipp Tomsich
2017-04-04 20:09         ` Marek Vasut [this message]
2017-04-04 20:26           ` Dr. Philipp Tomsich
2017-04-05 10:25             ` Marek Vasut
2017-04-05 10:57               ` Dr. Philipp Tomsich
2017-04-05 11:25                 ` Marek Vasut
2017-04-05  8:18       ` Felipe Balbi
2017-04-05  8:33         ` Dr. Philipp Tomsich
2017-04-05  9:49           ` Felipe Balbi
2017-04-05  8:43         ` Marek Vasut
2017-04-05  8:15   ` Felipe Balbi
2017-04-05  8:43     ` Marek Vasut
2017-04-08  6:09 mohammadjannati04

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=0274b567-62c0-e801-2a6d-779f87c9ab9e@denx.de \
    --to=marex@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.