From: CMY Date: Tue, 23 Dec 2014 09:51:27 +0000 (+0800) Subject: rk: ion: ion's heap id order by heap type X-Git-Tag: firefly_0821_release~4369 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=be6254128bfdf72529dd91b6ade1e07b7d722c15;p=firefly-linux-kernel-4.4.55.git rk: ion: ion's heap id order by heap type need update android, including: hardware/rk29/libgralloc_ump/ hardware/rk29/camera/ external/rk-pcba-test/ --- diff --git a/arch/arm/boot/dts/rk3036.dtsi b/arch/arm/boot/dts/rk3036.dtsi index 0f885bea42d2..64f4f0182f4f 100755 --- a/arch/arm/boot/dts/rk3036.dtsi +++ b/arch/arm/boot/dts/rk3036.dtsi @@ -638,14 +638,14 @@ #address-cells = <1>; #size-cells = <0>; - ion_cma: rockchip,ion-heap@1 { /* CMA HEAP */ + ion_cma: rockchip,ion-heap@4 { /* CMA HEAP */ compatible = "rockchip,ion-heap"; - rockchip,ion_heap = <1>; + rockchip,ion_heap = <4>; reg = <0x00000000 0x00000000>; /* 0MB */ }; - rockchip,ion-heap@3 { /* VMALLOC HEAP */ + rockchip,ion-heap@0 { /* VMALLOC HEAP */ compatible = "rockchip,ion-heap"; - rockchip,ion_heap = <3>; + rockchip,ion_heap = <0>; }; }; diff --git a/arch/arm/boot/dts/rk312x.dtsi b/arch/arm/boot/dts/rk312x.dtsi index 062f7df90ac1..b39e094dc4ca 100755 --- a/arch/arm/boot/dts/rk312x.dtsi +++ b/arch/arm/boot/dts/rk312x.dtsi @@ -931,14 +931,14 @@ #address-cells = <1>; #size-cells = <0>; - ion_cma: rockchip,ion-heap@1 { /* CMA HEAP */ + ion_cma: rockchip,ion-heap@4 { /* CMA HEAP */ compatible = "rockchip,ion-heap"; - rockchip,ion_heap = <1>; + rockchip,ion_heap = <4>; reg = <0x00000000 0x800000>; /* 8MB */ }; - rockchip,ion-heap@3 { /* VMALLOC HEAP */ + rockchip,ion-heap@0 { /* VMALLOC HEAP */ compatible = "rockchip,ion-heap"; - rockchip,ion_heap = <3>; + rockchip,ion_heap = <0>; }; }; cif: cif@1010a000 { diff --git a/arch/arm/boot/dts/rk3288-fpga.dts b/arch/arm/boot/dts/rk3288-fpga.dts index bca81c030d9a..5eee1dd814e5 100755 --- a/arch/arm/boot/dts/rk3288-fpga.dts +++ b/arch/arm/boot/dts/rk3288-fpga.dts @@ -265,14 +265,14 @@ compatible = "rockchip,ion"; #address-cells = <1>; #size-cells = <0>; - ion_cma: rockchip,ion-heap@1 { /* CMA HEAP */ + ion_cma: rockchip,ion-heap@4 { /* CMA HEAP */ compatible = "rockchip,ion-heap"; - rockchip,ion_heap = <1>; + rockchip,ion_heap = <4>; reg = <0x00000000 0x04000000>; /* 64MB */ }; - rockchip,ion-heap@3 { /* VMALLOC HEAP */ + rockchip,ion-heap@0 { /* VMALLOC HEAP */ compatible = "rockchip,ion-heap"; - rockchip,ion_heap = <3>; + rockchip,ion_heap = <0>; }; }; diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi index 742d12a890a6..a1d7c4bde5db 100755 --- a/arch/arm/boot/dts/rk3288.dtsi +++ b/arch/arm/boot/dts/rk3288.dtsi @@ -978,14 +978,14 @@ #address-cells = <1>; #size-cells = <0>; - ion_cma: rockchip,ion-heap@1 { /* CMA HEAP */ + ion_cma: rockchip,ion-heap@4 { /* CMA HEAP */ compatible = "rockchip,ion-heap"; - rockchip,ion_heap = <1>; + rockchip,ion_heap = <4>; reg = <0x00000000 0x28000000>; /* 640MB */ }; - rockchip,ion-heap@3 { /* VMALLOC HEAP */ + rockchip,ion-heap@0 { /* VMALLOC HEAP */ compatible = "rockchip,ion-heap"; - rockchip,ion_heap = <3>; + rockchip,ion_heap = <0>; }; }; diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index bde5f6eeb087..369cfe68e82a 100755 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -807,7 +807,7 @@ int ion_map_iommu(struct device *iommu_dev, struct ion_client *client, mutex_lock(&buffer->lock); - if (ION_IS_CACHED(buffer->flags)) { + if (ion_buffer_cached(buffer)) { pr_err("%s: Cannot map iommu as cached.\n", __func__); ret = -EINVAL; goto out; diff --git a/drivers/staging/android/ion/rockchip/rockchip_ion.c b/drivers/staging/android/ion/rockchip/rockchip_ion.c index cb957f9506a0..34fb2cbb5cfd 100755 --- a/drivers/staging/android/ion/rockchip/rockchip_ion.c +++ b/drivers/staging/android/ion/rockchip/rockchip_ion.c @@ -45,7 +45,14 @@ extern struct ion_handle *ion_handle_get_by_id(struct ion_client *client, int id); extern int ion_handle_put(struct ion_handle *handle); +#define ION_CMA_HEAP_NAME "cma" +#define ION_IOMMU_HEAP_NAME "iommu" +#define ION_VMALLOC_HEAP_NAME "vmalloc" +#define ION_DRM_HEAP_NAME "drm" +#define ION_CARVEOUT_HEAP_NAME "carveout" + #define MAX_ION_HEAP 10 + static struct ion_platform_heap ion_plat_heap[MAX_ION_HEAP]; struct ion_platform_data ion_pdata = { .nr = 0, @@ -112,10 +119,6 @@ static long rockchip_custom_ioctl (struct ion_client *client, unsigned int cmd, pr_debug("[%s %d] cmd=%X\n", __func__, __LINE__, cmd); switch (cmd) { - case ION_IOC_CLEAN_CACHES: - case ION_IOC_INV_CACHES: - case ION_IOC_CLEAN_INV_CACHES: - break; case ION_IOC_GET_PHYS: { struct ion_phys_data data; @@ -139,47 +142,6 @@ static long rockchip_custom_ioctl (struct ion_client *client, unsigned int cmd, return -EFAULT; break; } - case ION_IOC_GET_SHARE_ID: - { - struct ion_share_id_data data; - struct dma_buf *dmabuf = NULL; - - if (copy_from_user(&data, (void __user *)arg, - sizeof(struct ion_share_id_data))) - return -EFAULT; - - dmabuf = dma_buf_get(data.fd); - if (IS_ERR(dmabuf)) - return PTR_ERR(dmabuf); - - data.id = (unsigned int)dmabuf; -// dma_buf_put(dmabuf); - - if (copy_to_user((void __user *)arg, &data, sizeof(struct ion_share_id_data))) - return -EFAULT; - - break; - } - case ION_IOC_SHARE_BY_ID: - { - struct ion_share_id_data data; - int fd = 0; - - if (copy_from_user(&data, (void __user *)arg, - sizeof(struct ion_share_id_data))) - return -EFAULT; - - fd = dma_buf_fd((struct dma_buf*)data.id, O_CLOEXEC); - if (fd < 0) - return fd; - - data.fd = fd; - - if (copy_to_user((void __user *)arg, &data, sizeof(struct ion_share_id_data))) - return -EFAULT; - - break; - } default: return -ENOTTY; } diff --git a/include/linux/rockchip_ion.h b/include/linux/rockchip_ion.h index 7ce449dea2b4..59d6bf7ce53f 100644 --- a/include/linux/rockchip_ion.h +++ b/include/linux/rockchip_ion.h @@ -22,96 +22,32 @@ #include #endif -#define ROCKCHIP_ION_VERSION "v1.0" +#define ROCKCHIP_ION_VERSION "v1.1" +/* + * ion_heap_ids order by ion_heap_type + */ enum ion_heap_ids { - INVALID_HEAP_ID = -1, - ION_CMA_HEAP_ID = 1, - ION_IOMMU_HEAP_ID, - ION_VMALLOC_HEAP_ID, - ION_DRM_HEAP_ID, - ION_CARVEOUT_HEAP_ID, - - ION_HEAP_ID_RESERVED = 31 + ION_VMALLOC_HEAP_ID = 0, + ION_CARVEOUT_HEAP_ID = 2, + ION_CMA_HEAP_ID = 4, + ION_DRM_HEAP_ID = 5, }; #define ION_HEAP(bit) (1 << (bit)) -#define ION_CMA_HEAP_NAME "cma" -#define ION_IOMMU_HEAP_NAME "iommu" -#define ION_VMALLOC_HEAP_NAME "vmalloc" -#define ION_DRM_HEAP_NAME "drm" -#define ION_CARVEOUT_HEAP_NAME "carveout" - -#define ION_SET_CACHED(__cache) (__cache | ION_FLAG_CACHED) -#define ION_SET_UNCACHED(__cache) (__cache & ~ION_FLAG_CACHED) -#define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED) - -/* struct ion_flush_data - data passed to ion for flushing caches - * - * @handle: handle with data to flush - * @fd: fd to flush - * @vaddr: userspace virtual address mapped with mmap - * @offset: offset into the handle to flush - * @length: length of handle to flush - * - * Performs cache operations on the handle. If p is the start address - * of the handle, p + offset through p + offset + length will have - * the cache operations performed - */ -struct ion_flush_data { - ion_user_handle_t handle; - int fd; - void *vaddr; - unsigned int offset; - unsigned int length; -}; - struct ion_phys_data { ion_user_handle_t handle; unsigned long phys; unsigned long size; }; -struct ion_share_id_data { - int fd; - unsigned int id; -}; - #define ION_IOC_ROCKCHIP_MAGIC 'R' -/** - * Clean the caches of the handle specified. - */ -#define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_ROCKCHIP_MAGIC, 0, \ - struct ion_flush_data) -/** - * Invalidate the caches of the handle specified. - */ -#define ION_IOC_INV_CACHES _IOWR(ION_IOC_ROCKCHIP_MAGIC, 1, \ - struct ion_flush_data) -/** - * Clean and invalidate the caches of the handle specified. - */ -#define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_ROCKCHIP_MAGIC, 2, \ - struct ion_flush_data) - /** * Get phys addr of the handle specified. */ -#define ION_IOC_GET_PHYS _IOWR(ION_IOC_ROCKCHIP_MAGIC, 3, \ +#define ION_IOC_GET_PHYS _IOWR(ION_IOC_ROCKCHIP_MAGIC, 0, \ struct ion_phys_data) -/** - * Get share object of the fd specified. - */ -#define ION_IOC_GET_SHARE_ID _IOWR(ION_IOC_ROCKCHIP_MAGIC, 4, \ - struct ion_share_id_data) - -/** - * Set share object and associate new fd. - */ -#define ION_IOC_SHARE_BY_ID _IOWR(ION_IOC_ROCKCHIP_MAGIC, 5, \ - struct ion_share_id_data) - #endif