From patchwork Tue Dec 21 10:13:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12689477 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 1E946C433F5 for ; Tue, 21 Dec 2021 10:13:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 116A810F1C8; Tue, 21 Dec 2021 10:13:33 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F91910F1C8; Tue, 21 Dec 2021 10:13:30 +0000 (UTC) Received: by mail-wr1-x431.google.com with SMTP id s1so25898721wrg.1; Tue, 21 Dec 2021 02:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nTc5PZ4Wpig4VXigMSaZ0XPsk2m3HQFKiyeVvNbBNNc=; b=dJHKjSoEEyVDkgtyh+/qOBv2HluDHaGeirviwPCijFFsSYfAhtrw4ytbGMh5V6eqpV ccUrgpQQwnhNyl1FVEETH07cmfqFR5oq+3eEN2QgH5ZLA1ZiERd7bJ7/PVCc8jNSpfsz 7ha/4NGab+1PYTf58rRiQBsLI5ucgutc66cqc2iOt9k8aDjcEfTPHkyFdwaHaYf3KSrA /yC0imuNG3jMSHoSAlU1pibAoiLgS+huZgX3msw/pKYg0tT5990jrKTgMR3/n3M6pbVN vXuLxJpKgVbm/852wjXVhog0tfoBKaeV6vKPIDdgX20pvenMvW1lh0T7u7FYQd9DyXKO OPkw== 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=nTc5PZ4Wpig4VXigMSaZ0XPsk2m3HQFKiyeVvNbBNNc=; b=G0F/o6ypnrUDX/jWYylpXkMT8prwQk8BIIf9avH++nVwibttu/dZVMKpN7ErKOPlD3 GbOwlMjnisNkZIJGcfZQVMidy9TGNhFTbOyPxWjWAKTWldJFuEFuS4/QNMhp3/vU63WZ 62c8CO0Q/SUff8g8zUFIS31iIa2hbPZ6RSHc2iCjImYvwAmLTRAmQuc7oEdptHYo/rW3 sbNB43SfMkyIY5YExcMeBGWHOCN80jEDOoXspgXYNGVjBg7f+J+LIsv7ef5+Pctizzr0 cGK9SKJ+YybDZsf7E8aOjnRqjTmOpkWp2F6O64ImU6mWY4UeeWcfO9c96A0TE6nAVz23 Brzg== X-Gm-Message-State: AOAM531bmFx5RkAQn8TCo9AeldTOTawgdsCmknpfdI1EBsdoJpAsstc8 pjQ6du2bG3chF9coBbgerUs= X-Google-Smtp-Source: ABdhPJwWwRH/sAEV2HigzIshd3439K7j8BsMJXS05VWy3mSDd+pPK3adu3sTGg0uNpYiwEPOmgUKZw== X-Received: by 2002:a5d:64a7:: with SMTP id m7mr1949098wrp.687.1640081608579; Tue, 21 Dec 2021 02:13:28 -0800 (PST) Received: from localhost.localdomain ([217.113.240.86]) by smtp.gmail.com with ESMTPSA id m21sm18012267wrb.2.2021.12.21.02.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 02:13:28 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: robdclark@gmail.com Subject: [PATCH 1/3] drm/plane: Mention format_mod_supported in IN_FORMATS docs Date: Tue, 21 Dec 2021 11:13:17 +0100 Message-Id: <20211221101319.7980-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221101319.7980-1-jose.exposito89@gmail.com> References: <20211221101319.7980-1-jose.exposito89@gmail.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: freedreno@lists.freedesktop.org, jernej.skrabec@gmail.com, airlied@linux.ie, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, wens@csie.org, maxime@cerno.tech, tzimmermann@suse.de, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , sean@poorly.run, linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Adding format modifiers without implementing the function "drm_plane_funcs.format_mod_supported" exposes an invalid IN_FORMATS blob with modifiers but no formats to user-space. This breaks the latest Weston [1]. For testing purposes, I extracted the affected code to a standalone program [2]. Make clear in the IN_FORMATS documentation that implementing "format_mod_supported" is mandatory. [1] https://gitlab.freedesktop.org/wayland/weston/-/blob/9.0/libweston/backend-drm/kms.c#L431 [2] https://github.com/JoseExposito/drm-sandbox/blob/main/in_formats.c Signed-off-by: José Expósito Reviewed-by: Simon Ser --- drivers/gpu/drm/drm_plane.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 82afb854141b..347571f8909a 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -126,8 +126,11 @@ * IN_FORMATS: * Blob property which contains the set of buffer format and modifier * pairs supported by this plane. The blob is a struct - * drm_format_modifier_blob. Without this property the plane doesn't - * support buffers with modifiers. Userspace cannot change this property. + * drm_format_modifier_blob and the drm_plane_funcs.format_mod_supported + * function must be implemented by the driver to determine if the given + * format/modifier combination is valid for the plane. Without this property + * the plane doesn't support buffers with modifiers. Userspace cannot change + * this property. * * Note that userspace can check the &DRM_CAP_ADDFB2_MODIFIERS driver * capability for general modifier support. If this flag is set then every From patchwork Tue Dec 21 10:13:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12689481 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 8D101C433F5 for ; Tue, 21 Dec 2021 10:13:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8638C10F8D3; Tue, 21 Dec 2021 10:13:33 +0000 (UTC) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6558910F1C8; Tue, 21 Dec 2021 10:13:31 +0000 (UTC) Received: by mail-wr1-x434.google.com with SMTP id t18so25761448wrg.11; Tue, 21 Dec 2021 02:13:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BFpZdmylFWaxjp/eKztb6USl6FN9U+6JIs/PIPKjnRc=; b=pr/JtJb6WF0mQRD4vOqRacTgAvypWKEfk5V8syiJ9sIDUxNN7jQrq1XKXDsBABqB3H DXLpsoP5dGydBjl/uyIiN40HdW11PvdjEe2DTpV9AvR7iiiSmPkvo6q5qo0QuYpmSn1b RkHn18uFSr0cv2V73JCTMQ5RsP2+Tpl8Opl/ZvaVRVPiKlvJqEZ9keLBs9oPJV9BQthg 5qijCUVRCAZbuQzKWRfM8525TyNqDiqukLQhd6Ayr+oj3VAi8UBbl8moRwUl2PIwK05Q /liEv1cmO+FYYCWkD9PB9pEF1nKTnN65qxU23KALNBNKH9eFoDluBspEw9LtzjTGXd6w vXrQ== 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=BFpZdmylFWaxjp/eKztb6USl6FN9U+6JIs/PIPKjnRc=; b=UtSxpjXuw9mG4fohvZpfTiuJ+yxXVJK+Pemr5zeN/VQVVKJCsXI69k5FxFLaPxIn96 kEK0YGyY+S2KOhZBkissIoAQ1PLBixziiu1+ryvOF8gv811LFJVGGJZyWEEcMN552SVS tovM+UMtzp0aK6YPCOp1hBi3piXUYreQJniv1QKOjFN/1OjMHGGt51NaSPnKu0vN7AAp ZoCquQlBBErtqTJshHf61wNe7w3dHVryUNLOkEj9v9K0qkDRoHPtJ7vCZRgkGLJRWS84 mxjk/PZ1ubyS6tsqyjIYNelg5ZNGFOopkyM7lKfwctRReQLOxBmSG3YHY4PA7Ue9WhAf PV0w== X-Gm-Message-State: AOAM532rTnDB7C39ty6oKLykBWWK0u99K/bIcnKBeiACxU2mQgq0WD/Z RYjssFzUB04u1Eg+j5tia5E= X-Google-Smtp-Source: ABdhPJzAPRTEhTqDe67YQMa1+RCtyyuXKyFuoRwZlIZMVBSj/As0a4YnwYmSvRWTIecaf4LuQzMRTA== X-Received: by 2002:adf:d1e9:: with SMTP id g9mr2088396wrd.238.1640081609809; Tue, 21 Dec 2021 02:13:29 -0800 (PST) Received: from localhost.localdomain ([217.113.240.86]) by smtp.gmail.com with ESMTPSA id m21sm18012267wrb.2.2021.12.21.02.13.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 02:13:29 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: robdclark@gmail.com Subject: [PATCH 2/3] drm/msm/mdp4: Add format_mod_supported function Date: Tue, 21 Dec 2021 11:13:18 +0100 Message-Id: <20211221101319.7980-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221101319.7980-1-jose.exposito89@gmail.com> References: <20211221101319.7980-1-jose.exposito89@gmail.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: freedreno@lists.freedesktop.org, jernej.skrabec@gmail.com, airlied@linux.ie, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, wens@csie.org, maxime@cerno.tech, tzimmermann@suse.de, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , sean@poorly.run, linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Implement the missing "drm_plane_funcs.format_mod_supported" function to avoid exposing an invalid IN_FORMATS blob with modifiers but no formats. Signed-off-by: José Expósito --- drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c index 49bdabea8ed5..8809f1633786 100644 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c @@ -80,6 +80,13 @@ static int mdp4_plane_set_property(struct drm_plane *plane, return -EINVAL; } +static bool mdp4_plane_format_mod_supported(struct drm_plane *plane, u32 format, + u64 modifier) +{ + return (modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) || + (modifier == DRM_FORMAT_MOD_LINEAR); +} + static const struct drm_plane_funcs mdp4_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, @@ -88,6 +95,7 @@ static const struct drm_plane_funcs mdp4_plane_funcs = { .reset = drm_atomic_helper_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, + .format_mod_supported = mdp4_plane_format_mod_supported, }; static void mdp4_plane_cleanup_fb(struct drm_plane *plane, From patchwork Tue Dec 21 10:13:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12689479 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 4BCB7C433FE for ; Tue, 21 Dec 2021 10:13:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 904E710F8DF; Tue, 21 Dec 2021 10:13:33 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F56810F1C8; Tue, 21 Dec 2021 10:13:32 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id s1so20443830wra.6; Tue, 21 Dec 2021 02:13:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DEyc+NVxVKi+L8yckVOHzJw2NoQPHaqK818Sh5CD0II=; b=lxMPKYkdr/tQQ5EF9glUhX8o6TAPzZHvOOcoty8aNGCRmqkX67V5uOWbfJu2le08B+ k5Vb67u4Hj9e6ds5NQVE1QBG2BLEftP90TQPLF5pUYHG9RBeIIV3aZxipCeyzGSFDIBP Gw/UzNTUcXDmfnIC5nii9VhaJ7ubVO//u+xpHk8ftoqOnGirhOFZaEW/W3pNAnfUzgaH vBvxWdEUh9havG6ympZQiTKQCMg/xhVwAIWo6ByxJ3Hw6jIcSMsMdm3yZWtBmx/IZj5E iyrYtaF263Fe4tH/Dz1A2sKmma4e/WamHVQeGJYLWfMOBNEG1vzkzYQAZ5eJHzbdooWx C6yg== 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=DEyc+NVxVKi+L8yckVOHzJw2NoQPHaqK818Sh5CD0II=; b=jld9V1fxzmvkq4wUdeMPoH1pr/9hgcPHDYnVfmsL22Rzk+8gVLOdTOgzLXhA/UnUFl duOB3BMTh+1zStiDoFEloeqbRo+RFd4Bg68Ji5SXY9rO3VK7+HhD6D8IRtOlfkFzwn9e 94Wd44kLhKKDN9aqzP6aT5AzGk5pmptj6wvPUn2AiTMiCqi3hIaaNjdMa30EnWsyGpUu d8yGGt6/WvOwyq7XgFz/k2n/MZ8hgUl6tda1JDgaD8am1BNNfQs0LIZbsse50atoq0yB dboTD/9T+w3sQDn7BgzSRKZTjwv5IIIslNnyI5/LFWcMNCe7bahJyaiaFCHJqF9ClOUG Awgw== X-Gm-Message-State: AOAM533aZ8l1Jx+E4UCJ6PLSIpM71c+USOTmcCdTuF3iFg/F+cSaxffi Ef4KgbhEqj33J7UI+WmnV8Q= X-Google-Smtp-Source: ABdhPJwlXh9Hinn/Wk7ysQCkWYtXKp4CzjPNtpjWfGGw6aNsx8L9xFEr+Qk++VuuE6LFwzWkgksbVQ== X-Received: by 2002:adf:fdc9:: with SMTP id i9mr2018666wrs.660.1640081611007; Tue, 21 Dec 2021 02:13:31 -0800 (PST) Received: from localhost.localdomain ([217.113.240.86]) by smtp.gmail.com with ESMTPSA id m21sm18012267wrb.2.2021.12.21.02.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 02:13:30 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: robdclark@gmail.com Subject: [PATCH 3/3] drm/sun4i: Add format_mod_supported function Date: Tue, 21 Dec 2021 11:13:19 +0100 Message-Id: <20211221101319.7980-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221101319.7980-1-jose.exposito89@gmail.com> References: <20211221101319.7980-1-jose.exposito89@gmail.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: freedreno@lists.freedesktop.org, jernej.skrabec@gmail.com, airlied@linux.ie, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, wens@csie.org, maxime@cerno.tech, tzimmermann@suse.de, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , sean@poorly.run, linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Implement the missing "drm_plane_funcs.format_mod_supported" function to avoid exposing an invalid IN_FORMATS blob with modifiers but no formats. Signed-off-by: José Expósito --- drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 7 +++++++ drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c index 7845c2a53a7f..728563f23cd6 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c @@ -331,6 +331,12 @@ static void sun8i_ui_layer_atomic_update(struct drm_plane *plane, true, zpos, old_zpos); } +static bool sun8i_ui_layer_format_mod_supported(struct drm_plane *plane, + u32 format, u64 modifier) +{ + return (modifier == DRM_FORMAT_MOD_LINEAR); +} + static const struct drm_plane_helper_funcs sun8i_ui_layer_helper_funcs = { .atomic_check = sun8i_ui_layer_atomic_check, .atomic_disable = sun8i_ui_layer_atomic_disable, @@ -344,6 +350,7 @@ static const struct drm_plane_funcs sun8i_ui_layer_funcs = { .disable_plane = drm_atomic_helper_disable_plane, .reset = drm_atomic_helper_plane_reset, .update_plane = drm_atomic_helper_update_plane, + .format_mod_supported = sun8i_ui_layer_format_mod_supported, }; static const u32 sun8i_ui_layer_formats[] = { diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c index bb7c43036dfa..d17813a7cac3 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c @@ -435,6 +435,12 @@ static void sun8i_vi_layer_atomic_update(struct drm_plane *plane, true, zpos, old_zpos); } +static bool sun8i_vi_layer_format_mod_supported(struct drm_plane *plane, + u32 format, u64 modifier) +{ + return (modifier == DRM_FORMAT_MOD_LINEAR); +} + static const struct drm_plane_helper_funcs sun8i_vi_layer_helper_funcs = { .atomic_check = sun8i_vi_layer_atomic_check, .atomic_disable = sun8i_vi_layer_atomic_disable, @@ -448,6 +454,7 @@ static const struct drm_plane_funcs sun8i_vi_layer_funcs = { .disable_plane = drm_atomic_helper_disable_plane, .reset = drm_atomic_helper_plane_reset, .update_plane = drm_atomic_helper_update_plane, + .format_mod_supported = sun8i_vi_layer_format_mod_supported, }; /*