From patchwork Tue Mar 14 15:35:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 663034 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 A3ADCC6FD1F for ; Tue, 14 Mar 2023 15:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231603AbjCNPh4 (ORCPT ); Tue, 14 Mar 2023 11:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231725AbjCNPhc (ORCPT ); Tue, 14 Mar 2023 11:37:32 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83E30AD001 for ; Tue, 14 Mar 2023 08:36:36 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id b13so16450459ljf.6 for ; Tue, 14 Mar 2023 08:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678808161; 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=LL1jta76uEc1px4/1UNoICUDwq822jJ4GMfO6I/zxMQ=; b=m8yEKVzAjUtwECC0b+dhYbmFTCBcYwzD5dTLmfwBtw7YHnePh3yq5/RYp++5SGgdma ObXOVPSLicXkXyHiSUhCeOgRYl6BaYMnSs4RnwjWV/qIeWnyWBZGJ+AIWMTkzWwq1X+W LbQkBPvlMLSQYXrWWmUXpxakWjwpG7jkTpiPQctlCcUnP+ghgB0Q6wJvEKiX1A/Fv2Us MJGuyY5rjE21+UXXDGUjD2fvtpBDpF5p8mj5ju0AkZrtDw2ztOj/syUyegto02yoejHp Yun/exAKspSfLI+D29ydqMeLvTrqo7Q1ktcTybq+PwjhvfK91JU3IhuvMvjfRajbGb9u P0Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678808161; 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=LL1jta76uEc1px4/1UNoICUDwq822jJ4GMfO6I/zxMQ=; b=buaCskpysNwWOdlpRk75c06ED3Sbu9+JMId6l2IMcL6+c6HEZIYdxbGuf9KIn3ioIb YQpIevPqj7BBMJKs0OaQc0aUqHRK/JhHDUeQjD8Htf47HA4dLeK/3WWfud/e6Vux+426 o3gNTMSjHSwJy7i3/G4xiQ+jatbZeMxZj368gH9SwdVxGzjxZoLk4lYlDDrXUNDZgdyt oVVM2bAXSDmY2nVJUDTyQ7fxOVoyIcGe4NQHCLBfSw/GSN+yya1yR4Zorxl6MpVgECjN mDNPI3rEgCHfB4DmlKZYLUhqYNrXYqwU42RTgvJY/0o8xq9qzOICumUaf2r1MRAXIOzI ZpEA== X-Gm-Message-State: AO0yUKWUCXcZqK/xKslC+Gb3Zb18u7OLyW3chbRb5B5sirPgxasDuKsK CycgS/PdYKy5cC+Z5opvNgOC/g== X-Google-Smtp-Source: AK7set93W8RltGLLVvrFi5bIvd+LNi8IK0uKKDkDSdU3zYRhwZ58YgsvPtd61lUEcvKxQPIMM0AUPA== X-Received: by 2002:a2e:9244:0:b0:295:b0cd:517 with SMTP id v4-20020a2e9244000000b00295b0cd0517mr11935253ljg.35.1678808161444; Tue, 14 Mar 2023 08:36:01 -0700 (PDT) Received: from umbar.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id z8-20020a2eb528000000b0029573844d03sm470854ljm.109.2023.03.14.08.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 08:36:01 -0700 (PDT) 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 v6 21/32] drm/msm/dpu: simplify dpu_plane_validate_src() Date: Tue, 14 Mar 2023 18:35:34 +0300 Message-Id: <20230314153545.3442879-22-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230314153545.3442879-1-dmitry.baryshkov@linaro.org> References: <20230314153545.3442879-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(). Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- 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;