freedreno: rework internal ring->emit_reloc_ring()

No need for it to deal with ringmarkers.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
diff --git a/freedreno/freedreno_priv.h b/freedreno/freedreno_priv.h
index 53817b1..835fadb 100644
--- a/freedreno/freedreno_priv.h
+++ b/freedreno/freedreno_priv.h
@@ -122,7 +122,8 @@
 	void (*emit_reloc)(struct fd_ringbuffer *ring,
 			const struct fd_reloc *reloc);
 	void (*emit_reloc_ring)(struct fd_ringbuffer *ring,
-			struct fd_ringmarker *target, struct fd_ringmarker *end);
+			struct fd_ringbuffer *target,
+			uint32_t submit_offset, uint32_t size);
 	void (*destroy)(struct fd_ringbuffer *ring);
 };
 
@@ -168,4 +169,10 @@
 #define U642VOID(x) ((void *)(unsigned long)(x))
 #define VOID2U64(x) ((uint64_t)(unsigned long)(x))
 
+static inline uint32_t
+offset_bytes(void *end, void *start)
+{
+	return ((char *)end) - ((char *)start);
+}
+
 #endif /* FREEDRENO_PRIV_H_ */
diff --git a/freedreno/freedreno_ringbuffer.c b/freedreno/freedreno_ringbuffer.c
index 984da24..9d987aa 100644
--- a/freedreno/freedreno_ringbuffer.c
+++ b/freedreno/freedreno_ringbuffer.c
@@ -102,8 +102,14 @@
 			      struct fd_ringmarker *target,
 			      struct fd_ringmarker *end)
 {
+	uint32_t submit_offset, size;
+
 	assert(target->ring == end->ring);
-	ring->funcs->emit_reloc_ring(ring, target, end);
+
+	submit_offset = offset_bytes(target->cur, target->ring->start);
+	size = offset_bytes(end->cur, target->cur);
+
+	ring->funcs->emit_reloc_ring(ring, target->ring, submit_offset, size);
 }
 
 struct fd_ringmarker * fd_ringmarker_new(struct fd_ringbuffer *ring)
diff --git a/freedreno/kgsl/kgsl_ringbuffer.c b/freedreno/kgsl/kgsl_ringbuffer.c
index 6f68f2f..a0bc9d0 100644
--- a/freedreno/kgsl/kgsl_ringbuffer.c
+++ b/freedreno/kgsl/kgsl_ringbuffer.c
@@ -174,11 +174,11 @@
 }
 
 static void kgsl_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
-		struct fd_ringmarker *target, struct fd_ringmarker *end)
+		struct fd_ringbuffer *target,
+		uint32_t submit_offset, uint32_t size)
 {
-	struct kgsl_ringbuffer *target_ring = to_kgsl_ringbuffer(target->ring);
-	(*ring->cur++) = target_ring->bo->gpuaddr +
-			(uint8_t *)target->cur - (uint8_t *)target->ring->start;
+	struct kgsl_ringbuffer *target_ring = to_kgsl_ringbuffer(target);
+	(*ring->cur++) = target_ring->bo->gpuaddr + submit_offset;
 }
 
 static void kgsl_ringbuffer_destroy(struct fd_ringbuffer *ring)
diff --git a/freedreno/msm/msm_ringbuffer.c b/freedreno/msm/msm_ringbuffer.c
index 34bc2fe..b5a50de 100644
--- a/freedreno/msm/msm_ringbuffer.c
+++ b/freedreno/msm/msm_ringbuffer.c
@@ -143,11 +143,6 @@
 	return msm_ring->submit.bos[cmd->submit_idx].handle == bo->handle;
 }
 
-static uint32_t offset_bytes(void *end, void *start)
-{
-	return ((char *)end) - ((char *)start);
-}
-
 static struct drm_msm_gem_submit_cmd * get_cmd(struct fd_ringbuffer *ring,
 		struct fd_ringbuffer *target_ring, struct fd_bo *target_bo,
 		uint32_t submit_offset, uint32_t size, uint32_t type)
@@ -328,16 +323,13 @@
 }
 
 static void msm_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
-		struct fd_ringmarker *target, struct fd_ringmarker *end)
+		struct fd_ringbuffer *target,
+		uint32_t submit_offset, uint32_t size)
 {
-	struct fd_bo *target_bo = to_msm_ringbuffer(target->ring)->ring_bo;
+	struct fd_bo *target_bo = to_msm_ringbuffer(target)->ring_bo;
 	struct drm_msm_gem_submit_cmd *cmd;
-	uint32_t submit_offset, size;
 
-	submit_offset = offset_bytes(target->cur, target->ring->start);
-	size = offset_bytes(end->cur, target->cur);
-
-	cmd = get_cmd(ring, target->ring, target_bo, submit_offset, size,
+	cmd = get_cmd(ring, target, target_bo, submit_offset, size,
 			MSM_SUBMIT_CMD_IB_TARGET_BUF);
 	assert(cmd);