AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sunil Khatri <sunil.khatri@amd.com>
To: "Alex Deucher" <alexander.deucher@amd.com>,
	"Liu Leo" <Leo.Liu@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Cc: amd-gfx@lists.freedesktop.org, Sunil Khatri <sunil.khatri@amd.com>
Subject: [PATCH 1/2] drm/amdgpu: print VCN instance dump for valid instance
Date: Fri, 26 Jul 2024 18:17:50 +0530	[thread overview]
Message-ID: <20240726124751.3121312-1-sunil.khatri@amd.com> (raw)

VCN dump is dependent on power state of the ip. Dump is
valid if VCN was powered up at the time of ip dump.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index 9e1cbeee10db..c2278cc49dd5 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -2329,7 +2329,7 @@ static void vcn_v3_0_print_ip_state(void *handle, struct drm_printer *p)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	int i, j;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_3_0);
-	uint32_t inst_off;
+	uint32_t inst_off, is_powered;
 
 	if (!adev->vcn.ip_dump)
 		return;
@@ -2342,11 +2342,17 @@ static void vcn_v3_0_print_ip_state(void *handle, struct drm_printer *p)
 		}
 
 		inst_off = i * reg_count;
-		drm_printf(p, "\nActive Instance:VCN%d\n", i);
+		is_powered = (adev->vcn.ip_dump[inst_off] &
+				UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
 
-		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]);
+		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);
+		}
 	}
 }
 
@@ -2354,7 +2360,7 @@ static void vcn_v3_0_dump_ip_state(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	int i, j;
-	bool reg_safe;
+	bool is_powered;
 	uint32_t inst_off;
 	uint32_t reg_count = ARRAY_SIZE(vcn_reg_list_3_0);
 
@@ -2366,11 +2372,13 @@ static void vcn_v3_0_dump_ip_state(void *handle)
 			continue;
 
 		inst_off = i * reg_count;
-		reg_safe = (RREG32_SOC15(VCN, i, mmUVD_POWER_STATUS) &
-			    UVD_POWER_STATUS__UVD_POWER_STATUS_MASK) != 1;
+		/* 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;
 
-		if (reg_safe)
-			for (j = 0; j < reg_count; j++)
+		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));
 	}
-- 
2.34.1


             reply	other threads:[~2024-07-26 12:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26 12:47 Sunil Khatri [this message]
2024-07-26 12:47 ` [PATCH 2/2] drm/amdgpu: trigger ip dump before suspend of IP's Sunil Khatri
2024-07-26 13:12   ` Alex Deucher
2024-07-26 13:48     ` Lazar, Lijo
2024-07-26 14:23       ` Khatri, Sunil
2024-07-26 14:41         ` Khatri, Sunil
2024-07-26 15:06           ` Lazar, Lijo
2024-07-26 17:16             ` Khatri, Sunil
2024-07-26 18:43               ` Alex Deucher
2024-07-26 19:21                 ` Khatri, Sunil
2024-07-29  4:38                   ` Lazar, Lijo
2024-07-29  5:38                     ` Khatri, Sunil
2024-07-29  5:47                       ` Lazar, Lijo
2024-07-29  8:27                         ` Khatri, Sunil
2024-07-26 13:12 ` [PATCH 1/2] drm/amdgpu: print VCN instance dump for valid instance Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240726124751.3121312-1-sunil.khatri@amd.com \
    --to=sunil.khatri@amd.com \
    --cc=Leo.Liu@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox