From patchwork Mon Mar 15 21:04:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 12140679 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 3EAEEC433E6 for ; Mon, 15 Mar 2021 21:05:04 +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 A4FC664F0F for ; Mon, 15 Mar 2021 21:05:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4FC664F0F 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 522716E1A2; Mon, 15 Mar 2021 21:05:02 +0000 (UTC) Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 010856E1A2 for ; Mon, 15 Mar 2021 21:05:00 +0000 (UTC) Received: by mail-pg1-x52c.google.com with SMTP id n10so21206226pgl.10 for ; Mon, 15 Mar 2021 14:05:00 -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=s0KQwkIrKscoVwwx+us9L2o+rKON2YJch7CTyZitEcY=; b=uEtP/1tB/eS1dgqBTNXdjGJSVljDZwea2otpdj83EN20UudWNqucbkNrqv21zv2d67 gb8IziWjdbKl6lSXmmuPOnXFqqggE4RQhrxS6hwFPsyPQsZmdCUk6TIV4KEWbSa/C+UE SxAd2Lk08CC1E8Ol6SrVMVbHA6VOBq4OgJpJ2YBy4kZJgIYr2/bJoLyh3rWtUIaZF7M8 SR1JWXTe7nM/mj1Fq2cCG9/QIgyJ43PYxiEeG1nX5Qz2dVUAxJ/fOiHDN4UKV2YHIU2R 3pmJhmUIKq1mKrUi9A7r/M4FO9z9CdLEn/H0YsWCgO47ZWQ9J1eIjh/nePunHa7tOGyc CyMA== 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=s0KQwkIrKscoVwwx+us9L2o+rKON2YJch7CTyZitEcY=; b=lhWq6qEnXra3C/KafglDxETwm+0ZWZhjYhd5PAo7Fo0bnpeAfe1vj+lvZXHT+SYogL UfwvatuIVl5ccY1SDTRP5XyM1GBaywHU3/3YroG1yn/aIkoh2u25ZstX3a+7+iyYCp2z gi0Q5H5KBp5NIzb+dgUZomoN/Q6kjpPD00Mbsx8vez2ddthjZxWVQnL0ERjAyN5Ywfqr N0ZHT0en57sw8dapyXKI+gAp1Tkhhppko+NH9azFdyFHVjsECCjkP+LhBJK7blzAoIoa lFNa7ysGmu/lr3wm6ok+57Vuo4S48ND4q6JNIJ6a1PPQvmWXLP4mC8LcgcmEzySNQJ0b I+KA== X-Gm-Message-State: AOAM5335aEI2mte+ftJLpBeRqsbhuwJQhis+JPa4erH8Cwlk2Dwl0GeV yEasxyZzWgxG+RQ4nbqW0IIOkBgYRNihog== X-Google-Smtp-Source: ABdhPJyuKdlnSoHEDzVFj/cg5qtmsGDUBvPPYUVFZzcRDoRjhQSf5y9bo4yn8TkS1Bw41OmW4oA8JA== X-Received: by 2002:a63:d618:: with SMTP id q24mr809737pgg.283.1615842300048; Mon, 15 Mar 2021 14:05:00 -0700 (PDT) Received: from omlet.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id t19sm13923609pgj.8.2021.03.15.14.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 14:04:59 -0700 (PDT) From: Jason Ekstrand To: dri-devel@lists.freedesktop.org Subject: [PATCH 0/3] dma-buf: Add an API for exporting sync files (v6) Date: Mon, 15 Mar 2021 16:04:50 -0500 Message-Id: <20210315210453.1667925-1-jason@jlekstrand.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20200317212115.419358-1-jason@jlekstrand.net> References: <20200317212115.419358-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 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(+)