From patchwork Fri Aug 2 17:40:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 11074015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 534311395 for ; Fri, 2 Aug 2019 17:40:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480E7286C6 for ; Fri, 2 Aug 2019 17:40:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C2BF287C1; Fri, 2 Aug 2019 17:40:45 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 9D1AE2882A for ; Fri, 2 Aug 2019 17:40:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CAA406EF24; Fri, 2 Aug 2019 17:40:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F6FC6EF24 for ; Fri, 2 Aug 2019 17:40:42 +0000 (UTC) Received: by mail-pl1-x641.google.com with SMTP id az7so33879298plb.5 for ; Fri, 02 Aug 2019 10:40:42 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=mFZPHoP+w1tg0CkzilYEAAs7fCXXrSLLeKnprks9+hI=; b=rEiH0BJf62FrDIsQ+ZjJymrodESJAqEMctFkSmXa98IloRk5fkYyYtA5aK/uEMbDQ5 +qJQ0jnl/anwiE02yAFYZjbkwnKybJaii+F1bH4pRTZC9AoNsFI+xM+5TmBltdxfT7/s MYRSj0/PDx6EFO6iaoISSHJY4hD+pSM1w+WZ9ToF9u0CC3eGPqUiklQWWWdwSPB86SQV Dv4ey8Fs1vx1wmqYmKyV7QZBmge0VD6Y+d8bBZI6FqsPwCoGfpgcm3FEbJO7QAm7mqXf cCJw5LmEV5jjtbWsQhrjmCsI8bWotsu4qPdx67PHJvqeNQPphm7019NfTJLua+7YZ2yG Fn6g== X-Gm-Message-State: APjAAAWTfVgQsBkH6gJM9pIU3mGAch8PZc2Gsj7PeYf9bK7FuxtT29nh yvdMAJyRKvRiBjG2FLAOgZW8yc4J X-Google-Smtp-Source: APXvYqzfdqJmcF5/Js2WhCm3TRMjx4Ax4hNMFwN64OSl8FEVjSpL8zHT/dF53mWaPRGLeuJtQXl19A== X-Received: by 2002:a17:902:ac85:: with SMTP id h5mr133877351plr.198.1564767641163; Fri, 02 Aug 2019 10:40:41 -0700 (PDT) Received: from omlet.jf.intel.com ([2605:6000:1026:c030::17c]) by smtp.gmail.com with ESMTPSA id o130sm132337898pfg.171.2019.08.02.10.40.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 10:40:40 -0700 (PDT) From: Jason Ekstrand To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/syncobj: Add better overview documentation for syncobj Date: Fri, 2 Aug 2019 12:40:33 -0500 Message-Id: <20190802174033.10505-1-jason@jlekstrand.net> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-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:mime-version :content-transfer-encoding; bh=mFZPHoP+w1tg0CkzilYEAAs7fCXXrSLLeKnprks9+hI=; b=nLD1dQ/Z7qFNjaAD2S41hH3lkWpiA1Fo4RZMzH+YRPYhSGAAjF/aUN4z/hRGE7GYsB Zj+WdOQT/Y4a+hacQk4lIQqMCT5lNbelGvWdrYg0vWbD4flxVaXo8Dhlen7A/N1xYdTW TNVrDNGQfdFQglkxNMIButpjoqV4vtCvNJ8I8u1E5PDo6211HLYtguD9jjuDeLNaYvlM A+PJdm1MuwKgBeqwoOBZhfRkgSqdAF9N5tFI3B1wQYyLoJHZpHwv0bRO6AnIR/ixyrFQ KOL/LZJhKWgOuPdkfnbr/TJkVUrGG7rII7VcbOrJT4kehzx7oxHEa7FjYWq1u/0y2/uy YRIQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Ekstrand Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch only brings the syncobj documentation up-to-date for the original form of syncobj. It does not contain any information about the design of timeline syncobjs. --- drivers/gpu/drm/drm_syncobj.c | 81 +++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 1438dcb3ebb1..03cc888744fb 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -29,17 +29,82 @@ /** * DOC: Overview * - * DRM synchronisation objects (syncobj, see struct &drm_syncobj) are - * persistent objects that contain an optional fence. The fence can be updated - * with a new fence, or be NULL. + * DRM synchronisation objects (syncobj, see struct &drm_syncobj) provide a + * synchronization primitive which can be used by userspace to explicitly + * synchronize GPU commands, can be shared between userspace processes, and + * can be shared between different DRM drivers. + * Their primary use-case is to implement Vulkan fences and semaphores. + * The syncobj userspace API provides ioctls for several operations: * - * syncobj's can be waited upon, where it will wait for the underlying - * fence. + * - Creation and destruction of syncobjs + * - Import and export of syncobjs to/from a syncobj file descriptor + * - Import and export a syncobj's underlying fence to/from a sync file + * - Reset a syncobj (set its fence to NULL) + * - Signal a syncobj (set a trivially signaled fence) + * - Wait a syncobj's fence to be signaled * - * syncobj's can be export to fd's and back, these fd's are opaque and - * have no other use case, except passing the syncobj between processes. + * At it's core, a syncobj simply a wrapper around a pointer to a struct + * &dma_fence which may be NULL. + * When GPU work which signals a syncobj is enqueued in a DRM driver, + * the syncobj fence is replaced with a fence which will be signaled by the + * completion of that work. + * When GPU work which waits on a syncobj is enqueued in a DRM driver, the + * driver retrieves syncobj's current fence at the time the work is enqueued + * waits on that fence before submitting the work to hardware. + * If the syncobj's fence is NULL, the enqueue operation is expected to fail. + * All manipulation of the syncobjs's fence happens in terms of the current + * fence at the time the ioctl is called by userspace regardless of whether + * that operation is an immediate host-side operation (signal or reset) or + * or an operation which is enqueued in some driver queue. * - * Their primary use-case is to implement Vulkan fences and semaphores. + * + * Host-side wait on syncobjs + * -------------------------- + * + * The userspace syncobj API provides an ioctl for waiting on a set of + * syncobjs. + * The wait ioctl takes an array of syncobj handles and a flag indicating + * whether it should return immediately once one syncobj has been signaled + * or if it should wait for all the syncobjs to be signaled. + * Unlike the enqueued GPU work dependencies, the host-side wait ioctl + * will also optionally wait for the syncobj to first receive a fence and + * then wait on that fence. + * Assuming the syncobj starts off with a NULL fence, this allows a client + * to do a host wait in one thread (or process) which waits on GPU work + * submitted in another thread (or process) without having to manually + * synchronize between the two. + * This requirement is inherited from the Vulkan fence API. + * + * + * Import/export of syncobjs + * ------------------------- + * + * The userspace syncobj API provides two mechanisms for import/export of + * syncobjs. + * + * The first lets the client import or export an entire syncobj to a file + * descriptor. + * These fd's are opaque and have no other use case, except passing the + * syncobj between processes. + * All syncobj handles which are created as the result of such an import + * operation refer to the same underlying syncobj as was used for the + * export and the syncobj can be used persistently across all the processes + * with which it is shared. + * Unlike dma-buf, importing a syncobj creates a new handle for every + * import instead of de-duplicating. + * The primary use-case of this persistent import/export is for shared + * Vulkan fences and semaphores. + * + * The second import/export mechanism lets the client export the syncobj's + * current fence to/from a &sync_file. + * When a syncobj is exported to a sync file, that sync file wraps the + * sycnobj's fence at the time of export and any later signal or reset + * operations on the syncobj will not affect the exported sync file. + * When a sync file is imported into a syncobj, the syncobj's fence is set + * to the fence wrapped by that sync file. + * Because sync files are immutable, resetting or signaling the syncobj + * will not affect any sync files whose fences have been imported into the + * syncobj. * * syncobj have a kref reference count, but also have an optional file. * The file is only created once the syncobj is exported.