add dma_fence_timestamp() for 6.1.59 drm
authorjsg <jsg@openbsd.org>
Fri, 20 Oct 2023 03:38:58 +0000 (03:38 +0000)
committerjsg <jsg@openbsd.org>
Fri, 20 Oct 2023 03:38:58 +0000 (03:38 +0000)
sys/dev/pci/drm/drm_linux.c
sys/dev/pci/drm/include/linux/dma-fence.h

index ab2afec..1cfd4bf 100644 (file)
@@ -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 <jsg@openbsd.org>
  * Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
@@ -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)
 {
index f18e7a1..b6942e4 100644 (file)
@@ -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 *);