Skip to contentSkip to conversation

drm/amdgpu: Move GC v12.1 spm vmid init to hw init

PATCH In review Lijo Lazar 2 participants 3 messages Sep 3 – Sep 7

Subsystems (2)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Move GC v12.1 spm vmid init to hw init

GC reset is not released during sw init and hence it shouldn't be accessed. Move spm vmid programming to hw init phase. This programming may later be overridden with the job's vmid.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +6 -8
index f812d6d81e9c..1aa86b85ce88 100644
@@ -218,6 +218,8 @@ static void gfx_v12_1_xcc_update_perf_clk(struct amdgpu_device *adev,
 static int gfx_v12_1_init_cp_compute_microcode_bo(struct amdgpu_device *adev);
 static void gfx_v12_1_xcc_update_medium_grain_clock_gating(
 	struct amdgpu_device *adev, bool enable, int xcc_id, bool force);
+static void gfx_v12_1_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
+				      struct amdgpu_ring *ring, unsigned vmid);
 
 static void gfx_v12_1_kiq_set_resources(struct amdgpu_ring *kiq_ring,
 					uint64_t queue_mask)
@@ -695,7 +697,7 @@ static void gfx_v12_1_init_rlcg_reg_access_ctrl(struct amdgpu_device *adev)
 static int gfx_v12_1_rlc_init(struct amdgpu_device *adev)
 {
 	const struct cs_section_def *cs_data;
-	int r, i, num_xcc;
+	int r;
 
 	adev->gfx.rlc.cs_data = gfx12_cs_data;
 
@@ -708,13 +710,6 @@ static int gfx_v12_1_rlc_init(struct amdgpu_device *adev)
 			return r;
 	}
 
-	/* init spm vmid with 0xf */
-	num_xcc = NUM_XCC(adev->gfx.xcc_mask);
-	for (i = 0; i < num_xcc; i++) {
-		if (adev->gfx.rlc.funcs->update_spm_vmid)
-			adev->gfx.rlc.funcs->update_spm_vmid(adev, i, NULL, 0xf);
-	}
-
 	return 0;
 }
 
@@ -2005,6 +2000,9 @@ static int gfx_v12_1_xcc_rlc_resume(struct amdgpu_device *adev,
 {
 	int r;
 
+	/* init spm vmid with 0xf */
+	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, 0xf);
+
 	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
 		gfx_v12_1_xcc_init_csb(adev, xcc_id);
 
Signature · 1 line
2.49.0
#1 lore raw

<Ping>

This is also a bug fix.

Fixes ad5f1ee0a9b0 ("drm/amdgpu: Add initial support for gfx v12_1")
Quoted 55 lines · Lijo Lazar

GC reset is not released during sw init and hence it shouldn't be accessed. Move spm vmid programming to hw init phase. This programming may later be overridden with the job's vmid.

---
  drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 14 ++++++--------
  1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +6 -8
index f812d6d81e9c..1aa86b85ce88 100644
@@ -218,6 +218,8 @@ static void gfx_v12_1_xcc_update_perf_clk(struct amdgpu_device *adev,
  static int gfx_v12_1_init_cp_compute_microcode_bo(struct amdgpu_device *adev);
  static void gfx_v12_1_xcc_update_medium_grain_clock_gating(
  	struct amdgpu_device *adev, bool enable, int xcc_id, bool force);
+static void gfx_v12_1_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
+				      struct amdgpu_ring *ring, unsigned vmid);
 
  static void gfx_v12_1_kiq_set_resources(struct amdgpu_ring *kiq_ring,
  					uint64_t queue_mask)
@@ -695,7 +697,7 @@ static void gfx_v12_1_init_rlcg_reg_access_ctrl(struct amdgpu_device *adev)
  static int gfx_v12_1_rlc_init(struct amdgpu_device *adev)
  {
  	const struct cs_section_def *cs_data;
-	int r, i, num_xcc;
+	int r;
 
  	adev->gfx.rlc.cs_data = gfx12_cs_data;
 
@@ -708,13 +710,6 @@ static int gfx_v12_1_rlc_init(struct amdgpu_device *adev)
  			return r;
  	}
 
-	/* init spm vmid with 0xf */
-	num_xcc = NUM_XCC(adev->gfx.xcc_mask);
-	for (i = 0; i < num_xcc; i++) {
-		if (adev->gfx.rlc.funcs->update_spm_vmid)
-			adev->gfx.rlc.funcs->update_spm_vmid(adev, i, NULL, 0xf);
-	}
-
  	return 0;
  }
 
@@ -2005,6 +2000,9 @@ static int gfx_v12_1_xcc_rlc_resume(struct amdgpu_device *adev,
  {
  	int r;
 
+	/* init spm vmid with 0xf */
+	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, 0xf);
+
  	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
  		gfx_v12_1_xcc_init_csb(adev, xcc_id);
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Lijo Lazar

AMD General

Regards,
Hawking
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Thursday, September 3, 2026 1:56 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Ma, Le <[email protected]>
Subject: [PATCH] drm/amdgpu: Move GC v12.1 spm vmid init to hw init

GC reset is not released during sw init and hence it shouldn't be accessed. Move spm vmid programming to hw init phase. This programming may later be overridden with the job's vmid.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +6 -9
index f812d6d81e9c..1aa86b85ce88 100644
@@ -218,6 +218,8 @@ static void gfx_v12_1_xcc_update_perf_clk(struct amdgpu_device *adev,  static int gfx_v12_1_init_cp_compute_microcode_bo(struct amdgpu_device *adev);  static void gfx_v12_1_xcc_update_medium_grain_clock_gating(
        struct amdgpu_device *adev, bool enable, int xcc_id, bool force);
+static void gfx_v12_1_update_spm_vmid(struct amdgpu_device *adev, int xcc_id,
+                                     struct amdgpu_ring *ring, unsigned vmid);
 
 static void gfx_v12_1_kiq_set_resources(struct amdgpu_ring *kiq_ring,
                                        uint64_t queue_mask)
@@ -695,7 +697,7 @@ static void gfx_v12_1_init_rlcg_reg_access_ctrl(struct amdgpu_device *adev)  static int gfx_v12_1_rlc_init(struct amdgpu_device *adev)  {
        const struct cs_section_def *cs_data;
-       int r, i, num_xcc;
+       int r;
 
        adev->gfx.rlc.cs_data = gfx12_cs_data;
 
@@ -708,13 +710,6 @@ static int gfx_v12_1_rlc_init(struct amdgpu_device *adev)
                        return r;
        }
 
-       /* init spm vmid with 0xf */
-       num_xcc = NUM_XCC(adev->gfx.xcc_mask);
-       for (i = 0; i < num_xcc; i++) {
-               if (adev->gfx.rlc.funcs->update_spm_vmid)
-                       adev->gfx.rlc.funcs->update_spm_vmid(adev, i, NULL, 0xf);
-       }
-
        return 0;
 }
 
@@ -2005,6 +2000,9 @@ static int gfx_v12_1_xcc_rlc_resume(struct amdgpu_device *adev,  {
        int r;
 
+       /* init spm vmid with 0xf */
+       gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, 0xf);
+
        if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
                gfx_v12_1_xcc_init_csb(adev, xcc_id);
 
--

2.49.0