]> www.infradead.org Git - users/jedix/linux-maple.git/commit
usb: chipidea: udc: create bounce buffer for problem sglist entries if possible
authorXu Yang <xu.yang_2@nxp.com>
Mon, 23 Sep 2024 08:12:03 +0000 (16:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 13:13:58 +0000 (15:13 +0200)
commitedfcc455c85ccc5855f0c329ca5a2d85cc9fc6c6
tree4076d396d8736fe1e11b173483167ad78401660c
parentca8d18aa7b0f22d66a3ca9a90d8f73431b8eca89
usb: chipidea: udc: create bounce buffer for problem sglist entries if possible

The chipidea controller doesn't fully support sglist, such as it can not
transfer data spanned more dTDs to form a bus packet, so it can only work
on very limited cases.

The limitations as below:
1. the end address of the first sg buffer must be 4KB aligned.
2. the start and end address of the middle sg buffer must be 4KB aligned.
3. the start address of the first sg buffer must be 4KB aligned.

However, not all the use cases violate these limitations. To make the
controller compatible with most of the cases, this will try to bounce the
problem sglist entries which can be found by sglist_get_invalid_entry().
Then a bounced line buffer (the size will roundup to page size) will be
allocated to replace the remaining problem sg entries. The data will be
copied between problem sg entries and bounce buffer according to the
transfer direction. The bounce buffer will be freed when the request
completed.

Acked-by: Peter Chen <peter.chen@kernel.com>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://lore.kernel.org/r/20240923081203.2851768-3-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/chipidea/udc.c
drivers/usb/chipidea/udc.h