summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFancy Fang <chen.fang@freescale.com>2014-07-17 15:22:39 +0800
committerFancy Fang <chen.fang@freescale.com>2014-07-18 09:14:31 +0800
commitad0a08722750b31b594fec65e12439d911fa0a01 (patch)
tree7871955f2ee82b856a8745c3205e9855748299eb
parent954e1ef80e9874a4790ce7d4b5b277e8c756bfde (diff)
ENGR00322215 EPDC: kernel dump when do EPDC framebuffer unit test
[<80013b00>] (unwind_backtrace+0x0/0xf4) from [<80011524>] (show_stack+0x10/0x14) [<80011524>] (show_stack+0x10/0x14) from [<8026bc4c>] (Ldiv0+0x8/0x10) [<8026bc4c>] (Ldiv0+0x8/0x10) from [<802c1144>] (pxp_dispatch_thread+0xd74/0x11f8) [<802c1144>] (pxp_dispatch_thread+0xd74/0x11f8) from [<80046a90>] (kthread+0xb4/0xb8) [<80046a90>] (kthread+0xb4/0xb8) from [<8000e118>] (ret_from_fork+0x14/0x3c) This is caused by div by 0 in some corner cases. So add the check before doing the division. Signed-off-by: Fancy Fang <chen.fang@freescale.com> (cherry picked from commit 2a5dfad5ff763d4eb8b33628ea96291ad4b95d5e)
-rw-r--r--drivers/dma/pxp/pxp_dma_v2.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/drivers/dma/pxp/pxp_dma_v2.c b/drivers/dma/pxp/pxp_dma_v2.c
index a310569c40e6..c805477a9a46 100644
--- a/drivers/dma/pxp/pxp_dma_v2.c
+++ b/drivers/dma/pxp/pxp_dma_v2.c
@@ -659,12 +659,23 @@ static int pxp_set_scaling(struct pxps *pxp)
if (!is_yuv(s0_params->pixel_fmt) ||
(s0_params->pixel_fmt == PXP_PIX_FMT_GREY) ||
(s0_params->pixel_fmt == PXP_PIX_FMT_GY04) ||
- (s0_params->pixel_fmt == PXP_PIX_FMT_YUV444))
- xscale = (proc_data->srect.width - 1) * 0x1000 /
- (proc_data->drect.width - 1);
- else
- xscale = (proc_data->srect.width - 2) * 0x1000 /
- (proc_data->drect.width - 1);
+ (s0_params->pixel_fmt == PXP_PIX_FMT_YUV444)) {
+ if ((proc_data->srect.width > 1) &&
+ (proc_data->drect.width > 1))
+ xscale = (proc_data->srect.width - 1) * 0x1000 /
+ (proc_data->drect.width - 1);
+ else
+ xscale = proc_data->srect.width * 0x1000 /
+ proc_data->drect.width;
+ } else {
+ if ((proc_data->srect.width > 2) &&
+ (proc_data->drect.width > 1))
+ xscale = (proc_data->srect.width - 2) * 0x1000 /
+ (proc_data->drect.width - 1);
+ else
+ xscale = proc_data->srect.width * 0x1000 /
+ proc_data->drect.width;
+ }
}
if (decy > 1) {
if (decy >= 2 && decy < 4) {
@@ -679,9 +690,15 @@ static int pxp_set_scaling(struct pxps *pxp)
}
yscale = proc_data->srect.height * 0x1000 /
(proc_data->drect.height * decy);
- } else
- yscale = (proc_data->srect.height - 1) * 0x1000 /
- (proc_data->drect.height - 1);
+ } else {
+ if ((proc_data->srect.height > 1) &&
+ (proc_data->drect.height > 1))
+ yscale = (proc_data->srect.height - 1) * 0x1000 /
+ (proc_data->drect.height - 1);
+ else
+ yscale = proc_data->srect.height * 0x1000 /
+ proc_data->drect.height;
+ }
__raw_writel((xdec << 10) | (ydec << 8), pxp->base + HW_PXP_PS_CTRL);