Skip to contentSkip to conversation

drm/i915: properly init lockdep class

PATCH In review Sebastian Andrzej Siewior 3 participants 6 messages Nov 30, 2017 – Dec 13, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 201711250649.n1NUHo79%[email protected]

#1 lore raw

PATCH 1/1 drm/i915: properly init lockdep class

The code has an ifdef and uses two functions to either init the bare spinlock or init it and set a lock-class. It is possible to do the same thing without an ifdef.
With this patch (in debug case) we first use the "default" lock class which is later overwritten to the supplied one. Without lockdep the set name/class function vanishes.

---
 drivers/gpu/drm/i915/i915_gem_timeline.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gem_timeline.c +1 -4
@@ -33,11 +33,8 @@ static void __intel_timeline_init(struct
 {
 	tl->fence_context = context;
 	tl->common = parent;
-#ifdef CONFIG_DEBUG_SPINLOCK
-	__raw_spin_lock_init(&tl->lock.rlock, lockname, lockclass);
-#else
 	spin_lock_init(&tl->lock);
-#endif
+	lockdep_set_class_and_name(&tl->lock, lockclass, lockname);
 	init_request_active(&tl->last_request, NULL);
 	INIT_LIST_HEAD(&tl->requests);
 	i915_syncmap_init(&tl->sync);

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#2 lore raw
Quoted 8 lines · Sebastian Andrzej Siewior

The code has an ifdef and uses two functions to either init the bare spinlock or init it and set a lock-class. It is possible to do the same thing without an ifdef.
With this patch (in debug case) we first use the "default" lock class which is later overwritten to the supplied one. Without lockdep the set name/class function vanishes.

How exactly did kbuild test robot figure this out?

At least according to the source there doesn't seem to be clarity about what is the right thing to do, this being just one option.

Regards, Joonas

Quoted 14 lines

+++ b/drivers/gpu/drm/i915/i915_gem_timeline.c

drivers/gpu/drm/i915/i915_gem_timeline.c +1 -4
@@ -33,11 +33,8 @@ static void __intel_timeline_init(struct
 {
 	tl->fence_context = context;
 	tl->common = parent;
-#ifdef CONFIG_DEBUG_SPINLOCK
-	__raw_spin_lock_init(&tl->lock.rlock, lockname, lockclass);
-#else
 	spin_lock_init(&tl->lock);
-#endif
+	lockdep_set_class_and_name(&tl->lock, lockclass, lockname);
 	init_request_active(&tl->last_request, NULL);
 	INIT_LIST_HEAD(&tl->requests);
 	i915_syncmap_init(&tl->sync);
Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 11 lines · Joonas Lahtinen
Quoted 8 lines · Sebastian Andrzej Siewior

The code has an ifdef and uses two functions to either init the bare spinlock or init it and set a lock-class. It is possible to do the same thing without an ifdef.
With this patch (in debug case) we first use the "default" lock class which is later overwritten to the supplied one. Without lockdep the set name/class function vanishes.

How exactly did kbuild test robot figure this out?

I fixed it up for RT, then robot found a way to complain about it. Then I slapped myself for not submitting this patch in the first place.

Quoted 2 lines

At least according to the source there doesn't seem to be clarity about what is the right thing to do, this being just one option.

I don' think `ifdef CONFIG_DEBUG_SPINLOCK' is an option. Especially since the i915 driver here is the only user in tree doing this kind of thing.
Then we have lockdep_set_class_and_name() (which I promote here). This looks like the official way of doing lockdep related things and it has even more than ten users in tree.

Quoted 1 line

Regards, Joonas

Sebastian
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#4 lore raw
Quoted 9 lines · Sebastian Andrzej Siewior
Quoted 8 lines · Joonas Lahtinen
Quoted 7 lines · Sebastian Andrzej Siewior

The code has an ifdef and uses two functions to either init the bare spinlock or init it and set a lock-class. It is possible to do the same thing without an ifdef.
With this patch (in debug case) we first use the "default" lock class which is later overwritten to the supplied one. Without lockdep the set name/class function vanishes.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

How exactly did kbuild test robot figure this out?

I fixed it up for RT, then robot found a way to complain about it. Then I slapped myself for not submitting this patch in the first place.

Right, I was kinda wondering if the robot has gained consciuousness and is developing new checks...

Quoted 9 lines
Quoted 2 lines

At least according to the source there doesn't seem to be clarity about what is the right thing to do, this being just one option.

I don' think `ifdef CONFIG_DEBUG_SPINLOCK' is an option. Especially since the i915 driver here is the only user in tree doing this kind of thing.
Then we have lockdep_set_class_and_name() (which I promote here). This looks like the official way of doing lockdep related things and it has even more than ten users in tree.

I think it be worthwhile to suggest would be the addition of __spin_lock_init where you can pass in the the lockclass and name.

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

+peterz
context: http://www.spinics.net/lists/intel-gfx/msg149011.html

Quoted 9 lines · Joonas Lahtinen
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 7 lines · Joonas Lahtinen
Quoted 6 lines · Sebastian Andrzej Siewior

The code has an ifdef and uses two functions to either init the bare spinlock or init it and set a lock-class. It is possible to do the same thing without an ifdef.
With this patch (in debug case) we first use the "default" lock class which is later overwritten to the supplied one. Without lockdep the set name/class function vanishes.

…

Quoted 10 lines
Quoted 9 lines
Quoted 2 lines

At least according to the source there doesn't seem to be clarity about what is the right thing to do, this being just one option.

I don' think `ifdef CONFIG_DEBUG_SPINLOCK' is an option. Especially since the i915 driver here is the only user in tree doing this kind of thing.
Then we have lockdep_set_class_and_name() (which I promote here). This looks like the official way of doing lockdep related things and it has even more than ten users in tree.

Quoted 2 lines

I think it be worthwhile to suggest would be the addition of __spin_lock_init where you can pass in the the lockclass and name.

I don't due to the existing interface. However I don't call the shots here and added peterz instead :)

Quoted 1 line

Regards, Joonas

Sebastian
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw
Quoted 6 lines · Sebastian Andrzej Siewior

+peterz
context: http://www.spinics.net/lists/intel-gfx/msg149011.html

Quoted 2 lines · Joonas Lahtinen
Quoted 1 line · Sebastian Andrzej Siewior

On 2017-12-13 16:00:49 [+0200], Joonas Lahtinen wrote:

Quoted 10 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Sebastian Andrzej Siewior
Quoted 6 lines

The code has an ifdef and uses two functions to either init the bare spinlock or init it and set a lock-class. It is possible to do the same thing without an ifdef.
With this patch (in debug case) we first use the "default" lock class which is later overwritten to the supplied one. Without lockdep the set name/class function vanishes.

…

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

At least according to the source there doesn't seem to be clarity about what is the right thing to do, this being just one option.

The proposed patch is definitely the right thing to do. The fact that it doesn't require #ifdef is a very big clue.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx