arm: Round the dma_alloc_coherent memory size to cache line aligned
authorYe Li <ye.li@nxp.com>
Fri, 4 Jan 2019 09:24:14 +0000 (09:24 +0000)
committerTom Rini <trini@konsulko.com>
Wed, 9 Jan 2019 12:13:31 +0000 (07:13 -0500)
commit9d47d1316da6585bbafe141e42bbdcdfd562bc71
tree76ae95054759fcb457413c736d328e743e60f91b
parentf3ccba3e4ee8a33869c54627331b032a334d18ac
arm: Round the dma_alloc_coherent memory size to cache line aligned

When running usb dwc3 gadget driver, we meet random USB enumeration failure in fastboot.
The root cause is a cache coherence issue. When it happens, the ctrl_req in
gadget driver is allocated at 0xfe932f40, and the usb_composite_dev (cdev)
is allocated at 0xfe932f60. So after we submit the setup request (cache flushed) to USB
controller, any accessing to usb_composite_dev variable will cause the cache line refill, then
when setup transfer is completed, reading the setup data in ctrl_req will gets old value from
cache not from memory.

The ctrl_req is allocated by API dma_alloc_coherent, but u-boot don't have cohernet memory.
so it still needs cache maintain operations before/after HW accessing. Since the cache flush or
invalidate bases on cache line, so when the allocated memory size is not cache line aligned,
potentially it may meet such issue.

This patch modifies the dma_alloc_coherent API to round the size to cache line aligned.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
arch/arm/include/asm/dma-mapping.h