lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 28 Feb 2020 23:32:57 +0100
From:   Linus Walleij <linus.walleij@...aro.org>
To:     Bartosz Golaszewski <brgl@...ev.pl>
Cc:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        Khouloud Touil <ktouil@...libre.com>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: Re: [PATCH v5 3/5] gpiolib: use kref in gpio_desc

On Fri, Feb 21, 2020 at 4:48 PM Bartosz Golaszewski <brgl@...ev.pl> wrote:

> From: Bartosz Golaszewski <bgolaszewski@...libre.com>
>
> GPIO descriptors are freed by consumers using gpiod_put(). The name of
> this function suggests some reference counting is going on but it's not
> true.
>
> Use kref to actually introduce reference counting for gpio_desc objects.
> Add a corresponding gpiod_get() helper for increasing the reference count.
>
> This doesn't change anything for already existing (correct) drivers but
> allows us to keep track of GPIO descs used by multiple users.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>

I'm having some trouble figuring out if we might be reinventing
a wheel here.

A while back there was a proposed patch to add device links
between GPIO producers and consumers, so that a GPIO
chip won't be dropped while there are active consumers.

(I don't remember who sent the patch.)

We have a similar functionality in pin control if the
.link_consumers property is set on the pincontrol device.
I was thinking about making that compulsory at one point.

The device links use a kref already existing in struct
device and would in this case be the kref in the struct
device for the struct gpio_device.

So if that existed, gpiod_ref could just grab another
device_link_add().

Maybe we should just add device links between all
GPIO consumers (devices) and struct gpio_device:s
struct device and implement it like this so we don't
have to back out of this later?

C.f. commit
commit 036f394dd77f8117346874151793ec38967d843f
pinctrl: Enable device link creation for pin control

(...)
> @@ -81,6 +81,7 @@ struct gpio_descs *__must_check gpiod_get_array(struct device *dev,
>  struct gpio_descs *__must_check gpiod_get_array_optional(struct device *dev,
>                                                         const char *con_id,
>                                                         enum gpiod_flags flags);
> +struct gpio_desc *gpiod_ref(struct gpio_desc *desc);
>  void gpiod_put(struct gpio_desc *desc);
>  void gpiod_put_array(struct gpio_descs *descs);

You forgot to add a stub for the case where GPIOLIB is not
compiled in I think? (Lower in the same file.)

Yours,
Linus Walleij

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ