From: Mark Yao Date: Mon, 7 Mar 2016 02:45:32 +0000 (+0800) Subject: video: rockchip: rk322x: check hwc_size before H/W register config X-Git-Tag: firefly_0821_release~2891 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4534d4b84146eb48833a0b0340ae6c6175b80583;p=firefly-linux-kernel-4.4.55.git video: rockchip: rk322x: check hwc_size before H/W register config Check hwc_size after hwc registor config, if check fail, would cause unexpect problem, iommu crash. Change-Id: I2e18ea86e9e27e13ccce0737d9d48befcbe345fb Signed-off-by: Mark Yao --- diff --git a/drivers/video/rockchip/lcdc/rk322x_lcdc.c b/drivers/video/rockchip/lcdc/rk322x_lcdc.c index 10b926bce011..8f75e3c7d334 100644 --- a/drivers/video/rockchip/lcdc/rk322x_lcdc.c +++ b/drivers/video/rockchip/lcdc/rk322x_lcdc.c @@ -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);