[Beignet] [PATCH] Refine the logic when suspend a batch buffer.
Yang Rong
rong.r.yang at intel.com
Tue Jul 1 23:29:24 PDT 2014
Clear the gpgpu's batch buffer when suspend to avoid potential issue.
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
src/intel/intel_batchbuffer.c | 12 ++++++++++++
src/intel/intel_batchbuffer.h | 1 +
src/intel/intel_gpgpu.c | 4 +---
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/intel/intel_batchbuffer.c b/src/intel/intel_batchbuffer.c
index 19dc901..d0da77a 100644
--- a/src/intel/intel_batchbuffer.c
+++ b/src/intel/intel_batchbuffer.c
@@ -186,3 +186,15 @@ intel_batchbuffer_delete(intel_batchbuffer_t *batch)
cl_free(batch);
}
+LOCAL void
+intel_batchbuffer_take(intel_batchbuffer_t *from, intel_batchbuffer_t *to)
+{
+ *to = *from;
+ //Need not unreference the buffer, to will unreference it.
+ from->buffer = NULL;
+ from->map = NULL;
+ from->ptr = NULL;
+ from->size = 0;
+ from->atomic = 0;
+ from->enable_slm = 0;
+}
diff --git a/src/intel/intel_batchbuffer.h b/src/intel/intel_batchbuffer.h
index 0c3bc13..c62043e 100644
--- a/src/intel/intel_batchbuffer.h
+++ b/src/intel/intel_batchbuffer.h
@@ -101,6 +101,7 @@ extern void intel_batchbuffer_init(intel_batchbuffer_t*, struct intel_driver*);
extern void intel_batchbuffer_terminate(intel_batchbuffer_t*);
extern void intel_batchbuffer_flush(intel_batchbuffer_t*);
extern void intel_batchbuffer_reset(intel_batchbuffer_t*, size_t sz);
+extern void intel_batchbuffer_take(intel_batchbuffer_t*, intel_batchbuffer_t *);
static INLINE uint32_t
intel_batchbuffer_space(const intel_batchbuffer_t *batch)
diff --git a/src/intel/intel_gpgpu.c b/src/intel/intel_gpgpu.c
index 5decdfc..8afa1e2 100644
--- a/src/intel/intel_gpgpu.c
+++ b/src/intel/intel_gpgpu.c
@@ -1192,9 +1192,7 @@ intel_gpgpu_event_pending(intel_gpgpu_t *gpgpu, intel_event_t *event)
assert(event->batch == NULL); //This command haven't pengding.
event->batch = intel_batchbuffer_new(gpgpu->drv);
assert(event->batch);
- *event->batch = *gpgpu->batch;
- if(event->batch->buffer)
- drm_intel_bo_reference(event->batch->buffer);
+ intel_batchbuffer_take(gpgpu->batch, event->batch);
}
static void
--
1.8.3.2
More information about the Beignet
mailing list