linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3 1/2] powerpc/MPIC: Add get_version API both for internal and external use
@ 2013-04-03  2:03 Jia Hongtao
  2013-04-03  2:03 ` [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata Jia Hongtao
  2013-04-03 16:17 ` [PATCH V3 1/2] powerpc/MPIC: Add get_version API both for internal and external use Scott Wood
  0 siblings, 2 replies; 13+ messages in thread
From: Jia Hongtao @ 2013-04-03  2:03 UTC (permalink / raw)
  To: linuxppc-dev, galak; +Cc: B07421, hongtao.jia

MPIC version is useful information for both mpic_alloc() and mpic_init().
The patch provide an API to get MPIC version for reusing the code.
Also, some other IP block may need MPIC version for their own use.
The API for external use is also provided.

Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
Changes for V3:
* change the name of function from mpic_primary_get_version() to
  fsl_mpic_primary_get_version().
* return 0 if mpic_primary is null.

 arch/powerpc/include/asm/mpic.h |  3 +++
 arch/powerpc/sysdev/mpic.c      | 29 ++++++++++++++++++++++-------
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index c0f9ef9..ea6bf72 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -393,6 +393,9 @@ struct mpic
 #define	MPIC_REGSET_STANDARD		MPIC_REGSET(0)	/* Original MPIC */
 #define	MPIC_REGSET_TSI108		MPIC_REGSET(1)	/* Tsi108/109 PIC */
 
+/* Get the version of primary MPIC */
+extern u32 fsl_mpic_primary_get_version(void);
+
 /* Allocate the controller structure and setup the linux irq descs
  * for the range if interrupts passed in. No HW initialization is
  * actually performed.
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index d30e6a6..e793337 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1165,10 +1165,30 @@ static struct irq_domain_ops mpic_host_ops = {
 	.xlate = mpic_host_xlate,
 };
 
+static u32 mpic_get_version(struct mpic *mpic)
+{
+	u32 brr1;
+
+	brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs,
+			MPIC_FSL_BRR1);
+
+	return brr1 & MPIC_FSL_BRR1_VER;
+}
+
 /*
  * Exported functions
  */
 
+u32 fsl_mpic_primary_get_version(void)
+{
+	struct mpic *mpic = mpic_primary;
+
+	if (mpic)
+		return mpic_get_version(mpic);
+
+	return 0;
+}
+
 struct mpic * __init mpic_alloc(struct device_node *node,
 				phys_addr_t phys_addr,
 				unsigned int flags,
@@ -1315,7 +1335,6 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
 
 	if (mpic->flags & MPIC_FSL) {
-		u32 brr1;
 		int ret;
 
 		/*
@@ -1326,9 +1345,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 		mpic_map(mpic, mpic->paddr, &mpic->thiscpuregs,
 			 MPIC_CPU_THISBASE, 0x1000);
 
-		brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs,
-				MPIC_FSL_BRR1);
-		fsl_version = brr1 & MPIC_FSL_BRR1_VER;
+		fsl_version = mpic_get_version(mpic);
 
 		/* Error interrupt mask register (EIMR) is required for
 		 * handling individual device error interrupts. EIMR
@@ -1518,9 +1535,7 @@ void __init mpic_init(struct mpic *mpic)
 	mpic_cpu_write(MPIC_INFO(CPU_CURRENT_TASK_PRI), 0xf);
 
 	if (mpic->flags & MPIC_FSL) {
-		u32 brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs,
-				      MPIC_FSL_BRR1);
-		u32 version = brr1 & MPIC_FSL_BRR1_VER;
+		u32 version = mpic_get_version(mpic);
 
 		/*
 		 * Timer group B is present at the latest in MPIC 3.1 (e.g.
-- 
1.8.0

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

* [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-04-03  2:03 [PATCH V3 1/2] powerpc/MPIC: Add get_version API both for internal and external use Jia Hongtao
@ 2013-04-03  2:03 ` Jia Hongtao
  2013-06-28  2:28   ` [V2,2/2] " Scott Wood
  2013-09-05 18:34   ` [PATCH V2 2/2] " Kumar Gala
  2013-04-03 16:17 ` [PATCH V3 1/2] powerpc/MPIC: Add get_version API both for internal and external use Scott Wood
  1 sibling, 2 replies; 13+ messages in thread
From: Jia Hongtao @ 2013-04-03  2:03 UTC (permalink / raw)
  To: linuxppc-dev, galak; +Cc: B07421, hongtao.jia

The MPIC version 2.0 has a MSI errata (errata PIC1 of mpc8544), It causes
that neither MSI nor MSI-X can work fine. This is a workaround to allow
MSI-X to function properly.

Signed-off-by: Liu Shuo <soniccat.liu@gmail.com>
Signed-off-by: Li Yang <leoli@freescale.com>
Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
---
Changes for V2:
* change the name of function mpic_has_errata() to mpic_has_erratum_pic1().
* move MSI_HW_ERRATA_ENDIAN define to fsl_msi.h with all other defines.

 arch/powerpc/sysdev/fsl_msi.c | 40 +++++++++++++++++++++++++++++++++++++---
 arch/powerpc/sysdev/fsl_msi.h |  2 ++
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index 178c994..ca1157a 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -98,8 +98,18 @@ static int fsl_msi_init_allocator(struct fsl_msi *msi_data)
 
 static int fsl_msi_check_device(struct pci_dev *pdev, int nvec, int type)
 {
-	if (type == PCI_CAP_ID_MSIX)
-		pr_debug("fslmsi: MSI-X untested, trying anyway.\n");
+	struct fsl_msi *msi;
+
+	if (type == PCI_CAP_ID_MSI) {
+		/*
+		 * MPIC version 2.0 has erratum PIC1. For now MSI
+		 * could not work. So check to prevent MSI from
+		 * being used on the board with this erratum.
+		 */
+		list_for_each_entry(msi, &msi_head, list)
+			if (msi->feature & MSI_HW_ERRATA_ENDIAN)
+				return -EINVAL;
+	}
 
 	return 0;
 }
@@ -142,7 +152,17 @@ static void fsl_compose_msi_msg(struct pci_dev *pdev, int hwirq,
 	msg->address_lo = lower_32_bits(address);
 	msg->address_hi = upper_32_bits(address);
 
-	msg->data = hwirq;
+	/*
+	 * MPIC version 2.0 has erratum PIC1. It causes
+	 * that neither MSI nor MSI-X can work fine.
+	 * This is a workaround to allow MSI-X to function
+	 * properly. It only works for MSI-X, we prevent
+	 * MSI on buggy chips in fsl_msi_check_device().
+	 */
+	if (msi_data->feature & MSI_HW_ERRATA_ENDIAN)
+		msg->data = __swab32(hwirq);
+	else
+		msg->data = hwirq;
 
 	pr_debug("%s: allocated srs: %d, ibs: %d\n",
 		__func__, hwirq / IRQS_PER_MSI_REG, hwirq % IRQS_PER_MSI_REG);
@@ -361,6 +381,15 @@ static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev,
 	return 0;
 }
 
+/* MPIC version 2.0 has erratum PIC1 */
+static int mpic_has_erratum_pic1(void)
+{
+	if (fsl_mpic_primary_get_version() == 0x0200)
+		return 1;
+
+	return 0;
+}
+
 static const struct of_device_id fsl_of_msi_ids[];
 static int fsl_of_msi_probe(struct platform_device *dev)
 {
@@ -423,6 +452,11 @@ static int fsl_of_msi_probe(struct platform_device *dev)
 
 	msi->feature = features->fsl_pic_ip;
 
+	if ((features->fsl_pic_ip & FSL_PIC_IP_MASK) == FSL_PIC_IP_MPIC) {
+		if (mpic_has_erratum_pic1())
+			msi->feature |= MSI_HW_ERRATA_ENDIAN;
+	}
+
 	/*
 	 * Remember the phandle, so that we can match with any PCI nodes
 	 * that have an "fsl,msi" property.
diff --git a/arch/powerpc/sysdev/fsl_msi.h b/arch/powerpc/sysdev/fsl_msi.h
index 8225f86..7389e8e 100644
--- a/arch/powerpc/sysdev/fsl_msi.h
+++ b/arch/powerpc/sysdev/fsl_msi.h
@@ -25,6 +25,8 @@
 #define FSL_PIC_IP_IPIC   0x00000002
 #define FSL_PIC_IP_VMPIC  0x00000003
 
+#define MSI_HW_ERRATA_ENDIAN 0x00000010
+
 struct fsl_msi {
 	struct irq_domain *irqhost;
 
-- 
1.8.0

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

* Re: [PATCH V3 1/2] powerpc/MPIC: Add get_version API both for internal and external use
  2013-04-03  2:03 [PATCH V3 1/2] powerpc/MPIC: Add get_version API both for internal and external use Jia Hongtao
  2013-04-03  2:03 ` [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata Jia Hongtao
@ 2013-04-03 16:17 ` Scott Wood
  1 sibling, 0 replies; 13+ messages in thread
From: Scott Wood @ 2013-04-03 16:17 UTC (permalink / raw)
  To: Jia Hongtao; +Cc: hongtao.jia, B07421, linuxppc-dev

On 04/02/2013 09:03:17 PM, Jia Hongtao wrote:
> MPIC version is useful information for both mpic_alloc() and =20
> mpic_init().
> The patch provide an API to get MPIC version for reusing the code.
> Also, some other IP block may need MPIC version for their own use.
> The API for external use is also provided.
>=20
> Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
> Signed-off-by: Li Yang <leoli@freescale.com>
> ---
> Changes for V3:
> * change the name of function from mpic_primary_get_version() to
>   fsl_mpic_primary_get_version().
> * return 0 if mpic_primary is null.
>=20
>  arch/powerpc/include/asm/mpic.h |  3 +++
>  arch/powerpc/sysdev/mpic.c      | 29 ++++++++++++++++++++++-------
>  2 files changed, 25 insertions(+), 7 deletions(-)
>=20
> diff --git a/arch/powerpc/include/asm/mpic.h =20
> b/arch/powerpc/include/asm/mpic.h
> index c0f9ef9..ea6bf72 100644
> --- a/arch/powerpc/include/asm/mpic.h
> +++ b/arch/powerpc/include/asm/mpic.h
> @@ -393,6 +393,9 @@ struct mpic
>  #define	MPIC_REGSET_STANDARD		MPIC_REGSET(0)	/* =20
> Original MPIC */
>  #define	MPIC_REGSET_TSI108		MPIC_REGSET(1)	/* =20
> Tsi108/109 PIC */
>=20
> +/* Get the version of primary MPIC */
> +extern u32 fsl_mpic_primary_get_version(void);
> +
>  /* Allocate the controller structure and setup the linux irq descs
>   * for the range if interrupts passed in. No HW initialization is
>   * actually performed.
> diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> index d30e6a6..e793337 100644
> --- a/arch/powerpc/sysdev/mpic.c
> +++ b/arch/powerpc/sysdev/mpic.c
> @@ -1165,10 +1165,30 @@ static struct irq_domain_ops mpic_host_ops =3D {
>  	.xlate =3D mpic_host_xlate,
>  };
>=20
> +static u32 mpic_get_version(struct mpic *mpic)
> +{
> +	u32 brr1;
> +
> +	brr1 =3D _mpic_read(mpic->reg_type, &mpic->thiscpuregs,
> +			MPIC_FSL_BRR1);
> +
> +	return brr1 & MPIC_FSL_BRR1_VER;
> +}

This one should have "fsl" in the name as well.

-Scott=

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

* Re: [V2,2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-04-03  2:03 ` [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata Jia Hongtao
@ 2013-06-28  2:28   ` Scott Wood
  2013-07-01  9:36     ` Jia Hongtao-B38951
  2013-09-05  4:00     ` Jia Hongtao-B38951
  2013-09-05 18:34   ` [PATCH V2 2/2] " Kumar Gala
  1 sibling, 2 replies; 13+ messages in thread
From: Scott Wood @ 2013-06-28  2:28 UTC (permalink / raw)
  To: Hongtao Jia; +Cc: B07421, linuxppc-dev

On Wed, Apr 03, 2013 at 10:03:18AM +0800, Hongtao Jia wrote:
> The MPIC version 2.0 has a MSI errata (errata PIC1 of mpc8544), It causes
> that neither MSI nor MSI-X can work fine. This is a workaround to allow
> MSI-X to function properly.
> 
> Signed-off-by: Liu Shuo <soniccat.liu@gmail.com>
> Signed-off-by: Li Yang <leoli@freescale.com>
> Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>

Building on 83xx:

  arch/powerpc/sysdev/built-in.o: In function `fsl_of_msi_probe':
  fsl_msi.c:(.text+0x1464): undefined reference to `fsl_mpic_primary_get_version'
  make[1]: *** [vmlinux] Error 1
  make: *** [sub-make] Error 2

fsl_msi.c supports IPIC as well.

-Scott

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

* RE: [V2,2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-06-28  2:28   ` [V2,2/2] " Scott Wood
@ 2013-07-01  9:36     ` Jia Hongtao-B38951
  2013-09-05  4:00     ` Jia Hongtao-B38951
  1 sibling, 0 replies; 13+ messages in thread
From: Jia Hongtao-B38951 @ 2013-07-01  9:36 UTC (permalink / raw)
  To: Wood Scott-B07421; +Cc: linuxppc-dev@lists.ozlabs.org

> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Friday, June 28, 2013 10:29 AM
> To: Jia Hongtao-B38951
> Cc: linuxppc-dev@lists.ozlabs.org; galak@kernel.crashing.org; Wood Scott-
> B07421
> Subject: Re: [V2,2/2] powerpc/85xx: workaround for chips with MSI
> hardware errata
>=20
> On Wed, Apr 03, 2013 at 10:03:18AM +0800, Hongtao Jia wrote:
> > The MPIC version 2.0 has a MSI errata (errata PIC1 of mpc8544), It
> > causes that neither MSI nor MSI-X can work fine. This is a workaround
> > to allow MSI-X to function properly.
> >
> > Signed-off-by: Liu Shuo <soniccat.liu@gmail.com>
> > Signed-off-by: Li Yang <leoli@freescale.com>
> > Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
>=20
> Building on 83xx:
>=20
>   arch/powerpc/sysdev/built-in.o: In function `fsl_of_msi_probe':
>   fsl_msi.c:(.text+0x1464): undefined reference to
> `fsl_mpic_primary_get_version'
>   make[1]: *** [vmlinux] Error 1
>   make: *** [sub-make] Error 2
>=20
> fsl_msi.c supports IPIC as well.
>=20
> -Scott

Hi Scott,
I updated the patch to fix this compile error just now.
please refer to:
http://patchwork.ozlabs.org/patch/256018/

Thanks.
-Hongtao

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

* RE: [V2,2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-06-28  2:28   ` [V2,2/2] " Scott Wood
  2013-07-01  9:36     ` Jia Hongtao-B38951
@ 2013-09-05  4:00     ` Jia Hongtao-B38951
  2013-09-05 17:57       ` Scott Wood
  1 sibling, 1 reply; 13+ messages in thread
From: Jia Hongtao-B38951 @ 2013-09-05  4:00 UTC (permalink / raw)
  To: Jia Hongtao-B38951, Wood Scott-B07421; +Cc: linuxppc-dev@lists.ozlabs.org

> -----Original Message-----
> From: Jia Hongtao-B38951
> Sent: Monday, July 01, 2013 5:36 PM
> To: Wood Scott-B07421
> Cc: linuxppc-dev@lists.ozlabs.org; galak@kernel.crashing.org
> Subject: RE: [V2,2/2] powerpc/85xx: workaround for chips with MSI
> hardware errata
>=20
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Friday, June 28, 2013 10:29 AM
> > To: Jia Hongtao-B38951
> > Cc: linuxppc-dev@lists.ozlabs.org; galak@kernel.crashing.org; Wood
> > Scott-
> > B07421
> > Subject: Re: [V2,2/2] powerpc/85xx: workaround for chips with MSI
> > hardware errata
> >
> > On Wed, Apr 03, 2013 at 10:03:18AM +0800, Hongtao Jia wrote:
> > > The MPIC version 2.0 has a MSI errata (errata PIC1 of mpc8544), It
> > > causes that neither MSI nor MSI-X can work fine. This is a
> > > workaround to allow MSI-X to function properly.
> > >
> > > Signed-off-by: Liu Shuo <soniccat.liu@gmail.com>
> > > Signed-off-by: Li Yang <leoli@freescale.com>
> > > Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
> >
> > Building on 83xx:
> >
> >   arch/powerpc/sysdev/built-in.o: In function `fsl_of_msi_probe':
> >   fsl_msi.c:(.text+0x1464): undefined reference to
> > `fsl_mpic_primary_get_version'
> >   make[1]: *** [vmlinux] Error 1
> >   make: *** [sub-make] Error 2
> >
> > fsl_msi.c supports IPIC as well.
> >
> > -Scott
>=20
> Hi Scott,
> I updated the patch to fix this compile error just now.
> please refer to:
> http://patchwork.ozlabs.org/patch/256018/
>=20
> Thanks.
> -Hongtao

Hi Scott,

The 83xx compile issue has already been fixed.
Please have a review on this patch.

Thanks.
-Hongtao

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

* Re: [V2,2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-09-05  4:00     ` Jia Hongtao-B38951
@ 2013-09-05 17:57       ` Scott Wood
  2013-09-06  3:19         ` Jia Hongtao-B38951
  0 siblings, 1 reply; 13+ messages in thread
From: Scott Wood @ 2013-09-05 17:57 UTC (permalink / raw)
  To: Jia Hongtao-B38951; +Cc: Wood Scott-B07421, linuxppc-dev@lists.ozlabs.org

On Wed, 2013-09-04 at 23:00 -0500, Jia Hongtao-B38951 wrote:
> > -----Original Message-----
> > From: Jia Hongtao-B38951
> > Sent: Monday, July 01, 2013 5:36 PM
> > To: Wood Scott-B07421
> > Cc: linuxppc-dev@lists.ozlabs.org; galak@kernel.crashing.org
> > Subject: RE: [V2,2/2] powerpc/85xx: workaround for chips with MSI
> > hardware errata
> > 
> > > -----Original Message-----
> > > From: Wood Scott-B07421
> > > Sent: Friday, June 28, 2013 10:29 AM
> > > To: Jia Hongtao-B38951
> > > Cc: linuxppc-dev@lists.ozlabs.org; galak@kernel.crashing.org; Wood
> > > Scott-
> > > B07421
> > > Subject: Re: [V2,2/2] powerpc/85xx: workaround for chips with MSI
> > > hardware errata
> > >
> > > On Wed, Apr 03, 2013 at 10:03:18AM +0800, Hongtao Jia wrote:
> > > > The MPIC version 2.0 has a MSI errata (errata PIC1 of mpc8544), It
> > > > causes that neither MSI nor MSI-X can work fine. This is a
> > > > workaround to allow MSI-X to function properly.
> > > >
> > > > Signed-off-by: Liu Shuo <soniccat.liu@gmail.com>
> > > > Signed-off-by: Li Yang <leoli@freescale.com>
> > > > Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
> > >
> > > Building on 83xx:
> > >
> > >   arch/powerpc/sysdev/built-in.o: In function `fsl_of_msi_probe':
> > >   fsl_msi.c:(.text+0x1464): undefined reference to
> > > `fsl_mpic_primary_get_version'
> > >   make[1]: *** [vmlinux] Error 1
> > >   make: *** [sub-make] Error 2
> > >
> > > fsl_msi.c supports IPIC as well.
> > >
> > > -Scott
> > 
> > Hi Scott,
> > I updated the patch to fix this compile error just now.
> > please refer to:
> > http://patchwork.ozlabs.org/patch/256018/
> > 
> > Thanks.
> > -Hongtao
> 
> Hi Scott,
> 
> The 83xx compile issue has already been fixed.
> Please have a review on this patch.

Oh, sorry -- I missed it because it was marked "Changes Requested".
I've changed the status and will consider it for the next batch of
"next" patches.

In the future, if a patch is miscategorized in patchwork (e.g. says
"changes requested" when there is no longer a need to submit a new
patch) please mention that specifically and provide the patchwork URL.

-Scott

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

* Re: [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-04-03  2:03 ` [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata Jia Hongtao
  2013-06-28  2:28   ` [V2,2/2] " Scott Wood
@ 2013-09-05 18:34   ` Kumar Gala
  2013-09-05 18:37     ` Scott Wood
  1 sibling, 1 reply; 13+ messages in thread
From: Kumar Gala @ 2013-09-05 18:34 UTC (permalink / raw)
  To: Jia Hongtao; +Cc: B07421, linuxppc-dev


On Apr 2, 2013, at 9:03 PM, Jia Hongtao wrote:

> The MPIC version 2.0 has a MSI errata (errata PIC1 of mpc8544), It =
causes
> that neither MSI nor MSI-X can work fine. This is a workaround to =
allow
> MSI-X to function properly.
>=20
> Signed-off-by: Liu Shuo <soniccat.liu@gmail.com>
> Signed-off-by: Li Yang <leoli@freescale.com>
> Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
> ---
> Changes for V2:
> * change the name of function mpic_has_errata() to =
mpic_has_erratum_pic1().
> * move MSI_HW_ERRATA_ENDIAN define to fsl_msi.h with all other =
defines.
>=20
> arch/powerpc/sysdev/fsl_msi.c | 40 =
+++++++++++++++++++++++++++++++++++++---
> arch/powerpc/sysdev/fsl_msi.h |  2 ++
> 2 files changed, 39 insertions(+), 3 deletions(-)
>=20
> diff --git a/arch/powerpc/sysdev/fsl_msi.c =
b/arch/powerpc/sysdev/fsl_msi.c
> index 178c994..ca1157a 100644
> --- a/arch/powerpc/sysdev/fsl_msi.c
> +++ b/arch/powerpc/sysdev/fsl_msi.c
> @@ -98,8 +98,18 @@ static int fsl_msi_init_allocator(struct fsl_msi =
*msi_data)
>=20
> static int fsl_msi_check_device(struct pci_dev *pdev, int nvec, int =
type)
> {
> -	if (type =3D=3D PCI_CAP_ID_MSIX)
> -		pr_debug("fslmsi: MSI-X untested, trying anyway.\n");
> +	struct fsl_msi *msi;
> +
> +	if (type =3D=3D PCI_CAP_ID_MSI) {
> +		/*
> +		 * MPIC version 2.0 has erratum PIC1. For now MSI
> +		 * could not work. So check to prevent MSI from
> +		 * being used on the board with this erratum.
> +		 */
> +		list_for_each_entry(msi, &msi_head, list)
> +			if (msi->feature & MSI_HW_ERRATA_ENDIAN)
> +				return -EINVAL;
> +	}
>=20
> 	return 0;
> }
> @@ -142,7 +152,17 @@ static void fsl_compose_msi_msg(struct pci_dev =
*pdev, int hwirq,
> 	msg->address_lo =3D lower_32_bits(address);
> 	msg->address_hi =3D upper_32_bits(address);
>=20
> -	msg->data =3D hwirq;
> +	/*
> +	 * MPIC version 2.0 has erratum PIC1. It causes
> +	 * that neither MSI nor MSI-X can work fine.
> +	 * This is a workaround to allow MSI-X to function
> +	 * properly. It only works for MSI-X, we prevent
> +	 * MSI on buggy chips in fsl_msi_check_device().
> +	 */
> +	if (msi_data->feature & MSI_HW_ERRATA_ENDIAN)
> +		msg->data =3D __swab32(hwirq);
> +	else
> +		msg->data =3D hwirq;
>=20
> 	pr_debug("%s: allocated srs: %d, ibs: %d\n",
> 		__func__, hwirq / IRQS_PER_MSI_REG, hwirq % =
IRQS_PER_MSI_REG);
> @@ -361,6 +381,15 @@ static int fsl_msi_setup_hwirq(struct fsl_msi =
*msi, struct platform_device *dev,
> 	return 0;
> }
>=20
> +/* MPIC version 2.0 has erratum PIC1 */
> +static int mpic_has_erratum_pic1(void)
> +{
> +	if (fsl_mpic_primary_get_version() =3D=3D 0x0200)
> +		return 1;
> +
> +	return 0;
> +}
> +
> static const struct of_device_id fsl_of_msi_ids[];
> static int fsl_of_msi_probe(struct platform_device *dev)
> {
> @@ -423,6 +452,11 @@ static int fsl_of_msi_probe(struct =
platform_device *dev)
>=20
> 	msi->feature =3D features->fsl_pic_ip;
>=20
> +	if ((features->fsl_pic_ip & FSL_PIC_IP_MASK) =3D=3D =
FSL_PIC_IP_MPIC) {
> +		if (mpic_has_erratum_pic1())

Get ride of the mpic_has_erratum_pic1() function and just put the test =
here

> +			msi->feature |=3D MSI_HW_ERRATA_ENDIAN;
> +	}
> +
> 	/*
> 	 * Remember the phandle, so that we can match with any PCI nodes
> 	 * that have an "fsl,msi" property.
> diff --git a/arch/powerpc/sysdev/fsl_msi.h =
b/arch/powerpc/sysdev/fsl_msi.h
> index 8225f86..7389e8e 100644
> --- a/arch/powerpc/sysdev/fsl_msi.h
> +++ b/arch/powerpc/sysdev/fsl_msi.h
> @@ -25,6 +25,8 @@
> #define FSL_PIC_IP_IPIC   0x00000002
> #define FSL_PIC_IP_VMPIC  0x00000003
>=20
> +#define MSI_HW_ERRATA_ENDIAN 0x00000010
> +

Why does this need to be in the header, why not just have it in the .c =
only

> struct fsl_msi {
> 	struct irq_domain *irqhost;
>=20
> --=20
> 1.8.0
>=20

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

* Re: [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-09-05 18:34   ` [PATCH V2 2/2] " Kumar Gala
@ 2013-09-05 18:37     ` Scott Wood
  2013-09-06 15:01       ` Kumar Gala
  0 siblings, 1 reply; 13+ messages in thread
From: Scott Wood @ 2013-09-05 18:37 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Jia Hongtao, B07421

On Thu, 2013-09-05 at 13:34 -0500, Kumar Gala wrote:
> On Apr 2, 2013, at 9:03 PM, Jia Hongtao wrote:
> > +			msi->feature |= MSI_HW_ERRATA_ENDIAN;
> > +	}
> > +
> > 	/*
> > 	 * Remember the phandle, so that we can match with any PCI nodes
> > 	 * that have an "fsl,msi" property.
> > diff --git a/arch/powerpc/sysdev/fsl_msi.h b/arch/powerpc/sysdev/fsl_msi.h
> > index 8225f86..7389e8e 100644
> > --- a/arch/powerpc/sysdev/fsl_msi.h
> > +++ b/arch/powerpc/sysdev/fsl_msi.h
> > @@ -25,6 +25,8 @@
> > #define FSL_PIC_IP_IPIC   0x00000002
> > #define FSL_PIC_IP_VMPIC  0x00000003
> > 
> > +#define MSI_HW_ERRATA_ENDIAN 0x00000010
> > +
> 
> Why does this need to be in the header, why not just have it in the .c only

Didn't you ask this last time around? :-)

This flag is part of the same numberspace as FSL_PIC_IP_xxx and thus
should be defined in the same place.

-Scott

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

* RE: [V2,2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-09-05 17:57       ` Scott Wood
@ 2013-09-06  3:19         ` Jia Hongtao-B38951
  0 siblings, 0 replies; 13+ messages in thread
From: Jia Hongtao-B38951 @ 2013-09-06  3:19 UTC (permalink / raw)
  To: Wood Scott-B07421; +Cc: linuxppc-dev@lists.ozlabs.org

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogV29vZCBTY290dC1CMDc0
MjENCj4gU2VudDogRnJpZGF5LCBTZXB0ZW1iZXIgMDYsIDIwMTMgMTo1NyBBTQ0KPiBUbzogSmlh
IEhvbmd0YW8tQjM4OTUxDQo+IENjOiBXb29kIFNjb3R0LUIwNzQyMTsgbGludXhwcGMtZGV2QGxp
c3RzLm96bGFicy5vcmc7DQo+IGdhbGFrQGtlcm5lbC5jcmFzaGluZy5vcmcNCj4gU3ViamVjdDog
UmU6IFtWMiwyLzJ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bmQg
cHJvdmlkZSB0aGUgcGF0Y2h3b3JrIFVSTC4NCj4gDQo+IC1TY290dA0KPiANCg0KT2ssIGdvdCBp
dC4NClNvcnJ5IGZvciB5b3VyIGluY29udmVuaWVudC4gDQoNCi1Ib25ndGFvDQoNCg==

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

* Re: [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-09-05 18:37     ` Scott Wood
@ 2013-09-06 15:01       ` Kumar Gala
  2013-09-06 15:36         ` Scott Wood
  0 siblings, 1 reply; 13+ messages in thread
From: Kumar Gala @ 2013-09-06 15:01 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, Jia Hongtao, B07421


On Sep 5, 2013, at 1:37 PM, Scott Wood wrote:

> On Thu, 2013-09-05 at 13:34 -0500, Kumar Gala wrote:
>> On Apr 2, 2013, at 9:03 PM, Jia Hongtao wrote:
>>> +			msi->feature |=3D MSI_HW_ERRATA_ENDIAN;
>>> +	}
>>> +
>>> 	/*
>>> 	 * Remember the phandle, so that we can match with any PCI nodes
>>> 	 * that have an "fsl,msi" property.
>>> diff --git a/arch/powerpc/sysdev/fsl_msi.h =
b/arch/powerpc/sysdev/fsl_msi.h
>>> index 8225f86..7389e8e 100644
>>> --- a/arch/powerpc/sysdev/fsl_msi.h
>>> +++ b/arch/powerpc/sysdev/fsl_msi.h
>>> @@ -25,6 +25,8 @@
>>> #define FSL_PIC_IP_IPIC   0x00000002
>>> #define FSL_PIC_IP_VMPIC  0x00000003
>>>=20
>>> +#define MSI_HW_ERRATA_ENDIAN 0x00000010
>>> +
>>=20
>> Why does this need to be in the header, why not just have it in the =
.c only
>=20
> Didn't you ask this last time around? :-)
>=20
> This flag is part of the same numberspace as FSL_PIC_IP_xxx and thus
> should be defined in the same place.

I probably did, if its part of the FSL_PIC_IP_xxx namespace, than lets =
remove blank line between things to make that a bit more clear

- k

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

* Re: [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-09-06 15:01       ` Kumar Gala
@ 2013-09-06 15:36         ` Scott Wood
  2013-09-06 16:11           ` Kumar Gala
  0 siblings, 1 reply; 13+ messages in thread
From: Scott Wood @ 2013-09-06 15:36 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Jia Hongtao, B07421

On Fri, 2013-09-06 at 10:01 -0500, Kumar Gala wrote:
> On Sep 5, 2013, at 1:37 PM, Scott Wood wrote:
> 
> > On Thu, 2013-09-05 at 13:34 -0500, Kumar Gala wrote:
> >> On Apr 2, 2013, at 9:03 PM, Jia Hongtao wrote:
> >>> +			msi->feature |= MSI_HW_ERRATA_ENDIAN;
> >>> +	}
> >>> +
> >>> 	/*
> >>> 	 * Remember the phandle, so that we can match with any PCI nodes
> >>> 	 * that have an "fsl,msi" property.
> >>> diff --git a/arch/powerpc/sysdev/fsl_msi.h b/arch/powerpc/sysdev/fsl_msi.h
> >>> index 8225f86..7389e8e 100644
> >>> --- a/arch/powerpc/sysdev/fsl_msi.h
> >>> +++ b/arch/powerpc/sysdev/fsl_msi.h
> >>> @@ -25,6 +25,8 @@
> >>> #define FSL_PIC_IP_IPIC   0x00000002
> >>> #define FSL_PIC_IP_VMPIC  0x00000003
> >>> 
> >>> +#define MSI_HW_ERRATA_ENDIAN 0x00000010
> >>> +
> >> 
> >> Why does this need to be in the header, why not just have it in the .c only
> > 
> > Didn't you ask this last time around? :-)
> > 
> > This flag is part of the same numberspace as FSL_PIC_IP_xxx and thus
> > should be defined in the same place.
> 
> I probably did, if its part of the FSL_PIC_IP_xxx namespace, than lets remove blank line between things to make that a bit more clear

It's not part of the FSL_PIC_IP_MASK subnumberspace though, just the
overall msi->features numberspace.

It would be nice if these symbols could have some sort of prefix in
common, though.

-Scott

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

* Re: [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata
  2013-09-06 15:36         ` Scott Wood
@ 2013-09-06 16:11           ` Kumar Gala
  0 siblings, 0 replies; 13+ messages in thread
From: Kumar Gala @ 2013-09-06 16:11 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, Jia Hongtao, B07421


On Sep 6, 2013, at 10:36 AM, Scott Wood wrote:

> On Fri, 2013-09-06 at 10:01 -0500, Kumar Gala wrote:
>> On Sep 5, 2013, at 1:37 PM, Scott Wood wrote:
>>=20
>>> On Thu, 2013-09-05 at 13:34 -0500, Kumar Gala wrote:
>>>> On Apr 2, 2013, at 9:03 PM, Jia Hongtao wrote:
>>>>> +			msi->feature |=3D MSI_HW_ERRATA_ENDIAN;
>>>>> +	}
>>>>> +
>>>>> 	/*
>>>>> 	 * Remember the phandle, so that we can match with any PCI nodes
>>>>> 	 * that have an "fsl,msi" property.
>>>>> diff --git a/arch/powerpc/sysdev/fsl_msi.h =
b/arch/powerpc/sysdev/fsl_msi.h
>>>>> index 8225f86..7389e8e 100644
>>>>> --- a/arch/powerpc/sysdev/fsl_msi.h
>>>>> +++ b/arch/powerpc/sysdev/fsl_msi.h
>>>>> @@ -25,6 +25,8 @@
>>>>> #define FSL_PIC_IP_IPIC   0x00000002
>>>>> #define FSL_PIC_IP_VMPIC  0x00000003
>>>>>=20
>>>>> +#define MSI_HW_ERRATA_ENDIAN 0x00000010
>>>>> +
>>>>=20
>>>> Why does this need to be in the header, why not just have it in the =
.c only
>>>=20
>>> Didn't you ask this last time around? :-)
>>>=20
>>> This flag is part of the same numberspace as FSL_PIC_IP_xxx and thus
>>> should be defined in the same place.
>>=20
>> I probably did, if its part of the FSL_PIC_IP_xxx namespace, than =
lets remove blank line between things to make that a bit more clear
>=20
> It's not part of the FSL_PIC_IP_MASK subnumberspace though, just the
> overall msi->features numberspace.
>=20
> It would be nice if these symbols could have some sort of prefix in
> common, though.
>=20
> -Scott

Maybe we should do something like MSI_FTR_ as a prefix

- k

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

end of thread, other threads:[~2013-09-06 16:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-03  2:03 [PATCH V3 1/2] powerpc/MPIC: Add get_version API both for internal and external use Jia Hongtao
2013-04-03  2:03 ` [PATCH V2 2/2] powerpc/85xx: workaround for chips with MSI hardware errata Jia Hongtao
2013-06-28  2:28   ` [V2,2/2] " Scott Wood
2013-07-01  9:36     ` Jia Hongtao-B38951
2013-09-05  4:00     ` Jia Hongtao-B38951
2013-09-05 17:57       ` Scott Wood
2013-09-06  3:19         ` Jia Hongtao-B38951
2013-09-05 18:34   ` [PATCH V2 2/2] " Kumar Gala
2013-09-05 18:37     ` Scott Wood
2013-09-06 15:01       ` Kumar Gala
2013-09-06 15:36         ` Scott Wood
2013-09-06 16:11           ` Kumar Gala
2013-04-03 16:17 ` [PATCH V3 1/2] powerpc/MPIC: Add get_version API both for internal and external use Scott Wood

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).