diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-10-27 06:13:18 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-10-27 06:13:18 -0400 |
commit | 4aa50b87f1e99164a93314c25ed3a827c24bc54f (patch) | |
tree | 296767a2be34402387aa2e24a99737cf2f300eb1 /Documentation/gpio/driver.txt | |
parent | 1ceacea220c36e7933216e79b0ca21e1318b7c8d (diff) |
Revert "gpio: add a real time compliance checklist"
This reverts commit 677b2ff4afd9996eabefc9472c701211b4b49e87.
Diffstat (limited to 'Documentation/gpio/driver.txt')
-rw-r--r-- | Documentation/gpio/driver.txt | 72 |
1 files changed, 12 insertions, 60 deletions
diff --git a/Documentation/gpio/driver.txt b/Documentation/gpio/driver.txt index 9d7985171f07..90d0f6aba7a6 100644 --- a/Documentation/gpio/driver.txt +++ b/Documentation/gpio/driver.txt | |||
@@ -93,37 +93,22 @@ GPIO irqchips usually fall in one of two categories: | |||
93 | Chained GPIO irqchips typically can NOT set the .can_sleep flag on | 93 | Chained GPIO irqchips typically can NOT set the .can_sleep flag on |
94 | struct gpio_chip, as everything happens directly in the callbacks. | 94 | struct gpio_chip, as everything happens directly in the callbacks. |
95 | 95 | ||
96 | NOTE: chained IRQ handlers are usually not good for real time. If you | 96 | * NESTED THREADED GPIO irqchips: these are off-chip GPIO expanders and any |
97 | are submitting a new driver or refactoring a driver for real time compliance, | 97 | other GPIO irqchip residing on the other side of a sleeping bus. Of course |
98 | consider using creating a nested/threaded irqchip instead, see below. | 98 | such drivers that need slow bus traffic to read out IRQ status and similar, |
99 | 99 | traffic which may in turn incur other IRQs to happen, cannot be handled | |
100 | * NESTED THREADED GPIO irqchips: these are traditionally off-chip GPIO | 100 | in a quick IRQ handler with IRQs disabled. Instead they need to spawn a |
101 | expanders and any other GPIO irqchip residing on the other side of a | 101 | thread and then mask the parent IRQ line until the interrupt is handled |
102 | sleeping bus. Of course such drivers that need slow bus traffic to read | 102 | by the driver. The hallmark of this driver is to call something like |
103 | out IRQ status and similar, traffic which may in turn incur other IRQs to | 103 | this in its interrupt handler: |
104 | happen, cannot be handled in a quick IRQ handler with IRQs disabled. | ||
105 | |||
106 | With the introduction of real time support in the Linux kernel, also other | ||
107 | GPIO irqchips are encouraged to use a nested and threaded IRQ handler. | ||
108 | Doing so makes the interrupts naturally preemptible on a real time | ||
109 | setup, which means the system can easily be configured for real time with | ||
110 | a (usually negligable) performance loss. | ||
111 | |||
112 | These drivers spawn a thread and then mask the parent IRQ line until the | ||
113 | interrupt is handled by the driver. The hallmark of this driver is to call | ||
114 | something like this in its interrupt handler: | ||
115 | 104 | ||
116 | static irqreturn_t tc3589x_gpio_irq(int irq, void *data) | 105 | static irqreturn_t tc3589x_gpio_irq(int irq, void *data) |
117 | ... | 106 | ... |
118 | handle_nested_irq(irq); | 107 | handle_nested_irq(irq); |
119 | OR | ||
120 | generic_handle_irq(irq); | ||
121 | 108 | ||
122 | Threaded GPIO irqchips should set the .can_sleep flag on struct gpio_chip | 109 | The hallmark of threaded GPIO irqchips is that they set the .can_sleep |
123 | to true if they are e.g. accessing the chip over I2C or SPI, indicating that | 110 | flag on struct gpio_chip to true, indicating that this chip may sleep |
124 | this chip may sleep when accessing the GPIOs. irqchips that are just made | 111 | when accessing the GPIOs. |
125 | threaded to be preemptible and thus real time compliant need not do this: | ||
126 | preemption is not sleeping. | ||
127 | 112 | ||
128 | To help out in handling the set-up and management of GPIO irqchips and the | 113 | To help out in handling the set-up and management of GPIO irqchips and the |
129 | associated irqdomain and resource allocation callbacks, the gpiolib has | 114 | associated irqdomain and resource allocation callbacks, the gpiolib has |
@@ -140,7 +125,7 @@ symbol: | |||
140 | gpio_chip from a parent IRQ and passes the struct gpio_chip* as handler | 125 | gpio_chip from a parent IRQ and passes the struct gpio_chip* as handler |
141 | data. (Notice handler data, since the irqchip data is likely used by the | 126 | data. (Notice handler data, since the irqchip data is likely used by the |
142 | parent irqchip!) This is for the chained type of chip. This is also used | 127 | parent irqchip!) This is for the chained type of chip. This is also used |
143 | to set up a threaded/nested irqchip if NULL is passed as handler. | 128 | to set up a nested irqchip if NULL is passed as handler. |
144 | 129 | ||
145 | To use the helpers please keep the following in mind: | 130 | To use the helpers please keep the following in mind: |
146 | 131 | ||
@@ -185,39 +170,6 @@ typically be called in the .startup() and .shutdown() callbacks from the | |||
185 | irqchip. | 170 | irqchip. |
186 | 171 | ||
187 | 172 | ||
188 | Real-Time compliance for GPIO IRQ chips | ||
189 | --------------------------------------- | ||
190 | |||
191 | Any provider of irqchips needs to be carefully tailored to support Real Time | ||
192 | preemption. It is desireable that all irqchips in the GPIO subsystem keep this | ||
193 | in mind and does the proper testing to assure they are real time-enabled. The | ||
194 | following is a checklist to follow when preparing a driver for real | ||
195 | time-compliance: | ||
196 | |||
197 | - Nominally use raw_spinlock_t in the IRQ context path of the IRQ handler as | ||
198 | we do not want these sections to be preempted. | ||
199 | |||
200 | - Do NOT use chained_irq_enter() or chained_irq_exit() in the IRQ handler, | ||
201 | as we want the hotpath to be preemptible. | ||
202 | |||
203 | - Instead use nested IRQs and generic handlers such as handle_bad_irq(), | ||
204 | handle_level_irq() and handle_edge_irq(). Consequentally the handler | ||
205 | argument of gpiochip_set_chained_irqchip() should be NULL when using the | ||
206 | gpiolib irqchip helpers. | ||
207 | |||
208 | - Nominally set all handlers to handle_bad_irq() in the setup call, then | ||
209 | set the handler to handle_level_irq() and/or handle_edge_irq() in the irqchip | ||
210 | .set_type() callback depending on what your controller supports. | ||
211 | |||
212 | - If you need to use the pm_runtime_get*()/pm_runtime_put*() callbacks in some | ||
213 | of the irqchip callbacks, these should be moved to the .irq_bus_lock() | ||
214 | and .irq_bus_unlock() callbacks respectively, as these are the only | ||
215 | slowpath callbacks on an irqchip. Create the callbacks if need be. | ||
216 | |||
217 | - Test your driver with the apropriate in-kernel real time test cases for both | ||
218 | level and edge IRQs. | ||
219 | |||
220 | |||
221 | Requesting self-owned GPIO pins | 173 | Requesting self-owned GPIO pins |
222 | ------------------------------- | 174 | ------------------------------- |
223 | 175 | ||