From mboxrd@z Thu Jan 1 00:00:00 1970 From: Felipe Balbi Date: Wed, 05 Apr 2017 11:15:32 +0300 Subject: [U-Boot] [PATCH] usb: dwc3: gadget: make cache-maintenance on event buffers more robust In-Reply-To: <8bb1f19c-a7f5-bbc8-3a0d-6c2de73a7410@denx.de> References: <1491241798-37084-1-git-send-email-philipp.tomsich@theobroma-systems.com> <8bb1f19c-a7f5-bbc8-3a0d-6c2de73a7410@denx.de> Message-ID: <87zifvgti3.fsf@linux.intel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, Marek Vasut 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. >> 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 -- balbi