From patchwork Thu Nov 17 07:54:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Ser X-Patchwork-Id: 13046272 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 8990BC433FE for ; Thu, 17 Nov 2022 07:54:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7BAF210E565; Thu, 17 Nov 2022 07:54:55 +0000 (UTC) Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) by gabe.freedesktop.org (Postfix) with ESMTPS id E4AC410E565 for ; Thu, 17 Nov 2022 07:54:51 +0000 (UTC) Date: Thu, 17 Nov 2022 07:54:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail3; t=1668671689; x=1668930889; bh=1cuoc+c0B+o0lfrnedqd5WCFg5h3m6La1/QER4aQjds=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=Bj+htasW8sXvK2+HDk1XwIkbOUtnHrFev999/911vdVW1ELp7MGRqrPQnKlZwdEej erxwCVpxUqpZoKti3OJe6VQtE6209kejI63RQKNjnD2bmHt/H23rb93DZO3lWhFiFC 9+DFC24V0+DBhZmdtD/5MxNhzWd79a0ppjJawgi6DHTdqSX24XHg+W0LPf0nyvz8z+ GLzAujJdeGd0+TH1wVubUql6B3L8U8FZ3ByeSGtCHnOruFg4MyJCZcbmMQ7O81QLwu BUdTSUiC3AzlY3iq+co3aino06c/ps1bcTd3vnLLTIWUctaz4xsnCT++ZBx3xuE+5t Cl/wXYjFf21Jg== To: dri-devel@lists.freedesktop.org, wayland-devel@lists.freedesktop.org From: Simon Ser Subject: [PATCH] drm/atomic: add quirks for blind save/restore Message-ID: <20221117075433.222968-1-contact@emersion.fr> Feedback-ID: 1358184:user:proton 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Two quirks to make blind atomic save/restore [1] work correctly: - Mark the DPMS property as immutable for atomic clients, since atomic clients cannot change it. - Allow user-space to set content protection to "enabled", interpret it as "desired". [1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3794 Signed-off-by: Simon Ser Acked-by: Pekka Paalanen Reviewed-by: Daniel Vetter --- I don't have the motivation to write IGT tests for this. drivers/gpu/drm/drm_atomic_uapi.c | 5 +++-- drivers/gpu/drm/drm_property.c | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index c06d0639d552..95363aac7f69 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -741,8 +741,9 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, state->scaling_mode = val; } else if (property == config->content_protection_property) { if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) { - drm_dbg_kms(dev, "only drivers can set CP Enabled\n"); - return -EINVAL; + /* Degrade ENABLED to DESIRED so that blind atomic + * save/restore works as intended. */ + val = DRM_MODE_CONTENT_PROTECTION_DESIRED; } state->content_protection = val; } else if (property == config->hdcp_content_type_property) { diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c index dfec479830e4..dde42986f8cb 100644 --- a/drivers/gpu/drm/drm_property.c +++ b/drivers/gpu/drm/drm_property.c @@ -474,7 +474,14 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, return -ENOENT; strscpy_pad(out_resp->name, property->name, DRM_PROP_NAME_LEN); + out_resp->flags = property->flags; + if (file_priv->atomic && property == dev->mode_config.dpms_property) { + /* Quirk: indicate that the legacy DPMS property is not + * writable from atomic user-space, so that blind atomic + * save/restore works as intended. */ + out_resp->flags |= DRM_MODE_PROP_IMMUTABLE; + } value_count = property->num_values; values_ptr = u64_to_user_ptr(out_resp->values_ptr);