Skip to content

Commit b538734

Browse files
YuanShangalexdeucher
authored andcommitted
drm/amd/amdgpu: Update RLC_SPM_MC_CNT by ring wreg in guest
Submit command of wreg in GFX and COMPUTE ring to update RLC_SPM_MC_CNT in guest machine during runtime. Signed-off-by: YuanShang <YuanShang.Mao@amd.com> Reviewed-by: Emily Deng <Emily.Deng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent b2f26f4 commit b538734

File tree

8 files changed

+23
-13
lines changed

8 files changed

+23
-13
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ struct amdgpu_rlc_funcs {
169169
void (*stop)(struct amdgpu_device *adev);
170170
void (*reset)(struct amdgpu_device *adev);
171171
void (*start)(struct amdgpu_device *adev);
172-
void (*update_spm_vmid)(struct amdgpu_device *adev, unsigned vmid);
172+
void (*update_spm_vmid)(struct amdgpu_device *adev, struct amdgpu_ring *ring, unsigned vmid);
173173
bool (*is_rlcg_access_range)(struct amdgpu_device *adev, uint32_t reg);
174174
};
175175

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,
693693
amdgpu_gmc_emit_pasid_mapping(ring, job->vmid, job->pasid);
694694

695695
if (spm_update_needed && adev->gfx.rlc.funcs->update_spm_vmid)
696-
adev->gfx.rlc.funcs->update_spm_vmid(adev, job->vmid);
696+
adev->gfx.rlc.funcs->update_spm_vmid(adev, ring, job->vmid);
697697

698698
if (!ring->is_mes_queue && ring->funcs->emit_gds_switch &&
699699
gds_switch_needed) {

drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7949,7 +7949,7 @@ static void gfx_v10_0_update_spm_vmid_internal(struct amdgpu_device *adev,
79497949
WREG32_SOC15_NO_KIQ(GC, 0, mmRLC_SPM_MC_CNTL, data);
79507950
}
79517951

7952-
static void gfx_v10_0_update_spm_vmid(struct amdgpu_device *adev, unsigned int vmid)
7952+
static void gfx_v10_0_update_spm_vmid(struct amdgpu_device *adev, struct amdgpu_ring *ring, unsigned int vmid)
79537953
{
79547954
amdgpu_gfx_off_ctrl(adev, false);
79557955

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ static int gfx_v11_0_rlc_init(struct amdgpu_device *adev)
749749

750750
/* init spm vmid with 0xf */
751751
if (adev->gfx.rlc.funcs->update_spm_vmid)
752-
adev->gfx.rlc.funcs->update_spm_vmid(adev, 0xf);
752+
adev->gfx.rlc.funcs->update_spm_vmid(adev, NULL, 0xf);
753753

754754
return 0;
755755
}
@@ -5049,7 +5049,7 @@ static int gfx_v11_0_update_gfx_clock_gating(struct amdgpu_device *adev,
50495049
return 0;
50505050
}
50515051

5052-
static void gfx_v11_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
5052+
static void gfx_v11_0_update_spm_vmid(struct amdgpu_device *adev, struct amdgpu_ring *ring, unsigned vmid)
50535053
{
50545054
u32 data;
50555055

@@ -5063,6 +5063,14 @@ static void gfx_v11_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
50635063
WREG32_SOC15_NO_KIQ(GC, 0, regRLC_SPM_MC_CNTL, data);
50645064

50655065
amdgpu_gfx_off_ctrl(adev, true);
5066+
5067+
if (ring
5068+
&& amdgpu_sriov_is_pp_one_vf(adev)
5069+
&& ((ring->funcs->type == AMDGPU_RING_TYPE_GFX)
5070+
|| (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE))) {
5071+
uint32_t reg = SOC15_REG_OFFSET(GC, 0, regRLC_SPM_MC_CNTL);
5072+
amdgpu_ring_emit_wreg(ring, reg, data);
5073+
}
50665074
}
50675075

50685076
static const struct amdgpu_rlc_funcs gfx_v11_0_rlc_funcs = {
@@ -6126,7 +6134,8 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_gfx = {
61266134
.get_rptr = gfx_v11_0_ring_get_rptr_gfx,
61276135
.get_wptr = gfx_v11_0_ring_get_wptr_gfx,
61286136
.set_wptr = gfx_v11_0_ring_set_wptr_gfx,
6129-
.emit_frame_size = /* totally 242 maximum if 16 IBs */
6137+
.emit_frame_size = /* totally 247 maximum if 16 IBs */
6138+
5 + /* update_spm_vmid */
61306139
5 + /* COND_EXEC */
61316140
9 + /* SET_Q_PREEMPTION_MODE */
61326141
7 + /* PIPELINE_SYNC */
@@ -6176,6 +6185,7 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_compute = {
61766185
.get_wptr = gfx_v11_0_ring_get_wptr_compute,
61776186
.set_wptr = gfx_v11_0_ring_set_wptr_compute,
61786187
.emit_frame_size =
6188+
5 + /* update_spm_vmid */
61796189
20 + /* gfx_v11_0_ring_emit_gds_switch */
61806190
7 + /* gfx_v11_0_ring_emit_hdp_flush */
61816191
5 + /* hdp invalidate */

drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,7 +3274,7 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
32743274

32753275
/* init spm vmid with 0xf */
32763276
if (adev->gfx.rlc.funcs->update_spm_vmid)
3277-
adev->gfx.rlc.funcs->update_spm_vmid(adev, 0xf);
3277+
adev->gfx.rlc.funcs->update_spm_vmid(adev, NULL, 0xf);
32783278

32793279
return 0;
32803280
}
@@ -3500,7 +3500,7 @@ static int gfx_v7_0_rlc_resume(struct amdgpu_device *adev)
35003500
return 0;
35013501
}
35023502

3503-
static void gfx_v7_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
3503+
static void gfx_v7_0_update_spm_vmid(struct amdgpu_device *adev, struct amdgpu_ring *ring, unsigned vmid)
35043504
{
35053505
u32 data;
35063506

drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
12881288

12891289
/* init spm vmid with 0xf */
12901290
if (adev->gfx.rlc.funcs->update_spm_vmid)
1291-
adev->gfx.rlc.funcs->update_spm_vmid(adev, 0xf);
1291+
adev->gfx.rlc.funcs->update_spm_vmid(adev, NULL, 0xf);
12921292

12931293
return 0;
12941294
}
@@ -5579,7 +5579,7 @@ static void gfx_v8_0_unset_safe_mode(struct amdgpu_device *adev, int xcc_id)
55795579
}
55805580
}
55815581

5582-
static void gfx_v8_0_update_spm_vmid(struct amdgpu_device *adev, unsigned vmid)
5582+
static void gfx_v8_0_update_spm_vmid(struct amdgpu_device *adev, struct amdgpu_ring *ring, unsigned vmid)
55835583
{
55845584
u32 data;
55855585

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4894,7 +4894,7 @@ static void gfx_v9_0_update_spm_vmid_internal(struct amdgpu_device *adev,
48944894
WREG32_SOC15(GC, 0, mmRLC_SPM_MC_CNTL, data);
48954895
}
48964896

4897-
static void gfx_v9_0_update_spm_vmid(struct amdgpu_device *adev, unsigned int vmid)
4897+
static void gfx_v9_0_update_spm_vmid(struct amdgpu_device *adev, struct amdgpu_ring *ring, unsigned int vmid)
48984898
{
48994899
amdgpu_gfx_off_ctrl(adev, false);
49004900

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ static int gfx_v9_4_3_rlc_init(struct amdgpu_device *adev)
11741174
{
11751175
/* init spm vmid with 0xf */
11761176
if (adev->gfx.rlc.funcs->update_spm_vmid)
1177-
adev->gfx.rlc.funcs->update_spm_vmid(adev, 0xf);
1177+
adev->gfx.rlc.funcs->update_spm_vmid(adev, NULL, 0xf);
11781178

11791179
return 0;
11801180
}
@@ -1385,7 +1385,7 @@ static int gfx_v9_4_3_rlc_resume(struct amdgpu_device *adev)
13851385
return 0;
13861386
}
13871387

1388-
static void gfx_v9_4_3_update_spm_vmid(struct amdgpu_device *adev,
1388+
static void gfx_v9_4_3_update_spm_vmid(struct amdgpu_device *adev, struct amdgpu_ring *ring,
13891389
unsigned vmid)
13901390
{
13911391
u32 reg, data;

0 commit comments

Comments
 (0)