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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDA04C7EE2D for ; Mon, 27 Feb 2023 19:36:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbjB0TgN (ORCPT ); Mon, 27 Feb 2023 14:36:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230116AbjB0TgI (ORCPT ); Mon, 27 Feb 2023 14:36:08 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E414C25BBA; Mon, 27 Feb 2023 11:35:58 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id i10so7900073plr.9; 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=HpWZiaFqEwg3Ql9vweLz1pB5KcRuLKzVbpoIop+jmfuwEYFdTUgjTjB6noWUWsKgvH BHnuz19mQdForAmm64hMvxZyT36ByuW1AKGt9q2fh0UEHe0HkqjXK9PYWY2QSxB5uTe4 XUEoIAbV0BKiGoaLuD44s4t+REBLOR0+CtDaNl77DqoUzkoiIihighJuGQEpEBHhtIZG 9+FTSpYLmQiu+y8390bdammcJsiZXKcHfiOq/UoAIvx25n47c2rJ3d40VETamCm2LFe/ A/5YEJjRfJs9V3u8TR5hQ5F84Vuy/T6l4u/Lthy5fEpgxKQyNVESE3EPV0x7jhB846lE 7dMg== X-Gm-Message-State: AO0yUKXW4bznOqQxpVDIDGeEHvDDSTY2bFrQS8ULDX0FvIhXj+7ijqHQ 6YnL0O+dRmVm6tP6gjkEP/Q= 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 Cc: freedreno@lists.freedesktop.org, Daniel Vetter , =?UTF-8?q?Christian=20K=C3=B6nig?= , =?UTF-8?q?Michel=20D=C3=A4nzer?= , Tvrtko Ursulin , Rodrigo Vivi , Alex Deucher , Pekka Paalanen , Simon Ser , Luben Tuikov , Rob Clark , =?UTF-8?q?Christian=20K=C3=B6nig?= , Sumit Semwal , linux-media@vger.kernel.org (open list:DMA BUFFER SHARING FRAMEWORK), linaro-mm-sig@lists.linaro.org (moderated list:DMA BUFFER SHARING FRAMEWORK), linux-kernel@vger.kernel.org (open list) 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.39.1