linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] powerpc/mpic: Move internal interrupt source vector allocation to a separate function.
@ 2012-03-27 12:16 Varun Sethi
  2012-03-27 13:24 ` Kumar Gala
  0 siblings, 1 reply; 6+ messages in thread
From: Varun Sethi @ 2012-03-27 12:16 UTC (permalink / raw)
  To: Linuxppc-dev; +Cc: Varun Sethi

Allocate vector numbers for MPIC internal interrupt sources (IPIs and Timers) in a 
separate function.

Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
---
 arch/powerpc/include/asm/mpic.h |    7 +++++--
 arch/powerpc/sysdev/mpic.c      |   30 +++++++++++++++++-------------
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index 30e3b29..3929b4b 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -118,6 +118,9 @@
 #define MPIC_MAX_CPUS		32
 #define MPIC_MAX_ISU		32
 
+#define MPIC_MAX_TIMER    8
+#define MPIC_MAX_IPI      4
+
 /*
  * Tsi108 implementation of MPIC has many differences from the original one
  */
@@ -284,8 +287,8 @@ struct mpic
 	unsigned int		senses_count;
 
 	/* vector numbers used for internal sources (ipi/timers) */
-	unsigned int		ipi_vecs[4];
-	unsigned int		timer_vecs[8];
+	unsigned int		ipi_vecs[MPIC_MAX_IPI];
+	unsigned int		timer_vecs[MPIC_MAX_TIMER];
 
 	/* Spurious vector to program into unused sources */
 	unsigned int		spurious_vec;
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 33520dd..c4da1d5 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -996,7 +996,8 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
 	}
 #endif /* CONFIG_SMP */
 
-	if (hw >= mpic->timer_vecs[0] && hw <= mpic->timer_vecs[7]) {
+	if (hw >= mpic->timer_vecs[0] &&
+	    hw <= mpic->timer_vecs[MPIC_MAX_TIMER - 1]) {
 		WARN_ON(mpic->flags & MPIC_SECONDARY);
 
 		DBG("mpic: mapping as timer\n");
@@ -1133,6 +1134,19 @@ static struct irq_host_ops mpic_host_ops = {
 	.xlate = mpic_host_xlate,
 };
 
+static void mpic_alloc_int_sources(struct mpic *mpic, int intvec_top)
+{
+	int i, intvec;
+
+	intvec = intvec_top;
+
+	for (i = MPIC_MAX_IPI - 1; i >= 0; i--)
+		mpic->ipi_vecs[i] = --intvec;
+
+	for (i = MPIC_MAX_TIMER - 1; i >= 0; i--)
+		mpic->timer_vecs[i] = --intvec;
+}
+
 /*
  * Exported functions
  */
@@ -1228,18 +1242,6 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	else
 		intvec_top = 255;
 
-	mpic->timer_vecs[0] = intvec_top - 12;
-	mpic->timer_vecs[1] = intvec_top - 11;
-	mpic->timer_vecs[2] = intvec_top - 10;
-	mpic->timer_vecs[3] = intvec_top - 9;
-	mpic->timer_vecs[4] = intvec_top - 8;
-	mpic->timer_vecs[5] = intvec_top - 7;
-	mpic->timer_vecs[6] = intvec_top - 6;
-	mpic->timer_vecs[7] = intvec_top - 5;
-	mpic->ipi_vecs[0]   = intvec_top - 4;
-	mpic->ipi_vecs[1]   = intvec_top - 3;
-	mpic->ipi_vecs[2]   = intvec_top - 2;
-	mpic->ipi_vecs[3]   = intvec_top - 1;
 	mpic->spurious_vec  = intvec_top;
 
 	/* Look for protected sources */
@@ -1365,6 +1367,8 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
 	mpic->isu_mask = (1 << mpic->isu_shift) - 1;
 
+	mpic_alloc_int_sources(mpic, intvec_top);
+
 	mpic->irqhost = irq_alloc_host(mpic->node, IRQ_HOST_MAP_LINEAR,
 				       last_irq + 1, &mpic_host_ops,
 				       intvec_top + 1);
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/4] powerpc/mpic: Move internal interrupt source vector allocation to a separate function.
  2012-03-27 12:16 [PATCH 3/4] powerpc/mpic: Move internal interrupt source vector allocation to a separate function Varun Sethi
@ 2012-03-27 13:24 ` Kumar Gala
  2012-03-27 13:52   ` Sethi Varun-B16395
  0 siblings, 1 reply; 6+ messages in thread
From: Kumar Gala @ 2012-03-27 13:24 UTC (permalink / raw)
  To: Varun Sethi; +Cc: Linuxppc-dev


On Mar 27, 2012, at 7:16 AM, Varun Sethi wrote:

> Allocate vector numbers for MPIC internal interrupt sources (IPIs and =
Timers) in a=20
> separate function.
>=20

Explain why you are making this change.

> Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
> ---
> arch/powerpc/include/asm/mpic.h |    7 +++++--
> arch/powerpc/sysdev/mpic.c      |   30 +++++++++++++++++-------------
> 2 files changed, 22 insertions(+), 15 deletions(-)
>=20
> diff --git a/arch/powerpc/include/asm/mpic.h =
b/arch/powerpc/include/asm/mpic.h
> index 30e3b29..3929b4b 100644
> --- a/arch/powerpc/include/asm/mpic.h
> +++ b/arch/powerpc/include/asm/mpic.h
> @@ -118,6 +118,9 @@
> #define MPIC_MAX_CPUS		32
> #define MPIC_MAX_ISU		32
>=20
> +#define MPIC_MAX_TIMER    8
> +#define MPIC_MAX_IPI      4
> +
> /*
>  * Tsi108 implementation of MPIC has many differences from the =
original one
>  */
> @@ -284,8 +287,8 @@ struct mpic
> 	unsigned int		senses_count;
>=20
> 	/* vector numbers used for internal sources (ipi/timers) */
> -	unsigned int		ipi_vecs[4];
> -	unsigned int		timer_vecs[8];
> +	unsigned int		ipi_vecs[MPIC_MAX_IPI];
> +	unsigned int		timer_vecs[MPIC_MAX_TIMER];
>=20
> 	/* Spurious vector to program into unused sources */
> 	unsigned int		spurious_vec;
> diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> index 33520dd..c4da1d5 100644
> --- a/arch/powerpc/sysdev/mpic.c
> +++ b/arch/powerpc/sysdev/mpic.c
> @@ -996,7 +996,8 @@ static int mpic_host_map(struct irq_host *h, =
unsigned int virq,
> 	}
> #endif /* CONFIG_SMP */
>=20
> -	if (hw >=3D mpic->timer_vecs[0] && hw <=3D mpic->timer_vecs[7]) =
{
> +	if (hw >=3D mpic->timer_vecs[0] &&
> +	    hw <=3D mpic->timer_vecs[MPIC_MAX_TIMER - 1]) {
> 		WARN_ON(mpic->flags & MPIC_SECONDARY);
>=20
> 		DBG("mpic: mapping as timer\n");
> @@ -1133,6 +1134,19 @@ static struct irq_host_ops mpic_host_ops =3D {
> 	.xlate =3D mpic_host_xlate,
> };
>=20
> +static void mpic_alloc_int_sources(struct mpic *mpic, int intvec_top)
> +{
> +	int i, intvec;
> +
> +	intvec =3D intvec_top;
> +

local intvec is pointless.

> +	for (i =3D MPIC_MAX_IPI - 1; i >=3D 0; i--)
> +		mpic->ipi_vecs[i] =3D --intvec;
> +
> +	for (i =3D MPIC_MAX_TIMER - 1; i >=3D 0; i--)
> +		mpic->timer_vecs[i] =3D --intvec;
> +}
> +
> /*
>  * Exported functions
>  */
> @@ -1228,18 +1242,6 @@ struct mpic * __init mpic_alloc(struct =
device_node *node,
> 	else
> 		intvec_top =3D 255;
>=20
> -	mpic->timer_vecs[0] =3D intvec_top - 12;
> -	mpic->timer_vecs[1] =3D intvec_top - 11;
> -	mpic->timer_vecs[2] =3D intvec_top - 10;
> -	mpic->timer_vecs[3] =3D intvec_top - 9;
> -	mpic->timer_vecs[4] =3D intvec_top - 8;
> -	mpic->timer_vecs[5] =3D intvec_top - 7;
> -	mpic->timer_vecs[6] =3D intvec_top - 6;
> -	mpic->timer_vecs[7] =3D intvec_top - 5;
> -	mpic->ipi_vecs[0]   =3D intvec_top - 4;
> -	mpic->ipi_vecs[1]   =3D intvec_top - 3;
> -	mpic->ipi_vecs[2]   =3D intvec_top - 2;
> -	mpic->ipi_vecs[3]   =3D intvec_top - 1;
> 	mpic->spurious_vec  =3D intvec_top;
>=20
> 	/* Look for protected sources */
> @@ -1365,6 +1367,8 @@ struct mpic * __init mpic_alloc(struct =
device_node *node,
> 	mpic->isu_shift =3D 1 + __ilog2(mpic->isu_size - 1);
> 	mpic->isu_mask =3D (1 << mpic->isu_shift) - 1;
>=20
> +	mpic_alloc_int_sources(mpic, intvec_top);
> +
> 	mpic->irqhost =3D irq_alloc_host(mpic->node, =
IRQ_HOST_MAP_LINEAR,
> 				       last_irq + 1, &mpic_host_ops,
> 				       intvec_top + 1);
> --=20
> 1.7.2.2
>=20
>=20
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 3/4] powerpc/mpic: Move internal interrupt source vector allocation to a separate function.
  2012-03-27 13:24 ` Kumar Gala
@ 2012-03-27 13:52   ` Sethi Varun-B16395
  2012-03-27 14:02     ` Kumar Gala
  0 siblings, 1 reply; 6+ messages in thread
From: Sethi Varun-B16395 @ 2012-03-27 13:52 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Linuxppc-dev



> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> Sent: Tuesday, March 27, 2012 6:55 PM
> To: Sethi Varun-B16395
> Cc: Linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH 3/4] powerpc/mpic: Move internal interrupt source
> vector allocation to a separate function.
>=20
>=20
> On Mar 27, 2012, at 7:16 AM, Varun Sethi wrote:
>=20
> > Allocate vector numbers for MPIC internal interrupt sources (IPIs and
> > Timers) in a separate function.
> >
>=20
> Explain why you are making this change.


[Sethi Varun-B16395] With the current code it becomes fairly difficult to
add new internal interrupt sources. In my case I had to add 32 additional
interrupt sources corresponding to the MPIC error interrupts. It's more
convenient doing the internal interrupt source allocation using a loop.


>=20
> > Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
> > ---
> > arch/powerpc/include/asm/mpic.h |    7 +++++--
> > arch/powerpc/sysdev/mpic.c      |   30 +++++++++++++++++-------------
> > 2 files changed, 22 insertions(+), 15 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/mpic.h
> > b/arch/powerpc/include/asm/mpic.h index 30e3b29..3929b4b 100644
> > --- a/arch/powerpc/include/asm/mpic.h
> > +++ b/arch/powerpc/include/asm/mpic.h
> > @@ -118,6 +118,9 @@
> > #define MPIC_MAX_CPUS		32
> > #define MPIC_MAX_ISU		32
> >
> > +#define MPIC_MAX_TIMER    8
> > +#define MPIC_MAX_IPI      4
> > +
> > /*
> >  * Tsi108 implementation of MPIC has many differences from the
> > original one  */ @@ -284,8 +287,8 @@ struct mpic
> > 	unsigned int		senses_count;
> >
> > 	/* vector numbers used for internal sources (ipi/timers) */
> > -	unsigned int		ipi_vecs[4];
> > -	unsigned int		timer_vecs[8];
> > +	unsigned int		ipi_vecs[MPIC_MAX_IPI];
> > +	unsigned int		timer_vecs[MPIC_MAX_TIMER];
> >
> > 	/* Spurious vector to program into unused sources */
> > 	unsigned int		spurious_vec;
> > diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> > index 33520dd..c4da1d5 100644
> > --- a/arch/powerpc/sysdev/mpic.c
> > +++ b/arch/powerpc/sysdev/mpic.c
> > @@ -996,7 +996,8 @@ static int mpic_host_map(struct irq_host *h,
> unsigned int virq,
> > 	}
> > #endif /* CONFIG_SMP */
> >
> > -	if (hw >=3D mpic->timer_vecs[0] && hw <=3D mpic->timer_vecs[7]) {
> > +	if (hw >=3D mpic->timer_vecs[0] &&
> > +	    hw <=3D mpic->timer_vecs[MPIC_MAX_TIMER - 1]) {
> > 		WARN_ON(mpic->flags & MPIC_SECONDARY);
> >
> > 		DBG("mpic: mapping as timer\n");
> > @@ -1133,6 +1134,19 @@ static struct irq_host_ops mpic_host_ops =3D {
> > 	.xlate =3D mpic_host_xlate,
> > };
> >
> > +static void mpic_alloc_int_sources(struct mpic *mpic, int intvec_top)
> > +{
> > +	int i, intvec;
> > +
> > +	intvec =3D intvec_top;
> > +
>=20
> local intvec is pointless.

[Sethi Varun-B16395] ok.

-Varun
=20

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/4] powerpc/mpic: Move internal interrupt source vector allocation to a separate function.
  2012-03-27 13:52   ` Sethi Varun-B16395
@ 2012-03-27 14:02     ` Kumar Gala
  2012-04-04 19:09       ` Sethi Varun-B16395
  0 siblings, 1 reply; 6+ messages in thread
From: Kumar Gala @ 2012-03-27 14:02 UTC (permalink / raw)
  To: Sethi Varun-B16395; +Cc: Linuxppc-dev


On Mar 27, 2012, at 8:52 AM, Sethi Varun-B16395 wrote:

>=20
>=20
>> -----Original Message-----
>> From: Kumar Gala [mailto:galak@kernel.crashing.org]
>> Sent: Tuesday, March 27, 2012 6:55 PM
>> To: Sethi Varun-B16395
>> Cc: Linuxppc-dev@lists.ozlabs.org
>> Subject: Re: [PATCH 3/4] powerpc/mpic: Move internal interrupt source
>> vector allocation to a separate function.
>>=20
>>=20
>> On Mar 27, 2012, at 7:16 AM, Varun Sethi wrote:
>>=20
>>> Allocate vector numbers for MPIC internal interrupt sources (IPIs =
and
>>> Timers) in a separate function.
>>>=20
>>=20
>> Explain why you are making this change.
>=20
>=20
> [Sethi Varun-B16395] With the current code it becomes fairly difficult =
to
> add new internal interrupt sources. In my case I had to add 32 =
additional
> interrupt sources corresponding to the MPIC error interrupts. It's =
more
> convenient doing the internal interrupt source allocation using a =
loop.

I think that is more due to how you added the MPIC error interrupts and =
issues w/that code.  If you are treating the MPIC error interrupts as a =
cascade than they should have a distinct linux IRQ space from the =
standard MPIC interrupts.  This is how the MSIs work (as an example).

- k=

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 3/4] powerpc/mpic: Move internal interrupt source vector allocation to a separate function.
  2012-03-27 14:02     ` Kumar Gala
@ 2012-04-04 19:09       ` Sethi Varun-B16395
  2012-04-04 23:29         ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 6+ messages in thread
From: Sethi Varun-B16395 @ 2012-04-04 19:09 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Linuxppc-dev



> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> Sent: Tuesday, March 27, 2012 7:32 PM
> To: Sethi Varun-B16395
> Cc: Linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH 3/4] powerpc/mpic: Move internal interrupt source
> vector allocation to a separate function.
>=20
>=20
> On Mar 27, 2012, at 8:52 AM, Sethi Varun-B16395 wrote:
>=20
> >
> >
> >> -----Original Message-----
> >> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> >> Sent: Tuesday, March 27, 2012 6:55 PM
> >> To: Sethi Varun-B16395
> >> Cc: Linuxppc-dev@lists.ozlabs.org
> >> Subject: Re: [PATCH 3/4] powerpc/mpic: Move internal interrupt source
> >> vector allocation to a separate function.
> >>
> >>
> >> On Mar 27, 2012, at 7:16 AM, Varun Sethi wrote:
> >>
> >>> Allocate vector numbers for MPIC internal interrupt sources (IPIs
> >>> and
> >>> Timers) in a separate function.
> >>>
> >>
> >> Explain why you are making this change.
> >
> >
> > [Sethi Varun-B16395] With the current code it becomes fairly difficult
> > to add new internal interrupt sources. In my case I had to add 32
> > additional interrupt sources corresponding to the MPIC error
> > interrupts. It's more convenient doing the internal interrupt source
> allocation using a loop.
>=20
> I think that is more due to how you added the MPIC error interrupts and
> issues w/that code.  If you are treating the MPIC error interrupts as a
> cascade than they should have a distinct linux IRQ space from the
> standard MPIC interrupts.  This is how the MSIs work (as an example).
In case of error interrupts we are depending on the mpic_host_maps
for mapping and interrupt specifier translations. There is no separate
initialization as in case of MSIs. That's the reason I am treating
error interrupts as mpic internal interrupt sources.

-Varun

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 3/4] powerpc/mpic: Move internal interrupt source vector allocation to a separate function.
  2012-04-04 19:09       ` Sethi Varun-B16395
@ 2012-04-04 23:29         ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2012-04-04 23:29 UTC (permalink / raw)
  To: Sethi Varun-B16395; +Cc: Linuxppc-dev

On Wed, 2012-04-04 at 19:09 +0000, Sethi Varun-B16395 wrote:
> > I think that is more due to how you added the MPIC error interrupts
> and
> > issues w/that code.  If you are treating the MPIC error interrupts
> as a
> > cascade than they should have a distinct linux IRQ space from the
> > standard MPIC interrupts.  This is how the MSIs work (as an
> example).
> In case of error interrupts we are depending on the mpic_host_maps
> for mapping and interrupt specifier translations. There is no separate
> initialization as in case of MSIs. That's the reason I am treating
> error interrupts as mpic internal interrupt sources. 

It makes sense to have an allocator for MPIC vectors but it should be a
single allocator shared with the MSI code.

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-04 23:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-27 12:16 [PATCH 3/4] powerpc/mpic: Move internal interrupt source vector allocation to a separate function Varun Sethi
2012-03-27 13:24 ` Kumar Gala
2012-03-27 13:52   ` Sethi Varun-B16395
2012-03-27 14:02     ` Kumar Gala
2012-04-04 19:09       ` Sethi Varun-B16395
2012-04-04 23:29         ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).