u-boot-dfu-20241017

CI: https://source.denx.de/u-boot/custodians/u-boot-dfu/-/pipelines/22742

Usb Gadget:
- Fix cdns3 endpoint configuration by setting maxpacket
- Fix dwc3 cache handling when using DMA

Fastboot:
- Make AVB_VERIFY depends on FASTBOOT
This commit is contained in:
Tom Rini 2024-10-17 08:34:01 -06:00
commit d17661a5ff
6 changed files with 33 additions and 7 deletions

View File

@ -850,6 +850,7 @@ config AVB_VERIFY
depends on LIBAVB
depends on MMC
depends on PARTITION_UUIDS
depends on FASTBOOT
help
This option enables compilation of bootloader-dependent operations,
used by Android Verified Boot 2.0 library (libavb). Includes:

View File

@ -1637,6 +1637,14 @@ void cdns3_ep_config(struct cdns3_endpoint *priv_ep)
else
priv_ep->trb_burst_size = 16;
/*
* The Endpoint is configured to handle a maximum packet size of
* max_packet_size. Hence, set priv_ep->endpoint.maxpacket to
* max_packet_size. This is necessary to ensure that the TD_SIZE
* is calculated correctly in cdns3_ep_run_transfer().
*/
priv_ep->endpoint.maxpacket = max_packet_size;
ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1,
!!priv_ep->dir);
if (ret) {

View File

@ -670,6 +670,7 @@ struct dwc3_scratchpad_array {
* @ep0_trb: dma address of ep0_trb
* @ep0_usb_req: dummy req used while handling STD USB requests
* @ep0_bounce_addr: dma address of ep0_bounce
* @setup_buf_addr: dma address of setup_buf
* @scratch_addr: dma address of scratchbuf
* @lock: for synchronizing
* @dev: pointer to our struct device
@ -757,6 +758,7 @@ struct dwc3 {
dma_addr_t ep0_trb_addr;
dma_addr_t ep0_bounce_addr;
dma_addr_t scratch_addr;
dma_addr_t setup_buf_addr;
struct dwc3_request ep0_usb_req;
/* device lock */

View File

@ -380,7 +380,7 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc,
dep = dwc->eps[0];
dwc->ep0_usb_req.dep = dep;
dwc->ep0_usb_req.request.length = sizeof(*response_pkt);
dwc->ep0_usb_req.request.buf = dwc->setup_buf;
dwc->ep0_usb_req.request.buf = (void *)dwc->setup_buf_addr;
dwc->ep0_usb_req.request.complete = dwc3_ep0_status_cmpl;
return __dwc3_gadget_ep0_queue(dep, &dwc->ep0_usb_req);
@ -662,7 +662,7 @@ static int dwc3_ep0_set_sel(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
dep = dwc->eps[0];
dwc->ep0_usb_req.dep = dep;
dwc->ep0_usb_req.request.length = dep->endpoint.maxpacket;
dwc->ep0_usb_req.request.buf = dwc->setup_buf;
dwc->ep0_usb_req.request.buf = (void *)dwc->setup_buf_addr;
dwc->ep0_usb_req.request.complete = dwc3_ep0_set_sel_cmpl;
return __dwc3_gadget_ep0_queue(dep, &dwc->ep0_usb_req);
@ -742,6 +742,8 @@ static void dwc3_ep0_inspect_setup(struct dwc3 *dwc,
if (!dwc->gadget_driver)
goto out;
dwc3_invalidate_cache((uintptr_t)ctrl, sizeof(*ctrl));
len = le16_to_cpu(ctrl->wLength);
if (!len) {
dwc->three_stage_setup = false;

View File

@ -2534,6 +2534,8 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf)
while (left > 0) {
union dwc3_event event;
dwc3_invalidate_cache((uintptr_t)evt->buf, evt->length);
event.raw = *(u32 *) (evt->buf + evt->lpos);
dwc3_process_event_entry(dwc, &event);
@ -2653,8 +2655,8 @@ int dwc3_gadget_init(struct dwc3 *dwc)
goto err1;
}
dwc->setup_buf = memalign(CONFIG_SYS_CACHELINE_SIZE,
DWC3_EP0_BOUNCE_SIZE);
dwc->setup_buf = dma_alloc_coherent(DWC3_EP0_BOUNCE_SIZE,
(unsigned long *)&dwc->setup_buf_addr);
if (!dwc->setup_buf) {
ret = -ENOMEM;
goto err2;
@ -2701,7 +2703,7 @@ err4:
dma_free_coherent(dwc->ep0_bounce);
err3:
kfree(dwc->setup_buf);
dma_free_coherent(dwc->setup_buf);
err2:
dma_free_coherent(dwc->ep0_trb);
@ -2723,7 +2725,7 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
dma_free_coherent(dwc->ep0_bounce);
kfree(dwc->setup_buf);
dma_free_coherent(dwc->setup_buf);
dma_free_coherent(dwc->ep0_trb);

View File

@ -50,6 +50,17 @@ static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
static inline void dwc3_flush_cache(uintptr_t addr, int length)
{
flush_dcache_range(addr, addr + ROUND(length, CACHELINE_SIZE));
uintptr_t start_addr = (uintptr_t)addr & ~(CACHELINE_SIZE - 1);
uintptr_t end_addr = ALIGN((uintptr_t)addr + length, CACHELINE_SIZE);
flush_dcache_range((unsigned long)start_addr, (unsigned long)end_addr);
}
static inline void dwc3_invalidate_cache(uintptr_t addr, int length)
{
uintptr_t start_addr = (uintptr_t)addr & ~(CACHELINE_SIZE - 1);
uintptr_t end_addr = ALIGN((uintptr_t)addr + length, CACHELINE_SIZE);
invalidate_dcache_range((unsigned long)start_addr, (unsigned long)end_addr);
}
#endif /* __DRIVERS_USB_DWC3_IO_H */