]> git.baikalelectronics.ru Git - kernel.git/commit
drm/vc4: Fix false positive WARN() backtrace on refcount_inc() usage
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Wed, 22 Nov 2017 20:39:28 +0000 (21:39 +0100)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Thu, 7 Dec 2017 09:09:43 +0000 (10:09 +0100)
commit0a67f06b8feb07f46d605138b648173accfbcb0f
treeda22b7b17e48e2e21c4de7305d8aba870407e612
parente1f7ca9fa6500dea7abd223fa548569c81ef1462
drm/vc4: Fix false positive WARN() backtrace on refcount_inc() usage

With CONFIG_REFCOUNT_FULL enabled, refcount_inc() complains when it's
passed a refcount object that has its counter set to 0. In this driver,
this is a valid use case since we want to increment ->usecnt only when
the BO object starts to be used by real HW components and this is
definitely not the case when the BO is created.

Fix the problem by using refcount_inc_not_zero() instead of
refcount_inc() and fallback to refcount_set(1) when
refcount_inc_not_zero() returns false. Note that this 2-steps operation
is not racy here because the whole section is protected by a mutex
which guarantees that the counter does not change between the
refcount_inc_not_zero() and refcount_set() calls.

Fixes: 8943349f4512 ("drm/vc4: Add the DRM_IOCTL_VC4_GEM_MADVISE ioctl")
Reported-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20171122203928.28135-1-boris.brezillon@free-electrons.com
drivers/gpu/drm/vc4/vc4_bo.c