Skip to content

Commit d2e3961

Browse files
Jie1zhangalexdeucher
authored andcommitted
drm/amdgpu: add amdgpu_sdma_sched_mask debugfs
Userspace wants to run jobs on a specific sdma ring for verification purposes. This debugfs entry helps to disable or enable submitting jobs to a specific ring. This entry is populated only if there are at least two or more cores in the sdma ip. 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 c5c63d9 commit d2e3961

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
20982098
amdgpu_debugfs_jpeg_sched_mask_init(adev);
20992099
amdgpu_debugfs_gfx_sched_mask_init(adev);
21002100
amdgpu_debugfs_compute_sched_mask_init(adev);
2101+
amdgpu_debugfs_sdma_sched_mask_init(adev);
21012102

21022103
amdgpu_ras_debugfs_create_all(adev);
21032104
amdgpu_rap_debugfs_init(adev);

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,73 @@ int amdgpu_sdma_ras_sw_init(struct amdgpu_device *adev)
343343

344344
return 0;
345345
}
346+
347+
/*
348+
* debugfs for to enable/disable sdma job submission to specific core.
349+
*/
350+
#if defined(CONFIG_DEBUG_FS)
351+
static int amdgpu_debugfs_sdma_sched_mask_set(void *data, u64 val)
352+
{
353+
struct amdgpu_device *adev = (struct amdgpu_device *)data;
354+
u32 i;
355+
u64 mask = 0;
356+
struct amdgpu_ring *ring;
357+
358+
if (!adev)
359+
return -ENODEV;
360+
361+
mask = (1 << adev->sdma.num_instances) - 1;
362+
if ((val & mask) == 0)
363+
return -EINVAL;
364+
365+
for (i = 0; i < adev->sdma.num_instances; ++i) {
366+
ring = &adev->sdma.instance[i].ring;
367+
if (val & (1 << i))
368+
ring->sched.ready = true;
369+
else
370+
ring->sched.ready = false;
371+
}
372+
/* publish sched.ready flag update effective immediately across smp */
373+
smp_rmb();
374+
return 0;
375+
}
376+
377+
static int amdgpu_debugfs_sdma_sched_mask_get(void *data, u64 *val)
378+
{
379+
struct amdgpu_device *adev = (struct amdgpu_device *)data;
380+
u32 i;
381+
u64 mask = 0;
382+
struct amdgpu_ring *ring;
383+
384+
if (!adev)
385+
return -ENODEV;
386+
for (i = 0; i < adev->sdma.num_instances; ++i) {
387+
ring = &adev->sdma.instance[i].ring;
388+
if (ring->sched.ready)
389+
mask |= 1 << i;
390+
}
391+
392+
*val = mask;
393+
return 0;
394+
}
395+
396+
DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_debugfs_sdma_sched_mask_fops,
397+
amdgpu_debugfs_sdma_sched_mask_get,
398+
amdgpu_debugfs_sdma_sched_mask_set, "%llx\n");
399+
400+
#endif
401+
402+
void amdgpu_debugfs_sdma_sched_mask_init(struct amdgpu_device *adev)
403+
{
404+
#if defined(CONFIG_DEBUG_FS)
405+
struct drm_minor *minor = adev_to_drm(adev)->primary;
406+
struct dentry *root = minor->debugfs_root;
407+
char name[32];
408+
409+
if (!(adev->sdma.num_instances > 1))
410+
return;
411+
sprintf(name, "amdgpu_sdma_sched_mask");
412+
debugfs_create_file(name, 0600, root, adev,
413+
&amdgpu_debugfs_sdma_sched_mask_fops);
414+
#endif
415+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,5 @@ int amdgpu_sdma_init_microcode(struct amdgpu_device *adev, u32 instance,
175175
void amdgpu_sdma_destroy_inst_ctx(struct amdgpu_device *adev,
176176
bool duplicate);
177177
int amdgpu_sdma_ras_sw_init(struct amdgpu_device *adev);
178-
178+
void amdgpu_debugfs_sdma_sched_mask_init(struct amdgpu_device *adev);
179179
#endif

0 commit comments

Comments
 (0)