From patchwork Wed Oct 6 15:19:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Ser X-Patchwork-Id: 12539553 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C150C433F5 for ; Wed, 6 Oct 2021 15:19:42 +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 DB84360F39 for ; Wed, 6 Oct 2021 15:19:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DB84360F39 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=emersion.fr Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 02DDB6E550; Wed, 6 Oct 2021 15:19:41 +0000 (UTC) Received: from mail-40136.proton.ch (mail-40136.proton.ch [185.70.40.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id ADEF46E550 for ; Wed, 6 Oct 2021 15:19:39 +0000 (UTC) Date: Wed, 06 Oct 2021 15:19:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail; t=1633533576; bh=IlqtNhdaO8cZ/qn4ZXnzlyd0yvsCx815ogXEnwm1pso=; h=Date:To:From:Cc:Reply-To:Subject:From; b=vubZtN0vmy0ecSDZhbKr7GyveDwpkGK/pogMoY+xchJbvs5KyOuvGWEipkTqbdjAO x98FMA4W7/QUZpIJLVstDil3p/cn6wnpOjv8dKFPiSNFqdjKxsXg4VoIDTST/+gVFT jXEU8USTnDi7qaOhmZDVg6GrL85KG+YRKtdBvPCpYMxVRsuaud8fqX507lLD7KDcoq Q2Yl1uR78RvUgyBQQen0kM5SZJsPn6/+qMJmT/JVfulUTSt7l0CDJjmlAJHfeG6SVE 3FPJcG5A8XL5q07zuKVxxK5F9xB/OzRqC9M7iqDYU0xbrrrhG3V/bqUZoOpxkaJwaW /1ll3LrOSt/xQ== To: dri-devel@lists.freedesktop.org From: Simon Ser Cc: Hans de Goede , Dennis Filder , Daniel Vetter , Pekka Paalanen Subject: [PATCH RFC] drm: introduce DRM_MODE_FB_PERSIST Message-ID: <20211006151921.312714-1-contact@emersion.fr> 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" This new ADDFB2 flag allows callers to mark a framebuffer as "persistent", and no longer have RMFB semantics when the DRM file is closed. [1]: https://lore.kernel.org/dri-devel/YTJypepF1Hpc2YYT@reader/ Signed-off-by: Simon Ser Cc: Hans de Goede Cc: Dennis Filder Cc: Daniel Vetter Cc: Pekka Paalanen --- I'm not sure this is enough, but posting this to get initial feedback and allow to start e.g. Plymouth experiments. I'll follow up with an IGT test soon. drivers/gpu/drm/drm_framebuffer.c | 6 ++++-- include/uapi/drm/drm_mode.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 07f5abc875e9..9b398838e1f4 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -292,7 +292,8 @@ drm_internal_framebuffer_create(struct drm_device *dev, struct drm_framebuffer *fb; int ret; - if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS)) { + if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS | + DRM_MODE_FB_PERSIST)) { DRM_DEBUG_KMS("bad framebuffer flags 0x%08x\n", r->flags); return ERR_PTR(-EINVAL); } @@ -789,7 +790,8 @@ void drm_fb_release(struct drm_file *priv) * at it any more. */ list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { - if (drm_framebuffer_read_refcount(fb) > 1) { + if (drm_framebuffer_read_refcount(fb) > 1 && + !(fb->flags & DRM_MODE_FB_PERSIST)) { list_move_tail(&fb->filp_head, &arg.fbs); } else { list_del_init(&fb->filp_head); diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index e1e351682872..c7a7089ec31e 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -662,6 +662,21 @@ struct drm_mode_fb_cmd { #define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */ #define DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifer[] */ +/** + * DRM_MODE_FB_PERSIST + * + * DRM framebuffers are normally implicitly removed when their owner closes the + * DRM FD. Passing this flag will make the framebuffer persistent: it will not + * be implicitly removed. This is useful to implement flicker-free transitions + * between two processes. + * + * This flag doesn't change the behavior of &DRM_IOCTL_MODE_RMFB. + * + * User-space should ensure the framebuffer doesn't expose any sensitive user + * information: persistent framebuffers can be read back by the next DRM + * master. + */ +#define DRM_MODE_FB_PERSIST (1 << 2) struct drm_mode_fb_cmd2 { __u32 fb_id;