[net-next v4 0/8] dpaa_eth: Add the Freescale DPAA Ethernet driver

2015-11-02 Thread Madalin Bucur
This patch series adds the Ethernet driver for the Freescale
QorIQ Data Path Acceleration Architecture (DPAA).

This version includes changes following the feedback received
on previous versions from Eric Dumazet, Bob Cochran, Joe Perches,
Paul Bolle, Joakim Tjernlund, Scott Wood, David Miller - thank you.

Together with the driver a managed version of alloc_percpu
is provided that simplifies the release of per-CPU memory.

The Freescale DPAA architecture consists in a series of hardware
blocks that support the Ethernet connectivity. The Ethernet driver
depends upon the following drivers that are currently in the Linux
kernel or in review (the underlying drivers are not inter-dependent):
 - Peripheral Access Memory Unit (PAMU)
drivers/iommu/fsl_*
 - Frame Manager (FMan)
drivers/net/ethernet/freescale/fman
 - Queue Manager (QMan), Buffer Manager (BMan)
drivers/soc/fsl/qbman

dpaa_eth interfaces mapping to FMan MACs:

  dpaa_eth   /eth0\ ...   /ethN\
  driver|  | |  |
  -      ---      -
   -Ports  / Tx  Rx \.../ Tx  Rx \
  FMan|  | |  |
   -MACs  |   MAC0   | |   MACN   |
 /   dtsec0   \  ...  /   dtsecN   \ (or tgec)
/  \ /  \(or memac)
  -  --  ---  --  -
  FMan, FMan Port, FMan SP, FMan MURAM drivers
  -
  FMan HW blocks: MURAM, MACs, Ports, SP
  -

dpaa_eth relation to QMan, FMan:
  
  dpaa_eth   /eth0\
  driver/  \
  -   -^-   -^-   -^-   ----
  QMan driver / \   / \   / \  \   /  | BMan|
 |Rx | |Rx | |Tx | |Tx |  | driver  |
  -  |Dfl| |Err| |Cnf| |FQs|  | |
  QMan HW|FQ | |FQ | |FQ | |   |  | |
 /   \ /   \ /   \  \ /   | |
  -   ---   ---   ---   -v--
|FMan QMI | |
| FMan HW   FMan BMI  | BMan HW |
  ---   

where the acronyms used above (and in the code) are:
DPAA = Data Path Acceleration Architecture
FMan = DPAA Frame Manager
QMan = DPAA Queue Manager
BMan = DPAA Buffers Manager
QMI = QMan interface in FMan
BMI = BMan interface in FMan
FMan SP = FMan Storage Profiles
MURAM = Multi-user RAM in FMan
FQ = QMan Frame Queue
Rx Dfl FQ = default reception FQ
Rx Err FQ = Rx error frames FQ
Tx Cnf FQ = Tx confirmation FQ
Tx FQs = transmission frame queues
dtsec = datapath three speed Ethernet controller (10/100/1000 Mbps)
tgec = ten gigabit Ethernet controller (10 Gbps)
memac = multirate Ethernet MAC (10/100/1000/1)

The latest FMan driver patches were submitted by Igal Liberman:
https://patchwork.ozlabs.org/project/netdev/list/?submitter=64715=*=[v7,

The latest Q/BMan drivers were submitted by Roy Pledge:
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?submitter=66331=*

Changes from v3:
 - removed bogus delay and comment in .ndo_stop implementation
 - addressed minor issues reported by David Miller

Changes from v2:
 - removed debugfs, moved exports to ethtool statistics
 - removed congestion groups Kconfig params

Changes from v1:
 - bpool level Kconfig options removed
 - print format using pr_fmt, cleaned up prints
 - __hot/__cold removed
 - gratuitous unlikely() removed
 - code style aligned, consistent spacing for declarations
 - comment formatting

The complete patch set based on the latest net-next/master kernel
can be found in the public git at:
http://git.freescale.com/git/cgit.cgi/ppc/upstream/linux.git
under the tag ldup_public_git_20151102:
http://git.freescale.com/git/cgit.cgi/ppc/upstream/linux.git/log/?h=ldup_public_git_20151102

There is one u-boot patch that one needs to make sure it's applied
to align u-boot to the latest device tree binding document specification
used by the FMan driver. Please make sure your u-boot includes this patch:

commit 97a8d010e029111e5711a45264a726bedbeb24c4
Author: Igal Liberman 
Date:   Tue Aug 18 14:47:05 2015 +0300

net/fman: Support both new and legacy FMan Compatibles

The patch was included in u-boot in v2015.10-rc3.

Madalin Bucur (8):
  devres: add devm_alloc_percpu()
  dpaa_eth: add support for DPAA Ethernet
  dpaa_eth: add support for S/G frames
  dpaa_eth: add driver's Tx queue selection
  dpaa_eth: add ethtool functionality
  dpaa_eth: add ethtool statistics
  dpaa_eth: add sysfs exports
  dpaa_eth: add trace points

 Documentation/driver-model/devres.txt  |4 +
 drivers/base/devres.c  |   64 +
 drivers/net/ethernet/freescale/Kconfig |2 +
 

Re: [PATCH] nx-842: Ignore bit 3 of condition register returned by icswx

2015-11-02 Thread Ram Pai
On Mon, Nov 02, 2015 at 12:23:36PM +1100, Michael Ellerman wrote:
> On Fri, 2015-10-30 at 15:31 -0700, Ram Pai wrote:
> > icswx occasionally under heavy load sets bit 3 of condition register 0.
> 
> Why?

The hardware manual says that bit is undefined, though it is set under some 
conditions.

> 
> Also you seem to be using IBM bit numbering, so please be explicit about that,
> or use normal bit numbering.

Ok. 


> 
> > It has no software implication.
> 
> What does it mean? You might be right but you don't give me enough info to
> decide.

The software is not supposed to interpret the bit since its meaning is
undefined. 

> 
> > Currently that bit is interpreted by the driver as a failure, when
> > it should have calmly ignored it.
> 
> Should the fix be in icswx or the driver? Please justify your choice.

Yes there are two solutions. One is icswx macro should not expose that
bit to its consumers.  Or the driver/consumers can ignore that bit.  I
think it makes more sense to contain it in one place, which is icswx
instruction. Drivers or whoever calls icswx should not know
more than what they need to know. This patch uses the first approach.

> 
> This sounds like it's fixing a bug so shouldn't the patch go to stable? And if
> so which version(s) should it apply to?

It should go to stable v4.2.  I will tag it to stable, in my next
version.

RP

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

Re: [PATCH] Endian swap ->count before handing over to the nx-842 compressor

2015-11-02 Thread Ram Pai
On Mon, Nov 02, 2015 at 12:24:36PM +1100, Michael Ellerman wrote:
> On Fri, 2015-10-30 at 15:13 -0700, Ram Pai wrote:
> 
> > The nx-842 compressor overshoots the output buffer corrupting memory. 
> > Verified
> > that the following patch the issue on a LE system.
> 
> This seems like a bug fix, so it should go to stable shouldn't it? If so which
> version(s) should it apply to?
> 
> And which commit introduced the breakage? Or has it always been broken?

Mike,

Please ignore this patch. I still run into corruption even after
this patch.  I am looking into the issue. Will have a more
comprehensive fix.

BTW: it has always been broken AFAICT. I find the issue even
with lzo software compression. So may be I am doing something
wrong in my driver, or there is more fundamental issue. Will dig
this further.

RP

> 
> cheers

-- 
Ram Pai

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

[v7, 1/6] fsl/fman: Add FMan MURAM support

2015-11-02 Thread igal.liberman
From: Igal Liberman 

Add Frame Manager Multi-User RAM support.
This internal FMan memory block is used by the
FMan hardware modules, the management being made
through the generic allocator.

The FMan Internal memory, for example, is used for
allocating transmit and receive FIFOs.

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/Kconfig   |1 +
 drivers/net/ethernet/freescale/Makefile  |2 +
 drivers/net/ethernet/freescale/fman/Kconfig  |8 ++
 drivers/net/ethernet/freescale/fman/Makefile |5 +
 drivers/net/ethernet/freescale/fman/fman_muram.c |  159 ++
 drivers/net/ethernet/freescale/fman/fman_muram.h |   51 +++
 6 files changed, 226 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/Kconfig
 create mode 100644 drivers/net/ethernet/freescale/fman/Makefile
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_muram.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_muram.h

diff --git a/drivers/net/ethernet/freescale/Kconfig 
b/drivers/net/ethernet/freescale/Kconfig
index ff76d4e..f3f89cc 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -53,6 +53,7 @@ config FEC_MPC52xx_MDIO
  If compiled as module, it will be called fec_mpc52xx_phy.
 
 source "drivers/net/ethernet/freescale/fs_enet/Kconfig"
+source "drivers/net/ethernet/freescale/fman/Kconfig"
 
 config FSL_PQ_MDIO
tristate "Freescale PQ MDIO"
diff --git a/drivers/net/ethernet/freescale/Makefile 
b/drivers/net/ethernet/freescale/Makefile
index 71debd1..4097c58 100644
--- a/drivers/net/ethernet/freescale/Makefile
+++ b/drivers/net/ethernet/freescale/Makefile
@@ -17,3 +17,5 @@ gianfar_driver-objs := gianfar.o \
gianfar_ethtool.o
 obj-$(CONFIG_UCC_GETH) += ucc_geth_driver.o
 ucc_geth_driver-objs := ucc_geth.o ucc_geth_ethtool.o
+
+obj-$(CONFIG_FSL_FMAN) += fman/
diff --git a/drivers/net/ethernet/freescale/fman/Kconfig 
b/drivers/net/ethernet/freescale/fman/Kconfig
new file mode 100644
index 000..66b7296
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/Kconfig
@@ -0,0 +1,8 @@
+config FSL_FMAN
+   bool "FMan support"
+   depends on FSL_SOC || COMPILE_TEST
+   select GENERIC_ALLOCATOR
+   default n
+   help
+   Freescale Data-Path Acceleration Architecture Frame Manager
+   (FMan) support
diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
new file mode 100644
index 000..fc2e194
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -0,0 +1,5 @@
+subdir-ccflags-y +=  -I$(srctree)/drivers/net/ethernet/freescale/fman
+
+obj-y  += fsl_fman.o
+
+fsl_fman-objs  := fman_muram.o
diff --git a/drivers/net/ethernet/freescale/fman/fman_muram.c 
b/drivers/net/ethernet/freescale/fman/fman_muram.c
new file mode 100644
index 000..35d4a50
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman_muram.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2008-2015 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 "fman_muram.h"
+
+#include 
+#include 
+#include 

[net-next v4 1/8] devres: add devm_alloc_percpu()

2015-11-02 Thread Madalin Bucur
Introduce managed counterparts for alloc_percpu() and free_percpu().
Add devm_alloc_percpu() and devm_free_percpu() into the managed
interfaces list.

Signed-off-by: Madalin Bucur 
Tested-by: Madalin-Cristian Bucur 
---
 Documentation/driver-model/devres.txt |  4 +++
 drivers/base/devres.c | 64 +++
 include/linux/device.h| 19 +++
 3 files changed, 87 insertions(+)

diff --git a/Documentation/driver-model/devres.txt 
b/Documentation/driver-model/devres.txt
index 831a536..595fd1b 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -312,6 +312,10 @@ MEM
   devm_kvasprintf()
   devm_kzalloc()
 
+PER-CPU MEM
+  devm_alloc_percpu()
+  devm_free_percpu()
+
 PCI
   pcim_enable_device() : after success, all PCI ops become managed
   pcim_pin_device(): keep PCI device enabled after release
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 8754646..6c314cc 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "base.h"
 
@@ -984,3 +985,66 @@ void devm_free_pages(struct device *dev, unsigned long 
addr)
   ));
 }
 EXPORT_SYMBOL_GPL(devm_free_pages);
+
+static void devm_percpu_release(struct device *dev, void *pdata)
+{
+   void __percpu *p;
+
+   p = *(void __percpu **)pdata;
+   free_percpu(p);
+}
+
+static int devm_percpu_match(struct device *dev, void *data, void *p)
+{
+   struct devres *devr = container_of(data, struct devres, data);
+
+   return *(void **)devr->data == p;
+}
+
+/**
+ * __devm_alloc_percpu - Resource-managed alloc_percpu
+ * @dev: Device to allocate per-cpu memory for
+ * @size: Size of per-cpu memory to allocate
+ * @align: Alignement of per-cpu memory to allocate
+ *
+ * Managed alloc_percpu. Per-cpu memory allocated with this function is
+ * automatically freed on driver detach.
+ *
+ * RETURNS:
+ * Pointer to allocated memory on success, NULL on failure.
+ */
+void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
+   size_t align)
+{
+   void *p;
+   void __percpu *pcpu;
+
+   pcpu = __alloc_percpu(size, align);
+   if (!pcpu)
+   return NULL;
+
+   p = devres_alloc(devm_percpu_release, sizeof(void *), GFP_KERNEL);
+   if (!p)
+   return NULL;
+
+   *(void __percpu **)p = pcpu;
+
+   devres_add(dev, p);
+
+   return pcpu;
+}
+EXPORT_SYMBOL_GPL(__devm_alloc_percpu);
+
+/**
+ * devm_free_percpu - Resource-managed free_percpu
+ * @dev: Device this memory belongs to
+ * @pdata: Per-cpu memory to free
+ *
+ * Free memory allocated with devm_alloc_percpu().
+ */
+void devm_free_percpu(struct device *dev, void __percpu *pdata)
+{
+   WARN_ON(devres_destroy(dev, devm_percpu_release, devm_percpu_match,
+  (void *)pdata));
+}
+EXPORT_SYMBOL_GPL(devm_free_percpu);
diff --git a/include/linux/device.h b/include/linux/device.h
index 5d7bc63..b563cc5 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -673,6 +673,25 @@ void __iomem *devm_ioremap_resource(struct device *dev, 
struct resource *res);
 int devm_add_action(struct device *dev, void (*action)(void *), void *data);
 void devm_remove_action(struct device *dev, void (*action)(void *), void 
*data);
 
+/**
+ * devm_alloc_percpu - Resource-managed alloc_percpu
+ * @dev: Device to allocate per-cpu memory for
+ * @type: Type to allocate per-cpu memory for
+ *
+ * Managed alloc_percpu. Per-cpu memory allocated with this function is
+ * automatically freed on driver detach.
+ *
+ * RETURNS:
+ * Pointer to allocated memory on success, NULL on failure.
+ */
+#define devm_alloc_percpu(dev, type)  \
+   (typeof(type) __percpu *)__devm_alloc_percpu(dev, sizeof(type), \
+__alignof__(type))
+
+void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
+  size_t align);
+void devm_free_percpu(struct device *dev, void __percpu *pdata);
+
 struct device_dma_parameters {
/*
 * a low level driver may set these to teach IOMMU code about
-- 
1.7.11.7

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

RE: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence

2015-11-02 Thread Dogra Raghav

Hi Scott,

I just checked on patchwork and noticed that the original patch has been 
modified as somehow my original comment has become part of the patch:
+   if (!lbc)
+   goto out;
 
ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL);
if (!ctrl->saved_regs)
return -ENOMEM;
[Dogra Raghav-B46184] This is the existing upstream code. Are you suggesting to 
modify the upstream code to take care of individual registers?
 
_memcpy_fromio(ctrl->saved_regs, lbc, sizeof(struct fsl_lbc_regs));
+
The patchwork is also showing two links for the patch. Please apply the 
original patch present at:
https://patchwork.ozlabs.org/patch/538605/

I will look into how this happened to avoid such incidents in future.

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

Re: [net-next v4 2/8] dpaa_eth: add support for DPAA Ethernet

2015-11-02 Thread Joakim Tjernlund
On Mon, 2015-11-02 at 19:31 +0200, Madalin Bucur wrote:
> +   if (unlikely(fd_status & FM_FD_STAT_RX_ERRORS) != 0) {
> +   if (net_ratelimit())
> +   netif_warn(priv, hw, net_dev, "FD status = 0x%08x\n",
> +  fd_status & FM_FD_STAT_RX_ERRORS);
> +
> +   percpu_stats->rx_errors++;
> +   goto _release_frame;
> +   }

I cannot find any detailed error accounting(maybe I am not looking hard enough) 
but I
would appreciate if both TX and RX errors where better 
accounted(rx_length_errors, rx_frame_errors,
rx_crc_errors, rx_fifo_errors etc.). This has helped me many times in the past 
diagnosing
board HW problems.

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

Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence

2015-11-02 Thread Scott Wood
On Tue, 2015-11-03 at 00:09 -0600, Dogra Raghav-B46184 wrote:
> 
> -Original Message-
> From: Wood Scott-B07421 
> Sent: Tuesday, November 03, 2015 11:10 AM
> To: Dogra Raghav-B46184 
> Cc: Kushwaha Prabhakar-B32579 ; 
> linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence
> 
> On Mon, 2015-11-02 at 23:31 -0600, Dogra Raghav-B46184 wrote:
> > 
> > -Original Message-
> > From: Wood Scott-B07421
> > Sent: Tuesday, November 03, 2015 4:31 AM
> > To: Dogra Raghav-B46184 
> > Cc: Kushwaha Prabhakar-B32579 ; 
> > linuxppc-dev@lists.ozlabs.org
> > Subject: Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry 
> > sequence
> > 
> > On Mon, 2015-11-02 at 00:12 -0600, Dogra Raghav-B46184 wrote:
> > > -Original Message-
> > > From: Raghav Dogra [mailto:rag...@freescale.com]
> > > Sent: Friday, October 30, 2015 11:55 AM
> > > To: linuxppc-dev@lists.ozlabs.org
> > > Cc: Wood Scott-B07421 ; Kushwaha
> > > Prabhakar-B32579 < prabha...@freescale.com>; Dogra Raghav-B46184 
> > > 
> > > Subject: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry 
> > > sequence
> > > 
> > > Modify platform driver suspend/resume to syscore suspend/resume. 
> > > This is because p1022ds needs to use localbus when entering the PCIE 
> > > resume.
> > > 
> > > Signed-off-by: Raghav Dogra 
> > > ---
> > >  arch/powerpc/sysdev/Makefile  |  2 +-  
> > > arch/powerpc/sysdev/fsl_lbc.c
> > > > 51 +---
> > > ---
> > >  2 files changed, 40 insertions(+), 13 deletions(-)
> > > 
> > > diff --git a/arch/powerpc/sysdev/Makefile 
> > > b/arch/powerpc/sysdev/Makefile index f7cb2a1..4c19e614 100644
> > > --- a/arch/powerpc/sysdev/Makefile
> > > +++ b/arch/powerpc/sysdev/Makefile
> > > @@ -18,9 +18,9 @@ obj-$(CONFIG_PPC_PMI)   += pmi.o
> > >  obj-$(CONFIG_U3_DART)+= dart_iommu.o
> > >  obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
> > >  obj-$(CONFIG_FSL_SOC)+= fsl_soc.o fsl_mpic_err.o
> > > +obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
> > >  obj-$(CONFIG_FSL_PCI)+= fsl_pci.o $(fsl-msi-obj-y)
> > >  obj-$(CONFIG_FSL_PMC)+= fsl_pmc.o
> > > -obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
> > >  obj-$(CONFIG_FSL_GTM)+= fsl_gtm.o
> > >  obj-$(CONFIG_FSL_85XX_CACHE_SRAM)+= fsl_85xx_l2ctlr.o 
> > > fsl_85xx_cache_sram.o
> > >  obj-$(CONFIG_SIMPLE_GPIO)+= simple_gpio.o
> > > diff --git a/arch/powerpc/sysdev/fsl_lbc.c 
> > > b/arch/powerpc/sysdev/fsl_lbc.c index d631022..332d700 100644
> > > --- a/arch/powerpc/sysdev/fsl_lbc.c
> > > +++ b/arch/powerpc/sysdev/fsl_lbc.c
> > > @@ -27,6 +27,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  
> > > @@ -354,24 +355,42 @@ err:
> > >  #ifdef CONFIG_SUSPEND
> > >  
> > >  /* save lbc registers */
> > > -static int fsl_lbc_suspend(struct platform_device *pdev, 
> > > pm_message_t
> > > state)
> > > +static int fsl_lbc_syscore_suspend(void)
> > >  {
> > > - struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(>dev);
> > > - struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
> > > + struct fsl_lbc_ctrl *ctrl;
> > > + struct fsl_lbc_regs __iomem *lbc;
> > > +
> > > + ctrl = fsl_lbc_ctrl_dev;
> > > + if (!ctrl)
> > > + goto out;
> > > +
> > > + lbc = ctrl->regs;
> > > + if (!lbc)
> > > + goto out;
> > >  
> > >   ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), 
> > > GFP_KERNEL);
> > >   if (!ctrl->saved_regs)
> > >   return -ENOMEM;
> > > [Dogra Raghav-B46184] This is the existing upstream code. Are you 
> > > suggesting to modify the upstream code to take care of individual 
> > > registers?
> > 
> > What specifically do you mean by "the upstream code"?  What other tree 
> > are we talking about here?
> > 
> > -Scott
> > 
> > I meant that these two lines of code are not being added or modified 
> > by this patch. They already exist in the upstream tree. Are you 
> > suggesting I modify them as well?
> > -Raghav
> 
> I have no idea which "two lines of code" you're talking about or how any 
> comment I made applies to the above diff hunk.
> 
> OK, I looked at the original patch and I guess you're talking about the
> _memcpy_fromio() that was *below* your comment?  Please configure your 
> mailer to quote properly, and put your replies below what you're quoting.
> 
> Yes, I think that that usage of _memcpy_fromio() is bad and should be 
> changed.
> 
> -Scott
> 
> Ok, I will take care that the replies are below what I am quoting in 
> future. 

Also please make your mailer use proper quote markers.

> Can this patch be applied as it is then? The changes you are suggesting can 
> come in a new patch.

OK.

-Scott


[PATCH V3 0/3] perf/powerpc:Add ability to sample intr machine state in powerpc

2015-11-02 Thread Anju T
This short patch series adds the ability to sample the interrupted
machine state for each hardware sample.

To test this patchset,
Eg:

$perf record -I ls   // record machine state at interrupt
$perf script -D  //read the perf.data file

Sample output obtained for this patchset/ output looks like as follows:

331557004666 0x1988 [0x188]: PERF_RECORD_SAMPLE(IP, 0x1): 4807/4807: 
0xc01ddf60 period: 1 addr: 0
... intr regs: mask 0x7ff ABI 64-bit
 gpr0  0xc01e6a74
 gpr1  0xc000ff33b9a0
 gpr2  0xc1523000
 gpr3  0xc00ffa9deb60
 gpr4  0xc000ff971e00
 gpr5  0x4d32564532
 gpr6  0x1e00
 gpr7  0x0
 gpr8  0x0
 gpr9  0x0
 gpr10 0x1
 gpr11 0x0
 gpr12 0x24022822
 gpr13 0xcfeeaf80
 gpr14 0x0
 gpr15 0xc000fbc21000
 gpr16 0x0
 gpr17 0xc00ffa9c5000
 gpr18 0xc000ff33b8a0
 gpr19 0xc1523000
 gpr20 0xc00a097c
 gpr21 0xc00fcac65600
 gpr22 0xc01e55a8
 gpr23 0xc1523000
 gpr24 0xc000ff33b850
 gpr25 0xc00fcac65600
 gpr26 0xc01e4b378210
 gpr27 0xfead
 gpr28 0x1
 gpr29 0xc00fcac65600
 gpr30 0x1
 gpr31 0x0
 nip   0xc01ddf68
 msr   0x90009032
 orig_r3 0xc01e5fcc
 ctr   0xc009e1b0
 link  0xc01e6a74
 xer   0x0
 ccr   0x84022882
 softe 0x0
 trap  0xf01
 dar   0x0
 dsisr 0xf0004006004
 ... thread: :4807:4807
 .. dso: /root/.debug/.build-id/1c/011201a1082e91b8449e6dd528f224d7a16535
   :4807  4807   331.557004:  1 cycles:  c01ddf60 
.perf_ctx_unlock (/boot/vmlinux)

0x1b10 [0x188]: event: 9


Changes from V2:

- tools/perf/config/Makefile is moved to the patch tools/perf.
- The patchset is reordered.
- perf_regs_load() function is used for the dwarf unwind test.Since it is not 
required here,
  it is removed from tools/perf/arch/powerpc/include/perf_regs.h
- PERF_REGS_POWERPC_RESULT is removed.





Anju T (3):
  perf/powerpc:add ability to sample intr machine state in power
  perf/powerpc :add support for sampling intr machine state
  tools/perf:Map the ID values with register names

 arch/powerpc/Kconfig|   1 +
 arch/powerpc/include/uapi/asm/perf_regs.h   |  54 +
 arch/powerpc/perf/Makefile  |   2 +
 arch/powerpc/perf/perf_regs.c   |  92 ++
 tools/perf/arch/powerpc/include/perf_regs.h | 114 
 tools/perf/config/Makefile  |   5 ++
 6 files changed, 268 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h
 create mode 100644 arch/powerpc/perf/perf_regs.c
 create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h

-- 
2.1.0

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

[PATCH V3 1/3] perf/powerpc:add ability to sample intr machine state in power

2015-11-02 Thread Anju T
The enum definition assigns an 'id' to each register in "struct pt_regs"
of arch/powerpc.The order of these values in the enum definition are
based on the corresponding macros in
arch/powerpc/include/uapi/asm/ptrace.h .

Signed-off-by: Anju T 
---
 arch/powerpc/include/uapi/asm/perf_regs.h | 54 +++
 1 file changed, 54 insertions(+)
 create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h

diff --git a/arch/powerpc/include/uapi/asm/perf_regs.h 
b/arch/powerpc/include/uapi/asm/perf_regs.h
new file mode 100644
index 000..30fb601
--- /dev/null
+++ b/arch/powerpc/include/uapi/asm/perf_regs.h
@@ -0,0 +1,54 @@
+#ifndef _ASM_POWERPC_PERF_REGS_H
+#define _ASM_POWERPC_PERF_REGS_H
+
+enum perf_event_powerpc_regs {
+   PERF_REG_POWERPC_GPR0,
+   PERF_REG_POWERPC_GPR1,
+   PERF_REG_POWERPC_GPR2,
+   PERF_REG_POWERPC_GPR3,
+   PERF_REG_POWERPC_GPR4,
+   PERF_REG_POWERPC_GPR5,
+   PERF_REG_POWERPC_GPR6,
+   PERF_REG_POWERPC_GPR7,
+   PERF_REG_POWERPC_GPR8,
+   PERF_REG_POWERPC_GPR9,
+   PERF_REG_POWERPC_GPR10,
+   PERF_REG_POWERPC_GPR11,
+   PERF_REG_POWERPC_GPR12,
+   PERF_REG_POWERPC_GPR13,
+   PERF_REG_POWERPC_GPR14,
+   PERF_REG_POWERPC_GPR15,
+   PERF_REG_POWERPC_GPR16,
+   PERF_REG_POWERPC_GPR17,
+   PERF_REG_POWERPC_GPR18,
+   PERF_REG_POWERPC_GPR19,
+   PERF_REG_POWERPC_GPR20,
+   PERF_REG_POWERPC_GPR21,
+   PERF_REG_POWERPC_GPR22,
+   PERF_REG_POWERPC_GPR23,
+   PERF_REG_POWERPC_GPR24,
+   PERF_REG_POWERPC_GPR25,
+   PERF_REG_POWERPC_GPR26,
+   PERF_REG_POWERPC_GPR27,
+   PERF_REG_POWERPC_GPR28,
+   PERF_REG_POWERPC_GPR29,
+   PERF_REG_POWERPC_GPR30,
+   PERF_REG_POWERPC_GPR31,
+   PERF_REG_POWERPC_NIP,
+   PERF_REG_POWERPC_MSR,
+   PERF_REG_POWERPC_ORIG_R3,
+   PERF_REG_POWERPC_CTR,
+   PERF_REG_POWERPC_LNK,
+   PERF_REG_POWERPC_XER,
+   PERF_REG_POWERPC_CCR,
+#ifdef __powerpc64__
+   PERF_REG_POWERPC_SOFTE,
+#else
+   PERF_REG_POWERPC_MQ,
+#endif
+   PERF_REG_POWERPC_TRAP,
+   PERF_REG_POWERPC_DAR,
+   PERF_REG_POWERPC_DSISR,
+   PERF_REG_POWERPC_MAX,
+};
+#endif /* _ASM_POWERPC_PERF_REGS_H */
-- 
2.1.0

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

[PATCH V3 3/3] tools/perf:Map the ID values with register names

2015-11-02 Thread Anju T
Map ID values with corresponding register names.These names are then
displayed when user issues perf record with the -I option
followed by perf report/script with -D option.

Signed-off-by: Anju T 
---
 tools/perf/arch/powerpc/include/perf_regs.h | 114 
 tools/perf/config/Makefile  |   5 ++
 2 files changed, 119 insertions(+)
 create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h

diff --git a/tools/perf/arch/powerpc/include/perf_regs.h 
b/tools/perf/arch/powerpc/include/perf_regs.h
new file mode 100644
index 000..47307ca
--- /dev/null
+++ b/tools/perf/arch/powerpc/include/perf_regs.h
@@ -0,0 +1,114 @@
+#ifndef ARCH_PERF_REGS_H
+#define ARCH_PERF_REGS_H
+
+#include 
+#include 
+#include 
+
+#define PERF_REGS_MASK  ((1ULL << PERF_REG_POWERPC_MAX) - 1)
+#define PERF_REGS_MAX   PERF_REG_POWERPC_MAX
+#define PERF_SAMPLE_REGS_ABI   PERF_SAMPLE_REGS_ABI_64
+
+#define PERF_REG_IP PERF_REG_POWERPC_NIP
+#define PERF_REG_SP PERF_REG_POWERPC_R1
+
+static inline const char *perf_reg_name(int id)
+{
+   switch (id) {
+   case PERF_REG_POWERPC_GPR0:
+   return "gpr0";
+   case PERF_REG_POWERPC_GPR1:
+   return "gpr1";
+   case PERF_REG_POWERPC_GPR2:
+   return "gpr2";
+   case PERF_REG_POWERPC_GPR3:
+   return "gpr3";
+   case PERF_REG_POWERPC_GPR4:
+   return "gpr4";
+   case PERF_REG_POWERPC_GPR5:
+   return "gpr5";
+   case PERF_REG_POWERPC_GPR6:
+   return "gpr6";
+   case PERF_REG_POWERPC_GPR7:
+   return "gpr7";
+   case PERF_REG_POWERPC_GPR8:
+   return "gpr8";
+   case PERF_REG_POWERPC_GPR9:
+   return "gpr9";
+   case PERF_REG_POWERPC_GPR10:
+   return "gpr10";
+   case PERF_REG_POWERPC_GPR11:
+   return "gpr11";
+   case PERF_REG_POWERPC_GPR12:
+   return "gpr12";
+   case PERF_REG_POWERPC_GPR13:
+   return "gpr13";
+   case PERF_REG_POWERPC_GPR14:
+   return "gpr14";
+   case PERF_REG_POWERPC_GPR15:
+   return "gpr15";
+   case PERF_REG_POWERPC_GPR16:
+   return "gpr16";
+   case PERF_REG_POWERPC_GPR17:
+   return "gpr17";
+   case PERF_REG_POWERPC_GPR18:
+   return "gpr18";
+   case PERF_REG_POWERPC_GPR19:
+   return "gpr19";
+   case PERF_REG_POWERPC_GPR20:
+   return "gpr20";
+   case PERF_REG_POWERPC_GPR21:
+   return "gpr21";
+   case PERF_REG_POWERPC_GPR22:
+   return "gpr22";
+   case PERF_REG_POWERPC_GPR23:
+   return "gpr23";
+   case PERF_REG_POWERPC_GPR24:
+   return "gpr24";
+   case PERF_REG_POWERPC_GPR25:
+   return "gpr25";
+   case PERF_REG_POWERPC_GPR26:
+   return "gpr26";
+   case PERF_REG_POWERPC_GPR27:
+   return "gpr27";
+   case PERF_REG_POWERPC_GPR28:
+   return "gpr28";
+   case PERF_REG_POWERPC_GPR29:
+   return "gpr29";
+   case PERF_REG_POWERPC_GPR30:
+   return "gpr30";
+   case PERF_REG_POWERPC_GPR31:
+   return "gpr31";
+   case PERF_REG_POWERPC_NIP:
+   return "nip";
+   case PERF_REG_POWERPC_MSR:
+   return "msr";
+   case PERF_REG_POWERPC_ORIG_R3:
+   return "orig_r3";
+   case PERF_REG_POWERPC_CTR:
+   return "ctr";
+   case PERF_REG_POWERPC_LNK:
+   return "link";
+   case PERF_REG_POWERPC_XER:
+   return "xer";
+   case PERF_REG_POWERPC_CCR:
+   return "ccr";
+#ifdef __powerpc64__
+   case PERF_REG_POWERPC_SOFTE:
+   return "softe";
+#else
+   case PERF_REG_POWERPC_MQ:
+   return "mq";
+#endif
+   case PERF_REG_POWERPC_TRAP:
+   return "trap";
+   case PERF_REG_POWERPC_DAR:
+   return "dar";
+   case PERF_REG_POWERPC_DSISR:
+   return "dsisr";
+   default:
+   return NULL;
+   }
+   return NULL;
+}
+#endif /*ARCH_PERF_REGS_H */
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 38a0853..3db9b5d 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -23,6 +23,11 @@ $(call detected_var,ARCH)
 
 NO_PERF_REGS := 1
 
+#Additional ARCH settings for ppc64
+ifeq ($(ARCH),powerpc)
+   NO_PERF_REGS := 0
+endif
+
 # Additional ARCH settings for x86
 ifeq ($(ARCH),x86)
   $(call detected,CONFIG_X86)
-- 
2.1.0

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

[PATCH V3 2/3] perf/powerpc :add support for sampling intr machine state

2015-11-02 Thread Anju T
The perf infrastructure uses a bit mask to find out
valid registers to display. Define a register mask
for supported registers defined in asm/perf_regs.h.
The bit positions also correspond to register IDs
which is used by perf infrastructure to fetch the register
values.CONFIG_HAVE_PERF_REGS enables
sampling of the interrupted machine state.

Signed-off-by: Anju T 
---
 arch/powerpc/Kconfig  |  1 +
 arch/powerpc/perf/Makefile|  2 +
 arch/powerpc/perf/perf_regs.c | 92 +++
 3 files changed, 95 insertions(+)
 create mode 100644 arch/powerpc/perf/perf_regs.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 9a7057e..c4ce60d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -119,6 +119,7 @@ config PPC
select GENERIC_ATOMIC64 if PPC32
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
select HAVE_PERF_EVENTS
+   select HAVE_PERF_REGS
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64
select ARCH_WANT_IPC_PARSE_VERSION
diff --git a/arch/powerpc/perf/Makefile b/arch/powerpc/perf/Makefile
index f9c083a..cbae78a 100644
--- a/arch/powerpc/perf/Makefile
+++ b/arch/powerpc/perf/Makefile
@@ -7,6 +7,8 @@ obj64-$(CONFIG_PPC_PERF_CTRS)   += power4-pmu.o ppc970-pmu.o 
power5-pmu.o \
   power5+-pmu.o power6-pmu.o power7-pmu.o \
   power8-pmu.o
 obj32-$(CONFIG_PPC_PERF_CTRS)  += mpc7450-pmu.o
+obj-$(CONFIG_PERF_EVENTS)  += perf_regs.o
+
 
 obj-$(CONFIG_FSL_EMB_PERF_EVENT) += core-fsl-emb.o
 obj-$(CONFIG_FSL_EMB_PERF_EVENT_E500) += e500-pmu.o e6500-pmu.o
diff --git a/arch/powerpc/perf/perf_regs.c b/arch/powerpc/perf/perf_regs.c
new file mode 100644
index 000..0520492
--- /dev/null
+++ b/arch/powerpc/perf/perf_regs.c
@@ -0,0 +1,92 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define PT_REGS_OFFSET(id, r) [id] = offsetof(struct pt_regs, r)
+
+#define REG_RESERVED (~((1ULL << PERF_REG_POWERPC_MAX) - 1))
+
+static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = {
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR0, gpr[0]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR1, gpr[1]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR2, gpr[2]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR3, gpr[3]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR4, gpr[4]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR5, gpr[5]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR6, gpr[6]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR7, gpr[7]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR8, gpr[8]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR9, gpr[9]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR10, gpr[10]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR11, gpr[11]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR12, gpr[12]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR13, gpr[13]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR14, gpr[14]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR15, gpr[15]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR16, gpr[16]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR17, gpr[17]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR18, gpr[18]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR19, gpr[19]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR20, gpr[20]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR21, gpr[21]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR22, gpr[22]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR23, gpr[23]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR24, gpr[24]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR25, gpr[25]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR26, gpr[26]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR27, gpr[27]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR28, gpr[28]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR29, gpr[29]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR30, gpr[30]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_GPR31, gpr[31]),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_NIP, nip),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_MSR, msr),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_ORIG_R3, orig_gpr3),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_CTR, ctr),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_LNK, link),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_XER, xer),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_CCR, ccr),
+#ifdef __powerpc64__
+   PT_REGS_OFFSET(PERF_REG_POWERPC_SOFTE, softe),
+#else
+   PT_REGS_OFFSET(PERF_REG_POWERPC_MQ, mq),
+#endif
+   PT_REGS_OFFSET(PERF_REG_POWERPC_TRAP, trap),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_DAR, dar),
+   PT_REGS_OFFSET(PERF_REG_POWERPC_DSISR, dsisr),
+};
+
+u64 perf_reg_value(struct pt_regs *regs, int idx)
+{
+   if (WARN_ON_ONCE(idx >= PERF_REG_POWERPC_MAX))
+   return 0;
+   return regs_get_register(regs, pt_regs_offset[idx]);
+}
+
+int perf_reg_validate(u64 mask)
+{
+   if (!mask || mask & REG_RESERVED)
+   return -EINVAL;
+   return 0;
+}

RE: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence

2015-11-02 Thread Dogra Raghav


-Original Message-
From: Wood Scott-B07421 
Sent: Tuesday, November 03, 2015 11:10 AM
To: Dogra Raghav-B46184 
Cc: Kushwaha Prabhakar-B32579 ; 
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence

On Mon, 2015-11-02 at 23:31 -0600, Dogra Raghav-B46184 wrote:
> 
> -Original Message-
> From: Wood Scott-B07421
> Sent: Tuesday, November 03, 2015 4:31 AM
> To: Dogra Raghav-B46184 
> Cc: Kushwaha Prabhakar-B32579 ; 
> linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry 
> sequence
> 
> On Mon, 2015-11-02 at 00:12 -0600, Dogra Raghav-B46184 wrote:
> > -Original Message-
> > From: Raghav Dogra [mailto:rag...@freescale.com]
> > Sent: Friday, October 30, 2015 11:55 AM
> > To: linuxppc-dev@lists.ozlabs.org
> > Cc: Wood Scott-B07421 ; Kushwaha
> > Prabhakar-B32579 < prabha...@freescale.com>; Dogra Raghav-B46184 
> > 
> > Subject: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry 
> > sequence
> > 
> > Modify platform driver suspend/resume to syscore suspend/resume. 
> > This is because p1022ds needs to use localbus when entering the PCIE resume.
> > 
> > Signed-off-by: Raghav Dogra 
> > ---
> >  arch/powerpc/sysdev/Makefile  |  2 +-  
> > arch/powerpc/sysdev/fsl_lbc.c
> > > 51 +---
> > ---
> >  2 files changed, 40 insertions(+), 13 deletions(-)
> > 
> > diff --git a/arch/powerpc/sysdev/Makefile 
> > b/arch/powerpc/sysdev/Makefile index f7cb2a1..4c19e614 100644
> > --- a/arch/powerpc/sysdev/Makefile
> > +++ b/arch/powerpc/sysdev/Makefile
> > @@ -18,9 +18,9 @@ obj-$(CONFIG_PPC_PMI)   += pmi.o
> >  obj-$(CONFIG_U3_DART)+= dart_iommu.o
> >  obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
> >  obj-$(CONFIG_FSL_SOC)+= fsl_soc.o fsl_mpic_err.o
> > +obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
> >  obj-$(CONFIG_FSL_PCI)+= fsl_pci.o $(fsl-msi-obj-y)
> >  obj-$(CONFIG_FSL_PMC)+= fsl_pmc.o
> > -obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
> >  obj-$(CONFIG_FSL_GTM)+= fsl_gtm.o
> >  obj-$(CONFIG_FSL_85XX_CACHE_SRAM)+= fsl_85xx_l2ctlr.o 
> > fsl_85xx_cache_sram.o
> >  obj-$(CONFIG_SIMPLE_GPIO)+= simple_gpio.o
> > diff --git a/arch/powerpc/sysdev/fsl_lbc.c 
> > b/arch/powerpc/sysdev/fsl_lbc.c index d631022..332d700 100644
> > --- a/arch/powerpc/sysdev/fsl_lbc.c
> > +++ b/arch/powerpc/sysdev/fsl_lbc.c
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  
> > @@ -354,24 +355,42 @@ err:
> >  #ifdef CONFIG_SUSPEND
> >  
> >  /* save lbc registers */
> > -static int fsl_lbc_suspend(struct platform_device *pdev, 
> > pm_message_t
> > state)
> > +static int fsl_lbc_syscore_suspend(void)
> >  {
> > - struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(>dev);
> > - struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
> > + struct fsl_lbc_ctrl *ctrl;
> > + struct fsl_lbc_regs __iomem *lbc;
> > +
> > + ctrl = fsl_lbc_ctrl_dev;
> > + if (!ctrl)
> > + goto out;
> > +
> > + lbc = ctrl->regs;
> > + if (!lbc)
> > + goto out;
> >  
> >   ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL);
> >   if (!ctrl->saved_regs)
> >   return -ENOMEM;
> > [Dogra Raghav-B46184] This is the existing upstream code. Are you 
> > suggesting to modify the upstream code to take care of individual 
> > registers?
> 
> What specifically do you mean by "the upstream code"?  What other tree 
> are we talking about here?
> 
> -Scott
> 
> I meant that these two lines of code are not being added or modified 
> by this patch. They already exist in the upstream tree. Are you 
> suggesting I modify them as well?
> -Raghav

I have no idea which "two lines of code" you're talking about or how any 
comment I made applies to the above diff hunk.

OK, I looked at the original patch and I guess you're talking about the
_memcpy_fromio() that was *below* your comment?  Please configure your mailer 
to quote properly, and put your replies below what you're quoting.

Yes, I think that that usage of _memcpy_fromio() is bad and should be changed.

-Scott

Ok, I will take care that the replies are below what I am quoting in future. 
Can this patch be applied as it is then? The changes you are suggesting can 
come in a new patch.

-Raghav

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

[PATCH 3/4] powerpc/perf: Rename some Power8 events

2015-11-02 Thread Sukadev Bhattiprolu
Rename following events to be consistent with the specs.
PM_L1_PREF to PM_LSU_L1_PREF
PM_PPC_CMPL to PM_INST_CMPL

Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/perf/power8-events-list.h | 2 +-
 arch/powerpc/perf/power8-pmu.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/perf/power8-events-list.h 
b/arch/powerpc/perf/power8-events-list.h
index 3262e26..69b1a25 100644
--- a/arch/powerpc/perf/power8-events-list.h
+++ b/arch/powerpc/perf/power8-events-list.h
@@ -21,7 +21,7 @@ EVENT(PM_BR_MPRED_CMPL,   0x400f6)
 EVENT(PM_LD_REF_L1,0x100ee)
 EVENT(PM_LD_MISS_L1,   0x3e054)
 EVENT(PM_ST_MISS_L1,   0x300f0)
-EVENT(PM_L1_PREF,  0x0d8b8)
+EVENT(PM_LSU_L1_PREF,  0x0d8b8)
 EVENT(PM_INST_FROM_L1, 0x04080)
 EVENT(PM_L1_ICACHE_MISS,   0x200fd)
 EVENT(PM_L1_DEMAND_WRITE,  0x0408c)
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
index 11848af..b453eb9 100644
--- a/arch/powerpc/perf/power8-pmu.c
+++ b/arch/powerpc/perf/power8-pmu.c
@@ -552,11 +552,11 @@ static int power8_get_alternatives(u64 event, unsigned 
int flags, u64 alt[])
case 0x600f4:   /* PM_RUN_CYC */
alt[j++] = 0x1e;
break;
-   case 0x2:   /* PM_PPC_CMPL */
+   case 0x2:   /* PM_INST_CMPL */
alt[j++] = 0x500fa; /* PM_RUN_INST_CMPL */
break;
case 0x500fa:   /* PM_RUN_INST_CMPL */
-   alt[j++] = 0x2; /* PM_PPC_CMPL */
+   alt[j++] = 0x2; /* PM_INST_CMPL */
break;
}
}
@@ -709,7 +709,7 @@ static int 
power8_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
[ C(RESULT_MISS)   ] = PM_ST_MISS_L1,
},
[ C(OP_PREFETCH) ] = {
-   [ C(RESULT_ACCESS) ] = PM_L1_PREF,
+   [ C(RESULT_ACCESS) ] = PM_LSU_L1_PREF,
[ C(RESULT_MISS)   ] = 0,
},
},
-- 
2.5.3

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

Re: [net-next v4 6/8] dpaa_eth: add ethtool statistics

2015-11-02 Thread Joe Perches
On Mon, 2015-11-02 at 19:31 +0200, Madalin Bucur wrote:
> Add a series of counters to be exported through ethtool:
> - add detailed counters for reception errors;
> - add detailed counters for QMan enqueue reject events;
> - count the number of fragmented skbs received from the stack;
> - count all frames received on the Tx confirmation path;
> - add congestion group statistics;
> - count the number of interrupts for each CPU.
[]
> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c 
> b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
[]
> +static void dpa_get_strings(struct net_device *net_dev, u32 stringset, u8 
> *data)
> +{
> + unsigned int i, j, num_cpus, size;
> + char string_cpu[ETH_GSTRING_LEN];
> + u8 *strings;
> +
> + strings   = data;
> + num_cpus  = num_online_cpus();
> + size  = DPA_STATS_GLOBAL_LEN * ETH_GSTRING_LEN;
> +
> + for (i = 0; i < DPA_STATS_PERCPU_LEN; i++) {
> + for (j = 0; j < num_cpus; j++) {
> + snprintf(string_cpu, ETH_GSTRING_LEN, "%s [CPU %d]",
> +  dpa_stats_percpu[i], j);
> + memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> + strings += ETH_GSTRING_LEN;
> + }
> + snprintf(string_cpu, ETH_GSTRING_LEN, "%s [TOTAL]",
> +  dpa_stats_percpu[i]);
> + memcpy(strings, string_cpu, ETH_GSTRING_LEN);
> + strings += ETH_GSTRING_LEN;
> + }
> + memcpy(strings, dpa_stats_global, size);
> +}

This leaks uninitialized stack via a memcpy of uninitialized
string_cpu bytes into user-space.

Using
char string_cpu[ETH_GSTRING_LEN] = {};
or a memset before each snprintf would fix it.


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

Re: [net-next v4 2/8] dpaa_eth: add support for DPAA Ethernet

2015-11-02 Thread Joe Perches
On Mon, 2015-11-02 at 19:31 +0200, Madalin Bucur wrote:
> This introduces the Freescale Data Path Acceleration Architecture
> (DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
> BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
> the Freescale DPAA QorIQ platforms.
[]
> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
> b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
[]
> +static void _dpa_rx_error(struct net_device *net_dev,
> +   const struct dpa_priv_s *priv,
> +   struct dpa_percpu_priv_s *percpu_priv,
> +   const struct qm_fd *fd,
> +   u32 fqid)
> +{
> + /* limit common, possibly innocuous Rx FIFO Overflow errors'
> +  * interference with zero-loss convergence benchmark results.
> +  */
> + if (likely(fd->status & FM_FD_ERR_PHYSICAL))
> + pr_warn_once("non-zero error counters in fman statistics 
> (sysfs)\n");
> + else
> + if (net_ratelimit())
> + netif_err(priv, hw, net_dev, "Err FD status = 0x%08x\n",
> +   fd->status & FM_FD_STAT_RX_ERRORS);

It's a bit of a pity the logging message code is
a mix of pr_, dev_, netdev_
and netif_

Perhaps netif__ratelimited macros should be added.

Something like:

---
 include/linux/netdevice.h | 54 +++
 1 file changed, 54 insertions(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 210d11a..555471d 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4025,6 +4025,60 @@ do { 
\
 })
 #endif
 
+#define netif_level_ratelimited(level, priv, type, dev, fmt, args...)  \
+do {   \
+   if (netif_msg_##type(priv) && net_ratelimit())  \
+   netdev_##level(dev, fmt, ##args);   \
+} while (0)
+
+#define netif_emerg_ratelimited(priv, type, dev, fmt, args...) \
+   netif_level_ratelimited(emerg, priv, type, dev, fmt, ##args)
+#define netif_alert_ratelimited(priv, type, dev, fmt, args...) \
+   netif_level_ratelimited(alert, priv, type, dev, fmt, ##args)
+#define netif_crit_ratelimited(priv, type, dev, fmt, args...)  \
+   netif_level_ratelimited(crit, priv, type, dev, fmt, ##args)
+#define netif_err_ratelimited(priv, type, dev, fmt, args...)   \
+   netif_level_ratelimited(err, priv, type, dev, fmt, ##args)
+#define netif_warn_ratelimited(priv, type, dev, fmt, args...)  \
+   netif_level_ratelimited(warn, priv, type, dev, fmt, ##args)
+#define netif_notice_ratelimited(priv, type, dev, fmt, args...)
\
+   netif_level_ratelimited(notice, priv, type, dev, fmt, ##args)
+#define netif_info_ratelimited(priv, type, dev, fmt, args...)  \
+   netif_level_ratelimited(info, priv, type, dev, fmt, ##args)
+
+#if defined(CONFIG_DYNAMIC_DEBUG)
+/* descriptor check is first to prevent flooding with "callbacks suppressed" */
+#define netif_dbg_ratelimited(priv, type, dev, fmt, args...)   \
+do {   \
+   DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
+   if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&\
+   netif_msg_##type(priv) && net_ratelimit())  \
+   __dynamic_netdev_dbg(, dev, fmt, ##args);\
+} while (0)
+#elif defined(DEBUG)
+#define netif_dbg_ratelimited(priv, type, dev, fmt, args...)   \
+do {   \
+   if (netif_msg_##type(priv) && net_ratelimit())  \
+   netif_printk(priv, type, KERN_DEBUG, dev, fmt, ##args); \
+} while (0)
+#else
+#define netif_dbg_ratelimited(priv, type, dev, fmt, args...)   \
+do {   \
+   if (0)  \
+   netif_printk(priv, type, KERN_DEBUG, dev, fmt, ##args); \
+} while (0)
+#endif
+
+#if defined(VERBOSE_DEBUG)
+#define netif_vdbg_ratelimited netif_dbg_ratelimited
+#else
+#define netif_vdbg(priv, type, dev, fmt, args...)  \
+do {   \
+   if (0)  \
+   netif_printk(priv, type, KERN_DEBUG, dev, fmt, ##args); \
+} while (0)
+#endif
+
 /*
  * The list of packet types we will receive (as opposed to discard)
  * and the routines to invoke.


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

[PATCH 0/4] powerpc/perf: Export Power8 PMU events in sysfs

2015-11-02 Thread Sukadev Bhattiprolu
For consistency with Power7, export Power8 PMU events in sysfs.
This would also allow users to specify the PMU events by name:

perf stat -e 'cpu/PM_VSU1_FPSCR/' sleep 1

Sukadev Bhattiprolu (4):
  powerpc/perf: Remove PME_ prefix for power7 events
  powerpc/perf: Export Power8 generic and cache events in sysfs
  perf/powerpc: Rename some Power8 events
  powerpc/perf: Export all Power8 PMU events in sysfs

 arch/powerpc/include/asm/perf_event_server.h |2 +-
 arch/powerpc/perf/power7-pmu.c   |   18 +-
 arch/powerpc/perf/power8-events-list.h   | 1077 ++
 arch/powerpc/perf/power8-pmu.c   |   82 +-
 4 files changed, 1128 insertions(+), 51 deletions(-)
 create mode 100644 arch/powerpc/perf/power8-events-list.h

-- 
2.5.3

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

[PATCH 1/4] powerpc/perf: Remove PME_ prefix for power7 events

2015-11-02 Thread Sukadev Bhattiprolu
We used the PME_ prefix earlier to avoid some macro/variable name
collisions.  We have since changed the way we define/use the event
macros so we no longer need the prefix.

By dropping the prefix, we keep the the event macros consistent with
their official names.

Reported-by: Michael Ellerman 
Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/include/asm/perf_event_server.h |  2 +-
 arch/powerpc/perf/power7-pmu.c   | 18 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/include/asm/perf_event_server.h 
b/arch/powerpc/include/asm/perf_event_server.h
index 8146221..0691087 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -141,7 +141,7 @@ extern ssize_t power_events_sysfs_show(struct device *dev,
 #defineEVENT_PTR(_id, _suffix) _VAR(_id, 
_suffix).attr.attr
 
 #defineEVENT_ATTR(_name, _id, _suffix) 
\
-   PMU_EVENT_ATTR(_name, EVENT_VAR(_id, _suffix), PME_##_id,   \
+   PMU_EVENT_ATTR(_name, EVENT_VAR(_id, _suffix), _id, \
power_events_sysfs_show)
 
 #defineGENERIC_EVENT_ATTR(_name, _id)  EVENT_ATTR(_name, _id, _g)
diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c
index 5b62f238..a383c23 100644
--- a/arch/powerpc/perf/power7-pmu.c
+++ b/arch/powerpc/perf/power7-pmu.c
@@ -54,7 +54,7 @@
  * Power7 event codes.
  */
 #define EVENT(_name, _code) \
-   PME_##_name = _code,
+   _name = _code,
 
 enum {
 #include "power7-events-list.h"
@@ -318,14 +318,14 @@ static void power7_disable_pmc(unsigned int pmc, unsigned 
long mmcr[])
 }
 
 static int power7_generic_events[] = {
-   [PERF_COUNT_HW_CPU_CYCLES] =PME_PM_CYC,
-   [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =   PME_PM_GCT_NOSLOT_CYC,
-   [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =PME_PM_CMPLU_STALL,
-   [PERF_COUNT_HW_INSTRUCTIONS] =  PME_PM_INST_CMPL,
-   [PERF_COUNT_HW_CACHE_REFERENCES] =  PME_PM_LD_REF_L1,
-   [PERF_COUNT_HW_CACHE_MISSES] =  PME_PM_LD_MISS_L1,
-   [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] =   PME_PM_BRU_FIN,
-   [PERF_COUNT_HW_BRANCH_MISSES] = PME_PM_BR_MPRED,
+   [PERF_COUNT_HW_CPU_CYCLES] =PM_CYC,
+   [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =   PM_GCT_NOSLOT_CYC,
+   [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =PM_CMPLU_STALL,
+   [PERF_COUNT_HW_INSTRUCTIONS] =  PM_INST_CMPL,
+   [PERF_COUNT_HW_CACHE_REFERENCES] =  PM_LD_REF_L1,
+   [PERF_COUNT_HW_CACHE_MISSES] =  PM_LD_MISS_L1,
+   [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] =   PM_BRU_FIN,
+   [PERF_COUNT_HW_BRANCH_MISSES] = PM_BR_MPRED,
 };
 
 #define C(x)   PERF_COUNT_HW_CACHE_##x
-- 
2.5.3

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

Re: [net-next v4 1/8] devres: add devm_alloc_percpu()

2015-11-02 Thread Joe Perches
On Mon, 2015-11-02 at 19:31 +0200, Madalin Bucur wrote:
> Introduce managed counterparts for alloc_percpu() and free_percpu().
> Add devm_alloc_percpu() and devm_free_percpu() into the managed
> interfaces list.

trivia, could be fixed later

> +/**
> + * __devm_alloc_percpu - Resource-managed alloc_percpu
> + * @dev: Device to allocate per-cpu memory for
> + * @size: Size of per-cpu memory to allocate
> + * @align: Alignement of per-cpu memory to allocate

French spelling?  alignment


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

Re: [net-next v4 3/8] dpaa_eth: add support for S/G frames

2015-11-02 Thread Joe Perches
On Mon, 2015-11-02 at 19:31 +0200, Madalin Bucur wrote:
> Add support for Scater/Gather (S/G) frames. The FMan can place
> the frame content into multiple buffers and provide a S/G Table
> (SGT) into one first buffer with references to the others.

trivia: scatter

> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c 
> b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
[]
> @@ -1177,10 +1177,42 @@ void dpaa_eth_init_ports(struct mac_device *mac_dev,
> port_fqs->rx_defq, _layout[RX]);
>  }
>  
> +void dpa_release_sgt(struct qm_sg_entry *sgt)
> +{
> + struct dpa_bp *dpa_bp;
> + struct bm_buffer bmb[DPA_BUFF_RELEASE_MAX];

Where is "struct bm_buffer" defined?


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

[PATCH 4/4] powerpc/perf: Export all Power8 PMU events in sysfs

2015-11-02 Thread Sukadev Bhattiprolu
Export all Power8-specific PMU events in sysfs. These will be visible
in /sys/devices/cpu/events and can be used with perf:

perf record -e 'cpu/PM_GCT_NOSLOT_CYC/' ...

Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/perf/power8-events-list.h | 1076 +++-
 1 file changed, 1059 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/perf/power8-events-list.h 
b/arch/powerpc/perf/power8-events-list.h
index 69b1a25..4b37b3b 100644
--- a/arch/powerpc/perf/power8-events-list.h
+++ b/arch/powerpc/perf/power8-events-list.h
@@ -12,24 +12,1066 @@
 /*
  * Power8 event codes.
  */
-EVENT(PM_CYC,  0x0001e)
-EVENT(PM_GCT_NOSLOT_CYC,   0x100f8)
-EVENT(PM_CMPLU_STALL,  0x4000a)
-EVENT(PM_INST_CMPL,0x2)
+EVENT(PM_1LPAR_CYC,0x1F05E)
+EVENT(PM_1PLUS_PPC_CMPL,   0x100F2)
+EVENT(PM_1PLUS_PPC_DISP,   0x400F2)
+EVENT(PM_2LPAR_CYC,0x2006E)
+EVENT(PM_4LPAR_CYC,0x4E05E)
+EVENT(PM_ALL_CHIP_PUMP_CPRED,  0x610050)
+EVENT(PM_ALL_GRP_PUMP_CPRED,   0x520050)
+EVENT(PM_ALL_GRP_PUMP_MPRED,   0x620052)
+EVENT(PM_ALL_GRP_PUMP_MPRED_RTY,   0x610052)
+EVENT(PM_ALL_PUMP_CPRED,   0x610054)
+EVENT(PM_ALL_PUMP_MPRED,   0x640052)
+EVENT(PM_ALL_SYS_PUMP_CPRED,   0x630050)
+EVENT(PM_ALL_SYS_PUMP_MPRED,   0x630052)
+EVENT(PM_ALL_SYS_PUMP_MPRED_RTY,   0x640050)
+EVENT(PM_ANY_THRD_RUN_CYC, 0x100FA)
+EVENT(PM_BACK_BR_CMPL, 0x2505E)
+EVENT(PM_BANK_CONFLICT,0x04082)
+EVENT(PM_BR_2PATH, 0x20036)
+EVENT(PM_BR_BC_8,  0x05086)
+EVENT(PM_BR_BC_8_CONV, 0x05084)
+EVENT(PM_BR_CMPL,  0x40060)
+EVENT(PM_BR_MPRED_CCACHE,  0x040AC)
+EVENT(PM_BR_MPRED_CMPL,0x400F6)
+EVENT(PM_BR_MPRED_CR,  0x040B8)
+EVENT(PM_BR_MPRED_LSTACK,  0x040AE)
+EVENT(PM_BR_MPRED_TA,  0x040BA)
+EVENT(PM_BR_MRK_2PATH, 0x10138)
+EVENT(PM_BR_PRED_BR0,  0x0409C)
+EVENT(PM_BR_PRED_BR1,  0x0409E)
+EVENT(PM_BR_PRED_BR_CMPL,  0x0489C)
+EVENT(PM_BR_PRED_CCACHE_BR0,   0x040A4)
+EVENT(PM_BR_PRED_CCACHE_BR1,   0x040A6)
+EVENT(PM_BR_PRED_CCACHE_CMPL,  0x048A4)
+EVENT(PM_BR_PRED_CR_BR0,   0x040B0)
+EVENT(PM_BR_PRED_CR_BR1,   0x040B2)
+EVENT(PM_BR_PRED_CR_CMPL,  0x048B0)
+EVENT(PM_BR_PRED_LSTACK_BR0,   0x040A8)
+EVENT(PM_BR_PRED_LSTACK_BR1,   0x040AA)
+EVENT(PM_BR_PRED_LSTACK_CMPL,  0x048A8)
+EVENT(PM_BR_PRED_TA_BR0,   0x040B4)
+EVENT(PM_BR_PRED_TA_BR1,   0x040B6)
+EVENT(PM_BR_PRED_TA_CMPL,  0x048B4)
+EVENT(PM_BR_TAKEN_CMPL,0x200FA)
 EVENT(PM_BRU_FIN,  0x10068)
-EVENT(PM_BR_MPRED_CMPL,0x400f6)
-EVENT(PM_LD_REF_L1,0x100ee)
-EVENT(PM_LD_MISS_L1,   0x3e054)
-EVENT(PM_ST_MISS_L1,   0x300f0)
-EVENT(PM_LSU_L1_PREF,  0x0d8b8)
+EVENT(PM_BR_UNCOND_BR0,0x040A0)
+EVENT(PM_BR_UNCOND_BR1,0x040A2)
+EVENT(PM_BR_UNCOND_CMPL,   0x048A0)
+EVENT(PM_CASTOUT_ISSUED,   0x03094)
+EVENT(PM_CASTOUT_ISSUED_GPR,   0x03096)
+EVENT(PM_CHIP_PUMP_CPRED,  0x10050)
+EVENT(PM_CLB_HELD, 0x02090)
+EVENT(PM_CMPLU_STALL,  0x4000A)
+EVENT(PM_CMPLU_STALL_BRU,  0x4D018)
+EVENT(PM_CMPLU_STALL_BRU_CRU,  0x2D018)
+EVENT(PM_CMPLU_STALL_COQ_FULL, 0x30026)
+EVENT(PM_CMPLU_STALL_DCACHE_MISS,  0x2C012)
+EVENT(PM_CMPLU_STALL_DMISS_L21_L31,0x2C018)
+EVENT(PM_CMPLU_STALL_DMISS_L2L3,   0x2C016)
+EVENT(PM_CMPLU_STALL_DMISS_L2L3_CONFLICT,  0x4C016)
+EVENT(PM_CMPLU_STALL_DMISS_L3MISS, 0x4C01A)
+EVENT(PM_CMPLU_STALL_DMISS_LMEM,   0x4C018)
+EVENT(PM_CMPLU_STALL_DMISS_REMOTE, 0x2C01C)
+EVENT(PM_CMPLU_STALL_ERAT_MISS,0x4C012)
+EVENT(PM_CMPLU_STALL_FLUSH,0x30038)
+EVENT(PM_CMPLU_STALL_FXLONG,   0x4D016)
+EVENT(PM_CMPLU_STALL_FXU,  0x2D016)

[PATCH 2/4] powerpc/perf: Export Power8 generic and cache events in sysfs

2015-11-02 Thread Sukadev Bhattiprolu
Export generic and cache perf events for Power8 in sysfs.

Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/perf/power8-events-list.h | 35 
 arch/powerpc/perf/power8-pmu.c | 76 +-
 2 files changed, 73 insertions(+), 38 deletions(-)
 create mode 100644 arch/powerpc/perf/power8-events-list.h

diff --git a/arch/powerpc/perf/power8-events-list.h 
b/arch/powerpc/perf/power8-events-list.h
new file mode 100644
index 000..3262e26
--- /dev/null
+++ b/arch/powerpc/perf/power8-events-list.h
@@ -0,0 +1,35 @@
+/*
+ * Performance counter support for POWER8 processors.
+ *
+ * Copyright 2014 Sukadev Bhattiprolu, IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+/*
+ * Power8 event codes.
+ */
+EVENT(PM_CYC,  0x0001e)
+EVENT(PM_GCT_NOSLOT_CYC,   0x100f8)
+EVENT(PM_CMPLU_STALL,  0x4000a)
+EVENT(PM_INST_CMPL,0x2)
+EVENT(PM_BRU_FIN,  0x10068)
+EVENT(PM_BR_MPRED_CMPL,0x400f6)
+EVENT(PM_LD_REF_L1,0x100ee)
+EVENT(PM_LD_MISS_L1,   0x3e054)
+EVENT(PM_ST_MISS_L1,   0x300f0)
+EVENT(PM_L1_PREF,  0x0d8b8)
+EVENT(PM_INST_FROM_L1, 0x04080)
+EVENT(PM_L1_ICACHE_MISS,   0x200fd)
+EVENT(PM_L1_DEMAND_WRITE,  0x0408c)
+EVENT(PM_IC_PREF_WRITE,0x0408e)
+EVENT(PM_DATA_FROM_L3, 0x4c042)
+EVENT(PM_DATA_FROM_L3MISS, 0x300fe)
+EVENT(PM_L2_ST,0x17080)
+EVENT(PM_L2_ST_MISS,   0x17082)
+EVENT(PM_L3_PREF_ALL,  0x4e052)
+EVENT(PM_DTLB_MISS,0x300fc)
+EVENT(PM_ITLB_MISS,0x400fc)
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
index 396351d..11848af 100644
--- a/arch/powerpc/perf/power8-pmu.c
+++ b/arch/powerpc/perf/power8-pmu.c
@@ -17,48 +17,16 @@
 #include 
 #include 
 
-
 /*
  * Some power8 event codes.
  */
-#define PM_CYC 0x0001e
-#define PM_GCT_NOSLOT_CYC  0x100f8
-#define PM_CMPLU_STALL 0x4000a
-#define PM_INST_CMPL   0x2
-#define PM_BRU_FIN 0x10068
-#define PM_BR_MPRED_CMPL   0x400f6
-
-/* All L1 D cache load references counted at finish, gated by reject */
-#define PM_LD_REF_L1   0x100ee
-/* Load Missed L1 */
-#define PM_LD_MISS_L1  0x3e054
-/* Store Missed L1 */
-#define PM_ST_MISS_L1  0x300f0
-/* L1 cache data prefetches */
-#define PM_L1_PREF 0x0d8b8
-/* Instruction fetches from L1 */
-#define PM_INST_FROM_L10x04080
-/* Demand iCache Miss */
-#define PM_L1_ICACHE_MISS  0x200fd
-/* Instruction Demand sectors wriittent into IL1 */
-#define PM_L1_DEMAND_WRITE 0x0408c
-/* Instruction prefetch written into IL1 */
-#define PM_IC_PREF_WRITE   0x0408e
-/* The data cache was reloaded from local core's L3 due to a demand load */
-#define PM_DATA_FROM_L30x4c042
-/* Demand LD - L3 Miss (not L2 hit and not L3 hit) */
-#define PM_DATA_FROM_L3MISS0x300fe
-/* All successful D-side store dispatches for this thread */
-#define PM_L2_ST   0x17080
-/* All successful D-side store dispatches for this thread that were L2 Miss */
-#define PM_L2_ST_MISS  0x17082
-/* Total HW L3 prefetches(Load+store) */
-#define PM_L3_PREF_ALL 0x4e052
-/* Data PTEG reload */
-#define PM_DTLB_MISS   0x300fc
-/* ITLB Reloaded */
-#define PM_ITLB_MISS   0x400fc
+#define EVENT(_name, _code)_name = _code,
+
+enum {
+#include "power8-events-list.h"
+};
 
+#undef EVENT
 
 /*
  * Raw event encoding for POWER8:
@@ -604,6 +572,37 @@ static void power8_disable_pmc(unsigned int pmc, unsigned 
long mmcr[])
mmcr[1] &= ~(0xffUL << MMCR1_PMCSEL_SHIFT(pmc + 1));
 }
 
+GENERIC_EVENT_ATTR(cpu-cyles,  PM_CYC);
+GENERIC_EVENT_ATTR(stalled-cycles-frontend,PM_GCT_NOSLOT_CYC);
+GENERIC_EVENT_ATTR(stalled-cycles-backend, PM_CMPLU_STALL);
+GENERIC_EVENT_ATTR(instructions,   PM_INST_CMPL);
+GENERIC_EVENT_ATTR(branch-instructions,PM_BRU_FIN);
+GENERIC_EVENT_ATTR(branch-misses,  PM_BR_MPRED_CMPL);
+
+#define EVENT(_name, _code)POWER_EVENT_ATTR(_name, _name);
+#include 

Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence

2015-11-02 Thread Scott Wood
On Tue, 2015-11-03 at 00:33 -0600, Dogra Raghav-B46184 wrote:
> Hi Scott,
> 
> I just checked on patchwork and noticed that the original patch has been 
> modified as somehow my original comment has become part of the patch:
> + if (!lbc)
> + goto out;
>  
>   ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL);
>   if (!ctrl->saved_regs)
>   return -ENOMEM;
> [Dogra Raghav-B46184] This is the existing upstream code. Are you 
> suggesting to modify the upstream code to take care of individual registers?
>  
>   _memcpy_fromio(ctrl->saved_regs, lbc, sizeof(struct fsl_lbc_regs));
> +
> The patchwork is also showing two links for the patch. Please apply the 
> original patch present at:
> https://patchwork.ozlabs.org/patch/538605/
> 
> I will look into how this happened to avoid such incidents in future.

Your reply looked like a new patch, so Patchwork treated it as such.  If you 
fix your mailer to use proper quote markers (the > at the beginning of each 
line) then this won't happen.

-Scott

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

Re: [PATCH V4 00/31] powerpc/mm: Update page table format for book3s 64

2015-11-02 Thread Aneesh Kumar K.V
Denis Kirjanov  writes:

> On 10/23/15, Aneesh Kumar K.V  wrote:
>> Denis Kirjanov  writes:
>>
>>> On 10/17/15, Aneesh Kumar K.V  wrote:
 Hi All,

 This patch series attempt to update book3s 64 linux page table format to
 make it more flexible. Our current pte format is very restrictive and we
 overload multiple pte bits. This is due to the non-availability of free
 bits
 in pte_t. We use pte_t to track the validity of 4K subpages. This patch
 series free up pte_t of 11 bits by moving 4K subpage tracking to the
 lower half of PTE page. The pte format is updated such that we have a
 better method for identifying a pte entry at pmd level. This will also
 enable
 us to implement hugetlb migration(not yet done in this series).
>>>
>>> Hi, what tree does this apply to?
>>>
>>
>> linux-powerpc tree -next branch
>>
>> https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/
>
> Ok, but I'm getting the following error after applying the first patch
> from your series:
>
> error: patch failed: arch/powerpc/include/asm/pgalloc-64.h:166
> error: arch/powerpc/include/asm/pgalloc-64.h: patch does not apply
> error: arch/powerpc/mm/hash64_64k.c: No such file or directory
>
> kda@hydra ~/devel/linux $ git branch
>   master
> * next
> kda@hydra ~/devel/linux $ git remote show origin
> * remote origin
>   Fetch URL: git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git
>   Push  URL: git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git
>
> Or am I missing something?


Why not use

The patch series can also be found at
https://github.com/kvaneesh/linux.git book3s-pte-format 
https://github.com/kvaneesh/linux/commits/book3s-pte-format


-aneesh

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

Re: [RFC PATCH 0/7] Remove 4k subpage tracking with hash 64K config

2015-11-02 Thread Aneesh Kumar K.V
Paul Mackerras  writes:

> On Wed, Oct 21, 2015 at 01:42:26AM +0530, Aneesh Kumar K.V wrote:
>> Hi,
>> 
>> This patch series is on top of the series posted at 
>> 
>> https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-October/135299.html
>> "[PATCH V4 00/31] powerpc/mm: Update page table format for book3s 64". In 
>> this
>> series we remove 4k subpage tracking with 64K config. Instead we do a hash
>> table lookup to get the slot information of 4k hash ptes. This also allow us
>> to remove real_pte_t. Side effect of the change is that a specific 4k slot
>> lookup can result in multiple H_READ hcalls. But that should only impact
>> when we are using 4K subpages which should be rare.
>> 
>> NOTE: I only tested this on systemsim. Wanted to get this out to get early
>> feedback.
>
> I tried this on a quad G5 and it seems to work just fine.  On a kernel
> compile test there was very little difference in speed - I measured
> about 0.4% slowdown but that may not be statistically significant.
> This was with 64k pages configured and THP enabled.
>

I also ran mmtest configs/config-global-dhp__pagealloc-performance
config with changes including this series. (ie, the changes tested
include two patch series, one which change the pte format and this
series). I am attaching the results below. I removed the pagealloc
performance numbers from that because it was giving me all 00 which I
assume is due to systemtap script issue.

We don't see any performance impact with the series and some of the
performance change is withing the variance of test run as indicated by
the numbers below. We do find less page fault and in some case better
autonuma numbers 


aim9
 ltctulc6a   ltctulc6a
  p1-0c526e14410c98f0ebc7ap1-3754c8187ca17
Min  page_test  2233460.00 (  0.00%)  2231193.33 ( -0.10%)
Min  brk_test   4129380.41 (  0.00%)  4075466.67 ( -1.31%)
Min  exec_test 1703.00 (  0.00%) 1694.87 ( -0.48%)
Min  fork_test 4790.14 (  0.00%) 4723.52 ( -1.39%)
Hmeanpage_test  2259304.39 (  0.00%)  2245792.45 ( -0.60%)
Hmeanbrk_test   4177072.87 (  0.00%)  4109747.37 ( -1.61%)
Hmeanexec_test 1742.55 (  0.00%) 1734.06 ( -0.49%)
Hmeanfork_test 4827.06 (  0.00%) 4762.24 ( -1.34%)
Stddev   page_test19396.37 (  0.00%)10206.24 ( 47.38%)
Stddev   brk_test 62453.11 (  0.00%)38772.18 ( 37.92%)
Stddev   exec_test   14.49 (  0.00%)   18.28 (-26.14%)
Stddev   fork_test   15.42 (  0.00%)   20.78 (-34.74%)
CoeffVar page_test0.86 (  0.00%)0.45 ( 47.06%)
CoeffVar brk_test 1.49 (  0.00%)0.94 ( 36.89%)
CoeffVar exec_test0.83 (  0.00%)1.05 (-26.76%)
CoeffVar fork_test0.32 (  0.00%)0.44 (-36.58%)
Max  page_test  2295226.67 (  0.00%)  2270180.00 ( -1.09%)
Max  brk_test   4284000.00 (  0.00%)  4223933.33 ( -1.40%)
Max  exec_test 1766.33 (  0.00%) 1780.00 (  0.77%)
Max  fork_test 4860.19 (  0.00%) 4803.46 ( -1.17%)

   ltctulc6a   ltctulc6a
p1-0c526e14410c98f0ebc7ap1-3754c8187ca17
User0.100.10
System  0.130.13
Elapsed   723.11  722.38

 ltctulc6a   ltctulc6a
  p1-0c526e14410c98f0ebc7ap1-3754c8187ca17
Minor Faults  8371786582883370
Major Faults   515  24
Swap Ins 0   0
Swap Outs0   0
Allocation stalls0   0
DMA allocs3820511937853837
DMA32 allocs 0   0
Normal allocs0   0
Movable allocs   0   0
Direct pages scanned 0   0
Kswapd pages scanned 0   0
Kswapd pages reclaimed   0   0
Direct pages reclaimed   0   0
Kswapd efficiency 100%100%
Kswapd velocity  0.000   0.000
Direct efficiency 100%100%
Direct velocity  0.000   0.000
Percentage direct scans 0%  0%
Zone normal velocity 0.000   0.000
Zone dma32 velocity  0.000   0.000
Zone dma velocity0.000   0.000
Page writes by reclaim   0.000   0.000
Page writes file 0   0
Page writes anon 0   0
Page reclaim immediate   0   0
Sector Reads2021405240
Sector Writes   251812   70376
Page rescued immediate   0   0
Slabs scanned0   0
Direct inode steals  0   0
Kswapd inode steals  0   0
Kswapd skipped 

Re: [RFC PATCH 0/7] Remove 4k subpage tracking with hash 64K config

2015-11-02 Thread Benjamin Herrenschmidt
On Tue, 2015-11-03 at 10:38 +0530, Aneesh Kumar K.V wrote:
> I also ran mmtest configs/config-global-dhp__pagealloc-performance
> config with changes including this series. (ie, the changes tested
> include two patch series, one which change the pte format and this
> series). I am attaching the results below. I removed the pagealloc
> performance numbers from that because it was giving me all 00 which I
> assume is due to systemtap script issue.
> 
> We don't see any performance impact with the series and some of the
> performance change is withing the variance of test run as indicated by
> the numbers below. We do find less page fault and in some case better
> autonuma numbers 

Did you try under pHyp (ie. hit all those H_READ ?).

The easy way to do that is comment out 64K support in htab init to
force 4k demotion allways.

That would give you an idea of the impact on things like old P4/P5

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

RE: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence

2015-11-02 Thread Dogra Raghav


-Original Message-
From: Wood Scott-B07421 
Sent: Tuesday, November 03, 2015 4:31 AM
To: Dogra Raghav-B46184 
Cc: Kushwaha Prabhakar-B32579 ; 
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence

On Mon, 2015-11-02 at 00:12 -0600, Dogra Raghav-B46184 wrote:
> -Original Message-
> From: Raghav Dogra [mailto:rag...@freescale.com]
> Sent: Friday, October 30, 2015 11:55 AM
> To: linuxppc-dev@lists.ozlabs.org
> Cc: Wood Scott-B07421 ; Kushwaha 
> Prabhakar-B32579 < prabha...@freescale.com>; Dogra Raghav-B46184 
> 
> Subject: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence
> 
> Modify platform driver suspend/resume to syscore suspend/resume. This 
> is because p1022ds needs to use localbus when entering the PCIE resume.
> 
> Signed-off-by: Raghav Dogra 
> ---
>  arch/powerpc/sysdev/Makefile  |  2 +-  arch/powerpc/sysdev/fsl_lbc.c 
> | 51 +---
> ---
>  2 files changed, 40 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/Makefile 
> b/arch/powerpc/sysdev/Makefile index f7cb2a1..4c19e614 100644
> --- a/arch/powerpc/sysdev/Makefile
> +++ b/arch/powerpc/sysdev/Makefile
> @@ -18,9 +18,9 @@ obj-$(CONFIG_PPC_PMI)   += pmi.o
>  obj-$(CONFIG_U3_DART)+= dart_iommu.o
>  obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
>  obj-$(CONFIG_FSL_SOC)+= fsl_soc.o fsl_mpic_err.o
> +obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
>  obj-$(CONFIG_FSL_PCI)+= fsl_pci.o $(fsl-msi-obj-y)
>  obj-$(CONFIG_FSL_PMC)+= fsl_pmc.o
> -obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
>  obj-$(CONFIG_FSL_GTM)+= fsl_gtm.o
>  obj-$(CONFIG_FSL_85XX_CACHE_SRAM)+= fsl_85xx_l2ctlr.o 
> fsl_85xx_cache_sram.o
>  obj-$(CONFIG_SIMPLE_GPIO)+= simple_gpio.o
> diff --git a/arch/powerpc/sysdev/fsl_lbc.c 
> b/arch/powerpc/sysdev/fsl_lbc.c index d631022..332d700 100644
> --- a/arch/powerpc/sysdev/fsl_lbc.c
> +++ b/arch/powerpc/sysdev/fsl_lbc.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -354,24 +355,42 @@ err:
>  #ifdef CONFIG_SUSPEND
>  
>  /* save lbc registers */
> -static int fsl_lbc_suspend(struct platform_device *pdev, pm_message_t
> state)
> +static int fsl_lbc_syscore_suspend(void)
>  {
> - struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(>dev);
> - struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
> + struct fsl_lbc_ctrl *ctrl;
> + struct fsl_lbc_regs __iomem *lbc;
> +
> + ctrl = fsl_lbc_ctrl_dev;
> + if (!ctrl)
> + goto out;
> +
> + lbc = ctrl->regs;
> + if (!lbc)
> + goto out;
>  
>   ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL);
>   if (!ctrl->saved_regs)
>   return -ENOMEM;
> [Dogra Raghav-B46184] This is the existing upstream code. Are you 
> suggesting to modify the upstream code to take care of individual registers?

What specifically do you mean by "the upstream code"?  What other tree are we 
talking about here?

-Scott

I meant that these two lines of code are not being added or modified by this 
patch. They already exist in the upstream tree. Are you suggesting I modify 
them as well?
-Raghav
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence

2015-11-02 Thread Scott Wood
On Mon, 2015-11-02 at 23:31 -0600, Dogra Raghav-B46184 wrote:
> 
> -Original Message-
> From: Wood Scott-B07421 
> Sent: Tuesday, November 03, 2015 4:31 AM
> To: Dogra Raghav-B46184 
> Cc: Kushwaha Prabhakar-B32579 ; 
> linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence
> 
> On Mon, 2015-11-02 at 00:12 -0600, Dogra Raghav-B46184 wrote:
> > -Original Message-
> > From: Raghav Dogra [mailto:rag...@freescale.com]
> > Sent: Friday, October 30, 2015 11:55 AM
> > To: linuxppc-dev@lists.ozlabs.org
> > Cc: Wood Scott-B07421 ; Kushwaha 
> > Prabhakar-B32579 < prabha...@freescale.com>; Dogra Raghav-B46184 
> > 
> > Subject: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence
> > 
> > Modify platform driver suspend/resume to syscore suspend/resume. This 
> > is because p1022ds needs to use localbus when entering the PCIE resume.
> > 
> > Signed-off-by: Raghav Dogra 
> > ---
> >  arch/powerpc/sysdev/Makefile  |  2 +-  arch/powerpc/sysdev/fsl_lbc.c 
> > > 51 +---
> > ---
> >  2 files changed, 40 insertions(+), 13 deletions(-)
> > 
> > diff --git a/arch/powerpc/sysdev/Makefile 
> > b/arch/powerpc/sysdev/Makefile index f7cb2a1..4c19e614 100644
> > --- a/arch/powerpc/sysdev/Makefile
> > +++ b/arch/powerpc/sysdev/Makefile
> > @@ -18,9 +18,9 @@ obj-$(CONFIG_PPC_PMI)   += pmi.o
> >  obj-$(CONFIG_U3_DART)+= dart_iommu.o
> >  obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
> >  obj-$(CONFIG_FSL_SOC)+= fsl_soc.o fsl_mpic_err.o
> > +obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
> >  obj-$(CONFIG_FSL_PCI)+= fsl_pci.o $(fsl-msi-obj-y)
> >  obj-$(CONFIG_FSL_PMC)+= fsl_pmc.o
> > -obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
> >  obj-$(CONFIG_FSL_GTM)+= fsl_gtm.o
> >  obj-$(CONFIG_FSL_85XX_CACHE_SRAM)+= fsl_85xx_l2ctlr.o 
> > fsl_85xx_cache_sram.o
> >  obj-$(CONFIG_SIMPLE_GPIO)+= simple_gpio.o
> > diff --git a/arch/powerpc/sysdev/fsl_lbc.c 
> > b/arch/powerpc/sysdev/fsl_lbc.c index d631022..332d700 100644
> > --- a/arch/powerpc/sysdev/fsl_lbc.c
> > +++ b/arch/powerpc/sysdev/fsl_lbc.c
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  
> > @@ -354,24 +355,42 @@ err:
> >  #ifdef CONFIG_SUSPEND
> >  
> >  /* save lbc registers */
> > -static int fsl_lbc_suspend(struct platform_device *pdev, pm_message_t
> > state)
> > +static int fsl_lbc_syscore_suspend(void)
> >  {
> > - struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(>dev);
> > - struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
> > + struct fsl_lbc_ctrl *ctrl;
> > + struct fsl_lbc_regs __iomem *lbc;
> > +
> > + ctrl = fsl_lbc_ctrl_dev;
> > + if (!ctrl)
> > + goto out;
> > +
> > + lbc = ctrl->regs;
> > + if (!lbc)
> > + goto out;
> >  
> >   ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL);
> >   if (!ctrl->saved_regs)
> >   return -ENOMEM;
> > [Dogra Raghav-B46184] This is the existing upstream code. Are you 
> > suggesting to modify the upstream code to take care of individual 
> > registers?
> 
> What specifically do you mean by "the upstream code"?  What other tree are 
> we talking about here?
> 
> -Scott
> 
> I meant that these two lines of code are not being added or modified by 
> this patch. They already exist in the upstream tree. Are you suggesting I 
> modify them as well?
> -Raghav

I have no idea which "two lines of code" you're talking about or how any 
comment I made applies to the above diff hunk.

OK, I looked at the original patch and I guess you're talking about the 
_memcpy_fromio() that was *below* your comment?  Please configure your mailer 
to quote properly, and put your replies below what you're quoting.

Yes, I think that that usage of _memcpy_fromio() is bad and should be changed.

-Scott

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

[v7, 5/6] fsl/fman: Add FMan Port Support

2015-11-02 Thread igal.liberman
From: Igal Liberman 

Add the Data Path Acceleration Architecture Frame Manger Port Driver.
The FMan driver uses a module called "Port" to represent the physical
TX and RX ports.
Each FMan version has different number of physical ports.
This patch adds The FMan Port configuration, initialization and
runtime control routines for both TX and RX.

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile|2 +-
 drivers/net/ethernet/freescale/fman/fman_port.c | 1779 +++
 drivers/net/ethernet/freescale/fman/fman_port.h |  151 ++
 3 files changed, 1931 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_port.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_port.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 5141532..2eb0b9b 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -2,5 +2,5 @@ subdir-ccflags-y +=  
-I$(srctree)/drivers/net/ethernet/freescale/fman
 
 obj-y  += fsl_fman.o fsl_fman_mac.o
 
-fsl_fman-objs  := fman_muram.o fman.o fman_sp.o
+fsl_fman-objs  := fman_muram.o fman.o fman_sp.o fman_port.o
 fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o
diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c 
b/drivers/net/ethernet/freescale/fman/fman_port.c
new file mode 100644
index 000..56ecf2b
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -0,0 +1,1779 @@
+/*
+ * Copyright 2008 - 2015 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.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include "fman_port.h"
+#include "fman.h"
+#include "fman_sp.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Queue ID */
+#define DFLT_FQ_ID 0x00FF
+
+/* General defines */
+#define PORT_BMI_FIFO_UNITS0x100
+
+#define MAX_PORT_FIFO_SIZE(bmi_max_fifo_size)  \
+   min((u32)bmi_max_fifo_size, (u32)1024 * FMAN_BMI_FIFO_UNITS)
+
+#define PORT_CG_MAP_NUM8
+#define PORT_PRS_RESULT_WORDS_NUM  8
+#define PORT_IC_OFFSET_UNITS   0x10
+
+#define MIN_EXT_BUF_SIZE   64
+
+#define BMI_PORT_REGS_OFFSET   0
+#define QMI_PORT_REGS_OFFSET   0x400
+
+/* Default values */
+#define DFLT_PORT_BUFFER_PREFIX_CONTEXT_DATA_ALIGN \
+   DFLT_FM_SP_BUFFER_PREFIX_CONTEXT_DATA_ALIGN
+
+#define DFLT_PORT_CUT_BYTES_FROM_END   4
+
+#define DFLT_PORT_ERRORS_TO_DISCARDFM_PORT_FRM_ERR_CLS_DISCARD
+#define DFLT_PORT_MAX_FRAME_LENGTH 9600
+
+#define DFLT_PORT_RX_FIFO_PRI_ELEVATION_LEV(bmi_max_fifo_size) \
+   MAX_PORT_FIFO_SIZE(bmi_max_fifo_size)
+
+#define DFLT_PORT_RX_FIFO_THRESHOLD(major, bmi_max_fifo_size)  \
+   (major == 6 ?   \
+   MAX_PORT_FIFO_SIZE(bmi_max_fifo_size) : \
+   (MAX_PORT_FIFO_SIZE(bmi_max_fifo_size) * 3 / 4))\
+
+#define DFLT_PORT_EXTRA_NUM_OF_FIFO_BUFS   0
+
+/* QMI defines */
+#define 

[net-next v4 8/8] dpaa_eth: add trace points

2015-11-02 Thread Madalin Bucur
Add trace points on the hot processing path.

Signed-off-by: Ruxandra Ioana Radulescu 
---
 drivers/net/ethernet/freescale/dpaa/Makefile   |   1 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c |  12 ++
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.h |   4 +
 .../net/ethernet/freescale/dpaa/dpaa_eth_trace.h   | 141 +
 4 files changed, 158 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth_trace.h

diff --git a/drivers/net/ethernet/freescale/dpaa/Makefile 
b/drivers/net/ethernet/freescale/dpaa/Makefile
index 141ade4..15ed1c4 100644
--- a/drivers/net/ethernet/freescale/dpaa/Makefile
+++ b/drivers/net/ethernet/freescale/dpaa/Makefile
@@ -9,3 +9,4 @@ ccflags-y += -I$(FMAN)
 obj-$(CONFIG_FSL_DPAA_ETH) += fsl_dpa.o
 
 fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o dpaa_ethtool.o 
dpaa_eth_sysfs.o
+CFLAGS_dpaa_eth.o := -I$(src)
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 3cd03f5..b939d9d 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -57,6 +57,12 @@
 #include "dpaa_eth.h"
 #include "dpaa_eth_common.h"
 
+/* CREATE_TRACE_POINTS only needs to be defined once. Other dpa files
+ * using trace events only need to #include 
+ */
+#define CREATE_TRACE_POINTS
+#include "dpaa_eth_trace.h"
+
 /* Valid checksum indication */
 #define DPA_CSUM_VALID 0x
 
@@ -229,6 +235,9 @@ priv_rx_default_dqrr(struct qman_portal *portal,
priv = netdev_priv(net_dev);
dpa_bp = priv->dpa_bp;
 
+   /* Trace the Rx fd */
+   trace_dpa_rx_fd(net_dev, fq, >fd);
+
/* IRQ handler, non-migratable; safe to use raw_cpu_ptr here */
percpu_priv = raw_cpu_ptr(priv->percpu_priv);
count_ptr = raw_cpu_ptr(dpa_bp->percpu_count);
@@ -285,6 +294,9 @@ priv_tx_conf_default_dqrr(struct qman_portal *portal,
net_dev = ((struct dpa_fq *)fq)->net_dev;
priv = netdev_priv(net_dev);
 
+   /* Trace the fd */
+   trace_dpa_tx_conf_fd(net_dev, fq, >fd);
+
/* Non-migratable context, safe to use raw_cpu_ptr */
percpu_priv = raw_cpu_ptr(priv->percpu_priv);
 
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
index cdc7595..7dee8de 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
@@ -36,6 +36,7 @@
 
 #include "fman.h"
 #include "mac.h"
+#include "dpaa_eth_trace.h"
 
 extern int dpa_rx_extra_headroom;
 extern int dpa_max_frm;
@@ -407,6 +408,9 @@ static inline int dpa_xmit(struct dpa_priv_s *priv,
if (fd->bpid == 0xff)
fd->cmd |= qman_fq_fqid(priv->conf_fqs[queue]);
 
+   /* Trace this Tx fd */
+   trace_dpa_tx_fd(priv->net_dev, egress_fq, fd);
+
for (i = 0; i < 10; i++) {
err = qman_enqueue(egress_fq, fd, 0);
if (err != -EBUSY)
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_trace.h 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_trace.h
new file mode 100644
index 000..3b67477
--- /dev/null
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_trace.h
@@ -0,0 +1,141 @@
+/* Copyright 2013-2015 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 

[v7, 0/6] Freescale DPAA FMan

2015-11-02 Thread igal.liberman
From: Igal Liberman 

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 CPU cores and the accelerators.

One of the DPAA accelerators is the Frame Manager (FMan)
which contains a series of hardware blocks: ports, Ethernet MACs,
a multi user RAM (MURAM) and Storage Profile (SP).

This patch set introduce the FMan drivers.
Each driver configures and initializes the corresponding
FMan hardware module (described above).
The MAC driver offers support for three different
types of MACs (eTSEC, TGEC, MEMAC).

v6 --> v7:
- Addressed compilation issue on non-PPC targets
- Removed B4860 rev 1 support

v5 --> v6:
- Addressed feedback from Scott:
- Moved kernel doc to source files
- Removed a series of configurable settings
- Miscellaneous code updates

v4 --> v5:
- Addressed feedback from David Miller:
- Removed driver layering
- Reduce namespace pollution
- Reduce code complexity and size

v3 --> v4:
- Remove device_initcall call in driver registration (redundant)
- Remove hot/cold labels
- Minor update in FMan Clock read from device-tree
- Update fixed-link support
- Addressed feedback from Stephen Hemminger
- Remove bogus blank line

v2 --> v3:
- Addressed feedback from Scott:
- Remove typedefs
- Remove unnecessary memory barriers
- Remove unnecessary casting
- Remove KConfig options
- Remove early_params
- Remove Hungarian notation
- Remove __packed__  attribute and padding from structures
- Remove unlikely attribute (where it's not needed)
- Use proper error codes and remove unnecessary prints
- Use proper values for sleep routines
- Replace complex Macros with functions
- Improve device tree processing code
- Use symbolic defines
- Add time-out in busy-wait loops
- Removed exit code (loadable module support will be added 
later)
- Fixed "fixed-link" issue raised by Joakim Tjernlund

v1 --> v2:
- Addressed feedback from Paul Bolle:
- General feedback of FMan Driver layer
- Remove Errata defines
- Aligned comments to Kernel Doc
- Remove Loadable Module support (not yet supported)
- Removed not needed KConfig dependencies
- Addressed feedback from Scott Wood
- Use Kernel ioread/iowrite services
- Squash FLIB source and header patches together

This submission is based on the prior Freescale DPAA FMan V3,RFC submission.
Several issues addresses in this submission:
- Reduced MAC layering and complexity
- Reduced code base
- T1024/T2080 10G best effort support

Igal Liberman (6):
  fsl/fman: Add FMan MURAM support
  fsl/fman: Add FMan support
  fsl/fman: Add FMan MAC support
  fsl/fman: Add FMan SP support
  fsl/fman: Add FMan Port Support
  fsl/fman: Add FMan MAC driver

 drivers/net/ethernet/freescale/Kconfig |1 +
 drivers/net/ethernet/freescale/Makefile|2 +
 drivers/net/ethernet/freescale/fman/Kconfig|8 +
 drivers/net/ethernet/freescale/fman/Makefile   |7 +
 .../net/ethernet/freescale/fman/crc_mac_addr_ext.h |  314 +++
 drivers/net/ethernet/freescale/fman/fman.c | 2876 
 drivers/net/ethernet/freescale/fman/fman.h |  325 +++
 drivers/net/ethernet/freescale/fman/fman_dtsec.c   | 1609 +++
 drivers/net/ethernet/freescale/fman/fman_dtsec.h   |   59 +
 drivers/net/ethernet/freescale/fman/fman_mac.h |  276 ++
 drivers/net/ethernet/freescale/fman/fman_memac.c   | 1307 +
 drivers/net/ethernet/freescale/fman/fman_memac.h   |   60 +
 drivers/net/ethernet/freescale/fman/fman_muram.c   |  159 ++
 drivers/net/ethernet/freescale/fman/fman_muram.h   |   51 +
 drivers/net/ethernet/freescale/fman/fman_port.c| 1779 
 drivers/net/ethernet/freescale/fman/fman_port.h|  151 +
 drivers/net/ethernet/freescale/fman/fman_sp.c  |  167 ++
 drivers/net/ethernet/freescale/fman/fman_sp.h  |  103 +
 drivers/net/ethernet/freescale/fman/fman_tgec.c|  798 ++
 drivers/net/ethernet/freescale/fman/fman_tgec.h|   55 +
 drivers/net/ethernet/freescale/fman/mac.c  |  980 +++
 drivers/net/ethernet/freescale/fman/mac.h  |   97 +
 22 files changed, 11184 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/Kconfig
 create mode 100644 

[v7, 6/6] fsl/fman: Add FMan MAC driver

2015-11-02 Thread igal.liberman
From: Igal Liberman 

This patch adds the Ethernet MAC driver supporting the three
different types of MACs: dTSEC, tGEC and mEMAC.

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile |3 +-
 drivers/net/ethernet/freescale/fman/mac.c|  980 ++
 drivers/net/ethernet/freescale/fman/mac.h|   97 +++
 3 files changed, 1079 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/mac.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 2eb0b9b..51fd2e6 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -1,6 +1,7 @@
 subdir-ccflags-y +=  -I$(srctree)/drivers/net/ethernet/freescale/fman
 
-obj-y  += fsl_fman.o fsl_fman_mac.o
+obj-y  += fsl_fman.o fsl_fman_mac.o fsl_mac.o
 
 fsl_fman-objs  := fman_muram.o fman.o fman_sp.o fman_port.o
 fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o
+fsl_mac-objs += mac.o
diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
new file mode 100644
index 000..9dd66bc
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -0,0 +1,980 @@
+/* Copyright 2008-2015 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.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mac.h"
+#include "fman_mac.h"
+#include "fman_dtsec.h"
+#include "fman_tgec.h"
+#include "fman_memac.h"
+
+#define MAC_DESCRIPTION "FSL FMan MAC API based driver"
+
+MODULE_LICENSE("Dual BSD/GPL");
+
+MODULE_AUTHOR("Emil Medve ");
+
+MODULE_DESCRIPTION(MAC_DESCRIPTION);
+
+struct mac_priv_s {
+   struct device   *dev;
+   void __iomem*vaddr;
+   u8  cell_index;
+   phy_interface_t phy_if;
+   struct fman *fman;
+   struct device_node  *phy_node;
+   /* List of multicast addresses */
+   struct list_headmc_addr_list;
+   struct platform_device  *eth_dev;
+   struct fixed_phy_status *fixed_link;
+   u16 speed;
+   u16 max_speed;
+
+   int (*enable)(struct fman_mac *mac_dev, enum comm_mode mode);
+   int (*disable)(struct fman_mac *mac_dev, enum comm_mode mode);
+};
+
+struct mac_address {
+   u8 addr[ETH_ALEN];
+   struct list_head list;
+};
+
+static void mac_exception(void *_mac_dev, enum fman_mac_exceptions ex)
+{
+   struct mac_device   *mac_dev;
+   struct mac_priv_s   *priv;
+
+   mac_dev = (struct mac_device *)_mac_dev;
+   priv = mac_dev->priv;
+
+   if (ex == FM_MAC_EX_10G_RX_FIFO_OVFL) {
+   /* don't flag RX FIFO after the first */
+   mac_dev->set_exception(mac_dev->fman_mac,
+  

[net-next v4 4/8] dpaa_eth: add driver's Tx queue selection

2015-11-02 Thread Madalin Bucur
Allow the selection of the transmission queue based on the CPU id.

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/dpaa/Kconfig   | 10 ++
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c|  3 +++
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.h|  6 ++
 drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c |  8 
 drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h |  4 
 5 files changed, 31 insertions(+)

diff --git a/drivers/net/ethernet/freescale/dpaa/Kconfig 
b/drivers/net/ethernet/freescale/dpaa/Kconfig
index 022d5aa..2577aac 100644
--- a/drivers/net/ethernet/freescale/dpaa/Kconfig
+++ b/drivers/net/ethernet/freescale/dpaa/Kconfig
@@ -11,6 +11,16 @@ menuconfig FSL_DPAA_ETH
 
 if FSL_DPAA_ETH
 
+config FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
+   bool "Use driver's Tx queue selection mechanism"
+   default y
+   ---help---
+ The DPAA Ethernet driver defines a ndo_select_queue() callback for 
optimal selection
+ of the egress FQ. That will override the XPS support for this 
netdevice.
+ If for whatever reason you want to be in control of the egress 
FQ-to-CPU selection and mapping,
+ or simply don't want to use the driver's ndo_select_queue() callback, 
then unselect this
+ and use the standard XPS support instead.
+
 config FSL_DPAA_ETH_FRIENDLY_IF_NAME
bool "Use fmX-macY names for the DPAA interfaces"
default y
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 31d55b4..894f1a7 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -390,6 +390,9 @@ static const struct net_device_ops dpa_private_ops = {
.ndo_get_stats64 = dpa_get_stats64,
.ndo_set_mac_address = dpa_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
+#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
+   .ndo_select_queue = dpa_select_queue,
+#endif
.ndo_change_mtu = dpa_change_mtu,
.ndo_set_rx_mode = dpa_set_rx_mode,
.ndo_init = dpa_ndo_init,
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
index 1ba6617..87577cf 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
@@ -420,9 +420,15 @@ static inline void _dpa_assign_wq(struct dpa_fq *fq)
}
 }
 
+#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
+/* Use in lieu of skb_get_queue_mapping() */
+#define dpa_get_queue_mapping(skb) \
+   raw_smp_processor_id()
+#else
 /* Use the queue selected by XPS */
 #define dpa_get_queue_mapping(skb) \
skb_get_queue_mapping(skb)
+#endif
 
 static inline void _dpa_bp_free_pf(void *addr)
 {
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
index b36cbca..89f3b1f 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
@@ -593,6 +593,14 @@ bool dpa_bpid2pool_use(int bpid)
return false;
 }
 
+#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
+u16 dpa_select_queue(struct net_device *net_dev, struct sk_buff *skb,
+void *accel_priv, select_queue_fallback_t fallback)
+{
+   return dpa_get_queue_mapping(skb);
+}
+#endif
+
 struct dpa_fq *dpa_fq_alloc(struct device *dev,
const struct fqid_cell *fqids,
struct list_head *list,
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
index 9df8f14..2e9471d 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
@@ -70,6 +70,10 @@ struct dpa_bp *dpa_bpid2pool(int bpid);
 void dpa_bpid2pool_map(int bpid, struct dpa_bp *dpa_bp);
 bool dpa_bpid2pool_use(int bpid);
 void dpa_bp_drain(struct dpa_bp *bp);
+#ifdef CONFIG_FSL_DPAA_ETH_USE_NDO_SELECT_QUEUE
+u16 dpa_select_queue(struct net_device *net_dev, struct sk_buff *skb,
+void *accel_priv, select_queue_fallback_t fallback);
+#endif
 struct dpa_fq *dpa_fq_alloc(struct device *dev,
const struct fqid_cell *fqids,
struct list_head *list,
-- 
1.7.11.7

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

[net-next v4 6/8] dpaa_eth: add ethtool statistics

2015-11-02 Thread Madalin Bucur
Add a series of counters to be exported through ethtool:
- add detailed counters for reception errors;
- add detailed counters for QMan enqueue reject events;
- count the number of fragmented skbs received from the stack;
- count all frames received on the Tx confirmation path;
- add congestion group statistics;
- count the number of interrupts for each CPU.

Signed-off-by: Ioana Ciornei 
Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c |  12 ++
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.h |  34 
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.c  |  40 -
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.h  |   2 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c  |   1 +
 drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 183 +
 6 files changed, 270 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 894f1a7..0b3332a 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -102,6 +102,15 @@ static void _dpa_rx_error(struct net_device *net_dev,
 
percpu_priv->stats.rx_errors++;
 
+   if (fd->status & FM_FD_ERR_DMA)
+   percpu_priv->rx_errors.dme++;
+   if (fd->status & FM_FD_ERR_PHYSICAL)
+   percpu_priv->rx_errors.fpe++;
+   if (fd->status & FM_FD_ERR_SIZE)
+   percpu_priv->rx_errors.fse++;
+   if (fd->status & FM_FD_ERR_PRS_HDR_ERR)
+   percpu_priv->rx_errors.phe++;
+
dpa_fd_release(net_dev, fd);
 }
 
@@ -167,6 +176,8 @@ static void _dpa_tx_conf(struct net_device *net_dev,
percpu_priv->stats.tx_errors++;
}
 
+   percpu_priv->tx_confirm++;
+
skb = _dpa_cleanup_tx_fd(priv, fd);
 
dev_kfree_skb(skb);
@@ -302,6 +313,7 @@ static void priv_ern(struct qman_portal *portal,
 
percpu_priv->stats.tx_dropped++;
percpu_priv->stats.tx_fifo_errors++;
+   count_ern(percpu_priv, msg);
 
/* If we intended this buffer to go into the pool
 * when the FM was done, we need to put it in
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
index 87577cf..ccaadd9 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
@@ -192,6 +192,25 @@ struct dpa_bp {
void (*free_buf_cb)(void *addr);
 };
 
+struct dpa_rx_errors {
+   u64 dme;/* DMA Error */
+   u64 fpe;/* Frame Physical Error */
+   u64 fse;/* Frame Size Error */
+   u64 phe;/* Header Error */
+};
+
+/* Counters for QMan ERN frames - one counter per rejection code */
+struct dpa_ern_cnt {
+   u64 cg_tdrop;   /* Congestion group taildrop */
+   u64 wred;   /* WRED congestion */
+   u64 err_cond;   /* Error condition */
+   u64 early_window;   /* Order restoration, frame too early */
+   u64 late_window;/* Order restoration, frame too late */
+   u64 fq_tdrop;   /* FQ taildrop */
+   u64 fq_retired; /* FQ is retired */
+   u64 orp_zero;   /* ORP disabled */
+};
+
 struct dpa_napi_portal {
struct napi_struct napi;
struct qman_portal *p;
@@ -201,7 +220,13 @@ struct dpa_napi_portal {
 struct dpa_percpu_priv_s {
struct net_device *net_dev;
struct dpa_napi_portal *np;
+   u64 in_interrupt;
+   u64 tx_confirm;
+   /* fragmented (non-linear) skbuffs received from the stack */
+   u64 tx_frag_skbuffs;
struct rtnl_link_stats64 stats;
+   struct dpa_rx_errors rx_errors;
+   struct dpa_ern_cnt ern_cnt;
 };
 
 struct dpa_priv_s {
@@ -228,6 +253,14 @@ struct dpa_priv_s {
 * (and the same) congestion group.
 */
struct qman_cgr cgr;
+   /* If congested, when it began. Used for performance stats. */
+   u32 congestion_start_jiffies;
+   /* Number of jiffies the Tx port was congested. */
+   u32 congested_jiffies;
+   /* Counter for the number of times the CGR
+* entered congestion state
+*/
+   u32 cgr_congested_count;
} cgr_data;
/* Use a per-port CGR for ingress traffic. */
bool use_ingress_cgr;
@@ -289,6 +322,7 @@ static inline int dpaa_eth_napi_schedule(struct 
dpa_percpu_priv_s *percpu_priv,
 
np->p = portal;
napi_schedule(>napi);
+   percpu_priv->in_interrupt++;
return 1;
}
}
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
index 

[v7, 4/6] fsl/fman: Add FMan SP support

2015-11-02 Thread igal.liberman
From: Igal Liberman 

The Storage Profiles contain parameters that are used
by the FMan for frame reception and transmission.

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile  |2 +-
 drivers/net/ethernet/freescale/fman/fman_sp.c |  167 +
 drivers/net/ethernet/freescale/fman/fman_sp.h |  103 +++
 3 files changed, 271 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_sp.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman_sp.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 43360d70..5141532 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -2,5 +2,5 @@ subdir-ccflags-y +=  
-I$(srctree)/drivers/net/ethernet/freescale/fman
 
 obj-y  += fsl_fman.o fsl_fman_mac.o
 
-fsl_fman-objs  := fman_muram.o fman.o
+fsl_fman-objs  := fman_muram.o fman.o fman_sp.o
 fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o
diff --git a/drivers/net/ethernet/freescale/fman/fman_sp.c 
b/drivers/net/ethernet/freescale/fman/fman_sp.c
new file mode 100644
index 000..f36c622
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman_sp.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2008 - 2015 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 "fman_sp.h"
+#include "fman.h"
+
+void fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools
+*fm_ext_pools,
+u8 *ordered_array,
+u16 *sizes_array)
+{
+   u16 buf_size = 0;
+   int i = 0, j = 0, k = 0;
+
+   /* First we copy the external buffers pools information
+* to an ordered local array
+*/
+   for (i = 0; i < fm_ext_pools->num_of_pools_used; i++) {
+   /* get pool size */
+   buf_size = fm_ext_pools->ext_buf_pool[i].size;
+
+   /* keep sizes in an array according to poolId
+* for direct access
+*/
+   sizes_array[fm_ext_pools->ext_buf_pool[i].id] = buf_size;
+
+   /* save poolId in an ordered array according to size */
+   for (j = 0; j <= i; j++) {
+   /* this is the next free place in the array */
+   if (j == i)
+   ordered_array[i] =
+   fm_ext_pools->ext_buf_pool[i].id;
+   else {
+   /* find the right place for this poolId */
+   if (buf_size < sizes_array[ordered_array[j]]) {
+   /* move the pool_ids one place ahead
+* to make room for this poolId
+*/
+   for (k = i; k > j; k--)
+   ordered_array[k] =
+   

[net-next v4 2/8] dpaa_eth: add support for DPAA Ethernet

2015-11-02 Thread Madalin Bucur
This introduces the Freescale Data Path Acceleration Architecture
(DPAA) Ethernet driver (dpaa_eth) that builds upon the DPAA QMan,
BMan, PAMU and FMan drivers to deliver Ethernet connectivity on
the Freescale DPAA QorIQ platforms.

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/Kconfig |2 +
 drivers/net/ethernet/freescale/Makefile|1 +
 drivers/net/ethernet/freescale/dpaa/Kconfig|   22 +
 drivers/net/ethernet/freescale/dpaa/Makefile   |   11 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c |  819 
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.h |  432 +++
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.c  | 1299 
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.h  |   98 ++
 drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c  |  408 ++
 9 files changed, 3092 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/dpaa/Kconfig
 create mode 100644 drivers/net/ethernet/freescale/dpaa/Makefile
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c

diff --git a/drivers/net/ethernet/freescale/Kconfig 
b/drivers/net/ethernet/freescale/Kconfig
index f3f89cc..92198be 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -92,4 +92,6 @@ config GIANFAR
  and MPC86xx family of chips, the eTSEC on LS1021A and the FEC
  on the 8540.
 
+source "drivers/net/ethernet/freescale/dpaa/Kconfig"
+
 endif # NET_VENDOR_FREESCALE
diff --git a/drivers/net/ethernet/freescale/Makefile 
b/drivers/net/ethernet/freescale/Makefile
index 4097c58..ae13dc5 100644
--- a/drivers/net/ethernet/freescale/Makefile
+++ b/drivers/net/ethernet/freescale/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_FS_ENET) += fs_enet/
 obj-$(CONFIG_FSL_PQ_MDIO) += fsl_pq_mdio.o
 obj-$(CONFIG_FSL_XGMAC_MDIO) += xgmac_mdio.o
 obj-$(CONFIG_GIANFAR) += gianfar_driver.o
+obj-$(CONFIG_FSL_DPAA_ETH) += dpaa/
 obj-$(CONFIG_PTP_1588_CLOCK_GIANFAR) += gianfar_ptp.o
 gianfar_driver-objs := gianfar.o \
gianfar_ethtool.o
diff --git a/drivers/net/ethernet/freescale/dpaa/Kconfig 
b/drivers/net/ethernet/freescale/dpaa/Kconfig
new file mode 100644
index 000..022d5aa
--- /dev/null
+++ b/drivers/net/ethernet/freescale/dpaa/Kconfig
@@ -0,0 +1,22 @@
+menuconfig FSL_DPAA_ETH
+   tristate "DPAA Ethernet"
+   depends on FSL_SOC && FSL_BMAN && FSL_QMAN && FSL_FMAN
+   select PHYLIB
+   select FSL_FMAN_MAC
+   ---help---
+ Data Path Acceleration Architecture Ethernet driver,
+ supporting the Freescale QorIQ chips.
+ Depends on Freescale Buffer Manager and Queue Manager
+ driver and Frame Manager Driver.
+
+if FSL_DPAA_ETH
+
+config FSL_DPAA_ETH_FRIENDLY_IF_NAME
+   bool "Use fmX-macY names for the DPAA interfaces"
+   default y
+   ---help---
+ The DPAA Ethernet netdevices are created for each FMan port available
+ on a certain board. Enable this to get interface names derived from
+ the underlying FMan hardware for a simple identification.
+
+endif # FSL_DPAA_ETH
diff --git a/drivers/net/ethernet/freescale/dpaa/Makefile 
b/drivers/net/ethernet/freescale/dpaa/Makefile
new file mode 100644
index 000..3847ec7
--- /dev/null
+++ b/drivers/net/ethernet/freescale/dpaa/Makefile
@@ -0,0 +1,11 @@
+#
+# Makefile for the Freescale DPAA Ethernet controllers
+#
+
+# Include FMan headers
+FMAN= $(srctree)/drivers/net/ethernet/freescale/fman
+ccflags-y += -I$(FMAN)
+
+obj-$(CONFIG_FSL_DPAA_ETH) += fsl_dpa.o
+
+fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
new file mode 100644
index 000..8381616
--- /dev/null
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -0,0 +1,819 @@
+/* Copyright 2008 - 2015 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.
+ 

[net-next v4 3/8] dpaa_eth: add support for S/G frames

2015-11-02 Thread Madalin Bucur
Add support for Scater/Gather (S/G) frames. The FMan can place
the frame content into multiple buffers and provide a S/G Table
(SGT) into one first buffer with references to the others.

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c |   6 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.h |   2 +-
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.c  |  50 ++-
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.h  |   2 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth_sg.c  | 335 +++--
 5 files changed, 374 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 8381616..31d55b4 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -463,6 +463,12 @@ static int dpa_private_netdev_init(struct net_device 
*net_dev)
net_dev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
 NETIF_F_LLTX);
 
+   /* Advertise S/G and HIGHDMA support for private interfaces */
+   net_dev->hw_features |= NETIF_F_SG | NETIF_F_HIGHDMA;
+   /* Recent kernels enable GSO automatically, if
+* we declare NETIF_F_SG. For conformity, we'll
+* still declare GSO explicitly.
+*/
net_dev->features |= NETIF_F_GSO;
 
return dpa_netdev_init(net_dev, mac_addr, tx_timeout);
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
index 1cc8682..1ba6617 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
@@ -347,7 +347,7 @@ static inline void clear_fd(struct qm_fd *fd)
 }
 
 static inline int _dpa_tx_fq_to_id(const struct dpa_priv_s *priv,
-  struct qman_fq *tx_fq)
+   struct qman_fq *tx_fq)
 {
int i;
 
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
index 963be4d8..b36cbca 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
@@ -1177,10 +1177,42 @@ void dpaa_eth_init_ports(struct mac_device *mac_dev,
  port_fqs->rx_defq, _layout[RX]);
 }
 
+void dpa_release_sgt(struct qm_sg_entry *sgt)
+{
+   struct dpa_bp *dpa_bp;
+   struct bm_buffer bmb[DPA_BUFF_RELEASE_MAX];
+   u8 i = 0, j;
+
+   memset(bmb, 0, sizeof(bmb));
+
+   do {
+   dpa_bp = dpa_bpid2pool(sgt[i].bpid);
+   DPA_ERR_ON(!dpa_bp);
+
+   j = 0;
+   do {
+   DPA_ERR_ON(sgt[i].extension);
+
+   bmb[j].hi = sgt[i].addr_hi;
+   bmb[j].lo = be32_to_cpu(sgt[i].addr_lo);
+
+   j++; i++;
+   } while (j < ARRAY_SIZE(bmb) &&
+   !sgt[i - 1].final &&
+   sgt[i - 1].bpid == sgt[i].bpid);
+
+   while (bman_release(dpa_bp->pool, bmb, j, 0))
+   cpu_relax();
+   } while (!sgt[i - 1].final);
+}
+
 void dpa_fd_release(const struct net_device *net_dev, const struct qm_fd *fd)
 {
+   struct qm_sg_entry *sgt;
struct dpa_bp *dpa_bp;
struct bm_buffer bmb;
+   dma_addr_t addr;
+   void *vaddr;
 
memset(, 0, sizeof(bmb));
bm_buffer_set64(, fd->addr);
@@ -1188,7 +1220,23 @@ void dpa_fd_release(const struct net_device *net_dev, 
const struct qm_fd *fd)
dpa_bp = dpa_bpid2pool(fd->bpid);
DPA_ERR_ON(!dpa_bp);
 
-   DPA_ERR_ON(fd->format == qm_fd_sg);
+   if (fd->format == qm_fd_sg) {
+   vaddr = phys_to_virt(fd->addr);
+   sgt = vaddr + dpa_fd_offset(fd);
+
+   dma_unmap_single(dpa_bp->dev, qm_fd_addr(fd), dpa_bp->size,
+DMA_BIDIRECTIONAL);
+
+   dpa_release_sgt(sgt);
+
+   addr = dma_map_single(dpa_bp->dev, vaddr, dpa_bp->size,
+ DMA_BIDIRECTIONAL);
+   if (dma_mapping_error(dpa_bp->dev, addr)) {
+   dev_err(dpa_bp->dev, "DMA mapping failed");
+   return;
+   }
+   bm_buffer_set64(, addr);
+   }
 
while (bman_release(dpa_bp->pool, , 1, 0))
cpu_relax();
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
index 68843c0..9df8f14 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
@@ -37,6 +37,7 @@
 
 #include "dpaa_eth.h"
 
+#define DPA_SGT_MAX_ENTRIES 16 /* maximum number of entries in SG Table */
 #define DPA_BUFF_RELEASE_MAX 8 /* maximum number of buffers released at 

[v7, 2/6] fsl/fman: Add FMan support

2015-11-02 Thread igal.liberman
From: Igal Liberman 

Add the Data Path Acceleration Architecture Frame Manger Driver.
The FMan embeds a series of hardware blocks that implement a group
of Ethernet interfaces. This patch adds The FMan configuration,
initialization and runtime control routines.

The FMan driver supports several hardware versions
differentiated by things like:
- Different type of MACs
- Number of MAC and ports
- Available resources
- Different hardware errata

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile |2 +-
 drivers/net/ethernet/freescale/fman/fman.c   | 2876 ++
 drivers/net/ethernet/freescale/fman/fman.h   |  325 +++
 3 files changed, 3202 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/fman/fman.c
 create mode 100644 drivers/net/ethernet/freescale/fman/fman.h

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index fc2e194..fb5a7f0 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -2,4 +2,4 @@ subdir-ccflags-y +=  
-I$(srctree)/drivers/net/ethernet/freescale/fman
 
 obj-y  += fsl_fman.o
 
-fsl_fman-objs  := fman_muram.o
+fsl_fman-objs  := fman_muram.o fman.o
diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
new file mode 100644
index 000..f97a52b
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -0,0 +1,2876 @@
+/*
+ * Copyright 2008-2015 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.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include "fman.h"
+#include "fman_muram.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* General defines */
+#define FMAN_LIODN_TBL 64  /* size of LIODN table */
+#define MAX_NUM_OF_MACS10
+#define FM_NUM_OF_FMAN_CTRL_EVENT_REGS 4
+#define BASE_RX_PORTID 0x08
+#define BASE_TX_PORTID 0x28
+
+/* Modules registers offsets */
+#define BMI_OFFSET 0x0008
+#define QMI_OFFSET 0x00080400
+#define DMA_OFFSET 0x000C2000
+#define FPM_OFFSET 0x000C3000
+#define IMEM_OFFSET0x000C4000
+#define CGP_OFFSET 0x000DB000
+
+/* Exceptions bit map */
+#define EX_DMA_BUS_ERROR   0x8000
+#define EX_DMA_READ_ECC0x4000
+#define EX_DMA_SYSTEM_WRITE_ECC0x2000
+#define EX_DMA_FM_WRITE_ECC0x1000
+#define EX_FPM_STALL_ON_TASKS  0x0800
+#define EX_FPM_SINGLE_ECC  0x0400
+#define EX_FPM_DOUBLE_ECC  0x0200
+#define EX_QMI_SINGLE_ECC  0x0100
+#define EX_QMI_DEQ_FROM_UNKNOWN_PORTID 0x0080
+#define EX_QMI_DOUBLE_ECC  0x0040
+#define EX_BMI_LIST_RAM_ECC0x0020
+#define EX_BMI_STORAGE_PROFILE_ECC 0x0010
+#define EX_BMI_STATISTICS_RAM_ECC  0x0008
+#define EX_IRAM_ECC0x0004
+#define EX_MURAM_ECC  

[net-next v4 7/8] dpaa_eth: add sysfs exports

2015-11-02 Thread Madalin Bucur
Export Frame Queue and Buffer Pool IDs through sysfs.

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/dpaa/Makefile   |   2 +-
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c |   2 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.h |   3 +
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.c  |   2 +
 .../net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c   | 167 +
 5 files changed, 175 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c

diff --git a/drivers/net/ethernet/freescale/dpaa/Makefile 
b/drivers/net/ethernet/freescale/dpaa/Makefile
index 9b75d52..141ade4 100644
--- a/drivers/net/ethernet/freescale/dpaa/Makefile
+++ b/drivers/net/ethernet/freescale/dpaa/Makefile
@@ -8,4 +8,4 @@ ccflags-y += -I$(FMAN)
 
 obj-$(CONFIG_FSL_DPAA_ETH) += fsl_dpa.o
 
-fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o dpaa_ethtool.o
+fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o dpaa_ethtool.o 
dpaa_eth_sysfs.o
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 0b3332a..3cd03f5 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -756,6 +756,8 @@ dpaa_eth_priv_probe(struct platform_device *pdev)
if (err < 0)
goto netdev_init_failed;
 
+   dpaa_eth_sysfs_init(_dev->dev);
+
pr_info("Probed interface %s\n", net_dev->name);
 
return 0;
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
index ccaadd9..cdc7595 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
@@ -371,6 +371,9 @@ static inline u16 dpa_get_headroom(struct 
dpa_buffer_layout_s *bl)
return bl->data_align ? ALIGN(headroom, bl->data_align) : headroom;
 }
 
+void dpaa_eth_sysfs_remove(struct device *dev);
+void dpaa_eth_sysfs_init(struct device *dev);
+
 void dpa_private_napi_del(struct net_device *net_dev);
 
 static inline void clear_fd(struct qm_fd *fd)
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
index 4947cb9..2cf4565 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
@@ -299,6 +299,8 @@ int dpa_remove(struct platform_device *pdev)
 
priv = netdev_priv(net_dev);
 
+   dpaa_eth_sysfs_remove(dev);
+
dev_set_drvdata(dev, NULL);
unregister_netdev(net_dev);
 
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
new file mode 100644
index 000..a6c71b1
--- /dev/null
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
@@ -0,0 +1,167 @@
+/* Copyright 2008-2015 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 
+#include 
+#include 
+#include 
+#include 
+#include "dpaa_eth.h"
+#include "mac.h"
+
+static ssize_t dpaa_eth_show_addr(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+   struct 

[net-next v4 5/8] dpaa_eth: add ethtool functionality

2015-11-02 Thread Madalin Bucur
Add support for basic ethtool operations.

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/dpaa/Makefile   |   2 +-
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.c  |   2 +
 .../net/ethernet/freescale/dpaa/dpaa_eth_common.h  |   3 +
 drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 230 +
 4 files changed, 236 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c

diff --git a/drivers/net/ethernet/freescale/dpaa/Makefile 
b/drivers/net/ethernet/freescale/dpaa/Makefile
index 3847ec7..9b75d52 100644
--- a/drivers/net/ethernet/freescale/dpaa/Makefile
+++ b/drivers/net/ethernet/freescale/dpaa/Makefile
@@ -8,4 +8,4 @@ ccflags-y += -I$(FMAN)
 
 obj-$(CONFIG_FSL_DPAA_ETH) += fsl_dpa.o
 
-fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o
+fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o dpaa_ethtool.o
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
index 89f3b1f..2b95696 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c
@@ -102,6 +102,8 @@ int dpa_netdev_init(struct net_device *net_dev,
memcpy(net_dev->perm_addr, mac_addr, net_dev->addr_len);
memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len);
 
+   net_dev->ethtool_ops = _ethtool_ops;
+
net_dev->needed_headroom = priv->tx_headroom;
net_dev->watchdog_timeo = msecs_to_jiffies(tx_timeout);
 
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
index 2e9471d..160a018 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h
@@ -43,6 +43,9 @@
 /* used in napi related functions */
 extern u16 qman_portal_max;
 
+/* from dpa_ethtool.c */
+extern const struct ethtool_ops dpa_ethtool_ops;
+
 int dpa_netdev_init(struct net_device *net_dev,
const u8 *mac_addr,
u16 tx_timeout);
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
new file mode 100644
index 000..fa8ba69
--- /dev/null
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
@@ -0,0 +1,230 @@
+/* Copyright 2008-2015 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.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+
+#include "dpaa_eth.h"
+#include "mac.h"
+#include "dpaa_eth_common.h"
+
+static int dpa_get_settings(struct net_device *net_dev,
+   struct ethtool_cmd *et_cmd)
+{
+   int err;
+   struct dpa_priv_s *priv;
+
+   priv = netdev_priv(net_dev);
+
+   if (!priv->mac_dev->phy_dev) {
+   netdev_dbg(net_dev, "phy device not initialized\n");
+   return 0;
+   }
+
+   err = phy_ethtool_gset(priv->mac_dev->phy_dev, et_cmd);
+
+   return err;
+}
+
+static int dpa_set_settings(struct net_device *net_dev,
+   struct ethtool_cmd *et_cmd)
+{
+   int err;
+   struct dpa_priv_s *priv;
+
+   priv = 

[PATCH] memory-hotplug: Fix kernel warning during memory hotplug on ppc64

2015-11-02 Thread John Allen
This patch fixes a bug where a kernel warning is triggered when performing
a memory hotplug on ppc64. This warning may also occur on any architecture
that has multiple sections per memory block.

[   78.300767] [ cut here ]
[   78.300768] WARNING: at ../drivers/base/memory.c:210
[   78.300769] Modules linked in: rpadlpar_io(X) rpaphp(X) tcp_diag udp_diag 
inet_diag unix_diag af_packet_diag netlink_diag af_packet xfs libcrc32c 
ibmveth(X) rtc_generic btrfs xor raid6_pq xts gf128mul dm_crypt sd_mod sr_mod 
cdrom crc_t10dif ibmvscsi(X) scsi_transport_srp scsi_tgt dm_mod sg scsi_mod 
autofs4
[   78.300789] Supported: Yes, External
[   78.300791] CPU: 1 PID: 3090 Comm: systemd-udevd Tainted: G  X 
3.12.45-1-default #1
[   78.300793] task: c004d7d1d970 ti: c004d7b9 task.ti: 
c004d7b9
[   78.300794] NIP: c04fcff8 LR: c04fda84 CTR: 
[   78.300795] REGS: c004d7b93930 TRAP: 0700   Tainted: G  X  
(3.12.45-1-default)
[   78.300796] MSR: 80029033   CR: 24088848  XER: 

[   78.300800] CFAR: c04fcf98 SOFTE: 1
GPR00: 0537 c004d7b93bb0 c0e7f200 00053000
GPR04: 1000 0001 c0e0f200 
GPR08:  0001 0537 014dc000
GPR12: 00054000 ce7f0900 10041040 
GPR16: 0100206f0010 1003ff78 1006c824 100410b0
GPR20: 1003ff90 1006c00c 01002073cd20 0100206f0760
GPR24: 0100206f85a0 c076d950 c004ef7c95e0 c004d7b93e00
GPR28: c004de601738 0001 c1218f80 003f
[   78.300818] NIP [c04fcff8] memory_block_action+0x258/0x2e0
[   78.300820] LR [c04fda84] memory_subsys_online+0x54/0x100
[   78.300821] Call Trace:
[   78.300822] [c004d7b93bb0] [c9071ce0] 0xc9071ce0 
(unreliable)
[   78.300824] [c004d7b93c40] [c04fda84] 
memory_subsys_online+0x54/0x100
[   78.300826] [c004d7b93c70] [c04df784] device_online+0xb4/0x120
[   78.300828] [c004d7b93cb0] [c04fd738] store_mem_state+0x88/0x220
[   78.300830] [c004d7b93cf0] [c04db448] dev_attr_store+0x68/0xa0
[   78.300833] [c004d7b93d30] [c031f938] sysfs_write_file+0xf8/0x1d0
[   78.300835] [c004d7b93d90] [c027d29c] vfs_write+0xec/0x250
[   78.300837] [c004d7b93de0] [c027dfdc] SyS_write+0x6c/0xf0
[   78.300839] [c004d7b93e30] [c000a17c] syscall_exit+0x0/0x7c
[   78.300840] Instruction dump:
[   78.300841] 780a0560 79482ea4 7ce94214 2fa7 41de0014 7d09402a 396b4000 
7907ffe3
[   78.300844] 4082ff54 3cc2fff9 8926b83a 69290001 <0b09> 2fa9 40de006c 
3860fff0
[   78.300847] ---[ end trace dfec8da06ebbc762 ]---

The warning is triggered because there is a udev rule that automatically
tries to online memory after it has been added. The udev rule varies from
distro to distro, but will generally look something like:

SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online"

On any architecture that uses memory_probe_store to reserve memory,
this can interrupt the memory reservation process. This patch modifies
memory_probe_store to take the hotplug sysfs lock to prevent the online
of added memory before the completion of the probe.

Signed-off-by: John Allen 
---
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 2804aed..baf7a22 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -457,6 +457,10 @@ memory_probe_store(struct device *dev, struct 
device_attribute *attr,
if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1))
return -EINVAL;

+   ret = lock_device_hotplug_sysfs();
+   if (ret)
+   return ret;
+
for (i = 0; i < sections_per_block; i++) {
nid = memory_add_physaddr_to_nid(phys_addr);
ret = add_memory(nid, phys_addr,
@@ -467,6 +471,8 @@ memory_probe_store(struct device *dev, struct 
device_attribute *attr,
phys_addr += MIN_MEMORY_BLOCK_SIZE;
}

+   unlock_device_hotplug();
+
ret = count;
 out:
return ret;

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

Re: [PATCH] nx-842: Ignore bit 3 of condition register returned by icswx

2015-11-02 Thread Michael Ellerman
On Mon, 2015-11-02 at 10:41 -0800, Ram Pai wrote:
> On Mon, Nov 02, 2015 at 12:23:36PM +1100, Michael Ellerman wrote:
> > On Fri, 2015-10-30 at 15:31 -0700, Ram Pai wrote:
> > > icswx occasionally under heavy load sets bit 3 of condition register 0.
> >
> > Why?
>
> The hardware manual says that bit is undefined, though it is set under some
> conditions.

Which hardware manual?

Last I checked none of this was documented anywhere public. But the out of date
RFC I have does define bit zero to mean something.

> > > Currently that bit is interpreted by the driver as a failure, when
> > > it should have calmly ignored it.
> > 
> > Should the fix be in icswx or the driver? Please justify your choice.
> 
> Yes there are two solutions. One is icswx macro should not expose that
> bit to its consumers.  Or the driver/consumers can ignore that bit.  I
> think it makes more sense to contain it in one place, which is icswx
> instruction. Drivers or whoever calls icswx should not know
> more than what they need to know. This patch uses the first approach.

Yep, I'm fine with doing it in icswx if we're 100% sure the bit is always
undefined.

> > This sounds like it's fixing a bug so shouldn't the patch go to stable? And 
> > if
> > so which version(s) should it apply to?
> 
> It should go to stable v4.2.  I will tag it to stable, in my next version.

Thanks.

cheers

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

Re: [net-next v4 3/8] dpaa_eth: add support for S/G frames

2015-11-02 Thread Joe Perches
On Mon, 2015-11-02 at 19:31 +0200, Madalin Bucur wrote:
> Add support for Scater/Gather (S/G) frames. The FMan can place
> the frame content into multiple buffers and provide a S/G Table
> (SGT) into one first buffer with references to the others.

trivia:

> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h 
> b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h
[]
> @@ -347,7 +347,7 @@ static inline void clear_fd(struct qm_fd *fd)
>  }
>  
>  static inline int _dpa_tx_fq_to_id(const struct dpa_priv_s *priv,
> -struct qman_fq *tx_fq)
> + struct qman_fq *tx_fq)

superfluous change?

> +void dpa_release_sgt(struct qm_sg_entry *sgt)
> +{
> + struct dpa_bp *dpa_bp;
> + struct bm_buffer bmb[DPA_BUFF_RELEASE_MAX];
> + u8 i = 0, j;

Using int may be better than u8 for indexing


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

Re: [v2] powerpc/msi: fix section mismatch warning

2015-11-02 Thread Michael Ellerman
On Wed, 2015-21-10 at 11:29:13 UTC, Denis Kirjanov wrote:
> Building with CONFIG_DEBUG_SECTION_MISMATCH
> gives the following warning:
> 
> WARNING: vmlinux.o(.text+0x41fa8): Section mismatch in reference from
> the function .msi_bitmap_alloc() to the function
> .init.text:.memblock_virt_alloc_try_nid()
> The function .msi_bitmap_alloc() references
> the function __init .memblock_virt_alloc_try_nid().
> This is often because .msi_bitmap_alloc lacks a __init
> annotation or the annotation of .memblock_virt_alloc_try_nid is wrong.
> 
> memory allocation in msi_bitmap_alloc use either slab allocator or
> memblock boot-time allocator so that's why we need the __init_refok
> for the latter case.
> 
> Signed-off-by: Denis Kirjanov 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/ccde64b51b33821159d52b09

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

Re: [PATCH powerpc/next 2/2] powerpc: Make {cmp}xchg* and their atomic_ versions fully ordered

2015-11-02 Thread Peter Zijlstra
On Mon, Nov 02, 2015 at 09:30:32AM +0800, Boqun Feng wrote:
> According to memory-barriers.txt, xchg*, cmpxchg* and their atomic_
> versions all need to be fully ordered, however they are now just
> RELEASE+ACQUIRE, which are not fully ordered.
> 
> So also replace PPC_RELEASE_BARRIER and PPC_ACQUIRE_BARRIER with
> PPC_ATOMIC_ENTRY_BARRIER and PPC_ATOMIC_EXIT_BARRIER in
> __{cmp,}xchg_{u32,u64} respectively to guarantee fully ordered semantics
> of atomic{,64}_{cmp,}xchg() and {cmp,}xchg(), as a complement of commit
> b97021f85517 ("powerpc: Fix atomic_xxx_return barrier semantics")
> 
> This patch depends on patch "powerpc: Make value-returning atomics fully
> ordered" for PPC_ATOMIC_ENTRY_BARRIER definition.
> 
> Cc:  # 3.4+
> Signed-off-by: Boqun Feng 

Acked-by: Peter Zijlstra (Intel) 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH V10 10/12] powerpc/eeh: Support error recovery for VF PE

2015-11-02 Thread Wei Yang
On Mon, Nov 02, 2015 at 10:40:36AM +1100, Alexey Kardashevskiy wrote:
>On 11/01/2015 12:53 PM, Wei Yang wrote:
>>On Fri, Oct 30, 2015 at 04:20:48PM +1100, Alexey Kardashevskiy wrote:
>>>On 10/26/2015 02:16 PM, Wei Yang wrote:
Different from PCI bus dependent PE, PE for VFs doesn't have the
>>>
>>>s/Different from/Unlike/
>>>
>>
>>Will change in next version.
>>
>>>
primary bus, on which the PCI hotplug is implemented. The patch
supports error recovery, especially the PCI hotplug for VF's PE.
>>>
>>>The patch adds support for error recovery of what exactly?
>>>What is "especially" about?
>>>
>>
>>PFs are enumerated on PCI bus, while VFs are created by PF's driver.
>>
>>In EEH recovery, it has two cases.
>>1. Device and driver is EEH aware, error handlers are called.
>>2. Device and driver is not EEH aware, un-plug the device and plug it again by
>>enumerating it.
>>
>>The special thing happens on the second case. For a PF, we could use the
>>original pci core to enumerate the bus, while for VF, we need to record the VF
>>which are un-plugged then plug it again.
>
>
>Right. This should have been the actual commit log.
>
>
>>>
The hotplug on VF's PE is implemented based on VFs, instead of
PCI bus any more.
>>>
>>>Needs rephrase.
>>>
>>>Is this patch about EEH error recovery, i.e. unplug VF, re-plug VF? Why does
>>>the commit log talk about PE hotplug? I thought we do VF (i.e. PCI device)
>>>hotplug, not PE.
>>>
>>
>>Hmm... unlike the Bus PE for PFs, VF PE is dynamically created and released
>>when VFs are created and released.
>
>
>Sure. PEs are created/released, not plugged/unplugged (VFs are), that was my
>point.
>

Thanks for the suggestion, will change it in next version.

>
>>
>>>

[gwshan: changelog and code refactoring]
Signed-off-by: Wei Yang 
Acked-by: Gavin Shan 
---
  arch/powerpc/include/asm/eeh.h   |   1 +
  arch/powerpc/kernel/eeh.c|   8 
  arch/powerpc/kernel/eeh_driver.c | 100 
 +++
  arch/powerpc/kernel/eeh_pe.c |   3 +-
  4 files changed, 90 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 331c856..ea1f13c4 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -142,6 +142,7 @@ struct eeh_dev {
struct pci_controller *phb; /* Associated PHB   */
struct pci_dn *pdn; /* Associated PCI device node   */
struct pci_dev *pdev;   /* Associated PCI device*/
+   intin_error;/* Error flag for eeh_dev   */
>>>
>>>Make it "bool".
>>>
>>
>>Will change it in next version.
>>
>>>
struct pci_dev *physfn; /* Associated PF PORT   */
struct pci_bus *bus;/* PCI bus for partial hotplug  */
  };
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index af9b597..28e4d73 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1227,6 +1227,14 @@ void eeh_remove_device(struct pci_dev *dev)
 * from the parent PE during the BAR resotre.
 */
edev->pdev = NULL;
+
+   /*
+* The flag "in_error" is used to trace EEH devices for VFs
+* in error state or not. It's set in eeh_report_error(). If
+* it's not set, eeh_report_{reset,resume}() won't be called
+* for the VF EEH device.
+*/
+   edev->in_error = 0;
dev->dev.archdata.edev = NULL;
if (!(edev->pe->state & EEH_PE_KEEP))
eeh_rmv_from_parent_pe(edev);
diff --git a/arch/powerpc/kernel/eeh_driver.c 
b/arch/powerpc/kernel/eeh_driver.c
index 89eb4bc..99868e2 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -211,6 +211,7 @@ static void *eeh_report_error(void *data, void 
*userdata)
if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
if (*res == PCI_ERS_RESULT_NONE) *res = rc;

+   edev->in_error = 1;
eeh_pcid_put(dev);
return NULL;
  }
@@ -282,7 +283,8 @@ static void *eeh_report_reset(void *data, void 
*userdata)

if (!driver->err_handler ||
!driver->err_handler->slot_reset ||
-   (edev->mode & EEH_DEV_NO_HANDLER)) {
+   (edev->mode & EEH_DEV_NO_HANDLER) ||
+   (!edev->in_error)) {
eeh_pcid_put(dev);
return NULL;
}
@@ -339,14 +341,16 @@ static void *eeh_report_resume(void *data, void 
*userdata)

>>>
>>>bood was_in_error = edev->in_error;
>>>edev->in_error = false;
>>>
>>>then use was_in_error below and there is no need to replace return with goto,
>>>etc -> slightly simpler code.
>>>
>>
>>Will change it in next version.
>>
>>>
if (!driver->err_handler ||

Re: [v2] powerpc/pseries: Correct string length in pseries_of_derive_parent()

2015-11-02 Thread Michael Ellerman
On Tue, 2015-27-10 at 15:46:47 UTC, Nathan Fontenot wrote:
> Commit a030e1e4bbd085bbcfd0a23f8d355fcd41f39bed make a change to use
> kstrndup() instead of kmalloc() + strlcpy() in the pseries_of_derive_parent()
> routine that introduces a subtle change in the parent path name generated.
> The kstrndup() routine will copy n characters followed by a terminating null,
> whereas strlcpy() will copy n-1 characters and add a terminating null.
> 
> This slight difference results in having a parent path that includes the
> tailing '/' character, "/cpus/" vs. "/cpus". This then causes the subsequent
> call to of_find_node_by_path() to fail, and in the case of DLPAR add
> operations the DLPAR request fails.
> 
> This patch decrements the pointer returned from kbasename() to point to the
> '/' character before the base name instead of the base name. This then
> adjusts the string length calculations to not include the trailing '/'
> in the parent path name.
> 
> Signed-off-by: Nathan Fontenot 
> Reviewed-by: Andy Shevchenko 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f755ecfb8cec7b19dff84295

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

Re: [PATCH powerpc/next 1/2] powerpc: Make value-returning atomics fully ordered

2015-11-02 Thread Peter Zijlstra
On Mon, Nov 02, 2015 at 09:30:31AM +0800, Boqun Feng wrote:
> According to memory-barriers.txt:
> 
> > Any atomic operation that modifies some state in memory and returns
> > information about the state (old or new) implies an SMP-conditional
> > general memory barrier (smp_mb()) on each side of the actual
> > operation ...
> 
> Which mean these operations should be fully ordered. However on PPC,
> PPC_ATOMIC_ENTRY_BARRIER is the barrier before the actual operation,
> which is currently "lwsync" if SMP=y. The leading "lwsync" can not
> guarantee fully ordered atomics, according to Paul Mckenney:
> 
> https://lkml.org/lkml/2015/10/14/970
> 
> To fix this, we define PPC_ATOMIC_ENTRY_BARRIER as "sync" to guarantee
> the fully-ordered semantics.
> 
> This also makes futex atomics fully ordered, which can avoid possible
> memory ordering problems if userspace code relies on futex system call
> for fully ordered semantics.
> 
> Cc:  # 3.4+
> Signed-off-by: Boqun Feng 

Acked-by: Peter Zijlstra (Intel) 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence

2015-11-02 Thread Scott Wood
On Mon, 2015-11-02 at 00:12 -0600, Dogra Raghav-B46184 wrote:
> -Original Message-
> From: Raghav Dogra [mailto:rag...@freescale.com] 
> Sent: Friday, October 30, 2015 11:55 AM
> To: linuxppc-dev@lists.ozlabs.org
> Cc: Wood Scott-B07421 ; Kushwaha Prabhakar-B32579 <
> prabha...@freescale.com>; Dogra Raghav-B46184 
> Subject: [PATCH 1/2] mpc85xx/lbc: modify suspend/resume entry sequence
> 
> Modify platform driver suspend/resume to syscore suspend/resume. This is 
> because p1022ds needs to use localbus when entering the PCIE resume.
> 
> Signed-off-by: Raghav Dogra 
> ---
>  arch/powerpc/sysdev/Makefile  |  2 +-
>  arch/powerpc/sysdev/fsl_lbc.c | 51 +---
> ---
>  2 files changed, 40 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile 
> index f7cb2a1..4c19e614 100644
> --- a/arch/powerpc/sysdev/Makefile
> +++ b/arch/powerpc/sysdev/Makefile
> @@ -18,9 +18,9 @@ obj-$(CONFIG_PPC_PMI)   += pmi.o
>  obj-$(CONFIG_U3_DART)+= dart_iommu.o
>  obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
>  obj-$(CONFIG_FSL_SOC)+= fsl_soc.o fsl_mpic_err.o
> +obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
>  obj-$(CONFIG_FSL_PCI)+= fsl_pci.o $(fsl-msi-obj-y)
>  obj-$(CONFIG_FSL_PMC)+= fsl_pmc.o
> -obj-$(CONFIG_FSL_LBC)+= fsl_lbc.o
>  obj-$(CONFIG_FSL_GTM)+= fsl_gtm.o
>  obj-$(CONFIG_FSL_85XX_CACHE_SRAM)+= fsl_85xx_l2ctlr.o 
> fsl_85xx_cache_sram.o
>  obj-$(CONFIG_SIMPLE_GPIO)+= simple_gpio.o
> diff --git a/arch/powerpc/sysdev/fsl_lbc.c b/arch/powerpc/sysdev/fsl_lbc.c 
> index d631022..332d700 100644
> --- a/arch/powerpc/sysdev/fsl_lbc.c
> +++ b/arch/powerpc/sysdev/fsl_lbc.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -354,24 +355,42 @@ err:
>  #ifdef CONFIG_SUSPEND
>  
>  /* save lbc registers */
> -static int fsl_lbc_suspend(struct platform_device *pdev, pm_message_t 
> state)
> +static int fsl_lbc_syscore_suspend(void)
>  {
> - struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(>dev);
> - struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
> + struct fsl_lbc_ctrl *ctrl;
> + struct fsl_lbc_regs __iomem *lbc;
> +
> + ctrl = fsl_lbc_ctrl_dev;
> + if (!ctrl)
> + goto out;
> +
> + lbc = ctrl->regs;
> + if (!lbc)
> + goto out;
>  
>   ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL);
>   if (!ctrl->saved_regs)
>   return -ENOMEM;
> [Dogra Raghav-B46184] This is the existing upstream code. Are you 
> suggesting to modify the upstream code to take care of individual registers?

What specifically do you mean by "the upstream code"?  What other tree are we 
talking about here?

-Scott

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

Re: [PATCH] cxl: Fix reference count on struct pid when attaching

2015-11-02 Thread Ian Munsie
Excerpts from Michael Ellerman's message of 2015-11-02 11:53:45 +1100:
> On Thu, 2015-10-29 at 13:39 +0100, Frederic Barrat wrote:
> 
> > When the cxl driver creates a context, it stores the pid of the
> > calling task, incrementing the reference count on the struct
> > pid. Current code mistakenly increments the reference count twice,
> > once through get_task_pid(), once through get_pid(). The reference
> > count is only decremented once on detach, thus the struct pid of the
> > task attaching is never freed. The fix is to simply remove the call to
> > get_pid().
> > 
> > Signed-off-by: Frederic Barrat 
> 
> What's the symptom?

Everytime a process attached to a capi device it would reduce the total
number of processes that can be running simultaneously by one.

> Broken since when?
> Forever?
> So should go to stable?
> Starting from which release?

Looks like we managed to introduce the same bug twice (d'oh!), so we
should probably split this into two separate patches:

The bug in file.c has existed forever so the fix for that should go to
stable for 3.18+

The bug in api.c will only need to go in for 4.3 since that is the
release where cxlflash was merged and there weren't any users of that
code before that.

Cheers
-Ian

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

Re: [PATCH V10 08/12] powerpc/powernv: Support EEH reset for VF PE

2015-11-02 Thread Wei Yang
On Fri, Oct 30, 2015 at 07:05:05PM +1100, Alexey Kardashevskiy wrote:
>On 10/30/2015 06:18 PM, Wei Yang wrote:
>>On Fri, Oct 30, 2015 at 03:11:20PM +1100, Alexey Kardashevskiy wrote:
>>>On 10/26/2015 02:15 PM, Wei Yang wrote:
PEs for VFs don't have primary bus. So they have to have their own reset
backend, which is used during EEH recovery. The patch implements the reset
backend for VF's PE by issuing FLR or AF FLR to the VFs, which are contained
in the PE.

[gwshan: changelog and code refactoring]
Signed-off-by: Wei Yang 
Acked-by: Gavin Shan 
---
  arch/powerpc/include/asm/eeh.h   |   1 +
  arch/powerpc/platforms/powernv/eeh-powernv.c | 134 
 ++-
  2 files changed, 134 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index ec21f8f..331c856 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -136,6 +136,7 @@ struct eeh_dev {
int pcix_cap;   /* Saved PCIx capability*/
int pcie_cap;   /* Saved PCIe capability*/
int aer_cap;/* Saved AER capability */
+   int af_cap; /* Saved AF capability  */
struct eeh_pe *pe;  /* Associated PE*/
struct list_head list;  /* Form link list in the PE */
struct pci_controller *phb; /* Associated PHB   */
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c 
b/arch/powerpc/platforms/powernv/eeh-powernv.c
index cfd55dd..017cd72 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -404,6 +404,7 @@ static void *pnv_eeh_probe(struct pci_dn *pdn, void 
*data)
edev->pcix_cap = pnv_eeh_find_cap(pdn, PCI_CAP_ID_PCIX);
edev->pcie_cap = pnv_eeh_find_cap(pdn, PCI_CAP_ID_EXP);
edev->aer_cap  = pnv_eeh_find_ecap(pdn, PCI_EXT_CAP_ID_ERR);
+   edev->af_cap   = pnv_eeh_find_cap(pdn, PCI_CAP_ID_AF);
if ((edev->class_code >> 8) == PCI_CLASS_BRIDGE_PCI) {
edev->mode |= EEH_DEV_BRIDGE;
if (edev->pcie_cap) {
@@ -893,6 +894,127 @@ static int pnv_eeh_bridge_reset(struct pci_dev *dev, 
int option)
return 0;
  }

+static void pnv_eeh_wait_for_pending(struct pci_dn *pdn, int pos,
+u16 mask, bool af_flr_rst)
>
>Missed this - @af_flr_rst is only used for warnings so better do:
>s/bool af_flr_rst/const char *reset_type/
>to make it explicit.
>

Looks good, will change in next version.

>
+{
+   struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
+   int status, i;
+
+   /* Wait for Transaction Pending bit to be cleared */
+   for (i = 0; i < 4; i++) {
+   eeh_ops->read_config(pdn, pos, 2, );
>>>
>>>
>>>gcc should have complained on using uninitialized @status here.
>>>
>>
>>I remove the obj file and re-compile the file, not the warning.
>
>Hm. Does not warn me either.
>
>>And took a look at other places where read_config() is called. The laster
>>parameter is not initialized before called.
>
>So? It does not make it right.
>
>>You see the error during build?
>
>Why does it matter? We have an undefined behavior here which we should not.
>You could test the return values from read_config() but you do not so at
>least initialize local variables.
>

I believe your concern is reasonable.

I suggest to have a separate patch to fix the read_config() by initialize the
last parameter.

>
>>
>>>
+   if (!(status & mask))
+   return;
+
+   msleep((1 << i) * 100);
+   }
+
+   pr_warn("%s: Pending transaction while issuing %s FLR to "
+   "%04x:%02x:%02x.%01x\n",
>>>
>>>Do not wrap user-visible strings.
>>>
>>
>>Will change this.
>>
>>>
+   __func__, af_flr_rst ? "AF" : "",
+   edev->phb->global_number, pdn->busno,
+   PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
+}
+
+static int pnv_eeh_do_flr(struct pci_dn *pdn, int option)
+{
+   struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
+   u32 reg;
+
+   if (!edev->pcie_cap)
+   return -ENOTTY;
>>>
>>>
>>>Can pnv_eeh_do_flr() be really called on a non PCIe device, can we get that
>>>far? WARN_ON_ONCE() may be?
>>>
>>
>>So you suggest to add a WARN_ON_ONCE() in this condition, right?
>
>I am asking a question here whether it makes sense or not to add a
>WARN_ON_ONCE or replace "if" with WARN_ON_ONCE or not having pcie_cap
>initialized is possible in this code - which one is it?
>

I think the check here is reasonable. In the body of this function, pcie_cap
is used to access the config space. If we remove this, it would be a 

Re: [PATCH] cxl: Fix reference count on struct pid when attaching

2015-11-02 Thread Michael Ellerman
On Tue, 2015-11-03 at 10:48 +1100, Ian Munsie wrote:
> Excerpts from Michael Ellerman's message of 2015-11-02 11:53:45 +1100:
> > On Thu, 2015-10-29 at 13:39 +0100, Frederic Barrat wrote:
> > 
> > > When the cxl driver creates a context, it stores the pid of the
> > > calling task, incrementing the reference count on the struct
> > > pid. Current code mistakenly increments the reference count twice,
> > > once through get_task_pid(), once through get_pid(). The reference
> > > count is only decremented once on detach, thus the struct pid of the
> > > task attaching is never freed. The fix is to simply remove the call to
> > > get_pid().
> > > 
> > > Signed-off-by: Frederic Barrat 
> > 
> > What's the symptom?
> 
> Everytime a process attached to a capi device it would reduce the total
> number of processes that can be running simultaneously by one.

Right, and reduced it permanently until the next reboot, so eventually you'd
kill your system presumably.

cheers

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

Re: [v7, 2/6] fsl/fman: Add FMan support

2015-11-02 Thread David Miller
From: 
Date: Mon, 2 Nov 2015 14:30:12 +0200

> +static int clear_iram(struct fman *fman)
> +{
> + struct fman_iram_regs __iomem *iram;
> + int i, count;
> +
> + iram = (struct fman_iram_regs __iomem *)(fman->base_addr + IMEM_OFFSET);

"fman->base_addr" is of type "void __iomem *", therefore no cast should
be necessary at all.

Please audit your entire driver submission for this problem.

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