Skip to content

Commit 6cf0829

Browse files
MarkWangChinesenashif
authored andcommitted
drivers: usb: uhc: mcux: Improve setup noncache buffer allocation
Only allocate nocache setup packet buffer for control endpoint (EP0). Signed-off-by: Mark Wang <[email protected]>
1 parent 7ea8992 commit 6cf0829

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/usb/uhc/uhc_mcux_ehci.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,17 @@ static usb_host_transfer_t *uhc_mcux_hal_init_transfer(const struct device *dev,
197197
(void)uhc_mcux_hal_init_transfer_common(dev, mcux_xfer, mcux_ep_handle, xfer,
198198
uhc_mcux_transfer_callback);
199199
#if defined(CONFIG_NOCACHE_MEMORY)
200-
mcux_xfer->setupPacket = uhc_mcux_nocache_alloc(8u);
201-
memcpy(mcux_xfer->setupPacket, xfer->setup_pkt, 8u);
200+
if (USB_EP_GET_IDX(xfer->ep) == 0) {
201+
mcux_xfer->setupPacket = uhc_mcux_nocache_alloc(8u);
202+
if (mcux_xfer->setupPacket == NULL) {
203+
k_mem_slab_free(&mcux_uhc_transfer_pool, mcux_xfer);
204+
return NULL;
205+
}
206+
207+
memcpy(mcux_xfer->setupPacket, xfer->setup_pkt, 8u);
208+
} else {
209+
mcux_xfer->setupPacket = NULL;
210+
}
202211

203212
if (mcux_xfer->transferBuffer != NULL && mcux_xfer->transferLength != 0) {
204213
uint8_t *nocache_buf = uhc_mcux_nocache_alloc(mcux_xfer->transferLength);

0 commit comments

Comments
 (0)