Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3061735pxb; Mon, 18 Oct 2021 07:31:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWd7P8DyP8XOoelwyUCj0zVKiitugI3PVusTNshv8JfnC8tu1H4N1d3E8NgF6NIVA5hohy X-Received: by 2002:a17:906:6b0c:: with SMTP id q12mr30384172ejr.0.1634567462095; Mon, 18 Oct 2021 07:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634567462; cv=none; d=google.com; s=arc-20160816; b=VRzseG8R80dZ3fd3Bpq67kfuHQVuTw6rybrbho/eAMeQmtSHhxA1OfB+L/w418rip0 80qu6ylDttvRRdNhja93oc/msyiLDyngRLBl6ivRg7U6gT0zFRJp2dFVx3tz0TI/XoB9 7M21VnbqIyy9aUJWnFU1oBscH6O5cphNNGPdVFdPVJ3IGiuPwZkQAfNmYHxhEVaTiaNx VgDhMMHlEgbSu8/5qVs/0bd7tmpbgJo8mNfiAy954vFVBt2BFqeKgB6Y8IUJwemdU1OP MyV5+4Dsr+wNqkfZQzVPGjrMSev75kmQwKkcu7REMi0tqOjaL1AHUxPuoo+dmDMo5CXe bkaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jHztITnDF4fFQXSKxud+QNz8Jtqj0NJjpDNYvgJfDX8=; b=pN9WdGDQb5mUbLHML8qaLkb0PS6Tn6kGuWxoXVs6q0KDnWVTfxr06b8NDwlZJmMPOb SK8fFFrZLuRXzkcq4rt6p+SyjSnV8Nbwf2p+vG09H3LsabAjPiCi7fgCe7Ci1I9CQQgG NziVrpypTnSFhQkPFt8HVaU3kmNnxFmws/NCXFDD1LIxFZSr/UiLJO5GCBw1wb9j6bl4 jlL2zKTcL9xlFXkEHSVSY1FNhbIycgrbH78+JJ3FluCp2O1zeNBsopqH+FNtnq7yoJ6r eiS6/eamKJqeHdob4hZlYsQr/t2w8E9tEEm1P/W3KUHfaXiYBowJMjGwLvPACjlS0/Kz 1Yhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=a75bCI54; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs6si20707578ejb.640.2021.10.18.07.30.38; Mon, 18 Oct 2021 07:31:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=a75bCI54; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232019AbhJRObB (ORCPT + 99 others); Mon, 18 Oct 2021 10:31:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231970AbhJROa6 (ORCPT ); Mon, 18 Oct 2021 10:30:58 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E119C06161C for ; Mon, 18 Oct 2021 07:28:47 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id g39so4802357wmp.3 for ; Mon, 18 Oct 2021 07:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jHztITnDF4fFQXSKxud+QNz8Jtqj0NJjpDNYvgJfDX8=; b=a75bCI54fwhIwi6iZBBIUBOxKcoSSV0MXSYc+y1b39wdrWdh92RsRkKHhkx/2lOioN NUrd6JMCWMYONmkG7r4RxW0akwa8sd5rnt60p/WCFZozGLxjW3tKtJI3X0SDWMlqC4j8 GdQJs84k/L93E9LPe8IqA2id9EcqcweUNJKHx82dr9DhWbp0kxq/VRLYq78pDSHl+ro6 uN0Z9qtazeYNbjPxGZzvaqMhEJ5vH3UvTSk2tXo3bEg7wC30bhJ7ZXBILjuDefnD+Gpq YXxZPRFeGBQkmeV3Ixjg89V4Wr8/9OX/WXv+tQdwAzpYmoo19DJUCABCp+KUCZLipBtL wWvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jHztITnDF4fFQXSKxud+QNz8Jtqj0NJjpDNYvgJfDX8=; b=s5KC78SBsJWnlifWcHTGLT11CYX2+pjbRQ5ARMoauofPpJ3PxSN65rNo8iuWyegTkK Q8vhxb+2GXeFhYDwQLba3eESE4w/mS2YgaJ3Wca6at1vya5DRJOBWE3Wj5CVLjDm5XsF DwSsHW4n0Fu8PrIPWyoLjQHcZ9lncssSa3NBVQO6FrlTjAetc4MrfVVMhhUTtDSOCG5A tV8IiOwBTiftS9nqc/CTHuhfpBDOdTXVVvwp9zzkd5jVGjya2w/pRhDpk1hx+CpKgzvZ Sur2oVrJAcnkDWAuvfgsqgJqj3s6YlmIiOEsOluv0Ho048ATkW4yCJr+FsROKVdlsxeG AfiQ== X-Gm-Message-State: AOAM5320P3DoinmOCZJcZvR78PuTcBzF2WW1svhmB0YHuSTBe546mEza mPfr8SGxS13t4V4tGbCVyZpu2w== X-Received: by 2002:a05:600c:cc:: with SMTP id u12mr1446004wmm.46.1634567325978; Mon, 18 Oct 2021 07:28:45 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:45 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Neil Armstrong , Benoit Parrot Subject: [PATCH v6 1/9] drm/omap: add sanity plane state check Date: Mon, 18 Oct 2021 16:28:34 +0200 Message-Id: <20211018142842.2511200-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1849; h=from:subject; bh=jRkIww6GJd5Wg+RgwNKRyh7OLNc3fS8CQvhWZ54HJl0=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSFq/A8B8ssl6yiFVlKdW61NXQ3l6SuPbdR8b6q ZKp4TeGJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhQAKCRB33NvayMhJ0QgoD/ 0Y1G67QzeQnlWqz4y6rQyfTlmnlBQghuyus96kzr6X2utUqn2CCy0rJ9L4kqsuuFqHrruLjF2XBPcb JacJ0DIMHTX0WGr/RBWIxTyqlEE10Zg7uV/VTVBHmgE2bOCWNgMqRK3lFvdIr3IzNlt5EGlajO26rz gs2FwZdhTtneTdZUgUxIV2m7lSCLWgBuLjUw6lUzDJo4vw3R/3Hr8iGVGGvfG6SiGGC7M+drWWNxPi RoRYmryEINz3U1ywpQDrXP8SAJiZosCPNDyjCzn0HJxh1jZbOAW4vUw2YnbiZlw4qIcqvs0+3Ydlfs JP1Xjl68doj6DwP+PFEsGFrr9p4MpWfSmKdcZ9xq2lZJSOOVhZ1EqxE1bjKX8t7+zN8Jz2tgaWO9XY FxjXp8awUzmnEdJCKDZA862mFjykRKxKsP0mwTOsDkSt3jgv5F8yVnoUDUcRrDklqx1ludUPywsrp3 bUYtEUceq922sYSFFAqh2xGwmhtenxQKFWvf+z8HnSKWb9zJfh5pI0W64P8DrQR4mgJduDvb0lcfCy XfnLnBSRkkwwwZF3vczcvn9kijPmlpJOLdUvvbGq0cix7niwxmb67CpkfCp6JLamn48z0M6zc+HHLz BEudz0ht0gXv2v8TZjyrwJGwJslJnq/p89npsqExjha6xb4KdjTNG6M9JMxA== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call drm_atomic_helper_check_plane_state() from the plane atomic_check() callback in order to add plane state sanity checking. It will permit filtering out totally bad scaling factors, even if the real check are done later in the atomic commit. Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong --- drivers/gpu/drm/omapdrm/omap_plane.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 512af976b7e9..c3de4f339387 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -104,12 +104,15 @@ static void omap_plane_atomic_disable(struct drm_plane *plane, dispc_ovl_enable(priv->dispc, omap_plane->id, false); } +#define FRAC_16_16(mult, div) (((mult) << 16) / (div)) + static int omap_plane_atomic_check(struct drm_plane *plane, struct drm_atomic_state *state) { struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); struct drm_crtc_state *crtc_state; + int ret; if (!new_plane_state->fb) return 0; @@ -127,6 +130,18 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (!crtc_state->enable) return 0; + /* + * Note: these are just sanity checks to filter out totally bad scaling + * factors. The real limits must be calculated case by case, and + * unfortunately we currently do those checks only at the commit + * phase in dispc. + */ + ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state, + FRAC_16_16(1, 8), FRAC_16_16(8, 1), + true, true); + if (ret) + return ret; + if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0) return -EINVAL; -- 2.25.1