diff mbox series

pinctrl: cherryview: Associate IRQ descriptors to irqdomain manually

Message ID 20180425103211.66531-1-mika.westerberg@linux.intel.com
State New
Headers show
Series pinctrl: cherryview: Associate IRQ descriptors to irqdomain manually | expand

Commit Message

Mika Westerberg April 25, 2018, 10:32 a.m. UTC
When we dropped the custom Linux GPIO translation it resulted that the
IRQ numbers changed slightly as well. Normally this would be fine
because everyone is expected to use controller relative GPIO numbers and
ACPI GpioIo/GpioInt resources. However, there is a certain set of
Intel_Strago based Chromebooks where i8042 keyboard controller IRQ
number is hardcoded be 182 (this is corrected with newer coreboot but
the older ones still have the hardcoded Linux IRQ number). Because of
this hardcoded IRQ number keyboard on those systems accidentally broke
again.

Fix this by manually associating IRQ descriptors to the chip irqdomain
so that there are no gaps on those systems. Other systems are not
affected.

Fixes: 03c4749dd6c7 ("gpio / ACPI: Drop unnecessary ACPI GPIO to Linux GPIO translation")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=199463
Reported-by: Sultan Alsawaf <sultanxda@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Andy Shevchenko April 25, 2018, 2:55 p.m. UTC | #1
On Wed, 2018-04-25 at 13:32 +0300, Mika Westerberg wrote:
> When we dropped the custom Linux GPIO translation it resulted that the
> IRQ numbers changed slightly as well. Normally this would be fine
> because everyone is expected to use controller relative GPIO numbers
> and
> ACPI GpioIo/GpioInt resources. However, there is a certain set of
> Intel_Strago based Chromebooks where i8042 keyboard controller IRQ
> number is hardcoded be 182 (this is corrected with newer coreboot but
> the older ones still have the hardcoded Linux IRQ number). Because of
> this hardcoded IRQ number keyboard on those systems accidentally broke
> again.
> 
> Fix this by manually associating IRQ descriptors to the chip irqdomain
> so that there are no gaps on those systems. Other systems are not
> affected.
> 

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Fixes: 03c4749dd6c7 ("gpio / ACPI: Drop unnecessary ACPI GPIO to Linux
> GPIO translation")
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=199463
> Reported-by: Sultan Alsawaf <sultanxda@gmail.com>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
>  drivers/pinctrl/intel/pinctrl-cherryview.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c
> b/drivers/pinctrl/intel/pinctrl-cherryview.c
> index b1ae1618fefe..fee9225ca559 100644
> --- a/drivers/pinctrl/intel/pinctrl-cherryview.c
> +++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
> @@ -1622,22 +1622,30 @@ static int chv_gpio_probe(struct chv_pinctrl
> *pctrl, int irq)
>  
>  	if (!need_valid_mask) {
>  		irq_base = devm_irq_alloc_descs(pctrl->dev, -1, 0,
> -						chip->ngpio,
> NUMA_NO_NODE);
> +						community->npins,
> NUMA_NO_NODE);
>  		if (irq_base < 0) {
>  			dev_err(pctrl->dev, "Failed to allocate IRQ
> numbers\n");
>  			return irq_base;
>  		}
> -	} else {
> -		irq_base = 0;
>  	}
>  
> -	ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, irq_base,
> +	ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0,
>  				   handle_bad_irq, IRQ_TYPE_NONE);
>  	if (ret) {
>  		dev_err(pctrl->dev, "failed to add IRQ chip\n");
>  		return ret;
>  	}
>  
> +	if (!need_valid_mask) {
> +		for (i = 0; i < community->ngpio_ranges; i++) {
> +			range = &community->gpio_ranges[i];
> +
> +			irq_domain_associate_many(chip->irq.domain,
> irq_base,
> +						  range->base, range-
> >npins);
> +			irq_base += range->npins;
> +		}
> +	}
> +
>  	gpiochip_set_chained_irqchip(chip, &chv_gpio_irqchip, irq,
>  				     chv_gpio_irq_handler);
>  	return 0;
Linus Walleij April 30, 2018, 9:26 a.m. UTC | #2
On Wed, Apr 25, 2018 at 12:32 PM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:

> When we dropped the custom Linux GPIO translation it resulted that the
> IRQ numbers changed slightly as well. Normally this would be fine
> because everyone is expected to use controller relative GPIO numbers and
> ACPI GpioIo/GpioInt resources. However, there is a certain set of
> Intel_Strago based Chromebooks where i8042 keyboard controller IRQ
> number is hardcoded be 182 (this is corrected with newer coreboot but
> the older ones still have the hardcoded Linux IRQ number). Because of
> this hardcoded IRQ number keyboard on those systems accidentally broke
> again.
>
> Fix this by manually associating IRQ descriptors to the chip irqdomain
> so that there are no gaps on those systems. Other systems are not
> affected.
>
> Fixes: 03c4749dd6c7 ("gpio / ACPI: Drop unnecessary ACPI GPIO to Linux GPIO translation")
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=199463
> Reported-by: Sultan Alsawaf <sultanxda@gmail.com>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Patch applied with Andy's ACK.

However I replaced the word "manually" with "iteratively".
I have a personal aversion for all use of the "manual" in the kernel
when it is obviously a machine doing the job, not a man.

Think of it: who is pulling the lever? A person? Not really.

It's just a machine doing the job in non-standard manner.

It evokes the old story of the zoologist, the mathematician, the statistician,
and the programmer on safari, when they suddenly spot a zebra
with no stripes.
- A unique specimen that need to be documented! The zoologist said.
- Are you sure it is not stripy on the other side? The mathematician said.
- It's not significant. The Statistician said.
- Damn it, another special case! The programmer said.

Yours,
Linus Walleij

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index b1ae1618fefe..fee9225ca559 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -1622,22 +1622,30 @@  static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
 
 	if (!need_valid_mask) {
 		irq_base = devm_irq_alloc_descs(pctrl->dev, -1, 0,
-						chip->ngpio, NUMA_NO_NODE);
+						community->npins, NUMA_NO_NODE);
 		if (irq_base < 0) {
 			dev_err(pctrl->dev, "Failed to allocate IRQ numbers\n");
 			return irq_base;
 		}
-	} else {
-		irq_base = 0;
 	}
 
-	ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, irq_base,
+	ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0,
 				   handle_bad_irq, IRQ_TYPE_NONE);
 	if (ret) {
 		dev_err(pctrl->dev, "failed to add IRQ chip\n");
 		return ret;
 	}
 
+	if (!need_valid_mask) {
+		for (i = 0; i < community->ngpio_ranges; i++) {
+			range = &community->gpio_ranges[i];
+
+			irq_domain_associate_many(chip->irq.domain, irq_base,
+						  range->base, range->npins);
+			irq_base += range->npins;
+		}
+	}
+
 	gpiochip_set_chained_irqchip(chip, &chv_gpio_irqchip, irq,
 				     chv_gpio_irq_handler);
 	return 0;