Commit d2e3961a authored by Jesse Zhang's avatar Jesse Zhang Committed by Alex Deucher
Browse files

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: default avatarJesse Zhang <jesse.zhang@amd.com>
Suggested-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarTim Huang <tim.huang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c5c63d9c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2098,6 +2098,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
	amdgpu_debugfs_jpeg_sched_mask_init(adev);
	amdgpu_debugfs_gfx_sched_mask_init(adev);
	amdgpu_debugfs_compute_sched_mask_init(adev);
	amdgpu_debugfs_sdma_sched_mask_init(adev);

	amdgpu_ras_debugfs_create_all(adev);
	amdgpu_rap_debugfs_init(adev);
+70 −0
Original line number Diff line number Diff line
@@ -343,3 +343,73 @@ int amdgpu_sdma_ras_sw_init(struct amdgpu_device *adev)

	return 0;
}

/*
 * debugfs for to enable/disable sdma job submission to specific core.
 */
#if defined(CONFIG_DEBUG_FS)
static int amdgpu_debugfs_sdma_sched_mask_set(void *data, u64 val)
{
	struct amdgpu_device *adev = (struct amdgpu_device *)data;
	u32 i;
	u64 mask = 0;
	struct amdgpu_ring *ring;

	if (!adev)
		return -ENODEV;

	mask = (1 << adev->sdma.num_instances) - 1;
	if ((val & mask) == 0)
		return -EINVAL;

	for (i = 0; i < adev->sdma.num_instances; ++i) {
		ring = &adev->sdma.instance[i].ring;
		if (val & (1 << i))
			ring->sched.ready = true;
		else
			ring->sched.ready = false;
	}
	/* publish sched.ready flag update effective immediately across smp */
	smp_rmb();
	return 0;
}

static int amdgpu_debugfs_sdma_sched_mask_get(void *data, u64 *val)
{
	struct amdgpu_device *adev = (struct amdgpu_device *)data;
	u32 i;
	u64 mask = 0;
	struct amdgpu_ring *ring;

	if (!adev)
		return -ENODEV;
	for (i = 0; i < adev->sdma.num_instances; ++i) {
		ring = &adev->sdma.instance[i].ring;
		if (ring->sched.ready)
			mask |= 1 << i;
	}

	*val = mask;
	return 0;
}

DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_debugfs_sdma_sched_mask_fops,
			 amdgpu_debugfs_sdma_sched_mask_get,
			 amdgpu_debugfs_sdma_sched_mask_set, "%llx\n");

#endif

void amdgpu_debugfs_sdma_sched_mask_init(struct amdgpu_device *adev)
{
#if defined(CONFIG_DEBUG_FS)
	struct drm_minor *minor = adev_to_drm(adev)->primary;
	struct dentry *root = minor->debugfs_root;
	char name[32];

	if (!(adev->sdma.num_instances > 1))
		return;
	sprintf(name, "amdgpu_sdma_sched_mask");
	debugfs_create_file(name, 0600, root, adev,
			    &amdgpu_debugfs_sdma_sched_mask_fops);
#endif
}
+1 −1
Original line number Diff line number Diff line
@@ -175,5 +175,5 @@ int amdgpu_sdma_init_microcode(struct amdgpu_device *adev, u32 instance,
void amdgpu_sdma_destroy_inst_ctx(struct amdgpu_device *adev,
        bool duplicate);
int amdgpu_sdma_ras_sw_init(struct amdgpu_device *adev);

void amdgpu_debugfs_sdma_sched_mask_init(struct amdgpu_device *adev);
#endif