From a4e22c6cb9b226c188bcd5f7be3ee69614831bc9 Mon Sep 17 00:00:00 2001 From: "binqi.zhang" Date: Fri, 16 Jun 2017 14:38:58 +0800 Subject: [PATCH] osd: add cma heap for ion PD#146107: osd: add cma heap for ion on Android 8.0 Change-Id: Idf4371fd0dceecc883fd8402a656ed7724be1efd Signed-off-by: binqi.zhang --- arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts | 15 ++-- arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts | 15 ++-- arch/arm64/boot/dts/amlogic/gxl_skt.dts | 15 ++-- arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts | 15 ++-- arch/arm64/boot/dts/amlogic/gxm_skt.dts | 15 ++-- .../amlogic/media/common/ion_dev/dev_ion.c | 74 ++++++++++--------- drivers/amlogic/media/osd/osd_fb.c | 4 +- 7 files changed, 66 insertions(+), 87 deletions(-) diff --git a/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts b/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts index 13ba49c0d671..a151e7f68cb2 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts @@ -62,13 +62,6 @@ reg = <0x0 0x05300000 0x0 0x2000000>; no-map; }; - fb_reserved:linux,meson-fb { - compatible = "shared-dma-pool"; - reusable; - size = <0x0 0x2000000>; - alignment = <0x0 0x400000>; - alloc-ranges = <0x0 0x3e000000 0x0 0x2000000>; - }; //di_reserved:linux,di { // compatible = "amlogic, di-mem"; @@ -85,8 +78,11 @@ }; ion_reserved:linux,ion-dev { - compatible = "amlogic, idev-mem"; - size = <0x0 0x0>; + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000000>; + alignment = <0x0 0x400000>; + alloc-ranges = <0x0 0x3e000000 0x0 0x2000000>; }; /* vdin0 CMA pool */ @@ -681,7 +677,6 @@ meson-fb { compatible = "amlogic, meson-fb"; - memory-region = <&fb_reserved>; dev_name = "meson-fb"; status = "okay"; interrupts = <0 3 1 diff --git a/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts b/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts index 7ba4bc095acc..f888eab97a95 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts @@ -63,13 +63,6 @@ reg = <0x0 0x05300000 0x0 0x2000000>; no-map; }; - fb_reserved:linux,meson-fb { - compatible = "shared-dma-pool"; - reusable; - size = <0x0 0x2000000>; - alignment = <0x0 0x400000>; - alloc-ranges = <0x0 0x7e000000 0x0 0x2000000>; - }; //di_reserved:linux,di { // compatible = "amlogic, di-mem"; @@ -86,8 +79,11 @@ }; ion_reserved:linux,ion-dev { - compatible = "amlogic, idev-mem"; - size = <0x0 0x0>; + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000000>; + alignment = <0x0 0x400000>; + alloc-ranges = <0x0 0x7e000000 0x0 0x2000000>; }; /* vdin0 CMA pool */ @@ -682,7 +678,6 @@ meson-fb { compatible = "amlogic, meson-fb"; - memory-region = <&fb_reserved>; dev_name = "meson-fb"; status = "okay"; interrupts = <0 3 1 diff --git a/arch/arm64/boot/dts/amlogic/gxl_skt.dts b/arch/arm64/boot/dts/amlogic/gxl_skt.dts index 3b225f2ba3d7..8dcc0a5aa123 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_skt.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_skt.dts @@ -62,13 +62,6 @@ reg = <0x0 0x05300000 0x0 0x2000000>; no-map; }; - fb_reserved:linux,meson-fb { - compatible = "shared-dma-pool"; - reusable; - size = <0x0 0x2000000>; - alignment = <0x0 0x400000>; - alloc-ranges = <0x0 0x7e000000 0x0 0x2000000>; - }; //di_reserved:linux,di { // compatible = "amlogic, di-mem"; @@ -85,8 +78,11 @@ }; ion_reserved:linux,ion-dev { - compatible = "amlogic, idev-mem"; - size = <0x0 0x0>; + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000000>; + alignment = <0x0 0x400000>; + alloc-ranges = <0x0 0x7e000000 0x0 0x2000000>; }; /* vdin0 CMA pool */ @@ -674,7 +670,6 @@ meson-fb { compatible = "amlogic, meson-fb"; - memory-region = <&fb_reserved>; dev_name = "meson-fb"; status = "okay"; interrupts = <0 3 1 diff --git a/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts b/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts index 65870f7edac5..88198b1652e8 100644 --- a/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts +++ b/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts @@ -62,13 +62,6 @@ reg = <0x0 0x05300000 0x0 0x2000000>; no-map; }; - fb_reserved:linux,meson-fb { - compatible = "shared-dma-pool"; - reusable; - size = <0x0 0x2000000>; - alignment = <0x0 0x400000>; - alloc-ranges = <0x0 0x7e000000 0x0 0x2000000>; - }; //di_reserved:linux,di { // compatible = "amlogic, di-mem"; @@ -85,8 +78,11 @@ }; ion_reserved:linux,ion-dev { - compatible = "amlogic, idev-mem"; - size = <0x0 0x0>; + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000000>; + alignment = <0x0 0x400000>; + alloc-ranges = <0x0 0x7e000000 0x0 0x2000000>; }; /* vdin0 CMA pool */ @@ -706,7 +702,6 @@ meson-fb { compatible = "amlogic, meson-fb"; - memory-region = <&fb_reserved>; dev_name = "meson-fb"; status = "okay"; interrupts = <0 3 1 diff --git a/arch/arm64/boot/dts/amlogic/gxm_skt.dts b/arch/arm64/boot/dts/amlogic/gxm_skt.dts index d42ca2a561aa..d58e6809c1bf 100644 --- a/arch/arm64/boot/dts/amlogic/gxm_skt.dts +++ b/arch/arm64/boot/dts/amlogic/gxm_skt.dts @@ -63,13 +63,6 @@ reg = <0x0 0x05300000 0x0 0x2000000>; no-map; }; - fb_reserved:linux,meson-fb { - compatible = "shared-dma-pool"; - reusable; - size = <0x0 0x2000000>; - alignment = <0x0 0x400000>; - alloc-ranges = <0x0 0x3e000000 0x0 0x2000000>; - }; //di_reserved:linux,di { // compatible = "amlogic, di-mem"; @@ -86,8 +79,11 @@ }; ion_reserved:linux,ion-dev { - compatible = "amlogic, idev-mem"; - size = <0x0 0x0>; + compatible = "shared-dma-pool"; + reusable; + size = <0x0 0x2000000>; + alignment = <0x0 0x400000>; + alloc-ranges = <0x0 0x3e000000 0x0 0x2000000>; }; /* vdin0 CMA pool */ @@ -608,7 +604,6 @@ meson-fb { compatible = "amlogic, meson-fb"; - /* memory-region = <&fb_reserved>; */ dev_name = "meson-fb"; status = "okay"; interrupts = <0 3 1 diff --git a/drivers/amlogic/media/common/ion_dev/dev_ion.c b/drivers/amlogic/media/common/ion_dev/dev_ion.c index 8b4fbc801770..1940300432e0 100644 --- a/drivers/amlogic/media/common/ion_dev/dev_ion.c +++ b/drivers/amlogic/media/common/ion_dev/dev_ion.c @@ -169,6 +169,7 @@ static long meson_custom_ioctl( int dev_ion_probe(struct platform_device *pdev) { int err = 0; + int i; my_ion_heap[num_heaps].type = ION_HEAP_TYPE_SYSTEM; my_ion_heap[num_heaps].id = ION_HEAP_TYPE_SYSTEM; @@ -183,20 +184,57 @@ int dev_ion_probe(struct platform_device *pdev) my_ion_heap[num_heaps].size = 32 * 1024 * 1024; num_heaps++; #endif + /*add CMA ion heap*/ + my_ion_heap[num_heaps].type = ION_HEAP_TYPE_DMA; + my_ion_heap[num_heaps].id = ION_HEAP_TYPE_DMA; + my_ion_heap[num_heaps].name = "cma_ion"; + my_ion_heap[num_heaps].priv = &pdev->dev; + num_heaps++; + /* init reserved memory */ err = of_reserved_mem_device_init(&pdev->dev); if (err != 0) dprintk(1, "failed get reserved memory\n"); + heaps = kcalloc(num_heaps, sizeof(struct ion_heap *), GFP_KERNEL); + if (!heaps) + return -ENOMEM; + /* idev = ion_device_create(NULL); */ + idev = ion_device_create(meson_custom_ioctl); + if (IS_ERR_OR_NULL(idev)) { + kfree(heaps); + panic(0); + return PTR_ERR(idev); + } + platform_set_drvdata(pdev, idev); + + /* create the heaps as specified in the board file */ + for (i = 0; i < num_heaps; i++) { + heaps[i] = ion_heap_create(&my_ion_heap[i]); + if (IS_ERR_OR_NULL(heaps[i])) { + err = PTR_ERR(heaps[i]); + goto failed; + } + ion_device_add_heap(idev, heaps[i]); + dprintk(2, "add heap type:%d id:%d\n", + my_ion_heap[i].type, my_ion_heap[i].id); + } + + dprintk(1, "%s, create %d heaps\n", __func__, num_heaps); return 0; +failed: + dprintk(0, "ion heap create failed\n"); + kfree(heaps); + heaps = NULL; + panic(0); + return err; } int dev_ion_remove(struct platform_device *pdev) { struct ion_device *idev = platform_get_drvdata(pdev); int i; - ion_device_destroy(idev); for (i = 0; i < num_heaps; i++) ion_heap_destroy(heaps[i]); @@ -224,9 +262,6 @@ static struct platform_driver ion_driver = { */ static int ion_dev_mem_init(struct reserved_mem *rmem, struct device *dev) { - int i = 0; - int err; - struct platform_device *pdev = to_platform_device(dev); my_ion_heap[num_heaps].type = ION_HEAP_TYPE_CARVEOUT; my_ion_heap[num_heaps].id = ION_HEAP_TYPE_CARVEOUT; @@ -235,41 +270,10 @@ static int ion_dev_mem_init(struct reserved_mem *rmem, struct device *dev) my_ion_heap[num_heaps].size = rmem->size; pr_info("ion_dev_mem_init size=0x%llx\n", rmem->size); - num_heaps++; - heaps = kcalloc(num_heaps, sizeof(struct ion_heap *), GFP_KERNEL); - /* idev = ion_device_create(NULL); */ - idev = ion_device_create(meson_custom_ioctl); - if (IS_ERR_OR_NULL(idev)) { - kfree(heaps); - panic(0); - return PTR_ERR(idev); - } - - platform_set_drvdata(pdev, idev); - - /* create the heaps as specified in the board file */ - for (i = 0; i < num_heaps; i++) { - heaps[i] = ion_heap_create(&my_ion_heap[i]); - if (IS_ERR_OR_NULL(heaps[i])) { - err = PTR_ERR(heaps[i]); - goto failed; - } - ion_device_add_heap(idev, heaps[i]); - dprintk(2, "add heap type:%d id:%d\n", - my_ion_heap[i].type, my_ion_heap[i].id); - } - - dprintk(1, "%s, create %d heaps\n", __func__, num_heaps); return 0; -failed: - dprintk(0, "ion heap create failed\n"); - kfree(heaps); - heaps = NULL; - panic(0); - return err; } diff --git a/drivers/amlogic/media/osd/osd_fb.c b/drivers/amlogic/media/osd/osd_fb.c index 0ab9e28295e2..065fdb03d4e0 100644 --- a/drivers/amlogic/media/osd/osd_fb.c +++ b/drivers/amlogic/media/osd/osd_fb.c @@ -1157,7 +1157,7 @@ static int osd_open(struct fb_info *info, int arg) PAGE_ALIGN(fb_memsize[fb_index + 1]/ OSD_MAX_BUF_NUM), 0, - (1 << ION_HEAP_TYPE_CARVEOUT), + (1 << ION_HEAP_TYPE_DMA), 0); ret = ion_phys(fb_ion_client, fb_ion_handle[fb_index][j], @@ -1206,7 +1206,7 @@ static int osd_open(struct fb_info *info, int arg) ion_alloc(fb_ion_client, fb_memsize[fb_index + 1], 0, - (1 << ION_HEAP_TYPE_CARVEOUT), + (1 << ION_HEAP_TYPE_DMA), 0); ret = ion_phys(fb_ion_client, fb_ion_handle[fb_index][0],