[PATCH 2/3] drm/radeon: interface waiting for fence values

Simon Farnsworth simon.farnsworth at onelan.co.uk
Fri Feb 3 08:30:28 PST 2012


From: Christian König <deathsimple at vodafone.de>

To support waiting for fence values from usermode.

Signed-off-by: Christian König <deathsimple at vodafone.de>
---
Again, unchanged from Christian's original work

 drivers/gpu/drm/radeon/radeon_fence.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index ac177c5..85893c3 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -334,6 +334,28 @@ int radeon_fence_wait_last(struct radeon_device *rdev, int ring)
 	return r;
 }
 
+static bool radeon_fence_value_reached(struct radeon_device *rdev,
+				       int ring, uint64_t value)
+{
+	unsigned long irq_flags;
+	bool result;
+	read_lock_irqsave(&rdev->fence_lock, irq_flags);
+	result = rdev->fence_drv[ring].last_seq <= value;
+	read_unlock_irqrestore(&rdev->fence_lock, irq_flags);
+	return result;
+}
+
+int radeon_fence_wait_value(struct radeon_device *rdev, int ring,
+			    uint64_t value, unsigned long timeout)
+{
+	int r;
+	radeon_irq_kms_sw_irq_get(rdev, ring);
+	r = wait_event_interruptible_timeout(rdev->fence_drv[ring].queue,
+			radeon_fence_value_reached(rdev, ring, value), timeout);
+	radeon_irq_kms_sw_irq_put(rdev, ring);
+	return r;
+}
+
 struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence)
 {
 	kref_get(&fence->kref);
-- 
1.7.6.4



More information about the dri-devel mailing list