drm/exynos/gsc: Add resolution check and error handling 27/140227/10
authorHoegeun Kwon <hoegeun.kwon@samsung.com>
Thu, 20 Jul 2017 04:25:49 +0000 (13:25 +0900)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Thu, 10 Aug 2017 02:47:31 +0000 (02:47 +0000)
If the gscaler device tries to rotate the screen with a resolution
other than a multiple of 4 and 8, a kernel panic [1] occurs because of
referring unallocated memory areas. The cause of this problem is that
multiples of the resolution must be a multiple of 4, 8 each
horizontally and vertically. It is related to the hardware limit of
gscaler.

Add error handling to check that each horizontal and vertical
resolution is not a multiple of 4 and 8.

[1]
   BUG: failure at drivers/iommu/exynos-iommu.c:425/exynos_sysmmu_irq()!
   Kernel panic - not syncing: BUG!
   CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.1.36-00004-gfbfeb5b-dirty #215
   Hardware name: Samsung TM2 board (DT)
   Call trace:
   [<ffffffc00008a008>] dump_backtrace+0x0/0x12c
   [<ffffffc00008a148>] show_stack+0x14/0x1c
   [<ffffffc000a5c818>] dump_stack+0x84/0xa8
   [<ffffffc000a589d4>] panic+0xf0/0x234
   [<ffffffc00045c4c0>] exynos_sysmmu_irq+0x68/0x78
   [<ffffffc0000e8ab4>] handle_irq_event_percpu+0x78/0x290
   [<ffffffc0000e8d18>] handle_irq_event+0x4c/0x78
   [<ffffffc0000eb9c0>] handle_fasteoi_irq+0xe4/0x198
   [<ffffffc0000e8050>] generic_handle_irq+0x34/0x4c
   [<ffffffc0000e83a4>] __handle_domain_irq+0x88/0xf0
   [<ffffffc000082418>] gic_handle_irq+0x34/0x84
   Exception stack(0xffffffc001097da0 to 0xffffffc001097ed0)
   7da0: 010a1000 ffffffc0 00000000 00000080 01097ef0 ffffffc0 00086974 ffffffc0
   7dc0: 00000000 00000000 01097f00 ffffffc0 00000001 00000000 00000000 00000000
   7de0: 00000000 00000000 98e93c98 ffffffc0 6abd3580 00000018 99087c98 ffffffc0
   7e00: 010af230 ffffffc0 01097e40 ffffffc0 ffffb3a1 00000000 00a72988 ffffffc0
   7e20: f1efd6f4 00000000 f1efd708 00000000 f1efe290 00000000 00000000 00000000
   7e40: 0010cfa0 ffffffc0 00000000 00000000 00000000 00000000 010a1000 ffffffc0
   7e60: 0122a000 ffffffc0 00a71000 ffffffc0 00000000 00000000 00000000 00000000
   7e80: 010891b0 ffffffc0 0108a740 ffffffc0 01083be0 ffffffc0 00f54000 ffffffc0
   7ea0: 00000000 00000000 01097ef0 ffffffc0 00086970 ffffffc0 01097ef0 ffffffc0
   7ec0: 00086974 ffffffc0 60000145 00000000
   [<ffffffc000085700>] el1_irq+0x80/0xf8
   [<ffffffc0000d9d50>] cpu_startup_entry+0x290/0x458
   [<ffffffc000a5702c>] rest_init+0x84/0x8c
   [<ffffffc000fe9984>] start_kernel+0x398/0x3ac

Change-Id: I5e81a5217a0eaa12e8645cbe4fe118661decc037
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
drivers/gpu/drm/exynos/exynos_drm_gsc.c

index 51db079..6ecdda8 100644 (file)
@@ -1527,6 +1527,16 @@ static int gsc_ippdrv_check_property(struct device *dev,
                pos = &config->pos;
                sz = &config->sz;
 
+               /*
+                * Multiples of the resolution must be a multiple
+                * of 4, 8 each horizontally and vertically.
+                * Check the resolution.
+                */
+               if ((sz->hsize & 0x3) || (sz->vsize & 0x7)) {
+                       DRM_ERROR("resolution must be a multiple of 4 or 8.\n");
+                       goto err_property;
+               }
+
                /* check for flip */
                if (!gsc_check_drm_flip(config->flip)) {
                        DRM_ERROR("invalid flip.\n");