drm/amdgpu: correct the amdgpu runtime dereference usage count
Subsystems (2)
PATCH 1/2 drm/amdgpu: correct the amdgpu runtime dereference usage count
Fix the amdgpu runpm dereference usage count.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
@@ -1992,7 +1992,7 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val) ret =amdgpu_dpm_set_soft_freq_range (adev,PP_SCLK , (uint32_t )val, (uint32_t )val);if (ret) - ret = -EINVAL ; + goto out; out:pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
@@ -346,6 +346,7 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set,if (!active && adev->have_disp_power_ref) {pm_runtime_put_autosuspend (dev->dev); adev->have_disp_power_ref = false; +return ret; } out:
Signature · 1 line
2.34.1
PATCH 2/2 drm/amdgpu: add amdgpu runpm usage trace for separate funcs
Add trace for amdgpu runpm separate funcs usage and this will help debugging on the case of runpm usage missed to dereference. In the normal case the runpm usage count referred by one kind of functionality pairwise and usage should be changed from 1 to 0, otherwise there will be an issue in the amdgpu runpm usage dereference.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 7 ++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +4 -0
@@ -42,6 +42,7 @@#include <linux/dma-fence-array.h> #include <linux/pci-p2pdma.h> #include <linux/pm_runtime.h> +#include "amdgpu_trace.h" /** * amdgpu_dma_buf_attach - &dma_buf_ops.attach implementation
@@ -63,6 +64,7 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf, attach->peer2peer = false; r =pm_runtime_get_sync (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (1 , __func__);if (r <0 ) goto out;
@@ -70,6 +72,7 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf, out:pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__);return r; }
@@ -90,6 +93,7 @@ static void amdgpu_dma_buf_detach(struct dma_buf *dmabuf,pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__); }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +6 -1
@@ -183,6 +183,7 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f, struct amdamdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, seq, flags |AMDGPU_FENCE_FLAG_INT );pm_runtime_get_noresume (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (1 , __func__); ptr = &ring->fence_drv.fences[seq & ring->fence_drv.num_fences_mask];if (unlikely (rcu_dereference_protected (*ptr,1 ))) {struct dma_fence *old;
@@ -286,8 +287,11 @@ bool amdgpu_fence_process(struct amdgpu_ring *ring) seq != ring->fence_drv.sync_seq)amdgpu_fence_schedule_fallback (ring); -if (unlikely (seq == last_seq)) +if (unlikely (seq == last_seq)) { +pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__);return false; + } last_seq &= drv->num_fences_mask; seq &= drv->num_fences_mask;
@@ -310,6 +314,7 @@ bool amdgpu_fence_process(struct amdgpu_ring *ring)dma_fence_put (fence);pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__); }while (last_seq != seq);return true;
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +15 -0
@@ -554,6 +554,21 @@ TRACE_EVENT(amdgpu_reset_reg_dumps, __entry->value) ); +TRACE_EVENT (amdgpu_runpm_reference_dumps, + TP_PROTO(uint32_t index, const char *func), +TP_ARGS (index, func), +TP_STRUCT__entry ( + __field(uint32_t, index) +__string (func, func) + ), +TP_fast_assign ( + __entry->index = index; + __assign_str(func, func); + ), +TP_printk ("amdgpu runpm reference dump 0x%d: 0x%s\n" , + __entry->index, +__get_str (func)) +);#undef AMDGPU_JOB_GET_TIMELINE_NAME#endif
Signature · 1 line
2.34.1
RE: [PATCH 2/2] drm/amdgpu: add amdgpu runpm usage trace for separate funcs
[Public]
Quoted 9 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Thursday, November 9, 2023 2:37 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: add amdgpu runpm usage trace for separate funcs
Quoted 7 lines
Add trace for amdgpu runpm separate funcs usage and this will help debugging on the case of runpm usage missed to dereference. In the normal case the runpm usage count referred by one kind of functionality pairwise and usage should be changed from 1 to 0, otherwise there will be an issue in the amdgpu runpm usage dereference.
Signed-off-by Prike Liang <[email protected]>
Looks good. Not sure if you want to add tracepoints to the other call sites as well. These are probably the trickiest however.
Quoted 112 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 7 ++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +1
-0@@ -42,6 +42,7 @@#include <linux/dma-fence-array.h> #include <linux/pci-p2pdma.h> #include <linux/pm_runtime.h> +#include "amdgpu_trace.h" /** * amdgpu_dma_buf_attach - &dma_buf_ops.attach implementation @@ - 63,6 +64,7 @@ static int amdgpu_dma_buf_attach(struct
dma_buf*dmabuf,attach->peer2peer = false; r = pm_runtime_get_sync(adev_to_drm(adev)->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-0+trace_amdgpu_runpm_reference_dumps (1 , __func__);if (r <0 ) goto out;@@ -70,6 +72,7 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf, out:pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__);return r; }@@ -90,6 +93,7 @@ static void amdgpu_dma_buf_detach(struct dma_buf *dmabuf,pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__); }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-0@@ -183,6 +183,7 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring,struct
dma_fence**f, struct amdamdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr, seq, flags | AMDGPU_FENCE_FLAG_INT); pm_runtime_get_noresume(adev_to_drm(adev)->dev); + trace_amdgpu_runpm_reference_dumps(1, __func__); ptr = &ring->fence_drv.fences[seq & ring-Quoted 1 line
fence_drv.num_fences_mask];
if (unlikely(rcu_dereference_protected(*ptr, 1))) { struct dma_fence *old;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +4
-1@@ -286,8 +287,11 @@ bool amdgpu_fence_process(struct amdgpu_ring *ring) seq != ring->fence_drv.sync_seq)amdgpu_fence_schedule_fallback (ring); -if (unlikely (seq == last_seq)) +if (unlikely (seq == last_seq)) { +pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__);return false; + } last_seq &= drv->num_fences_mask;seq &= drv->num_fences_mask;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1
-0@@ -310,6 +314,7 @@ bool amdgpu_fence_process(struct amdgpu_ring *ring)dma_fence_put (fence);pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__); }while (last_seq != seq);return true;drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +15
-1@@ -554,6 +554,21 @@ TRACE_EVENT(amdgpu_reset_reg_dumps, __entry->value) ); +TRACE_EVENT (amdgpu_runpm_reference_dumps, + TP_PROTO(uint32_t index, const char *func), +TP_ARGS (index, func), +TP_STRUCT__entry ( + __field(uint32_t, index) +__string (func, func) + ), +TP_fast_assign ( + __entry->index = index; + __assign_str(func, func); + ), +TP_printk ("amdgpu runpm reference dump 0x%d: 0x%s\n" , + __entry->index, +__get_str (func)) +);#undef AMDGPU_JOB_GET_TIMELINE_NAME#endif --2.34.1
RE: [PATCH 2/2] drm/amdgpu: add amdgpu runpm usage trace for separate funcs
[Public]
Quoted 24 lines
-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Friday, November 10, 2023 5:49 AM
To: Liang, Prike <[email protected]>; [email protected]
Subject: RE: [PATCH 2/2] drm/amdgpu: add amdgpu runpm usage trace for separate funcs[Public]
Quoted 15 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Thursday, November 9, 2023 2:37 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: add amdgpu runpm usage trace for separate funcsAdd trace for amdgpu runpm separate funcs usage and this will help debugging on the case of runpm usage missed to dereference. In the normal case the runpm usage count referred by one kind of functionality pairwise and usage should be changed from 1 to 0, otherwise there will be an issue in the amdgpu runpm usage dereference.
Quoted 7 lines
Quoted 1 line
Signed-off-by Prike Liang <[email protected]>Looks good. Not sure if you want to add tracepoints to the other call sites as well. These are probably the trickiest however.
Acked-by Alex Deucher <[email protected]>
[Prike] Thanks for the review, now the trace points only added to the amdgpu functions which are referencing and dereferencing amdgpu runpm usage separately and from the checking that seems no more separate functions need the trace point at the moment.
Quoted 115 lines
Quoted 12 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 7 ++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c line 48
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +1
-0@@ -42,6 +42,7 @@#include <linux/dma-fence-array.h> #include <linux/pci-p2pdma.h> #include <linux/pm_runtime.h> +#include "amdgpu_trace.h" /** * amdgpu_dma_buf_attach - &dma_buf_ops.attach implementation @@ -
Quoted 1 line
63,6 +64,7 @@ static int amdgpu_dma_buf_attach(struct
dma_buf*dmabuf,
Quoted 92 lines
attach->peer2peer = false; r = pm_runtime_get_sync(adev_to_drm(adev)->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-0+trace_amdgpu_runpm_reference_dumps (1 , __func__);if (r <0 ) goto out;@@ -70,6 +72,7 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf, out:pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__);return r; }@@ -90,6 +93,7 @@ static void amdgpu_dma_buf_detach(struct dma_buf *dmabuf,pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__); }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-0@@ -183,6 +183,7 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring,struct
dma_fence**f, struct amdamdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr, seq, flags | AMDGPU_FENCE_FLAG_INT); pm_runtime_get_noresume(adev_to_drm(adev)->dev); + trace_amdgpu_runpm_reference_dumps(1, __func__); ptr = &ring->fence_drv.fences[seq & ring-Quoted 1 line
fence_drv.num_fences_mask];
if (unlikely(rcu_dereference_protected(*ptr, 1))) { struct dma_fence *old;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +4
-1@@ -286,8 +287,11 @@ bool amdgpu_fence_process(struct amdgpu_ring *ring) seq != ring->fence_drv.sync_seq)amdgpu_fence_schedule_fallback (ring); -if (unlikely (seq == last_seq)) +if (unlikely (seq == last_seq)) { +pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__);return false; + } last_seq &= drv->num_fences_mask;seq &= drv->num_fences_mask;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1
-0@@ -310,6 +314,7 @@ bool amdgpu_fence_process(struct amdgpu_ring *ring)dma_fence_put (fence);pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); +trace_amdgpu_runpm_reference_dumps (0 , __func__); }while (last_seq != seq);return true;drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +15
-1@@ -554,6 +554,21 @@ TRACE_EVENT(amdgpu_reset_reg_dumps, __entry->value) ); +TRACE_EVENT (amdgpu_runpm_reference_dumps, + TP_PROTO(uint32_t index, const char *func), +TP_ARGS (index, func), +TP_STRUCT__entry ( + __field(uint32_t, index) +__string (func, func) + ), +TP_fast_assign ( + __entry->index = index; + __assign_str(func, func); + ), +TP_printk ("amdgpu runpm reference dump 0x%d: 0x%s\n" , + __entry->index, +__get_str (func)) +);#undef AMDGPU_JOB_GET_TIMELINE_NAME#endif --2.34.1
Deucher, Alexander
maintainer[Public]
Quoted 23 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Thursday, November 9, 2023 2:37 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: correct the amdgpu runtime dereference usage countFix the amdgpu runpm dereference usage count.
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, · line 1997
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-1@@ -1992,7 +1992,7 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val) ret =amdgpu_dpm_set_soft_freq_range (adev,PP_SCLK , (uint32_t )val, (uint32_t )val);if (ret) - ret = -EINVAL ; + goto out;
I think this hunk can be dropped. It doesn't really change anything. Or you could just drop the whole ret check since we just return ret at the end anyway. Not sure if changing the error code is important here or not.
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0out:pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c int amdgpu_display_crtc_set_config(struct · line 351
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1
-0@@ -346,6 +346,7 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set, if (!active && adev->have_disp_power_ref) {pm_runtime_put_autosuspend (dev->dev); adev->have_disp_power_ref = false; +return ret; }
I think it would be cleaner to just drop the runtime_put above and update the comment. We'll just fall through to the end of the function.
Alex
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0
-1out: --2.34.1
[Public]
Quoted 34 lines
-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Friday, November 10, 2023 5:46 AM
To: Liang, Prike <[email protected]>; [email protected]
Subject: RE: [PATCH 1/2] drm/amdgpu: correct the amdgpu runtime dereference usage count[Public]
Quoted 25 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Thursday, November 9, 2023 2:37 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: correct the amdgpu runtime dereference usage countFix the amdgpu runpm dereference usage count.
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1992,7 +1992,7 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val)
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val) · line 1995
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-1ret =amdgpu_dpm_set_soft_freq_range (adev,PP_SCLK , (uint32_t )val, (uint32_t )val);if (ret) - ret = -EINVAL ; + goto out;I think this hunk can be dropped. It doesn't really change anything. Or you could just drop the whole ret check since we just return ret at the end anyway. Not sure if changing the error code is important here or not.
[Prike] Thanks for pointing it out, revisit this part that seems ok for reassign the return value when the caller function can't return a proper error type. I will keep this part as the unmodified since this has no problem for dereferencing the runpm usage.
Quoted 19 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0out:pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_display.c int amdgpu_display_crtc_set_config(struct · line 351
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1
-0@@ -346,6 +346,7 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set, if (!active && adev->have_disp_power_ref) {pm_runtime_put_autosuspend (dev->dev); adev->have_disp_power_ref = false; +return ret; }I think it would be cleaner to just drop the
runtime_putabove and update the comment. We'll just fall through to the end of the function.
Quoted 2 lines
Alex
[Prike] Do you mean something like as the following? I will submit a new patch for this.
- /* if we have no active crtcs, then drop the power ref
- * we got before
+ /* if we have no active crtcs, then go to
+ * drop the power ref we got before
*/
if (!active && adev->have_disp_power_ref) {
- pm_runtime_put_autosuspend(dev->dev);
adev->have_disp_power_ref = false;
+ goto out;
}Quoted 5 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0
-1out: --2.34.1
Quoted 68 lines · Prike
[Public]
Quoted 34 lines
-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Friday, November 10, 2023 5:46 AM
To: Liang, Prike <[email protected]>; [email protected]
Subject: RE: [PATCH 1/2] drm/amdgpu: correct the amdgpu runtime dereference usage count[Public]
Quoted 25 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Thursday, November 9, 2023 2:37 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: correct the amdgpu runtime dereference usage countFix the amdgpu runpm dereference usage count.
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1992,7 +1992,7 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val)Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static int amdgpu_debugfs_sclk_set(void *data, u64 val) · line 1995
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-1ret =amdgpu_dpm_set_soft_freq_range (adev,PP_SCLK , (uint32_t )val, (uint32_t )val);if (ret) - ret = -EINVAL ; + goto out;I think this hunk can be dropped. It doesn't really change anything. Or you could just drop the whole ret check since we just return ret at the end anyway. Not sure if changing the error code is important here or not.
[Prike] Thanks for pointing it out, revisit this part that seems ok for reassign the return value when the caller function can't return a proper error type. I will keep this part as the unmodified since this has no problem for dereferencing the runpm usage.
Quoted 19 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0out:pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_display.c int amdgpu_display_crtc_set_config(struct · line 351
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1
-0@@ -346,6 +346,7 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set, if (!active && adev->have_disp_power_ref) {pm_runtime_put_autosuspend (dev->dev); adev->have_disp_power_ref = false; +return ret; }I think it would be cleaner to just drop the
runtime_putabove and update the comment. We'll just fall through to the end of the function.
Quoted 3 lines
Quoted 2 lines
Alex
[Prike] Do you mean something like as the following? I will submit a new patch for this.
Just drop the goto out. E.g.
if (!active && adev->have_disp_power_ref)
adev->have_disp_power_ref = false;Alex
Quoted 17 lines
(quoted diff) +3
-3- /* if we have no active crtcs, then drop the power ref - * we got before + /* if we have no active crtcs, then go to + * drop the power ref we got before */ if (!active && adev->have_disp_power_ref) { - pm_runtime_put_autosuspend(dev->dev); adev->have_disp_power_ref = false; + goto out; }Quoted 5 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0
-1out: --2.34.1