drm/amdgpu: use IS_ERR for debugfs APIs
Subsystems (2)
PATCH 1/2 drm/amdgpu: use IS_ERR for debugfs APIs
debugfs APIs returns encoded error so useIS_ERR for checking return value.
References: https://gitlab.freedesktop.org/drm/amd/-/issues/1686
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2 -4
@@ -1696,18 +1696,16 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)struct dentry *ent;int r, i; - - ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt); -if (!ent) { +if (IS_ERR (ent)) {DRM_ERROR ("unable to create amdgpu_preempt_ib debugsfs file\n" );return -EIO ; } ent =debugfs_create_file ("amdgpu_force_sclk" ,0200 , root, adev, &fops_sclk_set); -if (!ent) { +if (IS_ERR (ent)) {DRM_ERROR ("unable to create amdgpu_set_sclk debugsfs file\n" );return -EIO ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 -1
@@ -428,7 +428,7 @@ int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, ent =debugfs_create_file (name,S_IFREG |S_IRUGO , root, ring, &amdgpu_debugfs_ring_fops); -if (!ent) +if (IS_ERR (ent))return -ENOMEM ;i_size_write (ent->d_inode, ring->ring_size +12 );
Signature · 1 line
2.32.0
PATCH 2/2 drm/amdgpu: cleanup debugfs for amdgpu rings
Use debugfs_create_file_size API for creating ring debugfs file, also cleanup surrounding code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16 +++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +------- 3 files changed, 7 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -3
@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)if (!ring)continue ; -if (amdgpu_debugfs_ring_init (adev, ring)) { -DRM_ERROR ("Failed to register debugfs file for rings !\n" ); - } +amdgpu_debugfs_ring_init (adev, ring); }amdgpu_ras_debugfs_create_all (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +5 -11
@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = {#endif -int amdgpu_debugfs_ring_init (struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init (struct amdgpu_device *adev,struct amdgpu_ring *ring) {#if defined(CONFIG_DEBUG_FS )struct drm_minor *minor =adev_to_drm (adev)->primary; -struct dentry *ent, *root = minor->debugfs_root; +struct dentry *root = minor->debugfs_root;char name[32 ];sprintf (name,"amdgpu_ring_%s" , ring->name); - ent =debugfs_create_file (name, -S_IFREG |S_IRUGO , root, - ring, &amdgpu_debugfs_ring_fops); -if (IS_ERR (ent)) -return -ENOMEM ; - -i_size_write (ent->d_inode, ring->ring_size +12 ); - ring->ent = ent; +debugfs_create_file_size (name,S_IFREG |S_IRUGO , root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size +12 );#endif -return 0 ; }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1 -7
@@ -253,10 +253,6 @@ struct amdgpu_ring {bool has_compute_vm_bug;bool no_scheduler;int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) -struct dentry *ent; -#endif };#define amdgpu_ring_parse_cs (r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring,int amdgpu_ring_test_helper (struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init (struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init (struct amdgpu_device *adev,struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); -#endif
Signature · 1 line
2.32.0
Re: [PATCH 2/2] drm/amdgpu: cleanup debugfs for amdgpu rings
Quoted 40 lines · Nirmoy Das
Use
debugfs_create_file_sizeAPI for creating ring debugfs file, also cleanup surrounding code.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16 +++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +------- 3 files changed, 7 insertions(+), 21 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-3@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)if (!ring)continue ; -if (amdgpu_debugfs_ring_init (adev, ring)) { -DRM_ERROR ("Failed to register debugfs file for rings !\n" ); - } +amdgpu_debugfs_ring_init (adev, ring); }amdgpu_ras_debugfs_create_all (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-2@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = {#endif -int amdgpu_debugfs_ring_init (struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init (struct amdgpu_device *adev,struct amdgpu_ring *ring) {#if defined(CONFIG_DEBUG_FS )struct drm_minor *minor =adev_to_drm (adev)->primary; -struct dentry *ent, *root = minor->debugfs_root;
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static const struct file_operations amdgpu_debugfs_ring_fops = { · line 432
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-5+struct dentry *root = minor->debugfs_root;char name[32 ];sprintf (name,"amdgpu_ring_%s" , ring->name); - ent =debugfs_create_file (name, -S_IFREG |S_IRUGO , root, - ring, &amdgpu_debugfs_ring_fops); -if (IS_ERR (ent)) -return -ENOMEM ;
Why are we doing this ? Why to make it void from int ?
- Shashank
Quoted 37 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-4- -i_size_write (ent->d_inode, ring->ring_size +12 ); - ring->ent = ent; +debugfs_create_file_size (name,S_IFREG |S_IRUGO , root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size +12 );#endif -return 0 ; }/** drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-7@@ -253,10 +253,6 @@ struct amdgpu_ring {bool has_compute_vm_bug;bool no_scheduler;int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) -struct dentry *ent; -#endif };#define amdgpu_ring_parse_cs (r, p, ib) ((r)->funcs->parse_cs((p), (ib)))@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring,int amdgpu_ring_test_helper (struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init (struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init (struct amdgpu_device *adev,struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); -#endif
Re: [PATCH 2/2] drm/amdgpu: cleanup debugfs for amdgpu rings
Quoted 43 lines · Shashank
Quoted 40 lines · Nirmoy Das
Use
debugfs_create_file_sizeAPI for creating ring debugfs file, also cleanup surrounding code.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16 +++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +-------3 files changed, 7 insertions(+), 21 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) if (!ring) continue; - if (amdgpu_debugfs_ring_init(adev, ring)) { - DRM_ERROR("Failed to register debugfs file for rings !\n"); - } + amdgpu_debugfs_ring_init(adev, ring); } amdgpu_ras_debugfs_create_all(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-1@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = { #endif -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring) { #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = adev_to_drm(adev)->primary; - struct dentry *ent, *root = minor->debugfs_root; + struct dentry *root = minor->debugfs_root; char name[32];
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static const struct file_operations amdgpu_debugfs_ring_fops = { · line 432
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-4sprintf(name, "amdgpu_ring_%s", ring->name); - ent = debugfs_create_file(name, - S_IFREG | S_IRUGO, root, - ring, &amdgpu_debugfs_ring_fops); - if (IS_ERR(ent)) - return -ENOMEM;Why are we doing this ? Why to make it void from int ?
We tend to ignore debugfs return values as those are not serious errors. This to sync with rest of our
debugfs calls.
Regards,
Nirmoy
Quoted 38 lines
- Shashank
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-4- - i_size_write(ent->d_inode, ring->ring_size + 12); - ring->ent = ent; + debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size + 12); #endif - return 0; } /**drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-6@@ -253,10 +253,6 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) - struct dentry *ent; -#endif }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, int amdgpu_ring_test_helper(struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); - #endif
Re: [PATCH 2/2] drm/amdgpu: cleanup debugfs for amdgpu rings
Quoted 55 lines · Nirmoy
Quoted 43 lines · Shashank
Quoted 40 lines · Nirmoy Das
Use
debugfs_create_file_sizeAPI for creating ring debugfs file, also cleanup surrounding code.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16 +++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +-------3 files changed, 7 insertions(+), 21 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) if (!ring) continue; - if (amdgpu_debugfs_ring_init(adev, ring)) { - DRM_ERROR("Failed to register debugfs file for rings !\n"); - } + amdgpu_debugfs_ring_init(adev, ring); } amdgpu_ras_debugfs_create_all(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-1@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = { #endif -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring) { #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = adev_to_drm(adev)->primary; - struct dentry *ent, *root = minor->debugfs_root; + struct dentry *root = minor->debugfs_root; char name[32];Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static const struct file_operations amdgpu_debugfs_ring_fops = { · line 432
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-4sprintf(name, "amdgpu_ring_%s", ring->name); - ent = debugfs_create_file(name, - S_IFREG | S_IRUGO, root, - ring, &amdgpu_debugfs_ring_fops); - if (IS_ERR(ent)) - return -ENOMEM;Why are we doing this ? Why to make it void from int ?
Quoted 9 lines
We tend to ignore debugfs return values as those are not serious errors. This to sync with rest of our
debugfs calls.
Regards,
Nirmoy
I am not suere if completely removing the provision of return value is a good way of doing it, we can always ignore it at the caller side, isn't it ?
- Shashank
Quoted 38 lines
Quoted 38 lines
- Shashank
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-4- - i_size_write(ent->d_inode, ring->ring_size + 12); - ring->ent = ent; + debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size + 12); #endif - return 0; } /**drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-6@@ -253,10 +253,6 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) - struct dentry *ent; -#endif }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, int amdgpu_ring_test_helper(struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); - #endif
Re: [PATCH 2/2] drm/amdgpu: cleanup debugfs for amdgpu rings
Quoted 64 lines · Shashank
Quoted 61 lines · Nirmoy
Quoted 44 lines · Shashank
Quoted 41 lines · Nirmoy Das
Use
debugfs_create_file_sizeAPI for creating ring debugfs file, also cleanup surrounding code.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16 +++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +-------3 files changed, 7 insertions(+), 21 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) if (!ring) continue; - if (amdgpu_debugfs_ring_init(adev, ring)) { - DRM_ERROR("Failed to register debugfs file for rings !\n"); - } + amdgpu_debugfs_ring_init(adev, ring); }
amdgpu_ras_debugfs_create_all(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-1@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = { #endif -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring) { #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = adev_to_drm(adev)->primary; - struct dentry *ent, *root = minor->debugfs_root; + struct dentry *root = minor->debugfs_root; char name[32];Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static const struct file_operations amdgpu_debugfs_ring_fops = { · line 432
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-4sprintf(name, "amdgpu_ring_%s", ring->name); - ent = debugfs_create_file(name, - S_IFREG | S_IRUGO, root, - ring, &amdgpu_debugfs_ring_fops); - if (IS_ERR(ent)) - return -ENOMEM;Why are we doing this ? Why to make it void from int ?
We tend to ignore debugfs return values as those are not serious errors. This to sync with rest of our
debugfs calls.
Quoted 7 lines
Quoted 4 lines
Regards,
Nirmoy
I am not suere if completely removing the provision of return value is a good way of doing it, we can always ignore it at the caller side, isn't it ?
Yes, we are currently throwing an error msg and ignoring it. I don't have a strong opinion regarding this, I will send a v2 restoring previous behavior.
Thanks,
Nirmoy
Quoted 41 lines
- Shashank
Quoted 38 lines
Quoted 38 lines
- Shashank
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-4- - i_size_write(ent->d_inode, ring->ring_size + 12); - ring->ent = ent; + debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size + 12); #endif - return 0; } /**drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-6@@ -253,10 +253,6 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) - struct dentry *ent; -#endif }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, int amdgpu_ring_test_helper(struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); - #endif
Re: [PATCH 2/2] drm/amdgpu: cleanup debugfs for amdgpu rings
Hi Shashank,
Quoted 66 lines · Nirmoy
Quoted 64 lines · Shashank
Quoted 61 lines · Nirmoy
Quoted 44 lines · Shashank
Quoted 41 lines · Nirmoy Das
Use
debugfs_create_file_sizeAPI for creating ring debugfs file, also cleanup surrounding code.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16 +++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +-------3 files changed, 7 insertions(+), 21 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) if (!ring) continue; - if (amdgpu_debugfs_ring_init(adev, ring)) { - DRM_ERROR("Failed to register debugfs file for rings !\n"); - } + amdgpu_debugfs_ring_init(adev, ring); }
amdgpu_ras_debugfs_create_all(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-1@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = { #endif -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring) { #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = adev_to_drm(adev)->primary; - struct dentry *ent, *root = minor->debugfs_root; + struct dentry *root = minor->debugfs_root; char name[32];Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static const struct file_operations amdgpu_debugfs_ring_fops = { · line 432
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-4sprintf(name, "amdgpu_ring_%s", ring->name); - ent = debugfs_create_file(name, - S_IFREG | S_IRUGO, root, - ring, &amdgpu_debugfs_ring_fops); - if (IS_ERR(ent)) - return -ENOMEM;Why are we doing this ? Why to make it void from int ?
We tend to ignore debugfs return values as those are not serious errors. This to sync with rest of our
debugfs calls.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Regards,
Nirmoy
I am not suere if completely removing the provision of return value is a good way of doing it, we can always ignore it at the caller side, isn't it ?
I just realized while making the change debugfs_create_file_size() is void return, so we don't have anything useful to return in amdgpu_debugfs_ring_init()
Regards,
Nirmoy
Quoted 51 lines
Yes, we are currently throwing an error msg and ignoring it. I don't have a strong opinion regarding this, I will send a v2 restoring previous behavior.
Thanks,
Nirmoy
Quoted 41 lines
- Shashank
Quoted 38 lines
Quoted 38 lines
- Shashank
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-4- - i_size_write(ent->d_inode, ring->ring_size + 12); - ring->ent = ent; + debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size + 12); #endif - return 0; } /**drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-6@@ -253,10 +253,6 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) - struct dentry *ent; -#endif }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, int amdgpu_ring_test_helper(struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); - #endif
Re: [PATCH 2/2] drm/amdgpu: cleanup debugfs for amdgpu rings
Quoted 75 lines · Nirmoy
Hi Shashank,
Quoted 72 lines · Nirmoy
Quoted 70 lines · Shashank
Quoted 65 lines · Nirmoy
Quoted 44 lines · Shashank
Quoted 41 lines · Nirmoy Das
Use
debugfs_create_file_sizeAPI for creating ring debugfs file, also cleanup surrounding code.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16 +++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +-------3 files changed, 7 insertions(+), 21 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) if (!ring) continue; - if (amdgpu_debugfs_ring_init(adev, ring)) { - DRM_ERROR("Failed to register debugfs file for rings !\n"); - } + amdgpu_debugfs_ring_init(adev, ring); }
amdgpu_ras_debugfs_create_all(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-1@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = { #endif -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring) { #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = adev_to_drm(adev)->primary; - struct dentry *ent, *root = minor->debugfs_root; + struct dentry *root = minor->debugfs_root; char name[32];Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static const struct file_operations amdgpu_debugfs_ring_fops = { · line 432
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-4sprintf(name, "amdgpu_ring_%s", ring->name); - ent = debugfs_create_file(name, - S_IFREG | S_IRUGO, root, - ring, &amdgpu_debugfs_ring_fops); - if (IS_ERR(ent)) - return -ENOMEM;Why are we doing this ? Why to make it void from int ?
We tend to ignore debugfs return values as those are not serious errors. This to sync with rest of our
debugfs calls.
Regards,
Nirmoy
Quoted 7 lines
Quoted 1 line
Quoted 1 line
I am not suere if completely removing the provision of return value is a good way of doing it, we can always ignore it at the caller side, isn't it ?
I just realized while making the change
debugfs_create_file_size()is void return, so we don't have anything useful to return inamdgpu_debugfs_ring_init()
Ah, it makes better sense now. Probably just a mention in the body of the message that we are moving from debugfs_create_file() to debugfs_create_file_size(), will make this change of return type more logical.
- Shashank
Quoted 56 lines
Regards,
Nirmoy
Quoted 51 lines
Yes, we are currently throwing an error msg and ignoring it. I don't have a strong opinion regarding this, I will send a v2 restoring previous behavior.
Thanks,
Nirmoy
Quoted 41 lines
- Shashank
Quoted 38 lines
Quoted 38 lines
- Shashank
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-4- - i_size_write(ent->d_inode, ring->ring_size + 12); - ring->ent = ent; + debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size + 12); #endif - return 0; } /**drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-6@@ -253,10 +253,6 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) - struct dentry *ent; -#endif }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, int amdgpu_ring_test_helper(struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); - #endif
Re: [PATCH 2/2] drm/amdgpu: cleanup debugfs for amdgpu rings
Quoted 82 lines · Shashank
Quoted 79 lines · Nirmoy
Hi Shashank,
Quoted 73 lines · Nirmoy
Quoted 71 lines · Shashank
Quoted 56 lines · Nirmoy
Quoted 44 lines · Shashank
Quoted 41 lines · Nirmoy Das
Use
debugfs_create_file_sizeAPI for creating ring debugfs file, also cleanup surrounding code.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16 +++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +-------3 files changed, 7 insertions(+), 21 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) if (!ring) continue; - if (amdgpu_debugfs_ring_init(adev, ring)) { - DRM_ERROR("Failed to register debugfs file for rings !\n"); - } + amdgpu_debugfs_ring_init(adev, ring); }
amdgpu_ras_debugfs_create_all(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-1@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = { #endif -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring) { #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = adev_to_drm(adev)->primary; - struct dentry *ent, *root = minor->debugfs_root; + struct dentry *root = minor->debugfs_root; char name[32];Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static const struct file_operations · line 429
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-4sprintf(name, "amdgpu_ring_%s", ring->name); - ent = debugfs_create_file(name, - S_IFREG | S_IRUGO, root, - ring, &amdgpu_debugfs_ring_fops); - if (IS_ERR(ent)) - return -ENOMEM;Why are we doing this ? Why to make it void from int ?
Quoted 9 lines
We tend to ignore debugfs return values as those are not serious errors. This to sync with rest of our
debugfs calls.
Regards,
Nirmoy
I am not suere if completely removing the provision of return value is a good way of doing it, we can always ignore it at the caller side, isn't it ?
Quoted 5 lines
Quoted 3 lines
I just realized while making the change
debugfs_create_file_size()is void return, so we don't have anything useful to return inamdgpu_debugfs_ring_init()Ah, it makes better sense now. Probably just a mention in the body of the message that we are moving from
debugfs_create_file()todebugfs_create_file_size(), will make this change of return type more logical.
Yes, I have that "Use debugfs_create_file_size API for creating ring debugfs file,..."
Nirmoy
Quoted 59 lines
- Shashank
Quoted 56 lines
Regards,
Nirmoy
Quoted 51 lines
Yes, we are currently throwing an error msg and ignoring it. I don't have a strong opinion regarding this, I will send a v2 restoring previous behavior.
Thanks,
Nirmoy
Quoted 41 lines
- Shashank
Quoted 38 lines
Quoted 38 lines
- Shashank
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-4- - i_size_write(ent->d_inode, ring->ring_size + 12); - ring->ent = ent; + debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size + 12); #endif - return 0; } /**drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-6@@ -253,10 +253,6 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) - struct dentry *ent; -#endif }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, int amdgpu_ring_test_helper(struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); - #endif
Sharma, Shashank
Reviewed-byRe: [PATCH 2/2] drm/amdgpu: cleanup debugfs for amdgpu rings
Quoted 84 lines · Nirmoy
Quoted 82 lines · Shashank
Quoted 79 lines · Nirmoy
Hi Shashank,
Quoted 73 lines · Nirmoy
Quoted 71 lines · Shashank
Quoted 56 lines · Nirmoy
Quoted 44 lines · Shashank
Quoted 41 lines · Nirmoy Das
Use
debugfs_create_file_sizeAPI for creating ring debugfs file, also cleanup surrounding code.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16 +++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +-------3 files changed, 7 insertions(+), 21 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) if (!ring) continue; - if (amdgpu_debugfs_ring_init(adev, ring)) { - DRM_ERROR("Failed to register debugfs file for rings !\n"); - } + amdgpu_debugfs_ring_init(adev, ring); }
amdgpu_ras_debugfs_create_all(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-1@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = { #endif -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring) { #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = adev_to_drm(adev)->primary; - struct dentry *ent, *root = minor->debugfs_root; + struct dentry *root = minor->debugfs_root; char name[32];Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static const struct file_operations · line 429
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-4sprintf(name, "amdgpu_ring_%s", ring->name); - ent = debugfs_create_file(name, - S_IFREG | S_IRUGO, root, - ring, &amdgpu_debugfs_ring_fops); - if (IS_ERR(ent)) - return -ENOMEM;Why are we doing this ? Why to make it void from int ?
Quoted 9 lines
We tend to ignore debugfs return values as those are not serious errors. This to sync with rest of our
debugfs calls.
Regards,
Nirmoy
I am not suere if completely removing the provision of return value is a good way of doing it, we can always ignore it at the caller side, isn't it ?
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
I just realized while making the change
debugfs_create_file_size()is void return, so we don't have anything useful to return inamdgpu_debugfs_ring_init()Ah, it makes better sense now. Probably just a mention in the body of the message that we are moving from
debugfs_create_file()todebugfs_create_file_size(), will make this change of return type more logical.Yes, I have that "Use
debugfs_create_file_sizeAPI for creating ring debugfs file,..."
My bad, I was too focused (and a bit confused due to uasge of clean-up) around the code change.
Suggestion for message: Use debugfs_create_file_size API for creating ring debugfs, and as its a NULL returning API, change the return type for amdgpu_debugfs_ring_init API as well.
With (or even without) this change, please feel free to use:
- Shashank
Quoted 61 lines
Nirmoy
Quoted 59 lines
- Shashank
Quoted 56 lines
Regards,
Nirmoy
Quoted 51 lines
Yes, we are currently throwing an error msg and ignoring it. I don't have a strong opinion regarding this, I will send a v2 restoring previous behavior.
Thanks,
Nirmoy
Quoted 41 lines
- Shashank
Quoted 38 lines
Quoted 38 lines
- Shashank
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-4- - i_size_write(ent->d_inode, ring->ring_size + 12); - ring->ent = ent; + debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size + 12); #endif - return 0; } /**drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-6@@ -253,10 +253,6 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) - struct dentry *ent; -#endif }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, int amdgpu_ring_test_helper(struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); - #endif
Re: [PATCH 2/2] drm/amdgpu: cleanup debugfs for amdgpu rings
Quoted 95 lines · Shashank
Quoted 92 lines · Nirmoy
Quoted 88 lines · Shashank
Quoted 76 lines · Nirmoy
Hi Shashank,
Quoted 73 lines · Nirmoy
Quoted 71 lines · Shashank
Quoted 66 lines · Nirmoy
Quoted 45 lines · Shashank
Quoted 42 lines · Nirmoy Das
Use
debugfs_create_file_sizeAPI for creating ring debugfs file, also cleanup surrounding code.Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 16
+++++-----------
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 8 +-------3 files changed, 7 insertions(+), 21 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-2@@ -1734,9 +1734,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) if (!ring) continue; - if (amdgpu_debugfs_ring_init(adev, ring)) { - DRM_ERROR("Failed to register debugfs file for rings !\n"); - } + amdgpu_debugfs_ring_init(adev, ring); }
amdgpu_ras_debugfs_create_all(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-1@@ -415,26 +415,20 @@ static const struct file_operations amdgpu_debugfs_ring_fops = { #endif -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring) { #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = adev_to_drm(adev)->primary; - struct dentry *ent, *root = minor->debugfs_root; + struct dentry *root = minor->debugfs_root; char name[32];Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c static const struct file_operations · line 429
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-4sprintf(name, "amdgpu_ring_%s", ring->name); - ent = debugfs_create_file(name, - S_IFREG | S_IRUGO, root, - ring, &amdgpu_debugfs_ring_fops); - if (IS_ERR(ent)) - return -ENOMEM;Why are we doing this ? Why to make it void from int ?
We tend to ignore debugfs return values as those are not serious errors. This to sync with rest of our
debugfs calls.
Regards,
Nirmoy
Quoted 7 lines
Quoted 1 line
Quoted 1 line
I am not suere if completely removing the provision of return value is a good way of doing it, we can always ignore it at the caller side, isn't it ?
I just realized while making the change
debugfs_create_file_size()is void return, so we don't have anything useful to return inamdgpu_debugfs_ring_init()Ah, it makes better sense now. Probably just a mention in the body of the message that we are moving from
debugfs_create_file()todebugfs_create_file_size(), will make this change of return type more logical.
Quoted 7 lines
Quoted 3 lines
Yes, I have that "Use
debugfs_create_file_sizeAPI for creating ring debugfs file,..."My bad, I was too focused (and a bit confused due to uasge of clean-up) around the code change.
Suggestion for message: Use
debugfs_create_file_sizeAPI for creating ring debugfs, and as its a NULL returning API, change the return type foramdgpu_debugfs_ring_initAPI as well.
Thanks Shashank, I pushed the change with your suggested commit message.
Nirmoy
Quoted 69 lines
With (or even without) this change, please feel free to use:
Reviewed-by Shashank Sharma <[email protected]>- Shashank
Quoted 62 lines
Nirmoy
Quoted 60 lines
- Shashank
Quoted 57 lines
Regards,
Nirmoy
Quoted 52 lines
Yes, we are currently throwing an error msg and ignoring it. I don't have a strong opinion regarding this, I will send a v2 restoring previous behavior.
Thanks,
Nirmoy
Quoted 42 lines
- Shashank
Quoted 39 lines
Quoted 39 lines
- Shashank
Quoted 35 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-4- - i_size_write(ent->d_inode, ring->ring_size + 12); - ring->ent = ent; + debugfs_create_file_size(name, S_IFREG | S_IRUGO, root, ring, + &amdgpu_debugfs_ring_fops, + ring->ring_size + 12); #endif - return 0; } /**drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-6@@ -253,10 +253,6 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; - -#if defined(CONFIG_DEBUG_FS ) - struct dentry *ent; -#endif }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))@@ -356,8 +352,6 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, int amdgpu_ring_test_helper(struct amdgpu_ring *ring); -int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, +void amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring); -void amdgpu_debugfs_ring_fini (struct amdgpu_ring *ring); - #endif
Quoted 41 lines · Nirmoy Das
debugfs APIs returns encoded error so use
IS_ERRfor checking return value.References: https://gitlab.freedesktop.org/drm/amd/-/issues/1686
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-4@@ -1696,18 +1696,16 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)struct dentry *ent;int r, i; - - ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt); -if (!ent) { +if (IS_ERR (ent)) {DRM_ERROR ("unable to create amdgpu_preempt_ib debugsfs file\n" );return -EIO ; } ent =debugfs_create_file ("amdgpu_force_sclk" ,0200 , root, adev, &fops_sclk_set); -if (!ent) { +if (IS_ERR (ent)) {DRM_ERROR ("unable to create amdgpu_set_sclk debugsfs file\n" );return -EIO ; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, · line 434
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-1@@ -428,7 +428,7 @@ int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, ent =debugfs_create_file (name,S_IFREG |S_IRUGO , root, ring, &amdgpu_debugfs_ring_fops); -if (!ent) +if (IS_ERR (ent))return -ENOMEM ;i_size_write (ent->d_inode, ring->ring_size +12 );
ACK: Shashank Sharma <[email protected]>
Regards
Shashank
Am 02.09.21 um 13:44 schrieb Nirmoy Das:
Quoted 5 lines
debugfs APIs returns encoded error so use
IS_ERRfor checking return value.References: https://gitlab.freedesktop.org/drm/amd/-/issues/1686
Signed-off-by Nirmoy Das <[email protected]>
Quoted 43 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-4@@ -1696,18 +1696,16 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)struct dentry *ent;int r, i; - - ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt); -if (!ent) { +if (IS_ERR (ent)) {DRM_ERROR ("unable to create amdgpu_preempt_ib debugsfs file\n" );return -EIO ; } ent =debugfs_create_file ("amdgpu_force_sclk" ,0200 , root, adev, &fops_sclk_set); -if (!ent) { +if (IS_ERR (ent)) {DRM_ERROR ("unable to create amdgpu_set_sclk debugsfs file\n" );return -EIO ; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-1@@ -428,7 +428,7 @@ int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, ent =debugfs_create_file (name,S_IFREG |S_IRUGO , root, ring, &amdgpu_debugfs_ring_fops); -if (!ent) +if (IS_ERR (ent))return -ENOMEM ;i_size_write (ent->d_inode, ring->ring_size +12 );
Hi Christian and Shashank,
Please review the v2 : https://patchwork.freedesktop.org/patch/452175/
In v2, I am returning "PTR_ERR(ent)" instead of -EIO which I think makes more sense.
Regards,
Nirmoy
Quoted 52 lines · Christian König
Am 02.09.21 um 13:44 schrieb Nirmoy Das:
Quoted 5 lines
debugfs APIs returns encoded error so use
IS_ERRfor checking return value.References: https://gitlab.freedesktop.org/drm/amd/-/issues/1686
Signed-off-by Nirmoy Das <[email protected]>Reviewed-by Christian König <[email protected]>Quoted 42 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +-2 files changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1696,18 +1696,16 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) struct dentry *ent; int r, i;-
-
ent =debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev, &fops_ib_preempt);
- if (!ent) {
+ if (IS_ERR(ent)) {
DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n"); return-EIO;
}
ent =debugfs_create_file("amdgpu_force_sclk", 0200, root, adev, &fops_sclk_set);
- if (!ent) {
+ if (IS_ERR(ent)) {
DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n"); return-EIO;
}drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-1@@ -428,7 +428,7 @@ int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, ent = debugfs_create_file(name, S_IFREG | S_IRUGO, root, ring, &amdgpu_debugfs_ring_fops); - if (!ent) + if (IS_ERR(ent)) return -ENOMEM; i_size_write(ent->d_inode, ring->ring_size + 12);
Christian König
maintainerYeah, sounds logical to me as well. Feel free to stick my rb on that as well.
Christian.
Am 03.09.21 um 10:13 schrieb Das, Nirmoy:
Quoted 63 lines
Hi Christian and Shashank,
Please review the v2 : https://patchwork.freedesktop.org/patch/452175/
In v2, I am returning "
PTR_ERR(ent)" instead of-EIOwhich I think makes more sense.Regards,
NirmoyQuoted 52 lines · Christian König
Am 02.09.21 um 13:44 schrieb Nirmoy Das:
Quoted 5 lines
debugfs APIs returns encoded error so use
IS_ERRfor checking return value.References: https://gitlab.freedesktop.org/drm/amd/-/issues/1686
Signed-off-by Nirmoy Das <[email protected]>Reviewed-by Christian König <[email protected]>Quoted 42 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +-2 files changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1696,18 +1696,16 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) struct dentry *ent; int r, i;-
-
ent =debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev, &fops_ib_preempt);
- if (!ent) {
+ if (IS_ERR(ent)) {
DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n"); return-EIO;
}
ent =debugfs_create_file("amdgpu_force_sclk", 0200, root, adev, &fops_sclk_set);
- if (!ent) {
+ if (IS_ERR(ent)) {
DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n"); return-EIO;
}drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-1@@ -428,7 +428,7 @@ int amdgpu_debugfs_ring_init(structamdgpu_device *adev, ent = debugfs_create_file(name, S_IFREG | S_IRUGO, root, ring, &amdgpu_debugfs_ring_fops); - if (!ent) + if (IS_ERR(ent)) return -ENOMEM; i_size_write(ent->d_inode, ring->ring_size + 12);
Sharma, Shashank
Reviewed-byQuoted 11 lines · Christian König
Yeah, sounds logical to me as well. Feel free to stick my rb on that as well.
Christian.
Am 03.09.21 um 10:13 schrieb Das, Nirmoy:
Quoted 6 lines
Hi Christian and Shashank,
Please review the v2 : https://patchwork.freedesktop.org/patch/452175/
In v2, I am returning "
PTR_ERR(ent)" instead of-EIOwhich I think makes more sense.
Agree, LGTM as well,
Regards
Shashank
Quoted 58 lines
Quoted 57 lines
Regards,
NirmoyQuoted 52 lines · Christian König
Am 02.09.21 um 13:44 schrieb Nirmoy Das:
Quoted 5 lines
debugfs APIs returns encoded error so use
IS_ERRfor checking return value.References: https://gitlab.freedesktop.org/drm/amd/-/issues/1686
Signed-off-by Nirmoy Das <[email protected]>Reviewed-by Christian König <[email protected]>Quoted 42 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +-2 files changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1696,18 +1696,16 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) struct dentry *ent; int r, i;-
-
ent =debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev, &fops_ib_preempt);
- if (!ent) {
+ if (IS_ERR(ent)) {
DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n"); return-EIO;
}
ent =debugfs_create_file("amdgpu_force_sclk", 0200, root, adev, &fops_sclk_set);
- if (!ent) {
+ if (IS_ERR(ent)) {
DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n"); return-EIO;
}drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1
-1@@ -428,7 +428,7 @@ int amdgpu_debugfs_ring_init(structamdgpu_device *adev, ent = debugfs_create_file(name, S_IFREG | S_IRUGO, root, ring, &amdgpu_debugfs_ring_fops); - if (!ent) + if (IS_ERR(ent)) return -ENOMEM; i_size_write(ent->d_inode, ring->ring_size + 12);