Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1683666 > unrolled thread
| Started by | Grygorii Strashko <grygorii.strashko@ti.com> |
|---|---|
| First post | 2017-07-09 00:50 +0200 |
| Last post | 2017-07-09 00:50 +0200 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
[RFC/RFT PATCH 0/3] gpiolib: make gpio irqchip compatible with sparse_irq Grygorii Strashko <grygorii.strashko@ti.com> - 2017-07-09 00:50 +0200
[RFC/RFT PATCH 2/3] gpio: pxa: remove gpio_to_irq() from hw irq handlers Grygorii Strashko <grygorii.strashko@ti.com> - 2017-07-09 00:50 +0200
| From | Grygorii Strashko <grygorii.strashko@ti.com> |
|---|---|
| Date | 2017-07-09 00:50 +0200 |
| Subject | [RFC/RFT PATCH 0/3] gpiolib: make gpio irqchip compatible with sparse_irq |
| Message-ID | <u16I2-840-11@gated-at.bofh.it> |
The idea of this changes was inspired by discussion [1]. Now IRQ mappings are always created for all (allowed) GPIOs in GPIO irqchip in gpiochip_irqchip_add_key() and this goes against the idea of SPARSE_IRQ and, as result, leads to: - increasing of memory consumption because of allocated IRQ descriptors most of which will never ever be used (especially on platform with a high number of GPIOs). - imposibility to use GPIO irqchip APIs by gpio drivers when HW implements GPIO IRQ functionality as IRQ crossbar/multiplexer which has only limited number of IRQ outputs (example from [1], all GPIOs can be mapped on only 8 IRQs). Hence, remove static IRQ mapping code from gpiochip_irqchip_add_key() and instead replace irq_find_mapping() with irq_create_mapping() in gpiochip_to_irq(). Also add additional gpiochip_irqchip_irq_valid() calls in gpiochip_to_irq() and gpiochip_irq_map(). After this change gpio2irq mapping will happen the following way when GPIO irqchip APIs are used by gpio driver: - IRQ mappings will be created statically if driver passes first_irq>0 vlaue in gpiochip_irqchip_add_key(). - IRQ mappings will be created dynamically from gpio_to_irq() or of_irq_get(). Tested on am335x-evm and dra72-evm-revc. - dra72-evm-revc: number of created irq mappings decreased from 402 -> 135 - am335x-evm: number of created irq mappings decreased from 188 -> 63 It's good to have more testing feedbacks for these patches (personally I do not expect regressions, but who knows). One possible side effect is "Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n" message during boot, but in this case it might be good to take a look on such GPIO drivers to understand why they need to allocate IRQ descriptors. [1] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1435847.html Grygorii Strashko (3): gpio: tegra: remove gpio_to_irq() from hw irq handlers gpio: pxa: remove gpio_to_irq() from hw irq handlers gpiolib: make gpio irqchip compatible with sparse_irq drivers/gpio/gpio-pxa.c | 8 +++++--- drivers/gpio/gpio-tegra.c | 3 ++- drivers/gpio/gpiolib.c | 29 ++++++----------------------- include/linux/gpio/driver.h | 1 - 4 files changed, 13 insertions(+), 28 deletions(-) -- 2.10.1
[toc] | [next] | [standalone]
| From | Grygorii Strashko <grygorii.strashko@ti.com> |
|---|---|
| Date | 2017-07-09 00:50 +0200 |
| Subject | [RFC/RFT PATCH 2/3] gpio: pxa: remove gpio_to_irq() from hw irq handlers |
| Message-ID | <u16I3-840-17@gated-at.bofh.it> |
| In reply to | #1683666 |
gpio_to_irq() API expected to be used by GPIO consumers and
not drivers and there are no guarantee that its gpiolib implementation
is irq safe.
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
drivers/gpio/gpio-pxa.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 832f3e4..6029899 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -451,7 +451,9 @@ static irqreturn_t pxa_gpio_demux_handler(int in_irq, void *d)
for_each_set_bit(n, &gedr, BITS_PER_LONG) {
loop = 1;
- generic_handle_irq(gpio_to_irq(gpio + n));
+ generic_handle_irq(
+ irq_find_mapping(pchip->irqdomain,
+ gpio + n));
}
}
handled += loop;
@@ -465,9 +467,9 @@ static irqreturn_t pxa_gpio_direct_handler(int in_irq, void *d)
struct pxa_gpio_chip *pchip = d;
if (in_irq == pchip->irq0) {
- generic_handle_irq(gpio_to_irq(0));
+ generic_handle_irq(irq_find_mapping(pchip->irqdomain, 0));
} else if (in_irq == pchip->irq1) {
- generic_handle_irq(gpio_to_irq(1));
+ generic_handle_irq(irq_find_mapping(pchip->irqdomain, 1));
} else {
pr_err("%s() unknown irq %d\n", __func__, in_irq);
return IRQ_NONE;
--
2.10.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web