Skip to content

Commit 928cd77

Browse files
Xiang Liualexdeucher
authored andcommitted
drm/amdgpu/vcn: reset fw_shared when VCPU buffers corrupted on vcn v4.0.3
It is not necessarily corrupted. When there is RAS fatal error, device memory access is blocked. Hence vcpu bo cannot be saved to system memory as in a regular suspend sequence before going for reset. In other full device reset cases, that gets saved and restored during resume. v2: Remove redundant code like vcn_v4_0 did v2: Refine commit message v3: Drop the volatile v3: Refine commit message Signed-off-by: Xiang Liu <[email protected]> Acked-by: Christian König <[email protected]> Reviewed-by: Stanley.Yang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 2f1b135 commit 928cd77

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ static int vcn_v4_0_3_early_init(struct amdgpu_ip_block *ip_block)
123123
return amdgpu_vcn_early_init(adev);
124124
}
125125

126+
static int vcn_v4_0_3_fw_shared_init(struct amdgpu_device *adev, int inst_idx)
127+
{
128+
struct amdgpu_vcn4_fw_shared *fw_shared;
129+
130+
fw_shared = adev->vcn.inst[inst_idx].fw_shared.cpu_addr;
131+
fw_shared->present_flag_0 = cpu_to_le32(AMDGPU_FW_SHARED_FLAG_0_UNIFIED_QUEUE);
132+
fw_shared->sq.is_enabled = 1;
133+
134+
if (amdgpu_vcnfw_log)
135+
amdgpu_vcn_fwlog_init(&adev->vcn.inst[inst_idx]);
136+
137+
return 0;
138+
}
139+
126140
/**
127141
* vcn_v4_0_3_sw_init - sw init for VCN block
128142
*
@@ -155,8 +169,6 @@ static int vcn_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)
155169
return r;
156170

157171
for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
158-
volatile struct amdgpu_vcn4_fw_shared *fw_shared;
159-
160172
vcn_inst = GET_INST(VCN, i);
161173

162174
ring = &adev->vcn.inst[i].ring_enc[0];
@@ -179,12 +191,7 @@ static int vcn_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)
179191
if (r)
180192
return r;
181193

182-
fw_shared = adev->vcn.inst[i].fw_shared.cpu_addr;
183-
fw_shared->present_flag_0 = cpu_to_le32(AMDGPU_FW_SHARED_FLAG_0_UNIFIED_QUEUE);
184-
fw_shared->sq.is_enabled = true;
185-
186-
if (amdgpu_vcnfw_log)
187-
amdgpu_vcn_fwlog_init(&adev->vcn.inst[i]);
194+
vcn_v4_0_3_fw_shared_init(adev, i);
188195
}
189196

190197
/* TODO: Add queue reset mask when FW fully supports it */
@@ -289,6 +296,8 @@ static int vcn_v4_0_3_hw_init(struct amdgpu_ip_block *ip_block)
289296
}
290297
} else {
291298
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
299+
struct amdgpu_vcn4_fw_shared *fw_shared;
300+
292301
vcn_inst = GET_INST(VCN, i);
293302
ring = &adev->vcn.inst[i].ring_enc[0];
294303

@@ -312,6 +321,11 @@ static int vcn_v4_0_3_hw_init(struct amdgpu_ip_block *ip_block)
312321
regVCN_RB1_DB_CTRL);
313322
}
314323

324+
/* Re-init fw_shared when RAS fatal error occurred */
325+
fw_shared = adev->vcn.inst[i].fw_shared.cpu_addr;
326+
if (!fw_shared->sq.is_enabled)
327+
vcn_v4_0_3_fw_shared_init(adev, i);
328+
315329
r = amdgpu_ring_test_helper(ring);
316330
if (r)
317331
return r;

0 commit comments

Comments
 (0)