From patchwork Mon Feb 27 19:35:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13154123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 216FDC64ED8 for ; Mon, 27 Feb 2023 19:36:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A91210E3D8; Mon, 27 Feb 2023 19:36:00 +0000 (UTC) Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by gabe.freedesktop.org (Postfix) with ESMTPS id F077610E3BC; Mon, 27 Feb 2023 19:35:58 +0000 (UTC) Received: by mail-pl1-x630.google.com with SMTP id i5so6226762pla.2; Mon, 27 Feb 2023 11:35:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MUhwCn+Xf/Lh0tYXdZ7kyW7NLgJoG2FRHZEn6JIAUnU=; b=e3dJQdT/GzzBi84Udq7ZZwyILaeZLE6iojJNPinMa5jB0hwTnM6VBosfHeleOT4aLP beQcDWs4ObtqFAz2/Erb6h1o7KUVB8Zct7AOIZp25OhasAL+at10V4pSEME1E5KGdr7k CTLQ8L43Zq9SC2MstsF09nAFYHENJmHGzhdiwUOti0lw7l8UEkfP8igFovG4jK/D0j22 gi3xNsGIJhpOFpW1ZmEa9BeN4CqDufAEokKrggl3PhSkrcNh0R6uuae40x8V7YX/Zfe0 Ty0u3rDEsMsUNp/eP6LZKUIc3ZSKhnINRv0ZUjiGLsfneDuvb1W33b38dWsznLdA9y8b L46w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MUhwCn+Xf/Lh0tYXdZ7kyW7NLgJoG2FRHZEn6JIAUnU=; b=A7kiVvak009je86XZHYGhaV/3GRW9HYhym/1pU7ejY1Vh8jxc0yW4y78OeS4Wne0eq FJt4WD/GC1apBajglwcU75e3PQe9FDHTwp20K79d3CJIvGAiB5XR94FDw7CwMnV7rjfj 66tdfXDal8tgQLN2TuzvegYmqrds91gNAJmNA64fibk64wV/C5MS+3zoPeb372dMgEl+ utZJQLkADkoCV4+DK8jJJ/KukDkVxUrSJw4sAOEhJcNrVF6kYZW3VANwU3EzhB9YJ76u GmnQReDpmnOc9lwuyVG7Q6NVlbJlrVTmvxCmE8hySKW2dEZ7DLLXutXIUJMGe/vjrAxj IcwQ== X-Gm-Message-State: AO0yUKW009EwBSEc8HMQWdaxvz/IFBi7tK94Q5FlN5/sBP3Ja/BwzCLV HIkxZpoUHakTYUrG6w0Pvh6xEr6z3YA= X-Google-Smtp-Source: AK7set9SvSJ6HJELWWpLIdMUGZPlro2YOMxpOiBCDlIbp7QbHLGDul/VNNeGq35L9JbLDh8lCbmibg== X-Received: by 2002:a17:90b:33d1:b0:233:f98a:8513 with SMTP id lk17-20020a17090b33d100b00233f98a8513mr435006pjb.8.1677526558236; Mon, 27 Feb 2023 11:35:58 -0800 (PST) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id mp4-20020a17090b190400b002375c356b0csm4727925pjb.19.2023.02.27.11.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 11:35:57 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH v7 04/15] dma-buf/dma-resv: Add a way to set fence deadline Date: Mon, 27 Feb 2023 11:35:10 -0800 Message-Id: <20230227193535.2822389-5-robdclark@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230227193535.2822389-1-robdclark@gmail.com> References: <20230227193535.2822389-1-robdclark@gmail.com> 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: Rob Clark , Tvrtko Ursulin , =?utf-8?q?Christian_K=C3=B6nig?= , =?utf-8?q?Michel_D=C3=A4nzer?= , open list , Sumit Semwal , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Pekka Paalanen , Luben Tuikov , Rodrigo Vivi , Alex Deucher , freedreno@lists.freedesktop.org, =?utf-8?q?Christian_K=C3=B6nig?= , "open list:DMA BUFFER SHARING FRAMEWORK" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark Add a way to set a deadline on remaining resv fences according to the requested usage. Signed-off-by: Rob Clark Reviewed-by: Christian König --- drivers/dma-buf/dma-resv.c | 22 ++++++++++++++++++++++ include/linux/dma-resv.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 1c76aed8e262..2a594b754af1 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -684,6 +684,28 @@ long dma_resv_wait_timeout(struct dma_resv *obj, enum dma_resv_usage usage, } EXPORT_SYMBOL_GPL(dma_resv_wait_timeout); +/** + * dma_resv_set_deadline - Set a deadline on reservation's objects fences + * @obj: the reservation object + * @usage: controls which fences to include, see enum dma_resv_usage. + * @deadline: the requested deadline (MONOTONIC) + * + * May be called without holding the dma_resv lock. Sets @deadline on + * all fences filtered by @usage. + */ +void dma_resv_set_deadline(struct dma_resv *obj, enum dma_resv_usage usage, + ktime_t deadline) +{ + struct dma_resv_iter cursor; + struct dma_fence *fence; + + dma_resv_iter_begin(&cursor, obj, usage); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + dma_fence_set_deadline(fence, deadline); + } + dma_resv_iter_end(&cursor); +} +EXPORT_SYMBOL_GPL(dma_resv_set_deadline); /** * dma_resv_test_signaled - Test if a reservation object's fences have been diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h index 0637659a702c..8d0e34dad446 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -479,6 +479,8 @@ int dma_resv_get_singleton(struct dma_resv *obj, enum dma_resv_usage usage, int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src); long dma_resv_wait_timeout(struct dma_resv *obj, enum dma_resv_usage usage, bool intr, unsigned long timeout); +void dma_resv_set_deadline(struct dma_resv *obj, enum dma_resv_usage usage, + ktime_t deadline); bool dma_resv_test_signaled(struct dma_resv *obj, enum dma_resv_usage usage); void dma_resv_describe(struct dma_resv *obj, struct seq_file *seq);