mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-13 14:53:06 +00:00
9d47d1316d
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>
36 lines
831 B
C
36 lines
831 B
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* (C) Copyright 2007
|
|
* Stelian Pop <stelian@popies.net>
|
|
* Lead Tech Design <www.leadtechdesign.com>
|
|
*/
|
|
#ifndef __ASM_ARM_DMA_MAPPING_H
|
|
#define __ASM_ARM_DMA_MAPPING_H
|
|
|
|
#include <linux/dma-direction.h>
|
|
|
|
#define dma_mapping_error(x, y) 0
|
|
|
|
static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
|
|
{
|
|
*handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, ROUND(len, ARCH_DMA_MINALIGN));
|
|
return (void *)*handle;
|
|
}
|
|
|
|
static inline void dma_free_coherent(void *addr)
|
|
{
|
|
free(addr);
|
|
}
|
|
|
|
static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
|
|
enum dma_data_direction dir)
|
|
{
|
|
return (unsigned long)vaddr;
|
|
}
|
|
|
|
static inline void dma_unmap_single(volatile void *vaddr, size_t len,
|
|
unsigned long paddr)
|
|
{
|
|
}
|
|
|
|
#endif /* __ASM_ARM_DMA_MAPPING_H */
|