[U-Boot] [PATCH] usb: dwc3: gadget: make cache-maintenance on event buffers more robust

Marek Vasut marex at denx.de
Wed Apr 5 08:43:12 UTC 2017


On 04/05/2017 10:15 AM, Felipe Balbi wrote:
> 
> Hi,
> 
> Marek Vasut <marex at denx.de> writes:
>>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>>> index b2c7eb1..f58c7ba 100644
>>> --- a/drivers/usb/dwc3/core.c
>>> +++ b/drivers/usb/dwc3/core.c
>>> @@ -125,6 +125,8 @@ static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
>>>  	if (!evt->buf)
>>>  		return ERR_PTR(-ENOMEM);
>>>  
>>> +	dwc3_flush_cache((long)evt->buf, evt->length);
>>> +
>>
>> Is the length aligned ? If not, you will get cache alignment warning.
>> Also, address should be uintptr_t to avoid 32/64 bit issues .
> 
> if it's not aligned to 128 bits (at least, IIRC), DWC3 won't work.

So this is already implicitly aligned, cool.

>>> 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 ?
> 
> nope. In linux we allocate from coherent

Got it , thanks.

-- 
Best regards,
Marek Vasut


More information about the U-Boot mailing list