From cbccd93a17b1a1c1ddf89bc322c35322440dad2c Mon Sep 17 00:00:00 2001 From: Sundar Raman Date: Tue, 23 Apr 2013 15:13:33 -0500 Subject: gpu: ion: omap: re-populate flags parameters into buffer Since the flags function param of omap_tiler_heap_allocate is used to pass the omap_tiler_info struct, pass the actual flags param from the client inside omap_tiler_info struct and re-populate it into the buffer struct. Change-Id: I06f3b6125c2760f7b4bcc7f174458139d80ec000 Signed-off-by: Sundar Raman --- drivers/gpu/ion/omap/omap_tiler_heap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/ion/omap/omap_tiler_heap.c b/drivers/gpu/ion/omap/omap_tiler_heap.c index af4988ad212..c3ac4f169c3 100644 --- a/drivers/gpu/ion/omap/omap_tiler_heap.c +++ b/drivers/gpu/ion/omap/omap_tiler_heap.c @@ -55,6 +55,7 @@ struct omap_tiler_info { u32 vsize; /* virtual stride of buffer */ u32 vstride; /* virtual size of buffer */ u32 phys_stride; /* Physical stride of the buffer */ + u32 flags; /* Flags specifying cached or not */ }; static int omap_tiler_heap_allocate(struct ion_heap *heap, @@ -62,6 +63,8 @@ static int omap_tiler_heap_allocate(struct ion_heap *heap, unsigned long size, unsigned long align, unsigned long flags) { + struct omap_tiler_info *info; + /* This means the buffer is already allocated and populated, we're getting here because * of dummy handle creation, so simply return*/ if (size == 0) { @@ -70,7 +73,12 @@ static int omap_tiler_heap_allocate(struct ion_heap *heap, * This will be used later on inside map_dma function to create * the sg list for tiler buffer */ - buffer->priv_virt = (void *)flags; + info = (struct omap_tiler_info *) flags; + if (!info) + pr_err("%s: flags argument is not setup\n", __func__); + buffer->priv_virt = info; + /* Re-update correct flags inside buffer */ + buffer->flags = info->flags; return 0; } @@ -174,6 +182,7 @@ int omap_tiler_alloc(struct ion_heap *heap, info->phys_addrs = (u32 *)(info + 1); info->tiler_addrs = info->phys_addrs + n_phys_pages; info->fmt = data->fmt; + info->flags = data->flags; /* Allocate tiler space FIXME: we only support PAGE_SIZE alignment right now. */ -- cgit v1.2.3-54-g00ecf From 556a225979c47c011034707f49beced49a36829c Mon Sep 17 00:00:00 2001 From: Sundar Raman Date: Fri, 26 Jul 2013 09:50:05 -0500 Subject: gpu: ion: omap: Fix TILER secure heap base address Access to ION TILER buffers were resulting in data aborts because of incorrect heap base address initialization. The omap_ion_heap_tiler_base variable was not being initialized. With this patch the ION tests pass. Change-Id: Ic072767a5b70b1eab37caf0a7fadb96f1da97b34 Signed-off-by: Sundar Raman --- drivers/gpu/ion/omap/omap_ion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/ion/omap/omap_ion.c b/drivers/gpu/ion/omap/omap_ion.c index e9b91f0787d..f3db9d7ca95 100755 --- a/drivers/gpu/ion/omap/omap_ion.c +++ b/drivers/gpu/ion/omap/omap_ion.c @@ -134,7 +134,7 @@ static int omap_ion_probe(struct platform_device *pdev) of_property_read_u32(node, "ti,omap_ion_heap_secure_input_base", &omap_ion_heap_secure_input_base); of_property_read_u32(node, "ti,omap_ion_heap_tiler_base", - &omap_ion_heap_tiler_size); + &omap_ion_heap_tiler_base); of_property_read_u32(node, "ti,omap_ion_heap_nonsecure_tiler_base", &omap_ion_heap_nonsecure_tiler_base); -- cgit v1.2.3-54-g00ecf From 5f1023048e35f0c6d89f0eb83c74866fa2cb54b2 Mon Sep 17 00:00:00 2001 From: Sundar Raman Date: Mon, 3 Jun 2013 13:19:31 -0500 Subject: gpu: ion: omap: add checks for carveout addresses and sizes This patch adds sanity checks on the carveout and size parameters read from the device tree file and returns error. It also checks if the device tree is populated and returns error accordingly. Change-Id: Ic1f4e9d7c5f7e9361d9fe922544f9dbc105d99c3 Signed-off-by: Sundar Raman --- drivers/gpu/ion/omap/omap_ion.c | 42 +++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/ion/omap/omap_ion.c b/drivers/gpu/ion/omap/omap_ion.c index f3db9d7ca95..886dd6f8133 100755 --- a/drivers/gpu/ion/omap/omap_ion.c +++ b/drivers/gpu/ion/omap/omap_ion.c @@ -124,12 +124,6 @@ static int omap_ion_probe(struct platform_device *pdev) uint omap_ion_heap_tiler_size = 0; uint omap_ion_heap_nonsecure_tiler_size = 0; - omap_ion_device = ion_device_create(omap_ion_ioctl); - if (IS_ERR_OR_NULL(omap_ion_device)) { - kfree(heaps); - return PTR_ERR(omap_ion_device); - } - if (node) { of_property_read_u32(node, "ti,omap_ion_heap_secure_input_base", &omap_ion_heap_secure_input_base); @@ -137,6 +131,19 @@ static int omap_ion_probe(struct platform_device *pdev) &omap_ion_heap_tiler_base); of_property_read_u32(node, "ti,omap_ion_heap_nonsecure_tiler_base", &omap_ion_heap_nonsecure_tiler_base); + if (omap_ion_heap_secure_input_base == 0 + || omap_ion_heap_tiler_base == 0 + || omap_ion_heap_nonsecure_tiler_base == 0) { + pr_err("%s: carveout memory address is null. please check dts file\n" + "omap_ion_heap_secure_input_base = 0x%x\n" + "omap_ion_heap_tiler_base = 0x%x\n" + "omap_ion_heap_nonsecure_tiler_base = 0x%x\n" + , __func__ + , omap_ion_heap_secure_input_base + , omap_ion_heap_tiler_base + , omap_ion_heap_tiler_base); + return -EFAULT; + } of_property_read_u32(node, "ti,omap_ion_heap_secure_input_size", &omap_ion_heap_secure_input_size); @@ -144,8 +151,30 @@ static int omap_ion_probe(struct platform_device *pdev) &omap_ion_heap_tiler_size); of_property_read_u32(node, "ti,omap_ion_heap_nonsecure_tiler_size", &omap_ion_heap_nonsecure_tiler_size); + if (omap_ion_heap_secure_input_size == 0 + || omap_ion_heap_tiler_size == 0 + || omap_ion_heap_nonsecure_tiler_size == 0) { + pr_err("%s: carveout memory address is null. please check dts file\n" + "omap_ion_heap_secure_input_size = 0x%x\n" + "omap_ion_heap_tiler_size = 0x%x\n" + "omap_ion_heap_nonsecure_tiler_size = 0x%x\n" + , __func__ + , omap_ion_heap_secure_input_size + , omap_ion_heap_tiler_size + , omap_ion_heap_nonsecure_tiler_size); + return -EINVAL; + } + + } else { + pr_err("%s: no matching device tree node\n", __func__); + return -ENODEV; } + omap_ion_device = ion_device_create(omap_ion_ioctl); + if (IS_ERR_OR_NULL(omap_ion_device)) + return PTR_ERR(omap_ion_device); + + num_heaps = omap_ion_data.nr; heaps = kzalloc(sizeof(struct ion_heap *)*num_heaps, GFP_KERNEL); @@ -242,6 +271,7 @@ int omap_ion_share_fd_to_buffers(int fd, struct ion_buffer **buffers, struct ion_handle **handles; struct ion_client *client; int i = 0, ret = 0; + int share_fd; handles = kzalloc(*num_handles * sizeof(struct ion_handle *), GFP_KERNEL); -- cgit v1.2.3-54-g00ecf From 3d84b522bf60b9dae8215b85f641a690f89fa652 Mon Sep 17 00:00:00 2001 From: Sundar Raman Date: Fri, 26 Jul 2013 09:34:26 -0500 Subject: gpu: ion: fix omap_ion_share_fd_to_buffers api the output value from ion_share_dma_buf is a dma buf fd buffers array was filled mistakenly as the code was ported from k3.4 where the equivalent function ion_share used to return pointer to ion_buffer. updated the code to upref using ion_share_dma_buf() and get the handle to buffer using ion_handle_buffer(). Change-Id: I3bb39f918a9dde8ee78ffa3adcab447589295fdf Signed-off-by: Sundar Raman --- drivers/gpu/ion/omap/omap_ion.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/ion/omap/omap_ion.c b/drivers/gpu/ion/omap/omap_ion.c index 886dd6f8133..df8f3818653 100755 --- a/drivers/gpu/ion/omap/omap_ion.c +++ b/drivers/gpu/ion/omap/omap_ion.c @@ -292,7 +292,8 @@ int omap_ion_share_fd_to_buffers(int fd, struct ion_buffer **buffers, for (i = 0; i < *num_handles; i++) { if (handles[i]) - buffers[i] = ion_share_dma_buf(client, handles[i]); + share_fd = ion_share_dma_buf(client, handles[i]); + buffers[i] = ion_handle_buffer(handles[i]); } exit: -- cgit v1.2.3-54-g00ecf From 7d7ad5311aca079575ef1278ef3812c833d9f775 Mon Sep 17 00:00:00 2001 From: Sundar Raman Date: Mon, 3 Jun 2013 13:32:53 -0500 Subject: ARM: dts: DRA7/OMAP5: reserve carveout buffers & fix carveout size Carveout buffers were initialized but not reserved for DRA7. This patch adds the missing memreserves without which there could be data corruption in highmem region. In addition, the carveout size for TILER secure heap was programmed wrongly to 96MB whereas it should have been 81 MB. This patch fixes this and re-adjusts the carveout base addresses. Change-Id: I151bd37f089aa7fbf590035ea4f612f1da12f53a Signed-off-by: Sundar Raman --- arch/arm/boot/dts/dra7-evm.dts | 12 ++++++++++++ arch/arm/boot/dts/omap5-uevm.dts | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts index 880c57fd40c..b8fd69852d2 100755 --- a/arch/arm/boot/dts/dra7-evm.dts +++ b/arch/arm/boot/dts/dra7-evm.dts @@ -7,6 +7,18 @@ */ /dts-v1/; +/* + * Following are the carveout addresses and the sizes for ION. SMC is not reserved for now + * C0000000 - SDRAM+1G + * BFD00000 - SMC (3MB) + * BA300000 - ION (90MB) + * B4300000 - TILER SECURE (81 MB) + * B3400000 - TILER NONSECURE (15 MB) +*/ +/memreserve/ 0xba300000 0x5a00000; +/memreserve/ 0xb5200000 0x5100000; +/memreserve/ 0xb4300000 0xf00000; + /include/ "dra7.dtsi" / { diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts index a339f321c2a..5694a6fc052 100644 --- a/arch/arm/boot/dts/omap5-uevm.dts +++ b/arch/arm/boot/dts/omap5-uevm.dts @@ -8,16 +8,16 @@ /dts-v1/; /* - * Following are the carveout addresses and the sizes. SMC is not reserved for now + * Following are the carveout addresses and the sizes for ION. SMC is not reserved for now * C0000000 - SDRAM+1G * BFD00000 - SMC (3MB) * BA300000 - ION (90MB) - * B4300000 - TILER SECURE (96 MB) + * B4300000 - TILER SECURE (81 MB) * B3400000 - TILER NONSECURE (15 MB) */ /memreserve/ 0xba300000 0x5a00000; -/memreserve/ 0xb4300000 0x6000000; -/memreserve/ 0xb3400000 0xf00000; +/memreserve/ 0xb5200000 0x5100000; +/memreserve/ 0xb4300000 0xf00000; /include/ "omap5.dtsi" /include/ "samsung_k3pe0e000b.dtsi" -- cgit v1.2.3-54-g00ecf From 473f405fbacba955b461a0f3c4cea09dfdf74980 Mon Sep 17 00:00:00 2001 From: Sundar Raman Date: Thu, 25 Jul 2013 08:43:29 -0500 Subject: gpu: ion: DRA7: ensure TILER 2d mappings are shared device Write combined mappings are not supported for TILER 2D on DRA7 similar to OMAP5 due to h/w issue. So, shared mappings should be used. Added the check which was missing for DRA7. Change-Id: I8ba9bd676f2942dd6a8bd5737bab8e25c8f1cbd3 Signed-off-by: Sundar Raman --- drivers/gpu/ion/omap/omap_tiler_heap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/ion/omap/omap_tiler_heap.c b/drivers/gpu/ion/omap/omap_tiler_heap.c index c3ac4f169c3..cbd16cf6c52 100644 --- a/drivers/gpu/ion/omap/omap_tiler_heap.c +++ b/drivers/gpu/ion/omap/omap_tiler_heap.c @@ -75,7 +75,7 @@ static int omap_tiler_heap_allocate(struct ion_heap *heap, */ info = (struct omap_tiler_info *) flags; if (!info) - pr_err("%s: flags argument is not setup\n", __func__); + pr_err("%s: flags argument is not setupg\n", __func__); buffer->priv_virt = info; /* Re-update correct flags inside buffer */ buffer->flags = info->flags; @@ -339,9 +339,9 @@ static int omap_tiler_heap_map_user(struct ion_heap *heap, int i, ret = 0; pgprot_t vm_page_prot; - /* Use writecombined mappings unless on OMAP5. If OMAP5, use + /* Use writecombined mappings unless on OMAP5 or DRA7. If OMAP5 or DRA7, use shared device due to h/w issue. */ - if (soc_is_omap54xx()) + if (soc_is_omap54xx() || soc_is_dra7xx()) vm_page_prot = __pgprot_modify(vma->vm_page_prot, L_PTE_MT_MASK, L_PTE_MT_DEV_SHARED); else -- cgit v1.2.3-54-g00ecf From 2474b61d8c1d217982a6caa76bea45e95568d5b3 Mon Sep 17 00:00:00 2001 From: Sundar Raman Date: Tue, 23 Apr 2013 17:39:34 -0500 Subject: gpu: ion: add support for more cache operations Enhance ion_sync_for_device to take in cache direction Change-Id: I78bef9c2b5cc461b5f49c6019d031a15ce1a36de Signed-off-by: Sundar Raman --- drivers/gpu/ion/ion.c | 16 ++++++++++++---- include/linux/ion.h | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index 8f477880f04..d7c780ff35b 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -951,7 +951,7 @@ end: } EXPORT_SYMBOL(ion_import_dma_buf); -static int ion_sync_for_device(struct ion_client *client, int fd) +static int ion_sync_for_device(struct ion_client *client, int fd, enum ion_data_direction dir) { struct dma_buf *dmabuf; struct ion_buffer *buffer; @@ -969,8 +969,16 @@ static int ion_sync_for_device(struct ion_client *client, int fd) } buffer = dmabuf->priv; - dma_sync_sg_for_device(NULL, buffer->sg_table->sgl, - buffer->sg_table->nents, DMA_BIDIRECTIONAL); + if(dir == ION_FROM_DEVICE) + dma_sync_sg_for_device(NULL, buffer->sg_table->sgl, + buffer->sg_table->nents, DMA_FROM_DEVICE); + else if(dir == ION_TO_DEVICE) + dma_sync_sg_for_device(NULL, buffer->sg_table->sgl, + buffer->sg_table->nents, DMA_TO_DEVICE); + else if(dir == ION_BIDIRECTIONAL) + dma_sync_sg_for_device(NULL, buffer->sg_table->sgl, + buffer->sg_table->nents, DMA_BIDIRECTIONAL); + dma_buf_put(dmabuf); return 0; } @@ -1053,7 +1061,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) if (copy_from_user(&data, (void __user *)arg, sizeof(struct ion_fd_data))) return -EFAULT; - ion_sync_for_device(client, data.fd); + ion_sync_for_device(client, data.fd, data.dir); break; } case ION_IOC_CUSTOM: diff --git a/include/linux/ion.h b/include/linux/ion.h index a55d11fbcbd..31045a150dc 100644 --- a/include/linux/ion.h +++ b/include/linux/ion.h @@ -41,6 +41,21 @@ enum ion_heap_type { ION_NUM_HEAPS = 16, }; +/** + * enum ion_data_direction - sync operation arguments + * @ION_BIDIRECTIONAL: memory written to & read from device + * @ION_TO_DEVICE: memory going to be transferred to device + * @ION_FROM_DEVICE: memory populated by device + * @ION_NONE: None of the above + */ +enum ion_data_direction { + ION_BIDIRECTIONAL = 0, + ION_TO_DEVICE = 1, + ION_FROM_DEVICE = 2, + ION_NONE = 3, +}; + + #define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM) #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG) #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) @@ -273,6 +288,7 @@ struct ion_allocation_data { struct ion_fd_data { struct ion_handle *handle; int fd; + enum ion_data_direction dir; }; /** -- cgit v1.2.3-54-g00ecf