From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3870CC43460 for ; Tue, 27 Apr 2021 09:20:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CEC7A61090 for ; Tue, 27 Apr 2021 09:20:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEC7A61090 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD8D06E938; Tue, 27 Apr 2021 09:20: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 E7D526E933 for ; Tue, 27 Apr 2021 09:20:31 +0000 (UTC) Received: by mail-wr1-x434.google.com with SMTP id q9so4531135wrs.6 for ; Tue, 27 Apr 2021 02:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cqP0gjc1UtzViswayeYBkOIxC7p7CX3JMgXUxI4EqHg=; b=XlkIchkuAqzR02//z/8rHKE0NKhNuLJTVZER4lpBdGGOLCqjnyyu7ruxnlyWcM3mfM 3H1UVfG8giq2OJxoqtHBKxnXQu6aT7cvF8xAEiVE0HX+NtZYedtm4QRboi2pJ8w0ahgF C1xOq7ubv1pPeLMx66CLx+UrrAhGZ+S7v6iug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cqP0gjc1UtzViswayeYBkOIxC7p7CX3JMgXUxI4EqHg=; b=C+kUUwhaudn7ZC9Qzbt51lWdghKASlqt4BraIwsgGgnjBhXv4XlIw0s9V7fO7oOOtu 3EAzwiQPKefs7pIUO25fj/S2lPFEoMzCVRo49FqOenD5Yk8ocF1/m3lf0kxEMGK4MqLE JhghF3IfYo6fGiCp4XkoQU9PNGJZ+dwEryfhVK0PKtDctjcIvKeZ4nOI/UrpkENnhPno 5d9INo7qQ3acNlr1IAhkmwZObQrTE2+LHQQzv6rs8OC+imDw09kdCTDF5msaQmywvtmK JimN9jehHXsxQIfqr0W3ekew/Fd2d4wXSNRpGhOFlnB6ho356MS2ZASSA5d60YYkSHnC 0XMA== X-Gm-Message-State: AOAM531kRSaN1+1An58OAtDMX9+B4b3CMEeX7raYvPHsUnB9Cpo5NOq9 6nurrrRrJW4WdU/MD1494s8akUO3355sOg== X-Google-Smtp-Source: ABdhPJzFTPu8PR2Hkya76z2tUgTkdBNHRW1jhO6CUU2wi4dYHPpDs0xPUpM0knu4xaa5W+ugt8qT3g== X-Received: by 2002:adf:ee0b:: with SMTP id y11mr28031670wrn.75.1619515230687; Tue, 27 Apr 2021 02:20:30 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id r24sm1939816wmh.8.2021.04.27.02.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 02:20:30 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 8/8] drm/modifiers: Enforce consistency between the cap an IN_FORMATS Date: Tue, 27 Apr 2021 11:20:18 +0200 Message-Id: <20210427092018.832258-8-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210427092018.832258-1-daniel.vetter@ffwll.ch> References: <20210427092018.832258-1-daniel.vetter@ffwll.ch> 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: Pekka Paalanen , David Airlie , Daniel Vetter , Intel Graphics Development , Maxime Ripard , Thomas Zimmermann , Daniel Vetter Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It's very confusing for userspace to have to deal with inconsistencies here, and some drivers screwed this up a bit. Most just ommitted the format list when they meant to say that only linear modifier is allowed, but some also meant that only implied modifiers are acceptable (because actually none of the planes registered supported modifiers). Now that this is all done consistently across all drivers, document the rules and enforce it in the drm core. v2: - Make the capability a link (Simon) - Note that all is lost before 5.1. Acked-by: Maxime Ripard Cc: Simon Ser Reviewed-by: Lucas Stach Cc: Pekka Paalanen Signed-off-by: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter --- drivers/gpu/drm/drm_plane.c | 18 +++++++++++++++++- include/drm/drm_mode_config.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 0dd43882fe7c..20c7a1665414 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -128,6 +128,13 @@ * 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. + * + * Note that userspace can check the &DRM_CAP_ADDFB2_MODIFIERS driver + * capability for general modifier support. If this flag is set then every + * plane will have the IN_FORMATS property, even when it only supports + * DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been + * various bugs in this area with inconsistencies between the capability + * flag and per-plane properties. */ static unsigned int drm_num_planes(struct drm_device *dev) @@ -277,8 +284,14 @@ static int __drm_universal_plane_init(struct drm_device *dev, format_modifier_count++; } - if (format_modifier_count) + /* autoset the cap and check for consistency across all planes */ + if (format_modifier_count) { + WARN_ON(!config->allow_fb_modifiers && + !list_empty(&config->plane_list)); config->allow_fb_modifiers = true; + } else { + WARN_ON(config->allow_fb_modifiers); + } plane->modifier_count = format_modifier_count; plane->modifiers = kmalloc_array(format_modifier_count, @@ -360,6 +373,9 @@ static int __drm_universal_plane_init(struct drm_device *dev, * drm_universal_plane_init() to let the DRM managed resource infrastructure * take care of cleanup and deallocation. * + * Drivers supporting modifiers must set @format_modifiers on all their planes, + * even those that only support DRM_FORMAT_MOD_LINEAR. + * * Returns: * Zero on success, error code on failure. */ diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index ab424ddd7665..1ddf7783fdf7 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -909,6 +909,8 @@ struct drm_mode_config { * @allow_fb_modifiers: * * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call. + * Note that drivers should not set this directly, it is automatically + * set in drm_universal_plane_init(). * * IMPORTANT: * -- 2.31.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79849C433B4 for ; Tue, 27 Apr 2021 09:20:52 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3744061026 for ; Tue, 27 Apr 2021 09:20:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3744061026 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 823876E93A; Tue, 27 Apr 2021 09:20:34 +0000 (UTC) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by gabe.freedesktop.org (Postfix) with ESMTPS id E87D56E934 for ; Tue, 27 Apr 2021 09:20:31 +0000 (UTC) Received: by mail-wr1-x429.google.com with SMTP id d11so852577wrw.8 for ; Tue, 27 Apr 2021 02:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cqP0gjc1UtzViswayeYBkOIxC7p7CX3JMgXUxI4EqHg=; b=XlkIchkuAqzR02//z/8rHKE0NKhNuLJTVZER4lpBdGGOLCqjnyyu7ruxnlyWcM3mfM 3H1UVfG8giq2OJxoqtHBKxnXQu6aT7cvF8xAEiVE0HX+NtZYedtm4QRboi2pJ8w0ahgF C1xOq7ubv1pPeLMx66CLx+UrrAhGZ+S7v6iug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cqP0gjc1UtzViswayeYBkOIxC7p7CX3JMgXUxI4EqHg=; b=Xfvr4GLPIEm0z5csIXsx1yE2E5pjRlxvLyYPwqQiOJnBm2ZAipJwO/mutVQfUEgh98 tG2xMf2K8S+HMis7qZvtuMfA5m058rPpMraMpDb2QArSADkRsdECbwOvutO1zlxX5HOm v/3yXzacoA2Kl0fYuNyynV8BQ8RHZ1pkXZwz0rfCSjVIGQiD2m3T63Ecbgk9vB2JNSc4 kKErBunpDFMcpwSa0+zxQPRJylY1BAPfFlbrTEGApOOG5Bgu0aOyn/eP0qN2p+T/tqhM WObgvgN+BkQwbMlFwyXIk37B1ube2uRRmn927uTII+yXShtw5r1bjm4s+7N/wGF/TTUS 2nAA== X-Gm-Message-State: AOAM530NcgAetukYt7E2tKI1gP+QFyQ1Xu2J0c7oydXHl+hlwRtKSjjN z5RixLglNP13JM5xNc9cZt7sUA== X-Google-Smtp-Source: ABdhPJzFTPu8PR2Hkya76z2tUgTkdBNHRW1jhO6CUU2wi4dYHPpDs0xPUpM0knu4xaa5W+ugt8qT3g== X-Received: by 2002:adf:ee0b:: with SMTP id y11mr28031670wrn.75.1619515230687; Tue, 27 Apr 2021 02:20:30 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id r24sm1939816wmh.8.2021.04.27.02.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 02:20:30 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Apr 2021 11:20:18 +0200 Message-Id: <20210427092018.832258-8-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210427092018.832258-1-daniel.vetter@ffwll.ch> References: <20210427092018.832258-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 8/8] drm/modifiers: Enforce consistency between the cap an IN_FORMATS X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pekka Paalanen , David Airlie , Daniel Vetter , Intel Graphics Development , Maxime Ripard , Maxime Ripard , Thomas Zimmermann , Simon Ser , Daniel Vetter , Lucas Stach Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" It's very confusing for userspace to have to deal with inconsistencies here, and some drivers screwed this up a bit. Most just ommitted the format list when they meant to say that only linear modifier is allowed, but some also meant that only implied modifiers are acceptable (because actually none of the planes registered supported modifiers). Now that this is all done consistently across all drivers, document the rules and enforce it in the drm core. v2: - Make the capability a link (Simon) - Note that all is lost before 5.1. Acked-by: Maxime Ripard Cc: Simon Ser Reviewed-by: Lucas Stach Cc: Pekka Paalanen Signed-off-by: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter --- drivers/gpu/drm/drm_plane.c | 18 +++++++++++++++++- include/drm/drm_mode_config.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 0dd43882fe7c..20c7a1665414 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -128,6 +128,13 @@ * 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. + * + * Note that userspace can check the &DRM_CAP_ADDFB2_MODIFIERS driver + * capability for general modifier support. If this flag is set then every + * plane will have the IN_FORMATS property, even when it only supports + * DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been + * various bugs in this area with inconsistencies between the capability + * flag and per-plane properties. */ static unsigned int drm_num_planes(struct drm_device *dev) @@ -277,8 +284,14 @@ static int __drm_universal_plane_init(struct drm_device *dev, format_modifier_count++; } - if (format_modifier_count) + /* autoset the cap and check for consistency across all planes */ + if (format_modifier_count) { + WARN_ON(!config->allow_fb_modifiers && + !list_empty(&config->plane_list)); config->allow_fb_modifiers = true; + } else { + WARN_ON(config->allow_fb_modifiers); + } plane->modifier_count = format_modifier_count; plane->modifiers = kmalloc_array(format_modifier_count, @@ -360,6 +373,9 @@ static int __drm_universal_plane_init(struct drm_device *dev, * drm_universal_plane_init() to let the DRM managed resource infrastructure * take care of cleanup and deallocation. * + * Drivers supporting modifiers must set @format_modifiers on all their planes, + * even those that only support DRM_FORMAT_MOD_LINEAR. + * * Returns: * Zero on success, error code on failure. */ diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index ab424ddd7665..1ddf7783fdf7 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -909,6 +909,8 @@ struct drm_mode_config { * @allow_fb_modifiers: * * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call. + * Note that drivers should not set this directly, it is automatically + * set in drm_universal_plane_init(). * * IMPORTANT: * -- 2.31.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx