From patchwork Thu Apr 10 07:32:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3960241 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B46909F336 for ; Thu, 10 Apr 2014 07:32:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD7AE20630 for ; Thu, 10 Apr 2014 07:32:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0403F20629 for ; Thu, 10 Apr 2014 07:32:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965212AbaDJHcj (ORCPT ); Thu, 10 Apr 2014 03:32:39 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:35006 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965168AbaDJHch (ORCPT ); Thu, 10 Apr 2014 03:32:37 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N3T00I0U0YCAMA0@mailout3.samsung.com> for linux-media@vger.kernel.org; Thu, 10 Apr 2014 16:32:37 +0900 (KST) X-AuditID: cbfee61b-b7f456d000006dfd-0c-534649135985 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id CA.18.28157.31946435; Thu, 10 Apr 2014 16:32:35 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N3T005990XW0YD0@mmp2.samsung.com>; Thu, 10 Apr 2014 16:32:35 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: s.nawrocki@samsung.com, Jacek Anaszewski , Kyungmin Park Subject: [PATCH v2 6/8] s5p-jpeg: Fix sysmmu page fault Date: Thu, 10 Apr 2014 09:32:16 +0200 Message-id: <1397115138-1095-6-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1397115138-1095-1-git-send-email-j.anaszewski@samsung.com> References: <1397115138-1095-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEJMWRmVeSWpSXmKPExsVy+t9jQV1hT7dgg8u7xS16rz5ntDjb9Ibd omfDVlaLw2/aWR1YPPq2rGL0+LxJLoApissmJTUnsyy1SN8ugSvj3fXnrAUd4hW/2tazNTBe Fepi5OSQEDCRWHziNTuELSZx4d56NhBbSGA6o8TzFtUuRi4gu51JYv3ne8wgCTYBQ4mfL14z gdgiAvIST3pvADVwcDALlEgcWq8IEhYWMJeYtfQhWJhFQFVi1tQUkDCvgLvEsnl9LCBhCQEF iTmTbEDCnAIeEj/2rGeG2OousXHydeYJjLwLGBlWMYqmFiQXFCel5xrpFSfmFpfmpesl5+du YgSHxDPpHYyrGiwOMQpwMCrx8B5Y5hosxJpYVlyZe4hRgoNZSYRXQcgtWIg3JbGyKrUoP76o NCe1+BCjNAeLkjjvwVbrQCGB9MSS1OzU1ILUIpgsEwenVAOj0YSWuBUVrFcmy2+9w7OSp8Wz 2LGfr3CBfUpSic92u11Rk1elrJ+qU/L25zPnjg7h7ndJeXcMDfdHml4z/+IXMtHz0OeY7N81 zX26nzx5IqYFaMyc6Hs080PBzVfGctWr1UJacyYw8b9O8TsepLvgoPO5H3/0RO6EGpwt4V/I F3xGKJ8lt0mJpTgj0VCLuag4EQCKpdhJBQIAAA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes jpeg sysmmu page fault on Exynos4x12 SoCs. During encoding Exynos4x12 SoCs access wider memory area than it results from Image_x and Image_y values written to the JPEG_IMAGE_SIZE register. In order to avoid sysmmu page fault apply proper output buffer size alignment. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 46 +++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 541f03e..393f3fd 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1106,6 +1106,32 @@ static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv, return vidioc_try_fmt(f, fmt, ctx, FMT_TYPE_OUTPUT); } +static int exynos4_jpeg_get_output_buffer_size(struct s5p_jpeg_ctx *ctx, + struct v4l2_format *f, + int fmt_depth) +{ + struct v4l2_pix_format *pix = &f->fmt.pix; + u32 pix_fmt = f->fmt.pix.pixelformat; + int w = pix->width, h = pix->height, wh_align; + + if (pix_fmt == V4L2_PIX_FMT_RGB32 || + pix_fmt == V4L2_PIX_FMT_NV24 || + pix_fmt == V4L2_PIX_FMT_NV42 || + pix_fmt == V4L2_PIX_FMT_NV12 || + pix_fmt == V4L2_PIX_FMT_NV21 || + pix_fmt == V4L2_PIX_FMT_YUV420) + wh_align = 4; + else + wh_align = 1; + + jpeg_bound_align_image(&w, S5P_JPEG_MIN_WIDTH, + S5P_JPEG_MAX_WIDTH, wh_align, + &h, S5P_JPEG_MIN_HEIGHT, + S5P_JPEG_MAX_HEIGHT, wh_align); + + return w * h * fmt_depth >> 3; +} + static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f) { struct vb2_queue *vq; @@ -1132,10 +1158,24 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f) q_data->fmt = s5p_jpeg_find_format(ct, pix->pixelformat, f_type); q_data->w = pix->width; q_data->h = pix->height; - if (q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG) - q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3; - else + if (q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG) { + /* + * During encoding Exynos4x12 SoCs access wider memory area + * than it results from Image_x and Image_y values written to + * the JPEG_IMAGE_SIZE register. In order to avoid sysmmu + * page fault calculate proper buffer size in such a case. + */ + if (ct->jpeg->variant->version == SJPEG_EXYNOS4 && + f_type == FMT_TYPE_OUTPUT && ct->mode == S5P_JPEG_ENCODE) + q_data->size = exynos4_jpeg_get_output_buffer_size(ct, + f, + q_data->fmt->depth); + else + q_data->size = q_data->w * q_data->h * + q_data->fmt->depth >> 3; + } else { q_data->size = pix->sizeimage; + } if (f_type == FMT_TYPE_OUTPUT) { ctrl_subs = v4l2_ctrl_find(&ct->ctrl_handler,