Skip to contentSkip to conversation

ARM: shmobile: irqpin: add a DT property to enable masking on parent

PATCH Superseded Guennadi Liakhovetski 4 participants 7 messages May 24, 2013 – Jun 18, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ARM: shmobile: irqpin: add a DT property to enable masking on parent

To disable spurious interrupts, that get triggered on certain hardware, the irqpin driver masks them on the parent interrupt controller. To specify such broken devices a .control_parent parameter can be provided in the platform data. In the DT case we need a property, to do the same.

---

These two patches simply split the earlier "ARM: shmobile: irqpin: fix handling of spurious interrupts in DT case" patch into two parts. Otherwise no change.

 .../interrupt-controller/renesas,intc-irqpin.txt   |    2 ++
 drivers/irqchip/irq-renesas-intc-irqpin.c          |    7 +++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt +2 -0
index c6f09b7..152b10a 100644
@@ -11,3 +11,5 @@ Optional properties:
   resource allocation properties
 - sense-bitfield-width: width of a single sense bitfield in the SENSE register,
   if different from the default 4 bits
+- control-parent: disable and enable interrupts on the parent interrupt
+  controller, needed for some broken implementations
drivers/irqchip/irq-renesas-intc-irqpin.c +5 -2
index 4aca1b2..82cec63 100644
@@ -348,11 +348,14 @@ static int intc_irqpin_probe(struct platform_device *pdev)
 	}
 
 	/* deal with driver instance configuration */
-	if (pdata)
+	if (pdata) {
 		memcpy(&p->config, pdata, sizeof(*pdata));
-	else
+	} else {
 		of_property_read_u32(pdev->dev.of_node, "sense-bitfield-width",
 				     &p->config.sense_bitfield_width);
+		p->config.control_parent = of_property_read_bool(pdev->dev.of_node,
+								 "control-parent");
+	}
 	if (!p->config.sense_bitfield_width)
 		p->config.sense_bitfield_width = 4; /* default to 4 bits */
 
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH 2/2 ARM: shmobile: irqpin: map spurious interrupts in DT case

In the non-DT case all interrupts get mapped statically during probing, therefore, if a spurious interrupt arrives, it can easily be mapped back to hardware registers and bits and handled. In the DT case interrupts are mapped only when a device, using that interrupt is instantiated from DT. So, spurious interrupts occur unmapped and thus cannot be handled properly. This patch fixes this by mapping such interrupts as they occur.

---
 drivers/irqchip/irq-renesas-intc-irqpin.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/irqchip/irq-renesas-intc-irqpin.c +8 -0
index 82cec63..e62d76d 100644
@@ -71,6 +71,7 @@ struct intc_irqpin_priv {
 	struct intc_irqpin_iomem iomem[INTC_IRQPIN_REG_NR];
 	struct intc_irqpin_irq irq[INTC_IRQPIN_MAX];
 	struct renesas_intc_irqpin_config config;
+	unsigned int min_irq;
 	unsigned int number_of_irqs;
 	struct platform_device *pdev;
 	struct irq_chip irq_chip;
@@ -274,6 +275,10 @@ static irqreturn_t intc_irqpin_irq_handler(int irq, void *dev_id)
 	struct intc_irqpin_priv *p = i->p;
 	unsigned long bit;
 
+	if (!i->domain_irq)
+		/* unmapped: spurious IRQ, map it now */
+		irq_create_mapping(p->irq_domain, irq - p->min_irq);
+
 	intc_irqpin_dbg(i, "demux1");
 	bit = intc_irqpin_hwirq_mask(p, INTC_IRQPIN_REG_SOURCE, i->hw_irq);
 
@@ -372,6 +377,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
 		}
 	}
 
+	p->min_irq = INT_MAX;
 	/* allow any number of IRQs between 1 and INTC_IRQPIN_MAX */
 	for (k = 0; k < INTC_IRQPIN_MAX; k++) {
 		irq = platform_get_resource(pdev, IORESOURCE_IRQ, k);
@@ -380,6 +386,8 @@ static int intc_irqpin_probe(struct platform_device *pdev)
 
 		p->irq[k].p = p;
 		p->irq[k].requested_irq = irq->start;
+		if (p->min_irq > irq->start)
+			p->min_irq = irq->start;
 	}
 
 	p->number_of_irqs = k;
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH 2/2 ARM: shmobile: irqpin: map spurious interrupts in DT case

Quoted 6 lines · Guennadi Liakhovetski

In the non-DT case all interrupts get mapped statically during probing, therefore, if a spurious interrupt arrives, it can easily be mapped back to hardware registers and bits and handled. In the DT case interrupts are mapped only when a device, using that interrupt is instantiated from DT. So, spurious interrupts occur unmapped and thus cannot be handled properly. This patch fixes this by mapping such interrupts as they occur.

That sounds like a bad approach. If the driver really requires the irqs to be mapped, then it should do all of them when the controller is set up. Mapping at interrupt handling time is absolutely the wrong time to do it.

Also, why is mapping the irq necessary to handle it? You don't want to call generic_handle_irq() on a bad interrupt because there won't be anything listening for it. First of all, that particular irq should be entirely disabled if at all possible. Second, if it isn't possible to disable it, then the handler function should clear the state and get out of the handler as quickly as possible.

g.

Quoted 54 lines
---
 drivers/irqchip/irq-renesas-intc-irqpin.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/irqchip/irq-renesas-intc-irqpin.c +8 -0
index 82cec63..e62d76d 100644
@@ -71,6 +71,7 @@ struct intc_irqpin_priv {
 	struct intc_irqpin_iomem iomem[INTC_IRQPIN_REG_NR];
 	struct intc_irqpin_irq irq[INTC_IRQPIN_MAX];
 	struct renesas_intc_irqpin_config config;
+	unsigned int min_irq;
 	unsigned int number_of_irqs;
 	struct platform_device *pdev;
 	struct irq_chip irq_chip;
@@ -274,6 +275,10 @@ static irqreturn_t intc_irqpin_irq_handler(int irq, void *dev_id)
 	struct intc_irqpin_priv *p = i->p;
 	unsigned long bit;
 
+	if (!i->domain_irq)
+		/* unmapped: spurious IRQ, map it now */
+		irq_create_mapping(p->irq_domain, irq - p->min_irq);
+
 	intc_irqpin_dbg(i, "demux1");
 	bit = intc_irqpin_hwirq_mask(p, INTC_IRQPIN_REG_SOURCE, i->hw_irq);
 
@@ -372,6 +377,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
 		}
 	}
 
+	p->min_irq = INT_MAX;
 	/* allow any number of IRQs between 1 and INTC_IRQPIN_MAX */
 	for (k = 0; k < INTC_IRQPIN_MAX; k++) {
 		irq = platform_get_resource(pdev, IORESOURCE_IRQ, k);
@@ -380,6 +386,8 @@ static int intc_irqpin_probe(struct platform_device *pdev)
 
 		p->irq[k].p = p;
 		p->irq[k].requested_irq = irq->start;
+		if (p->min_irq > irq->start)
+			p->min_irq = irq->start;
 	}
 
 	p->number_of_irqs = k;
Signature · 7 lines
1.7.2.5


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 2 lines
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
#3 lore raw

PATCH 1/2 ARM: shmobile: irqpin: add a DT property to enable masking on parent

In reply to Guennadi Liakhovetski
Quoted 11 lines · Guennadi Liakhovetski

To disable spurious interrupts, that get triggered on certain hardware, the irqpin driver masks them on the parent interrupt controller. To specify such broken devices a .control_parent parameter can be provided in the platform data. In the DT case we need a property, to do the same.

---

These two patches simply split the earlier "ARM: shmobile: irqpin: fix handling of spurious interrupts in DT case" patch into two parts. Otherwise no change.

Magnus,

could you please review this series?

Quoted 39 lines
 .../interrupt-controller/renesas,intc-irqpin.txt   |    2 ++
 drivers/irqchip/irq-renesas-intc-irqpin.c          |    7 +++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/interrupt-controller/renesas,intc-irqpin.txt +2 -0
index c6f09b7..152b10a 100644
@@ -11,3 +11,5 @@ Optional properties:
   resource allocation properties
 - sense-bitfield-width: width of a single sense bitfield in the SENSE register,
   if different from the default 4 bits
+- control-parent: disable and enable interrupts on the parent interrupt
+  controller, needed for some broken implementations
drivers/irqchip/irq-renesas-intc-irqpin.c +5 -2
index 4aca1b2..82cec63 100644
@@ -348,11 +348,14 @@ static int intc_irqpin_probe(struct platform_device *pdev)
 	}
 
 	/* deal with driver instance configuration */
-	if (pdata)
+	if (pdata) {
 		memcpy(&p->config, pdata, sizeof(*pdata));
-	else
+	} else {
 		of_property_read_u32(pdev->dev.of_node, "sense-bitfield-width",
 				     &p->config.sense_bitfield_width);
+		p->config.control_parent = of_property_read_bool(pdev->dev.of_node,
+								 "control-parent");
+	}
 	if (!p->config.sense_bitfield_width)
 		p->config.sense_bitfield_width = 4; /* default to 4 bits */
 
Signature · 1 line
1.7.2.5
#4 lore raw

PATCH 1/2 ARM: shmobile: irqpin: add a DT property to enable masking on parent

In reply to Guennadi Liakhovetski
Quoted 11 lines · Guennadi Liakhovetski

To disable spurious interrupts, that get triggered on certain hardware, the irqpin driver masks them on the parent interrupt controller. To specify such broken devices a .control_parent parameter can be provided in the platform data. In the DT case we need a property, to do the same.

---

These two patches simply split the earlier "ARM: shmobile: irqpin: fix handling of spurious interrupts in DT case" patch into two parts. Otherwise no change.

I'm fine with this portion of the patch series. Thanks for your help!

#5 lore raw

PATCH 1/2 ARM: shmobile: irqpin: add a DT property to enable masking on parent

Quoted 10 lines · Magnus Damm
Quoted 8 lines · Guennadi Liakhovetski

To disable spurious interrupts, that get triggered on certain hardware, the irqpin driver masks them on the parent interrupt controller. To specify such broken devices a .control_parent parameter can be provided in the platform data. In the DT case we need a property, to do the same.

---

Quoted 7 lines
Quoted 3 lines

These two patches simply split the earlier "ARM: shmobile: irqpin: fix handling of spurious interrupts in DT case" patch into two parts. Otherwise no change.

I'm fine with this portion of the patch series. Thanks for your help!

I believe that this patch depends on
"irqchip: renesas-intc-irqpin: DT binding for sense bitfield width" which Arnd has requested some modifications to.

"I think you should add documentation here about how the two interrupt cells are to be interpreted, to allow people to fill the values from a data sheet or board schematic."
http://www.spinics.net/lists/linux-sh/msg20202.html

Please post a fresh series that:

1. Includes a fresh version of "irqchip: renesas-intc-irqpin: DT binding for sense bitfield width" with Arnd's concerns addressed.

2. Includes this patch with Magnus's Ack.

Please be sure to CC Arnd on the new series.

#6 lore raw

PATCH 1/2 ARM: shmobile: irqpin: add a DT property to enable masking on parent

Quoted 28 lines · Simon Horman
Quoted 10 lines · Magnus Damm
Quoted 8 lines · Guennadi Liakhovetski

To disable spurious interrupts, that get triggered on certain hardware, the irqpin driver masks them on the parent interrupt controller. To specify such broken devices a .control_parent parameter can be provided in the platform data. In the DT case we need a property, to do the same.

---

Quoted 7 lines
Quoted 3 lines

These two patches simply split the earlier "ARM: shmobile: irqpin: fix handling of spurious interrupts in DT case" patch into two parts. Otherwise no change.

I'm fine with this portion of the patch series. Thanks for your help!

I believe that this patch depends on
"irqchip: renesas-intc-irqpin: DT binding for sense bitfield width" which Arnd has requested some modifications to.

"I think you should add documentation here about how the two interrupt cells are to be interpreted, to allow people to fill the values from a data sheet or board schematic."
http://www.spinics.net/lists/linux-sh/msg20202.html

Quoted 8 lines

Please post a fresh series that:

1. Includes a fresh version of "irqchip: renesas-intc-irqpin: DT binding for sense bitfield width" with Arnd's concerns addressed.

2. Includes this patch with Magnus's Ack.

Please be sure to CC Arnd on the new series.

Hi Guennadi,

I see that you reposted "irqchip: renesas-intc-irqpin: DT binding for sense bitfield width", which I have queued-up, without this patch.

Please rebase this patch and repost it with Magnus's Ack.