From patchwork Fri Mar 10 00:56:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 662486 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C63CC6FD1C for ; Fri, 10 Mar 2023 00:57:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229445AbjCJA5k (ORCPT ); Thu, 9 Mar 2023 19:57:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbjCJA5d (ORCPT ); Thu, 9 Mar 2023 19:57:33 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1449FC7D9 for ; Thu, 9 Mar 2023 16:57:26 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id f18so4630000lfa.3 for ; Thu, 09 Mar 2023 16:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678409845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hkRDIK8ume27O2eNp/2vFx54xBZXr96ITOU7VC+DkN8=; b=C3OdzVqwMLwGZQldG8df9J+3PEEDSHEjYgvdKOudQMVTqtHS8ELmwJrSwZM+OhsASO F/un4sFyOMNt2Mgv7IXu/UFRXajh63SweJAZIghAVG/epBgiS+/LqD3GTsQZYGq5r0rj gHtiE+lYSiUxxMuYljj0LiB3sl8ufKH3aFCuS+QB4r8QUJvVTM+Z5X9XJFGs4eOrSKqL kKjsrTOReQyPkeGykjHhwsVxVX/KlEc3nOWP28UNv++c1e2sBKEkwr+07Ls3MGIc+jEC TAMm8u+kVIq2SzVVX2s5xtZjfKUo83wwYHuVwuad3BfLnlDdOZSUxps/Da8N9Prl3iRw HOYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678409845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hkRDIK8ume27O2eNp/2vFx54xBZXr96ITOU7VC+DkN8=; b=JWebBzs1cl6I1WhMgeiEvhC0zXoBnGE9iDZ5bcB20CPX+tr23FLGDf5pJCirxfV0p0 BWGYNHYCHQ5prbgBn6QPpT23UVasHZWM+rwN7QTyspc7LboWJ2bgsq+Pf214J+upiAwu x/OevmTvA6AhamxKn21VLPdGZ1O6k1L20Hv40gVgf1lCKOZed54qBIXU99lG++7hD2q0 YaUGOOBo68qeAnskFmv81DsK8du4A6ozyW0uAfdyGWX6qYqNB6PQB7ZrBabPWamZPiSW 7HbFgupVXEPS5bFoFRZzNkXPVNbPXjEjXnVdm0l5O0+FPEGIh+ivmzbN+4fWwkoBBEfz FV/Q== X-Gm-Message-State: AO0yUKVeLwEMiqZELBkENBlq8w4jNbD2QynILMDeNegcIH33tmPg1b7c y2Z4wcFeNUb4k3/ZtQGmlQLfHg== X-Google-Smtp-Source: AK7set9O7IDe8FcaApcedfEGlJ63qT0R2UusEtH4nL7KZ+BlGslLl53NUUYZftrGN3BghgfsasH/PA== X-Received: by 2002:ac2:5971:0:b0:4cc:96f8:f9c4 with SMTP id h17-20020ac25971000000b004cc96f8f9c4mr6780976lfp.45.1678409845218; Thu, 09 Mar 2023 16:57:25 -0800 (PST) Received: from eriador.lan (dzccz6yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a085:4d00::8a5]) by smtp.gmail.com with ESMTPSA id m13-20020ac2428d000000b004d8540b947asm75280lfh.56.2023.03.09.16.57.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 16:57:24 -0800 (PST) From: Dmitry Baryshkov To: Rob Clark , Sean Paul , Abhinav Kumar Cc: Stephen Boyd , David Airlie , Daniel Vetter , Bjorn Andersson , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH v5 21/32] drm/msm/dpu: simplify dpu_plane_validate_src() Date: Fri, 10 Mar 2023 02:56:53 +0200 Message-Id: <20230310005704.1332368-22-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310005704.1332368-1-dmitry.baryshkov@linaro.org> References: <20230310005704.1332368-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The plane's clipped coordinates has already been validated against FB size in the drm_atomic_plane_check(). There is no need to check them again. Remove corresponding checks and inline dpu_plane_validate_src(). Signed-off-by: Dmitry Baryshkov Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 30 ++++++++--------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c index ba850e9feb9b..9c556ba9cb7b 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c @@ -894,25 +894,6 @@ static void dpu_plane_cleanup_fb(struct drm_plane *plane, old_pstate->needs_dirtyfb); } -static bool dpu_plane_validate_src(struct drm_rect *src, - struct drm_rect *fb_rect, - uint32_t min_src_size) -{ - /* Ensure fb size is supported */ - if (drm_rect_width(fb_rect) > MAX_IMG_WIDTH || - drm_rect_height(fb_rect) > MAX_IMG_HEIGHT) - return false; - - /* Ensure src rect is above the minimum size */ - if (drm_rect_width(src) < min_src_size || - drm_rect_height(src) < min_src_size) - return false; - - /* Ensure src is fully encapsulated in fb */ - return drm_rect_intersect(fb_rect, src) && - drm_rect_equals(fb_rect, src); -} - static int dpu_plane_check_inline_rotation(struct dpu_plane *pdpu, const struct dpu_sspp_sub_blks *sblk, struct drm_rect src, const struct dpu_format *fmt) @@ -998,6 +979,14 @@ static int dpu_plane_atomic_check(struct drm_plane *plane, fb_rect.x2 = new_plane_state->fb->width; fb_rect.y2 = new_plane_state->fb->height; + /* Ensure fb size is supported */ + if (drm_rect_width(&fb_rect) > MAX_IMG_WIDTH || + drm_rect_height(&fb_rect) > MAX_IMG_HEIGHT) { + DPU_DEBUG_PLANE(pdpu, "invalid framebuffer " DRM_RECT_FMT "\n", + DRM_RECT_ARG(&fb_rect)); + return -E2BIG; + } + max_linewidth = pdpu->catalog->caps->max_linewidth; fmt = to_dpu_format(msm_framebuffer_format(new_plane_state->fb)); @@ -1012,7 +1001,8 @@ static int dpu_plane_atomic_check(struct drm_plane *plane, return -EINVAL; /* check src bounds */ - } else if (!dpu_plane_validate_src(&pipe_cfg->src_rect, &fb_rect, min_src_size)) { + } else if (drm_rect_width(&pipe_cfg->src_rect) < min_src_size || + drm_rect_height(&pipe_cfg->src_rect) < min_src_size) { DPU_DEBUG_PLANE(pdpu, "invalid source " DRM_RECT_FMT "\n", DRM_RECT_ARG(&pipe_cfg->src_rect)); return -E2BIG;