Skip to content

Commit 69afef4

Browse files
committed
Merge tag 'gpio-updates-for-v6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio updates from Bartosz Golaszewski: "The biggest feature is the locking overhaul. Up until now the synchronization in the GPIO subsystem was broken. There was a single spinlock "protecting" multiple data structures but doing it wrong (as evidenced by several places where it would be released when a sleeping function was called and then reacquired without checking the protected state). We tried to use an RW semaphore before but the main issue with GPIO is that we have drivers implementing the interfaces in both sleeping and non-sleeping ways as well as user-facing interfaces that can be called both from process as well as atomic contexts. Both ends converge in the same code paths that can use neither spinlocks nor mutexes. The only reasonable way out is to use SRCU and go mostly lockless. To that end: we add several SRCU structs in relevant places and use them to assure consistency between API calls together with atomic reads and writes of GPIO descriptor flags where it makes sense. This code has spent several weeks in next and has received several fixes in the first week or two after which it stabilized nicely. The GPIO subsystem is now resilient to providers being suddenly unbound. We managed to also remove the existing character device RW semaphore and the obsolete global spinlock. Other than the locking rework we have one new driver (for Chromebook EC), much appreciated documentation improvements from Kent and the regular driver improvements, DT-bindings updates and GPIOLIB core tweaks. Serialization rework: - use SRCU to serialize access to the global GPIO device list, to GPIO device structs themselves and to GPIO descriptors - make the GPIO subsystem resilient to the GPIO providers being unbound while the API calls are in progress - don't dereference the SRCU-protected chip pointer if the information we need can be obtained from the GPIO device structure - move some of the information contained in struct gpio_chip to struct gpio_device to further reduce the need to dereference the former - pass the GPIO device struct instead of the GPIO chip to sysfs callback to, again, reduce the need for accessing the latter - get GPIO descriptors from the GPIO device, not from the chip for the same reason - allow for mostly lockless operation of the GPIO driver API: assure consistency with SRCU and atomic operations - remove the global GPIO spinlock - remove the character device RW semaphore Core GPIOLIB: - constify pointers in GPIO API where applicable - unify the GPIO counting APIs for ACPI and OF - provide a macro for iterating over all GPIOs, not only the ones that are requested - remove leftover typedefs - pass the consumer device to GPIO core in devm_fwnode_gpiod_get_index() for improved logging - constify the GPIO bus type - don't warn about removing GPIO chips with descriptors still held by users as we can now handle this situation gracefully - remove unused logging helpers - unexport functions that are only used internally in the GPIO subsystem - set the device type (assign the relevant struct device_type) for GPIO devices New drivers: - add the ChromeOS EC GPIO driver Driver improvements: - allow building gpio-vf610 with COMPILE_TEST as well as disabling it in menuconfig (before it was always built for i.MX cofigs) - count the number of EICs using the device properties instead of hard-coding it in gpio-eic-sprd - improve the device naming, extend the debugfs output and add lockdep asserts to gpio-sim DT bindings: - document the 'label' property for gpio-pca9570 - convert aspeed,ast2400-gpio bindings to DT schema - disallow unevaluated properties for gpio-mvebu - document a new model in renesas,rcar-gpio Documentation: - improve the character device kerneldocs in user-space headers - add proper documentation for the character device uAPI (both v1 and v2) - move the sysfs and gpio-mockup docs into the "obsolete" section - improve naming consistency for GPIO terms - clarify the line values description for sysfs - minor docs improvements - improve the driver API contract for setting GPIO direction - mark unsafe APIs as deprecated in kerneldocs and suggest replacements Other: - remove an obsolete test from selftests" * tag 'gpio-updates-for-v6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (79 commits) gpio: sysfs: repair export returning -EPERM on 1st attempt selftest: gpio: remove obsolete gpio-mockup test gpiolib: Deduplicate cleanup for-loop in gpiochip_add_data_with_key() dt-bindings: gpio: aspeed,ast2400-gpio: Convert to DT schema gpio: acpi: Make acpi_gpio_count() take firmware node as a parameter gpio: of: Make of_gpio_get_count() take firmware node as a parameter gpiolib: Pass consumer device through to core in devm_fwnode_gpiod_get_index() gpio: sim: use for_each_hwgpio() gpio: provide for_each_hwgpio() gpio: don't warn about removing GPIO chips with active users anymore gpio: sim: delimit the fwnode name with a ":" when generating labels gpio: sim: add lockdep asserts gpio: Add ChromeOS EC GPIO driver gpio: constify of_phandle_args in of_find_gpio_device_by_xlate() gpio: fix memory leak in gpiod_request_commit() gpio: constify opaque pointer "data" in gpio_device_find() gpio: cdev: fix a NULL-pointer dereference with DEBUG enabled gpio: uapi: clarify default_values being logical gpio: sysfs: fix inverted pointer logic gpio: don't let lockdep complain about inherently dangerous RCU usage ...
2 parents 6cdebf6 + 8636f19 commit 69afef4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2992
-770
lines changed

Documentation/ABI/obsolete/sysfs-gpio

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ Description:
2828
/label ... (r/o) descriptive, not necessarily unique
2929
/ngpio ... (r/o) number of GPIOs; numbered N to N + (ngpio - 1)
3030

31-
This ABI is deprecated and will be removed after 2020. It is
32-
replaced with the GPIO character device.
31+
This ABI is obsoleted by Documentation/ABI/testing/gpio-cdev and will be
32+
removed after 2020.

Documentation/ABI/testing/gpio-cdev

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ Description:
66
The character device files /dev/gpiochip* are the interface
77
between GPIO chips and userspace.
88

9-
The ioctl(2)-based ABI is defined and documented in
10-
[include/uapi]<linux/gpio.h>.
9+
The ioctl(2)-based ABI is defined in
10+
[include/uapi]<linux/gpio.h> and documented in
11+
Documentation/userspace-api/gpio/chardev.rst.
1112

1213
The following file operations are supported:
1314

@@ -17,8 +18,8 @@ Description:
1718
ioctl(2)
1819
Initiate various actions.
1920

20-
See the inline documentation in [include/uapi]<linux/gpio.h>
21-
for descriptions of all ioctls.
21+
See Documentation/userspace-api/gpio/chardev.rst
22+
for a description of all ioctls.
2223

2324
close(2)
2425
Stops and free up the I/O contexts that was associated

Documentation/admin-guide/gpio/gpio-mockup.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
GPIO Testing Driver
44
===================
55

6+
.. note::
7+
8+
This module has been obsoleted by the more flexible gpio-sim.rst.
9+
New developments should use that API and existing developments are
10+
encouraged to migrate as soon as possible.
11+
This module will continue to be maintained but no new features will be
12+
added.
13+
614
The GPIO Testing Driver (gpio-mockup) provides a way to create simulated GPIO
715
chips for testing purposes. The lines exposed by these chips can be accessed
816
using the standard GPIO character device interface as well as manipulated

Documentation/admin-guide/gpio/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
.. SPDX-License-Identifier: GPL-2.0
22
33
====
4-
gpio
4+
GPIO
55
====
66

77
.. toctree::
88
:maxdepth: 1
99

10+
Character Device Userspace API <../../userspace-api/gpio/chardev>
1011
gpio-aggregator
11-
sysfs
12-
gpio-mockup
1312
gpio-sim
13+
Obsolete APIs <obsolete>
1414

1515
.. only:: subproject and html
1616

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
==================
4+
Obsolete GPIO APIs
5+
==================
6+
7+
.. toctree::
8+
:maxdepth: 1
9+
10+
Character Device Userspace API (v1) <../../userspace-api/gpio/chardev_v1>
11+
Sysfs Interface <../../userspace-api/gpio/sysfs>
12+
Mockup Testing Module <gpio-mockup>
13+
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/gpio/aspeed,ast2400-gpio.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Aspeed GPIO controller
8+
9+
maintainers:
10+
- Andrew Jeffery <andrew@codeconstruct.com.au>
11+
12+
properties:
13+
compatible:
14+
enum:
15+
- aspeed,ast2400-gpio
16+
- aspeed,ast2500-gpio
17+
- aspeed,ast2600-gpio
18+
19+
reg:
20+
maxItems: 1
21+
22+
clocks:
23+
maxItems: 1
24+
description: The clock to use for debounce timings
25+
26+
gpio-controller: true
27+
gpio-line-names:
28+
minItems: 36
29+
maxItems: 232
30+
31+
gpio-ranges: true
32+
33+
"#gpio-cells":
34+
const: 2
35+
36+
interrupts:
37+
maxItems: 1
38+
39+
interrupt-controller: true
40+
41+
"#interrupt-cells":
42+
const: 2
43+
44+
ngpios:
45+
minimum: 36
46+
maximum: 232
47+
48+
required:
49+
- compatible
50+
- reg
51+
- interrupts
52+
- interrupt-controller
53+
- "#interrupt-cells"
54+
- gpio-controller
55+
- "#gpio-cells"
56+
57+
allOf:
58+
- if:
59+
properties:
60+
compatible:
61+
contains:
62+
const: aspeed,ast2400-gpio
63+
then:
64+
properties:
65+
gpio-line-names:
66+
minItems: 220
67+
maxItems: 220
68+
ngpios:
69+
const: 220
70+
- if:
71+
properties:
72+
compatible:
73+
contains:
74+
const: aspeed,ast2500-gpio
75+
then:
76+
properties:
77+
gpio-line-names:
78+
minItems: 232
79+
maxItems: 232
80+
ngpios:
81+
const: 232
82+
- if:
83+
properties:
84+
compatible:
85+
contains:
86+
const: aspeed,ast2600-gpio
87+
then:
88+
properties:
89+
gpio-line-names:
90+
minItems: 36
91+
maxItems: 208
92+
ngpios:
93+
enum: [ 36, 208 ]
94+
required:
95+
- ngpios
96+
97+
additionalProperties: false
98+
99+
examples:
100+
- |
101+
gpio@1e780000 {
102+
compatible = "aspeed,ast2400-gpio";
103+
reg = <0x1e780000 0x1000>;
104+
interrupts = <20>;
105+
interrupt-controller;
106+
#interrupt-cells = <2>;
107+
gpio-controller;
108+
#gpio-cells = <2>;
109+
};
110+
- |
111+
gpio: gpio@1e780000 {
112+
compatible = "aspeed,ast2500-gpio";
113+
reg = <0x1e780000 0x200>;
114+
interrupts = <20>;
115+
interrupt-controller;
116+
#interrupt-cells = <2>;
117+
gpio-controller;
118+
#gpio-cells = <2>;
119+
gpio-ranges = <&pinctrl 0 0 232>;
120+
};
121+
- |
122+
#include <dt-bindings/clock/ast2600-clock.h>
123+
#include <dt-bindings/interrupt-controller/arm-gic.h>
124+
#include <dt-bindings/interrupt-controller/irq.h>
125+
gpio0: gpio@1e780000 {
126+
compatible = "aspeed,ast2600-gpio";
127+
reg = <0x1e780000 0x400>;
128+
clocks = <&syscon ASPEED_CLK_APB2>;
129+
interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
130+
interrupt-controller;
131+
#interrupt-cells = <2>;
132+
#gpio-cells = <2>;
133+
gpio-controller;
134+
gpio-ranges = <&pinctrl 0 0 208>;
135+
ngpios = <208>;
136+
};
137+
gpio1: gpio@1e780800 {
138+
compatible = "aspeed,ast2600-gpio";
139+
reg = <0x1e780800 0x800>;
140+
clocks = <&syscon ASPEED_CLK_APB1>;
141+
interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>;
142+
interrupt-controller;
143+
#interrupt-cells = <2>;
144+
gpio-controller;
145+
#gpio-cells = <2>;
146+
gpio-ranges = <&pinctrl 0 208 36>;
147+
ngpios = <36>;
148+
};

Documentation/devicetree/bindings/gpio/gpio-aspeed.txt

Lines changed: 0 additions & 39 deletions
This file was deleted.

Documentation/devicetree/bindings/gpio/gpio-mvebu.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ allOf:
115115
required:
116116
- reg
117117

118-
unevaluatedProperties: true
118+
unevaluatedProperties: false
119119

120120
examples:
121121
- |

Documentation/devicetree/bindings/gpio/gpio-pca9570.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ properties:
2828
minItems: 4
2929
maxItems: 8
3030

31+
label:
32+
description: A descriptive name for this device.
33+
3134
required:
3235
- compatible
3336
- reg

Documentation/devicetree/bindings/gpio/renesas,rcar-gpio.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ properties:
5353
- renesas,gpio-r8a779a0 # R-Car V3U
5454
- renesas,gpio-r8a779f0 # R-Car S4-8
5555
- renesas,gpio-r8a779g0 # R-Car V4H
56+
- renesas,gpio-r8a779h0 # R-Car V4M
5657
- const: renesas,rcar-gen4-gpio # R-Car Gen4
5758

5859
reg:

0 commit comments

Comments
 (0)