Skip to contentSkip to conversation

gpio-langwell: fix irq conflicts when DT is not used

PATCH In review David Cohen 3 participants 5 messages May 6, 2013 – May 20, 2013 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio-langwell: fix irq conflicts when DT is not used

When DT is not used IOAPIC does not register irq domain. As result IOAPIC won't care about gpio-langwell's virq and may cause conflict if an irq number is equal to gpio-langwell's virq mapped beforehand.

This patch tells gpio_langwell to not ignore irq_base if != 0 and preferably use it to avoid the conflict.

If DT is used, irq_base can safely be 0.

---
 drivers/gpio/gpio-langwell.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpio/gpio-langwell.c +10 -7
index c48901a..88644db 100644
@@ -362,6 +362,7 @@ static int lnw_gpio_probe(struct pci_dev *pdev,
 	resource_size_t start, len;
 	struct lnw_gpio *lnw;
 	u32 gpio_base;
+	u32 irq_base;
 	int retval;
 	int ngpio = id->driver_data;
 
@@ -383,6 +384,7 @@ static int lnw_gpio_probe(struct pci_dev *pdev,
 		retval = -EFAULT;
 		goto err_ioremap;
 	}
+	irq_base = *(u32 *)base;
 	gpio_base = *((u32 *)base + 1);
 	/* release the IO mapping, since we already get the info from bar1 */
 	iounmap(base);
@@ -403,13 +405,6 @@ static int lnw_gpio_probe(struct pci_dev *pdev,
 		goto err_ioremap;
 	}
 
-	lnw->domain = irq_domain_add_linear(pdev->dev.of_node, ngpio,
-					    &lnw_gpio_irq_ops, lnw);
-	if (!lnw->domain) {
-		retval = -ENOMEM;
-		goto err_ioremap;
-	}
-
 	lnw->reg_base = base;
 	lnw->chip.label = dev_name(&pdev->dev);
 	lnw->chip.request = lnw_gpio_request;
@@ -422,6 +417,14 @@ static int lnw_gpio_probe(struct pci_dev *pdev,
 	lnw->chip.ngpio = ngpio;
 	lnw->chip.can_sleep = 0;
 	lnw->pdev = pdev;
+
+	lnw->domain = irq_domain_add_simple(pdev->dev.of_node, ngpio, irq_base,
+					    &lnw_gpio_irq_ops, lnw);
+	if (!lnw->domain) {
+		retval = -ENOMEM;
+		goto err_ioremap;
+	}
+
 	pci_set_drvdata(pdev, lnw);
 	retval = gpiochip_add(&lnw->chip);
 	if (retval) {
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · David Cohen

When DT is not used IOAPIC does not register irq domain. As result IOAPIC won't care about gpio-langwell's virq and may cause conflict if an irq number is equal to gpio-langwell's virq mapped beforehand.

This patch tells gpio_langwell to not ignore irq_base if != 0 and preferably use it to avoid the conflict.

If DT is used, irq_base can safely be 0.

Presuming that you have tested this on Medfield and it still works there.

#2 lore raw
Quoted 5 lines · Mika Westerberg
Quoted 4 lines · David Cohen

When DT is not used IOAPIC does not register irq domain. As result IOAPIC won't care about gpio-langwell's virq and may cause conflict if an irq number is equal to gpio-langwell's virq mapped beforehand.

Quoted 7 lines
Quoted 6 lines

This patch tells gpio_langwell to not ignore irq_base if != 0 and preferably use it to avoid the conflict.

If DT is used, irq_base can safely be 0.

Presuming that you have tested this on Medfield and it still works there.

Medfield and Clovertrail :)

Br, David

Quoted 2 lines
#3 lore raw

Hi Grant,

Quoted 9 lines · David Cohen
Quoted 8 lines · Mika Westerberg
Quoted 7 lines · David Cohen

When DT is not used IOAPIC does not register irq domain. As result IOAPIC won't care about gpio-langwell's virq and may cause conflict if an irq number is equal to gpio-langwell's virq mapped beforehand.

This patch tells gpio_langwell to not ignore irq_base if != 0 and preferably use it to avoid the conflict.

Quoted 11 lines
Quoted 4 lines
Quoted 3 lines

If DT is used, irq_base can safely be 0.

Presuming that you have tested this on Medfield and it still works there.

Medfield and Clovertrail :)

Br, David

Quoted 2 lines

Kindly ping :)
Comments?

Br, David

#4 lore raw
In reply to David Cohen
Quoted 10 lines · David Cohen

When DT is not used IOAPIC does not register irq domain. As result IOAPIC won't care about gpio-langwell's virq and may cause conflict if an irq number is equal to gpio-langwell's virq mapped beforehand.

This patch tells gpio_langwell to not ignore irq_base if != 0 and preferably use it to avoid the conflict.

If DT is used, irq_base can safely be 0.

Looks correct. Applied for rc-fixes with Mika's ACK.

Thanks!
Linus Walleij