From patchwork Fri Jan 13 16:59:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13101175 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD9F9C54EBD for ; Fri, 13 Jan 2023 17:00:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74F6D10EA75; Fri, 13 Jan 2023 17:00:44 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6AD4110EA6D; Fri, 13 Jan 2023 17:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=r3kUWrV2dzwrDfX4CutT7aJNmlncDrMB+wNqh9Eakhc=; b=OGPU3NKEnOhDV9apgkTsMxse7e HEZGCW398n412IWx4nui9f2TsA7S34mJRrJ7hpgiwzjiPYxuaF3xgoUWs6uWcSLjAqOSekH9EW9VE vnXXmtpbmCsIyJK68SF0MbSAhDXzK2FbEhzXA8Gm1ZUvPEPV44GCkIYSOxKSZMbg5OpZj7LXIUuz3 hpnsfAzCXjgUvXceIuZ7ZMugDvAGdJl0U+3Z5TdJQF1T2YDzgwBXR27SS5a7DfKNRWzPpXOKch4Re l1oWOxatuUTVctDWiQuA6tir/yu3rDfkWBu6j/zNjx5NgNyF9JANI4qHwRgxHb5+x2zj7JZzkMFRQ FwN8lazg==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pGNPm-007Hoz-Is; Fri, 13 Jan 2023 18:00:27 +0100 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Simon Ser , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Zack Rusin Subject: [PATCH v3 1/3] drm/framebuffer: Check for valid formats Date: Fri, 13 Jan 2023 13:59:18 -0300 Message-Id: <20230113165919.580210-2-mcanal@igalia.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113165919.580210-1-mcanal@igalia.com> References: <20230113165919.580210-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Andr=C3=A9_Almeida?= , Daniel Vetter , =?utf-8?q?Ma=C3=ADra_Canal?= , amd-gfx@lists.freedesktop.org, Melissa Wen , VMware Graphics Reviewers , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, framebuffer_check() doesn't check if the pixel format is supported, which can lead to the acceptance of invalid pixel formats e.g. the acceptance of invalid modifiers. Therefore, add a check for valid formats on framebuffer_check(), so that the ADDFB2 IOCTL rejects calls with invalid formats. Moreover, note that this check is only valid for atomic drivers, because, for non-atomic drivers, checking drm_any_plane_has_format() is not possible since the format list for the primary plane is fake, and we'd therefore reject valid formats. Reviewed-by: Daniel Vetter Signed-off-by: Maíra Canal --- Documentation/gpu/todo.rst | 9 ++++----- drivers/gpu/drm/drm_framebuffer.c | 8 ++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index 1f8a5ebe188e..3a79c26c5cc7 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -276,11 +276,10 @@ Various hold-ups: - Need to switch to drm_fbdev_generic_setup(), otherwise a lot of the custom fb setup code can't be deleted. -- Many drivers wrap drm_gem_fb_create() only to check for valid formats. For - atomic drivers we could check for valid formats by calling - drm_plane_check_pixel_format() against all planes, and pass if any plane - supports the format. For non-atomic that's not possible since like the format - list for the primary plane is fake and we'd therefor reject valid formats. +- Need to switch to drm_gem_fb_create(), as now framebuffer_check() checks for + valid formats for atomic drivers. + +- Add an addfb format validation for non-atomic drivers. - Many drivers subclass drm_framebuffer, we'd need a embedding compatible version of the varios drm_gem_fb_create functions. Maybe called diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index aff3746dedfb..0afc9e39188a 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -280,6 +280,14 @@ static int framebuffer_check(struct drm_device *dev, } } + /* Verify that the modifier is supported. */ + if (r->modifier[0] && drm_drv_uses_atomic_modeset(dev) && + !drm_any_plane_has_format(dev, r->pixel_format, r->modifier[0])) { + drm_dbg_kms(dev, "Unsupported pixel format %p4cc / modifier 0x%llx\n", + &r->pixel_format, r->modifier[0]); + return -EINVAL; + } + return 0; } From patchwork Fri Jan 13 16:59:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13101177 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40074C54EBE for ; Fri, 13 Jan 2023 17:00:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53DA910EA6C; Fri, 13 Jan 2023 17:00:51 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id E72C810EA70; Fri, 13 Jan 2023 17:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6XeSl7wi55EK/GcJ80AIBwpDhIHeyNAljXv8nYVrQ34=; b=OaFH1bpfNOiunP9K5TKTvnO7GJ KmefqAIJXgvnuUE4Mc1Kx2wevO77ATQy/HzqcqXzWhBlNr9Yb7BNvUPK+TROf9IlKZFtEqleor+ox 1tbiN2yVf0Nw388iw1duE+OZZS5G75rJDS9o38afD0RZm5tVLLy6xkv34VswV8LZQY9/TBpW5zqlk teG2a691T9FsOHmdzPFwBGhQrZLEkkFuK/nhOBXgxYe0QeNjxqK0bt2XvMWgDgKBfo0HyJy2Ld762 lXVdNukgoteiPM8hah6feq1ckybp5crmHoN3uH8yGS+4p2+ysNqCWPDKt8WTQpTifWwd8jUDoD7No 3sS3zJhA==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pGNPs-007Hoz-0Q; Fri, 13 Jan 2023 18:00:32 +0100 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Simon Ser , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Zack Rusin Subject: [PATCH v3 2/3] drm/amdgpu: Remove redundant framebuffer format check Date: Fri, 13 Jan 2023 13:59:19 -0300 Message-Id: <20230113165919.580210-3-mcanal@igalia.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113165919.580210-1-mcanal@igalia.com> References: <20230113165919.580210-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Andr=C3=A9_Almeida?= , =?utf-8?q?Ma?= =?utf-8?q?=C3=ADra_Canal?= , amd-gfx@lists.freedesktop.org, Melissa Wen , VMware Graphics Reviewers , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Now that framebuffer_check() verifies that the format is properly supported, there is no need to check it again on amdgpu's inside helpers. Therefore, remove the redundant framebuffer format check from the amdgpu_display_gem_fb_verify_and_init() function, letting framebuffer_check() perform the framebuffer validation. Reviewed-by: Simon Ser Signed-off-by: Maíra Canal --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index b22471b3bd63..611b7a4b086c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -1120,16 +1120,6 @@ static int amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev, rfb->base.obj[0] = obj; drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd); - /* Verify that the modifier is supported. */ - if (!drm_any_plane_has_format(dev, mode_cmd->pixel_format, - mode_cmd->modifier[0])) { - drm_dbg_kms(dev, - "unsupported pixel format %p4cc / modifier 0x%llx\n", - &mode_cmd->pixel_format, mode_cmd->modifier[0]); - - ret = -EINVAL; - goto err; - } ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj); if (ret) From patchwork Fri Jan 13 16:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13101178 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6DD12C54EBE for ; Fri, 13 Jan 2023 17:01:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D1AF10EA70; Fri, 13 Jan 2023 17:00:59 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3EBE210EA70; Fri, 13 Jan 2023 17:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=hMAR/fe4a+AqXAMEBm+JMkSSpKLeGsuHKZQINVwuouc=; b=peM/G9C7k2HUlD7jat6cOSPzU9 8uNMHGtngx06eV9F78Fti+qynhmhmz186Rc3Bu3nykmWf2vrQMogZeq7elnMxn0/6GeDMD8MJ5kOY 3Jal1x7vNxsbIxWKKfz0sikIMS7/n3HvbcaNOwdBoHw+ub5bGq5/vYsGh9maTJg6pj4J/mlWNyqoX PHfRNP1iPrJPCTSzknti/5bB9f75IiduN692EuMiEDyHFS6blY3I7h1lzdIa3I6wah4gm+ea+My4m qzHNOk5n20gvwQEeGBIzpopDq6t4JHuNxihqp90aNHdJcQEUSYLC04XskLOu0wcitRn0xihrw2P3a EjH/Dcxw==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pGNPx-007Hoz-Co; Fri, 13 Jan 2023 18:00:37 +0100 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Simon Ser , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Zack Rusin Subject: [PATCH v3 3/3] drm/vmwgfx: Remove redundant framebuffer format check Date: Fri, 13 Jan 2023 13:59:20 -0300 Message-Id: <20230113165919.580210-4-mcanal@igalia.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113165919.580210-1-mcanal@igalia.com> References: <20230113165919.580210-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Andr=C3=A9_Almeida?= , =?utf-8?q?Ma?= =?utf-8?q?=C3=ADra_Canal?= , amd-gfx@lists.freedesktop.org, Melissa Wen , VMware Graphics Reviewers , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Now that framebuffer_check() verifies that the format is properly supported, there is no need to check it again on vmwgfx's inside helpers. Therefore, remove the redundant framebuffer format check from the vmw_kms_new_framebuffer_surface() and vmw_kms_new_framebuffer_bo() functions, letting framebuffer_check() perform the framebuffer validation. Reviewed-by: Zack Rusin Signed-off-by: Maíra Canal --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 257f090071f1..05b8d8f912bf 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -1317,15 +1317,6 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv, * Sanity checks. */ - if (!drm_any_plane_has_format(&dev_priv->drm, - mode_cmd->pixel_format, - mode_cmd->modifier[0])) { - drm_dbg(&dev_priv->drm, - "unsupported pixel format %p4cc / modifier 0x%llx\n", - &mode_cmd->pixel_format, mode_cmd->modifier[0]); - return -EINVAL; - } - /* Surface must be marked as a scanout. */ if (unlikely(!surface->metadata.scanout)) return -EINVAL; @@ -1648,15 +1639,6 @@ static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv, return -EINVAL; } - if (!drm_any_plane_has_format(&dev_priv->drm, - mode_cmd->pixel_format, - mode_cmd->modifier[0])) { - drm_dbg(&dev_priv->drm, - "unsupported pixel format %p4cc / modifier 0x%llx\n", - &mode_cmd->pixel_format, mode_cmd->modifier[0]); - return -EINVAL; - } - vfbd = kzalloc(sizeof(*vfbd), GFP_KERNEL); if (!vfbd) { ret = -ENOMEM;