const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
u32 dispatch_flags;
int ret;
@@ -1531,7 +1532,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
void *data,
params->batch_obj_vm_offset =
i915_gem_obj_offset(batch_obj, vm);
/* Allocate a request for this batch buffer nice and early. */
- ret = dev_priv->gt.alloc_request(ring, ctx);
+ ret = dev_priv->gt.alloc_request(ring, ctx, &request);
if (ret)
goto err;
diff --git a/drivers/gpu/drm/i915/intel_lrc.c
b/drivers/gpu/drm/i915/intel_lrc.c
index 8628abf..c3c783f 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -857,13 +857,17 @@ void intel_lr_context_unpin(struct
intel_engine_cs *ring,
}
int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
- struct intel_context *ctx)
+ struct intel_context *ctx,
+ struct drm_i915_gem_request **req_out)
{
struct drm_i915_gem_request *request;
struct drm_i915_private *dev_private = ring->dev->dev_private;
int ret;
- if (ring->outstanding_lazy_request)
+ if (!req_out)
+ return -EINVAL;
+
+ if ((*req_out = ring->outstanding_lazy_request) != NULL)
return 0;
request = kzalloc(sizeof(*request), GFP_KERNEL);
@@ -898,7 +902,7 @@ int intel_logical_ring_alloc_request(struct
intel_engine_cs *ring,
i915_gem_context_reference(request->ctx);
request->ringbuf = ctx->engine[ring->id].ringbuf;
- ring->outstanding_lazy_request = request;
+ *req_out = ring->outstanding_lazy_request = request;
return 0;
}
@@ -1051,6 +1055,7 @@ static int logical_ring_prepare(struct
intel_ringbuffer *ringbuf,
int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
struct intel_context *ctx, int num_dwords)
{
+ struct drm_i915_gem_request *req;
struct intel_engine_cs *ring = ringbuf->ring;
struct drm_device *dev = ring->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1066,7 +1071,7 @@ int intel_logical_ring_begin(struct
intel_ringbuffer *ringbuf,
return ret;
/* Preallocate the olr before touching the ring */
- ret = intel_logical_ring_alloc_request(ring, ctx);
+ ret = intel_logical_ring_alloc_request(ring, ctx, &req);
if (ret)
return ret;
diff --git a/drivers/gpu/drm/i915/intel_lrc.h
b/drivers/gpu/drm/i915/intel_lrc.h
index 3cc38bd..77de8ac 100644
--- a/drivers/gpu/drm/i915/intel_lrc.h
+++ b/drivers/gpu/drm/i915/intel_lrc.h
@@ -37,7 +37,8 @@
/* Logical Rings */
int __must_check intel_logical_ring_alloc_request(struct
intel_engine_cs *ring,
- struct intel_context *ctx);
+ struct intel_context *ctx,
+ struct drm_i915_gem_request **req_out);
void intel_logical_ring_stop(struct intel_engine_cs *ring);
void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
int intel_logical_rings_init(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c
b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 635707a..1a9f884 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2164,13 +2164,18 @@ int intel_ring_idle(struct intel_engine_cs
*ring)
}
int
-intel_ring_alloc_request(struct intel_engine_cs *ring, struct
intel_context *ctx)
+intel_ring_alloc_request(struct intel_engine_cs *ring,
+ struct intel_context *ctx,
+ struct drm_i915_gem_request **req_out)
{
int ret;
struct drm_i915_gem_request *request;
struct drm_i915_private *dev_private = ring->dev->dev_private;
- if (ring->outstanding_lazy_request)
+ if (!req_out)
+ return -EINVAL;
+
+ if ((*req_out = ring->outstanding_lazy_request) != NULL)
return 0;
request = kzalloc(sizeof(*request), GFP_KERNEL);
@@ -2188,7 +2193,7 @@ intel_ring_alloc_request(struct intel_engine_cs
*ring, struct intel_context *ctx
return ret;
}
- ring->outstanding_lazy_request = request;
+ *req_out = ring->outstanding_lazy_request = request;
return 0;
}
@@ -2216,6 +2221,7 @@ static int __intel_ring_prepare(struct
intel_engine_cs *ring,
int intel_ring_begin(struct intel_engine_cs *ring,
int num_dwords)
{
+ struct drm_i915_gem_request *req;
struct drm_i915_private *dev_priv = ring->dev->dev_private;
int ret;
@@ -2229,7 +2235,7 @@ int intel_ring_begin(struct intel_engine_cs *ring,
return ret;
/* Preallocate the olr before touching the ring */
- ret = intel_ring_alloc_request(ring, NULL);
+ ret = intel_ring_alloc_request(ring, NULL, &req);
if (ret)
return ret;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h
b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 2fd960a..4f8a14a 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -393,7 +393,8 @@ void intel_cleanup_ring_buffer(struct
intel_engine_cs *ring);
int __must_check intel_ring_begin(struct intel_engine_cs *ring, int
n);
int __must_check intel_ring_cacheline_align(struct intel_engine_cs
*ring);
int __must_check intel_ring_alloc_request(struct intel_engine_cs
*ring,
- struct intel_context *ctx);
+ struct intel_context *ctx,
+ struct drm_i915_gem_request **req_out);
static inline void intel_ring_emit(struct intel_engine_cs *ring,
u32 data)
{