[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=Md40TPhTq7jwWQz8HmCJEZc4ixmjqhVjbcNzo1e6zwHNg@mail.gmail.com>
Date: Tue, 13 Feb 2024 16:05:51 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Linus Walleij <linus.walleij@...aro.org>, Kent Gibson <warthog618@...il.com>,
Alex Elder <elder@...aro.org>, Geert Uytterhoeven <geert+renesas@...der.be>,
"Paul E . McKenney" <paulmck@...nel.org>, Wolfram Sang <wsa@...-dreams.de>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH] gpio: initialize descriptor SRCU structure before adding
OF-based chips
On Tue, Feb 13, 2024 at 3:43 PM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Mon, Feb 12, 2024 at 10:39:20PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> >
> > In certain situations we may end up taking the GPIO descriptor SRCU read
> > lock in of_gpiochip_add() before the SRCU struct is initialized. Move
> > the initialization before the call to of_gpiochip_add().
>
> ...
>
> This is a bit unclear why you moved to that place and how it had been tested.
>
I didn't move it, I just added SRCU before it. It can be triggered by
a simple hog from DT. The link leads to a crash report.
> > @@ -991,10 +991,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
> > if (ret)
> > goto err_cleanup_gdev_srcu;
> >
> > - ret = of_gpiochip_add(gc);
> > - if (ret)
> > - goto err_free_gpiochip_mask;
> > -
> > for (i = 0; i < gc->ngpio; i++) {
> > struct gpio_desc *desc = &gdev->descs[i];
> >
>
> > if (ret) {
> > for (j = 0; j < i; j++)
> > cleanup_srcu_struct(&gdev->descs[j].srcu);
> > - goto err_remove_of_chip;
> > + goto err_free_gpiochip_mask;
> > }
> >
> > if (gc->get_direction && gpiochip_line_is_valid(gc, i)) {
>
> > }
> > }
> >
> > - ret = gpiochip_add_pin_ranges(gc);
> > + ret = of_gpiochip_add(gc);
> > if (ret)
> > goto err_cleanup_desc_srcu;
> >
> > + ret = gpiochip_add_pin_ranges(gc);
> > + if (ret)
> > + goto err_remove_of_chip;
> > +
> > acpi_gpiochip_add(gc);
>
> My logic tells me that if you need to call gpiochip_add_pin_ranges() before
> calling of_gpiochip_add(). It won't collide right now, but allows to cleanup
> further (with the gpio-ranges parser be generalized for fwnodes and be moved
> to gpiolib.c from gpiolib-of.c).
>
But it was already called before gpiochip_add_pin_ranges() so it's
material for another patch.
Bart
> --
> With Best Regards,
> Andy Shevchenko
>
>
Powered by blists - more mailing lists