From patchwork Tue Apr 4 08:13:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher James Halse Rogers X-Patchwork-Id: 9660941 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 8180E6032D for ; Tue, 4 Apr 2017 08:13:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 779AF284CB for ; Tue, 4 Apr 2017 08:13:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AE2E284D1; Tue, 4 Apr 2017 08:13:41 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 A5BFE284CB for ; Tue, 4 Apr 2017 08:13:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3DEA6E526; Tue, 4 Apr 2017 08:13:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.cooperteam.net (mail.cooperteam.net [150.101.105.211]) by gabe.freedesktop.org (Postfix) with ESMTPS id 51B2C6E526 for ; Tue, 4 Apr 2017 08:13:38 +0000 (UTC) Received: from localhost.localdomain (unknown [192.168.1.1]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: chris) by mail.cooperteam.net (Postfix) with ESMTPSA id E1F27A0B336; Tue, 4 Apr 2017 18:13:35 +1000 (AEST) From: raof@ubuntu.com To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT. Date: Tue, 4 Apr 2017 18:13:20 +1000 Message-Id: <20170404081321.19263-2-raof@ubuntu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170404081321.19263-1-raof@ubuntu.com> References: <20170404081321.19263-1-raof@ubuntu.com> Cc: Christopher James Halse Rogers , Christopher James Halse Rogers 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 From: Christopher James Halse Rogers Until recently, on (at least) nouveau, radeon, and amdgpu attempting to scanout of an imported dma-buf would silently result in the dma-buf sharing being broken. While the hardware is capable of scanning out of imported dma-bufs (at least in some circumstances), these drivers do not currently implement it, so attempts to scan out of such buffers will never succeed. Add a userspace-visible drm capability and associated driver_feature so that userspace can discover when scanning out of an imported dma-buf can work. Signed-off-by: Christopher James Halse Rogers --- drivers/gpu/drm/drm_ioctl.c | 3 +++ include/drm/drm_drv.h | 1 + include/uapi/drm/drm.h | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index a7c61c23685a..79ccf638668e 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -285,6 +285,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ case DRM_CAP_ADDFB2_MODIFIERS: req->value = dev->mode_config.allow_fb_modifiers; break; + case DRM_CAP_PRIME_SCANOUT: + req->value = drm_core_check_feature(dev, DRIVER_PRIME_SCANOUT); + break; default: return -EINVAL; } diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 5699f42195fe..32cc0d956d7e 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -53,6 +53,7 @@ struct drm_mode_create_dumb; #define DRIVER_RENDER 0x8000 #define DRIVER_ATOMIC 0x10000 #define DRIVER_KMS_LEGACY_CONTEXT 0x20000 +#define DRIVER_PRIME_SCANOUT 0x40000 /** * struct drm_driver - DRM driver structure diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index b2c52843bc70..c57213cdb702 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -647,6 +647,27 @@ struct drm_gem_open { #define DRM_CAP_CURSOR_HEIGHT 0x9 #define DRM_CAP_ADDFB2_MODIFIERS 0x10 #define DRM_CAP_PAGE_FLIP_TARGET 0x11 +/** + * DRM_CAP_PRIME_SCANOUT + * + * The PRIME_SCANOUT capability returns whether the driver might be capable + * of scanning out of an imported PRIME buffer. + * + * This does not guarantee that any imported buffer can be scanned out, as + * there may be specific requirements that a given buffer might not satisfy. + * + * If this capability is false then imported PRIME buffers will definitely + * never be suitable for scanout. + * + * Note: Prior to the introduction of this capability, bugs in drivers would + * allow userspace to attempt to scan out of imported PRIME buffers. This would + * work once, but move the buffer into an inconsistent state where rendering from + * the exporting GPU would no longer be seen by the importing GPU. + * + * It is unsafe for driver-agnostic code to attempt to scan out of an imported + * PRIME buffer in the absense of this capability. + */ +#define DRM_CAP_PRIME_SCANOUT 0x12 /** DRM_IOCTL_GET_CAP ioctl argument type */ struct drm_get_cap {