Re: [PATCH v3 22/24] gpio: protect the pointer to gpio_chip in gpio_device with SRCU

From: Bartosz Golaszewski
Date: Tue Feb 13 2024 - 03:11:19 EST


On Mon, Feb 12, 2024 at 10:20 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>

[snip]

> >
> >
> > [ 76.432519][ T1] gpiochip_find_base_unlocked: found new base at 512
> > [ 76.434591][ T1]
> > [ 76.435240][ T1] =============================
> > [ 76.436545][ T1] WARNING: suspicious RCU usage
> > [ 76.437813][ T1] 6.8.0-rc1-00050-gc21131f83abc #1 Tainted: G N
> > [ 76.439873][ T1] -----------------------------
> > [ 76.441158][ T1] drivers/gpio/gpiolib.c:219 suspicious rcu_dereference_check() usage!
> > [ 76.443364][ T1]

[snip]

>
> Paul,
>
> Could you help me out here? It seems that lockdep complains (with
> "suspicious RCU usage") whenever an RCU-protected pointer is passed to
> rcu_dereference() but is not actually dereferenced later - in which
> case switching to rcu_access_pointer() helps. But in the case of the
> of_unittests() it also emits the same warning for
> gpiod_direction_input() where gdev->chip is fetched with
> rcu_dereference() using CLASS(gpio_chip_guard) and later actually
> dereferenced by calling guard.gc->...
>
> Any hints as to what I'm doing wrong?
>
> Thanks,
> Bartosz

Seems like these can be silenced with rcu_dereference_protected() so
I'll use it for now.

Bart