From patchwork Wed Mar 17 22:19:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 12147049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8B72C433DB for ; Wed, 17 Mar 2021 22:19:48 +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 2AC2664DE7 for ; Wed, 17 Mar 2021 22:19:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2AC2664DE7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jlekstrand.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B5B86E041; Wed, 17 Mar 2021 22:19:47 +0000 (UTC) Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by gabe.freedesktop.org (Postfix) with ESMTPS id D46056E041 for ; Wed, 17 Mar 2021 22:19:46 +0000 (UTC) Received: by mail-pj1-x1033.google.com with SMTP id kk2-20020a17090b4a02b02900c777aa746fso2068861pjb.3 for ; Wed, 17 Mar 2021 15:19:46 -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 :mime-version:content-transfer-encoding; bh=NDkHjCWXg6V4YZ+2xwF9Emly1Ewc7c9IYUoCVHlDI0o=; b=gmI0y16wo9UmzFqqGn1ajeYkmMxwmI2eXye5g/9JojTjCySUQaAqxFmyPI26cT4LI/ JmhweS2O3YOGCqCy2xGV6DS2OArqwNqT30ZhZXZfrqCfEprcsE22CClREJxlleJnXnPC PMbQ30Jdf7lLa7YI1HL09yDzI+iOKKJFJF4zTWSQilwb2csoyR0HMMFQIIV/Glxd3aOR LcPaYXv0V1/AynxsOaR72JSNDo+RkFImzYASJXaYWxVyJiV5Qce5gJx0AJy6d2QJnNGL cOzMpT35euUeTYRJn3ceC3GevXE+ZeDltbMBILjdunBc69QHuu/mrZyUi7aSxazwyJBS O8Wg== 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:mime-version:content-transfer-encoding; bh=NDkHjCWXg6V4YZ+2xwF9Emly1Ewc7c9IYUoCVHlDI0o=; b=M0Vusto8UNaTcnyRfucIEdIzNQuj0rj+0CJkTuDPFW3ikJpjPK0qPB2BU0bCXw7pU6 4cpRf3+O4p75c5K814HRd9sbO1atv4PqSJcT1zitE6wph5LHf54Q8Zy6IAz7OYii+RvF vo7mtYnacant0x63QXoFgJZRPNrzFsEvrfR5qRtFjEU3wLnflZmtcbh45bwic5dSF0n7 Hrl4atnVJYn2TG48Gy/DXphhxATUbacIgxgx75JUrF35OIEq+HT4PMoxmIYpCKkwj1SU L8Wk1JO/WbX7l2BQhsY4huChIifIcCclq2vhMC7qmN+WRp9tFDplAVqBteAYUSQ4vZ/0 BEMQ== X-Gm-Message-State: AOAM531cf5SZ0kte4cJ5TEKwduvwNHLnb+tIwouj6YW/SxAsE4UYqooI jPbJ5Fd7auVAvb3qR9l3ugFVmvMxxdPwPw== X-Google-Smtp-Source: ABdhPJxUmP9NDMN+2eDA9j26505eq9yPbGI/OQ34dBPYDN5sI1T5fZD3s8aW1SjqIQnFPcqI+PMyVQ== X-Received: by 2002:a17:90a:e2cb:: with SMTP id fr11mr1039898pjb.2.1616019585926; Wed, 17 Mar 2021 15:19:45 -0700 (PDT) Received: from omlet.lan (jfdmzpr05-ext.jf.intel.com. [134.134.139.74]) by smtp.gmail.com with ESMTPSA id l19sm117708pjt.16.2021.03.17.15.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 15:19:45 -0700 (PDT) From: Jason Ekstrand To: dri-devel@lists.freedesktop.org Subject: [PATCH 0/3] dma-buf: Add an API for exporting sync files (v8) Date: Wed, 17 Mar 2021 17:19:37 -0500 Message-Id: <20210317221940.2146688-1-jason@jlekstrand.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210316045322.2020294-1-jason@jlekstrand.net> References: <20210316045322.2020294-1-jason@jlekstrand.net> 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: , Cc: Daniel Stone , =?utf-8?q?Michel_D=C3=A4nzer?= , Jason Ekstrand , Dave Airlie , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Modern userspace APIs like Vulkan are built on an explicit synchronization model. This doesn't always play nicely with the implicit synchronization used in the kernel and assumed by X11 and Wayland. The client -> compositor half of the synchronization isn't too bad, at least on intel, because we can control whether or not i915 synchronizes on the buffer and whether or not it's considered written. The harder part is the compositor -> client synchronization when we get the buffer back from the compositor. We're required to be able to provide the client with a VkSemaphore and VkFence representing the point in time where the window system (compositor and/or display) finished using the buffer. With current APIs, it's very hard to do this in such a way that we don't get confused by the Vulkan driver's access of the buffer. In particular, once we tell the kernel that we're rendering to the buffer again, any CPU waits on the buffer or GPU dependencies will wait on some of the client rendering and not just the compositor. This new IOCTL solves this problem by allowing us to get a snapshot of the implicit synchronization state of a given dma-buf in the form of a sync file. It's effectively the same as a poll() or I915_GEM_WAIT only, instead of CPU waiting directly, it encapsulates the wait operation, at the current moment in time, in a sync_file so we can check/wait on it later. As long as the Vulkan driver does the sync_file export from the dma-buf before we re-introduce it for rendering, it will only contain fences from the compositor or display. This allows to accurately turn it into a VkFence or VkSemaphore without any over- synchronization. Mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4037 IGT tests: https://lists.freedesktop.org/archives/igt-dev/2021-March/029825.html Cc: Christian König Cc: Michel Dänzer Cc: Dave Airlie Cc: Bas Nieuwenhuizen Cc: Daniel Stone Christian König (2): dma-buf: add dma_fence_array_for_each (v2) dma-buf: add dma_resv_get_singleton (v2) Jason Ekstrand (1): dma-buf: Add an API for exporting sync files (v8) drivers/dma-buf/dma-buf.c | 55 ++++++++++++++ drivers/dma-buf/dma-fence-array.c | 27 +++++++ drivers/dma-buf/dma-resv.c | 118 ++++++++++++++++++++++++++++++ include/linux/dma-fence-array.h | 17 +++++ include/linux/dma-resv.h | 3 + include/uapi/linux/dma-buf.h | 6 ++ 6 files changed, 226 insertions(+)