Skip to content

Commit fb98982

Browse files
Jie1zhangalexdeucher
authored andcommitted
drm/amdgpu: Add sysfs interface for vcn reset mask
Add the sysfs interface for vcn: vcn_reset_mask The interface is read-only and show the resets supported by the IP. For example, full adapter reset (mode1/mode2/BACO/etc), soft reset, queue reset, and pipe reset. V2: the sysfs node returns a text string instead of some flags (Christian) V2: the sysfs node returns a text string instead of some flags (Christian) v3: add a generic helper which takes the ring as parameter and print the strings in the order they are applied (Christian) check amdgpu_gpu_recovery before creating sysfs file itself, and initialize supported_reset_types in IP version files (Lijo) v4: s/sdma/vcn/ in the reset mask setup Acked-by: Christian König <[email protected]> Signed-off-by: Jesse Zhang <[email protected]> Suggested-by: Alex Deucher <[email protected]> Reviewed-by: Tim Huang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 4c28e64 commit fb98982

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,3 +1283,38 @@ int amdgpu_vcn_psp_update_sram(struct amdgpu_device *adev, int inst_idx,
12831283

12841284
return psp_execute_ip_fw_load(&adev->psp, &ucode);
12851285
}
1286+
1287+
static ssize_t amdgpu_get_vcn_reset_mask(struct device *dev,
1288+
struct device_attribute *attr,
1289+
char *buf)
1290+
{
1291+
struct drm_device *ddev = dev_get_drvdata(dev);
1292+
struct amdgpu_device *adev = drm_to_adev(ddev);
1293+
1294+
if (!adev)
1295+
return -ENODEV;
1296+
1297+
return amdgpu_show_reset_mask(buf, adev->vcn.supported_reset);
1298+
}
1299+
1300+
static DEVICE_ATTR(vcn_reset_mask, 0444,
1301+
amdgpu_get_vcn_reset_mask, NULL);
1302+
1303+
int amdgpu_vcn_sysfs_reset_mask_init(struct amdgpu_device *adev)
1304+
{
1305+
int r = 0;
1306+
1307+
if (adev->vcn.num_vcn_inst) {
1308+
r = device_create_file(adev->dev, &dev_attr_vcn_reset_mask);
1309+
if (r)
1310+
return r;
1311+
}
1312+
1313+
return r;
1314+
}
1315+
1316+
void amdgpu_vcn_sysfs_reset_mask_fini(struct amdgpu_device *adev)
1317+
{
1318+
if (adev->vcn.num_vcn_inst)
1319+
device_remove_file(adev->dev, &dev_attr_vcn_reset_mask);
1320+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ struct amdgpu_vcn {
333333

334334
/* IP reg dump */
335335
uint32_t *ip_dump;
336+
337+
uint32_t supported_reset;
336338
};
337339

338340
struct amdgpu_fw_shared_rb_ptrs_struct {
@@ -519,5 +521,7 @@ int amdgpu_vcn_ras_sw_init(struct amdgpu_device *adev);
519521
int amdgpu_vcn_psp_update_sram(struct amdgpu_device *adev, int inst_idx,
520522
enum AMDGPU_UCODE_ID ucode_id);
521523
int amdgpu_vcn_save_vcpu_bo(struct amdgpu_device *adev);
524+
int amdgpu_vcn_sysfs_reset_mask_init(struct amdgpu_device *adev);
525+
void amdgpu_vcn_sysfs_reset_mask_fini(struct amdgpu_device *adev);
522526

523527
#endif

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ static int vcn_v4_0_sw_init(struct amdgpu_ip_block *ip_block)
225225
vcn_v4_0_fw_shared_init(adev, i);
226226
}
227227

228+
/* TODO: Add queue reset mask when FW fully supports it */
229+
adev->vcn.supported_reset =
230+
amdgpu_get_soft_full_reset_mask(&adev->vcn.inst[0].ring_enc[0]);
231+
228232
if (amdgpu_sriov_vf(adev)) {
229233
r = amdgpu_virt_alloc_mm_table(adev);
230234
if (r)
@@ -247,6 +251,10 @@ static int vcn_v4_0_sw_init(struct amdgpu_ip_block *ip_block)
247251
adev->vcn.ip_dump = ptr;
248252
}
249253

254+
r = amdgpu_vcn_sysfs_reset_mask_init(adev);
255+
if (r)
256+
return r;
257+
250258
return 0;
251259
}
252260

@@ -284,6 +292,7 @@ static int vcn_v4_0_sw_fini(struct amdgpu_ip_block *ip_block)
284292
if (r)
285293
return r;
286294

295+
amdgpu_vcn_sysfs_reset_mask_fini(adev);
287296
r = amdgpu_vcn_sw_fini(adev);
288297

289298
kfree(adev->vcn.ip_dump);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ static int vcn_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)
187187
amdgpu_vcn_fwlog_init(&adev->vcn.inst[i]);
188188
}
189189

190+
/* TODO: Add queue reset mask when FW fully supports it */
191+
adev->vcn.supported_reset =
192+
amdgpu_get_soft_full_reset_mask(&adev->vcn.inst[0].ring_enc[0]);
193+
190194
if (amdgpu_sriov_vf(adev)) {
191195
r = amdgpu_virt_alloc_mm_table(adev);
192196
if (r)
@@ -213,6 +217,10 @@ static int vcn_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)
213217
adev->vcn.ip_dump = ptr;
214218
}
215219

220+
r = amdgpu_vcn_sysfs_reset_mask_init(adev);
221+
if (r)
222+
return r;
223+
216224
return 0;
217225
}
218226

@@ -246,6 +254,7 @@ static int vcn_v4_0_3_sw_fini(struct amdgpu_ip_block *ip_block)
246254
if (r)
247255
return r;
248256

257+
amdgpu_vcn_sysfs_reset_mask_fini(adev);
249258
r = amdgpu_vcn_sw_fini(adev);
250259

251260
kfree(adev->vcn.ip_dump);

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ static int vcn_v5_0_0_sw_init(struct amdgpu_ip_block *ip_block)
170170
amdgpu_vcn_fwlog_init(&adev->vcn.inst[i]);
171171
}
172172

173+
/* TODO: Add queue reset mask when FW fully supports it */
174+
adev->vcn.supported_reset =
175+
amdgpu_get_soft_full_reset_mask(&adev->vcn.inst[0].ring_enc[0]);
176+
173177
if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG)
174178
adev->vcn.pause_dpg_mode = vcn_v5_0_0_pause_dpg_mode;
175179

@@ -181,6 +185,11 @@ static int vcn_v5_0_0_sw_init(struct amdgpu_ip_block *ip_block)
181185
} else {
182186
adev->vcn.ip_dump = ptr;
183187
}
188+
189+
r = amdgpu_vcn_sysfs_reset_mask_init(adev);
190+
if (r)
191+
return r;
192+
184193
return 0;
185194
}
186195

@@ -215,6 +224,7 @@ static int vcn_v5_0_0_sw_fini(struct amdgpu_ip_block *ip_block)
215224
if (r)
216225
return r;
217226

227+
amdgpu_vcn_sysfs_reset_mask_fini(adev);
218228
r = amdgpu_vcn_sw_fini(adev);
219229

220230
kfree(adev->vcn.ip_dump);

0 commit comments

Comments
 (0)