AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/9] update devcoredump for new VCN instance design
@ 2024-10-29 13:50 Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 1/9] drm/amdgpu: update vcn_v1 devcoredump on per instance basis Sunil Khatri
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

Sunil Khatri (9):
  drm/amdgpu: update vcn_v1 devcoredump on per instance basis
  drm/amdgpu: update vcn_v2.0 devcoredump on per instance basis
  drm/amdgpu: update vcn_v2.5 devcoredump on per instance basis
  drm/amdgpu: update vcn_v3.0 devcoredump on per instance basis
  drm/amdgpu: update vcn_v4.0.3 devcoredump on per instance basis
  drm/amdgpu: update vcn_v4.0.5 devcoredump on per instance basis
  drm/amdgpu: update vcn_v4 devcoredump on per instance basis
  drm/amdgpu: update vcn_v5.0 devcoredump on per instance basis
  drm/amdgpu: remove unused ip_dump from vcn device

 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h |  3 -
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c   | 77 ++++++++++++------------
 drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c   | 77 ++++++++++++------------
 drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c   | 77 ++++++++++++------------
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c   | 75 +++++++++++------------
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c   | 80 ++++++++++++-------------
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 80 ++++++++++++-------------
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 80 ++++++++++++-------------
 drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 77 ++++++++++++------------
 10 files changed, 298 insertions(+), 330 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v1 1/9] drm/amdgpu: update vcn_v1 devcoredump on per instance basis
  2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
@ 2024-10-29 13:50 ` Sunil Khatri
  2024-10-31  9:46   ` Christian König
  2024-10-29 13:50 ` [PATCH v1 2/9] drm/amdgpu: update vcn_v2.0 " Sunil Khatri
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

vcn code is restructured for per instance basis. Each
vcn instance is represented by an ip_block and hence a
need to update the dump and print functions for each
instance as an IP.

Existing way was to capture the ip dump for each instance
in a same memory dump but now each ip_block of vcn is an
independent one and its memory is independent and handled
within the ip_block now.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  2 +
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 77 +++++++++++++--------------
 2 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index d4c8cc3c1730..ef564ddcfcbb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -392,6 +392,8 @@ struct amdgpu_ip_block {
 	const struct amdgpu_ip_block_version *version;
 	struct amdgpu_device *adev;
 	unsigned int instance;
+	/* IP reg dump */
+	uint32_t *ip_dump;
 };
 
 int amdgpu_device_ip_block_version_cmp(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
index 7638ddeccec7..f31fdd620c86 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
@@ -203,12 +203,12 @@ static int vcn_v1_0_sw_init(struct amdgpu_ip_block *ip_block)
 	r = jpeg_v1_0_sw_init(ip_block);
 
 	/* Allocate memory for VCN IP Dump buffer */
-	ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), GFP_KERNEL);
+	ptr = kcalloc(reg_count, sizeof(uint32_t), GFP_KERNEL);
 	if (!ptr) {
 		DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
-		adev->vcn.ip_dump = NULL;
+		ip_block->ip_dump = NULL;
 	} else {
-		adev->vcn.ip_dump = ptr;
+		ip_block->ip_dump = ptr;
 	}
 	return r;
 }
@@ -234,7 +234,7 @@ static int vcn_v1_0_sw_fini(struct amdgpu_ip_block *ip_block)
 
 	r = amdgpu_vcn_sw_fini(adev, inst);
 
-	kfree(adev->vcn.ip_dump);
+	kfree(ip_block->ip_dump);
 
 	return r;
 }
@@ -1933,61 +1933,58 @@ void vcn_v1_0_ring_end_use(struct amdgpu_ring *ring)
 static void vcn_v1_0_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_1_0);
-	uint32_t inst_off, is_powered;
+	uint32_t is_powered;
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i)) {
-			drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", i);
-			continue;
-		}
+	drm_printf(p, "Instance no:VCN%d\n", inst);
 
-		inst_off = i * reg_count;
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	if (adev->vcn.harvest_config & (1 << inst)) {
+		drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", inst);
+		return;
+	}
 
-		if (is_powered) {
-			drm_printf(p, "\nActive Instance:VCN%d\n", i);
-			for (j = 0; j < reg_count; j++)
-				drm_printf(p, "%-50s \t 0x%08x\n", vcn_reg_list_1_0[j].reg_name,
-					   adev->vcn.ip_dump[inst_off + j]);
-		} else {
-			drm_printf(p, "\nInactive Instance:VCN%d\n", i);
-		}
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+
+	if (is_powered) {
+		drm_printf(p, "\nActive Instance:VCN%d\n", inst);
+		for (i = 0; i < reg_count; i++)
+			drm_printf(p, "%-50s \t 0x%08x\n",
+				   vcn_reg_list_1_0[i].reg_name,
+				   ip_block->ip_dump[i]);
+	} else {
+		drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
 	}
 }
 
 static void vcn_v1_0_dump_ip_state(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
+	int inst = ip_block->instance;
 	bool is_powered;
-	uint32_t inst_off;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_1_0);
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return;
 
-		inst_off = i * reg_count;
-		/* mmUVD_POWER_STATUS is always readable and is first element of the array */
-		adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, i, mmUVD_POWER_STATUS);
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	/* mmUVD_POWER_STATUS is always readable and is first element of the array */
+	ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, mmUVD_POWER_STATUS);
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		if (is_powered)
-			for (j = 1; j < reg_count; j++)
-				adev->vcn.ip_dump[inst_off + j] =
-					RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_1_0[j], i));
-	}
+	if (is_powered)
+		for (i = 1; i < reg_count; i++)
+			ip_block->ip_dump[i] =
+				RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_1_0[i], inst));
 }
 
 static const struct amd_ip_funcs vcn_v1_0_ip_funcs = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v1 2/9] drm/amdgpu: update vcn_v2.0 devcoredump on per instance basis
  2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 1/9] drm/amdgpu: update vcn_v1 devcoredump on per instance basis Sunil Khatri
@ 2024-10-29 13:50 ` Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 3/9] drm/amdgpu: update vcn_v2.5 " Sunil Khatri
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

vcn code is restructured for per instance basis. Each
vcn instance is represented by an ip_block and hence a
need to update the dump and print functions for each
instance as an IP.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 77 +++++++++++++--------------
 1 file changed, 37 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
index a327c3bf84f2..f1c28944ff3e 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
@@ -225,12 +225,12 @@ static int vcn_v2_0_sw_init(struct amdgpu_ip_block *ip_block)
 		amdgpu_vcn_fwlog_init(adev->vcn.inst);
 
 	/* Allocate memory for VCN IP Dump buffer */
-	ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), GFP_KERNEL);
+	ptr = kcalloc(reg_count, sizeof(uint32_t), GFP_KERNEL);
 	if (!ptr) {
 		DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
-		adev->vcn.ip_dump = NULL;
+		ip_block->ip_dump = NULL;
 	} else {
-		adev->vcn.ip_dump = ptr;
+		ip_block->ip_dump = ptr;
 	}
 
 	return 0;
@@ -263,7 +263,7 @@ static int vcn_v2_0_sw_fini(struct amdgpu_ip_block *ip_block)
 
 	r = amdgpu_vcn_sw_fini(adev, inst);
 
-	kfree(adev->vcn.ip_dump);
+	kfree(ip_block->ip_dump);
 
 	return r;
 }
@@ -2041,61 +2041,58 @@ static int vcn_v2_0_start_sriov(struct amdgpu_device *adev)
 static void vcn_v2_0_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_2_0);
-	uint32_t inst_off, is_powered;
+	uint32_t is_powered;
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i)) {
-			drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", i);
-			continue;
-		}
+	drm_printf(p, "Instance no:VCN%d\n", inst);
 
-		inst_off = i * reg_count;
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	if (adev->vcn.harvest_config & (1 << inst)) {
+		drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", inst);
+		return;
+	}
 
-		if (is_powered) {
-			drm_printf(p, "\nActive Instance:VCN%d\n", i);
-			for (j = 0; j < reg_count; j++)
-				drm_printf(p, "%-50s \t 0x%08x\n", vcn_reg_list_2_0[j].reg_name,
-					   adev->vcn.ip_dump[inst_off + j]);
-		} else {
-			drm_printf(p, "\nInactive Instance:VCN%d\n", i);
-		}
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+
+	if (is_powered) {
+		drm_printf(p, "\nActive Instance:VCN%d\n", inst);
+		for (i = 0; i < reg_count; i++)
+			drm_printf(p, "%-50s \t 0x%08x\n",
+				   vcn_reg_list_2_0[i].reg_name,
+				   ip_block->ip_dump[i]);
+	} else {
+		drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
 	}
 }
 
 static void vcn_v2_0_dump_ip_state(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	bool is_powered;
-	uint32_t inst_off;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_2_0);
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return;
 
-		inst_off = i * reg_count;
-		/* mmUVD_POWER_STATUS is always readable and is first element of the array */
-		adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, i, mmUVD_POWER_STATUS);
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	/* mmUVD_POWER_STATUS is always readable and is first element of the array */
+	ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, mmUVD_POWER_STATUS);
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		if (is_powered)
-			for (j = 1; j < reg_count; j++)
-				adev->vcn.ip_dump[inst_off + j] =
-					RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_2_0[j], i));
-	}
+	if (is_powered)
+		for (i = 1; i < reg_count; i++)
+			ip_block->ip_dump[i] =
+				RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_2_0[i], inst));
 }
 
 static const struct amd_ip_funcs vcn_v2_0_ip_funcs = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v1 3/9] drm/amdgpu: update vcn_v2.5 devcoredump on per instance basis
  2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 1/9] drm/amdgpu: update vcn_v1 devcoredump on per instance basis Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 2/9] drm/amdgpu: update vcn_v2.0 " Sunil Khatri
@ 2024-10-29 13:50 ` Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 4/9] drm/amdgpu: update vcn_v3.0 " Sunil Khatri
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

vcn code is restructured for per instance basis. Each
vcn instance is represented by an ip_block and hence a
need to update the dump and print functions for each
instance as an IP.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c | 77 +++++++++++++--------------
 1 file changed, 37 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
index da3d55cc3ac1..4f7460d43da7 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
@@ -277,12 +277,12 @@ static int vcn_v2_5_sw_init(struct amdgpu_ip_block *ip_block)
 		return r;
 
 	/* Allocate memory for VCN IP Dump buffer */
-	ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), GFP_KERNEL);
+	ptr = kcalloc(reg_count, sizeof(uint32_t), GFP_KERNEL);
 	if (!ptr) {
 		DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
-		adev->vcn.ip_dump = NULL;
+		ip_block->ip_dump = NULL;
 	} else {
-		adev->vcn.ip_dump = ptr;
+		ip_block->ip_dump = ptr;
 	}
 
 	return 0;
@@ -322,7 +322,7 @@ static int vcn_v2_5_sw_fini(struct amdgpu_ip_block *ip_block)
 
 	r = amdgpu_vcn_sw_fini(adev, inst);
 
-	kfree(adev->vcn.ip_dump);
+	kfree(ip_block->ip_dump);
 
 	return r;
 }
@@ -1908,61 +1908,58 @@ static void vcn_v2_5_set_irq_funcs(struct amdgpu_device *adev, int inst)
 static void vcn_v2_5_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_2_5);
-	uint32_t inst_off, is_powered;
+	uint32_t is_powered;
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i)) {
-			drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", i);
-			continue;
-		}
+	drm_printf(p, "Instance no:VCN%d\n", inst);
 
-		inst_off = i * reg_count;
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	if (adev->vcn.harvest_config & (1 << inst)) {
+		drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", inst);
+		return;
+	}
 
-		if (is_powered) {
-			drm_printf(p, "\nActive Instance:VCN%d\n", i);
-			for (j = 0; j < reg_count; j++)
-				drm_printf(p, "%-50s \t 0x%08x\n", vcn_reg_list_2_5[j].reg_name,
-					   adev->vcn.ip_dump[inst_off + j]);
-		} else {
-			drm_printf(p, "\nInactive Instance:VCN%d\n", i);
-		}
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+
+	if (is_powered) {
+		drm_printf(p, "\nActive Instance:VCN%d\n", inst);
+		for (i = 0; i < reg_count; i++)
+			drm_printf(p, "%-50s \t 0x%08x\n",
+				   vcn_reg_list_2_5[i].reg_name,
+				   ip_block->ip_dump[i]);
+	} else {
+		drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
 	}
 }
 
 static void vcn_v2_5_dump_ip_state(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	bool is_powered;
-	uint32_t inst_off;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_2_5);
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return;
 
-		inst_off = i * reg_count;
-		/* mmUVD_POWER_STATUS is always readable and is first element of the array */
-		adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, i, mmUVD_POWER_STATUS);
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	/* mmUVD_POWER_STATUS is always readable and is first element of the array */
+	ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, mmUVD_POWER_STATUS);
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		if (is_powered)
-			for (j = 1; j < reg_count; j++)
-				adev->vcn.ip_dump[inst_off + j] =
-					RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_2_5[j], i));
-	}
+	if (is_powered)
+		for (i = 1; i < reg_count; i++)
+			ip_block->ip_dump[i] =
+			RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_2_5[i], inst));
 }
 
 static const struct amd_ip_funcs vcn_v2_5_ip_funcs = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v1 4/9] drm/amdgpu: update vcn_v3.0 devcoredump on per instance basis
  2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
                   ` (2 preceding siblings ...)
  2024-10-29 13:50 ` [PATCH v1 3/9] drm/amdgpu: update vcn_v2.5 " Sunil Khatri
@ 2024-10-29 13:50 ` Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 5/9] drm/amdgpu: update vcn_v4.0.3 " Sunil Khatri
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

vcn code is restructured for per instance basis. Each
vcn instance is represented by an ip_block and hence a
need to update the dump and print functions for each
instance as an IP.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 75 +++++++++++++--------------
 1 file changed, 35 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index b78c6da0a3cd..1c149b5f5a79 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -285,12 +285,12 @@ static int vcn_v3_0_sw_init(struct amdgpu_ip_block *ip_block)
 		adev->vcn.pause_dpg_mode = vcn_v3_0_pause_dpg_mode;
 
 	/* Allocate memory for VCN IP Dump buffer */
-	ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), GFP_KERNEL);
+	ptr = kcalloc(reg_count, sizeof(uint32_t), GFP_KERNEL);
 	if (ptr == NULL) {
 		DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
-		adev->vcn.ip_dump = NULL;
+		ip_block->ip_dump = NULL;
 	} else {
-		adev->vcn.ip_dump = ptr;
+		ip_block->ip_dump = ptr;
 	}
 
 	return 0;
@@ -331,7 +331,7 @@ static int vcn_v3_0_sw_fini(struct amdgpu_ip_block *ip_block)
 
 	r = amdgpu_vcn_sw_fini(adev, inst);
 
-	kfree(adev->vcn.ip_dump);
+	kfree(ip_block->ip_dump);
 	return r;
 }
 
@@ -2232,62 +2232,57 @@ static void vcn_v3_0_set_irq_funcs(struct amdgpu_device *adev, int inst)
 static void vcn_v3_0_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_3_0);
-	uint32_t inst_off;
 	bool is_powered;
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i)) {
-			drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", i);
-			continue;
-		}
+	drm_printf(p, "Instance no:VCN%d\n", inst);
+	if (adev->vcn.harvest_config & (1 << inst)) {
+		drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", inst);
+		return;
+	}
 
-		inst_off = i * reg_count;
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-			      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		if (is_powered) {
-			drm_printf(p, "\nActive Instance:VCN%d\n", i);
-			for (j = 0; j < reg_count; j++)
-				drm_printf(p, "%-50s \t 0x%08x\n", vcn_reg_list_3_0[j].reg_name,
-					   adev->vcn.ip_dump[inst_off + j]);
-		} else {
-			drm_printf(p, "\nInactive Instance:VCN%d\n", i);
-		}
+	if (is_powered) {
+		drm_printf(p, "\nActive Instance:VCN%d\n", inst);
+		for (i = 0; i < reg_count; i++)
+			drm_printf(p, "%-50s \t 0x%08x\n",
+				   vcn_reg_list_3_0[i].reg_name,
+				   ip_block->ip_dump[i]);
+	} else {
+		drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
 	}
 }
 
 static void vcn_v3_0_dump_ip_state(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	bool is_powered;
-	uint32_t inst_off;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_3_0);
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return;
 
-		inst_off = i * reg_count;
-		/* mmUVD_POWER_STATUS is always readable and is first element of the array */
-		adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, i, mmUVD_POWER_STATUS);
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-			      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	/* mmUVD_POWER_STATUS is always readable and is first element of the array */
+	ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, mmUVD_POWER_STATUS);
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		if (is_powered)
-			for (j = 1; j < reg_count; j++)
-				adev->vcn.ip_dump[inst_off + j] =
-					RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_3_0[j], i));
-	}
+	if (is_powered)
+		for (i = 1; i < reg_count; i++)
+			ip_block->ip_dump[i] =
+				RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_3_0[i], inst));
 }
 
 static const struct amd_ip_funcs vcn_v3_0_ip_funcs = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v1 5/9] drm/amdgpu: update vcn_v4.0.3 devcoredump on per instance basis
  2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
                   ` (3 preceding siblings ...)
  2024-10-29 13:50 ` [PATCH v1 4/9] drm/amdgpu: update vcn_v3.0 " Sunil Khatri
@ 2024-10-29 13:50 ` Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 6/9] drm/amdgpu: update vcn_v4.0.5 " Sunil Khatri
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

vcn code is restructured for per instance basis. Each
vcn instance is represented by an ip_block and hence a
need to update the dump and print functions for each
instance as an IP.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 80 ++++++++++++-------------
 1 file changed, 37 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
index 64b738f929b7..c37dcf835dc8 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
@@ -201,9 +201,9 @@ static int vcn_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)
 	ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), GFP_KERNEL);
 	if (!ptr) {
 		DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
-		adev->vcn.ip_dump = NULL;
+		ip_block->ip_dump = NULL;
 	} else {
-		adev->vcn.ip_dump = ptr;
+		ip_block->ip_dump = ptr;
 	}
 
 	return 0;
@@ -241,7 +241,7 @@ static int vcn_v4_0_3_sw_fini(struct amdgpu_ip_block *ip_block)
 
 	r = amdgpu_vcn_sw_fini(adev, inst);
 
-	kfree(adev->vcn.ip_dump);
+	kfree(ip_block->ip_dump);
 
 	return r;
 }
@@ -1722,63 +1722,57 @@ static void vcn_v4_0_3_set_irq_funcs(struct amdgpu_device *adev, int inst)
 static void vcn_v4_0_3_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_4_0_3);
-	uint32_t inst_off, is_powered;
+	uint32_t is_powered;
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i)) {
-			drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", i);
-			continue;
-		}
+	drm_printf(p, "Instance no:VCN%d\n", inst);
+	if (adev->vcn.harvest_config & (1 << inst)) {
+		drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", inst);
+		return;
+	}
 
-		inst_off = i * reg_count;
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		if (is_powered) {
-			drm_printf(p, "\nActive Instance:VCN%d\n", i);
-			for (j = 0; j < reg_count; j++)
-				drm_printf(p, "%-50s \t 0x%08x\n", vcn_reg_list_4_0_3[j].reg_name,
-					   adev->vcn.ip_dump[inst_off + j]);
-		} else {
-			drm_printf(p, "\nInactive Instance:VCN%d\n", i);
-		}
+	if (is_powered) {
+		drm_printf(p, "\nActive Instance:VCN%d\n", inst);
+		for (i = 0; i < reg_count; i++)
+			drm_printf(p, "%-50s \t 0x%08x\n",
+				   vcn_reg_list_4_0_3[i].reg_name,
+				   ip_block->ip_dump[i]);
+	} else {
+		drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
 	}
 }
 
 static void vcn_v4_0_3_dump_ip_state(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	bool is_powered;
-	uint32_t inst_off, inst_id;
+	uint32_t inst = GET_INST(VCN, ip_block->instance);
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_4_0_3);
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
-
-		inst_id = GET_INST(VCN, i);
-		inst_off = i * reg_count;
-		/* mmUVD_POWER_STATUS is always readable and is first element of the array */
-		adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, inst_id, regUVD_POWER_STATUS);
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
-
-		if (is_powered)
-			for (j = 1; j < reg_count; j++)
-				adev->vcn.ip_dump[inst_off + j] =
-					RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_4_0_3[j],
-									   inst_id));
-	}
+	if (adev->vcn.harvest_config & (1 << inst))
+		return;
+
+	/* mmUVD_POWER_STATUS is always readable and is first element of the array */
+	ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, regUVD_POWER_STATUS);
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+
+	if (is_powered)
+		for (i = 1; i < reg_count; i++)
+			ip_block->ip_dump[i] =
+				RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_4_0_3[i], inst));
 }
 
 static const struct amd_ip_funcs vcn_v4_0_3_ip_funcs = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v1 6/9] drm/amdgpu: update vcn_v4.0.5 devcoredump on per instance basis
  2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
                   ` (4 preceding siblings ...)
  2024-10-29 13:50 ` [PATCH v1 5/9] drm/amdgpu: update vcn_v4.0.3 " Sunil Khatri
@ 2024-10-29 13:50 ` Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 7/9] drm/amdgpu: update vcn_v4 " Sunil Khatri
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

vcn code is restructured for per instance basis. Each
vcn instance is represented by an ip_block and hence a
need to update the dump and print functions for each
instance as an IP.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 80 ++++++++++++-------------
 1 file changed, 38 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
index c901255a05ee..3854e248a619 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
@@ -207,12 +207,12 @@ static int vcn_v4_0_5_sw_init(struct amdgpu_ip_block *ip_block)
 		adev->vcn.pause_dpg_mode = vcn_v4_0_5_pause_dpg_mode;
 
 	/* Allocate memory for VCN IP Dump buffer */
-	ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), GFP_KERNEL);
+	ptr = kcalloc(reg_count, sizeof(uint32_t), GFP_KERNEL);
 	if (!ptr) {
 		DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
-		adev->vcn.ip_dump = NULL;
+		ip_block->ip_dump = NULL;
 	} else {
-		adev->vcn.ip_dump = ptr;
+		ip_block->ip_dump = ptr;
 	}
 	return 0;
 }
@@ -252,7 +252,7 @@ static int vcn_v4_0_5_sw_fini(struct amdgpu_ip_block *ip_block)
 
 	r = amdgpu_vcn_sw_fini(adev, inst);
 
-	kfree(adev->vcn.ip_dump);
+	kfree(ip_block->ip_dump);
 
 	return r;
 }
@@ -1602,62 +1602,58 @@ static void vcn_v4_0_5_set_irq_funcs(struct amdgpu_device *adev, int inst)
 static void vcn_v4_0_5_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_4_0_5);
-	uint32_t inst_off, is_powered;
+	uint32_t is_powered;
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i)) {
-			drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", i);
-			continue;
-		}
+	drm_printf(p, "Instances no:VCN%d\n", inst);
+
+	if (adev->vcn.harvest_config & (1 << inst)) {
+		drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", inst);
+		return;
+	}
 
-		inst_off = i * reg_count;
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		if (is_powered) {
-			drm_printf(p, "\nActive Instance:VCN%d\n", i);
-			for (j = 0; j < reg_count; j++)
-				drm_printf(p, "%-50s \t 0x%08x\n", vcn_reg_list_4_0_5[j].reg_name,
-					   adev->vcn.ip_dump[inst_off + j]);
-		} else {
-			drm_printf(p, "\nInactive Instance:VCN%d\n", i);
-		}
+	if (is_powered) {
+		drm_printf(p, "\nActive Instance:VCN%d\n", inst);
+		for (i = 0; i < reg_count; i++)
+			drm_printf(p, "%-50s \t 0x%08x\n",
+				   vcn_reg_list_4_0_5[i].reg_name,
+				   ip_block->ip_dump[i]);
+	} else {
+		drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
 	}
 }
 
 static void vcn_v4_0_5_dump_ip_state(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	bool is_powered;
-	uint32_t inst_off;
+	uint32_t inst = GET_INST(VCN, ip_block->instance);
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_4_0_5);
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return;
 
-		inst_off = i * reg_count;
-		/* mmUVD_POWER_STATUS is always readable and is first element of the array */
-		adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, i, regUVD_POWER_STATUS);
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
-
-		if (is_powered)
-			for (j = 1; j < reg_count; j++)
-				adev->vcn.ip_dump[inst_off + j] =
-					RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_4_0_5[j],
-									   i));
-	}
+	/* mmUVD_POWER_STATUS is always readable and is first element of the array */
+	ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, regUVD_POWER_STATUS);
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+
+	if (is_powered)
+		for (i = 1; i < reg_count; i++)
+			ip_block->ip_dump[i] =
+				RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_4_0_5[i], inst));
 }
 
 static const struct amd_ip_funcs vcn_v4_0_5_ip_funcs = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v1 7/9] drm/amdgpu: update vcn_v4 devcoredump on per instance basis
  2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
                   ` (5 preceding siblings ...)
  2024-10-29 13:50 ` [PATCH v1 6/9] drm/amdgpu: update vcn_v4.0.5 " Sunil Khatri
@ 2024-10-29 13:50 ` Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 8/9] drm/amdgpu: update vcn_v5.0 " Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 9/9] drm/amdgpu: remove unused ip_dump from vcn device Sunil Khatri
  8 siblings, 0 replies; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

vcn code is restructured for per instance basis. Each
vcn instance is represented by an ip_block and hence a
need to update the dump and print functions for each
instance as an IP.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 80 +++++++++++++--------------
 1 file changed, 38 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
index 8aa30a4bddbf..a4126c066b58 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
@@ -237,12 +237,12 @@ static int vcn_v4_0_sw_init(struct amdgpu_ip_block *ip_block)
 		return r;
 
 	/* Allocate memory for VCN IP Dump buffer */
-	ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), GFP_KERNEL);
+	ptr = kcalloc(reg_count, sizeof(uint32_t), GFP_KERNEL);
 	if (!ptr) {
 		DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
-		adev->vcn.ip_dump = NULL;
+		ip_block->ip_dump = NULL;
 	} else {
-		adev->vcn.ip_dump = ptr;
+		ip_block->ip_dump = ptr;
 	}
 
 	return 0;
@@ -283,7 +283,7 @@ static int vcn_v4_0_sw_fini(struct amdgpu_ip_block *ip_block)
 
 	r = amdgpu_vcn_sw_fini(adev, inst);
 
-	kfree(adev->vcn.ip_dump);
+	kfree(ip_block->ip_dump);
 
 	return r;
 }
@@ -2141,62 +2141,58 @@ static void vcn_v4_0_set_irq_funcs(struct amdgpu_device *adev, int inst)
 static void vcn_v4_0_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_4_0);
-	uint32_t inst_off, is_powered;
+	uint32_t is_powered;
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i)) {
-			drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", i);
-			continue;
-		}
+	drm_printf(p, "Instance no:VCN%d\n", inst);
 
-		inst_off = i * reg_count;
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	if (adev->vcn.harvest_config & (1 << inst)) {
+		drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", inst);
+		return;
+	}
 
-		if (is_powered) {
-			drm_printf(p, "\nActive Instance:VCN%d\n", i);
-			for (j = 0; j < reg_count; j++)
-				drm_printf(p, "%-50s \t 0x%08x\n", vcn_reg_list_4_0[j].reg_name,
-					   adev->vcn.ip_dump[inst_off + j]);
-		} else {
-			drm_printf(p, "\nInactive Instance:VCN%d\n", i);
-		}
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+
+	if (is_powered) {
+		drm_printf(p, "\nActive Instance:VCN%d\n", inst);
+		for (i = 0; i < reg_count; i++)
+			drm_printf(p, "%-50s \t 0x%08x\n",
+				   vcn_reg_list_4_0[i].reg_name,
+				   ip_block->ip_dump[i]);
+	} else {
+		drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
 	}
 }
 
 static void vcn_v4_0_dump_ip_state(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	bool is_powered;
-	uint32_t inst_off;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_4_0);
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return;
 
-		inst_off = i * reg_count;
-		/* mmUVD_POWER_STATUS is always readable and is first element of the array */
-		adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, i, regUVD_POWER_STATUS);
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
-
-		if (is_powered)
-			for (j = 1; j < reg_count; j++)
-				adev->vcn.ip_dump[inst_off + j] =
-					RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_4_0[j],
-									   i));
-	}
+	/* mmUVD_POWER_STATUS is always readable and is first element of the array */
+	ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, regUVD_POWER_STATUS);
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+
+	if (is_powered)
+		for (i = 1; i < reg_count; i++)
+			ip_block->ip_dump[i] =
+				RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_4_0[i], inst));
 }
 
 static const struct amd_ip_funcs vcn_v4_0_ip_funcs = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v1 8/9] drm/amdgpu: update vcn_v5.0 devcoredump on per instance basis
  2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
                   ` (6 preceding siblings ...)
  2024-10-29 13:50 ` [PATCH v1 7/9] drm/amdgpu: update vcn_v4 " Sunil Khatri
@ 2024-10-29 13:50 ` Sunil Khatri
  2024-10-29 13:50 ` [PATCH v1 9/9] drm/amdgpu: remove unused ip_dump from vcn device Sunil Khatri
  8 siblings, 0 replies; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

vcn code is restructured for per instance basis. Each
vcn instance is represented by an ip_block and hence a
need to update the dump and print functions for each
instance as an IP.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 77 ++++++++++++-------------
 1 file changed, 37 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
index 6973fee37c12..66e6e57b5386 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
@@ -174,12 +174,12 @@ static int vcn_v5_0_0_sw_init(struct amdgpu_ip_block *ip_block)
 		adev->vcn.pause_dpg_mode = vcn_v5_0_0_pause_dpg_mode;
 
 	/* Allocate memory for VCN IP Dump buffer */
-	ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), GFP_KERNEL);
+	ptr = kcalloc(reg_count, sizeof(uint32_t), GFP_KERNEL);
 	if (!ptr) {
 		DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
-		adev->vcn.ip_dump = NULL;
+		ip_block->ip_dump = NULL;
 	} else {
-		adev->vcn.ip_dump = ptr;
+		ip_block->ip_dump = ptr;
 	}
 	return 0;
 }
@@ -216,7 +216,7 @@ static int vcn_v5_0_0_sw_fini(struct amdgpu_ip_block *ip_block)
 
 	r = amdgpu_vcn_sw_fini(adev, inst);
 
-	kfree(adev->vcn.ip_dump);
+	kfree(ip_block->ip_dump);
 
 	return r;
 }
@@ -1329,61 +1329,58 @@ static void vcn_v5_0_0_set_irq_funcs(struct amdgpu_device *adev, int inst)
 static void vcn_v5_0_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_5_0);
-	uint32_t inst_off, is_powered;
+	uint32_t is_powered;
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i)) {
-			drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", i);
-			continue;
-		}
+	drm_printf(p, "Instance no:VCN%d\n", inst);
+
+	if (adev->vcn.harvest_config & (1 << inst)) {
+		drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", inst);
+		return;
+	}
 
-		inst_off = i * reg_count;
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		if (is_powered) {
-			drm_printf(p, "\nActive Instance:VCN%d\n", i);
-			for (j = 0; j < reg_count; j++)
-				drm_printf(p, "%-50s \t 0x%08x\n", vcn_reg_list_5_0[j].reg_name,
-					   adev->vcn.ip_dump[inst_off + j]);
-		} else {
-			drm_printf(p, "\nInactive Instance:VCN%d\n", i);
-		}
+	if (is_powered) {
+		drm_printf(p, "\nActive Instance:VCN%d\n", inst);
+		for (i = 0; i < reg_count; i++)
+			drm_printf(p, "%-50s \t 0x%08x\n",
+				   vcn_reg_list_5_0[i].reg_name,
+				   ip_block->ip_dump[i]);
+	} else {
+		drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
 	}
 }
 
 static void vcn_v5_0_dump_ip_state(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	int i, j;
+	int i;
 	bool is_powered;
-	uint32_t inst_off;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_5_0);
+	int inst = ip_block->instance;
 
-	if (!adev->vcn.ip_dump)
+	if (!ip_block->ip_dump)
 		return;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return;
 
-		inst_off = i * reg_count;
-		/* mmUVD_POWER_STATUS is always readable and is first element of the array */
-		adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, i, regUVD_POWER_STATUS);
-		is_powered = (adev->vcn.ip_dump[inst_off] &
-				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+	/* mmUVD_POWER_STATUS is always readable and is first element of the array */
+	ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, regUVD_POWER_STATUS);
+	is_powered = (ip_block->ip_dump[0] &
+		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		if (is_powered)
-			for (j = 1; j < reg_count; j++)
-				adev->vcn.ip_dump[inst_off + j] =
-					RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_5_0[j], i));
-	}
+	if (is_powered)
+		for (i = 1; i < reg_count; i++)
+			ip_block->ip_dump[i] =
+				RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_5_0[i], inst));
 }
 
 static const struct amd_ip_funcs vcn_v5_0_0_ip_funcs = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v1 9/9] drm/amdgpu: remove unused ip_dump from vcn device
  2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
                   ` (7 preceding siblings ...)
  2024-10-29 13:50 ` [PATCH v1 8/9] drm/amdgpu: update vcn_v5.0 " Sunil Khatri
@ 2024-10-29 13:50 ` Sunil Khatri
  2024-10-31  9:53   ` Christian König
  8 siblings, 1 reply; 14+ messages in thread
From: Sunil Khatri @ 2024-10-29 13:50 UTC (permalink / raw)
  To: Alex Deucher, Christian König, Leo Liu, Boyuan Zhang
  Cc: amd-gfx, Sunil Khatri

ip_dump pointer for the vcn has now moved to the
per instance ip_block hence clean the old pointer
from the vcn device.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
index 6cd094ee8218..7aa52a04b488 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
@@ -332,9 +332,6 @@ struct amdgpu_vcn {
 	uint16_t inst_mask;
 	uint8_t	num_inst_per_aid;
 	bool using_unified_queue;
-
-	/* IP reg dump */
-	uint32_t		*ip_dump;
 };
 
 struct amdgpu_fw_shared_rb_ptrs_struct {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v1 1/9] drm/amdgpu: update vcn_v1 devcoredump on per instance basis
  2024-10-29 13:50 ` [PATCH v1 1/9] drm/amdgpu: update vcn_v1 devcoredump on per instance basis Sunil Khatri
@ 2024-10-31  9:46   ` Christian König
  2024-11-04  4:04     ` Khatri, Sunil
  0 siblings, 1 reply; 14+ messages in thread
From: Christian König @ 2024-10-31  9:46 UTC (permalink / raw)
  To: Sunil Khatri, Alex Deucher, Leo Liu, Boyuan Zhang; +Cc: amd-gfx

Am 29.10.24 um 14:50 schrieb Sunil Khatri:
> vcn code is restructured for per instance basis. Each
> vcn instance is represented by an ip_block and hence a
> need to update the dump and print functions for each
> instance as an IP.
>
> Existing way was to capture the ip dump for each instance
> in a same memory dump but now each ip_block of vcn is an
> independent one and its memory is independent and handled
> within the ip_block now.
>
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  2 +
>   drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 77 +++++++++++++--------------
>   2 files changed, 39 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index d4c8cc3c1730..ef564ddcfcbb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -392,6 +392,8 @@ struct amdgpu_ip_block {
>   	const struct amdgpu_ip_block_version *version;
>   	struct amdgpu_device *adev;
>   	unsigned int instance;
> +	/* IP reg dump */

That comment could be improved, something like "Memory to dump IP 
registers and state in GPU reset handling".

Apart from that feel free to add Reviewed-by: Christian König 
<christian.koenig@amd.com> to the patch.

Regards,
Christian.

> +	uint32_t *ip_dump;
>   };
>   
>   int amdgpu_device_ip_block_version_cmp(struct amdgpu_device *adev,
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
> index 7638ddeccec7..f31fdd620c86 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
> @@ -203,12 +203,12 @@ static int vcn_v1_0_sw_init(struct amdgpu_ip_block *ip_block)
>   	r = jpeg_v1_0_sw_init(ip_block);
>   
>   	/* Allocate memory for VCN IP Dump buffer */
> -	ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), GFP_KERNEL);
> +	ptr = kcalloc(reg_count, sizeof(uint32_t), GFP_KERNEL);
>   	if (!ptr) {
>   		DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
> -		adev->vcn.ip_dump = NULL;
> +		ip_block->ip_dump = NULL;
>   	} else {
> -		adev->vcn.ip_dump = ptr;
> +		ip_block->ip_dump = ptr;
>   	}
>   	return r;
>   }
> @@ -234,7 +234,7 @@ static int vcn_v1_0_sw_fini(struct amdgpu_ip_block *ip_block)
>   
>   	r = amdgpu_vcn_sw_fini(adev, inst);
>   
> -	kfree(adev->vcn.ip_dump);
> +	kfree(ip_block->ip_dump);
>   
>   	return r;
>   }
> @@ -1933,61 +1933,58 @@ void vcn_v1_0_ring_end_use(struct amdgpu_ring *ring)
>   static void vcn_v1_0_print_ip_state(struct amdgpu_ip_block *ip_block, struct drm_printer *p)
>   {
>   	struct amdgpu_device *adev = ip_block->adev;
> -	int i, j;
> +	int i;
>   	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_1_0);
> -	uint32_t inst_off, is_powered;
> +	uint32_t is_powered;
> +	int inst = ip_block->instance;
>   
> -	if (!adev->vcn.ip_dump)
> +	if (!ip_block->ip_dump)
>   		return;
>   
> -	drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
> -	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
> -		if (adev->vcn.harvest_config & (1 << i)) {
> -			drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", i);
> -			continue;
> -		}
> +	drm_printf(p, "Instance no:VCN%d\n", inst);
>   
> -		inst_off = i * reg_count;
> -		is_powered = (adev->vcn.ip_dump[inst_off] &
> -				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
> +	if (adev->vcn.harvest_config & (1 << inst)) {
> +		drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", inst);
> +		return;
> +	}
>   
> -		if (is_powered) {
> -			drm_printf(p, "\nActive Instance:VCN%d\n", i);
> -			for (j = 0; j < reg_count; j++)
> -				drm_printf(p, "%-50s \t 0x%08x\n", vcn_reg_list_1_0[j].reg_name,
> -					   adev->vcn.ip_dump[inst_off + j]);
> -		} else {
> -			drm_printf(p, "\nInactive Instance:VCN%d\n", i);
> -		}
> +	is_powered = (ip_block->ip_dump[0] &
> +		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
> +
> +	if (is_powered) {
> +		drm_printf(p, "\nActive Instance:VCN%d\n", inst);
> +		for (i = 0; i < reg_count; i++)
> +			drm_printf(p, "%-50s \t 0x%08x\n",
> +				   vcn_reg_list_1_0[i].reg_name,
> +				   ip_block->ip_dump[i]);
> +	} else {
> +		drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
>   	}
>   }
>   
>   static void vcn_v1_0_dump_ip_state(struct amdgpu_ip_block *ip_block)
>   {
>   	struct amdgpu_device *adev = ip_block->adev;
> -	int i, j;
> +	int i;
> +	int inst = ip_block->instance;
>   	bool is_powered;
> -	uint32_t inst_off;
>   	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_1_0);
>   
> -	if (!adev->vcn.ip_dump)
> +	if (!ip_block->ip_dump)
>   		return;
>   
> -	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
> -		if (adev->vcn.harvest_config & (1 << i))
> -			continue;
> +	if (adev->vcn.harvest_config & (1 << inst))
> +		return;
>   
> -		inst_off = i * reg_count;
> -		/* mmUVD_POWER_STATUS is always readable and is first element of the array */
> -		adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, i, mmUVD_POWER_STATUS);
> -		is_powered = (adev->vcn.ip_dump[inst_off] &
> -				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
> +	/* mmUVD_POWER_STATUS is always readable and is first element of the array */
> +	ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, mmUVD_POWER_STATUS);
> +	is_powered = (ip_block->ip_dump[0] &
> +		      UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
>   
> -		if (is_powered)
> -			for (j = 1; j < reg_count; j++)
> -				adev->vcn.ip_dump[inst_off + j] =
> -					RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_1_0[j], i));
> -	}
> +	if (is_powered)
> +		for (i = 1; i < reg_count; i++)
> +			ip_block->ip_dump[i] =
> +				RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_1_0[i], inst));
>   }
>   
>   static const struct amd_ip_funcs vcn_v1_0_ip_funcs = {


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1 9/9] drm/amdgpu: remove unused ip_dump from vcn device
  2024-10-29 13:50 ` [PATCH v1 9/9] drm/amdgpu: remove unused ip_dump from vcn device Sunil Khatri
@ 2024-10-31  9:53   ` Christian König
  2024-11-04  4:05     ` Khatri, Sunil
  0 siblings, 1 reply; 14+ messages in thread
From: Christian König @ 2024-10-31  9:53 UTC (permalink / raw)
  To: Sunil Khatri, Alex Deucher, Leo Liu, Boyuan Zhang; +Cc: amd-gfx

Am 29.10.24 um 14:50 schrieb Sunil Khatri:
> ip_dump pointer for the vcn has now moved to the
> per instance ip_block hence clean the old pointer
> from the vcn device.
>
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com> for the entire 
series.

And Alex is right we should really look into moving the harvest config 
into the IP block state as well.

Regards,
Christian.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 3 ---
>   1 file changed, 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
> index 6cd094ee8218..7aa52a04b488 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
> @@ -332,9 +332,6 @@ struct amdgpu_vcn {
>   	uint16_t inst_mask;
>   	uint8_t	num_inst_per_aid;
>   	bool using_unified_queue;
> -
> -	/* IP reg dump */
> -	uint32_t		*ip_dump;
>   };
>   
>   struct amdgpu_fw_shared_rb_ptrs_struct {


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1 1/9] drm/amdgpu: update vcn_v1 devcoredump on per instance basis
  2024-10-31  9:46   ` Christian König
@ 2024-11-04  4:04     ` Khatri, Sunil
  0 siblings, 0 replies; 14+ messages in thread
From: Khatri, Sunil @ 2024-11-04  4:04 UTC (permalink / raw)
  To: Christian König, Alex Deucher, Leo Liu, Boyuan Zhang; +Cc: amd-gfx

On 10/31/2024 3:16 PM, Christian König wrote:
> Am 29.10.24 um 14:50 schrieb Sunil Khatri:
>> vcn code is restructured for per instance basis. Each
>> vcn instance is represented by an ip_block and hence a
>> need to update the dump and print functions for each
>> instance as an IP.
>>
>> Existing way was to capture the ip dump for each instance
>> in a same memory dump but now each ip_block of vcn is an
>> independent one and its memory is independent and handled
>> within the ip_block now.
>>
>> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  2 +
>>   drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 77 +++++++++++++--------------
>>   2 files changed, 39 insertions(+), 40 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> index d4c8cc3c1730..ef564ddcfcbb 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> @@ -392,6 +392,8 @@ struct amdgpu_ip_block {
>>       const struct amdgpu_ip_block_version *version;
>>       struct amdgpu_device *adev;
>>       unsigned int instance;
>> +    /* IP reg dump */
>
> That comment could be improved, something like "Memory to dump IP 
> registers and state in GPU reset handling".
> Sure will update the commit message as you suggested.
>
> Apart from that feel free to add Reviewed-by: Christian König 
> <christian.koenig@amd.com> to the patch.
>
> Regards,
> Christian.
>
>> +    uint32_t *ip_dump;
>>   };
>>     int amdgpu_device_ip_block_version_cmp(struct amdgpu_device *adev,
>> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c 
>> b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
>> index 7638ddeccec7..f31fdd620c86 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
>> @@ -203,12 +203,12 @@ static int vcn_v1_0_sw_init(struct 
>> amdgpu_ip_block *ip_block)
>>       r = jpeg_v1_0_sw_init(ip_block);
>>         /* Allocate memory for VCN IP Dump buffer */
>> -    ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, 
>> sizeof(uint32_t), GFP_KERNEL);
>> +    ptr = kcalloc(reg_count, sizeof(uint32_t), GFP_KERNEL);
>>       if (!ptr) {
>>           DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
>> -        adev->vcn.ip_dump = NULL;
>> +        ip_block->ip_dump = NULL;
>>       } else {
>> -        adev->vcn.ip_dump = ptr;
>> +        ip_block->ip_dump = ptr;
>>       }
>>       return r;
>>   }
>> @@ -234,7 +234,7 @@ static int vcn_v1_0_sw_fini(struct 
>> amdgpu_ip_block *ip_block)
>>         r = amdgpu_vcn_sw_fini(adev, inst);
>>   -    kfree(adev->vcn.ip_dump);
>> +    kfree(ip_block->ip_dump);
>>         return r;
>>   }
>> @@ -1933,61 +1933,58 @@ void vcn_v1_0_ring_end_use(struct amdgpu_ring 
>> *ring)
>>   static void vcn_v1_0_print_ip_state(struct amdgpu_ip_block 
>> *ip_block, struct drm_printer *p)
>>   {
>>       struct amdgpu_device *adev = ip_block->adev;
>> -    int i, j;
>> +    int i;
>>       uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_1_0);
>> -    uint32_t inst_off, is_powered;
>> +    uint32_t is_powered;
>> +    int inst = ip_block->instance;
>>   -    if (!adev->vcn.ip_dump)
>> +    if (!ip_block->ip_dump)
>>           return;
>>   -    drm_printf(p, "num_instances:%d\n", adev->vcn.num_vcn_inst);
>> -    for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
>> -        if (adev->vcn.harvest_config & (1 << i)) {
>> -            drm_printf(p, "\nHarvested Instance:VCN%d Skipping 
>> dump\n", i);
>> -            continue;
>> -        }
>> +    drm_printf(p, "Instance no:VCN%d\n", inst);
>>   -        inst_off = i * reg_count;
>> -        is_powered = (adev->vcn.ip_dump[inst_off] &
>> -                UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
>> +    if (adev->vcn.harvest_config & (1 << inst)) {
>> +        drm_printf(p, "\nHarvested Instance:VCN%d Skipping dump\n", 
>> inst);
>> +        return;
>> +    }
>>   -        if (is_powered) {
>> -            drm_printf(p, "\nActive Instance:VCN%d\n", i);
>> -            for (j = 0; j < reg_count; j++)
>> -                drm_printf(p, "%-50s \t 0x%08x\n", 
>> vcn_reg_list_1_0[j].reg_name,
>> -                       adev->vcn.ip_dump[inst_off + j]);
>> -        } else {
>> -            drm_printf(p, "\nInactive Instance:VCN%d\n", i);
>> -        }
>> +    is_powered = (ip_block->ip_dump[0] &
>> +              UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
>> +
>> +    if (is_powered) {
>> +        drm_printf(p, "\nActive Instance:VCN%d\n", inst);
>> +        for (i = 0; i < reg_count; i++)
>> +            drm_printf(p, "%-50s \t 0x%08x\n",
>> +                   vcn_reg_list_1_0[i].reg_name,
>> +                   ip_block->ip_dump[i]);
>> +    } else {
>> +        drm_printf(p, "\nInactive Instance:VCN%d\n", inst);
>>       }
>>   }
>>     static void vcn_v1_0_dump_ip_state(struct amdgpu_ip_block *ip_block)
>>   {
>>       struct amdgpu_device *adev = ip_block->adev;
>> -    int i, j;
>> +    int i;
>> +    int inst = ip_block->instance;
>>       bool is_powered;
>> -    uint32_t inst_off;
>>       uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_1_0);
>>   -    if (!adev->vcn.ip_dump)
>> +    if (!ip_block->ip_dump)
>>           return;
>>   -    for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
>> -        if (adev->vcn.harvest_config & (1 << i))
>> -            continue;
>> +    if (adev->vcn.harvest_config & (1 << inst))
>> +        return;
>>   -        inst_off = i * reg_count;
>> -        /* mmUVD_POWER_STATUS is always readable and is first 
>> element of the array */
>> -        adev->vcn.ip_dump[inst_off] = RREG32_SOC15(VCN, i, 
>> mmUVD_POWER_STATUS);
>> -        is_powered = (adev->vcn.ip_dump[inst_off] &
>> -                UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
>> +    /* mmUVD_POWER_STATUS is always readable and is first element of 
>> the array */
>> +    ip_block->ip_dump[0] = RREG32_SOC15(VCN, inst, mmUVD_POWER_STATUS);
>> +    is_powered = (ip_block->ip_dump[0] &
>> +              UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
>>   -        if (is_powered)
>> -            for (j = 1; j < reg_count; j++)
>> -                adev->vcn.ip_dump[inst_off + j] =
>> - RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_1_0[j], i));
>> -    }
>> +    if (is_powered)
>> +        for (i = 1; i < reg_count; i++)
>> +            ip_block->ip_dump[i] =
>> + RREG32(SOC15_REG_ENTRY_OFFSET_INST(vcn_reg_list_1_0[i], inst));
>>   }
>>     static const struct amd_ip_funcs vcn_v1_0_ip_funcs = {
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1 9/9] drm/amdgpu: remove unused ip_dump from vcn device
  2024-10-31  9:53   ` Christian König
@ 2024-11-04  4:05     ` Khatri, Sunil
  0 siblings, 0 replies; 14+ messages in thread
From: Khatri, Sunil @ 2024-11-04  4:05 UTC (permalink / raw)
  To: Christian König, Alex Deucher, Leo Liu, Boyuan Zhang; +Cc: amd-gfx


On 10/31/2024 3:23 PM, Christian König wrote:
> Am 29.10.24 um 14:50 schrieb Sunil Khatri:
>> ip_dump pointer for the vcn has now moved to the
>> per instance ip_block hence clean the old pointer
>> from the vcn device.
>>
>> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com> for the entire 
> series.
>
> And Alex is right we should really look into moving the harvest config 
> into the IP block state as well.
> I guess Boyuan will be taking care of that.

> Regards
> Sunil Khatri
>
> Regards,
> Christian.
>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 3 ---
>>   1 file changed, 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
>> index 6cd094ee8218..7aa52a04b488 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
>> @@ -332,9 +332,6 @@ struct amdgpu_vcn {
>>       uint16_t inst_mask;
>>       uint8_t    num_inst_per_aid;
>>       bool using_unified_queue;
>> -
>> -    /* IP reg dump */
>> -    uint32_t        *ip_dump;
>>   };
>>     struct amdgpu_fw_shared_rb_ptrs_struct {
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-11-04  4:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 13:50 [PATCH v1 0/9] update devcoredump for new VCN instance design Sunil Khatri
2024-10-29 13:50 ` [PATCH v1 1/9] drm/amdgpu: update vcn_v1 devcoredump on per instance basis Sunil Khatri
2024-10-31  9:46   ` Christian König
2024-11-04  4:04     ` Khatri, Sunil
2024-10-29 13:50 ` [PATCH v1 2/9] drm/amdgpu: update vcn_v2.0 " Sunil Khatri
2024-10-29 13:50 ` [PATCH v1 3/9] drm/amdgpu: update vcn_v2.5 " Sunil Khatri
2024-10-29 13:50 ` [PATCH v1 4/9] drm/amdgpu: update vcn_v3.0 " Sunil Khatri
2024-10-29 13:50 ` [PATCH v1 5/9] drm/amdgpu: update vcn_v4.0.3 " Sunil Khatri
2024-10-29 13:50 ` [PATCH v1 6/9] drm/amdgpu: update vcn_v4.0.5 " Sunil Khatri
2024-10-29 13:50 ` [PATCH v1 7/9] drm/amdgpu: update vcn_v4 " Sunil Khatri
2024-10-29 13:50 ` [PATCH v1 8/9] drm/amdgpu: update vcn_v5.0 " Sunil Khatri
2024-10-29 13:50 ` [PATCH v1 9/9] drm/amdgpu: remove unused ip_dump from vcn device Sunil Khatri
2024-10-31  9:53   ` Christian König
2024-11-04  4:05     ` Khatri, Sunil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox