video: rockchip: rk322x: check hwc_size before H/W register config
authorMark Yao <mark.yao@rock-chips.com>
Mon, 7 Mar 2016 02:45:32 +0000 (10:45 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 5 Apr 2016 06:05:22 +0000 (14:05 +0800)
Check hwc_size after hwc registor config, if check fail, would cause
unexpect problem, iommu crash.

Change-Id: I2e18ea86e9e27e13ccce0737d9d48befcbe345fb
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/video/rockchip/lcdc/rk322x_lcdc.c

index 10b926bce0115bea312bec0591d21e18515b2c8c..8f75e3c7d33456eba3e0b0d51903e6f6eb5a6a99 100644 (file)
@@ -1548,27 +1548,27 @@ static int vop_hwc_reg_update(struct rk_lcdc_driver *dev_drv, int win_id)
        unsigned int hwc_size = 0;
        u64 val;
 
+       if ((win->area[0].xsize == 32) && (win->area[0].ysize == 32)) {
+               hwc_size = 0;
+       } else if ((win->area[0].xsize == 64) && (win->area[0].ysize == 64)) {
+               hwc_size = 1;
+       } else if ((win->area[0].xsize == 96) && (win->area[0].ysize == 96)) {
+               hwc_size = 2;
+       } else if ((win->area[0].xsize == 128) &&
+                  (win->area[0].ysize == 128)) {
+               hwc_size = 3;
+       } else {
+               dev_err(vop_dev->dev, "un supported hwc size[%dx%d]!\n",
+                               win->area[0].xsize, win->area[0].ysize);
+               return -EINVAL;
+       }
+
        if (win->state == 1) {
                vop_axi_gather_cfg(vop_dev, win);
                val = V_HWC_EN(1) | V_HWC_DATA_FMT(win->area[0].fmt_cfg) |
                    V_HWC_RB_SWAP(win->area[0].swap_rb);
                vop_msk_reg(vop_dev, HWC_CTRL0, val);
 
-               if ((win->area[0].xsize == 32) && (win->area[0].ysize == 32))
-                       hwc_size = 0;
-               else if ((win->area[0].xsize == 64) &&
-                        (win->area[0].ysize == 64))
-                       hwc_size = 1;
-               else if ((win->area[0].xsize == 96) &&
-                        (win->area[0].ysize == 96))
-                       hwc_size = 2;
-               else if ((win->area[0].xsize == 128) &&
-                        (win->area[0].ysize == 128))
-                       hwc_size = 3;
-               else
-                       dev_err(vop_dev->dev, "un supported hwc size[%dx%d]!\n",
-                               win->area[0].xsize, win->area[0].ysize);
-
                val = V_HWC_SIZE(hwc_size);
                vop_msk_reg(vop_dev, HWC_CTRL0, val);