From patchwork Mon Aug 28 21:10:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 9926157 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 7BE1660329 for ; Mon, 28 Aug 2017 21:11:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6221B287EA for ; Mon, 28 Aug 2017 21:11:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 537F9287DB; Mon, 28 Aug 2017 21:11:05 +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_SIGNED, 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 68C61287C8 for ; Mon, 28 Aug 2017 21:11:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C2E46E313; Mon, 28 Aug 2017 21:10:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 98AA16E313 for ; Mon, 28 Aug 2017 21:10:33 +0000 (UTC) Received: by mail-pg0-x244.google.com with SMTP id 63so1195824pgc.1 for ; Mon, 28 Aug 2017 14:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jlekstrand-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9fQYbHf94015KiZ5jMaZXulgLtBQO+X+lEodvfrgC6Q=; b=eymc8Od+FD7BAvMn/gso+tE504Msf9iv01xHCKjvofBcIDripgJWdAcLywq7QUi8V0 cZK+f0xtJcqQ7vYLryry6Sb127LJASIStHSFYNsroNeKmtbHqFd5Knyg/9Bl5riYLNOz j4z1Vsqu4UHdwsMWztnGvdRF3XXt6Bck8k7+PVSfU54ec9e1e18WH3QNM+YFO+i7Jgzv cNIBJZbj6Zl0dDJEcCnoRwqR3nBZUGa01YQcAcZTklMcDkbn1ljaXVWaV9IREWHDHxX4 wnwaz9fMi+dh2tNPup4QxKx3bOREz/2uL+vEe0Ex+YnLOW7wOp+JCrgAc3FwbdeND3iN MpAQ== 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:in-reply-to :references; bh=9fQYbHf94015KiZ5jMaZXulgLtBQO+X+lEodvfrgC6Q=; b=rd16j0/wsCeRzJrTRL5tgyS/86Oo/QOih8RuCBTI7yIqfdEriISi7HXklS0IV3AWB+ IvZjpfEt1XjGAAhB4Cn7+AxdXxaZG7QAzU6t0Z1IJ+O/PCn5KXCx6od4EEB+Y/yf00Lg x2lkag4fxslRT7nW0L5YedAklNTpsLCnZGxFsMG8KXuOlqEyFgI2Tv8AJkPCOFNQMj10 iAW8K+0OABew5PIz2IFAdPy92/RaHwRm36jd9K87Nfi8Dl4iNwu0NStlRY4PV/+eKDZ+ RmIEAgy2ifJEYGg3Ai1dZ0CHoIl9iga+7Ddoniq7TatcAoGM5CBcliv+oWnDrw00Fbab kdVg== X-Gm-Message-State: AHYfb5gtUuqqB6UQO1rTQxnu4jx5cRh9Wp/dgoKqnJ4zJtfPGE/4weeK ucdpeUQKEYCDP4vmlmjX3Q== X-Received: by 10.84.131.104 with SMTP id 95mr2281074pld.58.1503954632657; Mon, 28 Aug 2017 14:10:32 -0700 (PDT) Received: from omlet.ak.intel.com ([134.134.139.78]) by smtp.gmail.com with ESMTPSA id c24sm2176668pfd.182.2017.08.28.14.10.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Aug 2017 14:10:31 -0700 (PDT) From: Jason Ekstrand X-Google-Original-From: Jason Ekstrand To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/syncobj: Add a signal ioctl (v3) Date: Mon, 28 Aug 2017 14:10:28 -0700 Message-Id: <1503954628-26426-2-git-send-email-jason.ekstrand@intel.com> X-Mailer: git-send-email 2.5.0.400.gff86faf In-Reply-To: <1503954628-26426-1-git-send-email-jason.ekstrand@intel.com> References: <1503954628-26426-1-git-send-email-jason.ekstrand@intel.com> Cc: Jason Ekstrand , Jason Ekstrand 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 This IOCTL provides a mechanism for userspace to trigger a sync object directly. There are other ways that userspace can trigger a syncobj such as submitting a dummy batch somewhere or hanging on to a triggered sync_file and doing an import. This just provides an easy way to manually trigger the sync object without weird hacks. The motivation for this IOCTL is Vulkan fences. Vulkan lets you create a fence already in the signaled state so that you can wait on it immediatly without stalling. We could also handle this with a new create flag to ask the driver to create a syncobj that is already signaled but the IOCTL seemed a bit cleaner and more generic. v2: - Take an array of sync objects (Dave Airlie) v3: - Throw -EINVAL if pad != 0 Signed-off-by: Jason Ekstrand signal --- drivers/gpu/drm/drm_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 2 ++ drivers/gpu/drm/drm_syncobj.c | 36 ++++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 1 + 4 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 83f1615..fbc3f30 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -171,3 +171,5 @@ int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); +int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private); diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 16c5d51..a9ae6dd 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -661,6 +661,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_RESET, drm_syncobj_reset_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_SIGNAL, drm_syncobj_signal_ioctl, + DRM_UNLOCKED|DRM_RENDER_ALLOW), }; #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls ) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 40d2ad2..0422b8c 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -918,3 +918,39 @@ drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, return 0; } + +int +drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_array *args = data; + struct drm_syncobj **syncobjs; + uint32_t i; + int ret; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad != 0) + return -EINVAL; + + if (args->count_handles == 0) + return -EINVAL; + + ret = drm_syncobj_array_find(file_private, + u64_to_user_ptr(args->handles), + args->count_handles, + &syncobjs); + if (ret < 0) + return ret; + + for (i = 0; i < args->count_handles; i++) { + ret = drm_syncobj_assign_null_handle(syncobjs[i]); + if (ret < 0) + break; + } + + drm_syncobj_array_free(syncobjs, args->count_handles); + + return ret; +} diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index b037fdf..97677cd 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -861,6 +861,7 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle) #define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait) #define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array) +#define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array) /** * Device specific ioctls should only be in their respective headers