Re: Gianfar driver crashes in Kernel v3.10

2013-10-04 Thread Claudiu Manoil

On 10/4/2013 3:03 PM, Thomas Hühn wrote:

Hi all,

We are several Openwrt users based on the TPlink 4900 device and suffer from a 
crashing gianfar driver.
We troubleshooted the problem down to the fact, that a 3.8er Linux kernel is 
working, and a v3.10 crashes, but there is
no reproducable case yet.


I'll have some low traffic tests with the upstream 3.10 kernel on a
p1010rdb, but since you say there's no "reproducibility case" the crash
may not be easy to spot on my side.  I wouldn't jump to conclusions
too fast, the fact that it manifests now doesn't neccesarily mean
that a bug was introduced between v3.8 and v3.10.
I'll let you know should I find something.  Meanwhile, if you have
additional information about how to reproduce it, please share.

Thanks,
Claudiu


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/3] gianfar: Enable eTSEC-A002 erratum w/a for all parts

2013-10-09 Thread Claudiu Manoil
A002 is still in "no plans to fix" state, and applies to all
the current P1/P2 parts as well, so it's resonable to enable
its workaround by default, for all the soc's with etsec.
The impact of not enabling this workaround for affected parts
is that under certain conditons (runt frames or even frames
with RX error detected at PHY level) during controller reset,
the controller might fail to indicate Rx reset (GRS) completion.

Signed-off-by: Claudiu Manoil 
---
 drivers/net/ethernet/freescale/gianfar.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index c4eaade..db5fc7b 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -947,6 +947,9 @@ static void gfar_detect_errata(struct gfar_private *priv)
unsigned int mod = (svr >> 16) & 0xfff6; /* w/o E suffix */
unsigned int rev = svr & 0x;
 
+   /* no plans to fix */
+   priv->errata |= GFAR_ERRATA_A002;
+
/* MPC8313 Rev 2.0 and higher; All MPC837x */
if ((pvr == 0x80850010 && mod == 0x80b0 && rev >= 0x0020) ||
(pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
@@ -957,11 +960,6 @@ static void gfar_detect_errata(struct gfar_private *priv)
(pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
priv->errata |= GFAR_ERRATA_76;
 
-   /* MPC8313 and MPC837x all rev */
-   if ((pvr == 0x80850010 && mod == 0x80b0) ||
-   (pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
-   priv->errata |= GFAR_ERRATA_A002;
-
/* MPC8313 Rev < 2.0, MPC8548 rev 2.0 */
if ((pvr == 0x80850010 && mod == 0x80b0 && rev < 0x0020) ||
(pvr == 0x80210020 && mod == 0x8030 && rev == 0x0020))
@@ -1599,7 +1597,7 @@ static int __gfar_is_rx_idle(struct gfar_private *priv)
/* Normaly TSEC should not hang on GRS commands, so we should
 * actually wait for IEVENT_GRSC flag.
 */
-   if (likely(!gfar_has_errata(priv, GFAR_ERRATA_A002)))
+   if (!gfar_has_errata(priv, GFAR_ERRATA_A002))
return 0;
 
/* Read the eTSEC register at offset 0xD1C. If bits 7-14 are
-- 
1.7.11.7


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 2/3] gianfar: Use mpc85xx support for errata detection

2013-10-09 Thread Claudiu Manoil
Use the macros and defines from mpc85xx.h to simplify
and prevent errors in identifying a mpc85xx based SoC
for errata detection.
This should help enabling (and identifying) workarounds
for various mpc85xx based chips and revisions.
For instance, express MPC8548 Rev.2 as:
(SVR_SOC_VER(svr) == SVR_8548) && (SVR_REV(svr) == 0x20)
instead of:
(pvr == 0x80210020 && mod == 0x8030 && rev == 0x0020)

Signed-off-by: Claudiu Manoil 
---
 drivers/net/ethernet/freescale/gianfar.c | 33 
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index db5fc7b..329a206 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -88,6 +88,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -939,17 +940,13 @@ static void gfar_init_filer_table(struct gfar_private 
*priv)
}
 }
 
-static void gfar_detect_errata(struct gfar_private *priv)
+static void __gfar_detect_errata_83xx(struct gfar_private *priv)
 {
-   struct device *dev = &priv->ofdev->dev;
unsigned int pvr = mfspr(SPRN_PVR);
unsigned int svr = mfspr(SPRN_SVR);
unsigned int mod = (svr >> 16) & 0xfff6; /* w/o E suffix */
unsigned int rev = svr & 0x;
 
-   /* no plans to fix */
-   priv->errata |= GFAR_ERRATA_A002;
-
/* MPC8313 Rev 2.0 and higher; All MPC837x */
if ((pvr == 0x80850010 && mod == 0x80b0 && rev >= 0x0020) ||
(pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
@@ -960,10 +957,30 @@ static void gfar_detect_errata(struct gfar_private *priv)
(pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
priv->errata |= GFAR_ERRATA_76;
 
-   /* MPC8313 Rev < 2.0, MPC8548 rev 2.0 */
-   if ((pvr == 0x80850010 && mod == 0x80b0 && rev < 0x0020) ||
-   (pvr == 0x80210020 && mod == 0x8030 && rev == 0x0020))
+   /* MPC8313 Rev < 2.0 */
+   if (pvr == 0x80850010 && mod == 0x80b0 && rev < 0x0020)
+   priv->errata |= GFAR_ERRATA_12;
+}
+
+static void __gfar_detect_errata_85xx(struct gfar_private *priv)
+{
+   unsigned int svr = mfspr(SPRN_SVR);
+
+   if ((SVR_SOC_VER(svr) == SVR_8548) && (SVR_REV(svr) == 0x20))
priv->errata |= GFAR_ERRATA_12;
+}
+
+static void gfar_detect_errata(struct gfar_private *priv)
+{
+   struct device *dev = &priv->ofdev->dev;
+
+   /* no plans to fix */
+   priv->errata |= GFAR_ERRATA_A002;
+
+   if (pvr_version_is(PVR_VER_E500V1) || pvr_version_is(PVR_VER_E500V2))
+   __gfar_detect_errata_85xx(priv);
+   else /* non-mpc85xx parts, i.e. e300 core based */
+   __gfar_detect_errata_83xx(priv);
 
if (priv->errata)
dev_info(dev, "enabled errata workarounds, flags: 0x%x\n",
-- 
1.7.11.7


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 3/3] gianfar: Enable eTSEC-20 erratum w/a for P2020 Rev1

2013-10-09 Thread Claudiu Manoil
Enable workaround for P2020/P2010 erratum eTSEC 20,
"Excess delays when transmitting TOE=1 large frames".
The impact is that frames lager than 2500-bytes for which
TOE (i.e. TCP/IP hw accelerations like Tx csum) is enabled
may see excess delay before start of transmission.
This erratum was fixed in Rev 2.0.

Signed-off-by: Claudiu Manoil 
---
 drivers/net/ethernet/freescale/gianfar.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index 329a206..9fbe4dd 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -968,6 +968,9 @@ static void __gfar_detect_errata_85xx(struct gfar_private 
*priv)
 
if ((SVR_SOC_VER(svr) == SVR_8548) && (SVR_REV(svr) == 0x20))
priv->errata |= GFAR_ERRATA_12;
+   if (((SVR_SOC_VER(svr) == SVR_P2020) && (SVR_REV(svr) < 0x20)) ||
+   ((SVR_SOC_VER(svr) == SVR_P2010) && (SVR_REV(svr) < 0x20)))
+   priv->errata |= GFAR_ERRATA_76; /* aka eTSEC 20 */
 }
 
 static void gfar_detect_errata(struct gfar_private *priv)
-- 
1.7.11.7


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: Gianfar driver crashes in Kernel v3.10

2013-10-10 Thread Claudiu Manoil

On 10/4/2013 3:28 PM, Thomas Hühn wrote:


[code]
[ 2671.841927] Oops: Exception in kernel mode, sig: 5 [#1]
[ 2671.847141] Freescale P1014
[ 2671.849925] Modules linked in: ath9k pppoe ppp_async iptable_nat
ath9k_common pppox p
e xt_tcpudp xt_tcpmss xt_string xt_statistic xt_state xt_recent xt_quota
xt_pkttype xt_o
mark xt_connbytes xt_comment xt_addrtype xt_TCPMSS xt_REDIRECT xt_NETMAP
xt_LOG xt_IPMAR
ms_datafab ums_cypress ums_alauda slhc nf_nat_tftp nf_nat_snmp_basic
nf_nat_sip nf_nat_r
ntrack_sip nf_conntrack_rtsp nf_conntrack_proto_gre nf_conntrack_irc
nf_conntrack_h323 n
compat_xtables compat ath sch_teql sch_tbf sch_sfq sch_red sch_prio
sch_htb sch_gred sc
skbedit act_mirred em_u32 cls_u32 cls_tcindex cls_flow cls_route cls_fw
sch_hfsc sch_ing
r usb_storage leds_gpio ohci_hcd ehci_platform ehci_hcd sd_mod scsi_mod
fsl_mph_dr_of gp
[ 2671.988946] CPU: 0 PID: 5209 Comm: iftop Not tainted 3.10.13 #2
[ 2671.994859] task: c4b0 ti: c7ff8000 task.ti: c477e000
[ 2672.000250] NIP: c018c7a0 LR: c018c794 CTR: c000b070
[ 2672.005206] REGS: c7ff9f10 TRAP: 3202   Not tainted  (3.10.13)
[ 2672.011028] MSR: 00029000   CR: 4824  XER: 2000
[ 2672.017125]
GPR00: 00ff c477fde0 c4b0   00ff 
7000
GPR08:  0008   0046 10022248 
0008
GPR16: c781b3c0 c781b3c0 00ff  0001 021c 0086
f800
GPR24: c7980300  0001 0040 0003 c4b33000 
0001
[ 2672.046832] NIP [c018c7a0] gfar_poll+0x424/0x520
[ 2672.051442] LR [c018c794] gfar_poll+0x418/0x520
[ 2672.055962] Call Trace:
[ 2672.058402] [c477fde0] [c018c674] gfar_poll+0x2f8/0x520 (unreliable)
[ 2672.064762] [c477fe80] [c01b0ce8] net_rx_action+0x6c/0x158
[ 2672.070249] [c477feb0] [c0027dc4] __do_softirq+0xbc/0x16c
[ 2672.075642] [c477ff00] [c0027f7c] irq_exit+0x4c/0x68
[ 2672.080604] [c477ff10] [c00041f8] do_IRQ+0xf4/0x10c
[ 2672.085478] [c477ff40] [c000ca3c] ret_from_except+0x0/0x18
[ 2672.090991] --- Exception: 501 at 0x48083c28
[ 2672.090991] LR = 0x48083bf8
[ 2672.098378] Instruction dump:
[ 2672.101338] 7f8f2040 419cfcc4 8090 38a0 8061004c 7e118378
81c10050 7ffafb78
[ 2672.109092] 4bf9eaa1 83810034 7c7e1b78 8361003c <83210038> 83a1004c
4860 41a2004c
[ 2672.117021] ---[ end trace 565fb54528d305fa ]---
[ 2672.121628]
[ 2673.103130] Kernel panic - not syncing: Fatal exception in interrupt
[ 2673.109474] Rebooting in 3 seconds..

U-Boot 2010.12-svn15934 (Dec 11 2012 - 16:23:49)
[/code]



Hi,

Does this show up on a half duplex (100Mb/s) link?
Could you provide following for the gianfar interface, on your setup:
# ethtool ethX
and
# ethtool -d ethX | grep 500

Is there any other indication before this Oops? Like a tx timeout WARN?

Thanks,
Claudiu


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: Gianfar driver crashes in Kernel v3.10

2013-10-11 Thread Claudiu Manoil



On 10/11/2013 12:41 AM, Scott Wood wrote:

On Thu, 2013-10-10 at 14:07 +0300, Claudiu Manoil wrote:

On 10/4/2013 3:28 PM, Thomas Hühn wrote:


[code]
[ 2671.841927] Oops: Exception in kernel mode, sig: 5 [#1]
[ 2671.847141] Freescale P1014
[ 2671.849925] Modules linked in: ath9k pppoe ppp_async iptable_nat
ath9k_common pppox p
e xt_tcpudp xt_tcpmss xt_string xt_statistic xt_state xt_recent xt_quota
xt_pkttype xt_o
mark xt_connbytes xt_comment xt_addrtype xt_TCPMSS xt_REDIRECT xt_NETMAP
xt_LOG xt_IPMAR
ms_datafab ums_cypress ums_alauda slhc nf_nat_tftp nf_nat_snmp_basic
nf_nat_sip nf_nat_r
ntrack_sip nf_conntrack_rtsp nf_conntrack_proto_gre nf_conntrack_irc
nf_conntrack_h323 n
compat_xtables compat ath sch_teql sch_tbf sch_sfq sch_red sch_prio
sch_htb sch_gred sc
skbedit act_mirred em_u32 cls_u32 cls_tcindex cls_flow cls_route cls_fw
sch_hfsc sch_ing
r usb_storage leds_gpio ohci_hcd ehci_platform ehci_hcd sd_mod scsi_mod
fsl_mph_dr_of gp
[ 2671.988946] CPU: 0 PID: 5209 Comm: iftop Not tainted 3.10.13 #2
[ 2671.994859] task: c4b0 ti: c7ff8000 task.ti: c477e000
[ 2672.000250] NIP: c018c7a0 LR: c018c794 CTR: c000b070
[ 2672.005206] REGS: c7ff9f10 TRAP: 3202   Not tainted  (3.10.13)
[ 2672.011028] MSR: 00029000   CR: 4824  XER: 2000
[ 2672.017125]
GPR00: 00ff c477fde0 c4b0   00ff 
7000
GPR08:  0008   0046 10022248 
0008
GPR16: c781b3c0 c781b3c0 00ff  0001 021c 0086
f800
GPR24: c7980300  0001 0040 0003 c4b33000 
0001
[ 2672.046832] NIP [c018c7a0] gfar_poll+0x424/0x520
[ 2672.051442] LR [c018c794] gfar_poll+0x418/0x520
[ 2672.055962] Call Trace:
[ 2672.058402] [c477fde0] [c018c674] gfar_poll+0x2f8/0x520 (unreliable)
[ 2672.064762] [c477fe80] [c01b0ce8] net_rx_action+0x6c/0x158
[ 2672.070249] [c477feb0] [c0027dc4] __do_softirq+0xbc/0x16c
[ 2672.075642] [c477ff00] [c0027f7c] irq_exit+0x4c/0x68
[ 2672.080604] [c477ff10] [c00041f8] do_IRQ+0xf4/0x10c
[ 2672.085478] [c477ff40] [c000ca3c] ret_from_except+0x0/0x18
[ 2672.090991] --- Exception: 501 at 0x48083c28
[ 2672.090991] LR = 0x48083bf8
[ 2672.098378] Instruction dump:
[ 2672.101338] 7f8f2040 419cfcc4 8090 38a0 8061004c 7e118378
81c10050 7ffafb78
[ 2672.109092] 4bf9eaa1 83810034 7c7e1b78 8361003c <83210038> 83a1004c
4860 41a2004c
[ 2672.117021] ---[ end trace 565fb54528d305fa ]---
[ 2672.121628]
[ 2673.103130] Kernel panic - not syncing: Fatal exception in interrupt
[ 2673.109474] Rebooting in 3 seconds..

U-Boot 2010.12-svn15934 (Dec 11 2012 - 16:23:49)
[/code]



Hi,

Does this show up on a half duplex (100Mb/s) link?
Could you provide following for the gianfar interface, on your setup:
# ethtool ethX
and
# ethtool -d ethX | grep 500

Is there any other indication before this Oops? Like a tx timeout WARN?


It's a watchdog interrupt (CPU watchdog, not netdev).  I think it's only
showing up in the gianfar code because that's what's running (unless the
gianfar code is causing the watchdog daemon to not run).



Hi Scott,
Good to know that the exception is triggered by the watchdog, and at
this point I assume they simply enabled the watchdog support in kernel
(as you know, it's not enabled by the default config) and that the
exception triggered as the system froze.  Since this reportedly happens
under certain traffic conditions (not "high network load, or routing
traffic") I think that information about the link state (whether
it's 100 Mb/s half duplex or not) is relevant here.  Any other
indication on top of that (if there is any) is also useful.

Thanks.

Claudiu


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: Fwd: Gianfar driver crashes in Kernel v3.10

2013-10-16 Thread Claudiu Manoil

On 10/11/2013 11:59 AM, Thomas Hühn wrote:

Hi Claudiu,


Does this show up on a half duplex (100Mb/s) link?


In my testsetup I always used 1GBit Ethernet connections, so no 100MBit tested 
yet.
Should I do so ?


Could you provide following for the gianfar interface, on your setup:


sure:

# ethtool ethX

root@Bluse-home:~# ethtool eth0
Settings for eth0:
Supported ports: [ ]
Supported link modes:   1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: No
Advertised link modes:  1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: No
Speed: 1000Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: external
Auto-negotiation: on
Current message level: 0x003f (63)
   drv probe link timer ifdown ifup
Link detected: yes


and
# ethtool -d ethX | grep 500


root@Bluse-home:~# ethtool -d eth0 | grep 500
0x0500: 00 00 00 3f 00 00 72 05 40 60 50 60 00 a1 f0 37



Is there any other indication before this Oops? Like a tx timeout WARN?



Nothing there about any timeout.



Please try the following patch:
http://patchwork.ozlabs.org/patch/283235/

It should help with your issue.

claudiu


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: Gianfar driver crashes in Kernel v3.10

2013-11-01 Thread Claudiu Manoil

Hi Thomas,

On 10/31/2013 1:51 PM, Thomas Hühn wrote:

Hi Claudiu,



Please try the following patch:
http://patchwork.ozlabs.org/patch/283235/

It should help with your issue.



Several OpenWrt users including myself have tested your patch on
TPLink-4900 routers.
We do have positive feedback, as no crash nor system freeze was reported
for different
network loads and router setups.
All different scenarios / details and two digit uptimes are in this
forum thread:
https://forum.openwrt.org/viewtopic.php?id=42062&p=13

Thanks again for your work and  I hope to see this patch merged upstream.

Greetings Thomas



Thanks for the testing and feedback.

The patch has been merged into davem/net-next.git:

http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=3ba405db1c1b05d157474c71e559393f7ea436ad

And I think it will be merged from there into the next
kernel release. I think that in time it will be back-ported
to stable kernel versions too. In some cases, requests are made
to the netdev mailing list to speedup inclusion of fixes (such
as this one) to certain stable kernel versions.

Thanks,
Claudiu


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc/85xx: Merge 85xx/p1023_defconfig into mpc85xx_smp_defconfig and mpc85xx_defconfig

2013-11-11 Thread Claudiu Manoil

On 11/9/2013 1:17 AM, Lijun Pan wrote:

diff --git a/arch/powerpc/configs/mpc85xx_defconfig 
b/arch/powerpc/configs/mpc85xx_defconfig
index d2e0fab..72fff6e 100644
--- a/arch/powerpc/configs/mpc85xx_defconfig
+++ b/arch/powerpc/configs/mpc85xx_defconfig
@@ -1,4 +1,5 @@
  CONFIG_PPC_85xx=y
+CONFIG_SMP=y


mpc85xx_defconfig is targeting single CPU systems, like P1010,
so why enable SMP here since there is a separate mpc85xx_smp_defconfig?

regards,
Claudiu


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/3] doc: dt: net: Add fsl,wake-on-filer for eTSEC

2015-10-01 Thread Claudiu Manoil
Add the "fsl,wake-on-filer" property for eTSEC nodes to
indicate that the system has the power management
infrastructure needed to be able to wake up the system
via FGPI (filer, aka. h/w rx parser) interrupt.

Cc: Li Yang 
Cc: Zhao Chenhui 

Signed-off-by: Claudiu Manoil 
---
 Documentation/devicetree/bindings/net/fsl-tsec-phy.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt 
b/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt
index 1e97532..db74f0d 100644
--- a/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt
+++ b/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt
@@ -57,6 +57,10 @@ Properties:
 "rgmii-id", as all other connection types are detected by hardware.
   - fsl,magic-packet : If present, indicates that the hardware supports
 waking up via magic packet.
+  - fsl,wake-on-filer : If present, indicates that the hardware supports
+waking up by Filer General Purpose Interrupt (FGPI) asserted on the
+Rx int line.  This is an advanced power management capability allowing
+certain packet types (user) defined by filer rules to wake up the system.
   - bd-stash : If present, indicates that the hardware supports stashing
 buffer descriptors in the L2.
   - rx-stash-len : Denotes the number of bytes of a received buffer to stash
-- 
1.7.11.7

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/3] powerpc: dts: p1022si: Add fsl,wake-on-filer for eTSEC

2015-10-01 Thread Claudiu Manoil
Enable the "wake-on-filer" (aka. wake on user defined packet)
wake on lan capability for the eTSEC ethernet nodes.

Cc: Li Yang 
Cc: Zhao Chenhui 

Signed-off-by: Claudiu Manoil 
---
 arch/powerpc/boot/dts/fsl/p1022si-post.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi
index 426bf41..5f51b7b 100644
--- a/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p1022si-post.dtsi
@@ -224,10 +224,12 @@
 
 /include/ "pq3-etsec2-0.dtsi"
enet0: enet0_grp2: ethernet@b {
+   fsl,wake-on-filer;
};
 
 /include/ "pq3-etsec2-1.dtsi"
enet1: enet1_grp2: ethernet@b1000 {
+   fsl,wake-on-filer;
};
 
global-utilities@e {
-- 
1.7.11.7

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 3/3] gianfar: Add WAKE_UCAST and "wake-on-filer" support

2015-10-01 Thread Claudiu Manoil
This enables eTSEC's filer (Rx parser) and the FGPI Rx
interrupt (Filer General Purpose Interrupt) as a wakeup
source event.

Upon entering suspend state, the eTSEC filer is given
a rule to match incoming L2 unicast packets.  A packet
matching the rule will be enqueued in the Rx ring and
a FGPI Rx interrupt will be asserted by the filer to
wakeup the system.  Other packet types will be dropped.
On resume the filer table is restored to the content
before entering suspend state.
The set of rules from gfar_filer_config_wol() could be
extended to implement other WoL capabilities as well.

The "fsl,wake-on-filer" DT binding enables this capability
on certain platforms that feature the necessary power
management infrastructure, targeting mainly printing and
imaging applications.
(refer to Power Management section of the SoC Ref Man)

Cc: Li Yang 
Cc: Zhao Chenhui 

Signed-off-by: Claudiu Manoil 
---
 drivers/net/ethernet/freescale/gianfar.c | 155 +--
 drivers/net/ethernet/freescale/gianfar.h |  12 +-
 drivers/net/ethernet/freescale/gianfar_ethtool.c |  43 +--
 3 files changed, 186 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index 710715f..7f5389c 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -907,6 +907,9 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
if (of_find_property(np, "fsl,magic-packet", NULL))
priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
 
+   if (of_get_property(np, "fsl,wake-on-filer", NULL))
+   priv->device_flags |= FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER;
+
priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
 
/* In the case of a fixed PHY, the DT node associated
@@ -1415,8 +1418,14 @@ static int gfar_probe(struct platform_device *ofdev)
goto register_fail;
}
 
-   device_set_wakeup_capable(&dev->dev, priv->device_flags &
- FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
+   if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET)
+   priv->wol_supported |= GFAR_WOL_MAGIC;
+
+   if ((priv->device_flags & FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER) &&
+   priv->rx_filer_enable)
+   priv->wol_supported |= GFAR_WOL_FILER_UCAST;
+
+   device_set_wakeup_capable(&ofdev->dev, priv->wol_supported);
 
/* fill out IRQ number and name fields */
for (i = 0; i < priv->num_grps; i++) {
@@ -1479,15 +1488,122 @@ static int gfar_remove(struct platform_device *ofdev)
 
 #ifdef CONFIG_PM
 
+static void __gfar_filer_disable(struct gfar_private *priv)
+{
+   struct gfar __iomem *regs = priv->gfargrp[0].regs;
+   u32 temp;
+
+   temp = gfar_read(®s->rctrl);
+   temp &= ~(RCTRL_FILREN | RCTRL_PRSDEP_INIT);
+   gfar_write(®s->rctrl, temp);
+}
+
+static void __gfar_filer_enable(struct gfar_private *priv)
+{
+   struct gfar __iomem *regs = priv->gfargrp[0].regs;
+   u32 temp;
+
+   temp = gfar_read(®s->rctrl);
+   temp |= RCTRL_FILREN | RCTRL_PRSDEP_INIT;
+   gfar_write(®s->rctrl, temp);
+}
+
+/* Filer rules implementing wol capabilities */
+static void gfar_filer_config_wol(struct gfar_private *priv)
+{
+   unsigned int i;
+   u32 rqfcr;
+
+   __gfar_filer_disable(priv);
+
+   /* clear the filer table, reject any packet by default */
+   rqfcr = RQFCR_RJE | RQFCR_CMP_MATCH;
+   for (i = 0; i <= MAX_FILER_IDX; i++)
+   gfar_write_filer(priv, i, rqfcr, 0);
+
+   i = 0;
+   if (priv->wol_opts & GFAR_WOL_FILER_UCAST) {
+   /* unicast packet, accept it */
+   struct net_device *ndev = priv->ndev;
+   /* get the default rx queue index */
+   u8 qindex = (u8)priv->gfargrp[0].rx_queue->qindex;
+   u32 dest_mac_addr = (ndev->dev_addr[0] << 16) |
+   (ndev->dev_addr[1] << 8) |
+ndev->dev_addr[2];
+
+   rqfcr = (qindex << 10) | RQFCR_AND |
+   RQFCR_CMP_EXACT | RQFCR_PID_DAH;
+
+   gfar_write_filer(priv, i++, rqfcr, dest_mac_addr);
+
+   dest_mac_addr = (ndev->dev_addr[3] << 16) |
+   (ndev->dev_addr[4] << 8) |
+ndev->dev_addr[5];
+   rqfcr = (qindex << 10) | RQFCR_GPI |
+   RQFCR_CMP_EXACT | RQFCR_PID_DAL;
+   gfar_write_filer(priv, i++, rqfcr, dest_mac_addr);
+   }
+
+   __gfar_filer_enable(priv);
+}
+
+static void gfar_filer_restore_table(struct gfar_private *priv)
+{

[PATCH] powerpc/85xx: Add missing config option for CACHE SRAM code

2012-01-31 Thread Claudiu Manoil
fsl_85xx_l2ctlr.o and fsl_85xx_cache_sram.o are built only
if CONFIG_FSL_85XX_CACHE_SRAM is defined. The driver that
qualifies and wants to make use of the CACHE SRAM's exported
API (i.e. a freescale net driver) should (be able to) select
this config option.

Signed-off-by: Claudiu Manoil 
---
 arch/powerpc/platforms/85xx/Kconfig |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/Kconfig 
b/arch/powerpc/platforms/85xx/Kconfig
index d7946be..6e2eecd 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -13,6 +13,15 @@ if FSL_SOC_BOOKE
 
 if PPC32
 
+config FSL_85XX_CACHE_SRAM
+   bool
+   select PPC_LIB_RHEAP
+   help
+ When selected, this option enables cache-sram support
+ for memory allocation on P1/P2 QorIQ platforms.
+ cache-sram-size and cache-sram-offset kernel boot
+ parameters should be passed when this option is enabled.
+
 config MPC8540_ADS
bool "Freescale MPC8540 ADS"
select DEFAULT_UIMAGE
-- 
1.6.6


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] powerpc/85xx: Fix compiler error with THIS_MODULE and related

2012-01-31 Thread Claudiu Manoil
   CC  arch/powerpc/sysdev/fsl_85xx_l2ctlr.o
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:209:13: error: 'THIS_MODULE' undeclared 
here (not in a function)
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:229:20: error: expected declaration 
specifiers or '...' before string constant
cc1: warnings being treated as errors
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:229:1: error: data definition has no type 
or storage class
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:229:1: error: type defaults to 'int' in 
declaration of 'MODULE_DESCRIPTION'
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:229:20: error: function declaration isn't 
a prototype
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:230:16: error: expected declaration 
specifiers or '...' before string constant
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:230:1: error: data definition has no type 
or storage class
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:230:1: error: type defaults to 'int' in 
declaration of 'MODULE_LICENSE'
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:230:16: error: function declaration isn't 
a prototype
make[1]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1

...

  CC  arch/powerpc/sysdev/fsl_85xx_cache_sram.o
cc1: warnings being treated as errors
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:69:1: error: data definition has no 
type or storage class
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:69:1: error: type defaults to 'int' 
in declaration of 'EXPORT_SYMBOL'
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:69:1: error: parameter names (without 
types) in function declaration
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:80:1: error: data definition has no 
type or storage class
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:80:1: error: type defaults to 'int' 
in declaration of 'EXPORT_SYMBOL'
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:80:1: error: parameter names (without 
types) in function declaration
make[1]: *** [arch/powerpc/sysdev/fsl_85xx_cache_sram.o] Error 1

Signed-off-by: Claudiu Manoil 
---
 arch/powerpc/sysdev/fsl_85xx_cache_sram.c |1 +
 arch/powerpc/sysdev/fsl_85xx_l2ctlr.c |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c 
b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c
index 1164158..92cce8d 100644
--- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c
+++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c
@@ -24,6 +24,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c 
b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
index 5f88797..1957e53 100644
--- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -21,6 +21,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
-- 
1.6.6


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH][v2] powerpc/85xx: Fix compiler error with THIS_MODULE and related

2012-02-01 Thread Claudiu Manoil
CC  arch/powerpc/sysdev/fsl_85xx_l2ctlr.o
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:209:13: error: 'THIS_MODULE' undeclared 
here (not in a function)
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:229:20: error: expected declaration 
specifiers or '...' before string constant
cc1: warnings being treated as errors
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:229:1: error: data definition has no type 
or storage class
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:229:1: error: type defaults to 'int' in 
declaration of 'MODULE_DESCRIPTION'
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:229:20: error: function declaration isn't 
a prototype
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:230:16: error: expected declaration 
specifiers or '...' before string constant
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:230:1: error: data definition has no type 
or storage class
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:230:1: error: type defaults to 'int' in 
declaration of 'MODULE_LICENSE'
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c:230:16: error: function declaration isn't 
a prototype
make[1]: *** [arch/powerpc/sysdev/fsl_85xx_l2ctlr.o] Error 1

...

  CC  arch/powerpc/sysdev/fsl_85xx_cache_sram.o
cc1: warnings being treated as errors
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:69:1: error: data definition has no 
type or storage class
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:69:1: error: type defaults to 'int' 
in declaration of 'EXPORT_SYMBOL'
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:69:1: error: parameter names (without 
types) in function declaration
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:80:1: error: data definition has no 
type or storage class
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:80:1: error: type defaults to 'int' 
in declaration of 'EXPORT_SYMBOL'
arch/powerpc/sysdev/fsl_85xx_cache_sram.c:80:1: error: parameter names (without 
types) in function declaration
make[1]: *** [arch/powerpc/sysdev/fsl_85xx_cache_sram.o] Error 1

Signed-off-by: Claudiu Manoil 
---
Replaced  with  for fsl_85xx_cache_sram.c.

 arch/powerpc/sysdev/fsl_85xx_cache_sram.c |1 +
 arch/powerpc/sysdev/fsl_85xx_l2ctlr.c |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c 
b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c
index 1164158..37a6909 100644
--- a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c
+++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c
@@ -24,6 +24,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c 
b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
index 5f88797..1957e53 100644
--- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -21,6 +21,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
-- 
1.6.6


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] powerpc/85xx: Fix sram_offset parameter type

2012-07-19 Thread Claudiu Manoil
The sram_offset parameter represents a physical address
and should be of type phys_addr_t. As part of this fix,
the extraction of sram_params is being cleaned-up and
fixed.
This patch fixes now the case when the offset value of
0xfff0 was being rejected by the driver (returning
-EINVAL), although this is a valid offset value.

Signed-off-by: Tang Yuantian 
Signed-off-by: Claudiu Manoil 
---
 arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h |4 +-
 arch/powerpc/sysdev/fsl_85xx_l2ctlr.c |   39 ++--
 2 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h 
b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
index 60c9c0b..a4ce9b8 100644
--- a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
+++ b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 Freescale Semiconductor, Inc
+ * Copyright 2009-2010 2012 Freescale Semiconductor, Inc
  *
  * QorIQ based Cache Controller Memory Mapped Registers
  *
@@ -91,7 +91,7 @@ struct mpc85xx_l2ctlr {
 
 struct sram_parameters {
unsigned int sram_size;
-   uint64_t sram_offset;
+   phys_addr_t sram_offset;
 };
 
 extern int instantiate_cache_sram(struct platform_device *dev,
diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c 
b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
index 611bb4b..d65e785 100644
--- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 Freescale Semiconductor, Inc.
+ * Copyright 2009-2010 2012 Freescale Semiconductor, Inc.
  *
  * QorIQ (P1/P2) L2 controller init for Cache-SRAM instantiation
  *
@@ -31,24 +31,21 @@ static char *sram_size;
 static char *sram_offset;
 struct mpc85xx_l2ctlr __iomem *l2ctlr;
 
-static long get_cache_sram_size(void)
+static int get_cache_sram_params(struct sram_parameters *sram_params)
 {
-   unsigned long val;
+   unsigned long long addr;
+   unsigned int size;
 
-   if (!sram_size || (strict_strtoul(sram_size, 0, &val) < 0))
+   if (!sram_size || (kstrtouint(sram_size, 0, &size) < 0))
return -EINVAL;
 
-   return val;
-}
-
-static long get_cache_sram_offset(void)
-{
-   unsigned long val;
-
-   if (!sram_offset || (strict_strtoul(sram_offset, 0, &val) < 0))
+   if (!sram_offset || (kstrtoull(sram_offset, 0, &addr) < 0))
return -EINVAL;
 
-   return val;
+   sram_params->sram_offset = addr;
+   sram_params->sram_size = size;
+
+   return 0;
 }
 
 static int __init get_size_from_cmdline(char *str)
@@ -93,17 +90,9 @@ static int __devinit mpc85xx_l2ctlr_of_probe(struct 
platform_device *dev)
}
l2cache_size = *prop;
 
-   sram_params.sram_size  = get_cache_sram_size();
-   if ((int)sram_params.sram_size <= 0) {
-   dev_err(&dev->dev,
-   "Entire L2 as cache, Aborting Cache-SRAM stuff\n");
-   return -EINVAL;
-   }
-
-   sram_params.sram_offset  = get_cache_sram_offset();
-   if ((int64_t)sram_params.sram_offset <= 0) {
+   if (get_cache_sram_params(&sram_params)) {
dev_err(&dev->dev,
-   "Entire L2 as cache, provide a valid sram offset\n");
+   "Entire L2 as cache, provide valid sram offset and 
size\n");
return -EINVAL;
}
 
@@ -125,14 +114,14 @@ static int __devinit mpc85xx_l2ctlr_of_probe(struct 
platform_device *dev)
 * Write bits[0-17] to srbar0
 */
out_be32(&l2ctlr->srbar0,
-   sram_params.sram_offset & L2SRAM_BAR_MSK_LO18);
+   lower_32_bits(sram_params.sram_offset) & L2SRAM_BAR_MSK_LO18);
 
/*
 * Write bits[18-21] to srbare0
 */
 #ifdef CONFIG_PHYS_64BIT
out_be32(&l2ctlr->srbarea0,
-   (sram_params.sram_offset >> 32) & L2SRAM_BARE_MSK_HI4);
+   upper_32_bits(sram_params.sram_offset) & L2SRAM_BARE_MSK_HI4);
 #endif
 
clrsetbits_be32(&l2ctlr->ctl, L2CR_L2E, L2CR_L2FI);
-- 
1.6.6


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc/85xx: Fix sram_offset parameter type

2012-07-26 Thread Claudiu Manoil

On 7/19/2012 3:07 PM, Kumar Gala wrote:


On Jul 19, 2012, at 5:28 AM, Claudiu Manoil wrote:


The sram_offset parameter represents a physical address
and should be of type phys_addr_t. As part of this fix,
the extraction of sram_params is being cleaned-up and
fixed.
This patch fixes now the case when the offset value of
0xfff0 was being rejected by the driver (returning
-EINVAL), although this is a valid offset value.

Signed-off-by: Tang Yuantian 
Signed-off-by: Claudiu Manoil 
---
arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h |4 +-
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c |   39 ++--
2 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h 
b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
index 60c9c0b..a4ce9b8 100644
--- a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
+++ b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 Freescale Semiconductor, Inc
+ * Copyright 2009-2010 2012 Freescale Semiconductor, Inc


we normally do 2009-2010, 2012


Hi Kumar,

Should I re-spin this patch, with the copyright year formatted per your 
suggestion above?


Thanks,
claudiu


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH][v1] powerpc/85xx: Fix sram_offset parameter type

2012-07-26 Thread Claudiu Manoil
The sram_offset parameter represents a physical address
and should be of type phys_addr_t. As part of this fix,
the extraction of sram_params is being cleaned-up and
fixed.
This patch fixes now the case when the offset value of
0xfff0 was being rejected by the driver (returning
-EINVAL), although this is a valid offset value.

Signed-off-by: Tang Yuantian 
Signed-off-by: Claudiu Manoil 
---
v1: fixed copyright year format

 arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h |4 +-
 arch/powerpc/sysdev/fsl_85xx_l2ctlr.c |   39 ++--
 2 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h 
b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
index 60c9c0b..2aa97dd 100644
--- a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
+++ b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 Freescale Semiconductor, Inc
+ * Copyright 2009-2010, 2012 Freescale Semiconductor, Inc
  *
  * QorIQ based Cache Controller Memory Mapped Registers
  *
@@ -91,7 +91,7 @@ struct mpc85xx_l2ctlr {
 
 struct sram_parameters {
unsigned int sram_size;
-   uint64_t sram_offset;
+   phys_addr_t sram_offset;
 };
 
 extern int instantiate_cache_sram(struct platform_device *dev,
diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c 
b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
index 611bb4b..d131c8a 100644
--- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009-2010 Freescale Semiconductor, Inc.
+ * Copyright 2009-2010, 2012 Freescale Semiconductor, Inc.
  *
  * QorIQ (P1/P2) L2 controller init for Cache-SRAM instantiation
  *
@@ -31,24 +31,21 @@ static char *sram_size;
 static char *sram_offset;
 struct mpc85xx_l2ctlr __iomem *l2ctlr;
 
-static long get_cache_sram_size(void)
+static int get_cache_sram_params(struct sram_parameters *sram_params)
 {
-   unsigned long val;
+   unsigned long long addr;
+   unsigned int size;
 
-   if (!sram_size || (strict_strtoul(sram_size, 0, &val) < 0))
+   if (!sram_size || (kstrtouint(sram_size, 0, &size) < 0))
return -EINVAL;
 
-   return val;
-}
-
-static long get_cache_sram_offset(void)
-{
-   unsigned long val;
-
-   if (!sram_offset || (strict_strtoul(sram_offset, 0, &val) < 0))
+   if (!sram_offset || (kstrtoull(sram_offset, 0, &addr) < 0))
return -EINVAL;
 
-   return val;
+   sram_params->sram_offset = addr;
+   sram_params->sram_size = size;
+
+   return 0;
 }
 
 static int __init get_size_from_cmdline(char *str)
@@ -93,17 +90,9 @@ static int __devinit mpc85xx_l2ctlr_of_probe(struct 
platform_device *dev)
}
l2cache_size = *prop;
 
-   sram_params.sram_size  = get_cache_sram_size();
-   if ((int)sram_params.sram_size <= 0) {
-   dev_err(&dev->dev,
-   "Entire L2 as cache, Aborting Cache-SRAM stuff\n");
-   return -EINVAL;
-   }
-
-   sram_params.sram_offset  = get_cache_sram_offset();
-   if ((int64_t)sram_params.sram_offset <= 0) {
+   if (get_cache_sram_params(&sram_params)) {
dev_err(&dev->dev,
-   "Entire L2 as cache, provide a valid sram offset\n");
+   "Entire L2 as cache, provide valid sram offset and 
size\n");
return -EINVAL;
}
 
@@ -125,14 +114,14 @@ static int __devinit mpc85xx_l2ctlr_of_probe(struct 
platform_device *dev)
 * Write bits[0-17] to srbar0
 */
out_be32(&l2ctlr->srbar0,
-   sram_params.sram_offset & L2SRAM_BAR_MSK_LO18);
+   lower_32_bits(sram_params.sram_offset) & L2SRAM_BAR_MSK_LO18);
 
/*
 * Write bits[18-21] to srbare0
 */
 #ifdef CONFIG_PHYS_64BIT
out_be32(&l2ctlr->srbarea0,
-   (sram_params.sram_offset >> 32) & L2SRAM_BARE_MSK_HI4);
+   upper_32_bits(sram_params.sram_offset) & L2SRAM_BARE_MSK_HI4);
 #endif
 
clrsetbits_be32(&l2ctlr->ctl, L2CR_L2E, L2CR_L2FI);
-- 
1.6.6


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: gianfar driver crash on P1020

2012-10-09 Thread Claudiu Manoil

Hello,

Did you try this patch?
http://patchwork.ozlabs.org/patch/186315/

Claudiu

On 10/9/2012 3:22 PM, Avi Tsarfati wrote:


Hi,

I have the same problem as you do.

Have you found the CPU stuck reason (or fix) in P1020RDB board ?

Thanks,

Avi Tsarfati.



 


This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & 
computer viruses(187).




___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH net-next 0/2] net: gianfar: Drop GFAR_MQ_POLLING support

2021-04-16 Thread Claudiu Manoil
Drop long time obsolete "per NAPI multi-queue" support in gianfar,
and related (and undocumented) device tree properties.

Claudiu Manoil (2):
  gianfar: Drop GFAR_MQ_POLLING support
  powerpc: dts: fsl: Drop obsolete fsl,rx-bit-map and fsl,tx-bit-map
properties

 arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi |   4 -
 arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi |   4 -
 arch/powerpc/boot/dts/fsl/c293si-post.dtsi|   4 -
 arch/powerpc/boot/dts/fsl/p1010si-post.dtsi   |  21 ---
 drivers/net/ethernet/freescale/gianfar.c  | 170 ++
 drivers/net/ethernet/freescale/gianfar.h  |  17 --
 6 files changed, 11 insertions(+), 209 deletions(-)

-- 
2.25.1



[PATCH net-next 1/2] gianfar: Drop GFAR_MQ_POLLING support

2021-04-16 Thread Claudiu Manoil
Gianfar used to enable all 8 Rx queues (DMA rings) per
ethernet device, even though the controller can only
support 2 interrupt lines at most.  This meant that
multiple Rx queues would have to be grouped per NAPI poll
routine, and the CPU would have to split the budget and
service them in a round robin manner.  The overhead of
this scheme proved to outweight the potential benefits.
The alternative was to introduce the "Single Queue" polling
mode, supporting one Rx queue per NAPI, which became the
default packet processing option and helped improve the
performance of the driver.
MQ_POLLING also relies on undocumeted device tree properties
to specify how to map the 8 Rx and Tx queues to a given
interrupt line (aka "interrupt group").  Using module parameters
to enable this mode wasn't an option either.  Long story short,
MQ_POLLING became obsolete, now it is just dead code, and no
one asked for it so far.
For the Tx queues, multi-queue support (more than 1 Tx queue
per CPU) could be revisited by adding tc MQPRIO support, but
again, one has to consider that there are only 2 interrupt lines.
So the NAPI poll routine would have to service multiple Tx rings.

Signed-off-by: Claudiu Manoil 
---
 drivers/net/ethernet/freescale/gianfar.c | 170 ++-
 drivers/net/ethernet/freescale/gianfar.h |  17 ---
 2 files changed, 11 insertions(+), 176 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index 3ec4d9fddd52..4e4c62d4061e 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -175,10 +175,7 @@ static void gfar_mac_rx_config(struct gfar_private *priv)
if (priv->rx_filer_enable) {
rctrl |= RCTRL_FILREN | RCTRL_PRSDEP_INIT;
/* Program the RIR0 reg with the required distribution */
-   if (priv->poll_mode == GFAR_SQ_POLLING)
-   gfar_write(®s->rir0, DEFAULT_2RXQ_RIR0);
-   else /* GFAR_MQ_POLLING */
-   gfar_write(®s->rir0, DEFAULT_8RXQ_RIR0);
+   gfar_write(®s->rir0, DEFAULT_2RXQ_RIR0);
}
 
/* Restore PROMISC mode */
@@ -521,29 +518,9 @@ static int gfar_parse_group(struct device_node *np,
grp->priv = priv;
spin_lock_init(&grp->grplock);
if (priv->mode == MQ_MG_MODE) {
-   u32 rxq_mask, txq_mask;
-   int ret;
-
+   /* One Q per interrupt group: Q0 to G0, Q1 to G1 */
grp->rx_bit_map = (DEFAULT_MAPPING >> priv->num_grps);
grp->tx_bit_map = (DEFAULT_MAPPING >> priv->num_grps);
-
-   ret = of_property_read_u32(np, "fsl,rx-bit-map", &rxq_mask);
-   if (!ret) {
-   grp->rx_bit_map = rxq_mask ?
-   rxq_mask : (DEFAULT_MAPPING >> priv->num_grps);
-   }
-
-   ret = of_property_read_u32(np, "fsl,tx-bit-map", &txq_mask);
-   if (!ret) {
-   grp->tx_bit_map = txq_mask ?
-   txq_mask : (DEFAULT_MAPPING >> priv->num_grps);
-   }
-
-   if (priv->poll_mode == GFAR_SQ_POLLING) {
-   /* One Q per interrupt group: Q0 to G0, Q1 to G1 */
-   grp->rx_bit_map = (DEFAULT_MAPPING >> priv->num_grps);
-   grp->tx_bit_map = (DEFAULT_MAPPING >> priv->num_grps);
-   }
} else {
grp->rx_bit_map = 0xFF;
grp->tx_bit_map = 0xFF;
@@ -650,18 +627,15 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
u32 stash_len = 0;
u32 stash_idx = 0;
unsigned int num_tx_qs, num_rx_qs;
-   unsigned short mode, poll_mode;
+   unsigned short mode;
 
if (!np)
return -ENODEV;
 
-   if (of_device_is_compatible(np, "fsl,etsec2")) {
+   if (of_device_is_compatible(np, "fsl,etsec2"))
mode = MQ_MG_MODE;
-   poll_mode = GFAR_SQ_POLLING;
-   } else {
+   else
mode = SQ_SG_MODE;
-   poll_mode = GFAR_SQ_POLLING;
-   }
 
if (mode == SQ_SG_MODE) {
num_tx_qs = 1;
@@ -677,22 +651,8 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
return -EINVAL;
}
 
-   if (poll_mode == GFAR_SQ_POLLING) {
-   num_tx_qs = num_grps; /* one txq per int group */
-   num_rx_qs = num_grps; /* one rxq per int group */
-   } else { /* GFAR_MQ_POLLING */
-   u32 tx_queues, rx_queues;
-   int ret;
-
- 

[PATCH net-next 2/2] powerpc: dts: fsl: Drop obsolete fsl, rx-bit-map and fsl, tx-bit-map properties

2021-04-16 Thread Claudiu Manoil
These are very old properties that were used by the "gianfar" ethernet
driver.  They don't have documented bindings and are obsolete.

Signed-off-by: Claudiu Manoil 
---
 arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi |  4 
 arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi |  4 
 arch/powerpc/boot/dts/fsl/c293si-post.dtsi|  4 
 arch/powerpc/boot/dts/fsl/p1010si-post.dtsi   | 21 ---
 4 files changed, 33 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi
index 0c0efa94cfb4..2a677fd323eb 100644
--- a/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi
@@ -170,8 +170,6 @@ timer@41100 {
 /include/ "pq3-etsec2-0.dtsi"
 enet0: ethernet@b {
queue-group@b {
-   fsl,rx-bit-map = <0xff>;
-   fsl,tx-bit-map = <0xff>;
interrupts = <26 2 0 0 27 2 0 0 28 2 0 0>;
};
 };
@@ -179,8 +177,6 @@ queue-group@b {
 /include/ "pq3-etsec2-1.dtsi"
 enet1: ethernet@b1000 {
queue-group@b1000 {
-   fsl,rx-bit-map = <0xff>;
-   fsl,tx-bit-map = <0xff>;
interrupts = <33 2 0 0 34 2 0 0 35 2 0 0>;
};
 };
diff --git a/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi
index b5f071574e83..b8e0edd1ac69 100644
--- a/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi
@@ -190,8 +190,6 @@ sec_jr3: jr@4000 {
 /include/ "pq3-etsec2-0.dtsi"
 enet0: ethernet@b {
queue-group@b {
-   fsl,rx-bit-map = <0xff>;
-   fsl,tx-bit-map = <0xff>;
interrupts = <26 2 0 0 27 2 0 0 28 2 0 0>;
};
 };
@@ -199,8 +197,6 @@ queue-group@b {
 /include/ "pq3-etsec2-1.dtsi"
 enet1: ethernet@b1000 {
queue-group@b1000 {
-   fsl,rx-bit-map = <0xff>;
-   fsl,tx-bit-map = <0xff>;
interrupts = <33 2 0 0 34 2 0 0 35 2 0 0>;
};
 };
diff --git a/arch/powerpc/boot/dts/fsl/c293si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
index bd208320bff5..bec0fc36849d 100644
--- a/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
@@ -171,8 +171,6 @@ jr@2000{
enet0: ethernet@b {
queue-group@b {
reg = <0x1 0x1000>;
-   fsl,rx-bit-map = <0xff>;
-   fsl,tx-bit-map = <0xff>;
};
};
 
@@ -180,8 +178,6 @@ queue-group@b {
enet1: ethernet@b1000 {
queue-group@b1000 {
reg = <0x11000 0x1000>;
-   fsl,rx-bit-map = <0xff>;
-   fsl,tx-bit-map = <0xff>;
};
};
 
diff --git a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
index 1b4aafc1f6a2..c2717f31925a 100644
--- a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
@@ -172,29 +172,8 @@ sdhc@2e000 {
 /include/ "pq3-mpic-timer-B.dtsi"
 
 /include/ "pq3-etsec2-0.dtsi"
-   enet0: ethernet@b {
-   queue-group@b {
-   fsl,rx-bit-map = <0xff>;
-   fsl,tx-bit-map = <0xff>;
-   };
-   };
-
 /include/ "pq3-etsec2-1.dtsi"
-   enet1: ethernet@b1000 {
-   queue-group@b1000 {
-   fsl,rx-bit-map = <0xff>;
-   fsl,tx-bit-map = <0xff>;
-   };
-   };
-
 /include/ "pq3-etsec2-2.dtsi"
-   enet2: ethernet@b2000 {
-   queue-group@b2000 {
-   fsl,rx-bit-map = <0xff>;
-   fsl,tx-bit-map = <0xff>;
-   };
-
-   };
 
global-utilities@e {
compatible = "fsl,p1010-guts";
-- 
2.25.1



[PATCH 0/5] Freescale DPAA 1.x QBMan Drivers

2016-09-16 Thread Claudiu Manoil
Add basic support for the Data Path Acceleration Architecture v1.x
(DPAA 1.x) hardware infrastructure and accelerators found on multicore
Freescale SoCs, commonly known as the QorIQ series.

CC: Roy Pledge 

Claudiu Manoil (5):
  soc/fsl: Introduce DPAA 1.x BMan device driver
  soc/fsl: Introduce DPAA 1.x QMan device driver
  soc/bman: Add self-test for BMan driver
  soc/qman: Add self-test for QMan driver
  arch/powerpc: Add CONFIG_FSL_DPAA to corenetXX_smp_defconfig

 arch/powerpc/Makefile   |4 +-
 arch/powerpc/configs/dpaa.config|1 +
 drivers/soc/Kconfig |1 +
 drivers/soc/fsl/Makefile|1 +
 drivers/soc/fsl/qbman/Kconfig   |   67 +
 drivers/soc/fsl/qbman/Makefile  |   12 +
 drivers/soc/fsl/qbman/bman.c|  797 +
 drivers/soc/fsl/qbman/bman_ccsr.c   |  263 +++
 drivers/soc/fsl/qbman/bman_portal.c |  215 +++
 drivers/soc/fsl/qbman/bman_priv.h   |   80 +
 drivers/soc/fsl/qbman/bman_test.c   |   53 +
 drivers/soc/fsl/qbman/bman_test.h   |   35 +
 drivers/soc/fsl/qbman/bman_test_api.c   |  151 ++
 drivers/soc/fsl/qbman/dpaa_sys.h|  103 ++
 drivers/soc/fsl/qbman/qman.c| 2881 +++
 drivers/soc/fsl/qbman/qman_ccsr.c   |  817 +
 drivers/soc/fsl/qbman/qman_portal.c |  354 
 drivers/soc/fsl/qbman/qman_priv.h   |  370 
 drivers/soc/fsl/qbman/qman_test.c   |   62 +
 drivers/soc/fsl/qbman/qman_test.h   |   36 +
 drivers/soc/fsl/qbman/qman_test_api.c   |  252 +++
 drivers/soc/fsl/qbman/qman_test_stash.c |  617 +++
 include/soc/fsl/bman.h  |  129 ++
 include/soc/fsl/qman.h  | 1076 
 24 files changed, 8375 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/configs/dpaa.config
 create mode 100644 drivers/soc/fsl/qbman/Kconfig
 create mode 100644 drivers/soc/fsl/qbman/Makefile
 create mode 100644 drivers/soc/fsl/qbman/bman.c
 create mode 100644 drivers/soc/fsl/qbman/bman_ccsr.c
 create mode 100644 drivers/soc/fsl/qbman/bman_portal.c
 create mode 100644 drivers/soc/fsl/qbman/bman_priv.h
 create mode 100644 drivers/soc/fsl/qbman/bman_test.c
 create mode 100644 drivers/soc/fsl/qbman/bman_test.h
 create mode 100644 drivers/soc/fsl/qbman/bman_test_api.c
 create mode 100644 drivers/soc/fsl/qbman/dpaa_sys.h
 create mode 100644 drivers/soc/fsl/qbman/qman.c
 create mode 100644 drivers/soc/fsl/qbman/qman_ccsr.c
 create mode 100644 drivers/soc/fsl/qbman/qman_portal.c
 create mode 100644 drivers/soc/fsl/qbman/qman_priv.h
 create mode 100644 drivers/soc/fsl/qbman/qman_test.c
 create mode 100644 drivers/soc/fsl/qbman/qman_test.h
 create mode 100644 drivers/soc/fsl/qbman/qman_test_api.c
 create mode 100644 drivers/soc/fsl/qbman/qman_test_stash.c
 create mode 100644 include/soc/fsl/bman.h
 create mode 100644 include/soc/fsl/qman.h

-- 
1.7.11.7



[PATCH 1/5] soc/fsl: Introduce DPAA 1.x BMan device driver

2016-09-16 Thread Claudiu Manoil
This driver enables the Freescale DPAA 1.x Buffer Manager block.
BMan is a hardware accelerator that manages buffer pools.  It allows
CPUs and other accelerators connected to the SoC datapath to acquire
and release buffers during data processing.

Signed-off-by: Roy Pledge 
Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/Kconfig   |  24 ++
 drivers/soc/fsl/qbman/Makefile  |   2 +
 drivers/soc/fsl/qbman/bman.c| 797 
 drivers/soc/fsl/qbman/bman_ccsr.c   | 263 
 drivers/soc/fsl/qbman/bman_portal.c | 215 ++
 drivers/soc/fsl/qbman/bman_priv.h   |  80 
 drivers/soc/fsl/qbman/dpaa_sys.h| 103 +
 include/soc/fsl/bman.h  | 129 ++
 8 files changed, 1613 insertions(+)
 create mode 100644 drivers/soc/fsl/qbman/Kconfig
 create mode 100644 drivers/soc/fsl/qbman/Makefile
 create mode 100644 drivers/soc/fsl/qbman/bman.c
 create mode 100644 drivers/soc/fsl/qbman/bman_ccsr.c
 create mode 100644 drivers/soc/fsl/qbman/bman_portal.c
 create mode 100644 drivers/soc/fsl/qbman/bman_priv.h
 create mode 100644 drivers/soc/fsl/qbman/dpaa_sys.h
 create mode 100644 include/soc/fsl/bman.h

diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
new file mode 100644
index 000..88ce5c6
--- /dev/null
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -0,0 +1,24 @@
+menuconfig FSL_DPAA
+   bool "Freescale DPAA 1.x support"
+   depends on OF && PPC
+   select GENERIC_ALLOCATOR
+   help
+ The Freescale Data Path Acceleration Architecture (DPAA) is a set of
+ hardware components on specific QorIQ multicore processors.
+ This architecture provides the infrastructure to support simplified
+ sharing of networking interfaces and accelerators by multiple CPUs.
+ The major h/w blocks composing DPAA are BMan and QMan.
+
+ The Buffer Manager (BMan) is a hardware buffer pool management block
+ that allows software and accelerators on the datapath to acquire and
+ release buffers in order to build frames.
+
+if FSL_DPAA
+
+config FSL_DPAA_CHECKING
+   bool "Additional driver checking"
+   help
+ Compiles in additional checks, to sanity-check the drivers and
+ any use of the exported API. Not recommended for performance.
+
+endif # FSL_DPAA
diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile
new file mode 100644
index 000..855c3ac
--- /dev/null
+++ b/drivers/soc/fsl/qbman/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_FSL_DPAA)  += bman_ccsr.o bman_portal.o \
+  bman.o
diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c
new file mode 100644
index 000..ffa48fd
--- /dev/null
+++ b/drivers/soc/fsl/qbman/bman.c
@@ -0,0 +1,797 @@
+/* Copyright 2008 - 2016 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bman_priv.h"
+
+#define IRQNAME"BMan portal %d"
+#define MAX_IRQNAME16  /* big enough for "BMan portal %d" */
+
+/* Portal register assists */
+
+/* Cache-inhibited register offsets */

[PATCH 3/5] soc/bman: Add self-test for BMan driver

2016-09-16 Thread Claudiu Manoil
Add a self test for the DPAA 1.x Buffer Manager driver. This
test ensures that the driver can properly acquire and release
buffers using the BMan portal infrastructure.

Signed-off-by: Roy Pledge 
Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/Kconfig |  16 
 drivers/soc/fsl/qbman/Makefile|   4 +
 drivers/soc/fsl/qbman/bman_test.c |  53 
 drivers/soc/fsl/qbman/bman_test.h |  35 
 drivers/soc/fsl/qbman/bman_test_api.c | 151 ++
 5 files changed, 259 insertions(+)
 create mode 100644 drivers/soc/fsl/qbman/bman_test.c
 create mode 100644 drivers/soc/fsl/qbman/bman_test.h
 create mode 100644 drivers/soc/fsl/qbman/bman_test_api.c

diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
index 0abb9c8..5e4b288 100644
--- a/drivers/soc/fsl/qbman/Kconfig
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -25,4 +25,20 @@ config FSL_DPAA_CHECKING
  Compiles in additional checks, to sanity-check the drivers and
  any use of the exported API. Not recommended for performance.
 
+config FSL_BMAN_TEST
+   tristate "BMan self-tests"
+   help
+ Compile the BMan self-test code. These tests will
+ exercise the BMan APIs to confirm functionality
+ of both the software drivers and hardware device.
+
+config FSL_BMAN_TEST_API
+   bool "High-level API self-test"
+   depends on FSL_BMAN_TEST
+   default y
+   help
+ This requires the presence of cpu-affine portals, and performs
+ high-level API testing with them (whichever portal(s) are affine
+ to the cpu(s) the test executes on).
+
 endif # FSL_DPAA
diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile
index 6e0ee30..714dd97 100644
--- a/drivers/soc/fsl/qbman/Makefile
+++ b/drivers/soc/fsl/qbman/Makefile
@@ -1,3 +1,7 @@
 obj-$(CONFIG_FSL_DPAA)  += bman_ccsr.o qman_ccsr.o \
   bman_portal.o qman_portal.o \
   bman.o qman.o
+
+obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o
+bman-test-y  = bman_test.o
+bman-test-$(CONFIG_FSL_BMAN_TEST_API)   += bman_test_api.o
diff --git a/drivers/soc/fsl/qbman/bman_test.c 
b/drivers/soc/fsl/qbman/bman_test.c
new file mode 100644
index 000..09b1c96
--- /dev/null
+++ b/drivers/soc/fsl/qbman/bman_test.c
@@ -0,0 +1,53 @@
+/* Copyright 2008 - 2016 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bman_test.h"
+
+MODULE_AUTHOR("Geoff Thorpe");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("BMan testing");
+
+static int test_init(void)
+{
+#ifdef CONFIG_FSL_BMAN_TEST_API
+   int loop = 1;
+
+   while (loop--)
+   bman_test_api();
+#endif
+   return 0;
+}
+
+static void test_exit(void)
+{
+}
+
+module_init(test_init);
+module_exit(test_exit);
diff --git a/drivers/soc/fsl/qbman/bman_test.h 
b/drivers/soc/fsl/qbman/bman_test.h
new file mode 100644
index 000..037ed34
--- /dev/null
+++ b/drivers/soc/fsl/qbman/bma

[PATCH 4/5] soc/qman: Add self-test for QMan driver

2016-09-16 Thread Claudiu Manoil
Add self tests for the DPAA 1.x Queue Manager driver. The tests
ensure that the driver can properly enqueue and dequeue to/from
frame queues using the QMan portal infrastructure.

Signed-off-by: Roy Pledge 
Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/Kconfig   |  23 ++
 drivers/soc/fsl/qbman/Makefile  |   5 +
 drivers/soc/fsl/qbman/qman_test.c   |  62 
 drivers/soc/fsl/qbman/qman_test.h   |  36 ++
 drivers/soc/fsl/qbman/qman_test_api.c   | 252 +
 drivers/soc/fsl/qbman/qman_test_stash.c | 617 
 6 files changed, 995 insertions(+)
 create mode 100644 drivers/soc/fsl/qbman/qman_test.c
 create mode 100644 drivers/soc/fsl/qbman/qman_test.h
 create mode 100644 drivers/soc/fsl/qbman/qman_test_api.c
 create mode 100644 drivers/soc/fsl/qbman/qman_test_stash.c

diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
index 5e4b288..3fdf154 100644
--- a/drivers/soc/fsl/qbman/Kconfig
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -41,4 +41,27 @@ config FSL_BMAN_TEST_API
  high-level API testing with them (whichever portal(s) are affine
  to the cpu(s) the test executes on).
 
+config FSL_QMAN_TEST
+   tristate "QMan self-tests"
+   help
+ Compile self-test code for QMan.
+
+config FSL_QMAN_TEST_API
+   bool "QMan high-level self-test"
+   depends on FSL_QMAN_TEST
+   default y
+   help
+ This requires the presence of cpu-affine portals, and performs
+ high-level API testing with them (whichever portal(s) are affine to
+ the cpu(s) the test executes on).
+
+config FSL_QMAN_TEST_STASH
+   bool "QMan 'hot potato' data-stashing self-test"
+   depends on FSL_QMAN_TEST
+   default y
+   help
+ This performs a "hot potato" style test enqueuing/dequeuing a frame
+ across a series of FQs scheduled to different portals (and cpus), with
+ DQRR, data and context stashing always on.
+
 endif # FSL_DPAA
diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile
index 714dd97..7ae199f 100644
--- a/drivers/soc/fsl/qbman/Makefile
+++ b/drivers/soc/fsl/qbman/Makefile
@@ -5,3 +5,8 @@ obj-$(CONFIG_FSL_DPAA)  += bman_ccsr.o 
qman_ccsr.o \
 obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o
 bman-test-y  = bman_test.o
 bman-test-$(CONFIG_FSL_BMAN_TEST_API)   += bman_test_api.o
+
+obj-$(CONFIG_FSL_QMAN_TEST)+= qman-test.o
+qman-test-y = qman_test.o
+qman-test-$(CONFIG_FSL_QMAN_TEST_API)  += qman_test_api.o
+qman-test-$(CONFIG_FSL_QMAN_TEST_STASH)+= qman_test_stash.o
diff --git a/drivers/soc/fsl/qbman/qman_test.c 
b/drivers/soc/fsl/qbman/qman_test.c
new file mode 100644
index 000..18f7f02
--- /dev/null
+++ b/drivers/soc/fsl/qbman/qman_test.c
@@ -0,0 +1,62 @@
+/* Copyright 2008 - 2016 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "qman_test.h"
+
+MODULE_AUTHOR("Geoff Thorpe");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DES

[PATCH 5/5] arch/powerpc: Add CONFIG_FSL_DPAA to corenetXX_smp_defconfig

2016-09-16 Thread Claudiu Manoil
Enable the drivers on the powerpc arch.

Signed-off-by: Roy Pledge 
Signed-off-by: Claudiu Manoil 
---
 arch/powerpc/Makefile| 4 ++--
 arch/powerpc/configs/dpaa.config | 1 +
 drivers/soc/Kconfig  | 1 +
 drivers/soc/fsl/Makefile | 1 +
 4 files changed, 5 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/configs/dpaa.config

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 1934707..f36347c 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -325,12 +325,12 @@ mpc85xx_smp_defconfig:
 PHONY += corenet32_smp_defconfig
 corenet32_smp_defconfig:
$(call merge_into_defconfig,corenet_basic_defconfig,\
-   85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
+   85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
 
 PHONY += corenet64_smp_defconfig
 corenet64_smp_defconfig:
$(call merge_into_defconfig,corenet_basic_defconfig,\
-   85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw)
+   85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
 
 PHONY += mpc86xx_defconfig
 mpc86xx_defconfig:
diff --git a/arch/powerpc/configs/dpaa.config b/arch/powerpc/configs/dpaa.config
new file mode 100644
index 000..efa99c0
--- /dev/null
+++ b/arch/powerpc/configs/dpaa.config
@@ -0,0 +1 @@
+CONFIG_FSL_DPAA=y
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index fe42a2f..e6e90e8 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,6 +1,7 @@
 menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/bcm/Kconfig"
+source "drivers/soc/fsl/qbman/Kconfig"
 source "drivers/soc/fsl/qe/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 203307f..75e1f53 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -2,5 +2,6 @@
 # Makefile for the Linux Kernel SOC fsl specific device drivers
 #
 
+obj-$(CONFIG_FSL_DPAA) += qbman/
 obj-$(CONFIG_QUICC_ENGINE) += qe/
 obj-$(CONFIG_CPM)  += qe/
-- 
1.7.11.7



[PATCH v2 0/5] Freescale DPAA 1.x QBMan Drivers

2016-09-22 Thread Claudiu Manoil
Add basic support for the Data Path Acceleration Architecture v1.x
(DPAA 1.x) hardware infrastructure and accelerators found on multicore
Freescale SoCs, commonly known as the QorIQ series.

CC: Roy Pledge 

Claudiu Manoil (5):
  soc/fsl: Introduce DPAA 1.x BMan device driver
  soc/fsl: Introduce DPAA 1.x QMan device driver
  soc/bman: Add self-test for BMan driver
  soc/qman: Add self-test for QMan driver
  arch/powerpc: Add CONFIG_FSL_DPAA to corenetXX_smp_defconfig

 arch/powerpc/Makefile   |4 +-
 arch/powerpc/configs/dpaa.config|1 +
 drivers/soc/Kconfig |1 +
 drivers/soc/fsl/Makefile|1 +
 drivers/soc/fsl/qbman/Kconfig   |   67 +
 drivers/soc/fsl/qbman/Makefile  |   12 +
 drivers/soc/fsl/qbman/bman.c|  797 +
 drivers/soc/fsl/qbman/bman_ccsr.c   |  263 +++
 drivers/soc/fsl/qbman/bman_portal.c |  219 +++
 drivers/soc/fsl/qbman/bman_priv.h   |   80 +
 drivers/soc/fsl/qbman/bman_test.c   |   53 +
 drivers/soc/fsl/qbman/bman_test.h   |   35 +
 drivers/soc/fsl/qbman/bman_test_api.c   |  151 ++
 drivers/soc/fsl/qbman/dpaa_sys.h|  103 ++
 drivers/soc/fsl/qbman/qman.c| 2881 +++
 drivers/soc/fsl/qbman/qman_ccsr.c   |  808 +
 drivers/soc/fsl/qbman/qman_portal.c |  355 
 drivers/soc/fsl/qbman/qman_priv.h   |  371 
 drivers/soc/fsl/qbman/qman_test.c   |   62 +
 drivers/soc/fsl/qbman/qman_test.h   |   36 +
 drivers/soc/fsl/qbman/qman_test_api.c   |  252 +++
 drivers/soc/fsl/qbman/qman_test_stash.c |  617 +++
 include/soc/fsl/bman.h  |  129 ++
 include/soc/fsl/qman.h  | 1074 
 24 files changed, 8370 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/configs/dpaa.config
 create mode 100644 drivers/soc/fsl/qbman/Kconfig
 create mode 100644 drivers/soc/fsl/qbman/Makefile
 create mode 100644 drivers/soc/fsl/qbman/bman.c
 create mode 100644 drivers/soc/fsl/qbman/bman_ccsr.c
 create mode 100644 drivers/soc/fsl/qbman/bman_portal.c
 create mode 100644 drivers/soc/fsl/qbman/bman_priv.h
 create mode 100644 drivers/soc/fsl/qbman/bman_test.c
 create mode 100644 drivers/soc/fsl/qbman/bman_test.h
 create mode 100644 drivers/soc/fsl/qbman/bman_test_api.c
 create mode 100644 drivers/soc/fsl/qbman/dpaa_sys.h
 create mode 100644 drivers/soc/fsl/qbman/qman.c
 create mode 100644 drivers/soc/fsl/qbman/qman_ccsr.c
 create mode 100644 drivers/soc/fsl/qbman/qman_portal.c
 create mode 100644 drivers/soc/fsl/qbman/qman_priv.h
 create mode 100644 drivers/soc/fsl/qbman/qman_test.c
 create mode 100644 drivers/soc/fsl/qbman/qman_test.h
 create mode 100644 drivers/soc/fsl/qbman/qman_test_api.c
 create mode 100644 drivers/soc/fsl/qbman/qman_test_stash.c
 create mode 100644 include/soc/fsl/bman.h
 create mode 100644 include/soc/fsl/qman.h

-- 
1.7.11.7



[PATCH v2 1/5] soc/fsl: Introduce DPAA 1.x BMan device driver

2016-09-22 Thread Claudiu Manoil
This driver enables the Freescale DPAA 1.x Buffer Manager block.
BMan is a hardware accelerator that manages buffer pools.  It allows
CPUs and other accelerators connected to the SoC datapath to acquire
and release buffers during data processing.

Signed-off-by: Roy Pledge 
Signed-off-by: Claudiu Manoil 
---
v2:
* FSL_DPAA depends on FSL_SOC_BOOKE (fixes allyesconfig build)
* further code cleanup and improvements around portal probing

 drivers/soc/fsl/qbman/Kconfig   |  28 ++
 drivers/soc/fsl/qbman/Makefile  |   2 +
 drivers/soc/fsl/qbman/bman.c| 797 
 drivers/soc/fsl/qbman/bman_ccsr.c   | 263 
 drivers/soc/fsl/qbman/bman_portal.c | 219 ++
 drivers/soc/fsl/qbman/bman_priv.h   |  80 
 drivers/soc/fsl/qbman/dpaa_sys.h| 103 +
 include/soc/fsl/bman.h  | 129 ++
 8 files changed, 1621 insertions(+)
 create mode 100644 drivers/soc/fsl/qbman/Kconfig
 create mode 100644 drivers/soc/fsl/qbman/Makefile
 create mode 100644 drivers/soc/fsl/qbman/bman.c
 create mode 100644 drivers/soc/fsl/qbman/bman_ccsr.c
 create mode 100644 drivers/soc/fsl/qbman/bman_portal.c
 create mode 100644 drivers/soc/fsl/qbman/bman_priv.h
 create mode 100644 drivers/soc/fsl/qbman/dpaa_sys.h
 create mode 100644 include/soc/fsl/bman.h

diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
new file mode 100644
index 000..8f2df64
--- /dev/null
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -0,0 +1,28 @@
+menuconfig FSL_DPAA
+   bool "Freescale DPAA 1.x support"
+   depends on FSL_SOC_BOOKE
+   select GENERIC_ALLOCATOR
+   help
+ The Freescale Data Path Acceleration Architecture (DPAA) is a set of
+ hardware components on specific QorIQ multicore processors.
+ This architecture provides the infrastructure to support simplified
+ sharing of networking interfaces and accelerators by multiple CPUs.
+ The major h/w blocks composing DPAA are BMan and QMan.
+
+ The Buffer Manager (BMan) is a hardware buffer pool management block
+ that allows software and accelerators on the datapath to acquire and
+ release buffers in order to build frames.
+
+ The Queue Manager (QMan) is a hardware queue management block
+ that allows software and accelerators on the datapath to enqueue and
+ dequeue frames in order to communicate.
+
+if FSL_DPAA
+
+config FSL_DPAA_CHECKING
+   bool "Additional driver checking"
+   help
+ Compiles in additional checks, to sanity-check the drivers and
+ any use of the exported API. Not recommended for performance.
+
+endif # FSL_DPAA
diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile
new file mode 100644
index 000..855c3ac
--- /dev/null
+++ b/drivers/soc/fsl/qbman/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_FSL_DPAA)  += bman_ccsr.o bman_portal.o \
+  bman.o
diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c
new file mode 100644
index 000..ffa48fd
--- /dev/null
+++ b/drivers/soc/fsl/qbman/bman.c
@@ -0,0 +1,797 @@
+/* Copyright 2008 - 2016 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
T

[PATCH v2 4/5] soc/qman: Add self-test for QMan driver

2016-09-22 Thread Claudiu Manoil
Add self tests for the DPAA 1.x Queue Manager driver. The tests
ensure that the driver can properly enqueue and dequeue to/from
frame queues using the QMan portal infrastructure.

Signed-off-by: Roy Pledge 
Signed-off-by: Claudiu Manoil 
---
v2: none

 drivers/soc/fsl/qbman/Kconfig   |  23 ++
 drivers/soc/fsl/qbman/Makefile  |   5 +
 drivers/soc/fsl/qbman/qman_test.c   |  62 
 drivers/soc/fsl/qbman/qman_test.h   |  36 ++
 drivers/soc/fsl/qbman/qman_test_api.c   | 252 +
 drivers/soc/fsl/qbman/qman_test_stash.c | 617 
 6 files changed, 995 insertions(+)
 create mode 100644 drivers/soc/fsl/qbman/qman_test.c
 create mode 100644 drivers/soc/fsl/qbman/qman_test.h
 create mode 100644 drivers/soc/fsl/qbman/qman_test_api.c
 create mode 100644 drivers/soc/fsl/qbman/qman_test_stash.c

diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
index e6da6a2..757033c 100644
--- a/drivers/soc/fsl/qbman/Kconfig
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -41,4 +41,27 @@ config FSL_BMAN_TEST_API
  high-level API testing with them (whichever portal(s) are affine
  to the cpu(s) the test executes on).
 
+config FSL_QMAN_TEST
+   tristate "QMan self-tests"
+   help
+ Compile self-test code for QMan.
+
+config FSL_QMAN_TEST_API
+   bool "QMan high-level self-test"
+   depends on FSL_QMAN_TEST
+   default y
+   help
+ This requires the presence of cpu-affine portals, and performs
+ high-level API testing with them (whichever portal(s) are affine to
+ the cpu(s) the test executes on).
+
+config FSL_QMAN_TEST_STASH
+   bool "QMan 'hot potato' data-stashing self-test"
+   depends on FSL_QMAN_TEST
+   default y
+   help
+ This performs a "hot potato" style test enqueuing/dequeuing a frame
+ across a series of FQs scheduled to different portals (and cpus), with
+ DQRR, data and context stashing always on.
+
 endif # FSL_DPAA
diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile
index 714dd97..7ae199f 100644
--- a/drivers/soc/fsl/qbman/Makefile
+++ b/drivers/soc/fsl/qbman/Makefile
@@ -5,3 +5,8 @@ obj-$(CONFIG_FSL_DPAA)  += bman_ccsr.o 
qman_ccsr.o \
 obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o
 bman-test-y  = bman_test.o
 bman-test-$(CONFIG_FSL_BMAN_TEST_API)   += bman_test_api.o
+
+obj-$(CONFIG_FSL_QMAN_TEST)+= qman-test.o
+qman-test-y = qman_test.o
+qman-test-$(CONFIG_FSL_QMAN_TEST_API)  += qman_test_api.o
+qman-test-$(CONFIG_FSL_QMAN_TEST_STASH)+= qman_test_stash.o
diff --git a/drivers/soc/fsl/qbman/qman_test.c 
b/drivers/soc/fsl/qbman/qman_test.c
new file mode 100644
index 000..18f7f02
--- /dev/null
+++ b/drivers/soc/fsl/qbman/qman_test.c
@@ -0,0 +1,62 @@
+/* Copyright 2008 - 2016 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "qman_test.h"
+
+MODULE_AUTHOR("Geoff Thorpe");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE

[PATCH v2 5/5] arch/powerpc: Add CONFIG_FSL_DPAA to corenetXX_smp_defconfig

2016-09-22 Thread Claudiu Manoil
Enable the drivers on the powerpc arch.

Signed-off-by: Roy Pledge 
Signed-off-by: Claudiu Manoil 
---
v2: none

 arch/powerpc/Makefile| 4 ++--
 arch/powerpc/configs/dpaa.config | 1 +
 drivers/soc/Kconfig  | 1 +
 drivers/soc/fsl/Makefile | 1 +
 4 files changed, 5 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/configs/dpaa.config

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 1934707..f36347c 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -325,12 +325,12 @@ mpc85xx_smp_defconfig:
 PHONY += corenet32_smp_defconfig
 corenet32_smp_defconfig:
$(call merge_into_defconfig,corenet_basic_defconfig,\
-   85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
+   85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
 
 PHONY += corenet64_smp_defconfig
 corenet64_smp_defconfig:
$(call merge_into_defconfig,corenet_basic_defconfig,\
-   85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw)
+   85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
 
 PHONY += mpc86xx_defconfig
 mpc86xx_defconfig:
diff --git a/arch/powerpc/configs/dpaa.config b/arch/powerpc/configs/dpaa.config
new file mode 100644
index 000..efa99c0
--- /dev/null
+++ b/arch/powerpc/configs/dpaa.config
@@ -0,0 +1 @@
+CONFIG_FSL_DPAA=y
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index fe42a2f..e6e90e8 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,6 +1,7 @@
 menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/bcm/Kconfig"
+source "drivers/soc/fsl/qbman/Kconfig"
 source "drivers/soc/fsl/qe/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 203307f..75e1f53 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -2,5 +2,6 @@
 # Makefile for the Linux Kernel SOC fsl specific device drivers
 #
 
+obj-$(CONFIG_FSL_DPAA) += qbman/
 obj-$(CONFIG_QUICC_ENGINE) += qe/
 obj-$(CONFIG_CPM)  += qe/
-- 
1.7.11.7



[PATCH v2 3/5] soc/bman: Add self-test for BMan driver

2016-09-22 Thread Claudiu Manoil
Add a self test for the DPAA 1.x Buffer Manager driver. This
test ensures that the driver can properly acquire and release
buffers using the BMan portal infrastructure.

Signed-off-by: Roy Pledge 
Signed-off-by: Claudiu Manoil 
---
v2: none

 drivers/soc/fsl/qbman/Kconfig |  16 
 drivers/soc/fsl/qbman/Makefile|   4 +
 drivers/soc/fsl/qbman/bman_test.c |  53 
 drivers/soc/fsl/qbman/bman_test.h |  35 
 drivers/soc/fsl/qbman/bman_test_api.c | 151 ++
 5 files changed, 259 insertions(+)
 create mode 100644 drivers/soc/fsl/qbman/bman_test.c
 create mode 100644 drivers/soc/fsl/qbman/bman_test.h
 create mode 100644 drivers/soc/fsl/qbman/bman_test_api.c

diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
index 8f2df64..e6da6a2 100644
--- a/drivers/soc/fsl/qbman/Kconfig
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -25,4 +25,20 @@ config FSL_DPAA_CHECKING
  Compiles in additional checks, to sanity-check the drivers and
  any use of the exported API. Not recommended for performance.
 
+config FSL_BMAN_TEST
+   tristate "BMan self-tests"
+   help
+ Compile the BMan self-test code. These tests will
+ exercise the BMan APIs to confirm functionality
+ of both the software drivers and hardware device.
+
+config FSL_BMAN_TEST_API
+   bool "High-level API self-test"
+   depends on FSL_BMAN_TEST
+   default y
+   help
+ This requires the presence of cpu-affine portals, and performs
+ high-level API testing with them (whichever portal(s) are affine
+ to the cpu(s) the test executes on).
+
 endif # FSL_DPAA
diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile
index 6e0ee30..714dd97 100644
--- a/drivers/soc/fsl/qbman/Makefile
+++ b/drivers/soc/fsl/qbman/Makefile
@@ -1,3 +1,7 @@
 obj-$(CONFIG_FSL_DPAA)  += bman_ccsr.o qman_ccsr.o \
   bman_portal.o qman_portal.o \
   bman.o qman.o
+
+obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o
+bman-test-y  = bman_test.o
+bman-test-$(CONFIG_FSL_BMAN_TEST_API)   += bman_test_api.o
diff --git a/drivers/soc/fsl/qbman/bman_test.c 
b/drivers/soc/fsl/qbman/bman_test.c
new file mode 100644
index 000..09b1c96
--- /dev/null
+++ b/drivers/soc/fsl/qbman/bman_test.c
@@ -0,0 +1,53 @@
+/* Copyright 2008 - 2016 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bman_test.h"
+
+MODULE_AUTHOR("Geoff Thorpe");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("BMan testing");
+
+static int test_init(void)
+{
+#ifdef CONFIG_FSL_BMAN_TEST_API
+   int loop = 1;
+
+   while (loop--)
+   bman_test_api();
+#endif
+   return 0;
+}
+
+static void test_exit(void)
+{
+}
+
+module_init(test_init);
+module_exit(test_exit);
diff --git a/drivers/soc/fsl/qbman/bman_test.h 
b/drivers/soc/fsl/qbman/bman_test.h
new file mode 100644
index 000..037ed34
--- /dev/null
+++ b/drivers/soc/fsl/qbman/bma

[PATCH 00/17] soc/qman: Fixes, endianness handling and related cleanup

2016-11-16 Thread Claudiu Manoil
* endianness fixes to ensure correct handling on little endian CPUs,
  as the qman h/w is big endian;
* removal of a platform device hack that may fail, used for dma mapping;
* various fixes and code cleanup;


Claudiu Manoil (15):
  soc/qman: Fix h/w resource cleanup error path handling
  soc/qbman: Fix resource leak on portal probing error path
  soc/qman: Fix struct qm_fqd set accessor for context_a
  soc/qman: Fix direct access to fd's addr_lo, use proper accesor
  soc/qman: test: Fix implementation of fd_cmp()
  soc/qman: Don't add a new platform device for dma mapping
  soc/qman: test: Don't use dummy platform device for dma mapping
  soc/qman: Remove redundant checks from qman_create_cgr()
  soc/qman: Remove unused struct qm_mcc* layouts
  soc/qman: Fix accesses to fqid, cleanup
  soc/qman: Drop unused field from eqcr/dqrr descriptors
  soc/qbman: Handle endianness of qm/bm_in/out()
  soc/qman: Change remaining contextB into context_b
  soc/qman: Clean up CGR CSCN target update operations
  soc/qman: Handle endianness of h/w descriptors

Madalin Bucur (2):
  soc/qman: Check ioremap return value
  soc/qman: Replace of_get_property() with portable equivalent

 drivers/soc/fsl/qbman/bman.c|   6 +-
 drivers/soc/fsl/qbman/bman_portal.c |  17 ++-
 drivers/soc/fsl/qbman/dpaa_sys.h|   1 +
 drivers/soc/fsl/qbman/qman.c| 231 +++-
 drivers/soc/fsl/qbman/qman_ccsr.c   |   3 +
 drivers/soc/fsl/qbman/qman_portal.c |  41 --
 drivers/soc/fsl/qbman/qman_priv.h   |  17 +--
 drivers/soc/fsl/qbman/qman_test_api.c   |  27 ++--
 drivers/soc/fsl/qbman/qman_test_stash.c |  36 +++--
 include/soc/fsl/qman.h  |  62 +
 10 files changed, 231 insertions(+), 210 deletions(-)

-- 
1.7.11.7



[PATCH 01/17] soc/qman: Check ioremap return value

2016-11-16 Thread Claudiu Manoil
From: Madalin Bucur 

Signed-off-by: Madalin Bucur 
Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman_ccsr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c 
b/drivers/soc/fsl/qbman/qman_ccsr.c
index 0cace9e..f4e6e70 100644
--- a/drivers/soc/fsl/qbman/qman_ccsr.c
+++ b/drivers/soc/fsl/qbman/qman_ccsr.c
@@ -444,6 +444,9 @@ static int zero_priv_mem(struct device *dev, struct 
device_node *node,
/* map as cacheable, non-guarded */
void __iomem *tmpp = ioremap_prot(addr, sz, 0);
 
+   if (!tmpp)
+   return -ENOMEM;
+
memset_io(tmpp, 0, sz);
flush_dcache_range((unsigned long)tmpp,
   (unsigned long)tmpp + sz);
-- 
1.7.11.7



[PATCH 02/17] soc/qman: Replace of_get_property() with portable equivalent

2016-11-16 Thread Claudiu Manoil
From: Madalin Bucur 

Use arch portable of_property_read_u32() instead, which takes
care of endianness conversions.

Signed-off-by: Madalin Bucur 
Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/dpaa_sys.h|  1 +
 drivers/soc/fsl/qbman/qman_portal.c | 12 ++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/soc/fsl/qbman/dpaa_sys.h b/drivers/soc/fsl/qbman/dpaa_sys.h
index b63fd72..2eaf318 100644
--- a/drivers/soc/fsl/qbman/dpaa_sys.h
+++ b/drivers/soc/fsl/qbman/dpaa_sys.h
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/soc/fsl/qbman/qman_portal.c 
b/drivers/soc/fsl/qbman/qman_portal.c
index 1486143..0c3e8ad 100644
--- a/drivers/soc/fsl/qbman/qman_portal.c
+++ b/drivers/soc/fsl/qbman/qman_portal.c
@@ -238,9 +238,9 @@ static int qman_portal_probe(struct platform_device *pdev)
struct device_node *node = dev->of_node;
struct qm_portal_config *pcfg;
struct resource *addr_phys[2];
-   const u32 *channel;
void __iomem *va;
-   int irq, len, cpu;
+   int irq, cpu, err;
+   u32 val;
 
pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL);
if (!pcfg)
@@ -264,13 +264,13 @@ static int qman_portal_probe(struct platform_device *pdev)
return -ENXIO;
}
 
-   channel = of_get_property(node, "cell-index", &len);
-   if (!channel || (len != 4)) {
+   err = of_property_read_u32(node, "cell-index", &val);
+   if (err) {
dev_err(dev, "Can't get %s property 'cell-index'\n",
node->full_name);
-   return -ENXIO;
+   return err;
}
-   pcfg->channel = *channel;
+   pcfg->channel = val;
pcfg->cpu = -1;
irq = platform_get_irq(pdev, 0);
if (irq <= 0) {
-- 
1.7.11.7



[PATCH 03/17] soc/qman: Fix h/w resource cleanup error path handling

2016-11-16 Thread Claudiu Manoil
qman_query_fq*() may return other error codes apart from
-ERANGE, in which cases the error handling done by the
resource cleanup callers would be wrong.  The patch
fixes the handling of those cases, and cleans up related
code inside the resource cleanup & release handlers (i.e.
replace hardcoded fqid value with corresponding define).

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 119054b..80ff0b7 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2789,15 +2789,18 @@ static int qpool_cleanup(u32 qp)
struct qm_mcr_queryfq_np np;
 
err = qman_query_fq_np(&fq, &np);
-   if (err)
+   if (err == -ERANGE)
/* FQID range exceeded, found no problems */
return 0;
+   else if (WARN_ON(err))
+   return err;
+
if ((np.state & QM_MCR_NP_STATE_MASK) != QM_MCR_NP_STATE_OOS) {
struct qm_fqd fqd;
 
err = qman_query_fq(&fq, &fqd);
if (WARN_ON(err))
-   return 0;
+   return err;
if (qm_fqd_get_chan(&fqd) == qp) {
/* The channel is the FQ's target, clean it */
err = qman_shutdown_fq(fq.fqid);
@@ -2836,7 +2839,7 @@ static int cgr_cleanup(u32 cgrid)
 * error, looking for non-OOS FQDs whose CGR is the CGR being released
 */
struct qman_fq fq = {
-   .fqid = 1
+   .fqid = QM_FQID_RANGE_START
};
int err;
 
@@ -2844,15 +2847,18 @@ static int cgr_cleanup(u32 cgrid)
struct qm_mcr_queryfq_np np;
 
err = qman_query_fq_np(&fq, &np);
-   if (err)
+   if (err == -ERANGE)
/* FQID range exceeded, found no problems */
return 0;
+   else if (WARN_ON(err))
+   return err;
+
if ((np.state & QM_MCR_NP_STATE_MASK) != QM_MCR_NP_STATE_OOS) {
struct qm_fqd fqd;
 
err = qman_query_fq(&fq, &fqd);
if (WARN_ON(err))
-   return 0;
+   return err;
if ((fqd.fq_ctrl & QM_FQCTRL_CGE) &&
fqd.cgid == cgrid) {
pr_err("CRGID 0x%x is being used by FQID 0x%x, 
CGR will be leaked\n",
-- 
1.7.11.7



[PATCH 05/17] soc/qman: Fix struct qm_fqd set accessor for context_a

2016-11-16 Thread Claudiu Manoil
context_a.hi is 32bit

Signed-off-by: Claudiu Manoil 
---
 include/soc/fsl/qman.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index 37f3eb0..1405810 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -411,7 +411,7 @@ static inline void qm_fqd_stashing_set64(struct qm_fqd 
*fqd, u64 addr)
 
 static inline void qm_fqd_context_a_set64(struct qm_fqd *fqd, u64 addr)
 {
-   fqd->context_a.hi = cpu_to_be16(upper_32_bits(addr));
+   fqd->context_a.hi = cpu_to_be32(upper_32_bits(addr));
fqd->context_a.lo = cpu_to_be32(lower_32_bits(addr));
 }
 
-- 
1.7.11.7



[PATCH 07/17] soc/qman: test: Fix implementation of fd_cmp()

2016-11-16 Thread Claudiu Manoil
This function must only return the truth value of whether
two frame descriptors are different or not.
It does NOT have to compute some obscure difference between
fd fields and return it as an int, making sparse complain
about type conversions in the process.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman_test_api.c | 23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman_test_api.c 
b/drivers/soc/fsl/qbman/qman_test_api.c
index 6880ff1..dba6a80 100644
--- a/drivers/soc/fsl/qbman/qman_test_api.c
+++ b/drivers/soc/fsl/qbman/qman_test_api.c
@@ -90,22 +90,15 @@ static void fd_inc(struct qm_fd *fd)
 }
 
 /* The only part of the 'fd' we can't memcmp() is the ppid */
-static int fd_cmp(const struct qm_fd *a, const struct qm_fd *b)
+static bool fd_neq(const struct qm_fd *a, const struct qm_fd *b)
 {
-   int r = (qm_fd_addr_get64(a) == qm_fd_addr_get64(b)) ? 0 : -1;
+   bool neq = qm_fd_addr_get64(a) != qm_fd_addr_get64(b);
 
-   if (!r) {
-   enum qm_fd_format fmt_a, fmt_b;
+   neq |= qm_fd_get_format(a) != qm_fd_get_format(b);
+   neq |= a->cfg != b->cfg;
+   neq |= a->cmd != b->cmd;
 
-   fmt_a = qm_fd_get_format(a);
-   fmt_b = qm_fd_get_format(b);
-   r = fmt_a - fmt_b;
-   }
-   if (!r)
-   r = a->cfg - b->cfg;
-   if (!r)
-   r = a->cmd - b->cmd;
-   return r;
+   return neq;
 }
 
 /* test */
@@ -217,12 +210,12 @@ static enum qman_cb_dqrr_result cb_dqrr(struct 
qman_portal *p,
struct qman_fq *fq,
const struct qm_dqrr_entry *dq)
 {
-   if (WARN_ON(fd_cmp(&fd_dq, &dq->fd))) {
+   if (WARN_ON(fd_neq(&fd_dq, &dq->fd))) {
pr_err("BADNESS: dequeued frame doesn't match;\n");
return qman_cb_dqrr_consume;
}
fd_inc(&fd_dq);
-   if (!(dq->stat & QM_DQRR_STAT_UNSCHEDULED) && !fd_cmp(&fd_dq, &fd)) {
+   if (!(dq->stat & QM_DQRR_STAT_UNSCHEDULED) && !fd_neq(&fd_dq, &fd)) {
sdqcr_complete = 1;
wake_up(&waitqueue);
}
-- 
1.7.11.7



[PATCH 04/17] soc/qbman: Fix resource leak on portal probing error path

2016-11-16 Thread Claudiu Manoil
In case init_pcfg() returns with error the CI region
must be unmapped too.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/bman_portal.c | 17 -
 drivers/soc/fsl/qbman/qman_portal.c | 17 -
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/soc/fsl/qbman/bman_portal.c 
b/drivers/soc/fsl/qbman/bman_portal.c
index 6579cc1..dd3f5d7 100644
--- a/drivers/soc/fsl/qbman/bman_portal.c
+++ b/drivers/soc/fsl/qbman/bman_portal.c
@@ -146,15 +146,19 @@ static int bman_portal_probe(struct platform_device *pdev)
pcfg->irq = irq;
 
va = ioremap_prot(addr_phys[0]->start, resource_size(addr_phys[0]), 0);
-   if (!va)
+   if (!va) {
+   dev_err(dev, "ioremap::CE failed\n");
goto err_ioremap1;
+   }
 
pcfg->addr_virt[DPAA_PORTAL_CE] = va;
 
va = ioremap_prot(addr_phys[1]->start, resource_size(addr_phys[1]),
  _PAGE_GUARDED | _PAGE_NO_CACHE);
-   if (!va)
+   if (!va) {
+   dev_err(dev, "ioremap::CI failed\n");
goto err_ioremap2;
+   }
 
pcfg->addr_virt[DPAA_PORTAL_CI] = va;
 
@@ -170,8 +174,10 @@ static int bman_portal_probe(struct platform_device *pdev)
spin_unlock(&bman_lock);
pcfg->cpu = cpu;
 
-   if (!init_pcfg(pcfg))
-   goto err_ioremap2;
+   if (!init_pcfg(pcfg)) {
+   dev_err(dev, "portal init failed\n");
+   goto err_portal_init;
+   }
 
/* clear irq affinity if assigned cpu is offline */
if (!cpu_online(cpu))
@@ -179,10 +185,11 @@ static int bman_portal_probe(struct platform_device *pdev)
 
return 0;
 
+err_portal_init:
+   iounmap(pcfg->addr_virt[DPAA_PORTAL_CI]);
 err_ioremap2:
iounmap(pcfg->addr_virt[DPAA_PORTAL_CE]);
 err_ioremap1:
-   dev_err(dev, "ioremap failed\n");
return -ENXIO;
 }
 
diff --git a/drivers/soc/fsl/qbman/qman_portal.c 
b/drivers/soc/fsl/qbman/qman_portal.c
index 0c3e8ad..6651168 100644
--- a/drivers/soc/fsl/qbman/qman_portal.c
+++ b/drivers/soc/fsl/qbman/qman_portal.c
@@ -280,15 +280,19 @@ static int qman_portal_probe(struct platform_device *pdev)
pcfg->irq = irq;
 
va = ioremap_prot(addr_phys[0]->start, resource_size(addr_phys[0]), 0);
-   if (!va)
+   if (!va) {
+   dev_err(dev, "ioremap::CE failed\n");
goto err_ioremap1;
+   }
 
pcfg->addr_virt[DPAA_PORTAL_CE] = va;
 
va = ioremap_prot(addr_phys[1]->start, resource_size(addr_phys[1]),
  _PAGE_GUARDED | _PAGE_NO_CACHE);
-   if (!va)
+   if (!va) {
+   dev_err(dev, "ioremap::CI failed\n");
goto err_ioremap2;
+   }
 
pcfg->addr_virt[DPAA_PORTAL_CI] = va;
 
@@ -306,8 +310,10 @@ static int qman_portal_probe(struct platform_device *pdev)
spin_unlock(&qman_lock);
pcfg->cpu = cpu;
 
-   if (!init_pcfg(pcfg))
-   goto err_ioremap2;
+   if (!init_pcfg(pcfg)) {
+   dev_err(dev, "portal init failed\n");
+   goto err_portal_init;
+   }
 
/* clear irq affinity if assigned cpu is offline */
if (!cpu_online(cpu))
@@ -315,10 +321,11 @@ static int qman_portal_probe(struct platform_device *pdev)
 
return 0;
 
+err_portal_init:
+   iounmap(pcfg->addr_virt[DPAA_PORTAL_CI]);
 err_ioremap2:
iounmap(pcfg->addr_virt[DPAA_PORTAL_CE]);
 err_ioremap1:
-   dev_err(dev, "ioremap failed\n");
return -ENXIO;
 }
 
-- 
1.7.11.7



[PATCH 09/17] soc/qman: test: Don't use dummy platform device for dma mapping

2016-11-16 Thread Claudiu Manoil
Replace dummy platform device hack with a reference to a portal's
platform device, in order to dma map the test frame for this
small unit test.  The 2 qman symbols need to be exported because
this self test is a kernel module.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c|  1 +
 drivers/soc/fsl/qbman/qman_portal.c |  1 +
 drivers/soc/fsl/qbman/qman_test_stash.c | 31 ---
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index a0020d2..283c2d3 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2711,6 +2711,7 @@ const struct qm_portal_config *qman_get_qm_portal_config(
 {
return portal->config;
 }
+EXPORT_SYMBOL(qman_get_qm_portal_config);
 
 struct gen_pool *qm_fqalloc; /* FQID allocator */
 struct gen_pool *qm_qpalloc; /* pool-channel allocator */
diff --git a/drivers/soc/fsl/qbman/qman_portal.c 
b/drivers/soc/fsl/qbman/qman_portal.c
index e6da2ea..c9a9bcb 100644
--- a/drivers/soc/fsl/qbman/qman_portal.c
+++ b/drivers/soc/fsl/qbman/qman_portal.c
@@ -31,6 +31,7 @@
 #include "qman_priv.h"
 
 struct qman_portal *qman_dma_portal;
+EXPORT_SYMBOL(qman_dma_portal);
 
 /* Enable portal interupts (as opposed to polling mode) */
 #define CONFIG_FSL_DPA_PIRQ_SLOW  1
diff --git a/drivers/soc/fsl/qbman/qman_test_stash.c 
b/drivers/soc/fsl/qbman/qman_test_stash.c
index 43cf66b..f8d25fa 100644
--- a/drivers/soc/fsl/qbman/qman_test_stash.c
+++ b/drivers/soc/fsl/qbman/qman_test_stash.c
@@ -191,6 +191,9 @@ struct hp_cpu {
 static u32 *frame_ptr;
 static dma_addr_t frame_dma;
 
+/* needed for dma_map*() */
+static const struct qm_portal_config *pcfg;
+
 /* the main function waits on this */
 static DECLARE_WAIT_QUEUE_HEAD(queue);
 
@@ -210,16 +213,14 @@ static int allocate_frame_data(void)
 {
u32 lfsr = HP_FIRST_WORD;
int loop;
-   struct platform_device *pdev = platform_device_alloc("foobar", -1);
 
-   if (!pdev) {
-   pr_crit("platform_device_alloc() failed");
-   return -EIO;
-   }
-   if (platform_device_add(pdev)) {
-   pr_crit("platform_device_add() failed");
+   if (!qman_dma_portal) {
+   pr_crit("portal not available\n");
return -EIO;
}
+
+   pcfg = qman_get_qm_portal_config(qman_dma_portal);
+
__frame_ptr = kmalloc(4 * HP_NUM_WORDS, GFP_KERNEL);
if (!__frame_ptr)
return -ENOMEM;
@@ -229,15 +230,22 @@ static int allocate_frame_data(void)
frame_ptr[loop] = lfsr;
lfsr = do_lfsr(lfsr);
}
-   frame_dma = dma_map_single(&pdev->dev, frame_ptr, 4 * HP_NUM_WORDS,
+
+   frame_dma = dma_map_single(pcfg->dev, frame_ptr, 4 * HP_NUM_WORDS,
   DMA_BIDIRECTIONAL);
-   platform_device_del(pdev);
-   platform_device_put(pdev);
+   if (dma_mapping_error(pcfg->dev, frame_dma)) {
+   pr_crit("dma mapping failure\n");
+   kfree(__frame_ptr);
+   return -EIO;
+   }
+
return 0;
 }
 
 static void deallocate_frame_data(void)
 {
+   dma_unmap_single(pcfg->dev, frame_dma, 4 * HP_NUM_WORDS,
+DMA_BIDIRECTIONAL);
kfree(__frame_ptr);
 }
 
@@ -249,7 +257,8 @@ static inline int process_frame_data(struct hp_handler 
*handler,
int loop;
 
if (qm_fd_addr_get64(fd) != handler->addr) {
-   pr_crit("bad frame address");
+   pr_crit("bad frame address, [%llX != %llX]\n",
+   qm_fd_addr_get64(fd), handler->addr);
return -EIO;
}
for (loop = 0; loop < HP_NUM_WORDS; loop++, p++) {
-- 
1.7.11.7



[PATCH 10/17] soc/qman: Remove redundant checks from qman_create_cgr()

2016-11-16 Thread Claudiu Manoil
opts is checked redundantly.
Move local_opts declaration inside its usage scope.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 283c2d3..6715485 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2294,7 +2294,6 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
struct qm_mcc_initcgr *opts)
 {
struct qm_mcr_querycgr cgr_state;
-   struct qm_mcc_initcgr local_opts = {};
int ret;
struct qman_portal *p;
 
@@ -2316,11 +2315,12 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
spin_lock(&p->cgr_lock);
 
if (opts) {
+   struct qm_mcc_initcgr local_opts = *opts;
+
ret = qman_query_cgr(cgr, &cgr_state);
if (ret)
goto out;
-   if (opts)
-   local_opts = *opts;
+
if ((qman_ip_rev & 0xFF00) >= QMAN_REV30)
local_opts.cgr.cscn_targ_upd_ctrl =
QM_CGR_TARG_UDP_CTRL_WRITE_BIT | PORTAL_IDX(p);
@@ -2331,7 +2331,7 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
local_opts.we_mask |= QM_CGR_WE_CSCN_TARG;
 
/* send init if flags indicate so */
-   if (opts && (flags & QMAN_CGR_FLAG_USE_INIT))
+   if (flags & QMAN_CGR_FLAG_USE_INIT)
ret = qm_modify_cgr(cgr, QMAN_CGR_FLAG_USE_INIT,
&local_opts);
else
-- 
1.7.11.7



[PATCH 11/17] soc/qman: Remove unused struct qm_mcc* layouts

2016-11-16 Thread Claudiu Manoil
1. qm_mcc_querywq layout not used for now, so drop it;
2. queryfq, queryfq_np and alterfq are used only for accesses to
   the 'fqid' field, so replace these with a generic 'fq' layout.
   As a consequence, 'querycgr' turns into 'cgr' following the
   same reasoning above and for consistent naming.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c  | 58 ---
 drivers/soc/fsl/qbman/qman_priv.h |  6 
 2 files changed, 18 insertions(+), 46 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 6715485..53d9bfb 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -183,41 +183,22 @@ struct qm_mr {
 };
 
 /* MC (Management Command) command */
-/* "Query FQ" */
-struct qm_mcc_queryfq {
+/* "FQ" command layout */
+struct qm_mcc_fq {
u8 _ncw_verb;
u8 __reserved1[3];
u32 fqid;   /* 24-bit */
u8 __reserved2[56];
 } __packed;
-/* "Alter FQ State Commands " */
-struct qm_mcc_alterfq {
-   u8 _ncw_verb;
-   u8 __reserved1[3];
-   u32 fqid;   /* 24-bit */
-   u8 __reserved2;
-   u8 count;   /* number of consecutive FQID */
-   u8 __reserved3[10];
-   u32 context_b;  /* frame queue context b */
-   u8 __reserved4[40];
-} __packed;
 
-/* "Query CGR" */
-struct qm_mcc_querycgr {
+/* "CGR" command layout */
+struct qm_mcc_cgr {
u8 _ncw_verb;
u8 __reserved1[30];
u8 cgid;
u8 __reserved2[32];
 };
 
-struct qm_mcc_querywq {
-   u8 _ncw_verb;
-   u8 __reserved;
-   /* select channel if verb != QUERYWQ_DEDICATED */
-   u16 channel_wq; /* ignores wq (3 lsbits): _res[0-2] */
-   u8 __reserved2[60];
-} __packed;
-
 #define QM_MCC_VERB_VBIT   0x80
 #define QM_MCC_VERB_MASK   0x7f/* where the verb contains; */
 #define QM_MCC_VERB_INITFQ_PARKED  0x40
@@ -243,12 +224,9 @@ struct qm_mcc_querywq {
u8 __reserved[63];
};
struct qm_mcc_initfq initfq;
-   struct qm_mcc_queryfq queryfq;
-   struct qm_mcc_alterfq alterfq;
struct qm_mcc_initcgr initcgr;
-   struct qm_mcc_querycgr querycgr;
-   struct qm_mcc_querywq querywq;
-   struct qm_mcc_queryfq_np queryfq_np;
+   struct qm_mcc_fq fq;
+   struct qm_mcc_cgr cgr;
 };
 
 /* MC (Management Command) result */
@@ -1777,7 +1755,7 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct 
qm_mcc_initfq *opts)
mcc = qm_mc_start(&p->p);
if (opts)
mcc->initfq = *opts;
-   mcc->initfq.fqid = fq->fqid;
+   mcc->fq.fqid = fq->fqid;
mcc->initfq.count = 0;
/*
 * If the FQ does *not* have the TO_DCPORTAL flag, contextB is set as a
@@ -1873,7 +1851,7 @@ int qman_schedule_fq(struct qman_fq *fq)
goto out;
}
mcc = qm_mc_start(&p->p);
-   mcc->alterfq.fqid = fq->fqid;
+   mcc->fq.fqid = fq->fqid;
qm_mc_commit(&p->p, QM_MCC_VERB_ALTER_SCHED);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
dev_err(p->config->dev, "ALTER_SCHED timeout\n");
@@ -1916,7 +1894,7 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
goto out;
}
mcc = qm_mc_start(&p->p);
-   mcc->alterfq.fqid = fq->fqid;
+   mcc->fq.fqid = fq->fqid;
qm_mc_commit(&p->p, QM_MCC_VERB_ALTER_RETIRE);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
dev_crit(p->config->dev, "ALTER_RETIRE timeout\n");
@@ -1995,7 +1973,7 @@ int qman_oos_fq(struct qman_fq *fq)
goto out;
}
mcc = qm_mc_start(&p->p);
-   mcc->alterfq.fqid = fq->fqid;
+   mcc->fq.fqid = fq->fqid;
qm_mc_commit(&p->p, QM_MCC_VERB_ALTER_OOS);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
ret = -ETIMEDOUT;
@@ -2021,7 +1999,7 @@ int qman_query_fq(struct qman_fq *fq, struct qm_fqd *fqd)
int ret = 0;
 
mcc = qm_mc_start(&p->p);
-   mcc->queryfq.fqid = fq->fqid;
+   mcc->fq.fqid = fq->fqid;
qm_mc_commit(&p->p, QM_MCC_VERB_QUERYFQ);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
ret = -ETIMEDOUT;
@@ -2047,7 +2025,7 @@ static int qman_query_fq_np(struct qman_fq *fq,
int ret = 0;
 
mcc = qm_mc_start(&p->p);
-   mcc->queryfq.fqid = fq->fqid;
+   mcc->fq.fqid = fq->fqid;
qm_mc_commit(&p->p, QM_MCC_VERB_QUERYFQ_NP);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
ret = -ETIMEDOUT;
@@ -2075,7 +2053,7 @@ static int qman_query_cgr(struct qman_cgr *cgr,
int ret = 0;
 
  

[PATCH 12/17] soc/qman: Fix accesses to fqid, cleanup

2016-11-16 Thread Claudiu Manoil
Preventively mask every access to the 'fqid' h/w field,
since it is defined as a 24-bit field, for every h/w
descriptor.  Add generic accessors for this field to
ensure correct access.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c | 32 
 include/soc/fsl/qman.h   |  5 +
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 53d9bfb..099ba8e 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -471,7 +471,7 @@ static inline void eqcr_commit_checks(struct qm_eqcr *eqcr)
 {
DPAA_ASSERT(eqcr->busy);
DPAA_ASSERT(eqcr->cursor->orp == (eqcr->cursor->orp & 0x00ff));
-   DPAA_ASSERT(eqcr->cursor->fqid == (eqcr->cursor->fqid & 0x00ff));
+   DPAA_ASSERT(!(eqcr->cursor->fqid & ~QM_FQID_MASK));
DPAA_ASSERT(eqcr->available >= 1);
 }
 
@@ -1387,7 +1387,7 @@ static void qm_mr_process_task(struct work_struct *work)
case QM_MR_VERB_FQRN:
case QM_MR_VERB_FQRL:
/* Lookup in the retirement table */
-   fq = fqid_to_fq(msg->fq.fqid);
+   fq = fqid_to_fq(qm_fqid_get(&msg->fq));
if (WARN_ON(!fq))
break;
fq_state_change(p, fq, msg, verb);
@@ -1755,7 +1755,7 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct 
qm_mcc_initfq *opts)
mcc = qm_mc_start(&p->p);
if (opts)
mcc->initfq = *opts;
-   mcc->fq.fqid = fq->fqid;
+   qm_fqid_set(&mcc->fq, fq->fqid);
mcc->initfq.count = 0;
/*
 * If the FQ does *not* have the TO_DCPORTAL flag, contextB is set as a
@@ -1851,7 +1851,7 @@ int qman_schedule_fq(struct qman_fq *fq)
goto out;
}
mcc = qm_mc_start(&p->p);
-   mcc->fq.fqid = fq->fqid;
+   qm_fqid_set(&mcc->fq, fq->fqid);
qm_mc_commit(&p->p, QM_MCC_VERB_ALTER_SCHED);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
dev_err(p->config->dev, "ALTER_SCHED timeout\n");
@@ -1894,7 +1894,7 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
goto out;
}
mcc = qm_mc_start(&p->p);
-   mcc->fq.fqid = fq->fqid;
+   qm_fqid_set(&mcc->fq, fq->fqid);
qm_mc_commit(&p->p, QM_MCC_VERB_ALTER_RETIRE);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
dev_crit(p->config->dev, "ALTER_RETIRE timeout\n");
@@ -1937,7 +1937,7 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
 
msg.verb = QM_MR_VERB_FQRNI;
msg.fq.fqs = mcr->alterfq.fqs;
-   msg.fq.fqid = fq->fqid;
+   qm_fqid_set(&msg.fq, fq->fqid);
msg.fq.contextB = fq_to_tag(fq);
fq->cb.fqs(p, fq, &msg);
}
@@ -1973,7 +1973,7 @@ int qman_oos_fq(struct qman_fq *fq)
goto out;
}
mcc = qm_mc_start(&p->p);
-   mcc->fq.fqid = fq->fqid;
+   qm_fqid_set(&mcc->fq, fq->fqid);
qm_mc_commit(&p->p, QM_MCC_VERB_ALTER_OOS);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
ret = -ETIMEDOUT;
@@ -1999,7 +1999,7 @@ int qman_query_fq(struct qman_fq *fq, struct qm_fqd *fqd)
int ret = 0;
 
mcc = qm_mc_start(&p->p);
-   mcc->fq.fqid = fq->fqid;
+   qm_fqid_set(&mcc->fq, fq->fqid);
qm_mc_commit(&p->p, QM_MCC_VERB_QUERYFQ);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
ret = -ETIMEDOUT;
@@ -2025,7 +2025,7 @@ static int qman_query_fq_np(struct qman_fq *fq,
int ret = 0;
 
mcc = qm_mc_start(&p->p);
-   mcc->fq.fqid = fq->fqid;
+   qm_fqid_set(&mcc->fq, fq->fqid);
qm_mc_commit(&p->p, QM_MCC_VERB_QUERYFQ_NP);
if (!qm_mc_result_timeout(&p->p, &mcr)) {
ret = -ETIMEDOUT;
@@ -2206,7 +2206,7 @@ int qman_enqueue(struct qman_fq *fq, const struct qm_fd 
*fd)
if (unlikely(!eq))
goto out;
 
-   eq->fqid = fq->fqid;
+   qm_fqid_set(eq, fq->fqid);
eq->tag = fq_to_tag(fq);
eq->fd = *fd;
 
@@ -2468,7 +2468,7 @@ static int _qm_dqrr_consume_and_match(struct qm_portal 
*p, u32 fqid, int s,
} while (wait && !dqrr);
 
while (dqrr) {
-   if (dqrr->fqid == fqid && (dqrr->stat & s))
+   if (qm_fqid_get(dqrr) == fqid && (d

[PATCH 13/17] soc/qman: Drop unused field from eqcr/dqrr descriptors

2016-11-16 Thread Claudiu Manoil
ORP ("Order Restoration Point") mechanism not supported.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c | 3 +--
 include/soc/fsl/qman.h   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 099ba8e..fd335bc 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -141,7 +141,7 @@ struct qm_eqcr_entry {
u8 _ncw_verb; /* writes to this are non-coherent */
u8 dca;
u16 seqnum;
-   u32 orp;/* 24-bit */
+   u8 __reserved[4];
u32 fqid;   /* 24-bit */
u32 tag;
struct qm_fd fd;
@@ -470,7 +470,6 @@ static inline struct qm_eqcr_entry 
*qm_eqcr_start_stash(struct qm_portal
 static inline void eqcr_commit_checks(struct qm_eqcr *eqcr)
 {
DPAA_ASSERT(eqcr->busy);
-   DPAA_ASSERT(eqcr->cursor->orp == (eqcr->cursor->orp & 0x00ff));
DPAA_ASSERT(!(eqcr->cursor->fqid & ~QM_FQID_MASK));
DPAA_ASSERT(eqcr->available >= 1);
 }
diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index f3fa53f..20bbc71 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -279,8 +279,7 @@ struct qm_dqrr_entry {
u8 dca;
u16 seqnum;
u8 rc;  /* Rej Code: 8-bit */
-   u8 orp_hi;  /* ORP: 24-bit */
-   u16 orp_lo;
+   u8 __reserved[3];
u32 fqid;   /* 24-bit */
u32 tag;
struct qm_fd fd;
-- 
1.7.11.7



[PATCH 08/17] soc/qman: Don't add a new platform device for dma mapping

2016-11-16 Thread Claudiu Manoil
The qman portals are platform devices themselves, so they should
handle dma mappings.  Creating a dummy platform device in order to
support dma mapping operations is not justified (and not portable).
Instead, do the mapping against the first portal that has been
initialised.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c| 31 ++-
 drivers/soc/fsl/qbman/qman_portal.c | 11 +++
 drivers/soc/fsl/qbman/qman_priv.h   |  1 +
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index b4ef4a3..a0020d2 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -962,8 +962,6 @@ struct qman_portal {
u32 sdqcr;
/* probing time config params for cpu-affine portals */
const struct qm_portal_config *config;
-   /* needed for providing a non-NULL device to dma_map_***() */
-   struct platform_device *pdev;
/* 2-element array. cgrs[0] is mask, cgrs[1] is snapshot. */
struct qman_cgrs *cgrs;
/* linked-list of CSCN handlers. */
@@ -1133,7 +1131,6 @@ static int qman_create_portal(struct qman_portal *portal,
  const struct qman_cgrs *cgrs)
 {
struct qm_portal *p;
-   char buf[16];
int ret;
u32 isdr;
 
@@ -1196,15 +1193,6 @@ static int qman_create_portal(struct qman_portal *portal,
portal->sdqcr = QM_SDQCR_SOURCE_CHANNELS | QM_SDQCR_COUNT_UPTO3 |
QM_SDQCR_DEDICATED_PRECEDENCE | QM_SDQCR_TYPE_PRIO_QOS |
QM_SDQCR_TOKEN_SET(0xab) | QM_SDQCR_CHANNELS_DEDICATED;
-   sprintf(buf, "qportal-%d", c->channel);
-   portal->pdev = platform_device_alloc(buf, -1);
-   if (!portal->pdev)
-   goto fail_devalloc;
-   if (dma_set_mask(&portal->pdev->dev, DMA_BIT_MASK(40)))
-   goto fail_devadd;
-   ret = platform_device_add(portal->pdev);
-   if (ret)
-   goto fail_devadd;
isdr = 0x;
qm_out(p, QM_REG_ISDR, isdr);
portal->irq_sources = 0;
@@ -1256,10 +1244,6 @@ static int qman_create_portal(struct qman_portal *portal,
 fail_affinity:
free_irq(c->irq, portal);
 fail_irq:
-   platform_device_del(portal->pdev);
-fail_devadd:
-   platform_device_put(portal->pdev);
-fail_devalloc:
kfree(portal->cgrs);
 fail_cgrs:
qm_mc_finish(p);
@@ -1321,9 +1305,6 @@ static void qman_destroy_portal(struct qman_portal *qm)
qm_dqrr_finish(&qm->p);
qm_eqcr_finish(&qm->p);
 
-   platform_device_del(qm->pdev);
-   platform_device_put(qm->pdev);
-
qm->config = NULL;
 }
 
@@ -1817,8 +1798,16 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct 
qm_mcc_initfq *opts)
memset(&mcc->initfq.fqd.context_a, 0,
sizeof(mcc->initfq.fqd.context_a));
} else {
-   phys_fq = dma_map_single(&p->pdev->dev, fq, sizeof(*fq),
-DMA_TO_DEVICE);
+   struct qman_portal *p = qman_dma_portal;
+
+   phys_fq = dma_map_single(p->config->dev, fq,
+sizeof(*fq), DMA_TO_DEVICE);
+   if (dma_mapping_error(p->config->dev, phys_fq)) {
+   dev_err(p->config->dev, "dma_mapping failed\n");
+   ret = -EIO;
+   goto out;
+   }
+
qm_fqd_stashing_set64(&mcc->initfq.fqd, phys_fq);
}
}
diff --git a/drivers/soc/fsl/qbman/qman_portal.c 
b/drivers/soc/fsl/qbman/qman_portal.c
index 6651168..e6da2ea 100644
--- a/drivers/soc/fsl/qbman/qman_portal.c
+++ b/drivers/soc/fsl/qbman/qman_portal.c
@@ -30,6 +30,8 @@
 
 #include "qman_priv.h"
 
+struct qman_portal *qman_dma_portal;
+
 /* Enable portal interupts (as opposed to polling mode) */
 #define CONFIG_FSL_DPA_PIRQ_SLOW  1
 #define CONFIG_FSL_DPA_PIRQ_FAST  1
@@ -150,6 +152,10 @@ static struct qman_portal *init_pcfg(struct 
qm_portal_config *pcfg)
/* all assigned portals are initialized now */
qman_init_cgr_all();
}
+
+   if (!qman_dma_portal)
+   qman_dma_portal = p;
+
spin_unlock(&qman_lock);
 
dev_info(pcfg->dev, "Portal initialised, cpu %d\n", pcfg->cpu);
@@ -310,6 +316,11 @@ static int qman_portal_probe(struct platform_device *pdev)
spin_unlock(&qman_lock);
pcfg->cpu = cpu;
 
+   if (dma_set_mask(dev, DMA_BIT_MASK(40))) {
+   dev_err(dev, "dma_set_mask() failed\n");
+   goto err_portal_init;
+   }
+
if (!i

[PATCH 06/17] soc/qman: Fix direct access to fd's addr_lo, use proper accesor

2016-11-16 Thread Claudiu Manoil
Use the proper accessor to get the FD address.
Accessing the internal field "addr_lo" directly is not portable
and error prone.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 80ff0b7..b4ef4a3 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -1239,8 +1239,8 @@ static int qman_create_portal(struct qman_portal *portal,
/* special handling, drain just in case it's a few FQRNIs */
const union qm_mr_entry *e = qm_mr_current(p);
 
-   dev_err(c->dev, "MR dirty, VB 0x%x, rc 0x%x\n, addr 0x%x",
-   e->verb, e->ern.rc, e->ern.fd.addr_lo);
+   dev_err(c->dev, "MR dirty, VB 0x%x, rc 0x%x, addr 0x%llx\n",
+   e->verb, e->ern.rc, qm_fd_addr_get64(&e->ern.fd));
goto fail_dqrr_mr_empty;
}
/* Success */
-- 
1.7.11.7



[PATCH 14/17] soc/qbman: Handle endianness of qm/bm_in/out()

2016-11-16 Thread Claudiu Manoil
Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/bman.c | 6 +++---
 drivers/soc/fsl/qbman/qman.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c
index ffa48fd..345e50c 100644
--- a/drivers/soc/fsl/qbman/bman.c
+++ b/drivers/soc/fsl/qbman/bman.c
@@ -167,12 +167,12 @@ struct bm_portal {
 /* Cache-inhibited register access. */
 static inline u32 bm_in(struct bm_portal *p, u32 offset)
 {
-   return __raw_readl(p->addr.ci + offset);
+   return be32_to_cpu(__raw_readl(p->addr.ci + offset));
 }
 
 static inline void bm_out(struct bm_portal *p, u32 offset, u32 val)
 {
-   __raw_writel(val, p->addr.ci + offset);
+   __raw_writel(cpu_to_be32(val), p->addr.ci + offset);
 }
 
 /* Cache Enabled Portal Access */
@@ -188,7 +188,7 @@ static inline void bm_cl_touch_ro(struct bm_portal *p, u32 
offset)
 
 static inline u32 bm_ce_in(struct bm_portal *p, u32 offset)
 {
-   return __raw_readl(p->addr.ce + offset);
+   return be32_to_cpu(__raw_readl(p->addr.ce + offset));
 }
 
 struct bman_portal {
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index fd335bc..e7e1314 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -321,12 +321,12 @@ struct qm_portal {
 /* Cache-inhibited register access. */
 static inline u32 qm_in(struct qm_portal *p, u32 offset)
 {
-   return __raw_readl(p->addr.ci + offset);
+   return be32_to_cpu(__raw_readl(p->addr.ci + offset));
 }
 
 static inline void qm_out(struct qm_portal *p, u32 offset, u32 val)
 {
-   __raw_writel(val, p->addr.ci + offset);
+   __raw_writel(cpu_to_be32(val), p->addr.ci + offset);
 }
 
 /* Cache Enabled Portal Access */
@@ -342,7 +342,7 @@ static inline void qm_cl_touch_ro(struct qm_portal *p, u32 
offset)
 
 static inline u32 qm_ce_in(struct qm_portal *p, u32 offset)
 {
-   return __raw_readl(p->addr.ce + offset);
+   return be32_to_cpu(__raw_readl(p->addr.ce + offset));
 }
 
 /* --- EQCR API --- */
-- 
1.7.11.7



[PATCH 15/17] soc/qman: Change remaining contextB into context_b

2016-11-16 Thread Claudiu Manoil
There are multiple occurences of both contextB and context_b
in different h/w descriptors, referring to the same descriptor
field known as "Context B". Stick with the "context_b" naming,
for obvious reasons including consistency (see also context_a).

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c | 12 ++--
 include/soc/fsl/qman.h   | 12 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index e7e1314..ac020fd 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -1395,7 +1395,7 @@ static void qm_mr_process_task(struct work_struct *work)
break;
case QM_MR_VERB_FQPN:
/* Parked */
-   fq = tag_to_fq(msg->fq.contextB);
+   fq = tag_to_fq(msg->fq.context_b);
fq_state_change(p, fq, msg, verb);
if (fq->cb.fqs)
fq->cb.fqs(p, fq, msg);
@@ -1494,7 +1494,7 @@ static inline unsigned int __poll_portal_fast(struct 
qman_portal *p,
 
if (dq->stat & QM_DQRR_STAT_UNSCHEDULED) {
/*
-* VDQCR: don't trust contextB as the FQ may have
+* VDQCR: don't trust context_b as the FQ may have
 * been configured for h/w consumption and we're
 * draining it post-retirement.
 */
@@ -1520,8 +1520,8 @@ static inline unsigned int __poll_portal_fast(struct 
qman_portal *p,
if (dq->stat & QM_DQRR_STAT_DQCR_EXPIRED)
clear_vdqcr(p, fq);
} else {
-   /* SDQCR: contextB points to the FQ */
-   fq = tag_to_fq(dq->contextB);
+   /* SDQCR: context_b points to the FQ */
+   fq = tag_to_fq(dq->context_b);
/* Now let the callback do its stuff */
res = fq->cb.dqrr(p, fq, dq);
/*
@@ -1757,7 +1757,7 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct 
qm_mcc_initfq *opts)
qm_fqid_set(&mcc->fq, fq->fqid);
mcc->initfq.count = 0;
/*
-* If the FQ does *not* have the TO_DCPORTAL flag, contextB is set as a
+* If the FQ does *not* have the TO_DCPORTAL flag, context_b is set as a
 * demux pointer. Otherwise, the caller-provided value is allowed to
 * stand, don't overwrite it.
 */
@@ -1937,7 +1937,7 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
msg.verb = QM_MR_VERB_FQRNI;
msg.fq.fqs = mcr->alterfq.fqs;
qm_fqid_set(&msg.fq, fq->fqid);
-   msg.fq.contextB = fq_to_tag(fq);
+   msg.fq.context_b = fq_to_tag(fq);
fq->cb.fqs(p, fq, &msg);
}
} else if (res == QM_MCR_RESULT_PENDING) {
diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index 20bbc71..c80ecca 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -248,7 +248,7 @@ struct qm_dqrr_entry {
u8 tok;
u8 __reserved2[3];
u32 fqid;   /* 24-bit */
-   u32 contextB;
+   u32 context_b;
struct qm_fd fd;
u8 __reserved4[32];
 } __packed;
@@ -290,7 +290,7 @@ struct qm_dqrr_entry {
u8 fqs; /* Frame Queue Status */
u8 __reserved1[6];
u32 fqid;   /* 24-bit */
-   u32 contextB;
+   u32 context_b;
u8 __reserved2[48];
} __packed fq;  /* FQRN/FQRNI/FQRL/FQPN */
 };
@@ -658,7 +658,7 @@ struct qm_mcc_initcgr {
 /*
  * This enum, and the callback type that returns it, are used when handling
  * dequeued frames via DQRR. Note that for "null" callbacks registered with the
- * portal object (for handling dequeues that do not demux because contextB is
+ * portal object (for handling dequeues that do not demux because context_b is
  * NULL), the return value *MUST* be qman_cb_dqrr_consume.
  */
 enum qman_cb_dqrr_result {
@@ -863,11 +863,11 @@ struct qman_cgr {
  * qman_fq" for more info). NO_MODIFY is only intended for enqueuing to
  * pre-existing frame-queues that aren't to be otherwise interfered with, it
  * prevents all other modifications to the frame queue. The TO_DCPORTAL flag
- * causes the driver to honour any contextB modifications requested in the
+ * causes the driver to honour any context_b modifications requested in the
  * qm_init_fq() API, as this indicates the frame queue will be consumed by a
  * direct-connect 

[PATCH 17/17] soc/qman: Handle endianness of h/w descriptors

2016-11-16 Thread Claudiu Manoil
The hardware descriptors have big endian (BE) format.
Provide proper endianness handling for the remaining
descriptor fields, to ensure they are correctly
accessed by non-BE CPUs too.

Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c| 65 ++---
 drivers/soc/fsl/qbman/qman_priv.h   | 10 ++---
 drivers/soc/fsl/qbman/qman_test_api.c   |  4 +-
 drivers/soc/fsl/qbman/qman_test_stash.c |  5 ++-
 include/soc/fsl/qman.h  | 48 
 5 files changed, 70 insertions(+), 62 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index d287ef0..41895078 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -140,10 +140,10 @@ enum qm_mr_cmode {/* matches QCSP_CFG::MM 
*/
 struct qm_eqcr_entry {
u8 _ncw_verb; /* writes to this are non-coherent */
u8 dca;
-   u16 seqnum;
+   __be16 seqnum;
u8 __reserved[4];
-   u32 fqid;   /* 24-bit */
-   u32 tag;
+   __be32 fqid;/* 24-bit */
+   __be32 tag;
struct qm_fd fd;
u8 __reserved3[32];
 } __packed;
@@ -187,7 +187,7 @@ struct qm_mr {
 struct qm_mcc_fq {
u8 _ncw_verb;
u8 __reserved1[3];
-   u32 fqid;   /* 24-bit */
+   __be32 fqid;/* 24-bit */
u8 __reserved2[56];
 } __packed;
 
@@ -470,7 +470,7 @@ static inline struct qm_eqcr_entry 
*qm_eqcr_start_stash(struct qm_portal
 static inline void eqcr_commit_checks(struct qm_eqcr *eqcr)
 {
DPAA_ASSERT(eqcr->busy);
-   DPAA_ASSERT(!(eqcr->cursor->fqid & ~QM_FQID_MASK));
+   DPAA_ASSERT(!(be32_to_cpu(eqcr->cursor->fqid) & ~QM_FQID_MASK));
DPAA_ASSERT(eqcr->available >= 1);
 }
 
@@ -1395,7 +1395,7 @@ static void qm_mr_process_task(struct work_struct *work)
break;
case QM_MR_VERB_FQPN:
/* Parked */
-   fq = tag_to_fq(msg->fq.context_b);
+   fq = tag_to_fq(be32_to_cpu(msg->fq.context_b));
fq_state_change(p, fq, msg, verb);
if (fq->cb.fqs)
fq->cb.fqs(p, fq, msg);
@@ -1409,7 +1409,7 @@ static void qm_mr_process_task(struct work_struct *work)
}
} else {
/* Its a software ERN */
-   fq = tag_to_fq(msg->ern.tag);
+   fq = tag_to_fq(be32_to_cpu(msg->ern.tag));
fq->cb.ern(p, fq, msg);
}
num++;
@@ -1521,7 +1521,7 @@ static inline unsigned int __poll_portal_fast(struct 
qman_portal *p,
clear_vdqcr(p, fq);
} else {
/* SDQCR: context_b points to the FQ */
-   fq = tag_to_fq(dq->context_b);
+   fq = tag_to_fq(be32_to_cpu(dq->context_b));
/* Now let the callback do its stuff */
res = fq->cb.dqrr(p, fq, dq);
/*
@@ -1738,9 +1738,9 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct 
qm_mcc_initfq *opts)
if (fq_isset(fq, QMAN_FQ_FLAG_NO_MODIFY))
return -EINVAL;
 #endif
-   if (opts && (opts->we_mask & QM_INITFQ_WE_OAC)) {
+   if (opts && (be16_to_cpu(opts->we_mask) & QM_INITFQ_WE_OAC)) {
/* And can't be set at the same time as TDTHRESH */
-   if (opts->we_mask & QM_INITFQ_WE_TDTHRESH)
+   if (be16_to_cpu(opts->we_mask) & QM_INITFQ_WE_TDTHRESH)
return -EINVAL;
}
/* Issue an INITFQ_[PARKED|SCHED] management command */
@@ -1764,14 +1764,16 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct 
qm_mcc_initfq *opts)
if (fq_isclear(fq, QMAN_FQ_FLAG_TO_DCPORTAL)) {
dma_addr_t phys_fq;
 
-   mcc->initfq.we_mask |= QM_INITFQ_WE_CONTEXTB;
-   mcc->initfq.fqd.context_b = fq_to_tag(fq);
+   mcc->initfq.we_mask |= cpu_to_be16(QM_INITFQ_WE_CONTEXTB);
+   mcc->initfq.fqd.context_b = cpu_to_be32(fq_to_tag(fq));
/*
 *  and the physical address - NB, if the user wasn't trying to
 * set CONTEXTA, clear the stashing settings.
 */
-   if (!(mcc->initfq.we_mask & QM_INITFQ_WE_CONTEXTA)) {
-   mcc->initfq.we_mask |= QM_INITFQ_WE_CONTEXTA;
+   if (!(be16_to_cpu(mcc->initfq.we_mask) &
+ QM_INITFQ_WE_CONTEXTA)) {
+   mcc->initfq.we_mask |=
+   cpu_to_be16(QM_INITFQ_WE_CONTEXTA);
   

[PATCH 16/17] soc/qman: Clean up CGR CSCN target update operations

2016-11-16 Thread Claudiu Manoil
Signed-off-by: Claudiu Manoil 
---
 drivers/soc/fsl/qbman/qman.c | 37 +++--
 include/soc/fsl/qman.h   |  4 ++--
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index ac020fd..d287ef0 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2248,7 +2248,23 @@ static int qm_modify_cgr(struct qman_cgr *cgr, u32 flags,
 }
 
 #define PORTAL_IDX(n)  (n->config->channel - QM_CHANNEL_SWPORTAL0)
-#define TARG_MASK(n)   (BIT(31) >> PORTAL_IDX(n))
+
+/* congestion state change notification target update control */
+static void qm_cgr_cscn_targ_set(struct __qm_mc_cgr *cgr, int pi, u32 val)
+{
+   if (qman_ip_rev >= QMAN_REV30)
+   cgr->cscn_targ_upd_ctrl = QM_CGR_TARG_UDP_CTRL_WRITE_BIT | pi;
+   else
+   cgr->cscn_targ = val | QM_CGR_TARG_PORTAL(pi);
+}
+
+static void qm_cgr_cscn_targ_clear(struct __qm_mc_cgr *cgr, int pi, u32 val)
+{
+   if (qman_ip_rev >= QMAN_REV30)
+   cgr->cscn_targ_upd_ctrl = pi;
+   else
+   cgr->cscn_targ = val & ~QM_CGR_TARG_PORTAL(pi);
+}
 
 static u8 qman_cgr_cpus[CGR_NUM];
 
@@ -2298,13 +2314,8 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
if (ret)
goto out;
 
-   if ((qman_ip_rev & 0xFF00) >= QMAN_REV30)
-   local_opts.cgr.cscn_targ_upd_ctrl =
-   QM_CGR_TARG_UDP_CTRL_WRITE_BIT | PORTAL_IDX(p);
-   else
-   /* Overwrite TARG */
-   local_opts.cgr.cscn_targ = cgr_state.cgr.cscn_targ |
-  TARG_MASK(p);
+   qm_cgr_cscn_targ_set(&local_opts.cgr, PORTAL_IDX(p),
+cgr_state.cgr.cscn_targ);
local_opts.we_mask |= QM_CGR_WE_CSCN_TARG;
 
/* send init if flags indicate so */
@@ -2371,13 +2382,11 @@ int qman_delete_cgr(struct qman_cgr *cgr)
list_add(&cgr->node, &p->cgr_cbs);
goto release_lock;
}
-   /* Overwrite TARG */
+
local_opts.we_mask = QM_CGR_WE_CSCN_TARG;
-   if ((qman_ip_rev & 0xFF00) >= QMAN_REV30)
-   local_opts.cgr.cscn_targ_upd_ctrl = PORTAL_IDX(p);
-   else
-   local_opts.cgr.cscn_targ = cgr_state.cgr.cscn_targ &
-~(TARG_MASK(p));
+   qm_cgr_cscn_targ_clear(&local_opts.cgr, PORTAL_IDX(p),
+  cgr_state.cgr.cscn_targ);
+
ret = qm_modify_cgr(cgr, 0, &local_opts);
if (ret)
/* add back to the list */
diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index c80ecca..d01d5a3 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -553,8 +553,8 @@ struct __qm_mc_cgr {
u8 cscn_en; /* boolean, use QM_CGR_EN */
union {
struct {
-   u16 cscn_targ_upd_ctrl; /* use QM_CSCN_TARG_UDP_ */
-   u16 cscn_targ_dcp_low;  /* CSCN_TARG_DCP low-16bits */
+   u16 cscn_targ_upd_ctrl; /* use QM_CGR_TARG_UDP_* */
+   u16 cscn_targ_dcp_low;
};
u32 cscn_targ;  /* use QM_CGR_TARG_* */
};
-- 
1.7.11.7



[PATCH] powerpc/85xx: Don't report SRAM to L2 cache fallback as error

2016-05-24 Thread Claudiu Manoil
If the SRAM region parameters are missing the SRAM driver
probing exits and the L2 region is configured as L2 cache
entirely.  This is the expected default behaviour, so it
makes no sense to report it as an error.

Signed-off-by: Claudiu Manoil 
---
 arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c 
b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
index 861cebf..15bc867 100644
--- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -91,9 +91,8 @@ static int mpc85xx_l2ctlr_of_probe(struct platform_device 
*dev)
l2cache_size = *prop;
 
if (get_cache_sram_params(&sram_params)) {
-   dev_err(&dev->dev,
-   "Entire L2 as cache, provide valid sram offset and 
size\n");
-   return -EINVAL;
+   dev_info(&dev->dev, "Configure entire L2 as cache\n");
+   return 0;
}
 
 
-- 
1.7.11.7

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH][v2] powerpc/85xx: Don't report SRAM to L2 cache fallback as error

2016-05-25 Thread Claudiu Manoil
If the SRAM region parameters are missing the SRAM driver
probing exits and the L2 region is configured as L2 cache
entirely.  This is the expected default behaviour, so it
makes no sense to report it as an error.

Signed-off-by: Claudiu Manoil 
---
v2: drop info print on Scott's request

 arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c 
b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
index 861cebf..c27058e 100644
--- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -90,12 +90,8 @@ static int mpc85xx_l2ctlr_of_probe(struct platform_device 
*dev)
}
l2cache_size = *prop;
 
-   if (get_cache_sram_params(&sram_params)) {
-   dev_err(&dev->dev,
-   "Entire L2 as cache, provide valid sram offset and 
size\n");
-   return -EINVAL;
-   }
-
+   if (get_cache_sram_params(&sram_params))
+   return 0; /* fall back to L2 cache only */
 
rem = l2cache_size % sram_params.sram_size;
ways = LOCK_WAYS_FULL * sram_params.sram_size / l2cache_size;
-- 
1.7.11.7

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH, RESEND, v2] powerpc/85xx: Don't report SRAM to L2 cache fallback as error

2016-07-07 Thread Claudiu Manoil
If the SRAM region parameters are missing the SRAM driver
probing exits and the L2 region is configured as L2 cache
entirely.  This is the expected default behaviour, so it
makes no sense to report it as an error.

Signed-off-by: Claudiu Manoil 
---
v2: drop info print

 arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c 
b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
index 861cebf..c27058e 100644
--- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -90,12 +90,8 @@ static int mpc85xx_l2ctlr_of_probe(struct platform_device 
*dev)
}
l2cache_size = *prop;
 
-   if (get_cache_sram_params(&sram_params)) {
-   dev_err(&dev->dev,
-   "Entire L2 as cache, provide valid sram offset and 
size\n");
-   return -EINVAL;
-   }
-
+   if (get_cache_sram_params(&sram_params))
+   return 0; /* fall back to L2 cache only */
 
rem = l2cache_size % sram_params.sram_size;
ways = LOCK_WAYS_FULL * sram_params.sram_size / l2cache_size;
-- 
1.7.11.7

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev