From patchwork Thu Dec 10 15:50:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Ser X-Patchwork-Id: 11965185 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=-18.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 97851C4361B for ; Thu, 10 Dec 2020 15:50:37 +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 B2DE323D20 for ; Thu, 10 Dec 2020 15:50:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2DE323D20 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=emersion.fr 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 326426EA84; Thu, 10 Dec 2020 15:50:36 +0000 (UTC) Received: from mail1.protonmail.ch (mail1.protonmail.ch [185.70.40.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id A0F356EA84 for ; Thu, 10 Dec 2020 15:50:34 +0000 (UTC) Date: Thu, 10 Dec 2020 15:50:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail2; t=1607615432; bh=dd1uKUE/I9vhhZdufmVMrR2Fh4xgpBw+W/jGQNNb3mo=; h=Date:To:From:Cc:Reply-To:Subject:From; b=LkZyhspL4Z2lRNMCbfKb2KoLzZ6bzkh2oVvR1RWBpE9woev6ilN7ir6TU4aeQt6qZ n5iWq8s56mUnrJkP5modRA2ogbZzfJJVRof33ELKMCUOURy6Y74L9VpQTqyokwGHTX 2C87TNE82BZrqJsfBRJGpdSbRV9ZbiPNvMpsxCg/ZRE1FB2WfBgaipC9PX5Rx8wXfe 5F6Uo6X8dfSxFA6zG0WsvHnXvO5MvzMehH+Wc6vAjotCe03zs71WNiP6AWHWdR3LF8 DOxQlnVh96/OYrmCSyDLxHon6pmZ+4F9+X+UndWJkdOrKBzb+pp7Py8xTUU8WYbFeV qBPLsIZ425iUA== To: dri-devel@lists.freedesktop.org From: Simon Ser Subject: [PATCH 1/3] drm: rework description of primary and cursor planes Message-ID: 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: , Reply-To: Simon Ser Cc: Daniel Vetter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The previous wording could be understood by user-space evelopers as "a primary/cursor plane is only compatible with a single CRTC" [1]. Reword the planes description to make it clear the DRM-internal drm_crtc.primary and drm_crtc.cursor planes are for legacy uAPI. [1]: https://github.com/swaywm/wlroots/pull/2333#discussion_r456788057 Signed-off-by: Simon Ser Reviewed-by: Daniel Vetter Cc: Pekka Paalanen --- drivers/gpu/drm/drm_crtc.c | 3 +++ drivers/gpu/drm/drm_plane.c | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 8d19d258547f..a6336c7154d6 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -256,6 +256,9 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc) * planes). For really simple hardware which has only 1 plane look at * drm_simple_display_pipe_init() instead. * + * The @primary and @cursor planes are only relevant for legacy uAPI, see + * &drm_crtc.primary and &drm_crtc.cursor. + * * Returns: * Zero on success, error code on failure. */ diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 385801dd21f9..5d33ca9f0032 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -49,14 +49,16 @@ * &struct drm_plane (possibly as part of a larger structure) and registers it * with a call to drm_universal_plane_init(). * - * Cursor and overlay planes are optional. All drivers should provide one - * primary plane per CRTC to avoid surprising userspace too much. See enum - * drm_plane_type for a more in-depth discussion of these special uapi-relevant - * plane types. Special planes are associated with their CRTC by calling - * drm_crtc_init_with_planes(). - * * The type of a plane is exposed in the immutable "type" enumeration property, - * which has one of the following values: "Overlay", "Primary", "Cursor". + * which has one of the following values: "Overlay", "Primary", "Cursor" (see + * enum drm_plane_type). A plane can be compatible with multiple CRTCs, see + * &drm_plane.possible_crtcs. + * + * Legacy uAPI doesn't expose the primary and cursor planes directly. DRM core + * relies on the driver to set the primary and optionally the cursor plane used + * for legacy IOCTLs. This is done by calling drm_crtc_init_with_planes(). All + * drivers should provide one primary plane per CRTC to avoid surprising legacy + * userspace too much. */ static unsigned int drm_num_planes(struct drm_device *dev) From patchwork Thu Dec 10 15:50:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Ser X-Patchwork-Id: 11965187 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=-13.5 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 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 92843C433FE for ; Thu, 10 Dec 2020 15:50:43 +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 1F83F23D20 for ; Thu, 10 Dec 2020 15:50:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F83F23D20 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=emersion.fr 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 8CB036E3F5; Thu, 10 Dec 2020 15:50:42 +0000 (UTC) Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by gabe.freedesktop.org (Postfix) with ESMTPS id 79D3D6E3F5 for ; Thu, 10 Dec 2020 15:50:41 +0000 (UTC) Date: Thu, 10 Dec 2020 15:50:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail2; t=1607615439; bh=y+0dg4WXnd7ljhZe0I2fblcXDIe0tyImGeiQ1ppGIBc=; h=Date:To:From:Cc:Reply-To:Subject:From; b=LmKCF48ND2zZ16o9AJQfQo5kCgwKPhZpgdsVI5wReiJmG4z0//lXQBM0cNa6cmO1x FyThT17SA+1infnQggb4NvctKxijowfspT9t8S4BVgug/z2YHiEzVdOsZpP8mqC1oI g5vu33WvKvTFWhkl+ertHRPOybZpkJQjJcLoeOFzaqMwj+2Thwm4SGTpUIKpQVOIxD nlD1tSyJJqnbNvmaC2rCth46EcBse+06AYoxsgFsM4N2P93iS4x4PcI7rpEb1XvPxC Ghyl84FVLeTw02ihke8Zez2o1e0pTOoxRh/t+5/ABN4c07F2tWqi8/didxniZUafZy sqqqZ3d+f2lYg== To: dri-devel@lists.freedesktop.org From: Simon Ser Subject: [PATCH 2/3] drm: validate possible_crtcs for primary and cursor planes Message-ID: <9YgBvQ4vfzhtRAXphq8hsw4alh2IZQ3Jh3aQztBFk@cp7-web-042.plabs.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: , Reply-To: Simon Ser Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If a primary or cursor plane is not compatible with a CRTC it's attached to via the legacy primary/cursor field, things will be broken for legacy user-space. Signed-off-by: Simon Ser Cc: Daniel Vetter Cc: Pekka Paalanen Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_mode_config.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index f1affc1bb679..2c73a60e8765 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -625,6 +625,7 @@ static void validate_encoder_possible_crtcs(struct drm_encoder *encoder) void drm_mode_config_validate(struct drm_device *dev) { struct drm_encoder *encoder; + struct drm_crtc *crtc; if (!drm_core_check_feature(dev, DRIVER_MODESET)) return; @@ -636,4 +637,19 @@ void drm_mode_config_validate(struct drm_device *dev) validate_encoder_possible_clones(encoder); validate_encoder_possible_crtcs(encoder); } + + drm_for_each_crtc(crtc, dev) { + if (crtc->primary) { + WARN(!(crtc->primary->possible_crtcs & BIT(crtc->index)), + "Bogus primary plane possible_crtcs: [PLANE:%d:%s] must be compatible with [CRTC:%d:%s]\n", + crtc->primary->base.id, crtc->primary->name, + crtc->base.id, crtc->name); + } + if (crtc->cursor) { + WARN(!(crtc->cursor->possible_crtcs & BIT(crtc->index)), + "Bogus cursor plane possible_crtcs: [PLANE:%d:%s] must be compatible with [CRTC:%d:%s]\n", + crtc->cursor->base.id, crtc->cursor->name, + crtc->base.id, crtc->name); + } + } } From patchwork Thu Dec 10 15:50:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Ser X-Patchwork-Id: 11965189 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=-13.5 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 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 70D9CC433FE for ; Thu, 10 Dec 2020 15:50:46 +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 02F2423CD4 for ; Thu, 10 Dec 2020 15:50:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 02F2423CD4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=emersion.fr 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 6AA306EA90; Thu, 10 Dec 2020 15:50:45 +0000 (UTC) Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 03B1E6EA90 for ; Thu, 10 Dec 2020 15:50:43 +0000 (UTC) Date: Thu, 10 Dec 2020 15:50:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail2; t=1607615441; bh=B1+xPAuBDsXYb2x/z69Z6BTcE5TGOXAA7b1lkaQgV6Q=; h=Date:To:From:Cc:Reply-To:Subject:From; b=WRB7WVeqprJnySXmeJh8yXcC7ASJy5DAzKyFNk4nWxzghHBraAex1VT9XVSYFNrX7 MP0Qtvck6L89Ec5V+u9CIV81WQMChmqP9AOKAYz+2hsdyTlJrpzj4QUrGFyZEhdhIE x1eL859Xe54YNLEpOrytcL95YfkHyJgNMwUalOUSAFJ+ckeU2eXIgQ3/3/nE8f2f5u GiQ3kqulozCE5Fz3HCB1AzRl2IjzQHwOmmDZnIukYPwyzWtK3VLeo47gu8gbitS1cZ iQ2VBj6DAbgOilTVfQH/oHKOUApd4ab3dDLuTfDrUA+8Ctfkg2AX6w4BXjIybv5W4Z ur0U+LoccKdRQ== To: dri-devel@lists.freedesktop.org From: Simon Ser Subject: [PATCH 3/3] drm: require a non_NULL drm_crtc.primary Message-ID: 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: , Reply-To: Simon Ser Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If a CRTC is missing a legacy primary plane pointer, a lot of things will be broken for user-space: fbdev stops working and the entire legacy uAPI stops working. Require all drivers to populate drm_crtc.primary to prevent these issues. Warn if it's NULL. Signed-off-by: Simon Ser Cc: Daniel Vetter Cc: Pekka Paalanen Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_mode_config.c | 3 +++ drivers/gpu/drm/drm_plane.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 2c73a60e8765..fbe680035129 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -639,6 +639,9 @@ void drm_mode_config_validate(struct drm_device *dev) } drm_for_each_crtc(crtc, dev) { + WARN(!crtc->primary, "Missing primary plane on [CRTC:%d:%s]\n", + crtc->base.id, crtc->name); + if (crtc->primary) { WARN(!(crtc->primary->possible_crtcs & BIT(crtc->index)), "Bogus primary plane possible_crtcs: [PLANE:%d:%s] must be compatible with [CRTC:%d:%s]\n", diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 5d33ca9f0032..49b0a8b9ac02 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -57,7 +57,7 @@ * Legacy uAPI doesn't expose the primary and cursor planes directly. DRM core * relies on the driver to set the primary and optionally the cursor plane used * for legacy IOCTLs. This is done by calling drm_crtc_init_with_planes(). All - * drivers should provide one primary plane per CRTC to avoid surprising legacy + * drivers must provide one primary plane per CRTC to avoid surprising legacy * userspace too much. */