gpiolib: work towards removing gpiochip_find()
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest11 patches 13 repliesIn review
- v311 patches 12 repliesSuperseded
- v211 patches 12 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 21 patches | 65 replies | Superseded |
Changes in v4 from the cover letter
- initialize managed pointers when declaring them
- drop unneeded casting
- collect more tags
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/11 | gpiolib: make gpio_device_get() and gpio_device_put() publicdrivers/ drivers/ include/ | +27 | 1 reply | |
| 2/11 | gpiolib: add support for scope-based management to gpio_deviceinclude/ | +5 | 1 reply | |
| 3/11 | gpiolib: provide gpio_device_find()drivers/ include/ | +56 | 4 replies | |
| 4/11 | gpiolib: provide gpio_device_find_by_label()drivers/ include/ | +22 | 3 replies | |
| 5/11 | gpiolib: provide gpio_device_get_desc()drivers/ include/ | +36 | 3 replies | |
| 6/11 | gpiolib: reluctantly provide gpio_device_get_chip()drivers/ include/ | +23 | 0 replies | |
| 7/11 | gpiolib: replace find_chip_by_name() with gpio_device_find_by_label()drivers/ | +11 | 0 replies | |
| 8/11 | gpio: of: replace gpiochip_find_* with gpio_device_find_*drivers/ | +17 | 0 replies | |
| 9/11 | gpio: acpi: replace gpiochip_find() with gpio_device_find()drivers/ | +8 | 0 replies | |
| 10/11 | gpio: swnode: replace gpiochip_find() with gpio_device_find_by_label()drivers/ | +16 | 0 replies | |
| 11/11 | gpio: sysfs: drop the mention of gpiochip_find() from sysfs codedrivers/ | +1 | 0 replies |
Reviews trailers per patch
All 11 patches have a Reviewed-by or Acked-by.
| Patch | Linus Walleij | Mika Westerberg | Andy Shevchenko |
|---|---|---|---|
| 1/11 | R-b | R-b | |
| 2/11 | R-b | R-b | |
| 3/11 | R-b | ||
| 4/11 | R-b | ||
| 5/11 | R-b | ||
| 6/11 | R-b | ||
| 7/11 | R-b | ||
| 8/11 | R-b | ||
| 9/11 | R-b | R-b | |
| 10/11 | R-b | ||
| 11/11 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v4 00/11] gpiolib: work towards removing gpiochip_find()
From: Bartosz Golaszewski <[email protected]>
This is a reduced subset of patches from the initial sumbission[1] limited only to changes inside GPIOLIB. Once this is upstream, we can then slowly merge patches for other subsystems (like HTE) and then eventually remove gpiochip_find() entirely.
The GPIO subsystem does not handle hot-unplug events very well. We have recently patched the user-space part of it so that at least a rouge user cannot crash the kernel but in-kernel users are still affected by a lot of
issues: from incorrect locking or lack thereof to using structures that are private to GPIO drivers. Since almost all GPIO controllers can be unbound, not to mention that we have USB devices registering GPIO expanders as well as I2C-on-USB HID devices on which I2C GPIO expanders can live, various media gadgets etc., we really need to make GPIO hotplug/unplug friendly.
Before we can even get to fixing the locking, we need to address a serious abuse of the GPIO driver API - accessing struct gpio_chip by anyone who isn't the driver owning this object. This structure is owned by the GPIO provider and its lifetime is tied to that of that provider. It is destroyed when the device is unregistered and this may happen at any moment. struct gpio_device is the opaque, reference counted interface to struct gpio_chip (which is the low-level implementation) and all access should pass through it.
The end-goal is to make all gpio_device manipulators check the existence of gdev->chip and then lock it for the duration of any of the calls using SRCU. Before we can get there, we need to first provide a set of functions that will replace any gpio_chip functions and convert all in-kernel users.
This series adds several new helpers to the public GPIO API and uses them across the core GPIO code.
Note that this does not make everything correct just yet. Especially the GPIOLIB internal users release the reference returned by the lookup function after getting the descriptor of interest but before requesting it. This will eventually be addressed. This is not a regression either.
[1] https://lore.kernel.org/lkml/[email protected]/T/
v3 -> v4:
- initialize managed pointers when declaring them
- drop unneeded casting
- collect more tags
v2 -> v3:
- use gpio_device_get_chip() consistently
- clarify comments
- fix buggy chip assignment
- check for PTR_ERR() in automatic cleanup
- rearrange code as requested by Andy
v1 -> v2:
- drop all non-GPIOLIB patches
- collect tags
- fix kernel docs
Bartosz Golaszewski (11):
gpiolib: make gpio_device_get() and gpio_device_put() public
gpiolib: add support for scope-based management to gpio_device
gpiolib: provide gpio_device_find()
gpiolib: provide gpio_device_find_by_label()
gpiolib: provide gpio_device_get_desc()
gpiolib: reluctantly provide gpio_device_get_chip()
gpiolib: replace find_chip_by_name() with gpio_device_find_by_label()
gpio: of: replace gpiochip_find_* with gpio_device_find_*
gpio: acpi: replace gpiochip_find() with gpio_device_find()
gpio: swnode: replace gpiochip_find() with gpio_device_find_by_label()
gpio: sysfs: drop the mention of gpiochip_find() from sysfs code
drivers/gpio/gpiolib-acpi.c | 12 +- drivers/gpio/gpiolib-of.c | 33 +++--- drivers/gpio/gpiolib-swnode.c | 33 +++--- drivers/gpio/gpiolib-sysfs.c | 2 +- drivers/gpio/gpiolib.c | 202 ++++++++++++++++++++++++++-------- drivers/gpio/gpiolib.h | 10 -- include/linux/gpio/driver.h | 16 +++ 7 files changed, 215 insertions(+), 93 deletions(-)
Signature · 1 line
2.39.2