diff mbox

[v3,1/2] irqchip: intc-irqpin: Add support for shared interrupt lines

Message ID 1364296699-20919-1-git-send-email-hechtb+renesas@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bastian Hecht March 26, 2013, 11:18 a.m. UTC
On some hardware we don't have a 1-1 mapping from the external
interrupts coming from INTC to the GIC SPI pins. We can however
share lines to demux incoming IRQs on these SoCs.

This patch enables the intc_irqpin driver to detect requests for shared
interrupt lines and demuxes them properly by querying the INTC INTREQx0A
registers.

If you need multiple shared intc_irqpin device instances, be sure to mask
out all interrupts on the INTC that share the one line before you start
to register them. Else you run into IRQ floods that would be caused by
interrupts for which no handler has been set up yet when the first
intc_irqpin device is registered.

Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
Acked-by: Magnus Damm <damm@opensource.se>
---
v3:

no changes.

 drivers/irqchip/irq-renesas-intc-irqpin.c |   90 ++++++++++++++++++++++++++---
 1 file changed, 83 insertions(+), 7 deletions(-)

Comments

Simon Horman March 27, 2013, 4:59 a.m. UTC | #1
On Tue, Mar 26, 2013 at 12:18:18PM +0100, Bastian Hecht wrote:
> On some hardware we don't have a 1-1 mapping from the external
> interrupts coming from INTC to the GIC SPI pins. We can however
> share lines to demux incoming IRQs on these SoCs.
> 
> This patch enables the intc_irqpin driver to detect requests for shared
> interrupt lines and demuxes them properly by querying the INTC INTREQx0A
> registers.
> 
> If you need multiple shared intc_irqpin device instances, be sure to mask
> out all interrupts on the INTC that share the one line before you start
> to register them. Else you run into IRQ floods that would be caused by
> interrupts for which no handler has been set up yet when the first
> intc_irqpin device is registered.
> 
> Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
> Acked-by: Magnus Damm <damm@opensource.se>

Thanks, I will see about queuing up these changes for v3.10.


I believe that with these changes it should be possible to rebase/rework
armadillo800eva-reference so that it no longer uses the unmerged INTC
DT bindings. Would it be possible for you to see about making a fresh
version of armadillo800eva-reference that is based on the next branch
in the Renesas tree plus this series of two patches?
Bastian Hecht March 27, 2013, 1:50 p.m. UTC | #2
Hi Simon,

2013/3/27 Simon Horman <horms@verge.net.au>:
> On Tue, Mar 26, 2013 at 12:18:18PM +0100, Bastian Hecht wrote:
>> On some hardware we don't have a 1-1 mapping from the external
>> interrupts coming from INTC to the GIC SPI pins. We can however
>> share lines to demux incoming IRQs on these SoCs.
>>
>> This patch enables the intc_irqpin driver to detect requests for shared
>> interrupt lines and demuxes them properly by querying the INTC INTREQx0A
>> registers.
>>
>> If you need multiple shared intc_irqpin device instances, be sure to mask
>> out all interrupts on the INTC that share the one line before you start
>> to register them. Else you run into IRQ floods that would be caused by
>> interrupts for which no handler has been set up yet when the first
>> intc_irqpin device is registered.
>>
>> Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
>> Acked-by: Magnus Damm <damm@opensource.se>
>
> Thanks, I will see about queuing up these changes for v3.10.
>
>
> I believe that with these changes it should be possible to rebase/rework
> armadillo800eva-reference so that it no longer uses the unmerged INTC
> DT bindings. Would it be possible for you to see about making a fresh
> version of armadillo800eva-reference that is based on the next branch
> in the Renesas tree plus this series of two patches?

yes ok, I'll prepare a new armadillo reference version. The patches
were based on all+next, but I'll post a v4 rebased on next.
I'll post a separate patch series for the reference code if you don't
mind, as this might take a few days to be done.

Thanks,

 Bastian
Simon Horman March 27, 2013, 2:04 p.m. UTC | #3
On Wed, Mar 27, 2013 at 02:50:05PM +0100, Bastian Hecht wrote:
> Hi Simon,
> 
> 2013/3/27 Simon Horman <horms@verge.net.au>:
> > On Tue, Mar 26, 2013 at 12:18:18PM +0100, Bastian Hecht wrote:
> >> On some hardware we don't have a 1-1 mapping from the external
> >> interrupts coming from INTC to the GIC SPI pins. We can however
> >> share lines to demux incoming IRQs on these SoCs.
> >>
> >> This patch enables the intc_irqpin driver to detect requests for shared
> >> interrupt lines and demuxes them properly by querying the INTC INTREQx0A
> >> registers.
> >>
> >> If you need multiple shared intc_irqpin device instances, be sure to mask
> >> out all interrupts on the INTC that share the one line before you start
> >> to register them. Else you run into IRQ floods that would be caused by
> >> interrupts for which no handler has been set up yet when the first
> >> intc_irqpin device is registered.
> >>
> >> Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
> >> Acked-by: Magnus Damm <damm@opensource.se>
> >
> > Thanks, I will see about queuing up these changes for v3.10.
> >
> >
> > I believe that with these changes it should be possible to rebase/rework
> > armadillo800eva-reference so that it no longer uses the unmerged INTC
> > DT bindings. Would it be possible for you to see about making a fresh
> > version of armadillo800eva-reference that is based on the next branch
> > in the Renesas tree plus this series of two patches?
> 
> yes ok, I'll prepare a new armadillo reference version. The patches
> were based on all+next, but I'll post a v4 rebased on next.

Thanks, sorry for the bother.

I have just pushed a fresh next branch and taged it as
renesas-next-20130327. If you quote that as your base I should
be able to apply your series without a hitch.

> I'll post a separate patch series for the reference code if you don't
> mind, as this might take a few days to be done.

Sure, no problem.
Simon Horman March 27, 2013, 2:11 p.m. UTC | #4
On Wed, Mar 27, 2013 at 11:04:56PM +0900, Simon Horman wrote:
> On Wed, Mar 27, 2013 at 02:50:05PM +0100, Bastian Hecht wrote:
> > Hi Simon,
> > 
> > 2013/3/27 Simon Horman <horms@verge.net.au>:
> > > On Tue, Mar 26, 2013 at 12:18:18PM +0100, Bastian Hecht wrote:
> > >> On some hardware we don't have a 1-1 mapping from the external
> > >> interrupts coming from INTC to the GIC SPI pins. We can however
> > >> share lines to demux incoming IRQs on these SoCs.
> > >>
> > >> This patch enables the intc_irqpin driver to detect requests for shared
> > >> interrupt lines and demuxes them properly by querying the INTC INTREQx0A
> > >> registers.
> > >>
> > >> If you need multiple shared intc_irqpin device instances, be sure to mask
> > >> out all interrupts on the INTC that share the one line before you start
> > >> to register them. Else you run into IRQ floods that would be caused by
> > >> interrupts for which no handler has been set up yet when the first
> > >> intc_irqpin device is registered.
> > >>
> > >> Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
> > >> Acked-by: Magnus Damm <damm@opensource.se>
> > >
> > > Thanks, I will see about queuing up these changes for v3.10.
> > >
> > >
> > > I believe that with these changes it should be possible to rebase/rework
> > > armadillo800eva-reference so that it no longer uses the unmerged INTC
> > > DT bindings. Would it be possible for you to see about making a fresh
> > > version of armadillo800eva-reference that is based on the next branch
> > > in the Renesas tree plus this series of two patches?
> > 
> > yes ok, I'll prepare a new armadillo reference version. The patches
> > were based on all+next, but I'll post a v4 rebased on next.
> 
> Thanks, sorry for the bother.
> 
> I have just pushed a fresh next branch and taged it as
> renesas-next-20130327. If you quote that as your base I should
> be able to apply your series without a hitch.

Sorry, I missed that you had already posted v4. Thanks!

> > I'll post a separate patch series for the reference code if you don't
> > mind, as this might take a few days to be done.
> 
> Sure, no problem.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Simon Horman April 3, 2013, 7:46 a.m. UTC | #5
On Wed, Mar 27, 2013 at 02:50:05PM +0100, Bastian Hecht wrote:
> Hi Simon,
> 
> 2013/3/27 Simon Horman <horms@verge.net.au>:
> > On Tue, Mar 26, 2013 at 12:18:18PM +0100, Bastian Hecht wrote:
> >> On some hardware we don't have a 1-1 mapping from the external
> >> interrupts coming from INTC to the GIC SPI pins. We can however
> >> share lines to demux incoming IRQs on these SoCs.
> >>
> >> This patch enables the intc_irqpin driver to detect requests for shared
> >> interrupt lines and demuxes them properly by querying the INTC INTREQx0A
> >> registers.
> >>
> >> If you need multiple shared intc_irqpin device instances, be sure to mask
> >> out all interrupts on the INTC that share the one line before you start
> >> to register them. Else you run into IRQ floods that would be caused by
> >> interrupts for which no handler has been set up yet when the first
> >> intc_irqpin device is registered.
> >>
> >> Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
> >> Acked-by: Magnus Damm <damm@opensource.se>
> >
> > Thanks, I will see about queuing up these changes for v3.10.
> >
> >
> > I believe that with these changes it should be possible to rebase/rework
> > armadillo800eva-reference so that it no longer uses the unmerged INTC
> > DT bindings. Would it be possible for you to see about making a fresh
> > version of armadillo800eva-reference that is based on the next branch
> > in the Renesas tree plus this series of two patches?
> 
> yes ok, I'll prepare a new armadillo reference version. The patches
> were based on all+next, but I'll post a v4 rebased on next.
> I'll post a separate patch series for the reference code if you don't
> mind, as this might take a few days to be done.

Hi Bastian,

gentle nudge with regards to a fresh armadillo-reference.
Bastian Hecht April 4, 2013, 1:47 p.m. UTC | #6
Hi Simon,

ok I've sent out a patch series with the reference DT code. I've had
to adapt a couple of things and the device list is rather short. How
long do I have to augment it a bit before the merge window closes?

Thanks,

 Bastian


2013/4/3 Simon Horman <horms@verge.net.au>:
> On Wed, Mar 27, 2013 at 02:50:05PM +0100, Bastian Hecht wrote:
>> Hi Simon,
>>
>> 2013/3/27 Simon Horman <horms@verge.net.au>:
>> > On Tue, Mar 26, 2013 at 12:18:18PM +0100, Bastian Hecht wrote:
>> >> On some hardware we don't have a 1-1 mapping from the external
>> >> interrupts coming from INTC to the GIC SPI pins. We can however
>> >> share lines to demux incoming IRQs on these SoCs.
>> >>
>> >> This patch enables the intc_irqpin driver to detect requests for shared
>> >> interrupt lines and demuxes them properly by querying the INTC INTREQx0A
>> >> registers.
>> >>
>> >> If you need multiple shared intc_irqpin device instances, be sure to mask
>> >> out all interrupts on the INTC that share the one line before you start
>> >> to register them. Else you run into IRQ floods that would be caused by
>> >> interrupts for which no handler has been set up yet when the first
>> >> intc_irqpin device is registered.
>> >>
>> >> Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
>> >> Acked-by: Magnus Damm <damm@opensource.se>
>> >
>> > Thanks, I will see about queuing up these changes for v3.10.
>> >
>> >
>> > I believe that with these changes it should be possible to rebase/rework
>> > armadillo800eva-reference so that it no longer uses the unmerged INTC
>> > DT bindings. Would it be possible for you to see about making a fresh
>> > version of armadillo800eva-reference that is based on the next branch
>> > in the Renesas tree plus this series of two patches?
>>
>> yes ok, I'll prepare a new armadillo reference version. The patches
>> were based on all+next, but I'll post a v4 rebased on next.
>> I'll post a separate patch series for the reference code if you don't
>> mind, as this might take a few days to be done.
>
> Hi Bastian,
>
> gentle nudge with regards to a fresh armadillo-reference.
Simon Horman April 5, 2013, 12:36 a.m. UTC | #7
On Thu, Apr 04, 2013 at 03:47:34PM +0200, Bastian Hecht wrote:
> Hi Simon,
> 
> ok I've sent out a patch series with the reference DT code. I've had
> to adapt a couple of things and the device list is rather short. How
> long do I have to augment it a bit before the merge window closes?

The merge window is more or less closed. So I think we will have
to aim for v3.11. But I don't think that should affect the way
you write the code, please just base it on the latest renesas-next tag.

> Thanks,
> 
>  Bastian
> 
> 
> 2013/4/3 Simon Horman <horms@verge.net.au>:
> > On Wed, Mar 27, 2013 at 02:50:05PM +0100, Bastian Hecht wrote:
> >> Hi Simon,
> >>
> >> 2013/3/27 Simon Horman <horms@verge.net.au>:
> >> > On Tue, Mar 26, 2013 at 12:18:18PM +0100, Bastian Hecht wrote:
> >> >> On some hardware we don't have a 1-1 mapping from the external
> >> >> interrupts coming from INTC to the GIC SPI pins. We can however
> >> >> share lines to demux incoming IRQs on these SoCs.
> >> >>
> >> >> This patch enables the intc_irqpin driver to detect requests for shared
> >> >> interrupt lines and demuxes them properly by querying the INTC INTREQx0A
> >> >> registers.
> >> >>
> >> >> If you need multiple shared intc_irqpin device instances, be sure to mask
> >> >> out all interrupts on the INTC that share the one line before you start
> >> >> to register them. Else you run into IRQ floods that would be caused by
> >> >> interrupts for which no handler has been set up yet when the first
> >> >> intc_irqpin device is registered.
> >> >>
> >> >> Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
> >> >> Acked-by: Magnus Damm <damm@opensource.se>
> >> >
> >> > Thanks, I will see about queuing up these changes for v3.10.
> >> >
> >> >
> >> > I believe that with these changes it should be possible to rebase/rework
> >> > armadillo800eva-reference so that it no longer uses the unmerged INTC
> >> > DT bindings. Would it be possible for you to see about making a fresh
> >> > version of armadillo800eva-reference that is based on the next branch
> >> > in the Renesas tree plus this series of two patches?
> >>
> >> yes ok, I'll prepare a new armadillo reference version. The patches
> >> were based on all+next, but I'll post a v4 rebased on next.
> >> I'll post a separate patch series for the reference code if you don't
> >> mind, as this might take a few days to be done.
> >
> > Hi Bastian,
> >
> > gentle nudge with regards to a fresh armadillo-reference.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Bastian Hecht April 8, 2013, 11:03 a.m. UTC | #8
2013/4/5 Simon Horman <horms@verge.net.au>:
> On Thu, Apr 04, 2013 at 03:47:34PM +0200, Bastian Hecht wrote:
>> Hi Simon,
>>
>> ok I've sent out a patch series with the reference DT code. I've had
>> to adapt a couple of things and the device list is rather short. How
>> long do I have to augment it a bit before the merge window closes?
>
> The merge window is more or less closed. So I think we will have
> to aim for v3.11. But I don't think that should affect the way
> you write the code, please just base it on the latest renesas-next tag.

Ok thanks for the info, Simon.

>> Thanks,
>>
>>  Bastian
>>
>>
>> 2013/4/3 Simon Horman <horms@verge.net.au>:
>> > On Wed, Mar 27, 2013 at 02:50:05PM +0100, Bastian Hecht wrote:
>> >> Hi Simon,
>> >>
>> >> 2013/3/27 Simon Horman <horms@verge.net.au>:
>> >> > On Tue, Mar 26, 2013 at 12:18:18PM +0100, Bastian Hecht wrote:
>> >> >> On some hardware we don't have a 1-1 mapping from the external
>> >> >> interrupts coming from INTC to the GIC SPI pins. We can however
>> >> >> share lines to demux incoming IRQs on these SoCs.
>> >> >>
>> >> >> This patch enables the intc_irqpin driver to detect requests for shared
>> >> >> interrupt lines and demuxes them properly by querying the INTC INTREQx0A
>> >> >> registers.
>> >> >>
>> >> >> If you need multiple shared intc_irqpin device instances, be sure to mask
>> >> >> out all interrupts on the INTC that share the one line before you start
>> >> >> to register them. Else you run into IRQ floods that would be caused by
>> >> >> interrupts for which no handler has been set up yet when the first
>> >> >> intc_irqpin device is registered.
>> >> >>
>> >> >> Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
>> >> >> Acked-by: Magnus Damm <damm@opensource.se>
>> >> >
>> >> > Thanks, I will see about queuing up these changes for v3.10.
>> >> >
>> >> >
>> >> > I believe that with these changes it should be possible to rebase/rework
>> >> > armadillo800eva-reference so that it no longer uses the unmerged INTC
>> >> > DT bindings. Would it be possible for you to see about making a fresh
>> >> > version of armadillo800eva-reference that is based on the next branch
>> >> > in the Renesas tree plus this series of two patches?
>> >>
>> >> yes ok, I'll prepare a new armadillo reference version. The patches
>> >> were based on all+next, but I'll post a v4 rebased on next.
>> >> I'll post a separate patch series for the reference code if you don't
>> >> mind, as this might take a few days to be done.
>> >
>> > Hi Bastian,
>> >
>> > gentle nudge with regards to a fresh armadillo-reference.
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c
index fd5dabc..5a68e5a 100644
--- a/drivers/irqchip/irq-renesas-intc-irqpin.c
+++ b/drivers/irqchip/irq-renesas-intc-irqpin.c
@@ -74,6 +74,8 @@  struct intc_irqpin_priv {
 	struct platform_device *pdev;
 	struct irq_chip irq_chip;
 	struct irq_domain *irq_domain;
+	bool shared_irqs;
+	u8 shared_irq_mask;
 };
 
 static unsigned long intc_irqpin_read32(void __iomem *iomem)
@@ -193,6 +195,28 @@  static void intc_irqpin_irq_disable(struct irq_data *d)
 	intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_MASK, hw_irq);
 }
 
+static void intc_irqpin_shared_irq_enable(struct irq_data *d)
+{
+	struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
+	int hw_irq = irqd_to_hwirq(d);
+
+	intc_irqpin_dbg(&p->irq[hw_irq], "shared enable");
+	intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_CLEAR, hw_irq);
+
+	p->shared_irq_mask &= ~BIT(hw_irq);
+}
+
+static void intc_irqpin_shared_irq_disable(struct irq_data *d)
+{
+	struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
+	int hw_irq = irqd_to_hwirq(d);
+
+	intc_irqpin_dbg(&p->irq[hw_irq], "shared disable");
+	intc_irqpin_irq_write_hwirq(p, INTC_IRQPIN_REG_MASK, hw_irq);
+
+	p->shared_irq_mask |= BIT(hw_irq);
+}
+
 static void intc_irqpin_irq_enable_force(struct irq_data *d)
 {
 	struct intc_irqpin_priv *p = irq_data_get_irq_chip_data(d);
@@ -261,6 +285,25 @@  static irqreturn_t intc_irqpin_irq_handler(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
+static irqreturn_t intc_irqpin_shared_irq_handler(int irq, void *dev_id)
+{
+	struct intc_irqpin_priv *p = dev_id;
+	unsigned int reg_source = intc_irqpin_read(p, INTC_IRQPIN_REG_SOURCE);
+	irqreturn_t status = IRQ_NONE;
+	int k;
+
+	for (k = 0; k < 8; k++) {
+		if (reg_source & BIT(7 - k)) {
+			if (BIT(k) & p->shared_irq_mask)
+				continue;
+
+			status |= intc_irqpin_irq_handler(irq, &p->irq[k]);
+		}
+	}
+
+	return status;
+}
+
 static int intc_irqpin_irq_domain_map(struct irq_domain *h, unsigned int virq,
 				      irq_hw_number_t hw)
 {
@@ -292,6 +335,7 @@  static int intc_irqpin_probe(struct platform_device *pdev)
 	void (*enable_fn)(struct irq_data *d);
 	void (*disable_fn)(struct irq_data *d);
 	const char *name = dev_name(&pdev->dev);
+	int ref_irq;
 	int ret;
 	int k;
 
@@ -372,13 +416,29 @@  static int intc_irqpin_probe(struct platform_device *pdev)
 	for (k = 0; k < p->number_of_irqs; k++)
 		intc_irqpin_mask_unmask_prio(p, k, 1);
 
+	/* clear all pending interrupts */
+	intc_irqpin_write(p, INTC_IRQPIN_REG_SOURCE, 0x0);
+
+	/* scan for shared interrupt lines */
+	ref_irq = p->irq[0].requested_irq;
+	p->shared_irqs = true;
+	for (k = 1; k < p->number_of_irqs; k++) {
+		if (ref_irq != p->irq[k].requested_irq) {
+			p->shared_irqs = false;
+			break;
+		}
+	}
+
 	/* use more severe masking method if requested */
 	if (p->config.control_parent) {
 		enable_fn = intc_irqpin_irq_enable_force;
 		disable_fn = intc_irqpin_irq_disable_force;
-	} else {
+	} else if (!p->shared_irqs) {
 		enable_fn = intc_irqpin_irq_enable;
 		disable_fn = intc_irqpin_irq_disable;
+	} else {
+		enable_fn = intc_irqpin_shared_irq_enable;
+		disable_fn = intc_irqpin_shared_irq_disable;
 	}
 
 	irq_chip = &p->irq_chip;
@@ -400,18 +460,34 @@  static int intc_irqpin_probe(struct platform_device *pdev)
 		goto err0;
 	}
 
-	/* request and set priority on interrupts one by one */
-	for (k = 0; k < p->number_of_irqs; k++) {
-		if (devm_request_irq(&pdev->dev, p->irq[k].requested_irq,
-				     intc_irqpin_irq_handler,
-				     0, name, &p->irq[k])) {
+	if (p->shared_irqs) {
+		/* request one shared interrupt */
+		if (devm_request_irq(&pdev->dev, p->irq[0].requested_irq,
+				intc_irqpin_shared_irq_handler,
+				IRQF_SHARED, name, p)) {
 			dev_err(&pdev->dev, "failed to request low IRQ\n");
 			ret = -ENOENT;
 			goto err1;
 		}
-		intc_irqpin_mask_unmask_prio(p, k, 0);
+	} else {
+		/* request interrupts one by one */
+		for (k = 0; k < p->number_of_irqs; k++) {
+			if (devm_request_irq(&pdev->dev,
+					p->irq[k].requested_irq,
+					intc_irqpin_irq_handler,
+					0, name, &p->irq[k])) {
+				dev_err(&pdev->dev,
+					"failed to request low IRQ\n");
+				ret = -ENOENT;
+				goto err1;
+			}
+		}
 	}
 
+	/* unmask all interrupts on prio level */
+	for (k = 0; k < p->number_of_irqs; k++)
+		intc_irqpin_mask_unmask_prio(p, k, 0);
+
 	dev_info(&pdev->dev, "driving %d irqs\n", p->number_of_irqs);
 
 	/* warn in case of mismatch if irq base is specified */