diff options
author | Vitaly Andrianov <vitalya@ti.com> | 2016-03-04 10:36:46 -0500 |
---|---|---|
committer | Sam Nelson <sam.nelson@ti.com> | 2016-03-15 12:05:17 -0400 |
commit | 8df44102413c2d653341c5b7e6caee882e206d8c (patch) | |
tree | 4f62c6a38b19c99931a984040b521ea20b89c18c | |
parent | 00241c45f810c8b8e4f5ac66c3323fec8e43b621 (diff) | |
download | linuxutils-8df44102413c2d653341c5b7e6caee882e206d8c.tar.gz |
ks2: set dma_pfn_offset for keystone2 devices4.10.02.064.10.02.05_eng
On kestone2 SOC where aliased memory is being used dma_alloc_coherent()
cannot be called with pointer to device set to NULL. The real
"struct device" has to be used. And the dma_pfn_offset has to be set
correctly. Otherwise the function returns wrong dma address.
This commit adds the cmem_cma_dev_0 pointer, which is set by
device_create(). It sets the correct coherent_dma_mask and dma_pfn_offset
for this device.
Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
-rw-r--r-- | src/cmem/module/cmemk.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/cmem/module/cmemk.c b/src/cmem/module/cmemk.c index da0a45c..d7692fb 100644 --- a/src/cmem/module/cmemk.c +++ b/src/cmem/module/cmemk.c @@ -228,7 +228,9 @@ static int cmem_cma_npools = 0; static int cmem_cma_heapsize = 0; static struct device *cmem_cma_dev; static struct pool_object *cmem_cma_p_objs; - +#if IS_ENABLED(CONFIG_ARCH_KEYSTONE) && IS_ENABLED(CONFIG_ARM_LPAE) +static struct device *cmem_cma_dev_0; +#endif #endif /* @@ -1153,7 +1155,11 @@ static long ioctl(struct file *filp, unsigned int cmd, unsigned long args) if (cmem_cma_heapsize == 0) { __D("no explicit CMEM CMA heap, using global area\n"); +#if IS_ENABLED(CONFIG_ARCH_KEYSTONE) && IS_ENABLED(CONFIG_ARM_LPAE) + dev = cmem_cma_dev_0; +#else dev = NULL; +#endif } else { dev = &cmem_cma_dev[heap_pool[bi]]; @@ -2326,8 +2332,15 @@ int __init cmem_init(void) goto fail_after_reg; } - device_create(cmem_class, NULL, MKDEV(cmem_major, 0), NULL, "cmem"); +#if IS_ENABLED(CONFIG_ARCH_KEYSTONE) && IS_ENABLED(CONFIG_ARM_LPAE) + cmem_cma_dev_0 = device_create(cmem_class, NULL, MKDEV(cmem_major, 0), + NULL, "cmem"); + cmem_cma_dev_0->coherent_dma_mask = DMA_BIT_MASK(32); + cmem_cma_dev_0->dma_pfn_offset = 0x780000UL; +#else + device_create(cmem_class, NULL, MKDEV(cmem_major, 0), NULL, "cmem"); +#endif for (bi = 0; bi < NBLOCKS; bi++) { if (!block_start[bi] || !block_end[bi]) { if (bi != 0) { @@ -2454,7 +2467,9 @@ int __init cmem_init(void) p_objs[NBLOCKS][i].numbufs = cmem_cma_p_objs[i].numbufs; cmem_cma_dev[i].coherent_dma_mask = DMA_BIT_MASK(32); - +#if IS_ENABLED(CONFIG_ARCH_KEYSTONE) && IS_ENABLED(CONFIG_ARM_LPAE) + cmem_cma_dev[i].dma_pfn_offset = 0x780000UL; +#endif __D(" pool %d: size=%#llx numbufs=%d\n", i, p_objs[NBLOCKS][i].size, p_objs[NBLOCKS][i].numbufs); } |