On 3/15/19 8:47 AM, Christian König wrote: > Am 15.03.19 um 13:42 schrieb Nicholas Kazlauskas: >> [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. > > Have you considered to use debugfs_create_u32 or debugfs_create_u16 > instead 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 > >> >> Cc: Leo Li <sunpeng.li@xxxxxxx> >> Cc: Harry Wentland <harry.wentland@xxxxxxx> >> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@xxxxxxx> >> --- >> .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 77 ++++++++++++++++++- >> 1 file changed, 75 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c >> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c >> index 4a55cde027cf..1d6bfb84d7cf 100644 >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c >> @@ -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; >> } > _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx