From 5158102c42af6a317a9c65e5e3ed103ac72b279d Mon Sep 17 00:00:00 2001 From: jsg Date: Fri, 20 Oct 2023 03:38:58 +0000 Subject: [PATCH] add dma_fence_timestamp() for 6.1.59 drm --- sys/dev/pci/drm/drm_linux.c | 14 +++++++++++++- sys/dev/pci/drm/include/linux/dma-fence.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c index ab2afec94d4..1cfd4bf9fdb 100644 --- a/sys/dev/pci/drm/drm_linux.c +++ b/sys/dev/pci/drm/drm_linux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.c,v 1.103 2023/08/04 09:36:28 jsg Exp $ */ +/* $OpenBSD: drm_linux.c,v 1.104 2023/10/20 03:38:58 jsg Exp $ */ /* * Copyright (c) 2013 Jonathan Gray * Copyright (c) 2015, 2016 Mark Kettenis @@ -1722,6 +1722,18 @@ dma_fence_is_signaled_locked(struct dma_fence *fence) return false; } +ktime_t +dma_fence_timestamp(struct dma_fence *fence) +{ + if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { + while (!test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags)) + CPU_BUSY_CYCLE(); + return fence->timestamp; + } else { + return ktime_get(); + } +} + long dma_fence_wait_timeout(struct dma_fence *fence, bool intr, long timeout) { diff --git a/sys/dev/pci/drm/include/linux/dma-fence.h b/sys/dev/pci/drm/include/linux/dma-fence.h index f18e7a1c66c..b6942e4b770 100644 --- a/sys/dev/pci/drm/include/linux/dma-fence.h +++ b/sys/dev/pci/drm/include/linux/dma-fence.h @@ -64,6 +64,7 @@ int dma_fence_signal_timestamp(struct dma_fence *, ktime_t); int dma_fence_signal_timestamp_locked(struct dma_fence *, ktime_t); bool dma_fence_is_signaled(struct dma_fence *); bool dma_fence_is_signaled_locked(struct dma_fence *); +ktime_t dma_fence_timestamp(struct dma_fence *); long dma_fence_default_wait(struct dma_fence *, bool, long); long dma_fence_wait_any_timeout(struct dma_fence **, uint32_t, bool, long, uint32_t *); -- 2.20.1