drm/amd/display: Add debugfs entry for amdgpu_dm_visual_confirm
Subsystems (3)
PATCH 1/1 drm/amd/display: Add debugfs entry for amdgpu_dm_visual_confirm
[Why]
DC provides a few visual confirmation debug options that can be dynamically changed at runtime to help debug surface programming issues but we don't have any way to access it from userspace.
[How]
Add the amdgpu_dm_visual_confirm debugfs entry.
It accepts a string containing the DC visual confirm enum value.
--- .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 77 ++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +75 -2
@@ -803,6 +803,65 @@ static ssize_t dtn_log_write(return size; } +/* +* Reads the DC visual confirm debug option value into the given buffer. +* Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_visual_confirm +*/ +static ssize_t visual_confirm_read (struct file *f,char __user *buf, +size_t size,loff_t *pos) +{ +struct amdgpu_device *adev =file_inode (f)->i_private; +struct dc *dc = adev->dm.dc; +size_t to_copy =0 ; +int len; +char tmp[16 ]; + +if (!buf || !size) +return -EINVAL ; + + len =snprintf (tmp,sizeof (tmp),"%d\n" , dc->debug.visual_confirm); +if (len <0 || len >=sizeof (tmp)) +return -EINVAL ; + +if (*pos >= len) +return 0 ; + + to_copy = len - *pos; +if (to_copy > size) +return 0 ; + +if (copy_to_user (buf, tmp + *pos, to_copy)) +return -EFAULT ; + + *pos += to_copy; + +return to_copy; +} + +/* +* Sets the DC visual confirm debug option from the given string. +* Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_visual_confirm +*/ +static ssize_t visual_confirm_write (struct file *f,const char __user *buf, +size_t size,loff_t *pos) +{ +struct amdgpu_device *adev =file_inode (f)->i_private; +struct dc *dc = adev->dm.dc; +int ret; +u16 val; + +if (size ==0 ) +return 0 ; + + ret =kstrtou16_from_user (buf, size,0 , &val); +if (ret) +return ret; + + dc->debug.visual_confirm = val; + +return size; +} +/* * Backlight at this moment. Read only. * As written to display, taking ABM and backlight lut into account.
@@ -850,7 +909,12 @@ int dtn_debugfs_init(struct amdgpu_device *adev) .write = dtn_log_write, .llseek = default_llseek }; - +static const struct file_operations visual_confirm_fops = { + .owner =THIS_MODULE , + .read = visual_confirm_read, + .write = visual_confirm_write, + .llseek = default_llseek + };struct drm_minor *minor = adev->ddev->primary;struct dentry *ent, *root = minor->debugfs_root;int ret;
@@ -867,5 +931,14 @@ int dtn_debugfs_init(struct amdgpu_device *adev) adev, &dtn_log_fops); -return PTR_ERR_OR_ZERO (ent); +if (IS_ERR (ent)) +return PTR_ERR (ent); + + ent =debugfs_create_file ("amdgpu_dm_visual_confirm" ,0644 , root, adev, + &visual_confirm_fops); + +if (IS_ERR (ent)) +return PTR_ERR (ent); + +return 0 ; }
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190315124249.4585-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org
Am 15.03.19 um 13:42 schrieb Nicholas Kazlauskas:
Quoted 8 lines
[Why]
DC provides a few visual confirmation debug options that can be dynamically changed at runtime to help debug surface programming issues but we don't have any way to access it from userspace.[How]
Add theamdgpu_dm_visual_confirmdebugfs entry.
It accepts a string containing the DC visual confirm enum value.
Have you considered to use debugfs_create_u32 or debugfs_create_u16 instead of open coding this?
Christian.
Quoted 98 lines
Cc Leo Li <[email protected]>Cc Harry Wentland <[email protected]>Signed-off-by Nicholas Kazlauskas <[email protected]>--- .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 77 ++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +66
-2@@ -803,6 +803,65 @@ static ssize_t dtn_log_write(return size; } +/* +* Reads the DC visual confirm debug option value into the given buffer. +* Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_visual_confirm +*/ +static ssize_t visual_confirm_read (struct file *f,char __user *buf, +size_t size,loff_t *pos) +{ +struct amdgpu_device *adev =file_inode (f)->i_private; +struct dc *dc = adev->dm.dc; +size_t to_copy =0 ; +int len; +char tmp[16 ]; + +if (!buf || !size) +return -EINVAL ; + + len =snprintf (tmp,sizeof (tmp),"%d\n" , dc->debug.visual_confirm); +if (len <0 || len >=sizeof (tmp)) +return -EINVAL ; + +if (*pos >= len) +return 0 ; + + to_copy = len - *pos; +if (to_copy > size) +return 0 ; + +if (copy_to_user (buf, tmp + *pos, to_copy)) +return -EFAULT ; + + *pos += to_copy; + +return to_copy; +} + +/* +* Sets the DC visual confirm debug option from the given string. +* Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_visual_confirm +*/ +static ssize_t visual_confirm_write (struct file *f,const char __user *buf, +size_t size,loff_t *pos) +{ +struct amdgpu_device *adev =file_inode (f)->i_private; +struct dc *dc = adev->dm.dc; +int ret; +u16 val; + +if (size ==0 ) +return 0 ; + + ret =kstrtou16_from_user (buf, size,0 , &val); +if (ret) +return ret; + + dc->debug.visual_confirm = val; + +return size; +} +/* * Backlight at this moment. Read only. * As written to display, taking ABM and backlight lut into account. @@ -850,7 +909,12 @@ int dtn_debugfs_init(struct amdgpu_device *adev) .write = dtn_log_write, .llseek = default_llseek }; - +static const struct file_operations visual_confirm_fops = { + .owner =THIS_MODULE , + .read = visual_confirm_read, + .write = visual_confirm_write, + .llseek = default_llseek + };struct drm_minor *minor = adev->ddev->primary;struct dentry *ent, *root = minor->debugfs_root;int ret;@@ -867,5 +931,14 @@ int dtn_debugfs_init(struct amdgpu_device *adev) adev, &dtn_log_fops); -return PTR_ERR_OR_ZERO (ent); +if (IS_ERR (ent))
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c int dtn_debugfs_init(struct amdgpu_device *adev) · line 944
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +9
-0+return PTR_ERR (ent); + + ent =debugfs_create_file ("amdgpu_dm_visual_confirm" ,0644 , root, adev, + &visual_confirm_fops); + +if (IS_ERR (ent)) +return PTR_ERR (ent); + +return 0 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 115d7002-8767-1a38-1f9f-1540336a1a1d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 6 lines · Christian König
Am 15.03.19 um 13:42 schrieb Nicholas Kazlauskas:
Quoted 5 lines
[Why]
DC provides a few visual confirmation debug options that can be dynamically changed at runtime to help debug surface programming issues but we don't have any way to access it from userspace.
Quoted 8 lines
Quoted 3 lines
[How]
Add theamdgpu_dm_visual_confirmdebugfs entry.
It accepts a string containing the DC visual confirm enum value.Have you considered to use
debugfs_create_u32ordebugfs_create_u16instead of open coding this?Christian.
I've never actually seen those helpers used before, but from a glance it looks like they'd do what I want.
Thanks for the suggestion!
Nicholas Kazlauskas
Quoted 102 lines
Quoted 102 lines
Cc Leo Li <[email protected]>Cc Harry Wentland <[email protected]>Signed-off-by Nicholas Kazlauskas <[email protected]>---
.../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c| 77 ++++++++++++++++++-1 file changed, 75 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +59
-0@@ -803,6 +803,65 @@ static ssize_t dtn_log_write( return size; } +/* +* Reads the DC visual confirm debug option value into the given buffer. +* Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_visual_confirm +*/ +static ssize_t visual_confirm_read (struct file *f,char __user *buf, + size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = file_inode(f)->i_private; + struct dc *dc = adev->dm.dc; + size_t to_copy = 0; + int len; + char tmp[16]; + + if (!buf || !size) + return -EINVAL; + + len = snprintf(tmp, sizeof(tmp), "%d\n", dc->debug.visual_confirm); + if (len < 0 || len >= sizeof(tmp)) + return -EINVAL; + + if (*pos >= len) + return 0; + + to_copy = len - *pos; + if (to_copy > size) + return 0; + + if (copy_to_user(buf, tmp + *pos, to_copy)) + return -EFAULT; + + *pos += to_copy; + + return to_copy; +} + +/* +* Sets the DC visual confirm debug option from the given string. +* Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_visual_confirm +*/ +static ssize_t visual_confirm_write (struct file *f,const char __user *buf, + size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = file_inode(f)->i_private; + struct dc *dc = adev->dm.dc; + int ret; + u16 val; + + if (size == 0) + return 0; + + ret = kstrtou16_from_user(buf, size, 0, &val); + if (ret) + return ret; + + dc->debug.visual_confirm = val; + + return size; +} + /** Backlight at this moment. Read only. * As written to display, taking ABM and backlight lut into account. @@ -850,7 +909,12 @@ int dtn_debugfs_init(struct amdgpu_device *adev) .write = dtn_log_write,.llseek =
default_llseek
};
-
+ static const structfile_operationsvisual_confirm_fops= { + .owner =THIS_MODULE,
+ .read =visual_confirm_read,
+ .write =visual_confirm_write,
+ .llseek =default_llseek
+ };
structdrm_minor*minor =adev->ddev->primary; struct dentry *ent, *root =minor->debugfs_root; int ret;drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +4
-1@@ -867,5 +931,14 @@ int dtn_debugfs_init(struct amdgpu_device *adev) adev, &dtn_log_fops); - return PTR_ERR_OR_ZERO(ent); + if (IS_ERR(ent)) + return PTR_ERR(ent); + + ent = debugfs_create_file("amdgpu_dm_visual_confirm", 0644, root,
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c int dtn_debugfs_init(struct amdgpu_device *adev) · line 944
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +6
-0adev, + &visual_confirm_fops); + + if (IS_ERR(ent)) + return PTR_ERR(ent); + + return 0; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx