From patchwork Sat Apr 1 19:11:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 9658197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3A900602BC for ; Sat, 1 Apr 2017 19:11:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4108B28555 for ; Sat, 1 Apr 2017 19:11:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32A3628552; Sat, 1 Apr 2017 19:11:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AD50328552 for ; Sat, 1 Apr 2017 19:11:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A44F06E18F; Sat, 1 Apr 2017 19:11:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x244.google.com (mail-qt0-x244.google.com [IPv6:2607:f8b0:400d:c0d::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E5D26E18F for ; Sat, 1 Apr 2017 19:11:48 +0000 (UTC) Received: by mail-qt0-x244.google.com with SMTP id r5so14294237qtb.2 for ; Sat, 01 Apr 2017 12:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=stDb8EbbTyyZfcdtaR1rUtiedC1PpR/Wa6Wd5fIGHQw=; b=TfuoYLbY7XQhTI+2ggS/n5/Zp4FAapXdFlJiJG8MEIfDlY4W4QEhHPt2zp0LzoiR/M IdFv5b0tcYxq96oEC3lNImFcvyDIUWO0ML7VlGVAqjN+qZ6uU7aVogikBv02vO4MTB2i 4rsavon+8IGCYGCvK25sf1g6dVjNmwoz+TcMGfPAgCd0AUi4GslCD5vbfreysxzkL3wU eoMfNobtgal6YCIMjk76XKqNTGifAU9WLJiZs2QZzHm4+0n3O1gwBTVnlypH2UfJUCfX xGRQwwfYBfXuDd3GN2Q0wEnxRqgRtEiAwYU0+3fydRFh5gIDbFKfs8blplXe+cwsqs6x 5htg== 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; bh=stDb8EbbTyyZfcdtaR1rUtiedC1PpR/Wa6Wd5fIGHQw=; b=qCJS5RYjRtSrZZNUwHJfH739J/VTa83tq82TvAjq3h4qeVsOicfsuiMt4HS6fglbbn lSgT2q6PJACQhH0TIx8wjaPeiiqfgXFaOChYNwiu4EIm2//LLHkF5hudHpSMwuyC9cRr Vns/qk8y3JIVmtS5OGlJH01SCX3oRtL0Pos3wzh1oZcxMxn2++LrxxgeTTkDNt+ALArs w3x5zPYKpx1wSIpdguH41d9mnmfxP9eJfoeWYNdDdN/GVPPkIuZ12RZgsryaxySZpqa1 7vgDLutR3hwt30gxgAwEgpgGCC0oLXcaWQuW1OQwJdMTzFse0ec81WV06WCuRtxPvmLN s2SQ== X-Gm-Message-State: AFeK/H1CJmHPZLUwEXvYKv/bYQiK6mwECzv0r5ejRLBs5B67R3eh7WZR9RqKSoDkn6HPFg== X-Received: by 10.200.46.35 with SMTP id r32mr9039307qta.56.1491073907697; Sat, 01 Apr 2017 12:11:47 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id b204sm788632qkg.43.2017.04.01.12.11.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Apr 2017 12:11:46 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [RFC] drm: atomic-rmfb semantics Date: Sat, 1 Apr 2017 15:11:36 -0400 Message-Id: <20170401191136.20401-1-robdclark@gmail.com> X-Mailer: git-send-email 2.9.3 Cc: Daniel Stone X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We possibly missed the boat on redefining rmfb semantics for atomic userspace to something more sane, unless perhaps the few existing atomic userspaces (CrOS?) could confirm that this change won't cause problems (in which case we could just call this a bug-fix, drop the cap, and delete some code?). The old semantics of rmfb shutting down the display is kind of pointless in an atomic world, and it is more awkward for userspace that creates and destroys the fb every frame, since they need to defer the rmfb. Since we have better ways for userspace to shut down the display pipe and the legacy behaviour of rmfb is awkward, provide a way for atomic userspace to simply make rmfb an unref. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_framebuffer.c | 2 +- drivers/gpu/drm/drm_ioctl.c | 9 +++++++++ include/drm/drm_file.h | 8 ++++++++ include/uapi/drm/drm.h | 7 +++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index e4909ae..c5127dd0 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -383,7 +383,7 @@ int drm_mode_rmfb(struct drm_device *dev, * so run this in a separate stack as there's no way to correctly * handle this after the fb is already removed from the lookup table. */ - if (drm_framebuffer_read_refcount(fb) > 1) { + if (drm_framebuffer_read_refcount(fb) > 1 && !file_priv->atomic_rmfb) { struct drm_mode_rmfb_work arg; INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn); diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index a7c61c2..b42348f 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -318,6 +318,15 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) file_priv->atomic = req->value; file_priv->universal_planes = req->value; break; + case DRM_CLIENT_CAP_ATOMIC_RMFB: + if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) + return -EINVAL; + if (req->value > 1) + return -EINVAL; + file_priv->atomic = req->value; + file_priv->universal_planes = req->value; + file_priv->atomic_rmfb = req->value; + break; default: return -EINVAL; } diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index 5dd27ae..2a41c29 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -181,6 +181,14 @@ struct drm_file { unsigned atomic:1; /** + * @atomic_rmfb: + * + * True if client wants new semantics for rmfb, ie. simply dropping + * refcnt without tearing down the display. + */ + unsigned atomic_rmfb:1; + + /** * @is_master: * * This client is the creator of @master. Protected by struct diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index b2c5284..4063cc8 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -678,6 +678,13 @@ struct drm_get_cap { */ #define DRM_CLIENT_CAP_ATOMIC 3 +/** + * DRM_CLIENT_CAP_ATOMIC_RMFB + * + * If set to 1, the DRM core will not shutdown display pipe on rmfb ioctl. + */ +#define DRM_CLIENT_CAP_ATOMIC_RMFB 4 + /** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap { __u64 capability;