drm: fix call_kern.cocci warnings
Subsystems (2)
PATCH 1/1 drm: fix call_kern.cocci warnings
drivers/gpu/drm/drm_syncobj.c:202:4-14: ERROR: function drm_syncobj_find_signal_pt_for_point called on line 390 inside lock on line 389 but uses GFP_KERNEL
Find functions that refer to GFP_KERNEL but are called with locks held.
Semantic patch information:
The proposed change of converting the GFP_KERNEL is not necessarily the correct one. It may be desired to unlock the lock, or to not call the function under the lock in the first place.
Generated by: scripts/coccinelle/locks/call_kern.cocci
--- drivers/gpu/drm/drm_syncobj.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_syncobj.c +6 -6
@@ -111,6 +111,7 @@ static struct dma_fence uint64_t point) {struct drm_syncobj_signal_pt *signal_pt; +struct dma_fence *fence =NULL ;if ((syncobj->type ==DRM_SYNCOBJ_TYPE_TIMELINE ) && (point <= syncobj->timeline)) {
@@ -131,15 +132,18 @@ static struct dma_fencereturn &fence->base; } +spin_lock (&syncobj->pt_lock);list_for_each_entry (signal_pt, &syncobj->signal_pt_list, list) {if (point > signal_pt->value)continue ;if ((syncobj->type ==DRM_SYNCOBJ_TYPE_BINARY ) && (point != signal_pt->value))continue ; -return dma_fence_get (&signal_pt->fence_array->base); + fence =dma_fence_get (&signal_pt->fence_array->base); +break ; } -return NULL ; +spin_unlock (&syncobj->pt_lock); +return fence; } static void drm_syncobj_add_callback_locked(struct drm_syncobj *syncobj,
@@ -166,9 +170,7 @@ static void drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, }mutex_lock (&syncobj->cb_mutex); -spin_lock (&syncobj->pt_lock); *fence =drm_syncobj_find_signal_pt_for_point (syncobj, pt_value); -spin_unlock (&syncobj->pt_lock);if (!*fence)drm_syncobj_add_callback_locked (syncobj, cb, func);mutex_unlock (&syncobj->cb_mutex);
@@ -379,11 +381,9 @@ drm_syncobj_point_get(struct drm_syncobj *syncobj, u64 point, u64 flags,if (ret <0 )return ret; } -spin_lock (&syncobj->pt_lock); *fence =drm_syncobj_find_signal_pt_for_point (syncobj, point);if (!*fence) ret = -EINVAL ; -spin_unlock (&syncobj->pt_lock);return ret; }
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
pls ignore this one, please review v2.
Quoted 64 lines · Chunming Zhou
drivers/gpu/drm/drm_syncobj.c:202:4-14: ERROR: function
drm_syncobj_find_signal_pt_for_pointcalled on line 390 inside lock on line 389 but usesGFP_KERNELFind functions that refer to
GFP_KERNELbut are called with locks held.Semantic patch information:
The proposed change of converting theGFP_KERNELis not necessarily the correct one. It may be desired to unlock the lock, or to not call the function under the lock in the first place.Generated by:
scripts/coccinelle/locks/call_kern.cocciSigned-off-by Chunming Zhou <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Christian König <[email protected]>--- drivers/gpu/drm/drm_syncobj.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_syncobj.c +6
-4@@ -111,6 +111,7 @@ static struct dma_fence uint64_t point) {struct drm_syncobj_signal_pt *signal_pt; +struct dma_fence *fence =NULL ;if ((syncobj->type ==DRM_SYNCOBJ_TYPE_TIMELINE ) && (point <= syncobj->timeline)) {@@ -131,15 +132,18 @@ static struct dma_fencereturn &fence->base; } +spin_lock (&syncobj->pt_lock);list_for_each_entry (signal_pt, &syncobj->signal_pt_list, list) {if (point > signal_pt->value)continue ;if ((syncobj->type ==DRM_SYNCOBJ_TYPE_BINARY ) && (point != signal_pt->value))continue ; -return dma_fence_get (&signal_pt->fence_array->base); + fence =dma_fence_get (&signal_pt->fence_array->base); +break ; } -return NULL ; +spin_unlock (&syncobj->pt_lock); +return fence; } static void drm_syncobj_add_callback_locked(struct drm_syncobj *syncobj,@@ -166,9 +170,7 @@ static void drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, }mutex_lock (&syncobj->cb_mutex); -spin_lock (&syncobj->pt_lock); *fence =drm_syncobj_find_signal_pt_for_point (syncobj, pt_value); -spin_unlock (&syncobj->pt_lock);if (!*fence)drm_syncobj_add_callback_locked (syncobj, cb, func);mutex_unlock (&syncobj->cb_mutex);@@ -379,11 +381,9 @@ drm_syncobj_point_get(struct drm_syncobj *syncobj, u64 point, u64 flags,if (ret <0 )
drivers/gpu/drm/drm_syncobj.c drm_syncobj_point_get(struct drm_syncobj *syncobj, u64 point, u64 flags, · line 389
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +0
-2return ret; } -spin_lock (&syncobj->pt_lock); *fence =drm_syncobj_find_signal_pt_for_point (syncobj, point);if (!*fence) ret = -EINVAL ; -spin_unlock (&syncobj->pt_lock);return ret; }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✓ Fi.CI.BAT: success for drm: fix call_kern.cocci warnings
In reply to Chunming Zhou== Series Details ==
== Series Details ==
Series: drm: fix call_kern.cocci warnings
URL : https://patchwork.freedesktop.org/series/51498/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_5033 -> Patchwork_10572 =
== Summary - WARNING ==
Minor unknown changes coming with Patchwork_10572 need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_10572, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/51498/revisions/1/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in Patchwork_10572:
=== IGT changes ===
==== Warnings ====
igt@pm_rpm@module-reload:
fi-hsw-4770r: SKIP -> PASS== Known issues ==
Here are the changes found in Patchwork_10572 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@drv_module_reload@basic-reload:
fi-glk-j4005: PASS -> DMESG-WARN (fdo#106725, fdo#106248)
igt@drv_selftest@live_sanitycheck:
fi-glk-j4005: PASS -> DMESG-WARN (fdo#105719)
igt@gem_exec_suspend@basic-s4-devices:
fi-kbl-7500u: PASS -> DMESG-WARN (fdo#107139, fdo#105128)
igt@kms_flip@basic-flip-vs-modeset:
fi-glk-j4005: PASS -> DMESG-WARN (fdo#106000)
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
fi-byt-clapper: PASS -> FAIL (fdo#107362, fdo#103191) +1
==== Possible fixes ====
igt@drv_module_reload@basic-reload-inject:
fi-hsw-4770r: DMESG-WARN (fdo#107924, fdo#107425) -> PASS
igt@drv_selftest@live_hangcheck:
fi-kbl-7560u: INCOMPLETE (fdo#108044) -> PASS
igt@kms_flip@basic-flip-vs-dpms:
fi-skl-6700hq: DMESG-WARN (fdo#105998) -> PASS fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#105128 https://bugs.freedesktop.org/show_bug.cgi?id=105128
fdo#105719 https://bugs.freedesktop.org/show_bug.cgi?id=105719
fdo#105998 https://bugs.freedesktop.org/show_bug.cgi?id=105998
fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
fdo#107139 https://bugs.freedesktop.org/show_bug.cgi?id=107139
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107425 https://bugs.freedesktop.org/show_bug.cgi?id=107425
fdo#107924 https://bugs.freedesktop.org/show_bug.cgi?id=107924
fdo#108044 https://bugs.freedesktop.org/show_bug.cgi?id=108044
== Participating hosts (47 -> 42) ==
Missing (5): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-icl-u
== Build changes ==
* Linux: CI_DRM_5033 -> Patchwork_10572
CI_DRM_5033: f935e4c7634781e6ffef10bb8a1c93225ac42d90 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4691: d445be01f5edc7e7a324444c73e221c9ed75602e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10572: 6e6364d5bfa3fcb88b0f2b8df5d398e525034c55 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
6e6364d5bfa3 drm: fix call_kern.cocci warnings
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10572/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 3 lines · Chunming Zhou
drivers/gpu/drm/drm_syncobj.c:202:4-14: ERROR: function
drm_syncobj_find_signal_pt_for_pointcalled on line 390 inside lock on line 389 but usesGFP_KERNELFind functions that refer to
GFP_KERNELbut are called with locks held.
Uh ... if your internal validation doesn't catch stuff like this (boils down to a) run code b) with sleep debugging enabled) what exactly do you do?
Not really inspiring confindence.
-Daniel
Quoted 78 lines
Semantic patch information:
The proposed change of converting theGFP_KERNELis not necessarily the correct one. It may be desired to unlock the lock, or to not call the function under the lock in the first place.Generated by:
scripts/coccinelle/locks/call_kern.cocciSigned-off-by Chunming Zhou <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Christian König <[email protected]>--- drivers/gpu/drm/drm_syncobj.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_syncobj.c +6
-6@@ -111,6 +111,7 @@ static struct dma_fence uint64_t point) {struct drm_syncobj_signal_pt *signal_pt; +struct dma_fence *fence =NULL ;if ((syncobj->type ==DRM_SYNCOBJ_TYPE_TIMELINE ) && (point <= syncobj->timeline)) {@@ -131,15 +132,18 @@ static struct dma_fencereturn &fence->base; } +spin_lock (&syncobj->pt_lock);list_for_each_entry (signal_pt, &syncobj->signal_pt_list, list) {if (point > signal_pt->value)continue ;if ((syncobj->type ==DRM_SYNCOBJ_TYPE_BINARY ) && (point != signal_pt->value))continue ; -return dma_fence_get (&signal_pt->fence_array->base); + fence =dma_fence_get (&signal_pt->fence_array->base); +break ; } -return NULL ; +spin_unlock (&syncobj->pt_lock); +return fence; } static void drm_syncobj_add_callback_locked(struct drm_syncobj *syncobj,@@ -166,9 +170,7 @@ static void drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, }mutex_lock (&syncobj->cb_mutex); -spin_lock (&syncobj->pt_lock); *fence =drm_syncobj_find_signal_pt_for_point (syncobj, pt_value); -spin_unlock (&syncobj->pt_lock);if (!*fence)drm_syncobj_add_callback_locked (syncobj, cb, func);mutex_unlock (&syncobj->cb_mutex);@@ -379,11 +381,9 @@ drm_syncobj_point_get(struct drm_syncobj *syncobj, u64 point, u64 flags,if (ret <0 )return ret; } -spin_lock (&syncobj->pt_lock); *fence =drm_syncobj_find_signal_pt_for_point (syncobj, point);if (!*fence) ret = -EINVAL ; -spin_unlock (&syncobj->pt_lock);return ret; }Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 25.10.18 um 11:35 schrieb Daniel Vetter:
Quoted 7 lines · Chunming Zhou
Quoted 3 lines
drivers/gpu/drm/drm_syncobj.c:202:4-14: ERROR: function
drm_syncobj_find_signal_pt_for_pointcalled on line 390 inside lock on line 389 but usesGFP_KERNELFind functions that refer to
GFP_KERNELbut are called with locks held.Uh ... if your internal validation doesn't catch stuff like this (boils down to a) run code b) with sleep debugging enabled) what exactly do you do?
Who says we do any internal validation? ;)
But kidding aside, this code path is only taken after garbage collection has already cleaned up the original fence and we need to return a dummy.
I think we just never covered that in the testing.
Christian.
Quoted 74 lines
Not really inspiring confindence.
-DanielQuoted 70 lines
Semantic patch information:
The proposed change of converting theGFP_KERNELis not necessarily the correct one. It may be desired to unlock the lock, or to not call the function under the lock in the first place.Generated by:
scripts/coccinelle/locks/call_kern.cocciSigned-off-by Chunming Zhou <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Christian König <[email protected]>--- drivers/gpu/drm/drm_syncobj.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_syncobj.c +6
-6@@ -111,6 +111,7 @@ static struct dma_fence uint64_t point) {struct drm_syncobj_signal_pt *signal_pt; +struct dma_fence *fence =NULL ;if ((syncobj->type ==DRM_SYNCOBJ_TYPE_TIMELINE ) && (point <= syncobj->timeline)) {@@ -131,15 +132,18 @@ static struct dma_fencereturn &fence->base; } +spin_lock (&syncobj->pt_lock);list_for_each_entry (signal_pt, &syncobj->signal_pt_list, list) {if (point > signal_pt->value)continue ;if ((syncobj->type ==DRM_SYNCOBJ_TYPE_BINARY ) && (point != signal_pt->value))continue ; -return dma_fence_get (&signal_pt->fence_array->base); + fence =dma_fence_get (&signal_pt->fence_array->base); +break ; } -return NULL ; +spin_unlock (&syncobj->pt_lock); +return fence; } static void drm_syncobj_add_callback_locked(struct drm_syncobj *syncobj,@@ -166,9 +170,7 @@ static void drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, }mutex_lock (&syncobj->cb_mutex); -spin_lock (&syncobj->pt_lock); *fence =drm_syncobj_find_signal_pt_for_point (syncobj, pt_value); -spin_unlock (&syncobj->pt_lock);if (!*fence)drm_syncobj_add_callback_locked (syncobj, cb, func);mutex_unlock (&syncobj->cb_mutex);@@ -379,11 +381,9 @@ drm_syncobj_point_get(struct drm_syncobj *syncobj, u64 point, u64 flags,if (ret <0 )return ret; } -spin_lock (&syncobj->pt_lock); *fence =drm_syncobj_find_signal_pt_for_point (syncobj, point);if (!*fence) ret = -EINVAL ; -spin_unlock (&syncobj->pt_lock);return ret; }
Quoted 7 lines
Quoted 7 lines
Signature · 6 lines
2.17.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Christian König
Am 25.10.18 um 11:35 schrieb Daniel Vetter:
Quoted 7 lines · Chunming Zhou
Quoted 3 lines
drivers/gpu/drm/drm_syncobj.c:202:4-14: ERROR: function
drm_syncobj_find_signal_pt_for_pointcalled on line 390 inside lock on line 389 but usesGFP_KERNELFind functions that refer to
GFP_KERNELbut are called with locks held.Uh ... if your internal validation doesn't catch stuff like this (boils down to a) run code b) with sleep debugging enabled) what exactly do you do?
Who says we do any internal validation? ;)
It's my mistake, I switched to new kernel and didn't check if these DEBUG options are enabled or not. I shouldn't take this kind mistake, anyway.
Sorry for that,
David
Quoted 81 lines
But kidding aside, this code path is only taken after garbage collection has already cleaned up the original fence and we need to return a dummy.
I think we just never covered that in the testing.
Christian.
Quoted 74 lines
Not really inspiring confindence.
-DanielQuoted 70 lines
Semantic patch information:
The proposed change of converting theGFP_KERNELis not necessarily the correct one. It may be desired to unlock the lock, or to not call the function under the lock in the first place.Generated by:
scripts/coccinelle/locks/call_kern.cocciSigned-off-by Chunming Zhou <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Christian König <[email protected]>---
drivers/gpu/drm/drm_syncobj.c| 12 ++++++------1 file changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_syncobj.c +1
-0@@ -111,6 +111,7 @@ static struct dma_fence uint64_t point) { struct drm_syncobj_signal_pt *signal_pt; + struct dma_fence *fence = NULL;if ((
syncobj->type==DRM_SYNCOBJ_TYPE_TIMELINE) && (point <=syncobj->timeline)) {drivers/gpu/drm/drm_syncobj.c +0
-0@@ -131,15 +132,18 @@ static struct dma_fence return &fence->base; } + spin_lock(&syncobj->pt_lock); list_for_each_entry(signal_pt, &syncobj->signal_pt_list, list) { if (point > signal_pt->value) continue;if ((
syncobj->type==DRM_SYNCOBJ_TYPE_BINARY) && (point !=signal_pt->value))
continue;
- returndma_fence_get(&signal_pt->fence_array->base);
+ fence =dma_fence_get(&signal_pt->fence_array->base);
+ break;
}
- return NULL;
+spin_unlock(&syncobj->pt_lock);
+ return fence;
}
static void drm_syncobj_add_callback_locked(structdrm_syncobj*syncobj,drivers/gpu/drm/drm_syncobj.c +0
-4@@ -166,9 +170,7 @@ static void drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, } mutex_lock(&syncobj->cb_mutex); - spin_lock(&syncobj->pt_lock); *fence = drm_syncobj_find_signal_pt_for_point(syncobj, pt_value); - spin_unlock(&syncobj->pt_lock); if (!*fence) drm_syncobj_add_callback_locked(syncobj, cb, func); mutex_unlock(&syncobj->cb_mutex);@@ -379,11 +381,9 @@ drm_syncobj_point_get(struct drm_syncobj *syncobj, u64 point, u64 flags, if (ret < 0) return ret; } - spin_lock(&syncobj->pt_lock); *fence = drm_syncobj_find_signal_pt_for_point(syncobj, point); if (!*fence) ret = -EINVAL; - spin_unlock(&syncobj->pt_lock); return ret; }--
2.17.1
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel