[Mesa-stable] [PATCH 3/3] i915: store reference to the context within struct intel_fence
Mauro Rossi
issor.oruam at gmail.com
Sat Jul 16 00:02:58 UTC 2016
Hi,
I'm sending the v2 re-spin of patch as per i965, rechecked twice
line-by-line with Tomasz's one.
Building ok, marshmallow-x86 booting ok and here are the results of Android
CTS egl and gles2 x86 target tests
Android CTS 6.0_r7 build:2906653
07-16 00:52:42 I/DeviceManager: Detected new device 192.168.1.7:5555
cts-tf > list r
Session Pass Fail Not Executed Start time Plan
name Device serial(s)
0(EGL) 1410 24 0 2016.07.16_00.21.30 NA
unknown
1(GLES2) 13832 82 0 2016.07.16_00.24.23 NA
unknown
cts-tf >
I get the same results as per i965GM
Mauro
>From d35c093d48facae4ad0d7119a8b6fdc898a6a1e8 Mon Sep 17 00:00:00 2001
From: Mauro Rossi <issor.oruam at gmail.com>
Date: Fri, 15 Jul 2016 21:46:09 +0200
Subject: [PATCH] i915: store reference to the context within struct
intel_fence (v2)
Porting of the corresponding patch for i965.
Here follows the original commit message by Tomasz Figa:
"As the spec allows for {server,client}_wait_sync to be called without
currently bound context, while our implementation requires context
pointer.
v2: Add a mutex and acquire it for the duration of
brw_fence_client_wait() and brw_fence_is_completed() as suggested
by Chad."
NOTE: in i915 all references to 'brw' are replaced by 'intel'
---
src/mesa/drivers/dri/i915/intel_syncobj.c | 55
++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 11 deletions(-)
diff --git a/src/mesa/drivers/dri/i915/intel_syncobj.c
b/src/mesa/drivers/dri/i915/intel_syncobj.c
index 18d1546..5d37204a 100644
--- a/src/mesa/drivers/dri/i915/intel_syncobj.c
+++ b/src/mesa/drivers/dri/i915/intel_syncobj.c
@@ -46,9 +46,11 @@
#include "intel_reg.h"
struct intel_fence {
+ struct intel_context *intel;
/** The fence waits for completion of this batch. */
drm_intel_bo *batch_bo;
+ mtx_t mutex;
bool signalled;
};
@@ -77,7 +79,7 @@ intel_fence_insert(struct intel_context *intel, struct
intel_fence *fence)
}
static bool
-intel_fence_has_completed(struct intel_fence *fence)
+intel_fence_has_completed_locked(struct intel_fence *fence)
{
if (fence->signalled)
return true;
@@ -92,13 +94,21 @@ intel_fence_has_completed(struct intel_fence *fence)
return false;
}
-/**
- * Return true if the function successfully signals or has already
signalled.
- * (This matches the behavior expected from __DRI2fence::client_wait_sync).
- */
static bool
-intel_fence_client_wait(struct intel_context *intel, struct intel_fence
*fence,
- uint64_t timeout)
+intel_fence_has_completed(struct intel_fence *fence)
+{
+ bool ret;
+
+ mtx_lock(&fence->mutex);
+ ret = intel_fence_has_completed_locked(fence);
+ mtx_unlock(&fence->mutex);
+
+ return ret;
+}
+
+static bool
+intel_fence_client_wait_locked(struct intel_context *intel, struct
intel_fence *fence,
+ uint64_t timeout)
{
if (fence->signalled)
return true;
@@ -123,6 +133,23 @@ intel_fence_client_wait(struct intel_context *intel,
struct intel_fence *fence,
return true;
}
+/**
+ * Return true if the function successfully signals or has already
signalled.
+ * (This matches the behavior expected from __DRI2fence::client_wait_sync).
+ */
+static bool
+intel_fence_client_wait(struct intel_context *intel, struct intel_fence
*fence,
+ uint64_t timeout)
+{
+ bool ret;
+
+ mtx_lock(&fence->mutex);
+ ret = intel_fence_client_wait_locked(intel, fence, timeout);
+ mtx_unlock(&fence->mutex);
+
+ return ret;
+}
+
static void
intel_fence_server_wait(struct intel_context *intel, struct intel_fence
*fence)
{
@@ -215,6 +242,8 @@ intel_dri_create_fence(__DRIcontext *ctx)
if (!fence)
return NULL;
+ mtx_init(&fence->mutex, mtx_plain);
+ fence->intel = intel;
intel_fence_insert(intel, fence);
return fence;
@@ -233,19 +262,23 @@ static GLboolean
intel_dri_client_wait_sync(__DRIcontext *ctx, void *driver_fence, unsigned
flags,
uint64_t timeout)
{
- struct intel_context *intel = ctx->driverPrivate;
struct intel_fence *fence = driver_fence;
- return intel_fence_client_wait(intel, fence, timeout);
+ return intel_fence_client_wait(fence->intel, fence, timeout);
}
static void
intel_dri_server_wait_sync(__DRIcontext *ctx, void *driver_fence, unsigned
flags)
{
- struct intel_context *intel = ctx->driverPrivate;
struct intel_fence *fence = driver_fence;
- intel_fence_server_wait(intel, fence);
+ /* We might be called here with a NULL fence as a result of WaitSyncKHR
+ * on a EGL_KHR_reusable_sync fence. Nothing to do here in such case.
+ */
+ if (!fence)
+ return;
+
+ intel_fence_server_wait(fence->intel, fence);
}
const __DRI2fenceExtension intelFenceExtension = {
--
2.7.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-stable/attachments/20160716/75875eee/attachment-0001.html>
More information about the mesa-stable
mailing list