]> git.ipfire.org Git - thirdparty/kernel/stable.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>
Sat, 14 Dec 2024 19:04:07 +0000 (20:04 +0100)
commitf14e63cf8649bd2ae3228fd1a0a1b188f0c194a3
treef7af441865308c410c8709a30bbacb9d7f643feb
parent8a5c06ebc2ee82c681c6d2cefe4cde45caa5e070
usb: chipidea: udc: create bounce buffer for problem sglist entries if possible

[ Upstream commit edfcc455c85ccc5855f0c329ca5a2d85cc9fc6c6 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/chipidea/udc.c
drivers/usb/chipidea/udc.h