Skip to contentSkip to conversation

pinctrl: cherryview: Do not mask all interrupts on probe

PATCH In review Mika Westerberg 7 participants 38 messages May 22, 2015 – Sep 18, 2016

Subsystems (3)
lore
Share & tools
lore

Mika Westerberg

author maintainer
#0 lore raw

PATCH 1/1 pinctrl: cherryview: Do not mask all interrupts on probe

BIOS/platform may use some of the pins by themselves, such as providing SCI (System Control Interrupt) from the embedded controller. The driver masks all interrupts at probe time which prevents those pins from triggering interrupts properly.

Fix this by not masking all interrupts at probe -- it should be enough just to clear the status register.

---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pinctrl/intel/pinctrl-cherryview.c +1 -2
index 82f691eeeec4..c9c0257a370c 100644
@@ -1417,8 +1417,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
 		offset += range->npins;
 	}
 
-	/* Mask and clear all interrupts */
-	chv_writel(0, pctrl->regs + CHV_INTMASK);
+	/* Clear all interrupts */
 	chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
 
 	ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0,
Signature · 1 line
2.1.4
author maintainer
#1 lore raw
Quoted 10 lines · Mika Westerberg

BIOS/platform may use some of the pins by themselves, such as providing SCI (System Control Interrupt) from the embedded controller. The driver masks all interrupts at probe time which prevents those pins from triggering interrupts properly.

Fix this by not masking all interrupts at probe -- it should be enough just to clear the status register.

Please ignore this patch for now. It turned out to be causing spurious interrupts on another platform.

I'll need to rethink how to fix the reported issue.

#2 lore raw
Quoted 9 lines · Mika Westerberg
Quoted 8 lines · Mika Westerberg

BIOS/platform may use some of the pins by themselves, such as providing SCI (System Control Interrupt) from the embedded controller. The driver masks all interrupts at probe time which prevents those pins from triggering interrupts properly.

Fix this by not masking all interrupts at probe -- it should be enough just to clear the status register.

Quoted 7 lines
Quoted 2 lines

Please ignore this patch for now. It turned out to be causing spurious interrupts on another platform.

I'll need to rethink how to fix the reported issue.

Looks like a case of "embed more magic knowledge" in the driver :/

It needs to know what platform it is running on, and only leave specific bits unmasked on these specific platforms. Right? Thereby tossing all of the acpi_device_id matching and abstraction out of the window.

(Yes, I hate BIOSes doing crap behind my back.)

Yours,
Linus Walleij

author maintainer
#3 lore raw
Quoted 17 lines · Linus Walleij
Quoted 15 lines · Mika Westerberg
Quoted 10 lines · Mika Westerberg

BIOS/platform may use some of the pins by themselves, such as providing SCI (System Control Interrupt) from the embedded controller. The driver masks all interrupts at probe time which prevents those pins from triggering interrupts properly.

Fix this by not masking all interrupts at probe -- it should be enough just to clear the status register.

Please ignore this patch for now. It turned out to be causing spurious interrupts on another platform.

Quoted 8 lines
Quoted 1 line

I'll need to rethink how to fix the reported issue.

Looks like a case of "embed more magic knowledge" in the driver :/

It needs to know what platform it is running on, and only leave specific bits unmasked on these specific platforms. Right? Thereby tossing all of the acpi_device_id matching and abstraction out of the window.

That's right.

We still have few options left, like using ACPI _AEI (ACPI GPIO triggered events) for this or adding GPIO interrupt support directly to the EC driver.

#4 lore raw
Quoted 6 lines · Mika Westerberg <mika.westerberg <at> linux.intel.com> writes:
Quoted 4 lines · Linus Walleij
Quoted 2 lines · On Mon, Jun 1, 2015 at 11:23 AM, Mika Westerberg <mika.westerberg <at>…
Quoted 1 line · Mika Westerberg

BIOS/platform may use some of the pins by themselves, such as

providing SCI

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

(System Control Interrupt) from the embedded controller. The driver masks all interrupts at probe time which prevents those pins from triggering interrupts properly.

Fix this by not masking all interrupts at probe -- it should be

enough just

Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

to clear the status register.

Reported-by Yu C Chen <yu.c.chen <at> intel.com>
Signed-off-by Mika Westerberg <mika.westerberg <at> linux.intel.com>

Please ignore this patch for now. It turned out to be causing spurious interrupts on another platform.

Quoted 8 lines
Quoted 1 line

I'll need to rethink how to fix the reported issue.

Looks like a case of "embed more magic knowledge" in the driver :/

It needs to know what platform it is running on, and only leave specific bits unmasked on these specific platforms. Right? Thereby tossing all of the acpi_device_id matching and abstraction out of the window.

Quoted 5 lines

That's right.

We still have few options left, like using ACPI _AEI (ACPI GPIO triggered events) for this or adding GPIO interrupt support directly to the EC driver.

Are there any updates on this problem? I came through this while doing hardware enablement for a laptop, and the symptoms were the brightness control keys stop working when this module was loaded. This patch fixes the problem on that specific platform.

I'm happy to test or help out with a better suited fix if given some guidance.

Best regards,

PS: please keep me copied in the thread since I do not sign linux-gpio nor LKML.

--
João Paulo Rechi Vita
http://about.me/jprvita

#5 lore raw
In reply to Mika Westerberg

Hi Mika,

Quoted 27 lines · Mika Westerberg
Quoted 17 lines · Linus Walleij
Quoted 15 lines · Mika Westerberg
Quoted 10 lines · Mika Westerberg

BIOS/platform may use some of the pins by themselves, such as providing SCI (System Control Interrupt) from the embedded controller. The driver masks all interrupts at probe time which prevents those pins from triggering interrupts properly.

Fix this by not masking all interrupts at probe -- it should be enough just to clear the status register.

Please ignore this patch for now. It turned out to be causing spurious interrupts on another platform.

Quoted 8 lines
Quoted 1 line

I'll need to rethink how to fix the reported issue.

Looks like a case of "embed more magic knowledge" in the driver :/

It needs to know what platform it is running on, and only leave specific bits unmasked on these specific platforms. Right? Thereby tossing all of the acpi_device_id matching and abstraction out of the window.

Quoted 5 lines

That's right.

We still have few options left, like using ACPI _AEI (ACPI GPIO triggered events) for this or adding GPIO interrupt support directly to the EC driver.

Did you find a way to fix this issue ? I'm seeing a similar problem on a laptop where this masks the interrupt used for ACPI events (brightness, lid, battery).

Regards,

Anisse

author maintainer
#6 lore raw
Quoted 33 lines · Anisse Astier

Hi Mika,

Quoted 29 lines · Mika Westerberg
Quoted 17 lines · Linus Walleij
Quoted 15 lines · Mika Westerberg
Quoted 10 lines · Mika Westerberg

BIOS/platform may use some of the pins by themselves, such as providing SCI (System Control Interrupt) from the embedded controller. The driver masks all interrupts at probe time which prevents those pins from triggering interrupts properly.

Fix this by not masking all interrupts at probe -- it should be enough just to clear the status register.

Please ignore this patch for now. It turned out to be causing spurious interrupts on another platform.

Quoted 8 lines
Quoted 1 line

I'll need to rethink how to fix the reported issue.

Looks like a case of "embed more magic knowledge" in the driver :/

It needs to know what platform it is running on, and only leave specific bits unmasked on these specific platforms. Right? Thereby tossing all of the acpi_device_id matching and abstraction out of the window.

That's right.

Quoted 7 lines
Quoted 3 lines

We still have few options left, like using ACPI _AEI (ACPI GPIO triggered events) for this or adding GPIO interrupt support directly to the EC driver.

Did you find a way to fix this issue ? I'm seeing a similar problem on a laptop where this masks the interrupt used for ACPI events (brightness, lid, battery).

I seem to have forgotten this completely :-/

Can you send me output of /sys/kernel/debug/pinctrl/INT33FF:*/pins for that particular EC pin?

In addition if you apply this patch do you see that ACPI events start working?

#7 lore raw
Quoted 9 lines · Mika Westerberg
Quoted 5 lines · Anisse Astier

Hi Mika,

Did you find a way to fix this issue ? I'm seeing a similar problem on a laptop where this masks the interrupt used for ACPI events (brightness, lid, battery).

I seem to have forgotten this completely :-/

Quoted 7 lines

Can you send me output of /sys/kernel/debug/pinctrl/INT33FF:*/pins for that particular EC pin?

In addition if you apply this patch do you see that ACPI events start working?

From what I've seen it's in the north range, I don't know which pin in

particular it is yet.

If the interrupts aren't masked for the north community, ACPI events start working.

# cat /sys/kernel/debug/pinctrl/INT33FF\:01/pins
registered pins: 59
pin 0 (GPIO_DFX_0) GPIO ctrl0 0x00118102 ctrl1 0x05c00000
pin 1 (GPIO_DFX_3) GPIO ctrl0 0x2c018100 ctrl1 0x05c00000
pin 2 (GPIO_DFX_7) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 3 (GPIO_DFX_1) GPIO ctrl0 0x18118100 ctrl1 0x05c00000
pin 4 (GPIO_DFX_5) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 5 (GPIO_DFX_4) GPIO ctrl0 0x00118102 ctrl1 0x05c00000
pin 6 (GPIO_DFX_8) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 7 (GPIO_DFX_2) GPIO ctrl0 0x00118100 ctrl1 0x05c00000
pin 8 (GPIO_DFX_6) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 15 (GPIO_SUS0) GPIO ctrl0 0x3c018201 ctrl1 0x05c00001
pin 16 (SEC_GPIO_SUS10) GPIO ctrl0 0x00118100 ctrl1 0x05c00000
pin 17 (GPIO_SUS3) GPIO ctrl0 0x4c118100 ctrl1 0x05c00000
pin 18 (GPIO_SUS7) GPIO ctrl0 0xfc918201 ctrl1 0x05c00001
pin 19 (GPIO_SUS1) mode 6 ctrl0 0x00160301 ctrl1 0x05c00000
pin 20 (GPIO_SUS5) mode 1 ctrl0 0x00910200 ctrl1 0x05c00000
pin 21 (SEC_GPIO_SUS11) GPIO ctrl0 0x5c118100 ctrl1 0x05c00000
pin 22 (GPIO_SUS4) mode 6 ctrl0 0x00960301 ctrl1 0x05c00000
pin 23 (SEC_GPIO_SUS8) mode 1 ctrl0 0x00910300 ctrl1 0x05c00000
pin 24 (GPIO_SUS2) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 25 (GPIO_SUS6) GPIO ctrl0 0xec918201 ctrl1 0x05c00001
pin 26 (CX_PREQ_B) mode 1 ctrl0 0x00a10301 ctrl1 0x05c00000
pin 27 (SEC_GPIO_SUS9) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 30 (TRST_B) mode 1 ctrl0 0x00a10300 ctrl1 0x05c00000
pin 31 (TCK) mode 1 ctrl0 0x00210300 ctrl1 0x05c00000
pin 32 (PROCHOT_B) mode 1 ctrl0 0x00010301 ctrl1 0x05c00060
pin 33 (SVIDO_DATA) mode 0 ctrl0 0x00000300 ctrl1 0x05c00020
pin 34 (TMS) mode 1 ctrl0 0x00a10301 ctrl1 0x05c00000
pin 35 (CX_PRDY_B_2) mode 1 ctrl0 0x00a10301 ctrl1 0x05c00000
pin 36 (TDO_2) mode 1 ctrl0 0x00010300 ctrl1 0x05c00000
pin 37 (CX_PRDY_B) mode 1 ctrl0 0x00a10301 ctrl1 0x05c00000
pin 38 (SVIDO_ALERT_B) mode 1 ctrl0 0x00010301 ctrl1 0x05c00040
pin 39 (TDO) mode 1 ctrl0 0x00010300 ctrl1 0x05c00000
pin 40 (SVIDO_CLK) mode 1 ctrl0 0x00010300 ctrl1 0x05c00000
pin 41 (TDI) mode 1 ctrl0 0x00a10301 ctrl1 0x05c00000
pin 45 (GP_CAMERASB_05) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 46 (GP_CAMERASB_02) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 47 (GP_CAMERASB_08) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 48 (GP_CAMERASB_00) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 49 (GP_CAMERASB_06) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 50 (GP_CAMERASB_10) GPIO ctrl0 0x00118100 ctrl1 0x05c00000
pin 51 (GP_CAMERASB_03) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 52 (GP_CAMERASB_09) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 53 (GP_CAMERASB_01) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 54 (GP_CAMERASB_07) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 55 (GP_CAMERASB_11) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 56 (GP_CAMERASB_04) GPIO ctrl0 0x00118100 ctrl1 0x05c00020
pin 60 (PANEL0_BKLTEN) mode 1 ctrl0 0x00010300 ctrl1 0x05c00000
pin 61 (HV_DDI0_HPD) mode 1 ctrl0 0x03110301 ctrl1 0x05c00020
pin 62 (HV_DDI2_DDC_SDA) mode 3 ctrl0 0x00930301 ctrl1 0x05c00000
pin 63 (PANEL1_BKLTCTL) GPIO ctrl0 0x00018102 ctrl1 0x05c00000
pin 64 (HV_DDI1_HPD) mode 1 ctrl0 0x03010300 ctrl1 0x05c00020
pin 65 (PANEL0_BKLTCTL) mode 1 ctrl0 0x00010300 ctrl1 0x05c00000
pin 66 (HV_DDI0_DDC_SDA) mode 1 ctrl0 0x00910301 ctrl1 0x05c00000
pin 67 (HV_DDI2_DDC_SCL) mode 3 ctrl0 0x00930301 ctrl1 0x05c00000
pin 68 (HV_DDI2_HPD) mode 1 ctrl0 0x03110300 ctrl1 0x05c00020
pin 69 (PANEL1_VDDEN) mode 1 ctrl0 0x00010300 ctrl1 0x05c00000
pin 70 (PANEL1_BKLTEN) mode 1 ctrl0 0x00010300 ctrl1 0x05c00000
pin 71 (HV_DDI0_DDC_SCL) mode 1 ctrl0 0x00910301 ctrl1 0x05c00000
pin 72 (PANEL0_VDDEN) mode 1 ctrl0 0x00010300 ctrl1 0x05c00000
author maintainer
#8 lore raw
Quoted 38 lines · Anisse Astier
Quoted 9 lines · Mika Westerberg
Quoted 5 lines · Anisse Astier

Hi Mika,

Did you find a way to fix this issue ? I'm seeing a similar problem on a laptop where this masks the interrupt used for ACPI events (brightness, lid, battery).

I seem to have forgotten this completely :-/

Quoted 7 lines

Can you send me output of /sys/kernel/debug/pinctrl/INT33FF:*/pins for that particular EC pin?

In addition if you apply this patch do you see that ACPI events start working?

From what I've seen it's in the north range, I don't know which pin in

particular it is yet.

If the interrupts aren't masked for the north community, ACPI events start working.

# cat /sys/kernel/debug/pinctrl/INT33FF\:01/pins
registered pins: 59
pin 0 (GPIO_DFX_0) GPIO ctrl0 0x00118102 ctrl1 0x05c00000
pin 1 (GPIO_DFX_3) GPIO ctrl0 0x2c018100 ctrl1 0x05c00000
pin 2 (GPIO_DFX_7) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 3 (GPIO_DFX_1) GPIO ctrl0 0x18118100 ctrl1 0x05c00000
pin 4 (GPIO_DFX_5) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 5 (GPIO_DFX_4) GPIO ctrl0 0x00118102 ctrl1 0x05c00000
pin 6 (GPIO_DFX_8) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 7 (GPIO_DFX_2) GPIO ctrl0 0x00118100 ctrl1 0x05c00000
pin 8 (GPIO_DFX_6) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 15 (GPIO_SUS0) GPIO ctrl0 0x3c018201 ctrl1 0x05c00001
pin 16 (SEC_GPIO_SUS10) GPIO ctrl0 0x00118100 ctrl1 0x05c00000
pin 17 (GPIO_SUS3) GPIO ctrl0 0x4c118100 ctrl1 0x05c00000
Quoted 8 lines
pin 18 (GPIO_SUS7) GPIO ctrl0 0xfc918201 ctrl1 0x05c00001
pin 19 (GPIO_SUS1) mode 6 ctrl0 0x00160301 ctrl1 0x05c00000
pin 20 (GPIO_SUS5) mode 1 ctrl0 0x00910200 ctrl1 0x05c00000
pin 21 (SEC_GPIO_SUS11) GPIO ctrl0 0x5c118100 ctrl1 0x05c00000
pin 22 (GPIO_SUS4) mode 6 ctrl0 0x00960301 ctrl1 0x05c00000
pin 23 (SEC_GPIO_SUS8) mode 1 ctrl0 0x00910300 ctrl1 0x05c00000
pin 24 (GPIO_SUS2) GPIO ctrl0 0x00918102 ctrl1 0x05c00000
pin 25 (GPIO_SUS6) GPIO ctrl0 0xec918201 ctrl1 0x05c00001

It is this one (GPIO_SUS6).

I wonder if we can relax the driver so that it only masks pins which are not configured to generate interrupts by the BIOS. I quickly tried following on one Braswell machine and it did not generate spurious interrupts.

Can you check if this works for you?

drivers/pinctrl/intel/pinctrl-cherryview.c +22 -2
index 5749a4eee746..579e0e48bdee 100644
@@ -1513,6 +1513,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
 	const struct chv_gpio_pinrange *range;
 	struct gpio_chip *chip = &pctrl->chip;
 	int ret, i, offset;
+	u32 intmask = 0;
 
 	*chip = chv_gpio_chip;
 
@@ -1539,8 +1540,27 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
 		offset += range->npins;
 	}
 
-	/* Mask and clear all interrupts */
-	chv_writel(0, pctrl->regs + CHV_INTMASK);
+	/*
+	 * Mask all interrupts except those which BIOS has configured to
+	 * actually generate interrupts in their padctrl registers.
+	 */
+	for (i = 0; i < pctrl->community->npins; i++) {
+		unsigned pin = pctrl->community->pins[i].number;
+		u32 intsel, ctrl1;
+
+		intsel = readl(chv_padreg(pctrl, pin, CHV_PADCTRL0));
+		intsel &= CHV_PADCTRL0_INTSEL_MASK;
+		intsel >>= CHV_PADCTRL0_INTSEL_SHIFT;
+		ctrl1 = readl(chv_padreg(pctrl, pin, CHV_PADCTRL1));
+
+		if (intsel && (ctrl1 & CHV_PADCTRL1_INTWAKECFG_MASK))
+			intmask |= BIT(intsel);
+	}
+
+	intmask &= readl(pctrl->regs + CHV_INTMASK);
+	writel(intmask, pctrl->regs + CHV_INTMASK);
+
+	/* Clear all interrupts */
 	chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
 
 	ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0,
#9 lore raw
Quoted 11 lines · Mika Westerberg
Quoted 1 line · Anisse Astier

pin 25 (GPIO_SUS6) GPIO ctrl0 0xec918201 ctrl1 0x05c00001

It is this one (GPIO_SUS6).

I wonder if we can relax the driver so that it only masks pins which are not configured to generate interrupts by the BIOS. I quickly tried following on one Braswell machine and it did not generate spurious interrupts.

Can you check if this works for you?

I tried it, your patch is working. It gives the same result as not clearing the north community. I receive the ACPI events.

Regards,

Anisse

author maintainer
#10 lore raw
Quoted 12 lines · Anisse Astier
Quoted 10 lines · Mika Westerberg
Quoted 1 line · Anisse Astier

pin 25 (GPIO_SUS6) GPIO ctrl0 0xec918201 ctrl1 0x05c00001

It is this one (GPIO_SUS6).

I wonder if we can relax the driver so that it only masks pins which are not configured to generate interrupts by the BIOS. I quickly tried following on one Braswell machine and it did not generate spurious interrupts.

Quoted 4 lines
Quoted 1 line

Can you check if this works for you?

I tried it, your patch is working. It gives the same result as not clearing the north community. I receive the ACPI events.

OK, thanks for testing.

I'll make a formal patch and submit it with you CC'd. Let's hope it will not break anything :)

#11 lore raw
Quoted 15 lines · Mika Westerberg
Quoted 14 lines · Anisse Astier
Quoted 11 lines · Mika Westerberg
Quoted 1 line · Anisse Astier

pin 25 (GPIO_SUS6) GPIO ctrl0 0xec918201 ctrl1 0x05c00001

It is this one (GPIO_SUS6).

I wonder if we can relax the driver so that it only masks pins which are not configured to generate interrupts by the BIOS. I quickly tried following on one Braswell machine and it did not generate spurious interrupts.

Can you check if this works for you?

Quoted 7 lines
Quoted 2 lines

I tried it, your patch is working. It gives the same result as not clearing the north community. I receive the ACPI events.

OK, thanks for testing.

I'll make a formal patch and submit it with you CC'd. Let's hope it will not break anything :)

Hi, we've also found this issue on HP X360, but both patches don't work with on it.

My current workaround is to save INTMASK before clearing then restore it after, but I'm not sure if there's any side-effect by doing so.

author maintainer
#12 lore raw
Quoted 21 lines · Phidias Chiang
Quoted 20 lines · Mika Westerberg
Quoted 12 lines · Anisse Astier
Quoted 10 lines · Mika Westerberg
Quoted 1 line · Anisse Astier

pin 25 (GPIO_SUS6) GPIO ctrl0 0xec918201 ctrl1 0x05c00001

It is this one (GPIO_SUS6).

I wonder if we can relax the driver so that it only masks pins which are not configured to generate interrupts by the BIOS. I quickly tried following on one Braswell machine and it did not generate spurious interrupts.

Quoted 4 lines
Quoted 1 line

Can you check if this works for you?

I tried it, your patch is working. It gives the same result as not clearing the north community. I receive the ACPI events.

OK, thanks for testing.

Quoted 8 lines
Quoted 2 lines

I'll make a formal patch and submit it with you CC'd. Let's hope it will not break anything :)

Hi, we've also found this issue on HP X360, but both patches don't work with on it.

My current workaround is to save INTMASK before clearing then restore it after, but I'm not sure if there's any side-effect by doing so.

Did you try the latest patch here?

https://patchwork.ozlabs.org/patch/661413/

#13 lore raw
Quoted 28 lines · Mika Westerberg
Quoted 27 lines · Phidias Chiang
Quoted 15 lines · Mika Westerberg
Quoted 14 lines · Anisse Astier
Quoted 11 lines · Mika Westerberg
Quoted 1 line · Anisse Astier

pin 25 (GPIO_SUS6) GPIO ctrl0 0xec918201 ctrl1 0x05c00001

It is this one (GPIO_SUS6).

I wonder if we can relax the driver so that it only masks pins which are not configured to generate interrupts by the BIOS. I quickly tried following on one Braswell machine and it did not generate spurious interrupts.

Can you check if this works for you?

Quoted 7 lines
Quoted 2 lines

I tried it, your patch is working. It gives the same result as not clearing the north community. I receive the ACPI events.

OK, thanks for testing.

I'll make a formal patch and submit it with you CC'd. Let's hope it will not break anything :)

Hi, we've also found this issue on HP X360, but both patches don't work with on it.

Quoted 6 lines
Quoted 2 lines

My current workaround is to save INTMASK before clearing then restore it after, but I'm not sure if there's any side-effect by doing so.

Did you try the latest patch here?

https://patchwork.ozlabs.org/patch/661413/

yes, that, including another patch in this thread. I inserted some debug message and found out INTMASK was still cleared after gpiochip_irqchip_add, hope it helps.

author maintainer
#14 lore raw
Quoted 32 lines · Phidias Chiang
Quoted 31 lines · Mika Westerberg
Quoted 29 lines · Phidias Chiang
Quoted 15 lines · Mika Westerberg
Quoted 14 lines · Anisse Astier
Quoted 11 lines · Mika Westerberg
Quoted 1 line · Anisse Astier

pin 25 (GPIO_SUS6) GPIO ctrl0 0xec918201 ctrl1 0x05c00001

It is this one (GPIO_SUS6).

I wonder if we can relax the driver so that it only masks pins which are not configured to generate interrupts by the BIOS. I quickly tried following on one Braswell machine and it did not generate spurious interrupts.

Can you check if this works for you?

Quoted 7 lines
Quoted 2 lines

I tried it, your patch is working. It gives the same result as not clearing the north community. I receive the ACPI events.

OK, thanks for testing.

I'll make a formal patch and submit it with you CC'd. Let's hope it will not break anything :)

Hi, we've also found this issue on HP X360, but both patches don't work with on it.

My current workaround is to save INTMASK before clearing then restore it after, but I'm not sure if there's any side-effect by doing so.

Quoted 7 lines
Quoted 3 lines

Did you try the latest patch here?

https://patchwork.ozlabs.org/patch/661413/

yes, that, including another patch in this thread. I inserted some debug message and found out INTMASK was still cleared after gpiochip_irqchip_add, hope it helps.

Hmm, how can that happen? The patch removes clearing of INTMASK and only other place where it is cleared temporarily is on resume. Can you add dev_info() calls like:

	/* Clear all interrupts */
	chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
	dev_info(pctrl->dev, "INTMASK0: 0x%08x\n", readl(pctrl->regs + CHV_INTMASK));

	...

	gpiochip_set_chained_irqchip(chip, &chv_gpio_irqchip, irq,
				     chv_gpio_irq_handler);
	dev_info(pctrl->dev, "INTMASK1: 0x%08x\n", readl(pctrl->regs + CHV_INTMASK));
	return 0;

It should print the same values both time.

Also which interrupt does not work and can you send me output of /proc/interrupts?

#15 lore raw
Quoted 17 lines · Mika Westerberg

On Fri, Sep 09, 2016 at 12:28:43AM +0800, Phidias Chiang wrote:

Hmm, how can that happen? The patch removes clearing of INTMASK and only other place where it is cleared temporarily is on resume. Can you add dev_info() calls like:

	/* Clear all interrupts */
	chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
	dev_info(pctrl->dev, "INTMASK0: 0x%08x\n", readl(pctrl->regs + CHV_INTMASK));

	...

	gpiochip_set_chained_irqchip(chip, &chv_gpio_irqchip, irq,
				     chv_gpio_irq_handler);
	dev_info(pctrl->dev, "INTMASK1: 0x%08x\n", readl(pctrl->regs + CHV_INTMASK));
	return 0;
Quoted 4 lines

It should print the same values both time.

Also which interrupt does not work and can you send me output of /proc/interrupts?

Output in dmesg:

[    2.054475] cherryview-pinctrl INT33FF:00: INTMASK0: 0x00000006
[    2.055247] cherryview-pinctrl INT33FF:00: INTMASK1: 0x00000000
[    2.055375] cherryview-pinctrl INT33FF:01: INTMASK0: 0x00004000
[    2.056931] cherryview-pinctrl INT33FF:01: INTMASK1: 0x00000000
[    2.057036] cherryview-pinctrl INT33FF:02: INTMASK0: 0x00000000
[    2.057367] cherryview-pinctrl INT33FF:02: INTMASK1: 0x00000000
[    2.057489] cherryview-pinctrl INT33FF:03: INTMASK0: 0x00000000
[    2.058337] cherryview-pinctrl INT33FF:03: INTMASK1: 0x00000000

So it's somehow got cleared in the process after.

And the following link is the complete /proc/interrupts:
http://pastebin.com/qwamyKZb

THe interrupt doesn't work is 9, when I made it work it responsed to pressing hotkeys.

author maintainer
#16 lore raw
Quoted 33 lines · Phidias Chiang
Quoted 17 lines · Mika Westerberg

On Fri, Sep 09, 2016 at 12:28:43AM +0800, Phidias Chiang wrote:

Hmm, how can that happen? The patch removes clearing of INTMASK and only other place where it is cleared temporarily is on resume. Can you add dev_info() calls like:

	/* Clear all interrupts */
	chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
	dev_info(pctrl->dev, "INTMASK0: 0x%08x\n", readl(pctrl->regs + CHV_INTMASK));

	...

	gpiochip_set_chained_irqchip(chip, &chv_gpio_irqchip, irq,
				     chv_gpio_irq_handler);
	dev_info(pctrl->dev, "INTMASK1: 0x%08x\n", readl(pctrl->regs + CHV_INTMASK));
	return 0;
Quoted 4 lines

It should print the same values both time.

Also which interrupt does not work and can you send me output of /proc/interrupts?

Output in dmesg:

[    2.054475] cherryview-pinctrl INT33FF:00: INTMASK0: 0x00000006
[    2.055247] cherryview-pinctrl INT33FF:00: INTMASK1: 0x00000000
[    2.055375] cherryview-pinctrl INT33FF:01: INTMASK0: 0x00004000
[    2.056931] cherryview-pinctrl INT33FF:01: INTMASK1: 0x00000000
[    2.057036] cherryview-pinctrl INT33FF:02: INTMASK0: 0x00000000
[    2.057367] cherryview-pinctrl INT33FF:02: INTMASK1: 0x00000000
[    2.057489] cherryview-pinctrl INT33FF:03: INTMASK0: 0x00000000
[    2.058337] cherryview-pinctrl INT33FF:03: INTMASK1: 0x00000000
Quoted 1 line

So it's somehow got cleared in the process after.

Only other place where we touch INTMASK register is chv_gpio_irq_mask_unmask(). Can you add some debug there to find out the caller?

Quoted 2 lines

And the following link is the complete /proc/interrupts:
http://pastebin.com/qwamyKZb

Looks quite normal.

Quoted 2 lines

THe interrupt doesn't work is 9, when I made it work it responsed to pressing hotkeys.

9 is the SCI interrupt used by ACPI which explains.

author maintainer
#17 lore raw
Quoted 34 lines · Mika Westerberg
Quoted 33 lines · Phidias Chiang
Quoted 17 lines · Mika Westerberg

On Fri, Sep 09, 2016 at 12:28:43AM +0800, Phidias Chiang wrote:

Hmm, how can that happen? The patch removes clearing of INTMASK and only other place where it is cleared temporarily is on resume. Can you add dev_info() calls like:

	/* Clear all interrupts */
	chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
	dev_info(pctrl->dev, "INTMASK0: 0x%08x\n", readl(pctrl->regs + CHV_INTMASK));

	...

	gpiochip_set_chained_irqchip(chip, &chv_gpio_irqchip, irq,
				     chv_gpio_irq_handler);
	dev_info(pctrl->dev, "INTMASK1: 0x%08x\n", readl(pctrl->regs + CHV_INTMASK));
	return 0;
Quoted 4 lines

It should print the same values both time.

Also which interrupt does not work and can you send me output of /proc/interrupts?

Output in dmesg:

[    2.054475] cherryview-pinctrl INT33FF:00: INTMASK0: 0x00000006
[    2.055247] cherryview-pinctrl INT33FF:00: INTMASK1: 0x00000000
[    2.055375] cherryview-pinctrl INT33FF:01: INTMASK0: 0x00004000
[    2.056931] cherryview-pinctrl INT33FF:01: INTMASK1: 0x00000000
[    2.057036] cherryview-pinctrl INT33FF:02: INTMASK0: 0x00000000
[    2.057367] cherryview-pinctrl INT33FF:02: INTMASK1: 0x00000000
[    2.057489] cherryview-pinctrl INT33FF:03: INTMASK0: 0x00000000
[    2.058337] cherryview-pinctrl INT33FF:03: INTMASK1: 0x00000000
Quoted 5 lines
Quoted 1 line

So it's somehow got cleared in the process after.

Only other place where we touch INTMASK register is chv_gpio_irq_mask_unmask(). Can you add some debug there to find out the caller?

Something like this:

drivers/pinctrl/intel/pinctrl-cherryview.c +5 -0
index 0fe8fad..95fa3b1 100644
@@ -1357,6 +1357,11 @@ static void chv_gpio_irq_mask_unmask(struct irq_data *d, bool mask)
 		value |= BIT(intr_line);
 	chv_writel(value, pctrl->regs + CHV_INTMASK);
 
+	if (printk_ratelimit()) {
+		dev_info(pctrl->dev, "%smask pin %u intmask 0x%08x\n",
+			 mask ? "" : "un", pin, readl(pctrl->regs + CHV_INTMASK));
+	}
+
 	raw_spin_unlock_irqrestore(&chv_lock, flags);
 }
 
#18 lore raw
Quoted 15 lines · Mika Westerberg
Quoted 5 lines · Mika Westerberg

On Fri, Sep 09, 2016 at 04:23:58PM +0800, Phidias Chiang wrote:

Only other place where we touch INTMASK register is chv_gpio_irq_mask_unmask(). Can you add some debug there to find out the caller?

Something like this:

drivers/pinctrl/intel/pinctrl-cherryview.c +0 -0
index 0fe8fad..95fa3b1 100644
@@ -1357,6 +1357,11 @@ static void chv_gpio_irq_mask_unmask(struct irq_data *d, bool mask)
 		value |= BIT(intr_line);

drivers/pinctrl/intel/pinctrl-cherryview.c static void chv_gpio_irq_mask_unmask(struct irq_data *d, bool mask) · line 1367

Quoted 10 lines
drivers/pinctrl/intel/pinctrl-cherryview.c +5 -0
 	chv_writel(value, pctrl->regs + CHV_INTMASK);
 
+	if (printk_ratelimit()) {
+		dev_info(pctrl->dev, "%smask pin %u intmask 0x%08x\n",
+			 mask ? "" : "un", pin, readl(pctrl->regs + CHV_INTMASK));
+	}
+
 	raw_spin_unlock_irqrestore(&chv_lock, flags);
 }
 

With printk_ratelimit():

[    2.058485] cherryview-pinctrl INT33FF:00: INTMASK0: 0x00000006
[    2.058513] cherryview-pinctrl INT33FF:00: mask pin 0 intmask 0x00000006
[    2.058533] cherryview-pinctrl INT33FF:00: mask pin 1 intmask 0x00000006
[    2.058551] cherryview-pinctrl INT33FF:00: mask pin 2 intmask 0x00000006
[    2.058569] cherryview-pinctrl INT33FF:00: mask pin 3 intmask 0x00000006
[    2.058587] cherryview-pinctrl INT33FF:00: mask pin 4 intmask 0x00000006
[    2.058604] cherryview-pinctrl INT33FF:00: mask pin 5 intmask 0x00000006
[    2.058623] cherryview-pinctrl INT33FF:00: mask pin 6 intmask 0x00000006
[    2.058641] cherryview-pinctrl INT33FF:00: mask pin 7 intmask 0x00000006
[    2.058663] cherryview-pinctrl INT33FF:00: mask pin 15 intmask 0x00000006
[    2.059401] cherryview-pinctrl INT33FF:00: INTMASK1: 0x00000000
[    2.059551] cherryview-pinctrl INT33FF:01: INTMASK0: 0x00004000
[    2.061272] cherryview-pinctrl INT33FF:01: INTMASK1: 0x00000000
[    2.061516] cherryview-pinctrl INT33FF:02: INTMASK0: 0x00000000
[    2.061906] cherryview-pinctrl INT33FF:02: INTMASK1: 0x00000000
[    2.062116] cherryview-pinctrl INT33FF:03: INTMASK0: 0x00000000
[    2.062956] cherryview-pinctrl INT33FF:03: INTMASK1: 0x00000000

w/o printk_ratelimit():
http://pastebin.com/dLDELDB4

The main difference is the intmask turns to 0x4 on pin 75 and 0x0 afterwards for INT33FF:00. And same thing happened with :01 on pin 25

author maintainer
#19 lore raw
Quoted 47 lines · Phidias Chiang
Quoted 15 lines · Mika Westerberg
Quoted 5 lines · Mika Westerberg

On Fri, Sep 09, 2016 at 04:23:58PM +0800, Phidias Chiang wrote:

Only other place where we touch INTMASK register is chv_gpio_irq_mask_unmask(). Can you add some debug there to find out the caller?

Something like this:

drivers/pinctrl/intel/pinctrl-cherryview.c +0 -0
index 0fe8fad..95fa3b1 100644
@@ -1357,6 +1357,11 @@ static void chv_gpio_irq_mask_unmask(struct irq_data *d, bool mask)
 		value |= BIT(intr_line);

drivers/pinctrl/intel/pinctrl-cherryview.c static void chv_gpio_irq_mask_unmask(struct irq_data *d, bool mask) · line 1367

Quoted 10 lines
drivers/pinctrl/intel/pinctrl-cherryview.c +5 -0
 	chv_writel(value, pctrl->regs + CHV_INTMASK);
 
+	if (printk_ratelimit()) {
+		dev_info(pctrl->dev, "%smask pin %u intmask 0x%08x\n",
+			 mask ? "" : "un", pin, readl(pctrl->regs + CHV_INTMASK));
+	}
+
 	raw_spin_unlock_irqrestore(&chv_lock, flags);
 }
 

With printk_ratelimit():

[    2.058485] cherryview-pinctrl INT33FF:00: INTMASK0: 0x00000006
[    2.058513] cherryview-pinctrl INT33FF:00: mask pin 0 intmask 0x00000006
[    2.058533] cherryview-pinctrl INT33FF:00: mask pin 1 intmask 0x00000006
[    2.058551] cherryview-pinctrl INT33FF:00: mask pin 2 intmask 0x00000006
[    2.058569] cherryview-pinctrl INT33FF:00: mask pin 3 intmask 0x00000006
[    2.058587] cherryview-pinctrl INT33FF:00: mask pin 4 intmask 0x00000006
[    2.058604] cherryview-pinctrl INT33FF:00: mask pin 5 intmask 0x00000006
[    2.058623] cherryview-pinctrl INT33FF:00: mask pin 6 intmask 0x00000006
[    2.058641] cherryview-pinctrl INT33FF:00: mask pin 7 intmask 0x00000006
[    2.058663] cherryview-pinctrl INT33FF:00: mask pin 15 intmask 0x00000006
[    2.059401] cherryview-pinctrl INT33FF:00: INTMASK1: 0x00000000
[    2.059551] cherryview-pinctrl INT33FF:01: INTMASK0: 0x00004000
[    2.061272] cherryview-pinctrl INT33FF:01: INTMASK1: 0x00000000
[    2.061516] cherryview-pinctrl INT33FF:02: INTMASK0: 0x00000000
[    2.061906] cherryview-pinctrl INT33FF:02: INTMASK1: 0x00000000
[    2.062116] cherryview-pinctrl INT33FF:03: INTMASK0: 0x00000000
[    2.062956] cherryview-pinctrl INT33FF:03: INTMASK1: 0x00000000
Quoted 5 lines

w/o printk_ratelimit():
http://pastebin.com/dLDELDB4

The main difference is the intmask turns to 0x4 on pin 75 and 0x0 afterwards for INT33FF:00. And same thing happened with :01 on pin 25

OK, I see what is going on now. When I changed handle_simple_irq to handle_bad_irq, the IRQ core in __irq_do_set_handler() thinks the handler is uninstalled and masks the line.

If you change handle_bad_irq to handle_simple_irq, in call to gpiochip_irqchip_add(), does it work then?

#20 lore raw
Quoted 7 lines · Mika Westerberg

OK, I see what is going on now. When I changed handle_simple_irq to handle_bad_irq, the IRQ core in __irq_do_set_handler() thinks the handler is uninstalled and masks the line.

If you change handle_bad_irq to handle_simple_irq, in call to gpiochip_irqchip_add(), does it work then?

Yes it does :), thank you for the support!

author maintainer
#21 lore raw
Quoted 10 lines · Phidias Chiang
Quoted 7 lines · Mika Westerberg

OK, I see what is going on now. When I changed handle_simple_irq to handle_bad_irq, the IRQ core in __irq_do_set_handler() thinks the handler is uninstalled and masks the line.

If you change handle_bad_irq to handle_simple_irq, in call to gpiochip_irqchip_add(), does it work then?

Yes it does :), thank you for the support!

Thanks for testing.

So we need to use handle_simple_irq here instead.

Linus, do you see any problems with that?

#22 lore raw
Quoted 10 lines · Mika Westerberg
Quoted 9 lines · Phidias Chiang
Quoted 7 lines · Mika Westerberg

OK, I see what is going on now. When I changed handle_simple_irq to handle_bad_irq, the IRQ core in __irq_do_set_handler() thinks the handler is uninstalled and masks the line.

If you change handle_bad_irq to handle_simple_irq, in call to gpiochip_irqchip_add(), does it work then?

Quoted 7 lines
Quoted 1 line

Yes it does :), thank you for the support!

Thanks for testing.

So we need to use handle_simple_irq here instead.

Linus, do you see any problems with that?

I need to see the patch in its context with a commit message, I can't figure it out from the thread.

handle_simple_irq() is for something generic not level- or edge-triggered. If you support specific triggers only, it should not be used.

Nominally assigning handle_bad_irq() until a specific edge or level is requested is the right thing to do, since the IRQ is really not configured for anything at all and hence has undefined behaviour.

But write a patch and involve the irqchip people I guess?

Yours,
Linus Walleij

author maintainer
#23 lore raw
Quoted 23 lines · Linus Walleij
Quoted 10 lines · Mika Westerberg
Quoted 9 lines · Phidias Chiang
Quoted 7 lines · Mika Westerberg

OK, I see what is going on now. When I changed handle_simple_irq to handle_bad_irq, the IRQ core in __irq_do_set_handler() thinks the handler is uninstalled and masks the line.

If you change handle_bad_irq to handle_simple_irq, in call to gpiochip_irqchip_add(), does it work then?

Quoted 7 lines
Quoted 1 line

Yes it does :), thank you for the support!

Thanks for testing.

So we need to use handle_simple_irq here instead.

Linus, do you see any problems with that?

I need to see the patch in its context with a commit message, I can't figure it out from the thread.

Quoted 8 lines

handle_simple_irq() is for something generic not level- or edge-triggered. If you support specific triggers only, it should not be used.

Nominally assigning handle_bad_irq() until a specific edge or level is requested is the right thing to do, since the IRQ is really not configured for anything at all and hence has undefined behaviour.

For Cherryview/Braswell some interrupts are actually configured by the BIOS but they are routed directly to the I/O-APIC and are supposed to be handled without involvement of the GPIO driver (an example of this is the ACPI SCI interrupt). However, INTMASK GPIO register can still be used to mask the interrupt in question.

So when we specify handle_bad_irq as handler the IRQ core thinks the handler is being uninstalled and masks the interrupt.

Quoted 1 line

But write a patch and involve the irqchip people I guess?

OK, I'll do this.

Thanks.

#24 lore raw
Quoted 33 lines · Mika Westerberg
Quoted 23 lines · Linus Walleij
Quoted 10 lines · Mika Westerberg
Quoted 9 lines · Phidias Chiang
Quoted 7 lines · Mika Westerberg

OK, I see what is going on now. When I changed handle_simple_irq to handle_bad_irq, the IRQ core in __irq_do_set_handler() thinks the handler is uninstalled and masks the line.

If you change handle_bad_irq to handle_simple_irq, in call to gpiochip_irqchip_add(), does it work then?

Quoted 7 lines
Quoted 1 line

Yes it does :), thank you for the support!

Thanks for testing.

So we need to use handle_simple_irq here instead.

Linus, do you see any problems with that?

I need to see the patch in its context with a commit message, I can't figure it out from the thread.

Quoted 8 lines

handle_simple_irq() is for something generic not level- or edge-triggered. If you support specific triggers only, it should not be used.

Nominally assigning handle_bad_irq() until a specific edge or level is requested is the right thing to do, since the IRQ is really not configured for anything at all and hence has undefined behaviour.

Quoted 5 lines

For Cherryview/Braswell some interrupts are actually configured by the BIOS but they are routed directly to the I/O-APIC and are supposed to be handled without involvement of the GPIO driver (an example of this is the ACPI SCI interrupt). However, INTMASK GPIO register can still be used to mask the interrupt in question.

A-ha! But why are you registering a irqdomain entry for an interrupt that cannot be used, hm?

Quoted 2 lines

So when we specify handle_bad_irq as handler the IRQ core thinks the handler is being uninstalled and masks the interrupt.

You should not register any handle for it.

In fact, IMO the irqdomain should reject it being mapped, as it is not for the kernel to use.

Check:
drivers/irqchip/irq-vic.c

We supply a u32 to the driver from the device tree named "valid-mask". This has bits set to 1 for the valid (to be mapped) IRQs and zero for those we may not touch.

So in our vic_irqdomain_map() call we have:

/* Skip invalid IRQs, only register handlers for the real ones */ if (!(v->valid_sources & (1 << hwirq)))

        return -EPERM;

So it can never be mapped.

Also notice:

/* create an IRQ mapping for each valid IRQ */
for (i = 0; i < fls(valid_sources); i++)

        if (valid_sources & (1 << i))
                irq_create_mapping(v->domain, i);

So we only create mappings where there are valid IRQs, skipping over any "holes" in the mapping.

We should do something like this.

To make this play nicely with gpiolib_irqchip_add() I suggest adding a bitmap valid_mask to struct gpio_chip() in include/linux/gpio/driver.h
inside the CONFIG_GPIOLIB_IRQCHIP

I guess

u32 bitmap[MAX_IRQS_FOR_A_GPIO_CHIP];

Then augment the generic GPIO IRQCHIP helpers in drivers/gpio/gpiolib.c per above so that the invalid IRQs can't be mapped.

The driver would just:

/* Mark line N as invalid: used by BIOS */
set_bit(&chip->valid_mask, N);

Before calling gpiolib_irqchip_add().

This has the downside of roofing the number of lines that can be flagged as valid/invalid, but I'm open to more advanced ideas on this, but the check needs to be fast in the irqdomain.

Yours,
Linus Walleij

author maintainer
#25 lore raw
Quoted 35 lines · Linus Walleij
Quoted 33 lines · Mika Westerberg
Quoted 31 lines · Linus Walleij
Quoted 10 lines · Mika Westerberg
Quoted 9 lines · Phidias Chiang
Quoted 7 lines · Mika Westerberg

OK, I see what is going on now. When I changed handle_simple_irq to handle_bad_irq, the IRQ core in __irq_do_set_handler() thinks the handler is uninstalled and masks the line.

If you change handle_bad_irq to handle_simple_irq, in call to gpiochip_irqchip_add(), does it work then?

Quoted 7 lines
Quoted 1 line

Yes it does :), thank you for the support!

Thanks for testing.

So we need to use handle_simple_irq here instead.

Linus, do you see any problems with that?

I need to see the patch in its context with a commit message, I can't figure it out from the thread.

handle_simple_irq() is for something generic not level- or edge-triggered. If you support specific triggers only, it should not be used.

Nominally assigning handle_bad_irq() until a specific edge or level is requested is the right thing to do, since the IRQ is really not configured for anything at all and hence has undefined behaviour.

Quoted 8 lines
Quoted 5 lines

For Cherryview/Braswell some interrupts are actually configured by the BIOS but they are routed directly to the I/O-APIC and are supposed to be handled without involvement of the GPIO driver (an example of this is the ACPI SCI interrupt). However, INTMASK GPIO register can still be used to mask the interrupt in question.

A-ha! But why are you registering a irqdomain entry for an interrupt that cannot be used, hm?

Unfortunately there is no way to figure out from the hardware (or firmware) whether the interrupt is supposed to be used by the GPIO driver or something else.

Quoted 44 lines
Quoted 2 lines

So when we specify handle_bad_irq as handler the IRQ core thinks the handler is being uninstalled and masks the interrupt.

You should not register any handle for it.

In fact, IMO the irqdomain should reject it being mapped, as it is not for the kernel to use.

Check:
drivers/irqchip/irq-vic.c

We supply a u32 to the driver from the device tree named "valid-mask". This has bits set to 1 for the valid (to be mapped) IRQs and zero for those we may not touch.

So in our vic_irqdomain_map() call we have:

/* Skip invalid IRQs, only register handlers for the real ones */ if (!(v->valid_sources & (1 << hwirq)))

        return -EPERM;

So it can never be mapped.

Also notice:

/* create an IRQ mapping for each valid IRQ */
for (i = 0; i < fls(valid_sources); i++)

        if (valid_sources & (1 << i))
                irq_create_mapping(v->domain, i);

So we only create mappings where there are valid IRQs, skipping over any "holes" in the mapping.

We should do something like this.

To make this play nicely with gpiolib_irqchip_add() I suggest adding a bitmap valid_mask to struct gpio_chip() in include/linux/gpio/driver.h
inside the CONFIG_GPIOLIB_IRQCHIP

I guess

u32 bitmap[MAX_IRQS_FOR_A_GPIO_CHIP];

Quoted 8 lines

Then augment the generic GPIO IRQCHIP helpers in drivers/gpio/gpiolib.c per above so that the invalid IRQs can't be mapped.

The driver would just:

/* Mark line N as invalid: used by BIOS */
set_bit(&chip->valid_mask, N);

Otherwise this probably works but it forces us to hardcode these "special" lines in the driver and I would like to avoid that if possible.

#26 lore raw
Quoted 7 lines · Mika Westerberg

[Me]

Quoted 2 lines

A-ha! But why are you registering a irqdomain entry for an interrupt that cannot be used, hm?

Unfortunately there is no way to figure out from the hardware (or firmware) whether the interrupt is supposed to be used by the GPIO driver or something else.

So the fact that we kept it in valid-mask in the DT was a hint: it is part of the hardware description.

Isn't this (a list of what IRQs are reserved by BIOS) by sheer logic something that ACPI should provide?

Or is this one of those "well we could alter ACPI tables but we can't because they already shipped so we just can't so now we need to hack around it"?

Letting Linux map an interrupt it cannot access and then papering it over by using handle_simple_irq() just feels wrong to me.

I would argue for associating the mask of BIOS-reserved IRQs with something in ACPI and implement the mentioned scheme to avoid even mapping them seems most logical.

If we have to use handle_simple_irq() by default on all I prefer to put in a very fat comment of the type:

/*
* HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
*
* Some interrupts are BIOS-reserved but we don't know which ones!
* So we anyway map them and assign the handle_simple_irq() handle
* to them, leaving them unmasked, pretending they can be used, and
* pray no-one will accidentally use these GPIO IRQs.
*
* HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
*/

Yours,
Linus Walleij

author maintainer
#27 lore raw
Quoted 13 lines · Linus Walleij
Quoted 7 lines · Mika Westerberg

[Me]

Quoted 2 lines

A-ha! But why are you registering a irqdomain entry for an interrupt that cannot be used, hm?

Unfortunately there is no way to figure out from the hardware (or firmware) whether the interrupt is supposed to be used by the GPIO driver or something else.

So the fact that we kept it in valid-mask in the DT was a hint: it is part of the hardware description.

Quoted 6 lines

Isn't this (a list of what IRQs are reserved by BIOS) by sheer logic something that ACPI should provide?

Or is this one of those "well we could alter ACPI tables but we can't because they already shipped so we just can't so now we need to hack around it"?

Isn't it always the case? ;-)

Once the hardware enters stores the firmware cannot be changed anymore and we get all the fun working around problems in the OS.

Quoted 6 lines

Letting Linux map an interrupt it cannot access and then papering it over by using handle_simple_irq() just feels wrong to me.

I would argue for associating the mask of BIOS-reserved IRQs with something in ACPI and implement the mentioned scheme to avoid even mapping them seems most logical.

I'm going to re-read the hardware spec and see if there is anything we can do about this. The newer hardware (Skylake, Broxton) has a bit that tells the IRQ is routed directly to I/O-APIC but unfortunately Braswell misses that. There may be something else, though.

Quoted 13 lines

If we have to use handle_simple_irq() by default on all I prefer to put in a very fat comment of the type:

/*
* HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
*
* Some interrupts are BIOS-reserved but we don't know which ones!
* So we anyway map them and assign the handle_simple_irq() handle
* to them, leaving them unmasked, pretending they can be used, and
* pray no-one will accidentally use these GPIO IRQs.
*
* HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
*/

OK, got it.

Let me try to come up with a solution that both works and does not involve using handle_simple_irq.

#28 lore raw
Quoted 5 lines · Mika Westerberg
Quoted 3 lines · Linus Walleij

Isn't this (a list of what IRQs are reserved by BIOS) by sheer logic something that ACPI should provide?

Quoted 8 lines
Quoted 3 lines

Or is this one of those "well we could alter ACPI tables but we can't because they already shipped so we just can't so now we need to hack around it"?

Isn't it always the case? ;-)

Once the hardware enters stores the firmware cannot be changed anymore and we get all the fun working around problems in the OS.

To me this is just a big proof that the ACPI design-by-committee isn't working. With Device Tree we review bindings and drivers together and then we tend to not miss stuff like this as much.

But I realize as soon as I say that someone will pull out a counter-example of stupid DT bindings used in the wild and make me look stupid.

Quoted 11 lines
Quoted 6 lines

Letting Linux map an interrupt it cannot access and then papering it over by using handle_simple_irq() just feels wrong to me.

I would argue for associating the mask of BIOS-reserved IRQs with something in ACPI and implement the mentioned scheme to avoid even mapping them seems most logical.

I'm going to re-read the hardware spec and see if there is anything we can do about this. The newer hardware (Skylake, Broxton) has a bit that tells the IRQ is routed directly to I/O-APIC but unfortunately Braswell misses that. There may be something else, though.

So as far as we can determine:

(A) we are running on Braswell and
(B) we are probing this driver

we can conclude that

(C) IRQs A,B,C are reserved by BIOS?

That sounds doable?

Yours,
Linus Walleij

author maintainer
#29 lore raw
Quoted 7 lines · Linus Walleij
Quoted 4 lines

I'm going to re-read the hardware spec and see if there is anything we can do about this. The newer hardware (Skylake, Broxton) has a bit that tells the IRQ is routed directly to I/O-APIC but unfortunately Braswell misses that. There may be something else, though.

So as far as we can determine:

Quoted 8 lines

(A) we are running on Braswell and
(B) we are probing this driver

we can conclude that

(C) IRQs A,B,C are reserved by BIOS?

That sounds doable?

Yes, it's doable but that requires some hard coding in the driver :-/

I'll look into it.

#30 lore raw
Quoted 13 lines · Mika Westerberg
Quoted 12 lines · Linus Walleij
Quoted 4 lines

I'm going to re-read the hardware spec and see if there is anything we can do about this. The newer hardware (Skylake, Broxton) has a bit that tells the IRQ is routed directly to I/O-APIC but unfortunately Braswell misses that. There may be something else, though.

So as far as we can determine:

(A) we are running on Braswell and
(B) we are probing this driver

we can conclude that

Quoted 7 lines
Quoted 3 lines

(C) IRQs A,B,C are reserved by BIOS?

That sounds doable?

Yes, it's doable but that requires some hard coding in the driver :-/

From my point of view that is the lesser of two evils.

We only have hard-coding (syntactic) madness over having behaviour-dependent (semantic) madness.

Yours,
Linus Walleij

author maintainer
#31 lore raw
Quoted 17 lines · Linus Walleij
Quoted 15 lines · Mika Westerberg
Quoted 14 lines · Linus Walleij
Quoted 4 lines

I'm going to re-read the hardware spec and see if there is anything we can do about this. The newer hardware (Skylake, Broxton) has a bit that tells the IRQ is routed directly to I/O-APIC but unfortunately Braswell misses that. There may be something else, though.

So as far as we can determine:

(A) we are running on Braswell and
(B) we are probing this driver

we can conclude that

(C) IRQs A,B,C are reserved by BIOS?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

That sounds doable?

Yes, it's doable but that requires some hard coding in the driver :-/

From my point of view that is the lesser of two evils.

We only have hard-coding (syntactic) madness over having behaviour-dependent (semantic) madness.

I re-read the hardware spec now and it occured to me that for north and southwest community, only the first 8 IRQs can be used as interrupts (all GPIOs which have IntSel value < 8). Rest can only trigger GPEs which are used for EC events.

I'll submit patches shortly using this information and valid_mask as you suggested.

author maintainer
#32 lore raw

PATCH 1/2 gpiolib: Add possibility to mask which GPIOs are added to IRQ domain

In reply to Linus Walleij

When using GPIO irqchip helpers to setup irqchip for a gpiolib based driver, it is not possible to select which GPIOs to add to the IRQ domain. Instead it just adds all GPIOs which is not always desired. For example there might be GPIOs that for some reason just cannot be used as interrupts at all.

To make this possible we add valid_mask to each gpio_chip and by default assume all GPIOs can be used as interrupts. Drivers can then tune this using clear_bit() or similar before they call gpiochip_irqchip_add().

---
 drivers/gpio/gpiolib.c      | 32 +++++++++++++++++++++++++++++---
 include/linux/gpio/driver.h |  1 +
 2 files changed, 30 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib.c +29 -3
index 53ff25ac66d8..d84c23b47f44 100644
@@ -1186,6 +1186,18 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
 		if (status)
 			goto err_remove_chip;
 	}
+
+#ifdef CONFIG_GPIOLIB_IRQCHIP
+	chip->valid_mask = kcalloc(BITS_TO_LONGS(chip->ngpio), sizeof(long),
+				   GFP_KERNEL);
+	if (!chip->valid_mask)
+		return -ENOMEM;
+
+	/* All GPIOs are valid interrupt sources by default */
+	for (i = 0; i < chip->ngpio; i++)
+		set_bit(i, chip->valid_mask);
+#endif
+
 	return 0;
 
 err_remove_chip:
@@ -1442,9 +1454,12 @@ void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip,
 	}
 
 	/* Set the parent IRQ for all affected IRQs */
-	for (offset = 0; offset < gpiochip->ngpio; offset++)
+	for (offset = 0; offset < gpiochip->ngpio; offset++) {
+		if (!test_bit(offset, gpiochip->valid_mask))
+			continue;
 		irq_set_parent(irq_find_mapping(gpiochip->irqdomain, offset),
 			       parent_irq);
+	}
 }
 EXPORT_SYMBOL_GPL(gpiochip_set_chained_irqchip);
 
@@ -1551,9 +1566,12 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
 
 	/* Remove all IRQ mappings and delete the domain */
 	if (gpiochip->irqdomain) {
-		for (offset = 0; offset < gpiochip->ngpio; offset++)
+		for (offset = 0; offset < gpiochip->ngpio; offset++) {
+			if (!test_bit(offset, gpiochip->valid_mask))
+				continue;
 			irq_dispose_mapping(
 				irq_find_mapping(gpiochip->irqdomain, offset));
+		}
 		irq_domain_remove(gpiochip->irqdomain);
 	}
 
@@ -1562,6 +1580,9 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
 		gpiochip->irqchip->irq_release_resources = NULL;
 		gpiochip->irqchip = NULL;
 	}
+
+	kfree(gpiochip->valid_mask);
+	gpiochip->valid_mask = NULL;
 }
 
 /**
@@ -1597,6 +1618,7 @@ int _gpiochip_irqchip_add(struct gpio_chip *gpiochip,
 			  struct lock_class_key *lock_key)
 {
 	struct device_node *of_node;
+	bool irq_base_set = false;
 	unsigned int offset;
 	unsigned irq_base = 0;
 
@@ -1646,13 +1668,17 @@ int _gpiochip_irqchip_add(struct gpio_chip *gpiochip,
 	 * necessary to allocate descriptors for all IRQs.
 	 */
 	for (offset = 0; offset < gpiochip->ngpio; offset++) {
+		if (!test_bit(offset, gpiochip->valid_mask))
+			continue;
 		irq_base = irq_create_mapping(gpiochip->irqdomain, offset);
-		if (offset == 0)
+		if (!irq_base_set) {
 			/*
 			 * Store the base into the gpiochip to be used when
 			 * unmapping the irqs.
 			 */
 			gpiochip->irq_base = irq_base;
+			irq_base_set = true;
+		}
 	}
 
 	acpi_gpiochip_request_interrupts(gpiochip);
include/linux/gpio/driver.h +1 -0
index 50882e09289b..8a7430230562 100644
@@ -191,6 +191,7 @@ struct gpio_chip {
 	unsigned int		irq_default_type;
 	int			irq_parent;
 	struct lock_class_key	*lock_key;
+	unsigned long		*valid_mask;
 #endif
 
 #if defined(CONFIG_OF_GPIO)
Signature · 1 line
2.9.3
author maintainer
#33 lore raw

PATCH 2/2 pinctrl: cherryview: Do not add all southwest and north GPIOs to IRQ domain

It turns out that for north and southwest communities, they can only generate GPIO interrupts for lower 8 interrupts (IntSel value). The upper part (8-15) can only generate GPEs (General Purpose Events).

Now the reason why EC events such as pressing hotkeys does not work if we mask all the interrupts is that in order to generate either interrupts or GPEs the INTMASK register must have that particular interrupt unmasked. In case of GPEs the CPU does not trigger normal interrupt (and thus the GPIO driver does not see it) but instead it causes SCI (System Control Interrupt) to be triggered with the GPE in question set.

To make this all work as expected we only add those GPIOs to the IRQ domain that can actually generate interrupts (IntSel value 0-7) and skip others.

---
Hi Phidias and Anisse,

Can you try this series out? It should finally fix the EC event issue(s) you have reported.

 drivers/pinctrl/intel/pinctrl-cherryview.c | 31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
drivers/pinctrl/intel/pinctrl-cherryview.c +31 -0
index 0fe8fad25e4d..717ef1b00adb 100644
@@ -134,6 +134,7 @@ struct chv_gpio_pinrange {
  * @gpio_ranges: An array of GPIO ranges in this community
  * @ngpio_ranges: Number of GPIO ranges
  * @ngpios: Total number of GPIOs in this community
+ * @nirqs: Total number of IRQs this community can generate
  */
 struct chv_community {
 	const char *uid;
@@ -146,6 +147,7 @@ struct chv_community {
 	const struct chv_gpio_pinrange *gpio_ranges;
 	size_t ngpio_ranges;
 	size_t ngpios;
+	size_t nirqs;
 };
 
 struct chv_pin_context {
@@ -396,6 +398,12 @@ static const struct chv_community southwest_community = {
 	.gpio_ranges = southwest_gpio_ranges,
 	.ngpio_ranges = ARRAY_SIZE(southwest_gpio_ranges),
 	.ngpios = ARRAY_SIZE(southwest_pins),
+	/*
+	 * Southwest community can benerate GPIO interrupts only for the
+	 * first 8 interrupts. The upper half (8-15) can only be used to
+	 * trigger GPEs.
+	 */
+	.nirqs = 8,
 };
 
 static const struct pinctrl_pin_desc north_pins[] = {
@@ -479,6 +487,12 @@ static const struct chv_community north_community = {
 	.gpio_ranges = north_gpio_ranges,
 	.ngpio_ranges = ARRAY_SIZE(north_gpio_ranges),
 	.ngpios = ARRAY_SIZE(north_pins),
+	/*
+	 * North community can benerate GPIO interrupts only for the first
+	 * 8 interrupts. The upper half (8-15) can only be used to trigger
+	 * GPEs.
+	 */
+	.nirqs = 8,
 };
 
 static const struct pinctrl_pin_desc east_pins[] = {
@@ -521,6 +535,7 @@ static const struct chv_community east_community = {
 	.gpio_ranges = east_gpio_ranges,
 	.ngpio_ranges = ARRAY_SIZE(east_gpio_ranges),
 	.ngpios = ARRAY_SIZE(east_pins),
+	.nirqs = 16,
 };
 
 static const struct pinctrl_pin_desc southeast_pins[] = {
@@ -646,6 +661,7 @@ static const struct chv_community southeast_community = {
 	.gpio_ranges = southeast_gpio_ranges,
 	.ngpio_ranges = ARRAY_SIZE(southeast_gpio_ranges),
 	.ngpios = ARRAY_SIZE(southeast_pins),
+	.nirqs = 16,
 };
 
 static const struct chv_community *chv_communities[] = {
@@ -1539,6 +1555,21 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
 		offset += range->npins;
 	}
 
+	/* Do not add GPIOs that can only generate GPEs to the IRQ domain */
+	for (i = 0; i < pctrl->community->npins; i++) {
+		const struct pinctrl_pin_desc *desc;
+		u32 intsel;
+
+		desc = &pctrl->community->pins[i];
+
+		intsel = readl(chv_padreg(pctrl, desc->number, CHV_PADCTRL0));
+		intsel &= CHV_PADCTRL0_INTSEL_MASK;
+		intsel >>= CHV_PADCTRL0_INTSEL_SHIFT;
+
+		if (intsel >= pctrl->community->nirqs)
+			clear_bit(i, chip->valid_mask);
+	}
+
 	/* Clear all interrupts */
 	chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
 
Signature · 1 line
2.9.3
#34 lore raw

Re: [PATCH 1/2] gpiolib: Add possibility to mask which GPIOs are added to IRQ domain

In reply to Mika Westerberg

Mika,

Quoted 22 lines · Mika Westerberg

When using GPIO irqchip helpers to setup irqchip for a gpiolib based driver, it is not possible to select which GPIOs to add to the IRQ domain. Instead it just adds all GPIOs which is not always desired. For example there might be GPIOs that for some reason just cannot be used as interrupts at all.

To make this possible we add valid_mask to each gpio_chip and by default assume all GPIOs can be used as interrupts. Drivers can then tune this using clear_bit() or similar before they call gpiochip_irqchip_add().

---
 drivers/gpio/gpiolib.c      | 32 +++++++++++++++++++++++++++++---
 include/linux/gpio/driver.h |  1 +
 2 files changed, 30 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib.c +0 -0
index 53ff25ac66d8..d84c23b47f44 100644

drivers/gpio/gpiolib.c int gpiochip_add_data(struct gpio_chip *chip, void *data) · line 1192

Quoted 7 lines
drivers/gpio/gpiolib.c +4 -0
@@ -1186,6 +1186,18 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
 		if (status)
 			goto err_remove_chip;
 	}
+
+#ifdef CONFIG_GPIOLIB_IRQCHIP
+	chip->valid_mask = kcalloc(BITS_TO_LONGS(chip->ngpio), sizeof(long),
+				   GFP_KERNEL);

Do we really want to make this a mandatory thing? In most cases, I'd expect this valid_mask to have all bits set, so you might as well not allocate it at all in that case (and only allocate it if you actually need it).

drivers/gpio/gpiolib.c int gpiochip_add_data(struct gpio_chip *chip, void *data) · line 1194

Quoted 2 lines
drivers/gpio/gpiolib.c +2 -0
+	if (!chip->valid_mask)
+		return -ENOMEM;

You really want to revise your error handling here.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
author maintainer
#35 lore raw

Re: [PATCH 1/2] gpiolib: Add possibility to mask which GPIOs are added to IRQ domain

Quoted 29 lines · Marc Zyngier

Mika,

Quoted 26 lines · Mika Westerberg

When using GPIO irqchip helpers to setup irqchip for a gpiolib based driver, it is not possible to select which GPIOs to add to the IRQ domain. Instead it just adds all GPIOs which is not always desired. For example there might be GPIOs that for some reason just cannot be used as interrupts at all.

To make this possible we add valid_mask to each gpio_chip and by default assume all GPIOs can be used as interrupts. Drivers can then tune this using clear_bit() or similar before they call gpiochip_irqchip_add().

---
 drivers/gpio/gpiolib.c      | 32 +++++++++++++++++++++++++++++---
 include/linux/gpio/driver.h |  1 +
 2 files changed, 30 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib.c +1 -0
index 53ff25ac66d8..d84c23b47f44 100644
@@ -1186,6 +1186,18 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
 		if (status)
 			goto err_remove_chip;
 	}
+
Quoted 8 lines

drivers/gpio/gpiolib.c int gpiochip_add_data(struct gpio_chip *chip, void *data) · line 1192

Quoted 3 lines
drivers/gpio/gpiolib.c +3 -0
+#ifdef CONFIG_GPIOLIB_IRQCHIP
+	chip->valid_mask = kcalloc(BITS_TO_LONGS(chip->ngpio), sizeof(long),
+				   GFP_KERNEL);

Do we really want to make this a mandatory thing? In most cases, I'd expect this valid_mask to have all bits set, so you might as well not allocate it at all in that case (and only allocate it if you actually need it).

We can make drivers to allocate it and only if set use it in core.

Quoted 5 lines

drivers/gpio/gpiolib.c int gpiochip_add_data(struct gpio_chip *chip, void *data) · line 1194

Quoted 3 lines
drivers/gpio/gpiolib.c +2 -0
+	if (!chip->valid_mask)
+		return -ENOMEM;

You really want to revise your error handling here.

Oops, right. It should be:

	if (!chip->valid_mask) {
		status = -ENOMEM;
		goto err_remove_chip;
	}
#36 lore raw

Re: [PATCH 1/2] gpiolib: Add possibility to mask which GPIOs are added to IRQ domain

Quoted 39 lines · Mika Westerberg
Quoted 29 lines · Marc Zyngier

Mika,

Quoted 26 lines · Mika Westerberg

When using GPIO irqchip helpers to setup irqchip for a gpiolib based driver, it is not possible to select which GPIOs to add to the IRQ domain. Instead it just adds all GPIOs which is not always desired. For example there might be GPIOs that for some reason just cannot be used as interrupts at all.

To make this possible we add valid_mask to each gpio_chip and by default assume all GPIOs can be used as interrupts. Drivers can then tune this using clear_bit() or similar before they call gpiochip_irqchip_add().

---
 drivers/gpio/gpiolib.c      | 32 +++++++++++++++++++++++++++++---
 include/linux/gpio/driver.h |  1 +
 2 files changed, 30 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib.c +1 -0
index 53ff25ac66d8..d84c23b47f44 100644
@@ -1186,6 +1186,18 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
 		if (status)
 			goto err_remove_chip;
 	}
+
Quoted 8 lines

drivers/gpio/gpiolib.c int gpiochip_add_data(struct gpio_chip *chip, void *data) · line 1192

Quoted 3 lines
drivers/gpio/gpiolib.c +3 -0
+#ifdef CONFIG_GPIOLIB_IRQCHIP
+	chip->valid_mask = kcalloc(BITS_TO_LONGS(chip->ngpio), sizeof(long),
+				   GFP_KERNEL);

Do we really want to make this a mandatory thing? In most cases, I'd expect this valid_mask to have all bits set, so you might as well not allocate it at all in that case (and only allocate it if you actually need it).

Quoted 1 line

We can make drivers to allocate it and only if set use it in core.

Make it a flag in gpio_chip which allocates it here when requested so we don't end up with driver writers getting the alloc/free/error handling wrong over and over.

Thanks,

tglx

#37 lore raw

Re: [PATCH 1/2] gpiolib: Add possibility to mask which GPIOs are added to IRQ domain

In reply to Mika Westerberg
Quoted 6 lines · Mika Westerberg

When using GPIO irqchip helpers to setup irqchip for a gpiolib based driver, it is not possible to select which GPIOs to add to the IRQ domain. Instead it just adds all GPIOs which is not always desired. For example there might be GPIOs that for some reason just cannot be used as interrupts at all.

Quoted 6 lines

To make this possible we add valid_mask to each gpio_chip and by default assume all GPIOs can be used as interrupts. Drivers can then tune this using clear_bit() or similar before they call gpiochip_irqchip_add().

Awesome, nice infrastructure.
Will apply once tglx and Marc's comments are fixed.

Yours,
Linus Walleij