drm/gud: Use scatter-gather USB bulk transfer
authorNoralf Trønnes <noralf@tronnes.org>
Thu, 1 Jul 2021 17:07:48 +0000 (19:07 +0200)
committerNoralf Trønnes <noralf@tronnes.org>
Thu, 8 Jul 2021 12:32:32 +0000 (14:32 +0200)
commit2eecd93b743b5611cd3654698794b4d0cefdc9ee
tree0ccbdfa9163126586581fbc44be72e9f39ab35b4
parentf8ac863b6a93863334cefb94285daaa6617381b5
drm/gud: Use scatter-gather USB bulk transfer

There'a limit to how big a kmalloc buffer can be, and as memory gets
fragmented it becomes more difficult to get big buffers. The downside of
smaller buffers is that the driver has to split the transfer up which
hampers performance. Compression might also take a hit because of the
splitting.

Solve this by allocating the transfer buffer using vmalloc and create a
SG table to be passed on to the USB subsystem. vmalloc_32() is used to
avoid DMA bounce buffers on USB controllers that can only access 32-bit
addresses.

This also solves the problem that split transfers can give host side
tearing since flushing is decoupled from rendering.

usb_sg_wait() doesn't have timeout handling builtin, so it is wrapped in
a timer like 4 out of 6 users in the kernel have done.

v2:
- Use DIV_ROUND_UP (Linus)
- Add timeout note to the commit log (Linus)
- Expand note about upper buffer limit (Linus)
- Change var name s/timer/ctx/ in gud_usb_bulk_timeout()

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210701170748.58009-2-noralf@tronnes.org
drivers/gpu/drm/gud/gud_drv.c
drivers/gpu/drm/gud/gud_internal.h
drivers/gpu/drm/gud/gud_pipe.c