From patchwork Tue Mar 16 04:53:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 12141247 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,URIBL_BLOCKED,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 65367C433DB for ; Tue, 16 Mar 2021 05:01:36 +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 D9A3365138 for ; Tue, 16 Mar 2021 05:01:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9A3365138 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 2F5C86E128; Tue, 16 Mar 2021 05:01:35 +0000 (UTC) Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A4A06E128 for ; Tue, 16 Mar 2021 05:01:33 +0000 (UTC) Received: by mail-pf1-x434.google.com with SMTP id x7so7998297pfi.7 for ; Mon, 15 Mar 2021 22:01: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 :mime-version:content-transfer-encoding; bh=sqqz+JuGB78iICP5cqTrqQ+fp82gQW2JceA6wp0uaTg=; b=PSs8V08LQvqKP3YrY1dbIDCaunzh1n+vaDzl2fYCAnA8vrNH1ATCRSRvriUBMjHmVD iOdNCudCxdH811rBC3c4kBtj9NzFAPcGbUB0OILCqcnCOfWjimWujZf2CF6RSyIXB5In bZVKfJM/mmFIgwzy4aa3IXyat9Rn++eC25fz5UbqguzMAKmS+HzurMIeB4b+1GuRxfFF q/9lEz5XMmt79bgLlHEeCjRCJzwHLb/a+hTwOaovgjDRpCaLGS0RlHT0L1kL7rHP3dCA cTn5Xkv73IeJ9YhNxnQgohavtLFp7bvvhGgB8VjhsXG4yuxVGh6Y/cMUa0HLMckHFFv+ 4ApA== 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=sqqz+JuGB78iICP5cqTrqQ+fp82gQW2JceA6wp0uaTg=; b=sNeSjWV0m7D/ZKYS2vm3xb9/Rnu4Pyc4hsMEH+mwcOSw4Pu7C191gNVG5Dfsze7986 TkT9UZXy/I/rA9kWjy9/sergZnOfp9Z9IK+pw581UKns2sAtpF05B7QSf7jGE1XF689d V1K8LlNo0eEwNE/wbv3fneGFcQcxnJ0WcW9ZldDkuw0LbR9OfJlFox8SAfhayIK6FmWT Q+Y7gQf4s8ZlqQSQsWLbnDoBQeWTzaPqWzStRS/gvRW8p6dn18PKJvvYqcSWERYI3jqP umTVYrTTRXIZdIy3BaW+j38i22/remoaLPgoZZC1Eg/MISsSQe7VS9gPVAiMTW7hnEN4 qVgA== X-Gm-Message-State: AOAM530TjVWbNHq6/DWcjEoc1Uiqa2v4himsKAUEGXC7/6450I4d9Bey SeJsRHHgrdzv1irsp7V36juHYUugnYnY7A== X-Google-Smtp-Source: ABdhPJzs9G6poOib8dqwHeGc6VF3eZ+AwHMP14H212nfjSPK0Q/hTp9uFxmzgZ5XCZ2Ed+jatcBOjg== X-Received: by 2002:a63:ef53:: with SMTP id c19mr2281265pgk.78.1615870408308; Mon, 15 Mar 2021 21:53:28 -0700 (PDT) Received: from omlet.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id w128sm15147785pfw.86.2021.03.15.21.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 21:53:27 -0700 (PDT) From: Jason Ekstrand To: dri-devel@lists.freedesktop.org Subject: [PATCH 0/3] dma-buf: Add an API for exporting sync files (v7) Date: Mon, 15 Mar 2021 23:53:19 -0500 Message-Id: <20210316045322.2020294-1-jason@jlekstrand.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210315210453.1667925-1-jason@jlekstrand.net> References: <20210315210453.1667925-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. The only remaining TODO item as far as I know is that some kernel CI system is sending me nastygrams about build system problems. With this change, dma-fence now has a dependency on sync_file and I really don't know how best to solve it. Should we make sync_file no longer optional? Should I hide the new ioctl behind a #define? If so, what #define? I'm a bit lost when it comes to KConfig, I'm afraid. 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 (v6) 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(+)