pinctrl: cherryview: Fix irq_valid_mask calculation
diff mbox series

Message ID 20191018090842.11189-1-hdegoede@redhat.com
State New
Headers show
Series
  • pinctrl: cherryview: Fix irq_valid_mask calculation
Related show

Commit Message

Hans de Goede Oct. 18, 2019, 9:08 a.m. UTC
Commit 03c4749dd6c7 ("gpio / ACPI: Drop unnecessary ACPI GPIO to Linux
GPIO translation") has made the cherryview gpio numbers sparse, to get
a 1:1 mapping between ACPI pin numbers and gpio numbers in Linux.

This has greatly simplified things, but the code setting the
irq_valid_mask was not updated for this, so the valid mask is still in
the old "compressed" numbering with the gaps in the pin numbers skipped,
which is wrong as irq_valid_mask needs to be expressed in gpio numbers.

This results in the following error on devices using pin 24 (0x0018) on
the north GPIO controller as an ACPI event source:

[    0.422452] cherryview-pinctrl INT33FF:01: Failed to translate GPIO to IRQ

This has been reported (by email) to be happening on a Caterpillar CAT T20
tablet and I've reproduced this myself on a Medion Akoya e2215t 2-in-1.

This commit uses the pin number instead of the compressed index into
community->pins to clear the correct bits in irq_valid_mask for GPIOs
using GPEs for interrupts, fixing these errors and in case of the
Medion Akoya e2215t also fixing the LID switch not working.

Cc: stable@vger.kernel.org
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes: 03c4749dd6c7 ("gpio / ACPI: Drop unnecessary ACPI GPIO to Linux GPIO translation")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andy Shevchenko Oct. 18, 2019, 9:23 a.m. UTC | #1
On Fri, Oct 18, 2019 at 11:08:42AM +0200, Hans de Goede wrote:
> Commit 03c4749dd6c7 ("gpio / ACPI: Drop unnecessary ACPI GPIO to Linux
> GPIO translation") has made the cherryview gpio numbers sparse, to get
> a 1:1 mapping between ACPI pin numbers and gpio numbers in Linux.
> 
> This has greatly simplified things, but the code setting the
> irq_valid_mask was not updated for this, so the valid mask is still in
> the old "compressed" numbering with the gaps in the pin numbers skipped,
> which is wrong as irq_valid_mask needs to be expressed in gpio numbers.
> 
> This results in the following error on devices using pin 24 (0x0018) on
> the north GPIO controller as an ACPI event source:
> 
> [    0.422452] cherryview-pinctrl INT33FF:01: Failed to translate GPIO to IRQ
> 
> This has been reported (by email) to be happening on a Caterpillar CAT T20
> tablet and I've reproduced this myself on a Medion Akoya e2215t 2-in-1.
> 
> This commit uses the pin number instead of the compressed index into
> community->pins to clear the correct bits in irq_valid_mask for GPIOs
> using GPEs for interrupts, fixing these errors and in case of the
> Medion Akoya e2215t also fixing the LID switch not working.

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

> 
> Cc: stable@vger.kernel.org
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Fixes: 03c4749dd6c7 ("gpio / ACPI: Drop unnecessary ACPI GPIO to Linux GPIO translation")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/pinctrl/intel/pinctrl-cherryview.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
> index aae51c507f59..02ff5e8b0510 100644
> --- a/drivers/pinctrl/intel/pinctrl-cherryview.c
> +++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
> @@ -1563,7 +1563,7 @@ static void chv_init_irq_valid_mask(struct gpio_chip *chip,
>  		intsel >>= CHV_PADCTRL0_INTSEL_SHIFT;
>  
>  		if (intsel >= community->nirqs)
> -			clear_bit(i, valid_mask);
> +			clear_bit(desc->number, valid_mask);
>  	}
>  }
>  
> -- 
> 2.23.0
>
Mika Westerberg Oct. 21, 2019, 2:09 p.m. UTC | #2
On Fri, Oct 18, 2019 at 11:08:42AM +0200, Hans de Goede wrote:
> Commit 03c4749dd6c7 ("gpio / ACPI: Drop unnecessary ACPI GPIO to Linux
> GPIO translation") has made the cherryview gpio numbers sparse, to get
> a 1:1 mapping between ACPI pin numbers and gpio numbers in Linux.
> 
> This has greatly simplified things, but the code setting the
> irq_valid_mask was not updated for this, so the valid mask is still in
> the old "compressed" numbering with the gaps in the pin numbers skipped,
> which is wrong as irq_valid_mask needs to be expressed in gpio numbers.
> 
> This results in the following error on devices using pin 24 (0x0018) on
> the north GPIO controller as an ACPI event source:
> 
> [    0.422452] cherryview-pinctrl INT33FF:01: Failed to translate GPIO to IRQ
> 
> This has been reported (by email) to be happening on a Caterpillar CAT T20
> tablet and I've reproduced this myself on a Medion Akoya e2215t 2-in-1.
> 
> This commit uses the pin number instead of the compressed index into
> community->pins to clear the correct bits in irq_valid_mask for GPIOs
> using GPEs for interrupts, fixing these errors and in case of the
> Medion Akoya e2215t also fixing the LID switch not working.
> 
> Cc: stable@vger.kernel.org
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Fixes: 03c4749dd6c7 ("gpio / ACPI: Drop unnecessary ACPI GPIO to Linux GPIO translation")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied to intel.git/fixes, thanks!

Patch
diff mbox series

diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index aae51c507f59..02ff5e8b0510 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -1563,7 +1563,7 @@  static void chv_init_irq_valid_mask(struct gpio_chip *chip,
 		intsel >>= CHV_PADCTRL0_INTSEL_SHIFT;
 
 		if (intsel >= community->nirqs)
-			clear_bit(i, valid_mask);
+			clear_bit(desc->number, valid_mask);
 	}
 }