Re: [PATCH 3/4] gpio: pxa: change the interrupt management

2015-12-10 Thread Linus Walleij
On Sat, Nov 28, 2015 at 10:37 PM, Robert Jarzmik  wrote:

> The interrupt management is changed by this patch to rely on chip data
> instead of chained interrupts.
>
> The main goal is to loosen the dependency on the global pxa chip
> structure in favor of the passed chip data. The secondary goal is to
> better show in /proc/interrupts the difference between interrupts for
> gpio0 and gpio1 (directly wired to interrupt controller), and the other
> gpios (wired onto a third line in the interrupt controller).
>
> The last advantage of this patch is that the interrupt is actually
> requested, so that another driver cannot steal this line, or overwrite
> the handler.
>
> Signed-off-by: Robert Jarzmik 

I stopped applying here, waiting for a v2 of the two last
patches.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/4] gpio: pxa: change the interrupt management

2015-12-10 Thread Linus Walleij
On Sat, Nov 28, 2015 at 10:37 PM, Robert Jarzmik  wrote:

> The interrupt management is changed by this patch to rely on chip data
> instead of chained interrupts.
>
> The main goal is to loosen the dependency on the global pxa chip
> structure in favor of the passed chip data. The secondary goal is to
> better show in /proc/interrupts the difference between interrupts for
> gpio0 and gpio1 (directly wired to interrupt controller), and the other
> gpios (wired onto a third line in the interrupt controller).
>
> The last advantage of this patch is that the interrupt is actually
> requested, so that another driver cannot steal this line, or overwrite
> the handler.
>
> Signed-off-by: Robert Jarzmik 

I stopped applying here, waiting for a v2 of the two last
patches.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/4] gpio: pxa: change the interrupt management

2015-11-29 Thread Robert Jarzmik
kbuild test robot  writes:

> Hi Robert,
>
> [auto build test ERROR on: gpio/for-next]
> [also build test ERROR on: v4.4-rc2 next-20151127]
>
> url:
> https://github.com/0day-ci/linux/commits/Robert-Jarzmik/gpio-pxa-integrate-with-pincontrol/20151129-054738
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 
> for-next
> config: arm-pxa910_defconfig (attached as .config)
> reproduce:
> wget 
> https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
>  -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=arm 
>
> All errors (new ones prefixed by >>):
>
>drivers/gpio/gpio-pxa.c: In function 'pxa_gpio_probe':
>>> drivers/gpio/gpio-pxa.c:625:12: error: 'pxa_irq_domain_ops' undeclared 
>>> (first use in this function)
>0, _irq_domain_ops, pchip);
>^
>drivers/gpio/gpio-pxa.c:625:12: note: each undeclared identifier is 
> reported only once for each function it appears in
>drivers/gpio/gpio-pxa.c: At top level:
>drivers/gpio/gpio-pxa.c:500:24: warning: 'pxa_muxed_gpio_chip' defined but 
> not used [-Wunused-variable]
> static struct irq_chip pxa_muxed_gpio_chip = {

Ok, that one is a matter of "#ifdef CONFIG_OF" englobbing pxa_irq_domain_ops and
pxa_irq_domain_map().

Didn't see it as the platform_data based test has CONFIG_OF activated in my
kernel. That will be for v2, and tested without the CONFIG_OF to be sure.

Cheers.

--
Robert
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/4] gpio: pxa: change the interrupt management

2015-11-29 Thread Robert Jarzmik
kbuild test robot  writes:

> Hi Robert,
>
> [auto build test ERROR on: gpio/for-next]
> [also build test ERROR on: v4.4-rc2 next-20151127]
>
> url:
> https://github.com/0day-ci/linux/commits/Robert-Jarzmik/gpio-pxa-integrate-with-pincontrol/20151129-054738
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 
> for-next
> config: arm-pxa910_defconfig (attached as .config)
> reproduce:
> wget 
> https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
>  -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=arm 
>
> All errors (new ones prefixed by >>):
>
>drivers/gpio/gpio-pxa.c: In function 'pxa_gpio_probe':
>>> drivers/gpio/gpio-pxa.c:625:12: error: 'pxa_irq_domain_ops' undeclared 
>>> (first use in this function)
>0, _irq_domain_ops, pchip);
>^
>drivers/gpio/gpio-pxa.c:625:12: note: each undeclared identifier is 
> reported only once for each function it appears in
>drivers/gpio/gpio-pxa.c: At top level:
>drivers/gpio/gpio-pxa.c:500:24: warning: 'pxa_muxed_gpio_chip' defined but 
> not used [-Wunused-variable]
> static struct irq_chip pxa_muxed_gpio_chip = {

Ok, that one is a matter of "#ifdef CONFIG_OF" englobbing pxa_irq_domain_ops and
pxa_irq_domain_map().

Didn't see it as the platform_data based test has CONFIG_OF activated in my
kernel. That will be for v2, and tested without the CONFIG_OF to be sure.

Cheers.

--
Robert
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/4] gpio: pxa: change the interrupt management

2015-11-28 Thread kbuild test robot
Hi Robert,

[auto build test ERROR on: gpio/for-next]
[also build test ERROR on: v4.4-rc2 next-20151127]

url:
https://github.com/0day-ci/linux/commits/Robert-Jarzmik/gpio-pxa-integrate-with-pincontrol/20151129-054738
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 
for-next
config: arm-pxa910_defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/gpio/gpio-pxa.c: In function 'pxa_gpio_probe':
>> drivers/gpio/gpio-pxa.c:625:12: error: 'pxa_irq_domain_ops' undeclared 
>> (first use in this function)
   0, _irq_domain_ops, pchip);
   ^
   drivers/gpio/gpio-pxa.c:625:12: note: each undeclared identifier is reported 
only once for each function it appears in
   drivers/gpio/gpio-pxa.c: At top level:
   drivers/gpio/gpio-pxa.c:500:24: warning: 'pxa_muxed_gpio_chip' defined but 
not used [-Wunused-variable]
static struct irq_chip pxa_muxed_gpio_chip = {
   ^

vim +/pxa_irq_domain_ops +625 drivers/gpio/gpio-pxa.c

   619  
   620  if (!pxa_last_gpio)
   621  return -EINVAL;
   622  
   623  pchip->irqdomain = irq_domain_add_legacy(pdev->dev.of_node,
   624   pxa_last_gpio + 1, 
irq_base,
 > 625   0, 
 > _irq_domain_ops, pchip);
   626  if (IS_ERR(pchip->irqdomain))
   627  return PTR_ERR(pchip->irqdomain);
   628  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH 3/4] gpio: pxa: change the interrupt management

2015-11-28 Thread Robert Jarzmik
The interrupt management is changed by this patch to rely on chip data
instead of chained interrupts.

The main goal is to loosen the dependency on the global pxa chip
structure in favor of the passed chip data. The secondary goal is to
better show in /proc/interrupts the difference between interrupts for
gpio0 and gpio1 (directly wired to interrupt controller), and the other
gpios (wired onto a third line in the interrupt controller).

The last advantage of this patch is that the interrupt is actually
requested, so that another driver cannot steal this line, or overwrite
the handler.

Signed-off-by: Robert Jarzmik 
---
 drivers/gpio/gpio-pxa.c | 145 +++-
 1 file changed, 82 insertions(+), 63 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 8558abf98204..7e02157c5b92 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -64,11 +64,6 @@
 int pxa_last_gpio;
 static int irq_base;
 
-#ifdef CONFIG_OF
-static struct irq_domain *domain;
-static struct device_node *pxa_gpio_of_node;
-#endif
-
 struct pxa_gpio_bank {
void __iomem*regbase;
unsigned long   irq_mask;
@@ -87,6 +82,7 @@ struct pxa_gpio_chip {
struct device *dev;
struct gpio_chip chip;
struct pxa_gpio_bank *banks;
+   struct irq_domain *irqdomain;
 
int irq0;
int irq1;
@@ -231,14 +227,23 @@ static inline int __gpio_is_occupied(struct pxa_gpio_chip 
*pchip, unsigned gpio)
return ret;
 }
 
-static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
+int pxa_irq_to_gpio(int irq)
 {
-   return offset + irq_base;
+   struct pxa_gpio_chip *pchip = pxa_gpio_chip;
+   int irq_gpio0;
+
+   irq_gpio0 = irq_find_mapping(pchip->irqdomain, 0);
+   if (irq_gpio0 > 0)
+   return irq - irq_gpio0;
+
+   return irq_gpio0;
 }
 
-int pxa_irq_to_gpio(int irq)
+static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 {
-   return irq - irq_base;
+   struct pxa_gpio_chip *pchip = chip_to_pxachip(chip);
+
+   return irq_find_mapping(pchip->irqdomain, offset);
 }
 
 static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
@@ -314,7 +319,7 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc,
 #endif
 
 static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio,
- void __iomem *regbase)
+ struct device_node *np, void __iomem *regbase)
 {
int i, gpio, nbanks = DIV_ROUND_UP(ngpio, 32);
struct pxa_gpio_bank *bank;
@@ -332,7 +337,7 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, 
int ngpio,
pchip->chip.to_irq = pxa_gpio_to_irq;
pchip->chip.ngpio = ngpio;
 #ifdef CONFIG_OF_GPIO
-   pchip->chip.of_node = pxa_gpio_of_node;
+   pchip->chip.of_node = np;
pchip->chip.of_xlate = pxa_gpio_of_xlate;
pchip->chip.of_gpio_n_cells = 2;
 #endif
@@ -362,8 +367,8 @@ static inline void update_edge_detect(struct pxa_gpio_bank 
*c)
 
 static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type)
 {
-   struct pxa_gpio_chip *pchip = pxa_gpio_chip;
-   int gpio = pxa_irq_to_gpio(d->irq);
+   struct pxa_gpio_chip *pchip = irq_data_get_irq_chip_data(d);
+   unsigned int gpio = irqd_to_hwirq(d);
struct pxa_gpio_bank *c = gpio_to_pxabank(>chip, gpio);
unsigned long gpdr, mask = GPIO_bit(gpio);
 
@@ -405,16 +410,13 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned 
int type)
return 0;
 }
 
-static void pxa_gpio_demux_handler(struct irq_desc *desc)
+static irqreturn_t pxa_gpio_demux_handler(int in_irq, void *d)
 {
int loop, gpio, n, handled = 0;
unsigned long gedr;
-   struct irq_chip *chip = irq_desc_get_chip(desc);
-   struct pxa_gpio_chip *pchip = pxa_gpio_chip;
+   struct pxa_gpio_chip *pchip = d;
struct pxa_gpio_bank *c;
 
-   chained_irq_enter(chip, desc);
-
do {
loop = 0;
for_each_gpio_bank(gpio, c, pchip) {
@@ -428,15 +430,31 @@ static void pxa_gpio_demux_handler(struct irq_desc *desc)
generic_handle_irq(gpio_to_irq(gpio + n));
}
}
+   handled += loop;
} while (loop);
 
-   chained_irq_exit(chip, desc);
+   return handled ? IRQ_HANDLED : IRQ_NONE;
+}
+
+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));
+   } else if (in_irq == pchip->irq1) {
+   generic_handle_irq(gpio_to_irq(1));
+   } else {
+   pr_err("%s() unknown irq %d\n", __func__, in_irq);
+   return IRQ_NONE;
+   }
+   return IRQ_HANDLED;
 }
 
 static void pxa_ack_muxed_gpio(struct irq_data *d)
 {
-   struct pxa_gpio_chip 

[PATCH 3/4] gpio: pxa: change the interrupt management

2015-11-28 Thread Robert Jarzmik
The interrupt management is changed by this patch to rely on chip data
instead of chained interrupts.

The main goal is to loosen the dependency on the global pxa chip
structure in favor of the passed chip data. The secondary goal is to
better show in /proc/interrupts the difference between interrupts for
gpio0 and gpio1 (directly wired to interrupt controller), and the other
gpios (wired onto a third line in the interrupt controller).

The last advantage of this patch is that the interrupt is actually
requested, so that another driver cannot steal this line, or overwrite
the handler.

Signed-off-by: Robert Jarzmik 
---
 drivers/gpio/gpio-pxa.c | 145 +++-
 1 file changed, 82 insertions(+), 63 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 8558abf98204..7e02157c5b92 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -64,11 +64,6 @@
 int pxa_last_gpio;
 static int irq_base;
 
-#ifdef CONFIG_OF
-static struct irq_domain *domain;
-static struct device_node *pxa_gpio_of_node;
-#endif
-
 struct pxa_gpio_bank {
void __iomem*regbase;
unsigned long   irq_mask;
@@ -87,6 +82,7 @@ struct pxa_gpio_chip {
struct device *dev;
struct gpio_chip chip;
struct pxa_gpio_bank *banks;
+   struct irq_domain *irqdomain;
 
int irq0;
int irq1;
@@ -231,14 +227,23 @@ static inline int __gpio_is_occupied(struct pxa_gpio_chip 
*pchip, unsigned gpio)
return ret;
 }
 
-static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
+int pxa_irq_to_gpio(int irq)
 {
-   return offset + irq_base;
+   struct pxa_gpio_chip *pchip = pxa_gpio_chip;
+   int irq_gpio0;
+
+   irq_gpio0 = irq_find_mapping(pchip->irqdomain, 0);
+   if (irq_gpio0 > 0)
+   return irq - irq_gpio0;
+
+   return irq_gpio0;
 }
 
-int pxa_irq_to_gpio(int irq)
+static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 {
-   return irq - irq_base;
+   struct pxa_gpio_chip *pchip = chip_to_pxachip(chip);
+
+   return irq_find_mapping(pchip->irqdomain, offset);
 }
 
 static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
@@ -314,7 +319,7 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc,
 #endif
 
 static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio,
- void __iomem *regbase)
+ struct device_node *np, void __iomem *regbase)
 {
int i, gpio, nbanks = DIV_ROUND_UP(ngpio, 32);
struct pxa_gpio_bank *bank;
@@ -332,7 +337,7 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, 
int ngpio,
pchip->chip.to_irq = pxa_gpio_to_irq;
pchip->chip.ngpio = ngpio;
 #ifdef CONFIG_OF_GPIO
-   pchip->chip.of_node = pxa_gpio_of_node;
+   pchip->chip.of_node = np;
pchip->chip.of_xlate = pxa_gpio_of_xlate;
pchip->chip.of_gpio_n_cells = 2;
 #endif
@@ -362,8 +367,8 @@ static inline void update_edge_detect(struct pxa_gpio_bank 
*c)
 
 static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type)
 {
-   struct pxa_gpio_chip *pchip = pxa_gpio_chip;
-   int gpio = pxa_irq_to_gpio(d->irq);
+   struct pxa_gpio_chip *pchip = irq_data_get_irq_chip_data(d);
+   unsigned int gpio = irqd_to_hwirq(d);
struct pxa_gpio_bank *c = gpio_to_pxabank(>chip, gpio);
unsigned long gpdr, mask = GPIO_bit(gpio);
 
@@ -405,16 +410,13 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned 
int type)
return 0;
 }
 
-static void pxa_gpio_demux_handler(struct irq_desc *desc)
+static irqreturn_t pxa_gpio_demux_handler(int in_irq, void *d)
 {
int loop, gpio, n, handled = 0;
unsigned long gedr;
-   struct irq_chip *chip = irq_desc_get_chip(desc);
-   struct pxa_gpio_chip *pchip = pxa_gpio_chip;
+   struct pxa_gpio_chip *pchip = d;
struct pxa_gpio_bank *c;
 
-   chained_irq_enter(chip, desc);
-
do {
loop = 0;
for_each_gpio_bank(gpio, c, pchip) {
@@ -428,15 +430,31 @@ static void pxa_gpio_demux_handler(struct irq_desc *desc)
generic_handle_irq(gpio_to_irq(gpio + n));
}
}
+   handled += loop;
} while (loop);
 
-   chained_irq_exit(chip, desc);
+   return handled ? IRQ_HANDLED : IRQ_NONE;
+}
+
+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));
+   } else if (in_irq == pchip->irq1) {
+   generic_handle_irq(gpio_to_irq(1));
+   } else {
+   pr_err("%s() unknown irq %d\n", __func__, in_irq);
+   return IRQ_NONE;
+   }
+   return IRQ_HANDLED;
 }
 
 static void pxa_ack_muxed_gpio(struct irq_data *d)
 {
-   

Re: [PATCH 3/4] gpio: pxa: change the interrupt management

2015-11-28 Thread kbuild test robot
Hi Robert,

[auto build test ERROR on: gpio/for-next]
[also build test ERROR on: v4.4-rc2 next-20151127]

url:
https://github.com/0day-ci/linux/commits/Robert-Jarzmik/gpio-pxa-integrate-with-pincontrol/20151129-054738
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 
for-next
config: arm-pxa910_defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/gpio/gpio-pxa.c: In function 'pxa_gpio_probe':
>> drivers/gpio/gpio-pxa.c:625:12: error: 'pxa_irq_domain_ops' undeclared 
>> (first use in this function)
   0, _irq_domain_ops, pchip);
   ^
   drivers/gpio/gpio-pxa.c:625:12: note: each undeclared identifier is reported 
only once for each function it appears in
   drivers/gpio/gpio-pxa.c: At top level:
   drivers/gpio/gpio-pxa.c:500:24: warning: 'pxa_muxed_gpio_chip' defined but 
not used [-Wunused-variable]
static struct irq_chip pxa_muxed_gpio_chip = {
   ^

vim +/pxa_irq_domain_ops +625 drivers/gpio/gpio-pxa.c

   619  
   620  if (!pxa_last_gpio)
   621  return -EINVAL;
   622  
   623  pchip->irqdomain = irq_domain_add_legacy(pdev->dev.of_node,
   624   pxa_last_gpio + 1, 
irq_base,
 > 625   0, 
 > _irq_domain_ops, pchip);
   626  if (IS_ERR(pchip->irqdomain))
   627  return PTR_ERR(pchip->irqdomain);
   628  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data