Skip to contentSkip to conversation

drm/amdgpu: Program ring for vce instance 1 at its own register space

PATCH In review Leo Liu 5 participants 7 messages May 29, 2017 – May 30, 2017 4 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Leo Liu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Program ring for vce instance 1 at its own register space

when harvest part has only instance 1 available

---
 drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 61 +++++++++++++++++++++++++++++++----
 1 file changed, 55 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +55 -6
index fb08193..77af395 100644
@@ -77,13 +77,26 @@ static int vce_v3_0_set_clockgating_state(void *handle,
 static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
 
 	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_RPTR);
+		v = RREG32(mmVCE_RB_RPTR);
 	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_RPTR2);
+		v = RREG32(mmVCE_RB_RPTR2);
 	else
-		return RREG32(mmVCE_RB_RPTR3);
+		v = RREG32(mmVCE_RB_RPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
 }
 
 /**
@@ -96,13 +109,26 @@ static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
 static uint64_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
 
 	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_WPTR);
+		v = RREG32(mmVCE_RB_WPTR);
 	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_WPTR2);
+		v = RREG32(mmVCE_RB_WPTR2);
 	else
-		return RREG32(mmVCE_RB_WPTR3);
+		v = RREG32(mmVCE_RB_WPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
 }
 
 /**
@@ -116,12 +142,22 @@ static void vce_v3_0_ring_set_wptr(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
 
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
+
 	if (ring == &adev->vce.ring[0])
 		WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
 	else if (ring == &adev->vce.ring[1])
 		WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
 	else
 		WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
 }
 
 static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device *adev, bool override)
@@ -231,6 +267,14 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
 	struct amdgpu_ring *ring;
 	int idx, r;
 
+	/* we need program ring buffer on instance 1 register space domain
+	when only if instance 1 available, with two instances or instance 0
+	we need only program instance 0 regsiter space domain for ring */
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
+
 	ring = &adev->vce.ring[0];
 	WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
 	WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
@@ -252,6 +296,11 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
 	WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
 	WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
 
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
 	mutex_lock(&adev->grbm_idx_mutex);
 	for (idx = 0; idx < 2; ++idx) {
 		if (adev->vce.harvest_config & (1 << idx))
Signature · 6 lines
2.9.3

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by Alex Deucher
#2 lore raw
Quoted 113 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Leo Liu
Sent: Monday, May 29, 2017 2:22 PM
To: [email protected]
Cc: Liu, Leo
Subject: [PATCH] drm/amdgpu: Program ring for vce instance 1 at its own register space

when harvest part has only instance 1 available

---
 drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 61
+++++++++++++++++++++++++++++++----
 1 file changed, 55 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +16 -3
index fb08193..77af395 100644
@@ -77,13 +77,26 @@ static int vce_v3_0_set_clockgating_state(void
 *handle,
 static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
 
 	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_RPTR);
+		v = RREG32(mmVCE_RB_RPTR);
 	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_RPTR2);
+		v = RREG32(mmVCE_RB_RPTR2);
 	else
-		return RREG32(mmVCE_RB_RPTR3);
+		v = RREG32(mmVCE_RB_RPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
 }

/**

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +16 -3
@@ -96,13 +109,26 @@ static uint64_t vce_v3_0_ring_get_rptr(struct
 amdgpu_ring *ring)
 static uint64_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
 
 	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_WPTR);
+		v = RREG32(mmVCE_RB_WPTR);
 	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_WPTR2);
+		v = RREG32(mmVCE_RB_WPTR2);
 	else
-		return RREG32(mmVCE_RB_WPTR3);
+		v = RREG32(mmVCE_RB_WPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
 }

/**

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +10 -0
@@ -116,12 +142,22 @@ static void vce_v3_0_ring_set_wptr(struct
 amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
 
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
+
 	if (ring == &adev->vce.ring[0])
 		WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
 	else if (ring == &adev->vce.ring[1])
 		WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
 	else
 		WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
 }

static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device
*adev, bool override)

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c static int vce_v3_0_start(struct amdgpu_device · line 273

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +3 -0
@@ -231,6 +267,14 @@ static int vce_v3_0_start(struct amdgpu_device
 *adev)
 	struct amdgpu_ring *ring;
 	int idx, r;
 
+	/* we need program ring buffer on instance 1 register space domain
+	when only if instance 1 available, with two instances or instance 0
+	we need only program instance 0 regsiter space domain for ring */

Please add this comment to the commit message as well. With that fixed:

Also, add CC: [email protected]

Quoted 25 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +5 -0
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
+
 	ring = &adev->vce.ring[0];
 	WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +5 -0
 	WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
@@ -252,6 +296,11 @@ static int vce_v3_0_start(struct amdgpu_device
 *adev)
 	WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
 	WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
 
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
 	mutex_lock(&adev->grbm_idx_mutex);
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +0 -1
 	for (idx = 0; idx < 2; ++idx) {
 		if (adev->vce.harvest_config & (1 << idx))
--

2.9.3

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB1652D8852FBB1EDD82FF2651F7F00-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#4 lore raw

Am 30.05.2017 um 16:57 schrieb Deucher, Alexander:

Quoted 121 lines
Quoted 113 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Leo Liu
Sent: Monday, May 29, 2017 2:22 PM
To: [email protected]
Cc: Liu, Leo
Subject: [PATCH] drm/amdgpu: Program ring for vce instance 1 at its own register space

when harvest part has only instance 1 available

---
  drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 61
+++++++++++++++++++++++++++++++----
  1 file changed, 55 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +16 -3
index fb08193..77af395 100644
@@ -77,13 +77,26 @@ static int vce_v3_0_set_clockgating_state(void
 *handle,
  static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
  {
  	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
 
  	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_RPTR);
+		v = RREG32(mmVCE_RB_RPTR);
  	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_RPTR2);
+		v = RREG32(mmVCE_RB_RPTR2);
  	else
-		return RREG32(mmVCE_RB_RPTR3);
+		v = RREG32(mmVCE_RB_RPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
  }

/**

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +16 -3
@@ -96,13 +109,26 @@ static uint64_t vce_v3_0_ring_get_rptr(struct
 amdgpu_ring *ring)
  static uint64_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
  {
  	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
 
  	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_WPTR);
+		v = RREG32(mmVCE_RB_WPTR);
  	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_WPTR2);
+		v = RREG32(mmVCE_RB_WPTR2);
  	else
-		return RREG32(mmVCE_RB_WPTR3);
+		v = RREG32(mmVCE_RB_WPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
  }

/**

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +10 -0
@@ -116,12 +142,22 @@ static void vce_v3_0_ring_set_wptr(struct
 amdgpu_ring *ring)
  {
  	struct amdgpu_device *adev = ring->adev;
 
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
+
  	if (ring == &adev->vce.ring[0])
  		WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
  	else if (ring == &adev->vce.ring[1])
  		WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
  	else
  		WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
  }

static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device
*adev, bool override)

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c static int vce_v3_0_start(struct amdgpu_device · line 273

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +3 -0
@@ -231,6 +267,14 @@ static int vce_v3_0_start(struct amdgpu_device
 *adev)
  	struct amdgpu_ring *ring;
  	int idx, r;
 
+	/* we need program ring buffer on instance 1 register space domain
+	when only if instance 1 available, with two instances or instance 0
+	we need only program instance 0 regsiter space domain for ring */

Please add this comment to the commit message as well. With that fixed:

Quoted 7 lines

Also, add CC: [email protected]

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c static int vce_v3_0_set_clockgating_state(void *handle, · line 85

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +4 -0
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}

I would prefer if we always grab the mutex and program mmGRBM_GFX_INDEX with the not harvested instance.

This way we don't run into bad surprises any more when we only test on boards where the second VCE instance is harvested.

Christian.

Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +1 -0
+
  	ring = &adev->vce.ring[0];
  	WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
  	WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +5 -0
@@ -252,6 +296,11 @@ static int vce_v3_0_start(struct amdgpu_device
 *adev)
  	WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
  	WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
 
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
  	mutex_lock(&adev->grbm_idx_mutex);

for (idx = 0; idx < 2; ++idx) {
if (adev->vce.harvest_config & (1 << idx))
--
2.9.3

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): d3fc8ec8-2167-126e-a9bd-cb98c6d0006c-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#6 lore raw
Quoted 126 lines · Christian König

Am 30.05.2017 um 16:57 schrieb Deucher, Alexander:

Quoted 125 lines
Quoted 119 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Leo Liu
Sent: Monday, May 29, 2017 2:22 PM
To: [email protected]
Cc: Liu, Leo
Subject: [PATCH] drm/amdgpu: Program ring for vce instance 1 at its own register space

when harvest part has only instance 1 available

---
  drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 61
+++++++++++++++++++++++++++++++----
  1 file changed, 55 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +16 -3
index fb08193..77af395 100644
@@ -77,13 +77,26 @@ static int vce_v3_0_set_clockgating_state(void
 *handle,
  static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
  {
      struct amdgpu_device *adev = ring->adev;
+    u32 v;
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        mutex_lock(&adev->grbm_idx_mutex);
+        WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+    }
 
      if (ring == &adev->vce.ring[0])
-        return RREG32(mmVCE_RB_RPTR);
+        v = RREG32(mmVCE_RB_RPTR);
      else if (ring == &adev->vce.ring[1])
-        return RREG32(mmVCE_RB_RPTR2);
+        v = RREG32(mmVCE_RB_RPTR2);
      else
-        return RREG32(mmVCE_RB_RPTR3);
+        v = RREG32(mmVCE_RB_RPTR3);
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+        mutex_unlock(&adev->grbm_idx_mutex);
+    }
+
+    return v;
  }

/**

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +16 -3
@@ -96,13 +109,26 @@ static uint64_t vce_v3_0_ring_get_rptr(struct
 amdgpu_ring *ring)
  static uint64_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
  {
      struct amdgpu_device *adev = ring->adev;
+    u32 v;
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        mutex_lock(&adev->grbm_idx_mutex);
+        WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+    }
 
      if (ring == &adev->vce.ring[0])
-        return RREG32(mmVCE_RB_WPTR);
+        v = RREG32(mmVCE_RB_WPTR);
      else if (ring == &adev->vce.ring[1])
-        return RREG32(mmVCE_RB_WPTR2);
+        v = RREG32(mmVCE_RB_WPTR2);
      else
-        return RREG32(mmVCE_RB_WPTR3);
+        v = RREG32(mmVCE_RB_WPTR3);
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+        mutex_unlock(&adev->grbm_idx_mutex);
+    }
+
+    return v;
  }

/**

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +10 -0
@@ -116,12 +142,22 @@ static void vce_v3_0_ring_set_wptr(struct
 amdgpu_ring *ring)
  {
      struct amdgpu_device *adev = ring->adev;
 
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        mutex_lock(&adev->grbm_idx_mutex);
+        WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+    }
+
      if (ring == &adev->vce.ring[0])
          WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
      else if (ring == &adev->vce.ring[1])
          WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
      else
          WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+        mutex_unlock(&adev->grbm_idx_mutex);
+    }
  }

static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device
*adev, bool override)

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +2 -0
@@ -231,6 +267,14 @@ static int vce_v3_0_start(struct amdgpu_device
 *adev)
      struct amdgpu_ring *ring;
      int idx, r;
 
+    /* we need program ring buffer on instance 1 register space domain
+    when only if instance 1 available, with two instances or 
Quoted 2 lines

instance 0
+ we need only program instance 0 regsiter space domain for ring */

Please add this comment to the commit message as well. With that fixed:

Also, add CC: [email protected]

Quoted 8 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c static int vce_v3_0_set_clockgating_state(void *handle, · line 85

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +4 -0
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        mutex_lock(&adev->grbm_idx_mutex);
+        WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+    }

I would prefer if we always grab the mutex and program mmGRBM_GFX_INDEX with the not harvested instance.

This way we don't run into bad surprises any more when we only test on boards where the second VCE instance is harvested.

Okay. the v2 patch will send shortly.

Leo

Quoted 34 lines

Christian.

Quoted 29 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +6 -0
+
      ring = &adev->vce.ring[0];
      WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
      WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
@@ -252,6 +296,11 @@ static int vce_v3_0_start(struct amdgpu_device
 *adev)
      WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
      WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
 
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        WREG32(mmGRBM_GFX_INDEX,
 mmGRBM_GFX_INDEX_DEFAULT);
+        mutex_unlock(&adev->grbm_idx_mutex);
+    }
+
      mutex_lock(&adev->grbm_idx_mutex);
Quoted 9 lines
      for (idx = 0; idx < 2; ++idx) {
          if (adev->vce.harvest_config & (1 << idx))
Signature · 6 lines
2.9.3

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#7 lore raw

PATCH 1/1 drm/amdgpu: Program ring for vce instance 1 at its register space

In reply to Leo Liu

We need program ring buffer on instance 1 register space domain, when only if instance 1 available, with two instances or instance 0, and we need only program instance 0 regsiter space domain for ring.

---
 drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 95 +++++++++++++++++++++++++----------
 1 file changed, 68 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +68 -27
index fb08193..7e39e42 100644
@@ -77,13 +77,26 @@ static int vce_v3_0_set_clockgating_state(void *handle,
 static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
 
 	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_RPTR);
+		v = RREG32(mmVCE_RB_RPTR);
 	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_RPTR2);
+		v = RREG32(mmVCE_RB_RPTR2);
 	else
-		return RREG32(mmVCE_RB_RPTR3);
+		v = RREG32(mmVCE_RB_RPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
 }
 
 /**
@@ -96,13 +109,26 @@ static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
 static uint64_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
 
 	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_WPTR);
+		v = RREG32(mmVCE_RB_WPTR);
 	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_WPTR2);
+		v = RREG32(mmVCE_RB_WPTR2);
 	else
-		return RREG32(mmVCE_RB_WPTR3);
+		v = RREG32(mmVCE_RB_WPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
 }
 
 /**
@@ -116,12 +142,22 @@ static void vce_v3_0_ring_set_wptr(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
 
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
+
 	if (ring == &adev->vce.ring[0])
 		WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
 	else if (ring == &adev->vce.ring[1])
 		WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
 	else
 		WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
 }
 
 static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device *adev, bool override)
@@ -231,33 +267,38 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
 	struct amdgpu_ring *ring;
 	int idx, r;
 
-	ring = &adev->vce.ring[0];
-	WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
-	WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
-	WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
-
-	ring = &adev->vce.ring[1];
-	WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
-	WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
-	WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
-
-	ring = &adev->vce.ring[2];
-	WREG32(mmVCE_RB_RPTR3, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr);
-	WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
-	WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
-
 	mutex_lock(&adev->grbm_idx_mutex);
 	for (idx = 0; idx < 2; ++idx) {
 		if (adev->vce.harvest_config & (1 << idx))
 			continue;
 
 		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(idx));
+
+		/* Program instance 0 reg space for two instances or instance 0 case
+		program instance 1 reg space for only instance 1 available case */
+		if (idx != 1 || adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+			ring = &adev->vce.ring[0];
+			WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
+			WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
+			WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
+
+			ring = &adev->vce.ring[1];
+			WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
+			WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
+			WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
+
+			ring = &adev->vce.ring[2];
+			WREG32(mmVCE_RB_RPTR3, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr);
+			WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
+			WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
+		}
+
 		vce_v3_0_mc_resume(adev, idx);
 		WREG32_FIELD(VCE_STATUS, JOB_BUSY, 1);
 
Signature · 1 line
1.9.1
#8 lore raw

Re: [PATCH] drm/amdgpu: Program ring for vce instance 1 at its register space

Am 30.05.2017 um 17:56 schrieb Leo Liu:

Quoted 16 lines

We need program ring buffer on instance 1 register space domain, when only if instance 1 available, with two instances or instance 0, and we need only program instance 0 regsiter space domain for ring.

---
  drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 95 +++++++++++++++++++++++++----------
  1 file changed, 68 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +0 -0
index fb08193..7e39e42 100644

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c static int vce_v3_0_set_clockgating_state(void *handle, · line 85

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +6 -0
@@ -77,13 +77,26 @@ static int vce_v3_0_set_clockgating_state(void *handle,
  static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
  {
  	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}

Did you missed my comment? I think we should always grab the mutex and program mmGRBM_GFX_INDEX.

Otherwise we silently rely on that it is correctly set when the function is called and have different code path for different harvested configs.

Apart from that the patch looks good to me.

Christian.

Quoted 133 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +62 -27
  	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_RPTR);
+		v = RREG32(mmVCE_RB_RPTR);
  	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_RPTR2);
+		v = RREG32(mmVCE_RB_RPTR2);
  	else
-		return RREG32(mmVCE_RB_RPTR3);
+		v = RREG32(mmVCE_RB_RPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
  }
 
  /**
@@ -96,13 +109,26 @@ static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
  static uint64_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
  {
  	struct amdgpu_device *adev = ring->adev;
+	u32 v;
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
 
  	if (ring == &adev->vce.ring[0])
-		return RREG32(mmVCE_RB_WPTR);
+		v = RREG32(mmVCE_RB_WPTR);
  	else if (ring == &adev->vce.ring[1])
-		return RREG32(mmVCE_RB_WPTR2);
+		v = RREG32(mmVCE_RB_WPTR2);
  	else
-		return RREG32(mmVCE_RB_WPTR3);
+		v = RREG32(mmVCE_RB_WPTR3);
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
+
+	return v;
  }
 
  /**
@@ -116,12 +142,22 @@ static void vce_v3_0_ring_set_wptr(struct amdgpu_ring *ring)
  {
  	struct amdgpu_device *adev = ring->adev;
 
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		mutex_lock(&adev->grbm_idx_mutex);
+		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+	}
+
  	if (ring == &adev->vce.ring[0])
  		WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
  	else if (ring == &adev->vce.ring[1])
  		WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
  	else
  		WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+
+	if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+		WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+		mutex_unlock(&adev->grbm_idx_mutex);
+	}
  }
 
  static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device *adev, bool override)
@@ -231,33 +267,38 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
  	struct amdgpu_ring *ring;
  	int idx, r;
 
-	ring = &adev->vce.ring[0];
-	WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
-	WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
-	WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
-
-	ring = &adev->vce.ring[1];
-	WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
-	WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
-	WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
-
-	ring = &adev->vce.ring[2];
-	WREG32(mmVCE_RB_RPTR3, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
-	WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr);
-	WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
-	WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
-
  	mutex_lock(&adev->grbm_idx_mutex);
  	for (idx = 0; idx < 2; ++idx) {
  		if (adev->vce.harvest_config & (1 << idx))
  			continue;
 
  		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(idx));
+
+		/* Program instance 0 reg space for two instances or instance 0 case
+		program instance 1 reg space for only instance 1 available case */
+		if (idx != 1 || adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+			ring = &adev->vce.ring[0];
+			WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
+			WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
+			WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
+
+			ring = &adev->vce.ring[1];
+			WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
+			WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
+			WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
+
+			ring = &adev->vce.ring[2];
+			WREG32(mmVCE_RB_RPTR3, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+			WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr);
+			WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
+			WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
+		}
+
  		vce_v3_0_mc_resume(adev, idx);
  		WREG32_FIELD(VCE_STATUS, JOB_BUSY, 1);
 

A message that is not in the archive (sent off-list or not yet received): df87fdbc-60f9-32c0-9c38-66123473cadb-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#10 lore raw

Re: [PATCH] drm/amdgpu: Program ring for vce instance 1 at its register space

Quoted 22 lines · Christian König

Am 30.05.2017 um 17:56 schrieb Leo Liu:

Quoted 21 lines

We need program ring buffer on instance 1 register space domain, when only if instance 1 available, with two instances or instance 0, and we need only program instance 0 regsiter space domain for ring.

---
  drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 95 
+++++++++++++++++++++++++----------
  1 file changed, 68 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +0 -0
index fb08193..7e39e42 100644
@@ -77,13 +77,26 @@ static int vce_v3_0_set_clockgating_state(void 
 *handle,
  static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
  {
      struct amdgpu_device *adev = ring->adev;
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c static int vce_v3_0_set_clockgating_state(void *handle, · line 85

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +6 -0
+    u32 v;
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        mutex_lock(&adev->grbm_idx_mutex);
+        WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+    }

Did you missed my comment? I think we should always grab the mutex and program mmGRBM_GFX_INDEX.

No I haven't , I did move the programming the ring regs from "vce_start" for Instance 0, to under mutex and mmGRBM_GFX_INDEX.

IMO, I don't think we need this here, because "mutex lock + mmGRBM_GFX_INDEX" and "mutex unlock+mmGRBM_GFX_DEFAULT" are always paired, So it should be always in default space when instance 0, and we do take care the case for instance 1 only.

I can follow your comment for here and other place in my patch for get/set w/rptr.

Thanks,
Leo

Quoted 130 lines

Otherwise we silently rely on that it is correctly set when the function is called and have different code path for different harvested configs.

Apart from that the patch looks good to me.

Christian.

Quoted 123 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +35 -6
        if (ring == &adev->vce.ring[0])
-        return RREG32(mmVCE_RB_RPTR);
+        v = RREG32(mmVCE_RB_RPTR);
      else if (ring == &adev->vce.ring[1])
-        return RREG32(mmVCE_RB_RPTR2);
+        v = RREG32(mmVCE_RB_RPTR2);
      else
-        return RREG32(mmVCE_RB_RPTR3);
+        v = RREG32(mmVCE_RB_RPTR3);
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+        mutex_unlock(&adev->grbm_idx_mutex);
+    }
+
+    return v;
  }
    /**
@@ -96,13 +109,26 @@ static uint64_t vce_v3_0_ring_get_rptr(struct 
 amdgpu_ring *ring)
  static uint64_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
  {
      struct amdgpu_device *adev = ring->adev;
+    u32 v;
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        mutex_lock(&adev->grbm_idx_mutex);
+        WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+    }
        if (ring == &adev->vce.ring[0])
-        return RREG32(mmVCE_RB_WPTR);
+        v = RREG32(mmVCE_RB_WPTR);
      else if (ring == &adev->vce.ring[1])
-        return RREG32(mmVCE_RB_WPTR2);
+        v = RREG32(mmVCE_RB_WPTR2);
      else
-        return RREG32(mmVCE_RB_WPTR3);
+        v = RREG32(mmVCE_RB_WPTR3);
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+        mutex_unlock(&adev->grbm_idx_mutex);
+    }
+
+    return v;
  }
    /**
@@ -116,12 +142,22 @@ static void vce_v3_0_ring_set_wptr(struct 
 amdgpu_ring *ring)
  {
      struct amdgpu_device *adev = ring->adev;
  +    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        mutex_lock(&adev->grbm_idx_mutex);
+        WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));
+    }
+
      if (ring == &adev->vce.ring[0])
          WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
      else if (ring == &adev->vce.ring[1])
          WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
      else
          WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+
+    if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) {
+        WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT);
+        mutex_unlock(&adev->grbm_idx_mutex);
+    }
  }
    static void vce_v3_0_override_vce_clock_gating(struct 

amdgpu_device *adev, bool override)

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +2 -20
@@ -231,33 +267,38 @@ static int vce_v3_0_start(struct amdgpu_device 
 *adev)
      struct amdgpu_ring *ring;
      int idx, r;
  -    ring = &adev->vce.ring[0];
-    WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
-    WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
-    WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
-    WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
-    WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
-
-    ring = &adev->vce.ring[1];
-    WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr));
-    WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
-    WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
-    WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
-    WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
-
-    ring = &adev->vce.ring[2];
-    WREG32(mmVCE_RB_RPTR3, lower_32_bits(ring->wptr));
-    WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
-    WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr);
-    WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
-    WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
-
      mutex_lock(&adev->grbm_idx_mutex);
      for (idx = 0; idx < 2; ++idx) {
          if (adev->vce.harvest_config & (1 << idx))
              continue;
            WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(idx));
+
+        /* Program instance 0 reg space for two instances or 

instance 0 case
+ program instance 1 reg space for only instance 1 available
case */
+ if (idx != 1 || adev->vce.harvest_config ==
AMDGPU_VCE_HARVEST_VCE0) {

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +16 -0
+            ring = &adev->vce.ring[0];
+            WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
+            WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
+            WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
+            WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
+            WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
+
+            ring = &adev->vce.ring[1];
+            WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr));
+            WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
+            WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
+            WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
+            WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
+
+            ring = &adev->vce.ring[2];
+            WREG32(mmVCE_RB_RPTR3, lower_32_bits(ring->wptr));
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/vce_v3_0.c static int vce_v3_0_start(struct amdgpu_device *adev) · line 303

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +6 -0
+            WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr));
+            WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr);
+            WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr));
+            WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4);
+        }
+
          vce_v3_0_mc_resume(adev, idx);
          WREG32_FIELD(VCE_STATUS, JOB_BUSY, 1);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx