From patchwork Thu Jun 7 11:06:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 137864 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1948426lji; Thu, 7 Jun 2018 04:06:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKxK1A4T2YfR2g8MbykxX9ar16lCJP7sVMdmKM31BTnNYRi6mygSqbZlEmw12Mw7l8zpZou X-Received: by 2002:a63:7a11:: with SMTP id v17-v6mr1182735pgc.97.1528369586875; Thu, 07 Jun 2018 04:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528369586; cv=none; d=google.com; s=arc-20160816; b=zPKJ7Hw5jvil5wjpMJ/fT7LJZGXD4yBu730eFcpN1jUWUA2KLnUZgk1nbtNDQtK1vA UICatrHiskaR80kHFxnJqrb2y7o5e+CJ67k0w8+n6IsqdX70hmDEOsE74+zRFZvsBGV8 lUpYZ2/4ikk5IBX/SVNGepoUr6wKlSjy46jd1CMBl3X2JnqAQ9OTYq11uvCa9OdCDGz5 OfxzXadiqrS0xMOqwl2LEGodFtJuMy/U72pmnzvSZ0gkr/0tckKXhGkBczKQNYvoRiHH Yl6QOm0u17Jwm5Tw7tTCKhg4W7taAZL4wKSxAmBzzculZnsdF+JbUfgOm61U1DXkBn60 iBNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=deooa0RhzSEVF9KPW0gFXIXWeMd08rb49nz+u8GdpaQ=; b=oq6i8UW0O7nn6Pd/hCRKc6W6N5p0M7xZEJ7niMepZDeS2Z2XxYnY+6vZh1rbg2rMet LTVq69IK9gIObouhKGRLO5UHJueX0V7Nvu3rTx6LSixbuZF3ASuDqPWdbcxfUsjL1Czk w/OhUH5kIvGGSeuNgFKaDDIAXQ7aVe8AS8w7ALy+vOQzxKwT6XWMrUhxero8ZLb9DZP6 Yl9aIcO8c3bq2INUIe9ABO6hxuVmcusbfpGlFV5rjE4AmtPkDBjPl5Orxvq6rG7OKxXF miaa7IVjBp8XSSjs6vU3Me2B4JFXhoWpfpX7MHd6IQdYxUU8GQi/CxMIB040qxOUoFlF Y2KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=aQyVjZk1; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si15144102pgd.96.2018.06.07.04.06.26; Thu, 07 Jun 2018 04:06:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=aQyVjZk1; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753390AbeFGLGZ (ORCPT + 3 others); Thu, 7 Jun 2018 07:06:25 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:33802 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753149AbeFGLGX (ORCPT ); Thu, 7 Jun 2018 07:06:23 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180607110621euoutp02a971d44c3a94b8ec15de65084e9b401f~13Alsa-em2938129381euoutp02p; Thu, 7 Jun 2018 11:06:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180607110621euoutp02a971d44c3a94b8ec15de65084e9b401f~13Alsa-em2938129381euoutp02p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1528369581; bh=FmQgdqlcX4Sd0RiRlZWCL03ArVpSr2PewTISwk853o0=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=aQyVjZk1psUZgwkeTyA5dvkELphQkDHIb0G+p5uyFjLvQrwHUNVz5BAVkDqirY2cS NdCyQvFdcZbsa6K3iUIe1WCqWp6ttbIyLa7gq/j4CYP23gfgddM//qdgm08HBTOqYJ N+N1uts3JA2fMmSQT7Gs3v63L1AdXbmT2FZeJvLs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180607110620eucas1p143cc2d83fa14e7032e3a2b75b06d393a~13Ak-mKlO2078420784eucas1p14; Thu, 7 Jun 2018 11:06:20 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id CB.43.10409.CA1191B5; Thu, 7 Jun 2018 12:06:20 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180607110620eucas1p1b0fb05cea340248e2facadbc876e2764~13AkSrgfD2078420784eucas1p13; Thu, 7 Jun 2018 11:06:20 +0000 (GMT) X-AuditID: cbfec7f5-b45ff700000028a9-79-5b1911ac5910 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CD.BB.04183.CA1191B5; Thu, 7 Jun 2018 12:06:20 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P9Y0097E9IGLAA0@eusync1.samsung.com>; Thu, 07 Jun 2018 12:06:20 +0100 (BST) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Inki Dae , Seung-Woo Kim , Bartlomiej Zolnierkiewicz , Andrzej Pietrasiewicz Subject: [PATCH 1/9] drm/exynos: ipp: Rework checking for the correct buffer formats Date: Thu, 07 Jun 2018 13:06:06 +0200 Message-id: <20180607110614.335-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20180607110614.335-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRmVeSWpSXmKPExsWy7djPc7prBCWjDRqOKlvMetnOYrFxxnpW iytf37NZTLo/gcVixvl9TBZrj9xlt5gx+SWbA7vH/e7jTB59W1YxenzeJBfAHMVlk5Kak1mW WqRvl8CV8XHTLsaC87oVB5sPMzYw7lHpYuTkkBAwkWg/85Kxi5GLQ0hgBaPElg8vmCGcz4wS 8+93s8NUbZ26nAUisYxR4ubkRiYIp4FJ4u7EuWBVbAKGEl1vu9hAbBEBN4mmwzNZQYqYBR4z SqzdvRmsSFggTOLdk6NgRSwCqhJNS1qZQWxeAWuJhcs2s0Ksk5dYveEAWJxTwEbi/LJNYNsk BH6ySvy6+BCqyEXidv9bqPuEJV4d3wJly0hcntzNAtHQzCjRPmMWO4TTwyixdc4ONogqa4nD xy+CTWIW4JOYtG060DoOoDivREebEITpIXFzrztIhZBAP6NE71XzCYySCxgZVjGKp5YW56an FhvnpZbrFSfmFpfmpesl5+duYgTG2+l/x7/uYNz3J+kQowAHoxIPb8N98Wgh1sSy4srcQ4wS HMxKIryJl8SihXhTEiurUovy44tKc1KLDzFKc7AoifPGadRFCQmkJ5akZqemFqQWwWSZODil GhhNijZcVtubaNcn+P7GLgUW7xCl0FfsN9RO/N34L7Dp/gu7OE3t2vgzZjMWdZXY8T45rl91 77zvsYZYqdDfXY/l+2VeLGZ8oL7BVfjhnhXBby9dm+JSqldtWuzlVqYgYvRq95wV/Q0XCmY8 4Fq85dyNOqkfs/+rr2o/NvVki8P8pgIpkdJKdQclluKMREMt5qLiRADMXzOCswIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHJMWRmVeSWpSXmKPExsVy+t/xy7prBCWjDVYeYLaY9bKdxWLjjPWs Fle+vmezmHR/AovFjPP7mCzWHrnLbjFj8ks2B3aP+93HmTz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoEr4+OmXYwF53UrDjYfZmxg3KPSxcjJISFgIrF16nKWLkYuDiGBJYwSC/bMYINwmpgk Hi44yApSxSZgKNH1tosNxBYRcJNoOjyTFaSIWeAxo8THbafAioQFwiTePTkKVsQioCrRtKSV GcTmFbCWWLhsMyvEOnmJ1RsOgMU5BWwkzi/bxARiCwHVvH1wmn0CI88CRoZVjCKppcW56bnF RnrFibnFpXnpesn5uZsYgaGy7djPLTsYu94FH2IU4GBU4uG98VA8Wog1say4MvcQowQHs5II b+IlsWgh3pTEyqrUovz4otKc1OJDjNIcLErivOcNKqOEBNITS1KzU1MLUotgskwcnFINjC5b dpp+K8icu7rtP6/PDJW7N5+x/1r09YH9AU3DR9/Ca/8+XnGNdZU2u3zvjGl7pgdIPtrK+bx7 yaMf2d/fLkqasHKvgJDw9GWy31epp08q9090//T2RaTVkv/tb4PvdVaYdm3O2Nl8qW7FpdU2 AaelQnW0VXZdT+hr/f1pulKaZMgC746EuVuVWIozEg21mIuKEwGwHzdgEQIAAA== X-CMS-MailID: 20180607110620eucas1p1b0fb05cea340248e2facadbc876e2764 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180607110620eucas1p1b0fb05cea340248e2facadbc876e2764 References: <20180607110614.335-1-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Prepare a common function for size and scale checks and call it for source and destination buffers. Then also move there the state-less checks from exynos_drm_ipp_task_setup_buffer, so the format information is already available in limits processing. Finally perform the IPP_LIMIT_BUFFER check on the real width of the buffer (the width calculated from the provided buffer pitch). Signed-off-by: Marek Szyprowski --- drivers/gpu/drm/exynos/exynos_drm_ipp.c | 108 +++++++++++++----------- 1 file changed, 57 insertions(+), 51 deletions(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c index 26374e58c557..8840e6ec8e43 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c @@ -345,27 +345,6 @@ static int exynos_drm_ipp_task_setup_buffer(struct exynos_drm_ipp_buffer *buf, int ret = 0; int i; - /* basic checks */ - if (buf->buf.width == 0 || buf->buf.height == 0) - return -EINVAL; - buf->format = drm_format_info(buf->buf.fourcc); - for (i = 0; i < buf->format->num_planes; i++) { - unsigned int width = (i == 0) ? buf->buf.width : - DIV_ROUND_UP(buf->buf.width, buf->format->hsub); - - if (buf->buf.pitch[i] == 0) - buf->buf.pitch[i] = width * buf->format->cpp[i]; - if (buf->buf.pitch[i] < width * buf->format->cpp[i]) - return -EINVAL; - if (!buf->buf.gem_id[i]) - return -ENOENT; - } - - /* pitch for additional planes must match */ - if (buf->format->num_planes > 2 && - buf->buf.pitch[1] != buf->buf.pitch[2]) - return -EINVAL; - /* get GEM buffers and check their size */ for (i = 0; i < buf->format->num_planes; i++) { unsigned int height = (i == 0) ? buf->buf.height : @@ -495,12 +474,13 @@ static int exynos_drm_ipp_check_size_limits(struct exynos_drm_ipp_buffer *buf, enum drm_ipp_size_id id = rotate ? IPP_LIMIT_ROTATED : IPP_LIMIT_AREA; struct drm_ipp_limit l; struct drm_exynos_ipp_limit_val *lh = &l.h, *lv = &l.v; + int real_width = buf->buf.pitch[0] / buf->format->cpp[0]; if (!limits) return 0; __get_size_limit(limits, num_limits, IPP_LIMIT_BUFFER, &l); - if (!__size_limit_check(buf->buf.width, &l.h) || + if (!__size_limit_check(real_width, &l.h) || !__size_limit_check(buf->buf.height, &l.v)) return -EINVAL; @@ -560,10 +540,62 @@ static int exynos_drm_ipp_check_scale_limits( return 0; } +static int exynos_drm_ipp_check_format(struct exynos_drm_ipp_task *task, + struct exynos_drm_ipp_buffer *buf, + struct exynos_drm_ipp_buffer *src, + struct exynos_drm_ipp_buffer *dst, + bool rotate, bool swap) +{ + const struct exynos_drm_ipp_formats *fmt; + int ret, i; + + fmt = __ipp_format_get(task->ipp, buf->buf.fourcc, buf->buf.modifier, + buf == src ? DRM_EXYNOS_IPP_FORMAT_SOURCE : + DRM_EXYNOS_IPP_FORMAT_DESTINATION); + if (!fmt) { + DRM_DEBUG_DRIVER("Task %pK: %s format not supported\n", task, + buf == src ? "src" : "dst"); + return -EINVAL; + } + + /* basic checks */ + if (buf->buf.width == 0 || buf->buf.height == 0) + return -EINVAL; + + buf->format = drm_format_info(buf->buf.fourcc); + for (i = 0; i < buf->format->num_planes; i++) { + unsigned int width = (i == 0) ? buf->buf.width : + DIV_ROUND_UP(buf->buf.width, buf->format->hsub); + + if (buf->buf.pitch[i] == 0) + buf->buf.pitch[i] = width * buf->format->cpp[i]; + if (buf->buf.pitch[i] < width * buf->format->cpp[i]) + return -EINVAL; + if (!buf->buf.gem_id[i]) + return -ENOENT; + } + + /* pitch for additional planes must match */ + if (buf->format->num_planes > 2 && + buf->buf.pitch[1] != buf->buf.pitch[2]) + return -EINVAL; + + /* check driver limits */ + ret = exynos_drm_ipp_check_size_limits(buf, fmt->limits, + fmt->num_limits, + rotate, + buf == dst ? swap : false); + if (ret) + return ret; + ret = exynos_drm_ipp_check_scale_limits(&src->rect, &dst->rect, + fmt->limits, + fmt->num_limits, swap); + return ret; +} + static int exynos_drm_ipp_task_check(struct exynos_drm_ipp_task *task) { struct exynos_drm_ipp *ipp = task->ipp; - const struct exynos_drm_ipp_formats *src_fmt, *dst_fmt; struct exynos_drm_ipp_buffer *src = &task->src, *dst = &task->dst; unsigned int rotation = task->transform.rotation; int ret = 0; @@ -607,37 +639,11 @@ static int exynos_drm_ipp_task_check(struct exynos_drm_ipp_task *task) return -EINVAL; } - src_fmt = __ipp_format_get(ipp, src->buf.fourcc, src->buf.modifier, - DRM_EXYNOS_IPP_FORMAT_SOURCE); - if (!src_fmt) { - DRM_DEBUG_DRIVER("Task %pK: src format not supported\n", task); - return -EINVAL; - } - ret = exynos_drm_ipp_check_size_limits(src, src_fmt->limits, - src_fmt->num_limits, - rotate, false); - if (ret) - return ret; - ret = exynos_drm_ipp_check_scale_limits(&src->rect, &dst->rect, - src_fmt->limits, - src_fmt->num_limits, swap); + ret = exynos_drm_ipp_check_format(task, src, src, dst, rotate, swap); if (ret) return ret; - dst_fmt = __ipp_format_get(ipp, dst->buf.fourcc, dst->buf.modifier, - DRM_EXYNOS_IPP_FORMAT_DESTINATION); - if (!dst_fmt) { - DRM_DEBUG_DRIVER("Task %pK: dst format not supported\n", task); - return -EINVAL; - } - ret = exynos_drm_ipp_check_size_limits(dst, dst_fmt->limits, - dst_fmt->num_limits, - false, swap); - if (ret) - return ret; - ret = exynos_drm_ipp_check_scale_limits(&src->rect, &dst->rect, - dst_fmt->limits, - dst_fmt->num_limits, swap); + ret = exynos_drm_ipp_check_format(task, dst, src, dst, false, swap); if (ret) return ret;