From patchwork Fri Feb 24 20:01:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13151774 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 1F957C6FA8E for ; Fri, 24 Feb 2023 20:02:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 366D510ED0E; Fri, 24 Feb 2023 20:02:12 +0000 (UTC) Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 510D410ED0D; Fri, 24 Feb 2023 20:02:08 +0000 (UTC) Received: by mail-pj1-x102d.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so4045522pjh.0; Fri, 24 Feb 2023 12:02:08 -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=h7cN33BrnH1bRUCoetglj/sOcYD45HkKi2VY5Gkd+phwRLedbcNJ3G7XFtE6917xBT egahxBduMjZRCnpuWY3YsHe+AbNZP/laI8eWmju9ZiLHFdQ9wrcNvcl7Vjl7ZtO6oLzJ SdFZJWaZTn33EW8pzn0d4b45438murDXudjvRYRH2QNsde4cnb9hByzs0ZcKzLYJBhEC e6/7C84Nk+9lpNUdlWkPs3AXmcjg3wkMUejblQsYzcoaFsoam4xVY5ESubkpfDesHDZ6 2SzU5vXLc4Qlpxf0R8BE1FQNmnExqiINgfQmeMIpzCaSxUKI7GXztEOuO9JuCiWjpJK1 mbeA== 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=VgDa6hfuIvsKFtR2XH556aZcJF1qDJQIvF/zQaWEE6MYzMSLJdmOxe/Iz0n/Bvk1n7 lLRFgZQJ3vJCrJ1vZmiC+XtB2gx0Yff0twlx0dCShDchqERevuwU7rxBOg0ShtVq0btz c22rIizwrbfACki1COpmvVpOK/h+R0wvcfHlYoY+Kjrmd/5GM2lgHW+6f0vYxzumZzPv Bmwdbz6U/K7TR3psoGEmkbyvNPDyCzTVu8Nx6Ec32DqxfvMZ1+adTdgTAkEwkfdxqj8E 4HC1ctL9TkClk0xiA08Tx0LAIz/smO/JUek3o1ePeV+LNSZtIv0z/8TwqkO3rLVVkoOs NAvQ== X-Gm-Message-State: AO0yUKUpNCsjefUV9L+b6zGM8l2Y6kArNOBoazgiTZcbzvKXPLWeM6s3 Rcce7sZyigYHqtEQ5aI8sclpqvk+lms= X-Google-Smtp-Source: AK7set/OZA8f7pCtrbvKrWL0jPkHBC+o6LrHYg0KBjQGKxwuHHwYGtipmZlC2NhUCG1w5or8Xu19Nw== X-Received: by 2002:a05:6a20:748c:b0:cc:50cd:e0bc with SMTP id p12-20020a056a20748c00b000cc50cde0bcmr1032966pzd.10.1677268927405; Fri, 24 Feb 2023 12:02:07 -0800 (PST) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id v23-20020aa78097000000b0058d54960eccsm8964196pff.151.2023.02.24.12.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 12:02:07 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH v6 04/15] dma-buf/dma-resv: Add a way to set fence deadline Date: Fri, 24 Feb 2023 12:01:32 -0800 Message-Id: <20230224200155.2510320-5-robdclark@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230224200155.2510320-1-robdclark@gmail.com> References: <20230224200155.2510320-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);