drm/amd/amdgpu: Add gfxoff debugfs entry
Subsystems (2)
PATCH 1/1 drm/amd/amdgpu: Add gfxoff debugfs entry
Write a 32-bit value of zero to disable GFXOFF and write a 32-bit value of non-zero to enable GFXOFF.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +56 -0
@@ -842,6 +842,55 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,return result; } +/** +* amdgpu_debugfs_regs_gfxoff_write - Enable/disable GFXOFF +* +* @f: open file handle +* @buf: User buffer to write data from +* @size: Number of bytes to write +* @pos: Offset to seek to +* +* Write a 32-bit zero to disable or a 32-bit non-zero to enable +*/ +static ssize_t amdgpu_debugfs_gfxoff_write (struct file *f,const char __user *buf, +size_t size,loff_t *pos) +{ +struct amdgpu_device *adev =file_inode (f)->i_private; +ssize_t result =0 ; +int r; + +if (size &0x3 || *pos &0x3 ) +return -EINVAL ; + + r =pm_runtime_get_sync (adev->ddev->dev); +if (r <0 ) +return r; + +while (size) { +uint32_t value; + + r =get_user (value, (uint32_t *)buf); +if (r) { +pm_runtime_mark_last_busy (adev->ddev->dev); +pm_runtime_put_autosuspend (adev->ddev->dev); +return r; + } + +amdgpu_gfx_off_ctrl (adev, value ? true : false); + + result +=4 ; + buf +=4 ; + *pos +=4 ; + size -=4 ; + } + +pm_runtime_mark_last_busy (adev->ddev->dev); +pm_runtime_put_autosuspend (adev->ddev->dev); + +return result; +} + +static const struct file_operations amdgpu_debugfs_regs_fops = { .owner =THIS_MODULE , .read = amdgpu_debugfs_regs_read,
@@ -890,6 +939,11 @@ static const struct file_operations amdgpu_debugfs_gpr_fops = { .llseek = default_llseek }; +static const struct file_operations amdgpu_debugfs_gfxoff_fops = { + .owner =THIS_MODULE , + .write = amdgpu_debugfs_gfxoff_write, +}; +static const struct file_operations *debugfs_regs[] = { &amdgpu_debugfs_regs_fops, &amdgpu_debugfs_regs_didt_fops,
@@ -899,6 +953,7 @@ static const struct file_operations *debugfs_regs[] = { &amdgpu_debugfs_sensors_fops, &amdgpu_debugfs_wave_fops, &amdgpu_debugfs_gpr_fops, + &amdgpu_debugfs_gfxoff_fops, }; static const char *debugfs_regs_names[] = {
@@ -910,6 +965,7 @@ static const char *debugfs_regs_names[] = {"amdgpu_sensors" ,"amdgpu_wave" ,"amdgpu_gpr" , + "amdgpu_gfxoff", };/**
Signature · 6 lines
2.24.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 28 lines · Tom St Denis
Write a 32-bit value of zero to disable GFXOFF and write a 32-bit value of non-zero to enable GFXOFF.
Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +11
-0@@ -842,6 +842,55 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,return result; } +/** +* amdgpu_debugfs_regs_gfxoff_write - Enable/disable GFXOFF +* +* @f: open file handle +* @buf: User buffer to write data from +* @size: Number of bytes to write +* @pos: Offset to seek to +* +* Write a 32-bit zero to disable or a 32-bit non-zero to enable +*/ +static ssize_t amdgpu_debugfs_gfxoff_write(struct file *f, const char __user *buf,
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, · line 865
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +10
-0+ size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = file_inode(f)->i_private; +ssize_t result =0 ; +int r; + +if (size &0x3 || *pos &0x3 ) +return -EINVAL ; + + r =pm_runtime_get_sync (adev->ddev->dev);
Not really directly related to this patch, but If you are using umr for debugging, we should probably disable runtime pm, otherwise the entire GPU may be powered down between accesses. There is already an interface to do that via the core kernel power subsystem in sysfs. E.g.,/sys/class/drm/card0/device/power/control /sys/class/drm/card0/device/power/runtime_status
Something else to look at for umr.
We don't store the state for when we dynamically turn it off like this so if we get a GPU reset or a power management event (runtime pm or S3), GFXOFF will be re-enabled at that point. This is just for debugging though so:
Alex
Quoted 62 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +35
-1+if (r <0 ) +return r; + +while (size) { +uint32_t value; + + r =get_user (value, (uint32_t *)buf); +if (r) { +pm_runtime_mark_last_busy (adev->ddev->dev); +pm_runtime_put_autosuspend (adev->ddev->dev); +return r; + } + +amdgpu_gfx_off_ctrl (adev, value ? true : false); + + result +=4 ; + buf +=4 ; + *pos +=4 ; + size -=4 ; + } + +pm_runtime_mark_last_busy (adev->ddev->dev); +pm_runtime_put_autosuspend (adev->ddev->dev); + +return result; +} + +static const struct file_operations amdgpu_debugfs_regs_fops = { .owner =THIS_MODULE , .read = amdgpu_debugfs_regs_read,@@ -890,6 +939,11 @@ static const struct file_operations amdgpu_debugfs_gpr_fops = { .llseek = default_llseek }; +static const struct file_operations amdgpu_debugfs_gfxoff_fops = { + .owner =THIS_MODULE , + .write = amdgpu_debugfs_gfxoff_write, +}; +static const struct file_operations *debugfs_regs[] = { &amdgpu_debugfs_regs_fops, &amdgpu_debugfs_regs_didt_fops,@@ -899,6 +953,7 @@ static const struct file_operations *debugfs_regs[] = { &amdgpu_debugfs_sensors_fops, &amdgpu_debugfs_wave_fops, &amdgpu_debugfs_gpr_fops, + &amdgpu_debugfs_gfxoff_fops, }; static const char *debugfs_regs_names[] = {@@ -910,6 +965,7 @@ static const char *debugfs_regs_names[] = {"amdgpu_sensors" ,"amdgpu_wave" ,"amdgpu_gpr" , + "amdgpu_gfxoff", };/** -- 2.24.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 38 lines · Alex Deucher
Quoted 27 lines · Tom St Denis
Write a 32-bit value of zero to disable GFXOFF and write a 32-bit value of non-zero to enable GFXOFF.
Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +11
-0@@ -842,6 +842,55 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,return result; } +/** +* amdgpu_debugfs_regs_gfxoff_write - Enable/disable GFXOFF +* +* @f: open file handle +* @buf: User buffer to write data from +* @size: Number of bytes to write +* @pos: Offset to seek to +* +* Write a 32-bit zero to disable or a 32-bit non-zero to enable +*/ +static ssize_t amdgpu_debugfs_gfxoff_write(struct file *f, const char __user *buf,drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, · line 865
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +10
-0+ size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = file_inode(f)->i_private; +ssize_t result =0 ; +int r; + +if (size &0x3 || *pos &0x3 ) +return -EINVAL ; + + r =pm_runtime_get_sync (adev->ddev->dev);
Quoted 8 lines
Not really directly related to this patch, but If you are using umr for debugging, we should probably disable runtime pm, otherwise the entire GPU may be powered down between accesses. There is already an interface to do that via the core kernel power subsystem in sysfs. E.g.,
/sys/class/drm/card0/device/power/control/sys/class/drm/card0/device/power/runtime_status
Something else to look at for umr.
We ran into something related to this for UVD/VCE access back in the day. When powered down the MMIO registers are mirrored and accessible but while in transition they are not. So we added a PG flag to the offset in the debugfs entry to flag when we need to take the pm mutex or not.
Quoted 6 lines
We don't store the state for when we dynamically turn it off like this so if we get a GPU reset or a power management event (runtime pm or S3), GFXOFF will be re-enabled at that point. This is just for debugging though so:
Acked-by Alex Deucher <[email protected]>
Good to note. Can I get a R-b from someone though so I can push this out?
Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 60 lines · Tom St Denis
Quoted 38 lines · Alex Deucher
Quoted 27 lines · Tom St Denis
Write a 32-bit value of zero to disable GFXOFF and write a 32-bit value of non-zero to enable GFXOFF.
Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +11
-0@@ -842,6 +842,55 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,return result; } +/** +* amdgpu_debugfs_regs_gfxoff_write - Enable/disable GFXOFF +* +* @f: open file handle +* @buf: User buffer to write data from +* @size: Number of bytes to write +* @pos: Offset to seek to +* +* Write a 32-bit zero to disable or a 32-bit non-zero to enable +*/ +static ssize_t amdgpu_debugfs_gfxoff_write(struct file *f, const char __user *buf,drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, · line 865
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +10
-0+ size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = file_inode(f)->i_private; +ssize_t result =0 ; +int r; + +if (size &0x3 || *pos &0x3 ) +return -EINVAL ; + + r =pm_runtime_get_sync (adev->ddev->dev);Quoted 8 lines
Not really directly related to this patch, but If you are using umr for debugging, we should probably disable runtime pm, otherwise the entire GPU may be powered down between accesses. There is already an interface to do that via the core kernel power subsystem in sysfs. E.g.,
/sys/class/drm/card0/device/power/control/sys/class/drm/card0/device/power/runtime_status
Something else to look at for umr.We ran into something related to this for UVD/VCE access back in the day. When powered down the MMIO registers are mirrored and accessible but while in transition they are not. So we added a PG flag to the offset in the debugfs entry to flag when we need to take the pm mutex or not.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
We don't store the state for when we dynamically turn it off like this so if we get a GPU reset or a power management event (runtime pm or S3), GFXOFF will be re-enabled at that point. This is just for debugging though so:
Acked-by Alex Deucher <[email protected]>Good to note. Can I get a R-b from someone though so I can push this out?
You can convert mine to an RB if you prefer.
Alex
Quoted 4 lines
Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx