[4.4-rc7 / vmwgfx] debugging bug or driver bug?

Tetsuo Handa penguin-kernel at I-love.SAKURA.ne.jp
Fri Jan 1 06:04:20 PST 2016


Thomas Hellstrom wrote:
> Most likely the spin_is_locked() function is not working on non - SMP
> systems (well how could it?). An oversight from my side.

You are right. I found a description in Documentation/scsi/ChangeLog.megaraid .

        there are several checks present in the kernel
        where somebody does a variation on the following:

          BUG_ON(!spin_is_locked(&some_lock));

        so what's wrong about that? nothing, unless you
        compile the code with CONFIG_DEBUG_SPINLOCK but
        without CONFIG_SMP ... in which case the BUG()
        will kill your kernel ...

> We should change the BUG_ON line to a lockdep_assert_held().

static __always_inline int spin_is_locked(spinlock_t *lock)
{
	return raw_spin_is_locked(&lock->rlock);
}

#define raw_spin_is_locked(lock)        arch_spin_is_locked(&(lock)->raw_lock)

include/linux/spinlock_up.h: /* !DEBUG_SPINLOCK */
#define arch_spin_is_locked(lock)       ((void)(lock), 0)

So, BUG_ON(!spin_is_locked(&man->lock)) was BUG_ON(!0) in my config, and
below change fixed this problem.

Regards.

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
index 6377e81..4d26de4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
@@ -247,7 +247,7 @@ static void __vmw_cmdbuf_header_free(struct vmw_cmdbuf_header *header)
 {
 	struct vmw_cmdbuf_man *man = header->man;
 
-	BUG_ON(!spin_is_locked(&man->lock));
+	lockdep_assert_held(&man->lock);
 
 	if (header->inline_space) {
 		vmw_cmdbuf_header_inline_free(header);


More information about the dri-devel mailing list