[3/4] drm/i915: Rename local struct intel_ringbuffer variables
diff mbox

Message ID 1458142855-3988-3-git-send-email-tvrtko.ursulin@linux.intel.com
State New
Headers show

Commit Message

Tvrtko Ursulin March 16, 2016, 3:40 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Majority of the code calls these ringbuf so fix up a few
places which use something else to be consistent.

Coccinelle script of:

@@
expression E;
identifier r;
@@
- struct intel_ringbuffer *r = E;
+ struct intel_ringbuffer *ringbuf = E;
<+...
- r
+ ringbuf
...+>
@@
identifier r;
@@
- struct intel_ringbuffer *r;
+ struct intel_ringbuffer *ringbuf;
<+...
- r
+ ringbuf
...+>

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c         |  8 ++++----
 drivers/gpu/drm/i915/intel_lrc.c        |  3 ++-
 drivers/gpu/drm/i915/intel_mocs.c       | 11 +++++++----
 drivers/gpu/drm/i915/intel_ringbuffer.c | 28 ++++++++++++++--------------
 4 files changed, 27 insertions(+), 23 deletions(-)

Comments

Chris Wilson March 16, 2016, 4 p.m. UTC | #1
On Wed, Mar 16, 2016 at 03:40:54PM +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Majority of the code calls these ringbuf so fix up a few
> places which use something else to be consistent.

I absolutely detest ringbuf as a name. The point of calling the engine
the engine was that we could call the ring state the ring.
-Chris
Tvrtko Ursulin March 16, 2016, 4:06 p.m. UTC | #2
On 16/03/16 16:00, Chris Wilson wrote:
> On Wed, Mar 16, 2016 at 03:40:54PM +0000, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> Majority of the code calls these ringbuf so fix up a few
>> places which use something else to be consistent.
>
> I absolutely detest ringbuf as a name. The point of calling the engine
> the engine was that we could call the ring state the ring.

:) I knew it. It is easily doable but it would be a somewhat bigger and 
again disruptive patch. Maybe someone else should do it so I am not the 
only one causing rebasing pain:

@@
expression E;
identifier r;
@@
- struct intel_ringbuffer *r = E;
+ struct intel_ringbuffer *ring = E;
<+...
- r
+ ring
...+>
@@
identifier r;
@@
- struct intel_ringbuffer *r;
+ struct intel_ringbuffer *ring;
<+...
- r
+ ring
...+>
@@
identifier func;
identifier r;
@@
func(..., struct intel_ringbuffer *
- r
+ ring
, ...)
{
<...
- r
+ ring
...>
}
@@
identifier func, r;
type T;
@@
T func(..., struct intel_ringbuffer *
- r
+ ring
, ...);

# cd $drm-intel/drivers/gpu/drm/i915
# spatch -c --no-includes --include-headers --sp-file <above> -j 
<numcpus> --in-place .

Could maybe be all that is required.

Regards,

Tvrtko
Chris Wilson March 16, 2016, 4:16 p.m. UTC | #3
On Wed, Mar 16, 2016 at 04:06:14PM +0000, Tvrtko Ursulin wrote:
> 
> On 16/03/16 16:00, Chris Wilson wrote:
> >On Wed, Mar 16, 2016 at 03:40:54PM +0000, Tvrtko Ursulin wrote:
> >>From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >>
> >>Majority of the code calls these ringbuf so fix up a few
> >>places which use something else to be consistent.
> >
> >I absolutely detest ringbuf as a name. The point of calling the engine
> >the engine was that we could call the ring state the ring.
> 
> :) I knew it. It is easily doable but it would be a somewhat bigger
> and again disruptive patch. Maybe someone else should do it so I am
> not the only one causing rebasing pain:

It's because it was the easier route that lead us into the current
miasma.

It just takes a few more steps to get ringbufs to be rings. I don't have
them as coccinelle patches, but in a few hours I'll see what they look
like after rebasing.
-Chris

Patch
diff mbox

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 042cb412e652..4a0f9bd87c34 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2821,7 +2821,7 @@  static void i915_gem_reset_engine_status(struct drm_i915_private *dev_priv,
 static void i915_gem_reset_engine_cleanup(struct drm_i915_private *dev_priv,
 					struct intel_engine_cs *engine)
 {
-	struct intel_ringbuffer *buffer;
+	struct intel_ringbuffer *ringbuf;
 
 	while (!list_empty(&engine->active_list)) {
 		struct drm_i915_gem_object *obj;
@@ -2874,9 +2874,9 @@  static void i915_gem_reset_engine_cleanup(struct drm_i915_private *dev_priv,
 	 * upon reset is less than when we start. Do one more pass over
 	 * all the ringbuffers to reset last_retired_head.
 	 */
-	list_for_each_entry(buffer, &engine->buffers, link) {
-		buffer->last_retired_head = buffer->tail;
-		intel_ring_update_space(buffer);
+	list_for_each_entry(ringbuf, &engine->buffers, link) {
+		ringbuf->last_retired_head = ringbuf->tail;
+		intel_ring_update_space(ringbuf);
 	}
 }
 
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 7c636b3db156..bc3183e1c0af 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1001,7 +1001,8 @@  int intel_execlists_submission(struct i915_execbuffer_params *params,
 		intel_logical_ring_emit(ringbuf, MI_NOOP);
 		intel_logical_ring_emit(ringbuf, MI_LOAD_REGISTER_IMM(1));
 		intel_logical_ring_emit_reg(ringbuf, INSTPM);
-		intel_logical_ring_emit(ringbuf, instp_mask << 16 | instp_mode);
+		intel_logical_ring_emit(ringbuf,
+					instp_mask << 16 | instp_mode);
 		intel_logical_ring_advance(ringbuf);
 
 		dev_priv->relative_constants_mode = instp_mode;
diff --git a/drivers/gpu/drm/i915/intel_mocs.c b/drivers/gpu/drm/i915/intel_mocs.c
index 3c725dde16ed..8ef7e2b29d71 100644
--- a/drivers/gpu/drm/i915/intel_mocs.c
+++ b/drivers/gpu/drm/i915/intel_mocs.c
@@ -210,7 +210,8 @@  static int emit_mocs_control_table(struct drm_i915_gem_request *req,
 				MI_LOAD_REGISTER_IMM(GEN9_NUM_MOCS_ENTRIES));
 
 	for (index = 0; index < table->size; index++) {
-		intel_logical_ring_emit_reg(ringbuf, mocs_register(ring, index));
+		intel_logical_ring_emit_reg(ringbuf,
+					    mocs_register(ring, index));
 		intel_logical_ring_emit(ringbuf,
 					table->table[index].control_value);
 	}
@@ -224,8 +225,10 @@  static int emit_mocs_control_table(struct drm_i915_gem_request *req,
 	 * that value to all the used entries.
 	 */
 	for (; index < GEN9_NUM_MOCS_ENTRIES; index++) {
-		intel_logical_ring_emit_reg(ringbuf, mocs_register(ring, index));
-		intel_logical_ring_emit(ringbuf, table->table[0].control_value);
+		intel_logical_ring_emit_reg(ringbuf,
+					    mocs_register(ring, index));
+		intel_logical_ring_emit(ringbuf,
+					table->table[0].control_value);
 	}
 
 	intel_logical_ring_emit(ringbuf, MI_NOOP);
@@ -266,7 +269,7 @@  static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req,
 	}
 
 	intel_logical_ring_emit(ringbuf,
-			MI_LOAD_REGISTER_IMM(GEN9_NUM_MOCS_ENTRIES / 2));
+				MI_LOAD_REGISTER_IMM(GEN9_NUM_MOCS_ENTRIES / 2));
 
 	for (i = 0, count = 0; i < table->size / 2; i++, count += 2) {
 		value = (table->table[count].l3cc_value & 0xffff) |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index b7c8fc1a73a3..a78a8fae4780 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2177,41 +2177,41 @@  static int intel_alloc_ringbuffer_obj(struct drm_device *dev,
 struct intel_ringbuffer *
 intel_engine_create_ringbuffer(struct intel_engine_cs *engine, int size)
 {
-	struct intel_ringbuffer *ring;
+	struct intel_ringbuffer *ringbuf;
 	int ret;
 
-	ring = kzalloc(sizeof(*ring), GFP_KERNEL);
-	if (ring == NULL) {
+	ringbuf = kzalloc(sizeof(*ringbuf), GFP_KERNEL);
+	if (ringbuf == NULL) {
 		DRM_DEBUG_DRIVER("Failed to allocate ringbuffer %s\n",
 				 engine->name);
 		return ERR_PTR(-ENOMEM);
 	}
 
-	ring->engine = engine;
-	list_add(&ring->link, &engine->buffers);
+	ringbuf->engine = engine;
+	list_add(&ringbuf->link, &engine->buffers);
 
-	ring->size = size;
+	ringbuf->size = size;
 	/* Workaround an erratum on the i830 which causes a hang if
 	 * the TAIL pointer points to within the last 2 cachelines
 	 * of the buffer.
 	 */
-	ring->effective_size = size;
+	ringbuf->effective_size = size;
 	if (IS_I830(engine->dev) || IS_845G(engine->dev))
-		ring->effective_size -= 2 * CACHELINE_BYTES;
+		ringbuf->effective_size -= 2 * CACHELINE_BYTES;
 
-	ring->last_retired_head = -1;
-	intel_ring_update_space(ring);
+	ringbuf->last_retired_head = -1;
+	intel_ring_update_space(ringbuf);
 
-	ret = intel_alloc_ringbuffer_obj(engine->dev, ring);
+	ret = intel_alloc_ringbuffer_obj(engine->dev, ringbuf);
 	if (ret) {
 		DRM_DEBUG_DRIVER("Failed to allocate ringbuffer %s: %d\n",
 				 engine->name, ret);
-		list_del(&ring->link);
-		kfree(ring);
+		list_del(&ringbuf->link);
+		kfree(ringbuf);
 		return ERR_PTR(ret);
 	}
 
-	return ring;
+	return ringbuf;
 }
 
 void