diff options
author | Dave Airlie <airlied@redhat.com> | 2023-10-13 04:04:53 +0300 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2023-10-13 04:05:40 +0300 |
commit | dcad98b140554c325fa2ec7d42311edc7a79cdbb (patch) | |
tree | 66c0216a655edab6c7ac45bbbbc0d90b9fe623f6 /include | |
parent | 94f6f0550c625fab1f373bb86a6669b45e9748b3 (diff) | |
parent | c1165df2be2fffe3adeeaa68f4ee4325108c5e4e (diff) | |
download | linux-dcad98b140554c325fa2ec7d42311edc7a79cdbb.tar.xz |
Merge tag 'drm-misc-fixes-2023-10-12' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
Short summary of fixes pull:
* atomic-helper: Relax checks for unregistered connectors
* dma-buf: Work around race condition when retrieving fence timestamp
* gem: Avoid OOB access in BO memory range
* panel:
* boe-tv101wun-ml6: Fix flickering
* simpledrm: Fix error output
* vwmgfx:
* Fix size calculation in texture-state code
* Ref GEM BOs in surfaces
Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20231012111638.GA25037@linux-uq9g
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/dma-fence.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h index 0d678e9a7b24..ebe78bd3d121 100644 --- a/include/linux/dma-fence.h +++ b/include/linux/dma-fence.h @@ -568,6 +568,25 @@ static inline void dma_fence_set_error(struct dma_fence *fence, fence->error = error; } +/** + * dma_fence_timestamp - helper to get the completion timestamp of a fence + * @fence: fence to get the timestamp from. + * + * After a fence is signaled the timestamp is updated with the signaling time, + * but setting the timestamp can race with tasks waiting for the signaling. This + * helper busy waits for the correct timestamp to appear. + */ +static inline ktime_t dma_fence_timestamp(struct dma_fence *fence) +{ + if (WARN_ON(!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))) + return ktime_get(); + + while (!test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags)) + cpu_relax(); + + return fence->timestamp; +} + signed long dma_fence_wait_timeout(struct dma_fence *, bool intr, signed long timeout); signed long dma_fence_wait_any_timeout(struct dma_fence **fences, |