public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Kent Gibson <warthog618@gmail.com>, Alex Elder <elder@linaro.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Wolfram Sang <wsa@the-dreams.de>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] gpio: initialize descriptor SRCU structure before adding OF-based chips
Date: Tue, 13 Feb 2024 16:42:53 +0200	[thread overview]
Message-ID: <Zct_7YcJk5-sg2pT@smile.fi.intel.com> (raw)
In-Reply-To: <20240212213920.49796-1-brgl@bgdev.pl>

On Mon, Feb 12, 2024 at 10:39:20PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.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.

> @@ -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).

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-02-13 14:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 21:39 [PATCH] gpio: initialize descriptor SRCU structure before adding OF-based chips Bartosz Golaszewski
2024-02-13 14:42 ` Andy Shevchenko [this message]
2024-02-13 15:05   ` Bartosz Golaszewski
2024-02-14  8:35 ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zct_7YcJk5-sg2pT@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=elder@linaro.org \
    --cc=geert+renesas@glider.be \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=paulmck@kernel.org \
    --cc=warthog618@gmail.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox