dwc_otg: constrain endpoint max packet and transfer size on split IN
authorJonathan Bell <jonathan@raspberrypi.org>
Tue, 7 Jan 2020 10:08:19 +0000 (10:08 +0000)
committerPhil Elwell <pelwell@users.noreply.github.com>
Mon, 13 Jan 2020 17:31:35 +0000 (17:31 +0000)
commitdd1494a4c54ed0bd8c1225457216ebad9467e5a7
tree24ddf0c3b73a1e14780d4b5bc8240e7961368543
parent767722747b98c2d57425f984da2a8192ae30cc69
dwc_otg: constrain endpoint max packet and transfer size on split IN

The hcd would unconditionally set the transfer length to the endpoint
packet size for non-isoc IN transfers. If the remaining buffer length
was less than the length of returned data, random memory would get
scribbled over, with bad effects if it crossed a page boundary.

Force a babble error if this happens by limiting the max transfer size
to the available buffer space. DMA will stop writing to memory on a
babble condition.

The hardware expects xfersize to be an integer multiple of maxpacket
size, so override hcchar.b.mps as well.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
drivers/usb/host/dwc_otg/dwc_otg_hcd.c