osd: add cma heap for ion
authorbinqi.zhang <binqi.zhang@amlogic.com>
Fri, 16 Jun 2017 06:38:58 +0000 (14:38 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 21 Jun 2017 03:02:46 +0000 (20:02 -0700)
PD#146107: osd: add cma heap for ion on Android 8.0

Change-Id: Idf4371fd0dceecc883fd8402a656ed7724be1efd
Signed-off-by: binqi.zhang <binqi.zhang@amlogic.com>
arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts
arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts
arch/arm64/boot/dts/amlogic/gxl_skt.dts
arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts
arch/arm64/boot/dts/amlogic/gxm_skt.dts
drivers/amlogic/media/common/ion_dev/dev_ion.c
drivers/amlogic/media/osd/osd_fb.c

index 13ba49c..a151e7f 100644 (file)
                        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";
                };
 
                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 */
 
        meson-fb {
                compatible = "amlogic, meson-fb";
-               memory-region = <&fb_reserved>;
                dev_name = "meson-fb";
                status = "okay";
                interrupts = <0 3 1
index 7ba4bc0..f888eab 100644 (file)
                        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";
                };
 
                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 */
 
        meson-fb {
                compatible = "amlogic, meson-fb";
-               memory-region = <&fb_reserved>;
                dev_name = "meson-fb";
                status = "okay";
                interrupts = <0 3 1
index 3b225f2..8dcc0a5 100644 (file)
                        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";
                };
 
                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 */
 
        meson-fb {
                compatible = "amlogic, meson-fb";
-               memory-region = <&fb_reserved>;
                dev_name = "meson-fb";
                status = "okay";
                interrupts = <0 3 1
index 65870f7..88198b1 100644 (file)
                        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";
                };
 
                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 */
 
        meson-fb {
                compatible = "amlogic, meson-fb";
-               memory-region = <&fb_reserved>;
                dev_name = "meson-fb";
                status = "okay";
                interrupts = <0 3 1
index d42ca2a..d58e680 100644 (file)
                        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";
                };
 
                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 */
 
        meson-fb {
                compatible = "amlogic, meson-fb";
-               /* memory-region = <&fb_reserved>; */
                dev_name = "meson-fb";
                status = "okay";
                interrupts = <0 3 1
index 8b4fbc8..1940300 100644 (file)
@@ -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;
 
 }
 
index 0ab9e28..065fdb0 100644 (file)
@@ -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],