Re: [PATCH kernel] powerpc: Bump minimum zone order for 4K system page size

2016-09-22 Thread Balbir Singh


On 23/09/16 14:51, Alexey Kardashevskiy wrote:
> The moderm kernel on powernv platform cannot possibly boot with values
> less than 12 as the default DMA window of 2GB requires
> (2<<30)/4096 TCEs which is 4MB of contiguous memory, log2(4M) == 22
> so anything less than 12 won't work.
> 
> Signed-off-by: Alexey Kardashevskiy 
> ---
> 
> I am hitting this when switching the system page size from 64K to 4K and
> back. When I switch to 64K, zone order is set to 9 by default and
> it does not change when I switch to 4K as 9 is still within the limits.
> And there are other folks complaining about this too.
> ---
>  arch/powerpc/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 927d2ab..3516f16 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -637,7 +637,7 @@ config FORCE_MAX_ZONEORDER
>   int "Maximum zone order"
>   range 8 9 if PPC64 && PPC_64K_PAGES
>   default "9" if PPC64 && PPC_64K_PAGES
> - range 9 13 if PPC64 && !PPC_64K_PAGES
> + range 12 13 if PPC64 && !PPC_64K_PAGES
>   default "13" if PPC64 && !PPC_64K_PAGES
>   range 9 64 if PPC32 && PPC_16K_PAGES
>   default "9" if PPC32 && PPC_16K_PAGES
> 

Aneesh already submitted a patch for this

Balbir Singh.


[PATCH kernel] powerpc: Bump minimum zone order for 4K system page size

2016-09-22 Thread Alexey Kardashevskiy
The moderm kernel on powernv platform cannot possibly boot with values
less than 12 as the default DMA window of 2GB requires
(2<<30)/4096 TCEs which is 4MB of contiguous memory, log2(4M) == 22
so anything less than 12 won't work.

Signed-off-by: Alexey Kardashevskiy 
---

I am hitting this when switching the system page size from 64K to 4K and
back. When I switch to 64K, zone order is set to 9 by default and
it does not change when I switch to 4K as 9 is still within the limits.
And there are other folks complaining about this too.
---
 arch/powerpc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 927d2ab..3516f16 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -637,7 +637,7 @@ config FORCE_MAX_ZONEORDER
int "Maximum zone order"
range 8 9 if PPC64 && PPC_64K_PAGES
default "9" if PPC64 && PPC_64K_PAGES
-   range 9 13 if PPC64 && !PPC_64K_PAGES
+   range 12 13 if PPC64 && !PPC_64K_PAGES
default "13" if PPC64 && !PPC_64K_PAGES
range 9 64 if PPC32 && PPC_16K_PAGES
default "9" if PPC32 && PPC_16K_PAGES
-- 
2.5.0.rc3



Re: [PATCH v2] powerpc/mm: export current mmu mode info

2016-09-22 Thread Aneesh Kumar K.V
Hari Bathini  writes:

> Hi Aneesh,
>
>
> On Thursday 22 September 2016 09:54 PM, Aneesh Kumar K.V wrote:
>> Hari Bathini  writes:
>>
>>> The kernel now supports both radix and hash MMU modes. Tools like crash
>>> and makedumpfile need to know the current MMU mode the kernel is using,
>>> to debug/analyze it.  The current MMU mode depends on hardware support
>>> and also whether disable_radix cmdline parameter is passed to the kernel.
>>> The mmu_features member of cpu_spec structure holds the current MMU mode
>>> a cpu is using. But the above mentioned tools need to know the MMU mode
>>> early in their init process, when they may not have access to offset info
>>> of structure members. A hard-coded offset may help but it won't be robust.
>> IIUC, you walk the linux page table and that should be more or less same
>
> Taking the case of crash tool, vmemmap start value is currently
> hard-coded to 0xf000UL but it changed to
> 0xc00aUL in case of radix.

All of that is already defined as variables in the kernel. You can look at
radix__early_init_mmu().


>
>> between radix/hash right except few bits. Now what crash will be
>> interested in will be the RPN part of the table which should be same
>> between hash/radix.
>
> Though the walk is pretty much the same, the tool still needs to know
> the right index values and vmemmap start to use, as they are different
> for radix and hash..
>
>>> This patch introduces a new global variable, which holds the current MMU
>>> mode the kernel is running in and can be accessed by tools early in thier
>>> init process,
>> Init process of what ? kernel or crash tool ?
>
> tool initialization - crash or makedumpfile..
>
>>> helping tools to initialize accurately for each MMU mode.
>>> This patch also optimizes the radix_enabled() function call.
>>>
>> how do you differentiate between the hold linux page table format and
>> the new ? Can you also summarize what crash tool look for in the page
>> table ?
>
> It needs the index sizes, masked bit values and page flag info to
> do the page table walk. Since they can be different for hash and
> radix..
>

Can you look at radix__early_init_mmu/hash__early_init_mmu and see you
can work with the variables defined there ?

-aneesh



Re: [PATCH] Work around for enabling CONFIG_CMDLINE on ppc64le

2016-09-22 Thread Akshay Adiga

Hi Michael,

Anton found this bug and raised it against gcc v7.0 and a fix is available
 in upstream gcc.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71709

Currently, gcc v5.4.0  and v6.1.1 shipped with Ubuntu 16.04 and 16.10  
respectively,
 are hitting this problem.

I have also raised bug against Ubuntu for fixing gcc for 16.04.

https://bugzilla.linux.ibm.com/show_bug.cgi?id=146668


On 09/22/2016 03:51 PM, Michael Ellerman wrote:

Akshay Adiga  writes:


Observed that boot arguments (passed as CONFIG_CMDLINE)  are not being
picked up by kernel while using gcc-ppc64-linux-gnu v5.4.0 and v6.1.1.
While it works as expected with v5.3.1 .

Found that in init/main.c in  setup_command_line() the pointers passed to
strcpy() is messed up.

Hi Akshay,

Thanks for debugging this.


The problem goes away when compiler optimization is restricted to -O1.
diff --git a/init/main.c b/init/main.c
index a8a58e2..4259c42 100644
--- a/init/main.c
+++ b/init/main.c
@@ -358,7 +358,13 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) 
{ }
   * parsing is performed in place, and we should allow a component to
   * store reference of name/value for future reference.
   */
-static void __init setup_command_line(char *command_line)
+static void __init
+#ifdef CONFIG_PPC64
+   #if  GCC_VERSION > 50301
+   __attribute__((optimize("-O1")))
+   #endif
+#endif
+   setup_command_line(char *command_line)
  {
saved_command_line =
memblock_virt_alloc(strlen(boot_command_line) + 1, 0);

But I can't merge that patch.

Our options are one or both of:
  - get GCC fixed and backport the fix to the compilers we care about.
  - blacklist the broken compiler versions.

Is there a GCC bug filed for this?

cheers





[PATCH v6 2/2] QE: remove PPCisms for QE

2016-09-22 Thread Zhao Qiang
QE was supported on PowerPC, and dependent on PPC,
Now it is supported on other platforms. so remove PPCisms.

Signed-off-by: Zhao Qiang 
---
Changes for v2:
- na
Changes for v3:
- add NO_IRQ
Changes for v4:
- modify spin_event_timeout to opencoded timeout loop
- remove NO_IRQ
- modify virq_to_hw to opencoed code
Changes for v5:
- modify commit msg
- modify depends of QUICC_ENGINE
- add kerneldoc header for qe_issue_cmd
Changes for v6:
- add dependency on FSL_SOC and PPC32 for drivers
  depending on QUICC_ENGING but not available on ARM

 drivers/irqchip/qe_ic.c| 28 +++-
 drivers/net/ethernet/freescale/Kconfig | 10 ++---
 drivers/soc/fsl/qe/Kconfig |  2 +-
 drivers/soc/fsl/qe/qe.c| 80 --
 drivers/soc/fsl/qe/qe_io.c | 42 --
 drivers/soc/fsl/qe/qe_tdm.c|  8 ++--
 drivers/soc/fsl/qe/ucc.c   | 10 ++---
 drivers/soc/fsl/qe/ucc_fast.c  | 68 ++---
 drivers/tty/serial/Kconfig |  2 +-
 drivers/usb/gadget/udc/Kconfig |  2 +-
 drivers/usb/host/Kconfig   |  2 +-
 include/soc/fsl/qe/qe.h|  1 -
 include/soc/fsl/qe/qe_ic.h | 12 ++---
 13 files changed, 141 insertions(+), 126 deletions(-)

diff --git a/drivers/irqchip/qe_ic.c b/drivers/irqchip/qe_ic.c
index 46652c0..32deb60 100644
--- a/drivers/irqchip/qe_ic.c
+++ b/drivers/irqchip/qe_ic.c
@@ -18,7 +18,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -177,13 +180,13 @@ static struct qe_ic_info qe_ic_info[] = {
 
 static inline u32 qe_ic_read(volatile __be32  __iomem * base, unsigned int reg)
 {
-   return in_be32(base + (reg >> 2));
+   return ioread32be(base + (reg >> 2));
 }
 
 static inline void qe_ic_write(volatile __be32  __iomem * base, unsigned int 
reg,
   u32 value)
 {
-   out_be32(base + (reg >> 2), value);
+   iowrite32be(value, base + (reg >> 2));
 }
 
 static inline struct qe_ic *qe_ic_from_irq(unsigned int virq)
@@ -285,7 +288,7 @@ static const struct irq_domain_ops qe_ic_host_ops = {
.xlate = irq_domain_xlate_onetwocell,
 };
 
-/* Return an interrupt vector or NO_IRQ if no interrupt is pending. */
+/* Return an interrupt vector or 0 if no interrupt is pending. */
 unsigned int qe_ic_get_low_irq(struct qe_ic *qe_ic)
 {
int irq;
@@ -296,12 +299,12 @@ unsigned int qe_ic_get_low_irq(struct qe_ic *qe_ic)
irq = qe_ic_read(qe_ic->regs, QEIC_CIVEC) >> 26;
 
if (irq == 0)
-   return NO_IRQ;
+   return 0;
 
return irq_linear_revmap(qe_ic->irqhost, irq);
 }
 
-/* Return an interrupt vector or NO_IRQ if no interrupt is pending. */
+/* Return an interrupt vector or 0 if no interrupt is pending. */
 unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic)
 {
int irq;
@@ -312,7 +315,7 @@ unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic)
irq = qe_ic_read(qe_ic->regs, QEIC_CHIVEC) >> 26;
 
if (irq == 0)
-   return NO_IRQ;
+   return 0;
 
return irq_linear_revmap(qe_ic->irqhost, irq);
 }
@@ -355,7 +358,7 @@ static int __init qe_ic_init(unsigned int flags)
qe_ic->virq_high = irq_of_parse_and_map(node, 0);
qe_ic->virq_low = irq_of_parse_and_map(node, 1);
 
-   if (qe_ic->virq_low == NO_IRQ) {
+   if (qe_ic->virq_low == 0) {
pr_err("Failed to map QE_IC low IRQ\n");
ret = -ENOMEM;
goto err_domain_remove;
@@ -387,7 +390,7 @@ static int __init qe_ic_init(unsigned int flags)
irq_set_handler_data(qe_ic->virq_low, qe_ic);
irq_set_chained_handler(qe_ic->virq_low, qe_ic_cascade_low_mpic);
 
-   if (qe_ic->virq_high != NO_IRQ &&
+   if (qe_ic->virq_high != 0 &&
qe_ic->virq_high != qe_ic->virq_low) {
irq_set_handler_data(qe_ic->virq_high, qe_ic);
irq_set_chained_handler(qe_ic->virq_high,
@@ -407,7 +410,8 @@ err_put_node:
 void qe_ic_set_highest_priority(unsigned int virq, int high)
 {
struct qe_ic *qe_ic = qe_ic_from_irq(virq);
-   unsigned int src = virq_to_hw(virq);
+   struct irq_data *irq_data = irq_get_irq_data(virq);
+   irq_hw_number_t src = WARN_ON(!irq_data) ? 0 : irq_data->hwirq;
u32 temp = 0;
 
temp = qe_ic_read(qe_ic->regs, QEIC_CICR);
@@ -425,7 +429,8 @@ void qe_ic_set_highest_priority(unsigned int virq, int high)
 int qe_ic_set_priority(unsigned int virq, unsigned int priority)
 {
struct qe_ic *qe_ic = qe_ic_from_irq(virq);
-   unsigned int src = virq_to_hw(virq);
+   struct irq_data *irq_data = irq_get_irq_data(virq);
+   irq_hw_number_t src = WARN_ON(!irq_data) ? 0 : irq_data->hwirq;
u32 temp;
 
if 

[PATCH v6 1/2] qe: modify get_qe_base function

2016-09-22 Thread Zhao Qiang
modify get_qe_base function with of_address_to_resource
instead of of_get_property and of_translate_address.

Signed-off-by: Zhao Qiang 
---
Changes for v2:
- na
Changes for v3:
- na
Changes for v4:
- na
Changes for v5:
- na
Changes for v6:
- na

 drivers/soc/fsl/qe/qe.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c
index 7026507..2707a82 100644
--- a/drivers/soc/fsl/qe/qe.c
+++ b/drivers/soc/fsl/qe/qe.c
@@ -69,8 +69,8 @@ static phys_addr_t qebase = -1;
 phys_addr_t get_qe_base(void)
 {
struct device_node *qe;
-   int size;
-   const u32 *prop;
+   int ret;
+   struct resource res;
 
if (qebase != -1)
return qebase;
@@ -82,9 +82,9 @@ phys_addr_t get_qe_base(void)
return qebase;
}
 
-   prop = of_get_property(qe, "reg", );
-   if (prop && size >= sizeof(*prop))
-   qebase = of_translate_address(qe, prop);
+   ret = of_address_to_resource(qe, 0, );
+   if (!ret)
+   qebase = res.start;
of_node_put(qe);
 
return qebase;
-- 
2.1.0.27.g96db324



RE: [PATCH v5 2/2] QE: remove PPCisms for QE

2016-09-22 Thread Qiang Zhao
On Fri, Sep 23, 2016 at 3:39 AM, Leo Li wrote:

> -Original Message-
> From: Leo Li [mailto:pku@gmail.com]
> Sent: Friday, September 23, 2016 3:39 AM
> To: Qiang Zhao 
> Cc: Scott Wood ; linuxppc-dev  d...@lists.ozlabs.org>; lkml ; X.B. Xie
> 
> Subject: Re: [PATCH v5 2/2] QE: remove PPCisms for QE
> 
> On Wed, Sep 21, 2016 at 8:43 PM, Qiang Zhao  wrote:
> > On Mon, Sep 22, 2016 at 2:19 AM, Leo Li wrote:
> >> -Original Message-
> >> From: Leo Li [mailto:pku@gmail.com]
> >> Sent: Thursday, September 22, 2016 2:19 AM
> >> To: Qiang Zhao 
> >> Cc: Scott Wood ; linuxppc-dev  >> d...@lists.ozlabs.org>; lkml ; X.B. Xie
> >> 
> >> Subject: Re: [PATCH v5 2/2] QE: remove PPCisms for QE
> >>
> >> On Tue, Sep 20, 2016 at 8:13 PM, Qiang Zhao  wrote:
> >> > On Mon, Sep 20, 2016 at 4:13 AM, Leo Li wrote:
> >> >> -Original Message-
> >> >> From: Leo Li [mailto:pku@gmail.com]
> >> >> Sent: Tuesday, September 20, 2016 4:13 AM
> >> >> To: Qiang Zhao 
> >> >> Cc: Scott Wood ; linuxppc-dev  >> >> d...@lists.ozlabs.org>; lkml ; X.B.
> >> >> Xie 
> >> >> Subject: Re: [PATCH v5 2/2] QE: remove PPCisms for QE
> >> >>
> >> >> On Mon, Jul 25, 2016 at 12:43 AM, Zhao Qiang 
> >> wrote:
> >> >> > QE was supported on PowerPC, and dependent on PPC, Now it is
> >> >> > supported on other platforms. so remove PPCisms.
> >> >> >
> >> >> > Signed-off-by: Zhao Qiang 
> >> >> > ---
> >> >> > Changes for v2:
> >> >> > - na
> >> >> > Changes for v3:
> >> >> > - add NO_IRQ
> >> >> > Changes for v4:
> >> >> > - modify spin_event_timeout to opencoded timeout loop
> >> >> > - remove NO_IRQ
> >> >> > - modify virq_to_hw to opencoed code Changes for v5:
> >> >> > - modify commit msg
> >> >> > - modify depends of QUICC_ENGINE
> >> >> > - add kerneldoc header for qe_issue_cmd
> >> >> >
> >> >> >  drivers/irqchip/qe_ic.c   | 28 +--
> >> >> >  drivers/soc/fsl/qe/Kconfig|  2 +-
> >> >> >  drivers/soc/fsl/qe/qe.c   | 80 ++--
> 
> >> 
> >> >> ---
> >> >> >  drivers/soc/fsl/qe/qe_io.c| 42 ++-
> >> >> >  drivers/soc/fsl/qe/qe_tdm.c   |  8 ++---
> >> >> >  drivers/soc/fsl/qe/ucc.c  | 10 +++---
> >> >> >  drivers/soc/fsl/qe/ucc_fast.c | 68 ++
> --
> >> >> >  include/soc/fsl/qe/qe.h   |  1 -
> >> >> >  include/soc/fsl/qe/qe_ic.h| 12 +++
> >> >> >  9 files changed, 133 insertions(+), 118 deletions(-)
> >> >> >
> >> >>
> >> >> [snip]
> >> >>
> >> >> > diff --git a/drivers/soc/fsl/qe/Kconfig
> >> >> > b/drivers/soc/fsl/qe/Kconfig index 73a2e08..b26b643 100644
> >> >> > --- a/drivers/soc/fsl/qe/Kconfig
> >> >> > +++ b/drivers/soc/fsl/qe/Kconfig
> >> >> > @@ -4,7 +4,7 @@
> >> >> >
> >> >> >  config QUICC_ENGINE
> >> >> > bool "Freescale QUICC Engine (QE) Support"
> >> >> > -   depends on FSL_SOC && PPC32
> >> >> > +   depends on OF && HAS_IOMEM
> >> >> > select GENERIC_ALLOCATOR
> >> >> > select CRC32
> >> >> > help
> >> >>
> >> >> You make it possible to build QE drivers on ARM, but the UCC_GETH
> >> >> fails to build on arm64.  Please make sure all these drivers can
> >> >> build on other architectures.  Or you can simply make them only
> >> >> build for Power architecture as most of them are not available on ARM.
> >> >>
> >> >
> >> > Most of them are not available on ARM and ARM64.
> >> > Now, only qe-hdlc is available on ARM64.
> >>
> >> Then you should update the Kconfig for these drivers too, if they are
> >> only depending on CONFIG_QUICC_ENGINE.
> >
> > You mean adding "depends on FSL_SOC && PPC32 " to the drivers that are
> not available for ARM?
> 
> Yes.  Previously these drivers get the architecture limitation from
> CONFIG_QUICC_ENGINE, but now they need them by their own.
> 


Ok, I will modify it in the next vertion.

BR
-Zhao Qiang


Re: [PATCH v5 2/2] QE: remove PPCisms for QE

2016-09-22 Thread Leo Li
On Wed, Sep 21, 2016 at 8:43 PM, Qiang Zhao  wrote:
> On Mon, Sep 22, 2016 at 2:19 AM, Leo Li wrote:
>> -Original Message-
>> From: Leo Li [mailto:pku@gmail.com]
>> Sent: Thursday, September 22, 2016 2:19 AM
>> To: Qiang Zhao 
>> Cc: Scott Wood ; linuxppc-dev > d...@lists.ozlabs.org>; lkml ; X.B. Xie
>> 
>> Subject: Re: [PATCH v5 2/2] QE: remove PPCisms for QE
>>
>> On Tue, Sep 20, 2016 at 8:13 PM, Qiang Zhao  wrote:
>> > On Mon, Sep 20, 2016 at 4:13 AM, Leo Li wrote:
>> >> -Original Message-
>> >> From: Leo Li [mailto:pku@gmail.com]
>> >> Sent: Tuesday, September 20, 2016 4:13 AM
>> >> To: Qiang Zhao 
>> >> Cc: Scott Wood ; linuxppc-dev > >> d...@lists.ozlabs.org>; lkml ; X.B. Xie
>> >> 
>> >> Subject: Re: [PATCH v5 2/2] QE: remove PPCisms for QE
>> >>
>> >> On Mon, Jul 25, 2016 at 12:43 AM, Zhao Qiang 
>> wrote:
>> >> > QE was supported on PowerPC, and dependent on PPC, Now it is
>> >> > supported on other platforms. so remove PPCisms.
>> >> >
>> >> > Signed-off-by: Zhao Qiang 
>> >> > ---
>> >> > Changes for v2:
>> >> > - na
>> >> > Changes for v3:
>> >> > - add NO_IRQ
>> >> > Changes for v4:
>> >> > - modify spin_event_timeout to opencoded timeout loop
>> >> > - remove NO_IRQ
>> >> > - modify virq_to_hw to opencoed code Changes for v5:
>> >> > - modify commit msg
>> >> > - modify depends of QUICC_ENGINE
>> >> > - add kerneldoc header for qe_issue_cmd
>> >> >
>> >> >  drivers/irqchip/qe_ic.c   | 28 +--
>> >> >  drivers/soc/fsl/qe/Kconfig|  2 +-
>> >> >  drivers/soc/fsl/qe/qe.c   | 80 ++--
>> 
>> >> ---
>> >> >  drivers/soc/fsl/qe/qe_io.c| 42 ++-
>> >> >  drivers/soc/fsl/qe/qe_tdm.c   |  8 ++---
>> >> >  drivers/soc/fsl/qe/ucc.c  | 10 +++---
>> >> >  drivers/soc/fsl/qe/ucc_fast.c | 68 ++--
>> >> >  include/soc/fsl/qe/qe.h   |  1 -
>> >> >  include/soc/fsl/qe/qe_ic.h| 12 +++
>> >> >  9 files changed, 133 insertions(+), 118 deletions(-)
>> >> >
>> >>
>> >> [snip]
>> >>
>> >> > diff --git a/drivers/soc/fsl/qe/Kconfig
>> >> > b/drivers/soc/fsl/qe/Kconfig index 73a2e08..b26b643 100644
>> >> > --- a/drivers/soc/fsl/qe/Kconfig
>> >> > +++ b/drivers/soc/fsl/qe/Kconfig
>> >> > @@ -4,7 +4,7 @@
>> >> >
>> >> >  config QUICC_ENGINE
>> >> > bool "Freescale QUICC Engine (QE) Support"
>> >> > -   depends on FSL_SOC && PPC32
>> >> > +   depends on OF && HAS_IOMEM
>> >> > select GENERIC_ALLOCATOR
>> >> > select CRC32
>> >> > help
>> >>
>> >> You make it possible to build QE drivers on ARM, but the UCC_GETH
>> >> fails to build on arm64.  Please make sure all these drivers can
>> >> build on other architectures.  Or you can simply make them only build
>> >> for Power architecture as most of them are not available on ARM.
>> >>
>> >
>> > Most of them are not available on ARM and ARM64.
>> > Now, only qe-hdlc is available on ARM64.
>>
>> Then you should update the Kconfig for these drivers too, if they are only
>> depending on CONFIG_QUICC_ENGINE.
>
> You mean adding "depends on FSL_SOC && PPC32 " to the drivers that are not 
> available for ARM?

Yes.  Previously these drivers get the architecture limitation from
CONFIG_QUICC_ENGINE, but now they need them by their own.

Regards,
Leo


Re: [PATCH v2] powerpc/mm: export current mmu mode info

2016-09-22 Thread Hari Bathini

Hi Aneesh,


On Thursday 22 September 2016 09:54 PM, Aneesh Kumar K.V wrote:

Hari Bathini  writes:


The kernel now supports both radix and hash MMU modes. Tools like crash
and makedumpfile need to know the current MMU mode the kernel is using,
to debug/analyze it.  The current MMU mode depends on hardware support
and also whether disable_radix cmdline parameter is passed to the kernel.
The mmu_features member of cpu_spec structure holds the current MMU mode
a cpu is using. But the above mentioned tools need to know the MMU mode
early in their init process, when they may not have access to offset info
of structure members. A hard-coded offset may help but it won't be robust.

IIUC, you walk the linux page table and that should be more or less same


Taking the case of crash tool, vmemmap start value is currently
hard-coded to 0xf000UL but it changed to
0xc00aUL in case of radix.


between radix/hash right except few bits. Now what crash will be
interested in will be the RPN part of the table which should be same
between hash/radix.


Though the walk is pretty much the same, the tool still needs to know
the right index values and vmemmap start to use, as they are different
for radix and hash..


This patch introduces a new global variable, which holds the current MMU
mode the kernel is running in and can be accessed by tools early in thier
init process,

Init process of what ? kernel or crash tool ?


tool initialization - crash or makedumpfile..


helping tools to initialize accurately for each MMU mode.
This patch also optimizes the radix_enabled() function call.


how do you differentiate between the hold linux page table format and
the new ? Can you also summarize what crash tool look for in the page
table ?


It needs the index sizes, masked bit values and page flag info to
do the page table walk. Since they can be different for hash and
radix..


Signed-off-by: Hari Bathini 
---

Changes from v1:
* Patch name changed from "ppc64/book3s: export mmu type info"
* Optimized radix_enabled() function


  arch/powerpc/include/asm/mmu.h  |   22 +-
  arch/powerpc/kernel/machine_kexec.c |3 +++
  arch/powerpc/mm/hash_utils_64.c |2 ++
  arch/powerpc/mm/pgtable-radix.c |2 ++
  arch/powerpc/mm/pgtable.c   |6 ++
  arch/powerpc/mm/tlb_hash32.c|1 +
  arch/powerpc/mm/tlb_nohash.c|2 ++
  7 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index e2fb408..558987c 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -199,6 +199,21 @@ static inline void mmu_clear_feature(unsigned long feature)

  extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;

+/*
+ * Possible MMU modes
+ */
+#define MMU_MODE_NONE   0
+#define MMU_MODE_RADIX  1
+#define MMU_MODE_HASH   2
+#define MMU_MODE_HASH32 3
+#define MMU_MODE_NOHASH 4
+#define MMU_MODE_NOHASH32   5
+
+/*
+ * current MMU mode
+ */
+extern unsigned int current_mmu_mode __read_mostly;
+
  #ifdef CONFIG_PPC64
  /* This is our real memory area size on ppc64 server, on embedded, we
   * make it match the size our of bolted TLB area
@@ -218,7 +233,12 @@ static inline void assert_pte_locked(struct mm_struct *mm, 
unsigned long addr)
  #ifdef CONFIG_PPC_RADIX_MMU
  static inline bool radix_enabled(void)
  {
-   return mmu_has_feature(MMU_FTR_TYPE_RADIX);
+   if (current_mmu_mode == MMU_MODE_RADIX)
+   return true;
+   else if (current_mmu_mode != MMU_MODE_NONE)
+   return false;
+   else
+   return mmu_has_feature(MMU_FTR_TYPE_RADIX);
  }


That is not optimization, that makes it slow. We hotpatch mmu_has_feature().


Ugh! I didn't consider that..

Thanks
Hari


  static inline bool early_radix_enabled(void)
diff --git a/arch/powerpc/kernel/machine_kexec.c 
b/arch/powerpc/kernel/machine_kexec.c
index 2694d07..4ecc184 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -77,6 +77,9 @@ void arch_crash_save_vmcoreinfo(void)
VMCOREINFO_SYMBOL(contig_page_data);
  #endif
  #if defined(CONFIG_PPC64) && defined(CONFIG_SPARSEMEM_VMEMMAP)
+#ifdef CONFIG_PPC_BOOK3S
+   VMCOREINFO_SYMBOL(current_mmu_mode);
+#endif
VMCOREINFO_SYMBOL(vmemmap_list);
VMCOREINFO_SYMBOL(mmu_vmemmap_psize);
VMCOREINFO_SYMBOL(mmu_psize_defs);
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 0821556..a566a95 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -886,6 +886,8 @@ void __init hash__early_init_devtree(void)

  void __init hash__early_init_mmu(void)
  {
+   current_mmu_mode = MMU_MODE_HASH;
+
htab_init_page_sizes();

/*
diff --git a/arch/powerpc/mm/pgtable-radix.c 

Re: [PATCH v21 00/20] perf, tools: Add support for PMU events in JSON format

2016-09-22 Thread Jiri Olsa
On Thu, Sep 22, 2016 at 05:00:22PM +0200, Jiri Olsa wrote:
> On Mon, Sep 19, 2016 at 09:28:20PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Sep 19, 2016 at 09:02:58PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Mon, Sep 19, 2016 at 08:37:53PM -0300, Arnaldo Carvalho de Melo 
> > > escreveu:
> > > > yeah, changing that typedef + true def to plain include 
> > > > makes it progress to the next failure, which is in cross compilation
> > > > environments, such as using fedora 24 + the Android NDK to try to build
> > > > a ARM android binary.
> > 
> > > 14 fedora:24-x-ARC-uClibc: FAIL
> > >   GEN  /tmp/build/perf/pmu-events/pmu-events.c
> > > /bin/sh: /tmp/build/perf/pmu-events/jevents: cannot execute binary file: 
> > > Exec format error
> > > pmu-events/Build:11: recipe for target 
> > > '/tmp/build/perf/pmu-events/pmu-events.c' failed
> > > make[2]: *** [/tmp/build/perf/pmu-events/pmu-events.c] Error 126
> > > Makefile.perf:461: recipe for target 
> > > '/tmp/build/perf/pmu-events/pmu-events-in.o' failed
> > > make[1]: *** [/tmp/build/perf/pmu-events/pmu-events-in.o] Error 2
> > > make[1]: *** Waiting for unfinished jobs
> > 
> > Jiri, we need something similar to scripts/Makefile.host :-\
> > 
> > Calling it a day, perhaps, for now, we should just detect that it is a
> > corss compile env (CROSS_COMPILE is set) and exclude all this code from
> > the build, emitting a warning.
> > 
> > I left what I did at the tmp.perf/core branch of my repo at
> > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git.
> 
> as discussed on irc we will disable it for cross builds now,
> because we dont have good solution at the moment.. it's
> similar case as for fixdep tool:
> 
> 3a70fcd3a4db tools build: Fix cross compile build
> ...
> We need to add support for host side tools build, meanwhile
> disabling fixdep usage for cross arch builds.
> 
> I'll make a change to disable this for crossbuild and
> work on common solution later

could you please give it a try with patch below?
I tested but not with properly cross building...

also,  did you want some message during the cross build that pmu-events are not 
included?

thanks,
jirka


---
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 24803c58049a..ec3a59d9a56b 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -755,6 +755,10 @@ ifndef NO_AUXTRACE
   endif
 endif
 
+ifndef CROSS_COMPILE
+  CFLAGS += -DHAVE_PMU_EVENTS_SUPPORT
+endif
+
 # Among the variables below, these:
 #   perfexecdir
 #   template_dir
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 0abebcba849f..85257c49d5ab 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -349,7 +349,14 @@ include $(srctree)/tools/build/Makefile.include
 
 JEVENTS   := $(OUTPUT)pmu-events/jevents
 JEVENTS_IN:= $(OUTPUT)pmu-events/jevents-in.o
+
+#
+# Disabling pmu-events for cross compile, as
+# we dont support host CC tools building yet.
+#
+ifndef CROSS_COMPILE
 PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
+endif
 
 export JEVENTS
 
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index ac097fcaba7b..21a3f21a6f6f 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -482,6 +482,8 @@ static struct cpu_map *pmu_cpumask(const char *name)
return cpus;
 }
 
+#ifdef HAVE_PMU_EVENTS_SUPPORT
+
 /*
  * Return the CPU id as a raw string.
  *
@@ -545,6 +547,13 @@ out:
return 0;
 }
 
+#else
+static int pmu_add_cpu_aliases(struct list_head *head __maybe_unused)
+{
+   return 0;
+}
+#endif /* HAVE_PMU_EVENTS_SUPPORT */
+
 struct perf_event_attr * __weak
 perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
 {


Re: [PATCH v2] powerpc/mm: export current mmu mode info

2016-09-22 Thread Aneesh Kumar K.V
Hari Bathini  writes:

> The kernel now supports both radix and hash MMU modes. Tools like crash
> and makedumpfile need to know the current MMU mode the kernel is using,
> to debug/analyze it.  The current MMU mode depends on hardware support
> and also whether disable_radix cmdline parameter is passed to the kernel.
> The mmu_features member of cpu_spec structure holds the current MMU mode
> a cpu is using. But the above mentioned tools need to know the MMU mode
> early in their init process, when they may not have access to offset info
> of structure members. A hard-coded offset may help but it won't be robust.

IIUC, you walk the linux page table and that should be more or less same
between radix/hash right except few bits. Now what crash will be
interested in will be the RPN part of the table which should be same
between hash/radix.

>
> This patch introduces a new global variable, which holds the current MMU
> mode the kernel is running in and can be accessed by tools early in thier
> init process,

Init process of what ? kernel or crash tool ?

>helping tools to initialize accurately for each MMU mode.
> This patch also optimizes the radix_enabled() function call.
>

how do you differentiate between the hold linux page table format and
the new ? Can you also summarize what crash tool look for in the page
table ?

> Signed-off-by: Hari Bathini 
> ---
>
> Changes from v1:
> * Patch name changed from "ppc64/book3s: export mmu type info"
> * Optimized radix_enabled() function
>
>
>  arch/powerpc/include/asm/mmu.h  |   22 +-
>  arch/powerpc/kernel/machine_kexec.c |3 +++
>  arch/powerpc/mm/hash_utils_64.c |2 ++
>  arch/powerpc/mm/pgtable-radix.c |2 ++
>  arch/powerpc/mm/pgtable.c   |6 ++
>  arch/powerpc/mm/tlb_hash32.c|1 +
>  arch/powerpc/mm/tlb_nohash.c|2 ++
>  7 files changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
> index e2fb408..558987c 100644
> --- a/arch/powerpc/include/asm/mmu.h
> +++ b/arch/powerpc/include/asm/mmu.h
> @@ -199,6 +199,21 @@ static inline void mmu_clear_feature(unsigned long 
> feature)
>
>  extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
>
> +/*
> + * Possible MMU modes
> + */
> +#define MMU_MODE_NONE   0
> +#define MMU_MODE_RADIX  1
> +#define MMU_MODE_HASH   2
> +#define MMU_MODE_HASH32 3
> +#define MMU_MODE_NOHASH 4
> +#define MMU_MODE_NOHASH32   5
> +
> +/*
> + * current MMU mode
> + */
> +extern unsigned int current_mmu_mode __read_mostly;
> +
>  #ifdef CONFIG_PPC64
>  /* This is our real memory area size on ppc64 server, on embedded, we
>   * make it match the size our of bolted TLB area
> @@ -218,7 +233,12 @@ static inline void assert_pte_locked(struct mm_struct 
> *mm, unsigned long addr)
>  #ifdef CONFIG_PPC_RADIX_MMU
>  static inline bool radix_enabled(void)
>  {
> - return mmu_has_feature(MMU_FTR_TYPE_RADIX);
> + if (current_mmu_mode == MMU_MODE_RADIX)
> + return true;
> + else if (current_mmu_mode != MMU_MODE_NONE)
> + return false;
> + else
> + return mmu_has_feature(MMU_FTR_TYPE_RADIX);
>  }
>

That is not optimization, that makes it slow. We hotpatch mmu_has_feature().


>  static inline bool early_radix_enabled(void)
> diff --git a/arch/powerpc/kernel/machine_kexec.c 
> b/arch/powerpc/kernel/machine_kexec.c
> index 2694d07..4ecc184 100644
> --- a/arch/powerpc/kernel/machine_kexec.c
> +++ b/arch/powerpc/kernel/machine_kexec.c
> @@ -77,6 +77,9 @@ void arch_crash_save_vmcoreinfo(void)
>   VMCOREINFO_SYMBOL(contig_page_data);
>  #endif
>  #if defined(CONFIG_PPC64) && defined(CONFIG_SPARSEMEM_VMEMMAP)
> +#ifdef CONFIG_PPC_BOOK3S
> + VMCOREINFO_SYMBOL(current_mmu_mode);
> +#endif
>   VMCOREINFO_SYMBOL(vmemmap_list);
>   VMCOREINFO_SYMBOL(mmu_vmemmap_psize);
>   VMCOREINFO_SYMBOL(mmu_psize_defs);
> diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
> index 0821556..a566a95 100644
> --- a/arch/powerpc/mm/hash_utils_64.c
> +++ b/arch/powerpc/mm/hash_utils_64.c
> @@ -886,6 +886,8 @@ void __init hash__early_init_devtree(void)
>
>  void __init hash__early_init_mmu(void)
>  {
> + current_mmu_mode = MMU_MODE_HASH;
> +
>   htab_init_page_sizes();
>
>   /*
> diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
> index af897d9..4b0ad48 100644
> --- a/arch/powerpc/mm/pgtable-radix.c
> +++ b/arch/powerpc/mm/pgtable-radix.c
> @@ -298,6 +298,8 @@ void __init radix__early_init_mmu(void)
>  {
>   unsigned long lpcr;
>
> + current_mmu_mode = MMU_MODE_RADIX;
> +
>  #ifdef CONFIG_PPC_64K_PAGES
>   /* PAGE_SIZE mappings */
>   mmu_virtual_psize = MMU_PAGE_64K;
> diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
> index 0b6fb24..4638a00 100644
> --- 

[RESEND PATCH v2] powerpc/mm: export current mmu mode info

2016-09-22 Thread Hari Bathini
The kernel now supports both radix and hash MMU modes. Tools like crash
and makedumpfile need to know the current MMU mode the kernel is using,
to debug/analyze it.  The current MMU mode depends on hardware support
and also whether disable_radix cmdline parameter is passed to the kernel.
The mmu_features member of cpu_spec structure holds the current MMU mode
a cpu is using. But the above mentioned tools need to know the MMU mode
early in their init process, when they may not have access to offset info
of structure members. A hard-coded offset may help but it won't be robust.

This patch introduces a new global variable, which holds the current MMU
mode the kernel is running in and can be accessed by tools early in thier
init process, helping tools to initialize accurately for each MMU mode.
This patch also optimizes the radix_enabled() function call.

Signed-off-by: Hari Bathini 
---

Changes from v1:
* Patch name changed from "ppc64/book3s: export mmu type info"
* Optimized radix_enabled() function
* Removed current_mmu_mode vmcoreinfo from under flags

 arch/powerpc/include/asm/mmu.h  |   22 +-
 arch/powerpc/kernel/machine_kexec.c |1 +
 arch/powerpc/mm/hash_utils_64.c |2 ++
 arch/powerpc/mm/pgtable-radix.c |2 ++
 arch/powerpc/mm/pgtable.c   |6 ++
 arch/powerpc/mm/tlb_hash32.c|1 +
 arch/powerpc/mm/tlb_nohash.c|2 ++
 7 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index e2fb408..558987c 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -199,6 +199,21 @@ static inline void mmu_clear_feature(unsigned long feature)
 
 extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
 
+/*
+ * Possible MMU modes
+ */
+#define MMU_MODE_NONE   0
+#define MMU_MODE_RADIX  1
+#define MMU_MODE_HASH   2
+#define MMU_MODE_HASH32 3
+#define MMU_MODE_NOHASH 4
+#define MMU_MODE_NOHASH32   5
+
+/*
+ * current MMU mode
+ */
+extern unsigned int current_mmu_mode __read_mostly;
+
 #ifdef CONFIG_PPC64
 /* This is our real memory area size on ppc64 server, on embedded, we
  * make it match the size our of bolted TLB area
@@ -218,7 +233,12 @@ static inline void assert_pte_locked(struct mm_struct *mm, 
unsigned long addr)
 #ifdef CONFIG_PPC_RADIX_MMU
 static inline bool radix_enabled(void)
 {
-   return mmu_has_feature(MMU_FTR_TYPE_RADIX);
+   if (current_mmu_mode == MMU_MODE_RADIX)
+   return true;
+   else if (current_mmu_mode != MMU_MODE_NONE)
+   return false;
+   else
+   return mmu_has_feature(MMU_FTR_TYPE_RADIX);
 }
 
 static inline bool early_radix_enabled(void)
diff --git a/arch/powerpc/kernel/machine_kexec.c 
b/arch/powerpc/kernel/machine_kexec.c
index 2694d07..2a32694 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -87,6 +87,7 @@ void arch_crash_save_vmcoreinfo(void)
VMCOREINFO_STRUCT_SIZE(mmu_psize_def);
VMCOREINFO_OFFSET(mmu_psize_def, shift);
 #endif
+   VMCOREINFO_SYMBOL(current_mmu_mode);
 }
 
 /*
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 0821556..a566a95 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -886,6 +886,8 @@ void __init hash__early_init_devtree(void)
 
 void __init hash__early_init_mmu(void)
 {
+   current_mmu_mode = MMU_MODE_HASH;
+
htab_init_page_sizes();
 
/*
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index af897d9..4b0ad48 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -298,6 +298,8 @@ void __init radix__early_init_mmu(void)
 {
unsigned long lpcr;
 
+   current_mmu_mode = MMU_MODE_RADIX;
+
 #ifdef CONFIG_PPC_64K_PAGES
/* PAGE_SIZE mappings */
mmu_virtual_psize = MMU_PAGE_64K;
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index 0b6fb24..4638a00 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -31,6 +31,12 @@
 #include 
 #include 
 
+/*
+ * current MMU mode
+ */
+unsigned int current_mmu_mode __read_mostly = MMU_MODE_NONE;
+EXPORT_SYMBOL(current_mmu_mode);
+
 static inline int is_exec_fault(void)
 {
return current->thread.regs && TRAP(current->thread.regs) == 0x400;
diff --git a/arch/powerpc/mm/tlb_hash32.c b/arch/powerpc/mm/tlb_hash32.c
index 702d768..0b55425 100644
--- a/arch/powerpc/mm/tlb_hash32.c
+++ b/arch/powerpc/mm/tlb_hash32.c
@@ -170,4 +170,5 @@ EXPORT_SYMBOL(flush_tlb_range);
 
 void __init early_init_mmu(void)
 {
+   current_mmu_mode = MMU_MODE_HASH32;
 }
diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c
index 050badc..74300a7 100644
--- a/arch/powerpc/mm/tlb_nohash.c
+++ b/arch/powerpc/mm/tlb_nohash.c
@@ -720,6 +720,7 @@ 

Re: [PATCH v2] powerpc/mm: export current mmu mode info

2016-09-22 Thread Hari Bathini



On Thursday 22 September 2016 09:32 PM, Hari Bathini wrote:

The kernel now supports both radix and hash MMU modes. Tools like crash
and makedumpfile need to know the current MMU mode the kernel is using,
to debug/analyze it.  The current MMU mode depends on hardware support
and also whether disable_radix cmdline parameter is passed to the kernel.
The mmu_features member of cpu_spec structure holds the current MMU mode
a cpu is using. But the above mentioned tools need to know the MMU mode
early in their init process, when they may not have access to offset info
of structure members. A hard-coded offset may help but it won't be robust.

This patch introduces a new global variable, which holds the current MMU
mode the kernel is running in and can be accessed by tools early in thier
init process, helping tools to initialize accurately for each MMU mode.
This patch also optimizes the radix_enabled() function call.

Signed-off-by: Hari Bathini 
---

Changes from v1:
* Patch name changed from "ppc64/book3s: export mmu type info"
* Optimized radix_enabled() function


  arch/powerpc/include/asm/mmu.h  |   22 +-
  arch/powerpc/kernel/machine_kexec.c |3 +++
  arch/powerpc/mm/hash_utils_64.c |2 ++
  arch/powerpc/mm/pgtable-radix.c |2 ++
  arch/powerpc/mm/pgtable.c   |6 ++
  arch/powerpc/mm/tlb_hash32.c|1 +
  arch/powerpc/mm/tlb_nohash.c|2 ++
  7 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index e2fb408..558987c 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -199,6 +199,21 @@ static inline void mmu_clear_feature(unsigned long feature)

  extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;

+/*
+ * Possible MMU modes
+ */
+#define MMU_MODE_NONE   0
+#define MMU_MODE_RADIX  1
+#define MMU_MODE_HASH   2
+#define MMU_MODE_HASH32 3
+#define MMU_MODE_NOHASH 4
+#define MMU_MODE_NOHASH32   5
+
+/*
+ * current MMU mode
+ */
+extern unsigned int current_mmu_mode __read_mostly;
+
  #ifdef CONFIG_PPC64
  /* This is our real memory area size on ppc64 server, on embedded, we
   * make it match the size our of bolted TLB area
@@ -218,7 +233,12 @@ static inline void assert_pte_locked(struct mm_struct *mm, 
unsigned long addr)
  #ifdef CONFIG_PPC_RADIX_MMU
  static inline bool radix_enabled(void)
  {
-   return mmu_has_feature(MMU_FTR_TYPE_RADIX);
+   if (current_mmu_mode == MMU_MODE_RADIX)
+   return true;
+   else if (current_mmu_mode != MMU_MODE_NONE)
+   return false;
+   else
+   return mmu_has_feature(MMU_FTR_TYPE_RADIX);
  }

  static inline bool early_radix_enabled(void)
diff --git a/arch/powerpc/kernel/machine_kexec.c 
b/arch/powerpc/kernel/machine_kexec.c
index 2694d07..4ecc184 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -77,6 +77,9 @@ void arch_crash_save_vmcoreinfo(void)
VMCOREINFO_SYMBOL(contig_page_data);
  #endif
  #if defined(CONFIG_PPC64) && defined(CONFIG_SPARSEMEM_VMEMMAP)
+#ifdef CONFIG_PPC_BOOK3S
+   VMCOREINFO_SYMBOL(current_mmu_mode);


Oops! This doesn't have to be under any flag. Let me resend.

Thanks
Hari



Re: [PATCH] percpu: improve generic percpu modify-return implementation

2016-09-22 Thread Tejun Heo
Hello,

On Thu, Sep 22, 2016 at 02:35:00PM +1000, Nicholas Piggin wrote:
> Well thank you, how about you?

Heh, can't complain.  Hope to see you around sometime.  It's been
forever.

> Trying a new mail client, sorry. It *seems* to be working now, how's
> this?

Hmm... Still encoded.

> From d0cb9052d6f4c31d24f999b7b0cecb34681eee9b Mon Sep 17 00:00:00 2001
> From: Nicholas Piggin 
> Date: Wed, 21 Sep 2016 18:23:43 +1000
> Subject: [PATCH] percpu: improve generic percpu modify-return implementations
> 
> Some architectures require an additional load to find the address of
> percpu pointers. In some implemenatations, the C aliasing rules do not
> allow the result of that load to be kept over the store that modifies
> the percpu variable, which causes additional loads.
> 
> Work around this by finding the pointer first, then operating on that.
> 
> It's also possible to mark things as restrict and those kind of games,
> but that can require larger and arch specific changes.

QP-decoded and applied to percpu/for-4.9.

Thanks.

-- 
tejun


[RFC PATCH] powerpc/mm: THP page cache support

2016-09-22 Thread Aneesh Kumar K.V
Update arch hook in the generic THP page cache code, that will
deposit and withdarw preallocated page table. Archs like ppc64 use
this preallocated table to store the hash pte slot information.

This is an RFC patch and I am sharing this early to get feedback on the
approach taken. I have used stress-ng mmap-file operation and that
resulted in some thp_file_mmap as show below.

[/mnt/stress]$ grep thp_file /proc/vmstat
thp_file_alloc 25403
thp_file_mapped 16967
[/mnt/stress]$

I did observe wrong nr_ptes count once. I need to recreate the problem
again.

Signed-off-by: Aneesh Kumar K.V 
---
 arch/powerpc/include/asm/book3s/64/pgtable.h |  3 ++
 include/asm-generic/pgtable.h|  8 +++-
 mm/Kconfig   |  6 +--
 mm/huge_memory.c | 19 +-
 mm/khugepaged.c  | 21 ++-
 mm/memory.c  | 56 +++-
 6 files changed, 93 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 263bf39ced40..1f45b06ce78e 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1017,6 +1017,9 @@ static inline int pmd_move_must_withdraw(struct spinlock 
*new_pmd_ptl,
 */
return true;
 }
+
+#define arch_needs_pgtable_deposit() (true)
+
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index d4458b6dbfb4..0d1e400e82a2 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -660,11 +660,17 @@ static inline int pmd_move_must_withdraw(spinlock_t 
*new_pmd_ptl,
/*
 * With split pmd lock we also need to move preallocated
 * PTE page table if new_pmd is on different PMD page table.
+*
+* We also don't deposit and withdraw tables for file pages.
 */
-   return new_pmd_ptl != old_pmd_ptl;
+   return (new_pmd_ptl != old_pmd_ptl) && vma_is_anonymous(vma);
 }
 #endif
 
+#ifndef arch_needs_pgtable_deposit
+#define arch_needs_pgtable_deposit() (false)
+#endif
+
 /*
  * This function is meant to be used by sites walking pagetables with
  * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
diff --git a/mm/Kconfig b/mm/Kconfig
index be0ee11fa0d9..0a279d399722 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -447,13 +447,9 @@ choice
  benefit.
 endchoice
 
-#
-# We don't deposit page tables on file THP mapping,
-# but Power makes use of them to address MMU quirk.
-#
 config TRANSPARENT_HUGE_PAGECACHE
def_bool y
-   depends on TRANSPARENT_HUGEPAGE && !PPC
+   depends on TRANSPARENT_HUGEPAGE
 
 #
 # UP and nommu archs use km based percpu allocator
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index a6abd76baa72..37176f455d16 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1320,6 +1320,14 @@ out_unlocked:
return ret;
 }
 
+void zap_deposited_table(struct mm_struct *mm, pmd_t *pmd)
+{
+   pgtable_t pgtable;
+   pgtable = pgtable_trans_huge_withdraw(mm, pmd);
+   pte_free(mm, pgtable);
+   atomic_long_dec(>nr_ptes);
+}
+
 int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 pmd_t *pmd, unsigned long addr)
 {
@@ -1359,6 +1367,8 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct 
vm_area_struct *vma,
atomic_long_dec(>mm->nr_ptes);
add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR);
} else {
+   if (arch_needs_pgtable_deposit())
+   zap_deposited_table(tlb->mm, pmd);
add_mm_counter(tlb->mm, MM_FILEPAGES, -HPAGE_PMD_NR);
}
spin_unlock(ptl);
@@ -1401,8 +1411,7 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned 
long old_addr,
pmd = pmdp_huge_get_and_clear(mm, old_addr, old_pmd);
VM_BUG_ON(!pmd_none(*new_pmd));
 
-   if (pmd_move_must_withdraw(new_ptl, old_ptl) &&
-   vma_is_anonymous(vma)) {
+   if (pmd_move_must_withdraw(new_ptl, old_ptl)) {
pgtable_t pgtable;
pgtable = pgtable_trans_huge_withdraw(mm, old_pmd);
pgtable_trans_huge_deposit(mm, new_pmd, pgtable);
@@ -1525,6 +1534,12 @@ static void __split_huge_pmd_locked(struct 
vm_area_struct *vma, pmd_t *pmd,
 
if (!vma_is_anonymous(vma)) {
_pmd = pmdp_huge_clear_flush_notify(vma, haddr, pmd);
+   /*
+* We are going to unmap this huge page. So
+* just go ahead and zap it
+*/
+   if (arch_needs_pgtable_deposit())
+

[PATCH v2] powerpc/mm: export current mmu mode info

2016-09-22 Thread Hari Bathini
The kernel now supports both radix and hash MMU modes. Tools like crash
and makedumpfile need to know the current MMU mode the kernel is using,
to debug/analyze it.  The current MMU mode depends on hardware support
and also whether disable_radix cmdline parameter is passed to the kernel.
The mmu_features member of cpu_spec structure holds the current MMU mode
a cpu is using. But the above mentioned tools need to know the MMU mode
early in their init process, when they may not have access to offset info
of structure members. A hard-coded offset may help but it won't be robust.

This patch introduces a new global variable, which holds the current MMU
mode the kernel is running in and can be accessed by tools early in thier
init process, helping tools to initialize accurately for each MMU mode.
This patch also optimizes the radix_enabled() function call.

Signed-off-by: Hari Bathini 
---

Changes from v1:
* Patch name changed from "ppc64/book3s: export mmu type info"
* Optimized radix_enabled() function


 arch/powerpc/include/asm/mmu.h  |   22 +-
 arch/powerpc/kernel/machine_kexec.c |3 +++
 arch/powerpc/mm/hash_utils_64.c |2 ++
 arch/powerpc/mm/pgtable-radix.c |2 ++
 arch/powerpc/mm/pgtable.c   |6 ++
 arch/powerpc/mm/tlb_hash32.c|1 +
 arch/powerpc/mm/tlb_nohash.c|2 ++
 7 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index e2fb408..558987c 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -199,6 +199,21 @@ static inline void mmu_clear_feature(unsigned long feature)
 
 extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
 
+/*
+ * Possible MMU modes
+ */
+#define MMU_MODE_NONE   0
+#define MMU_MODE_RADIX  1
+#define MMU_MODE_HASH   2
+#define MMU_MODE_HASH32 3
+#define MMU_MODE_NOHASH 4
+#define MMU_MODE_NOHASH32   5
+
+/*
+ * current MMU mode
+ */
+extern unsigned int current_mmu_mode __read_mostly;
+
 #ifdef CONFIG_PPC64
 /* This is our real memory area size on ppc64 server, on embedded, we
  * make it match the size our of bolted TLB area
@@ -218,7 +233,12 @@ static inline void assert_pte_locked(struct mm_struct *mm, 
unsigned long addr)
 #ifdef CONFIG_PPC_RADIX_MMU
 static inline bool radix_enabled(void)
 {
-   return mmu_has_feature(MMU_FTR_TYPE_RADIX);
+   if (current_mmu_mode == MMU_MODE_RADIX)
+   return true;
+   else if (current_mmu_mode != MMU_MODE_NONE)
+   return false;
+   else
+   return mmu_has_feature(MMU_FTR_TYPE_RADIX);
 }
 
 static inline bool early_radix_enabled(void)
diff --git a/arch/powerpc/kernel/machine_kexec.c 
b/arch/powerpc/kernel/machine_kexec.c
index 2694d07..4ecc184 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -77,6 +77,9 @@ void arch_crash_save_vmcoreinfo(void)
VMCOREINFO_SYMBOL(contig_page_data);
 #endif
 #if defined(CONFIG_PPC64) && defined(CONFIG_SPARSEMEM_VMEMMAP)
+#ifdef CONFIG_PPC_BOOK3S
+   VMCOREINFO_SYMBOL(current_mmu_mode);
+#endif
VMCOREINFO_SYMBOL(vmemmap_list);
VMCOREINFO_SYMBOL(mmu_vmemmap_psize);
VMCOREINFO_SYMBOL(mmu_psize_defs);
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 0821556..a566a95 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -886,6 +886,8 @@ void __init hash__early_init_devtree(void)
 
 void __init hash__early_init_mmu(void)
 {
+   current_mmu_mode = MMU_MODE_HASH;
+
htab_init_page_sizes();
 
/*
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index af897d9..4b0ad48 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -298,6 +298,8 @@ void __init radix__early_init_mmu(void)
 {
unsigned long lpcr;
 
+   current_mmu_mode = MMU_MODE_RADIX;
+
 #ifdef CONFIG_PPC_64K_PAGES
/* PAGE_SIZE mappings */
mmu_virtual_psize = MMU_PAGE_64K;
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index 0b6fb24..4638a00 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -31,6 +31,12 @@
 #include 
 #include 
 
+/*
+ * current MMU mode
+ */
+unsigned int current_mmu_mode __read_mostly = MMU_MODE_NONE;
+EXPORT_SYMBOL(current_mmu_mode);
+
 static inline int is_exec_fault(void)
 {
return current->thread.regs && TRAP(current->thread.regs) == 0x400;
diff --git a/arch/powerpc/mm/tlb_hash32.c b/arch/powerpc/mm/tlb_hash32.c
index 702d768..0b55425 100644
--- a/arch/powerpc/mm/tlb_hash32.c
+++ b/arch/powerpc/mm/tlb_hash32.c
@@ -170,4 +170,5 @@ EXPORT_SYMBOL(flush_tlb_range);
 
 void __init early_init_mmu(void)
 {
+   current_mmu_mode = MMU_MODE_HASH32;
 }
diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c
index 

Re: [PATCH v7 4/6] powerpc: lib/locks.c: Add cpu yield/wake helper function

2016-09-22 Thread Boqun Feng
Hi Xinhui,

On Mon, Sep 19, 2016 at 05:23:55AM -0400, Pan Xinhui wrote:
> Add two corresponding helper functions to support pv-qspinlock.
> 
> For normal use, __spin_yield_cpu will confer current vcpu slices to the
> target vcpu(say, a lock holder). If target vcpu is not specified or it
> is in running state, such conferging to lpar happens or not depends.
> 
> Because hcall itself will introduce latency and a little overhead. And
> we do NOT want to suffer any latency on some cases, e.g. in interrupt handler.
> The second parameter *confer* can indicate such case.
> 
> __spin_wake_cpu is simpiler, it will wake up one vcpu regardless of its
> current vcpu state.
> 
> Signed-off-by: Pan Xinhui 
> ---
>  arch/powerpc/include/asm/spinlock.h |  4 +++
>  arch/powerpc/lib/locks.c| 59 
> +
>  2 files changed, 63 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/spinlock.h 
> b/arch/powerpc/include/asm/spinlock.h
> index 6aef8dd..abb6b0f 100644
> --- a/arch/powerpc/include/asm/spinlock.h
> +++ b/arch/powerpc/include/asm/spinlock.h
> @@ -56,9 +56,13 @@
>  /* We only yield to the hypervisor if we are in shared processor mode */
>  #define SHARED_PROCESSOR (lppaca_shared_proc(local_paca->lppaca_ptr))
>  extern void __spin_yield(arch_spinlock_t *lock);
> +extern void __spin_yield_cpu(int cpu, int confer);
> +extern void __spin_wake_cpu(int cpu);
>  extern void __rw_yield(arch_rwlock_t *lock);
>  #else /* SPLPAR */
>  #define __spin_yield(x)  barrier()
> +#define __spin_yield_cpu(x,y) barrier()
> +#define __spin_wake_cpu(x) barrier()
>  #define __rw_yield(x)barrier()
>  #define SHARED_PROCESSOR 0
>  #endif
> diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
> index 6574626..892df7d 100644
> --- a/arch/powerpc/lib/locks.c
> +++ b/arch/powerpc/lib/locks.c
> @@ -23,6 +23,65 @@
>  #include 
>  #include 
>  
> +/*
> + * confer our slices to a specified cpu and return. If it is already running 
> or
> + * cpu is -1, then we will check confer. If confer is NULL, we will return
> + * otherwise we confer our slices to lpar.
> + */
> +void __spin_yield_cpu(int cpu, int confer)
> +{
> + unsigned int holder_cpu = cpu, yield_count;
> +

You don't need @holder_cpu at all, do you?

> + if (cpu == -1)
> + goto yield_to_lpar;
> +
> + BUG_ON(holder_cpu >= nr_cpu_ids);
> + yield_count = be32_to_cpu(lppaca_of(holder_cpu).yield_count);
> +
> + /* if cpu is running, confer slices to lpar conditionally*/
> + if ((yield_count & 1) == 0)
> + goto yield_to_lpar;
> +
> + plpar_hcall_norets(H_CONFER,
> + get_hard_smp_processor_id(holder_cpu), yield_count);
> + return;
> +
> +yield_to_lpar:
> + if (confer)
> + plpar_hcall_norets(H_CONFER, -1, 0);
> +}
> +EXPORT_SYMBOL_GPL(__spin_yield_cpu);
> +
> +void __spin_wake_cpu(int cpu)
> +{
> + unsigned int holder_cpu = cpu;
> +

Ditto.

Regards,
Boqun

> + BUG_ON(holder_cpu >= nr_cpu_ids);
> + /*
> +  * NOTE: we should always do this hcall regardless of
> +  * the yield_count of the holder_cpu.
> +  * as thers might be a case like below;
> +  * CPU  1   2
> +  *  yielded = true
> +  *  if (yielded)
> +  *  __spin_wake_cpu()
> +  *  __spin_yield_cpu()
> +  *
> +  * So we might lose a wake if we check the yield_count and
> +  * return directly if the holder_cpu is running.
> +  * IOW. do NOT code like below.
> +  *  yield_count = be32_to_cpu(lppaca_of(holder_cpu).yield_count);
> +  *  if ((yield_count & 1) == 0)
> +  *  return;
> +  *
> +  * a PROD hcall marks the target_cpu proded, which cause the next cede 
> or confer
> +  * called on the target_cpu invalid.
> +  */
> + plpar_hcall_norets(H_PROD,
> + get_hard_smp_processor_id(holder_cpu));
> +}
> +EXPORT_SYMBOL_GPL(__spin_wake_cpu);
> +
>  #ifndef CONFIG_QUEUED_SPINLOCKS
>  void __spin_yield(arch_spinlock_t *lock)
>  {
> -- 
> 2.4.11
> 


signature.asc
Description: PGP signature


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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

CC: Roy Pledge 

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

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

-- 
1.7.11.7



Re: [PATCH v21 00/20] perf, tools: Add support for PMU events in JSON format

2016-09-22 Thread Jiri Olsa
On Mon, Sep 19, 2016 at 09:28:20PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Sep 19, 2016 at 09:02:58PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Mon, Sep 19, 2016 at 08:37:53PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > yeah, changing that typedef + true def to plain include 
> > > makes it progress to the next failure, which is in cross compilation
> > > environments, such as using fedora 24 + the Android NDK to try to build
> > > a ARM android binary.
> 
> > 14 fedora:24-x-ARC-uClibc: FAIL
> >   GEN  /tmp/build/perf/pmu-events/pmu-events.c
> > /bin/sh: /tmp/build/perf/pmu-events/jevents: cannot execute binary file: 
> > Exec format error
> > pmu-events/Build:11: recipe for target 
> > '/tmp/build/perf/pmu-events/pmu-events.c' failed
> > make[2]: *** [/tmp/build/perf/pmu-events/pmu-events.c] Error 126
> > Makefile.perf:461: recipe for target 
> > '/tmp/build/perf/pmu-events/pmu-events-in.o' failed
> > make[1]: *** [/tmp/build/perf/pmu-events/pmu-events-in.o] Error 2
> > make[1]: *** Waiting for unfinished jobs
> 
> Jiri, we need something similar to scripts/Makefile.host :-\
> 
> Calling it a day, perhaps, for now, we should just detect that it is a
> corss compile env (CROSS_COMPILE is set) and exclude all this code from
> the build, emitting a warning.
> 
> I left what I did at the tmp.perf/core branch of my repo at
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git.

as discussed on irc we will disable it for cross builds now,
because we dont have good solution at the moment.. it's
similar case as for fixdep tool:

3a70fcd3a4db tools build: Fix cross compile build
...
We need to add support for host side tools build, meanwhile
disabling fixdep usage for cross arch builds.

I'll make a change to disable this for crossbuild and
work on common solution later

thanks,
jirka


Re: [PATCH v7 0/6] perf annotate: Cross arch support + few fixes

2016-09-22 Thread Kim Phillips
On Thu, 22 Sep 2016 10:48:13 +0530
Ravi Bangoria  wrote:

> On Thursday 22 September 2016 01:04 AM, Kim Phillips wrote:
> > On Wed, 21 Sep 2016 21:17:50 +0530
> > Ravi Bangoria  wrote:
> >
> >> Kim, I don't have arm test machine. Can you please help me to test
> >> this on arm.
> > This works for me:  hitting return on return instructions yields
> > "Invalid jump offset", but I'll get that later.
> 
> Thanks Kim.
> 
> Hmm.. so, ins__find_arm does not contain logic for return instructions. 
> Navigation
> with return instruction is working fine for x86 and powerpc.

Right, for ARM, in order to match return instructions, 'lr' must be
found to be the operand of the branch instruction, which is not
contained in the 'name' variable passed to ins__find().

I don't want this to inhibit acceptance of this series, however: I plan
on addressing it afterwards, unless, of course, it is perceived as a
problem somehow (compatibility-wise, it is not because it is an error
at the moment).

Thanks,

Kim


Re: [PATCH v21 00/20] perf, tools: Add support for PMU events in JSON format

2016-09-22 Thread Arnaldo Carvalho de Melo
oops, Jiri wasn't CCed, fixing it...

Em Mon, Sep 19, 2016 at 09:28:20PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Sep 19, 2016 at 09:02:58PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Mon, Sep 19, 2016 at 08:37:53PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > yeah, changing that typedef + true def to plain include 
> > > makes it progress to the next failure, which is in cross compilation
> > > environments, such as using fedora 24 + the Android NDK to try to build
> > > a ARM android binary.
> 
> > 14 fedora:24-x-ARC-uClibc: FAIL
> >   GEN  /tmp/build/perf/pmu-events/pmu-events.c
> > /bin/sh: /tmp/build/perf/pmu-events/jevents: cannot execute binary file: 
> > Exec format error
> > pmu-events/Build:11: recipe for target 
> > '/tmp/build/perf/pmu-events/pmu-events.c' failed
> > make[2]: *** [/tmp/build/perf/pmu-events/pmu-events.c] Error 126
> > Makefile.perf:461: recipe for target 
> > '/tmp/build/perf/pmu-events/pmu-events-in.o' failed
> > make[1]: *** [/tmp/build/perf/pmu-events/pmu-events-in.o] Error 2
> > make[1]: *** Waiting for unfinished jobs
> 
> Jiri, we need something similar to scripts/Makefile.host :-\
> 
> Calling it a day, perhaps, for now, we should just detect that it is a
> corss compile env (CROSS_COMPILE is set) and exclude all this code from
> the build, emitting a warning.
> 
> I left what I did at the tmp.perf/core branch of my repo at
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git.
> 
> - Arnaldo


Re: [PATCH] powerpc/64: whitelist unresolved modversions CRCs

2016-09-22 Thread Michal Marek
On 2016-09-14 04:45, Nicholas Piggin wrote:
> These are a symptom of CRC generation failure in generic
> build code, and not powerpc specific.
> 
> Signed-off-by: Nicholas Piggin 
> ---
> 
> Hi Michal,
> 
> Please merge this via your trees with Al's patches.

Done, thanks for the patch.

Michal



[PATCH] ppc64/book3s: export mmu type info

2016-09-22 Thread Hari Bathini
The kernel now supports both radix and hash MMU modes. Tools like crash
and makedumpfile need to know, the current MMU mode the kernel is using
to debug/analyze the kernel. The current MMU mode depends on H/W support
and also whether disable_radix cmdline parameter is passed to the kernel.
The mmu_features member of cpu_spec structure holds the current MMU mode
a cpu is using. But the above mentioned tools need to know, the MMU mode
early in their init process when they have no access to offset info of
structure members. A hard-coded offset may help but it won't be robust.

This patch introduces a new global variable, which holds the current MMU
mode the kernel is running in and can be accessed by tools early in thier
init process, helping tools to initialize accurately for each MMU mode.

Signed-off-by: Hari Bathini 
---
 arch/powerpc/include/asm/book3s/64/mmu.h |5 +
 arch/powerpc/include/asm/book3s/64/pgtable.h |6 ++
 arch/powerpc/kernel/machine_kexec.c  |3 +++
 arch/powerpc/mm/hash_utils_64.c  |2 ++
 arch/powerpc/mm/pgtable-radix.c  |2 ++
 arch/powerpc/mm/pgtable_64.c |6 ++
 6 files changed, 24 insertions(+)

diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h 
b/arch/powerpc/include/asm/book3s/64/mmu.h
index 8afb0e0..af68df3 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu.h
@@ -30,6 +30,11 @@ extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
 
 #ifndef __ASSEMBLY__
 /*
+ * current MMU mode
+ */
+extern unsigned int current_mmu_mode;
+
+/*
  * ISA 3.0 partiton and process table entry format
  */
 struct prtb_entry {
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 263bf39..f7faebd 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -2,6 +2,12 @@
 #define _ASM_POWERPC_BOOK3S_64_PGTABLE_H_
 
 /*
+ * Possible MMU modes
+ */
+#define HASH_MMU_MODE  0
+#define RADIX_MMU_MODE 1
+
+/*
  * Common bits between hash and Radix page table
  */
 #define _PAGE_BIT_SWAP_TYPE0
diff --git a/arch/powerpc/kernel/machine_kexec.c 
b/arch/powerpc/kernel/machine_kexec.c
index 2694d07..4ecc184 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -77,6 +77,9 @@ void arch_crash_save_vmcoreinfo(void)
VMCOREINFO_SYMBOL(contig_page_data);
 #endif
 #if defined(CONFIG_PPC64) && defined(CONFIG_SPARSEMEM_VMEMMAP)
+#ifdef CONFIG_PPC_BOOK3S
+   VMCOREINFO_SYMBOL(current_mmu_mode);
+#endif
VMCOREINFO_SYMBOL(vmemmap_list);
VMCOREINFO_SYMBOL(mmu_vmemmap_psize);
VMCOREINFO_SYMBOL(mmu_psize_defs);
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 0821556..3c7855a 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -886,6 +886,8 @@ void __init hash__early_init_devtree(void)
 
 void __init hash__early_init_mmu(void)
 {
+   current_mmu_mode = HASH_MMU_MODE;
+
htab_init_page_sizes();
 
/*
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index af897d9..98fbc97 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -298,6 +298,8 @@ void __init radix__early_init_mmu(void)
 {
unsigned long lpcr;
 
+   current_mmu_mode = RADIX_MMU_MODE;
+
 #ifdef CONFIG_PPC_64K_PAGES
/* PAGE_SIZE mappings */
mmu_virtual_psize = MMU_PAGE_64K;
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index f5e8d4e..04319ac 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -63,6 +63,12 @@
 
 #ifdef CONFIG_PPC_BOOK3S_64
 /*
+ * current MMU mode
+ */
+unsigned int current_mmu_mode;
+EXPORT_SYMBOL(current_mmu_mode);
+
+/*
  * partition table and process table for ISA 3.0
  */
 struct prtb_entry *process_tb;



Re: [PATCH 4/4] drivers/pci/hotplug: Support surprise hotplug

2016-09-22 Thread Michael Ellerman
Bjorn Helgaas  writes:

> Hi Gavin,
>
> You don't need my ack for any of these, and I assume you'll merge them
> through the powerpc tree.

Thanks Bjorn, I wasn't sure if you wanted to ack it or not. I'll take
the whole series via the powerpc tree.

> Minor comments below, feel free to ignore them.
>
> On Wed, Sep 21, 2016 at 10:15:30PM +1000, Gavin Shan wrote:
>> ...
>> @@ -536,9 +565,16 @@ static struct pnv_php_slot *pnv_php_alloc_slot(struct 
>> device_node *dn)
>>  if (unlikely(!php_slot))
>>  return NULL;
>>  
>> +php_slot->event = kzalloc(sizeof(struct pnv_php_event), GFP_KERNEL);
>> +if (unlikely(!php_slot->event)) {
>> +kfree(php_slot);
>> +return NULL;
>> +}
>
> Since you *always* allocate the event when allocating the php_slot,
> making the event a member of php_slot (instead of keeping a pointer to
> it) would simplify your memory management a bit.

> It seems to be the style in this file to use "unlikely" liberally, but
> I really doubt there's any performance consideration in this code.  To
> me it adds more clutter than usefulness.

Agreed on both counts. Gavin can you do another spin with those changes,
thanks.

cheers


Re: [PATCH] Work around for enabling CONFIG_CMDLINE on ppc64le

2016-09-22 Thread Anton Blanchard
Hi,

> But I can't merge that patch.
> 
> Our options are one or both of:
>  - get GCC fixed and backport the fix to the compilers we care about.
>  - blacklist the broken compiler versions.
> 
> Is there a GCC bug filed for this?

Likely: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71709

We need confirmation this patch fixes the 6.x issue too and that we need
a backport.

Anton


Re: [PATCH v7 6/6] powerpc: pSeries: Add pv-qspinlock build config/make

2016-09-22 Thread Michael Ellerman
xinhui  writes:

> hi, all
>   ok, this patch set depends on
> https://patchwork.kernel.org/patch/8953981/ [V4] powerpc: Implement {cmp}xchg 
> for u8 and u16

AKA: https://patchwork.ozlabs.org/patch/615480/

Sorry I saw the discussion on that and thought there'd be a new version.
But now I read the whole thread it looks like it was OK in the end.

I'll try and get it merged.

cheers


Re: [PATCH] Work around for enabling CONFIG_CMDLINE on ppc64le

2016-09-22 Thread Michael Ellerman
Akshay Adiga  writes:

> Observed that boot arguments (passed as CONFIG_CMDLINE)  are not being
> picked up by kernel while using gcc-ppc64-linux-gnu v5.4.0 and v6.1.1.
> While it works as expected with v5.3.1 .
>
> Found that in init/main.c in  setup_command_line() the pointers passed to
> strcpy() is messed up.

Hi Akshay,

Thanks for debugging this.

> The problem goes away when compiler optimization is restricted to -O1.

> diff --git a/init/main.c b/init/main.c
> index a8a58e2..4259c42 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -358,7 +358,13 @@ static inline void smp_prepare_cpus(unsigned int 
> maxcpus) { }
>   * parsing is performed in place, and we should allow a component to
>   * store reference of name/value for future reference.
>   */
> -static void __init setup_command_line(char *command_line)
> +static void __init
> +#ifdef CONFIG_PPC64
> + #if  GCC_VERSION > 50301
> + __attribute__((optimize("-O1")))
> + #endif
> +#endif
> + setup_command_line(char *command_line)
>  {
>   saved_command_line =
>   memblock_virt_alloc(strlen(boot_command_line) + 1, 0);

But I can't merge that patch.

Our options are one or both of:
 - get GCC fixed and backport the fix to the compilers we care about.
 - blacklist the broken compiler versions.

Is there a GCC bug filed for this?

cheers


Re: [PATCH v3 1/3] powerpc: port 64 bits pgtable_cache to 32 bits

2016-09-22 Thread Aneesh Kumar K.V

Christophe Leroy  writes:


Today powerpc64 uses a set of pgtable_caches while powerpc32 uses
standard pages when using 4k pages and a single pgtable_cache
if using other size pages.

In preparation of implementing huge pages on the 8xx, this patch
replaces the specific powerpc32 handling by the 64 bits approach.

This is done by:
* moving 64 bits pgtable_cache_add() and pgtable_cache_init()
in a new file called init-common.c
* modifying pgtable_cache_init() to also handle the case
without PMD
* removing the 32 bits version of pgtable_cache_add() and
pgtable_cache_init()
* copying related header contents from 64 bits into both the
book3s/32 and nohash/32 header files

On the 8xx, the following cache sizes will be used:
* 4k pages mode:
- PGT_CACHE(10) for PGD
- PGT_CACHE(3) for 512k hugepage tables
* 16k pages mode:
- PGT_CACHE(6) for PGD
- PGT_CACHE(7) for 512k hugepage tables
- PGT_CACHE(3) for 8M hugepage tables



Reviewed-by: Aneesh Kumar K.V 


Signed-off-by: Christophe Leroy 
---


-aneesh


[PATCH 6/6] powerpc/boot: Add support for XZ compression

2016-09-22 Thread Oliver O'Halloran
This patch adds an option to use XZ compression for the kernel image.
Currently this is only enabled for PPC64 targets since the bulk of the
32bit platforms produce uboot images which do not use the wrapper.

Signed-off-by: Oliver O'Halloran 
---
 arch/powerpc/boot/Makefile |  3 +++
 arch/powerpc/boot/decompress.c |  5 +
 arch/powerpc/boot/stdbool.h| 15 +
 arch/powerpc/boot/stdint.h | 13 
 arch/powerpc/boot/types.h  | 14 
 arch/powerpc/boot/xz_config.h  | 39 ++
 arch/powerpc/platforms/Kconfig.cputype |  1 +
 7 files changed, 90 insertions(+)
 create mode 100644 arch/powerpc/boot/stdbool.h
 create mode 100644 arch/powerpc/boot/stdint.h
 create mode 100644 arch/powerpc/boot/xz_config.h

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 9fb451d0586e..eae2dc8bc218 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -20,6 +20,7 @@
 all: $(obj)/zImage
 
 compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP
+compress-$(CONFIG_KERNEL_XZ)   := CONFIG_KERNEL_XZ
 
 BOOTCFLAGS:= -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 -fno-strict-aliasing -Os -msoft-float -pipe \
@@ -226,6 +227,7 @@ endif
 endif
 
 compressor-$(CONFIG_KERNEL_GZIP) := gz
+compressor-$(CONFIG_KERNEL_XZ)   := xz
 
 # args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
 quiet_cmd_wrap = WRAP$@
@@ -433,6 +435,7 @@ clean-files += $(image-) $(initrd-) cuImage.* dtbImage.* 
treeImage.* \
 # clean up files cached by wrapper
 clean-kernel-base := vmlinux.strip vmlinux.bin
 clean-kernel := $(addsuffix .gz,$(clean-kernel-base))
+clean-kernel += $(addsuffix .xz,$(clean-kernel-base))
 # If not absolute clean-files are relative to $(obj).
 clean-files += $(addprefix $(objtree)/, $(clean-kernel))
 
diff --git a/arch/powerpc/boot/decompress.c b/arch/powerpc/boot/decompress.c
index 60fc6fb26867..8f32ea4289af 100644
--- a/arch/powerpc/boot/decompress.c
+++ b/arch/powerpc/boot/decompress.c
@@ -37,6 +37,11 @@
 #  include "decompress_inflate.c"
 #endif
 
+#ifdef CONFIG_KERNEL_XZ
+#  include "xz_config.h"
+#  include "../../../lib/decompress_unxz.c"
+#endif
+
 /* globals for tracking the state of the decompression */
 static unsigned long decompressed_bytes;
 static unsigned long limit;
diff --git a/arch/powerpc/boot/stdbool.h b/arch/powerpc/boot/stdbool.h
new file mode 100644
index ..2ebcfa53b4c7
--- /dev/null
+++ b/arch/powerpc/boot/stdbool.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) IBM Corporation 2016.
+ *
+ * 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.
+ *
+ * This file is only necessary because some of the pre-boot decompressors
+ * expect stdbool.h to be available.
+ *
+ */
+
+#include "types.h"
+
diff --git a/arch/powerpc/boot/stdint.h b/arch/powerpc/boot/stdint.h
new file mode 100644
index ..c1c853be7490
--- /dev/null
+++ b/arch/powerpc/boot/stdint.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) IBM Corporation 2016.
+ *
+ * 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.
+ *
+ * This file is only necessary because some of the pre-boot decompressors
+ * expect stdint.h to be available.
+ */
+
+#include "types.h"
diff --git a/arch/powerpc/boot/types.h b/arch/powerpc/boot/types.h
index 85565a89bcc2..af6b66b842c4 100644
--- a/arch/powerpc/boot/types.h
+++ b/arch/powerpc/boot/types.h
@@ -1,6 +1,8 @@
 #ifndef _TYPES_H_
 #define _TYPES_H_
 
+#include 
+
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
 typedef unsigned char  u8;
@@ -34,4 +36,16 @@ typedef s64 int64_t;
(void) (&_x == &_y);\
_x > _y ? _x : _y; })
 
+#define min_t(type, a, b) min(((type) a), ((type) b))
+#define max_t(type, a, b) max(((type) a), ((type) b))
+
+typedef int bool;
+
+#ifndef true
+#define true 1
+#endif
+
+#ifndef false
+#define false 0
+#endif
 #endif /* _TYPES_H_ */
diff --git a/arch/powerpc/boot/xz_config.h b/arch/powerpc/boot/xz_config.h
new file mode 100644
index ..5c6afdbca642
--- /dev/null
+++ b/arch/powerpc/boot/xz_config.h
@@ -0,0 +1,39 @@
+#ifndef __XZ_CONFIG_H__
+#define __XZ_CONFIG_H__
+
+/*
+ * most of this is copied from lib/xz/xz_private.h, we can't use their defines
+ * since the boot wrapper is not built in the same environment as the rest of
+ * the kernel.
+ */
+
+#include "types.h"
+#include "swab.h"
+
+static inline uint32_t swab32p(void *p)
+{
+   uint32_t *q = p;
+
+   return swab32(*q);
+}
+
+#ifdef __LITTLE_ENDIAN__
+#define 

[PATCH 4/6] powerpc/boot: remove legacy gzip wrapper

2016-09-22 Thread Oliver O'Halloran
This code is no longer used and can be removed.

Signed-off-by: Oliver O'Halloran 
---
 arch/powerpc/boot/cuboot-c2k.c  |   1 -
 arch/powerpc/boot/gunzip_util.c | 204 
 arch/powerpc/boot/gunzip_util.h |  45 -
 3 files changed, 250 deletions(-)
 delete mode 100644 arch/powerpc/boot/gunzip_util.c
 delete mode 100644 arch/powerpc/boot/gunzip_util.h

diff --git a/arch/powerpc/boot/cuboot-c2k.c b/arch/powerpc/boot/cuboot-c2k.c
index e43594950ba3..9309c51f1d65 100644
--- a/arch/powerpc/boot/cuboot-c2k.c
+++ b/arch/powerpc/boot/cuboot-c2k.c
@@ -18,7 +18,6 @@
 #include "io.h"
 #include "ops.h"
 #include "elf.h"
-#include "gunzip_util.h"
 #include "mv64x60.h"
 #include "cuboot.h"
 #include "ppcboot.h"
diff --git a/arch/powerpc/boot/gunzip_util.c b/arch/powerpc/boot/gunzip_util.c
deleted file mode 100644
index 9dc52501de83..
--- a/arch/powerpc/boot/gunzip_util.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright 2007 David Gibson, IBM Corporation.
- * Based on earlier work, Copyright (C) Paul Mackerras 1997.
- *
- * 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.
- */
-
-#include 
-#include "string.h"
-#include "stdio.h"
-#include "ops.h"
-#include "gunzip_util.h"
-
-#define HEAD_CRC   2
-#define EXTRA_FIELD4
-#define ORIG_NAME  8
-#define COMMENT0x10
-#define RESERVED   0xe0
-
-/**
- * gunzip_start - prepare to decompress gzip data
- * @state: decompressor state structure to be initialized
- * @src:   buffer containing gzip compressed or uncompressed data
- * @srclen:size in bytes of the buffer at src
- *
- * If the buffer at @src contains a gzip header, this function
- * initializes zlib to decompress the data, storing the decompression
- * state in @state.  The other functions in this file can then be used
- * to decompress data from the gzipped stream.
- *
- * If the buffer at @src does not contain a gzip header, it is assumed
- * to contain uncompressed data.  The buffer information is recorded
- * in @state and the other functions in this file will simply copy
- * data from the uncompressed data stream at @src.
- *
- * Any errors, such as bad compressed data, cause an error to be
- * printed an the platform's exit() function to be called.
- */
-void gunzip_start(struct gunzip_state *state, void *src, int srclen)
-{
-   char *hdr = src;
-   int hdrlen = 0;
-
-   memset(state, 0, sizeof(*state));
-
-   /* Check for gzip magic number */
-   if ((hdr[0] == 0x1f) && (hdr[1] == 0x8b)) {
-   /* gzip data, initialize zlib parameters */
-   int r, flags;
-
-   state->s.workspace = state->scratch;
-   if (zlib_inflate_workspacesize() > sizeof(state->scratch))
-   fatal("insufficient scratch space for gunzip\n\r");
-
-   /* skip header */
-   hdrlen = 10;
-   flags = hdr[3];
-   if (hdr[2] != Z_DEFLATED || (flags & RESERVED) != 0)
-   fatal("bad gzipped data\n\r");
-   if ((flags & EXTRA_FIELD) != 0)
-   hdrlen = 12 + hdr[10] + (hdr[11] << 8);
-   if ((flags & ORIG_NAME) != 0)
-   while (hdr[hdrlen++] != 0)
-   ;
-   if ((flags & COMMENT) != 0)
-   while (hdr[hdrlen++] != 0)
-   ;
-   if ((flags & HEAD_CRC) != 0)
-   hdrlen += 2;
-   if (hdrlen >= srclen)
-   fatal("gunzip_start: ran out of data in header\n\r");
-
-   r = zlib_inflateInit2(>s, -MAX_WBITS);
-   if (r != Z_OK)
-   fatal("inflateInit2 returned %d\n\r", r);
-   }
-
-   state->s.total_in = hdrlen;
-   state->s.next_in = src + hdrlen;
-   state->s.avail_in = srclen - hdrlen;
-}
-
-/**
- * gunzip_partial - extract bytes from a gzip data stream
- * @state: gzip state structure previously initialized by gunzip_start()
- * @dst:   buffer to store extracted data
- * @dstlen:maximum number of bytes to extract
- *
- * This function extracts at most @dstlen bytes from the data stream
- * previously associated with @state by gunzip_start(), decompressing
- * if necessary.  Exactly @dstlen bytes are extracted unless the data
- * stream doesn't contain enough bytes, in which case the entire
- * remainder of the stream is decompressed.
- *
- * Returns the actual number of bytes extracted.  If any errors occur,
- * such as a corrupted compressed stream, an error is printed an the
- * platform's exit() function is called.
- */
-int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen)
-{
-   int len;
-

[PATCH 5/6] powerpc/boot: add xz support to the wrapper script

2016-09-22 Thread Oliver O'Halloran
This modifies the script so that the -Z option takes an argument to
specify the compression type. It can either be 'gz', 'xz' or 'none'.
The legazy --no-gzip and -z options are still supported and will set
the compression to none and gzip respectively, but they are not
documented.

Only xz -6 is used for compression rather than xz -9. Using compression
levels higher than 6 requires the decompressor to build a large (64MB)
dictionary when decompressing and some environments cannot satisfy large
allocations (e.g. POWER 6 LPAR partition firmware).

Signed-off-by: Oliver O'Halloran 
---
 arch/powerpc/boot/Makefile |  7 --
 arch/powerpc/boot/wrapper  | 61 ++
 2 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 861348c72519..9fb451d0586e 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -225,10 +225,13 @@ CROSSWRAP := -C "$(CROSS_COMPILE)"
 endif
 endif
 
+compressor-$(CONFIG_KERNEL_GZIP) := gz
+
 # args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
 quiet_cmd_wrap = WRAP$@
-  cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
-   $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux
+  cmd_wrap =$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \
+   $(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \
+   vmlinux
 
 image-$(CONFIG_PPC_PSERIES)+= zImage.pseries
 image-$(CONFIG_PPC_POWERNV)+= zImage.pseries
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 6681ec3625c9..6feacfd87588 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -20,6 +20,8 @@
 # -D dir   specify directory containing data files used by script
 #  (default ./arch/powerpc/boot)
 # -W dir   specify working directory for temporary files (default .)
+# -z   use gzip (legacy)
+# -Z zsuffixcompression to use (gz, xz or none)
 
 # Stop execution if any command fails
 set -e
@@ -38,7 +40,7 @@ dtb=
 dts=
 cacheit=
 binary=
-gzip=.gz
+compression=.gz
 pie=
 format=
 
@@ -59,7 +61,8 @@ tmpdir=.
 usage() {
 echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2
 echo '   [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2
-echo '   [-D datadir] [-W workingdir] [--no-gzip] [vmlinux]' >&2
+echo '   [-D datadir] [-W workingdir] [-Z (gz|xz|none)]' >&2
+echo '   [--no-compression] [vmlinux]' >&2
 exit 1
 }
 
@@ -126,8 +129,24 @@ while [ "$#" -gt 0 ]; do
[ "$#" -gt 0 ] || usage
tmpdir="$1"
;;
+-z)
+   compression=.gz
+   ;;
+-Z)
+   shift
+   [ "$#" -gt 0 ] || usage
+[ "$1" != "gz" -o "$1" != "xz" -o "$1" != "none" ] || usage
+
+   compression=".$1"
+
+if [ $compression = ".none" ]; then
+compression=
+fi
+   ;;
 --no-gzip)
-gzip=
+# a "feature" of the the wrapper script is that it can be used outside
+# the kernel tree. So keeping this around for backwards compatibility.
+compression=
 ;;
 -?)
usage
@@ -140,6 +159,7 @@ while [ "$#" -gt 0 ]; do
 shift
 done
 
+
 if [ -n "$dts" ]; then
 if [ ! -r "$dts" -a -r "$object/dts/$dts" ]; then
dts="$object/dts/$dts"
@@ -212,7 +232,7 @@ miboot|uboot*)
 ;;
 cuboot*)
 binary=y
-gzip=
+compression=
 case "$platform" in
 *-mpc866ads|*-mpc885ads|*-adder875*|*-ep88xc)
 platformo=$object/cuboot-8xx.o
@@ -243,7 +263,7 @@ cuboot*)
 ps3)
 platformo="$object/ps3-head.o $object/ps3-hvcall.o $object/ps3.o"
 lds=$object/zImage.ps3.lds
-gzip=
+compression=
 ext=bin
 objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data"
 ksection=.kernel:vmlinux.bin
@@ -310,27 +330,37 @@ mvme7100)
 esac
 
 vmz="$tmpdir/`basename \"$kernel\"`.$ext"
-if [ -z "$cacheit" -o ! -f "$vmz$gzip" -o "$vmz$gzip" -ot "$kernel" ]; then
-${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
 
-strip_size=$(stat -c %s $vmz.$$)
+# Calculate the vmlinux.strip size
+${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
+strip_size=$(stat -c %s $vmz.$$)
 
-if [ -n "$gzip" ]; then
+if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot 
"$kernel" ]; then
+# recompress the image if we need to
+case $compression in
+.xz)
+xz --check=crc32 -f -6 "$vmz.$$"
+;;
+.gz)
 gzip -n -f -9 "$vmz.$$"
-fi
+;;
+*)
+# drop the compression suffix so the stripped vmlinux is used
+compression=
+   ;;
+esac
 
 if [ -n "$cacheit" ]; then
-   mv -f "$vmz.$$$gzip" "$vmz$gzip"
+   mv -f "$vmz.$$$compression" "$vmz$compression"
 else
vmz="$vmz.$$"
 fi
 else
-# Calculate the vmlinux.strip size
-${CROSS}objcopy 

[PATCH 3/6] powerpc/boot: use the preboot decompression API

2016-09-22 Thread Oliver O'Halloran
Currently the powerpc boot wrapper has its own wrapper around zlib to
handle decompressing gzipped kernels. The kernel decompressor library
functions now provide a generic interface that can be used in the pre-boot
environment. This allows boot wrappers to easily support different
compression algorithms. This patch converts the wrapper to use this new
API, but does not add support for using new algorithms.

Signed-off-by: Oliver O'Halloran 
---
 arch/powerpc/boot/Makefile |  34 +++---
 arch/powerpc/boot/decompress.c | 142 +
 arch/powerpc/boot/main.c   |  35 +-
 arch/powerpc/boot/ops.h|   3 +
 4 files changed, 189 insertions(+), 25 deletions(-)
 create mode 100644 arch/powerpc/boot/decompress.c

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index bede555d78cf..861348c72519 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -63,13 +63,28 @@ $(obj)/treeboot-currituck.o: BOOTCFLAGS += -mcpu=405
 $(obj)/treeboot-akebono.o: BOOTCFLAGS += -mcpu=405
 $(obj)/virtex405-head.o: BOOTAFLAGS += -mcpu=405
 
-# the kernel's version of zlib pulls in a lot of other kernel headers
-# which we don't provide inside the wrapper.
+# The pre-boot decompressors pull in a lot of kernel headers and other source
+# files. This creates a bit of a dependency headache since we need to copy
+# these files into the build dir, fix up any includes and ensure that dependent
+# files are copied in the right order.
+
+# these need to be seperate variables because they are copied out of different
+# directories in the kernel tree. Sure you COULd merge them, but it's a
+# cure-is-worse-than-disease situation.
+zlib-decomp-$(CONFIG_KERNEL_GZIP) := decompress_inflate.c
 zlib-$(CONFIG_KERNEL_GZIP) := inffast.c inflate.c inftrees.c
 zlibheader-$(CONFIG_KERNEL_GZIP) := inffast.h inffixed.h inflate.h inftrees.h 
infutil.h
 zliblinuxheader-$(CONFIG_KERNEL_GZIP) := zlib.h zconf.h zutil.h
 
-$(addprefix $(obj)/,$(zlib-y) cuboot-c2k.o gunzip_util.o main.o): \
+$(addprefix $(obj)/, decompress.o): \
+   $(addprefix $(obj)/,$(zlib-decomp-y))
+
+$(addprefix $(obj)/, $(zlib-decomp-y)): \
+   $(addprefix $(obj)/,$(zliblinuxheader-y)) \
+   $(addprefix $(obj)/,$(zlibheader-y)) \
+   $(addprefix $(obj)/,$(zlib-y))
+
+$(addprefix $(obj)/,$(zlib-y)): \
$(addprefix $(obj)/,$(zliblinuxheader-y)) \
$(addprefix $(obj)/,$(zlibheader-y))
 
@@ -79,10 +94,10 @@ libfdtheader := fdt.h libfdt.h libfdt_internal.h
 $(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o): \
$(addprefix $(obj)/,$(libfdtheader))
 
-src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
+src-wlib-y := string.S crt0.S crtsavres.S stdio.c decompress.c main.c \
$(libfdt) libfdt-wrapper.c \
ns16550.c serial.c simple_alloc.c div64.S util.S \
-   gunzip_util.c elf_util.c $(zlib-y) devtree.c stdlib.c \
+   elf_util.c $(zlib-y) devtree.c stdlib.c \
oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \
uartlite.c mpc52xx-psc.c opal.c opal-calls.S
 src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
@@ -143,6 +158,9 @@ $(addprefix $(obj)/,$(zlibheader-y)): $(obj)/%: 
$(srctree)/lib/zlib_inflate/%
 $(addprefix $(obj)/,$(zliblinuxheader-y)): $(obj)/%: $(srctree)/include/linux/%
$(call cmd,copy_kern_src)
 
+$(addprefix $(obj)/,$(zlib-decomp-y)): $(obj)/%: $(srctree)/lib/%
+   $(call cmd,copy_kern_src)
+
 quiet_cmd_copy_libfdt = COPY$@
   cmd_copy_libfdt = cp $< $@
 
@@ -160,7 +178,7 @@ $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: 
$(srctree)/$(src)/%.S
$(Q)cp $< $@
 
 clean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \
-   $(libfdt) $(libfdtheader) \
+   $(zlib-decomp-) $(libfdt) $(libfdtheader) \
empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
 
 quiet_cmd_bootcc = BOOTCC  $@
@@ -410,8 +428,8 @@ clean-files += $(image-) $(initrd-) cuImage.* dtbImage.* 
treeImage.* \
zImage.maple simpleImage.* otheros.bld *.dtb
 
 # clean up files cached by wrapper
-clean-kernel := vmlinux.strip vmlinux.bin
-clean-kernel += $(addsuffix .gz,$(clean-kernel))
+clean-kernel-base := vmlinux.strip vmlinux.bin
+clean-kernel := $(addsuffix .gz,$(clean-kernel-base))
 # If not absolute clean-files are relative to $(obj).
 clean-files += $(addprefix $(objtree)/, $(clean-kernel))
 
diff --git a/arch/powerpc/boot/decompress.c b/arch/powerpc/boot/decompress.c
new file mode 100644
index ..60fc6fb26867
--- /dev/null
+++ b/arch/powerpc/boot/decompress.c
@@ -0,0 +1,142 @@
+/*
+ * Wrapper around the kernel's pre-boot decompression library.
+ *
+ * Copyright (C) IBM Corporation 2016.
+ *
+ * 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; 

[PATCH 2/6] powerpc/boot: Use CONFIG_KERNEL_GZIP

2016-09-22 Thread Oliver O'Halloran
Most architectures allow the compression algorithm used to produced the
vmlinuz image to be selected as a kernel config option. In preperation
for supporting algorithms other than gzip in the powerpc boot wrapper
the makefile needs to be modified to use these config options.

Signed-off-by: Oliver O'Halloran 
---
 arch/powerpc/Kconfig   |  1 +
 arch/powerpc/boot/Makefile | 30 ++
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5c295830e8c7..59e53f4552ae 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -161,6 +161,7 @@ config PPC
select GENERIC_CPU_AUTOPROBE
select HAVE_VIRT_CPU_ACCOUNTING
select HAVE_ARCH_HARDENED_USERCOPY
+   select HAVE_KERNEL_GZIP
 
 config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 7d6768253caa..bede555d78cf 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -19,10 +19,14 @@
 
 all: $(obj)/zImage
 
+compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP
+
 BOOTCFLAGS:= -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 -fno-strict-aliasing -Os -msoft-float -pipe \
 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
--isystem $(shell $(CROSS32CC) -print-file-name=include)
+-isystem $(shell $(CROSS32CC) -print-file-name=include) \
+-D$(compress-y)
+
 ifdef CONFIG_PPC64_BOOT_WRAPPER
 BOOTCFLAGS += -m64
 endif
@@ -59,13 +63,15 @@ $(obj)/treeboot-currituck.o: BOOTCFLAGS += -mcpu=405
 $(obj)/treeboot-akebono.o: BOOTCFLAGS += -mcpu=405
 $(obj)/virtex405-head.o: BOOTAFLAGS += -mcpu=405
 
+# the kernel's version of zlib pulls in a lot of other kernel headers
+# which we don't provide inside the wrapper.
+zlib-$(CONFIG_KERNEL_GZIP) := inffast.c inflate.c inftrees.c
+zlibheader-$(CONFIG_KERNEL_GZIP) := inffast.h inffixed.h inflate.h inftrees.h 
infutil.h
+zliblinuxheader-$(CONFIG_KERNEL_GZIP) := zlib.h zconf.h zutil.h
 
-zlib   := inffast.c inflate.c inftrees.c
-zlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h
-zliblinuxheader := zlib.h zconf.h zutil.h
-
-$(addprefix $(obj)/,$(zlib) cuboot-c2k.o gunzip_util.o main.o): \
-   $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix 
$(obj)/,$(zlibheader))
+$(addprefix $(obj)/,$(zlib-y) cuboot-c2k.o gunzip_util.o main.o): \
+   $(addprefix $(obj)/,$(zliblinuxheader-y)) \
+   $(addprefix $(obj)/,$(zlibheader-y))
 
 libfdt   := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c
 libfdtheader := fdt.h libfdt.h libfdt_internal.h
@@ -76,7 +82,7 @@ $(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o 
epapr.o opal.o): \
 src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
$(libfdt) libfdt-wrapper.c \
ns16550.c serial.c simple_alloc.c div64.S util.S \
-   gunzip_util.c elf_util.c $(zlib) devtree.c stdlib.c \
+   gunzip_util.c elf_util.c $(zlib-y) devtree.c stdlib.c \
oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \
uartlite.c mpc52xx-psc.c opal.c opal-calls.S
 src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c
@@ -128,13 +134,13 @@ obj-plat: $(libfdt)
 quiet_cmd_copy_kern_src = COPY$@
   cmd_copy_kern_src = sed -f 
$(srctree)/arch/powerpc/boot/fixup-headers.sed $< > $@
 
-$(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
+$(addprefix $(obj)/,$(zlib-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
$(call cmd,copy_kern_src)
 
-$(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
+$(addprefix $(obj)/,$(zlibheader-y)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
$(call cmd,copy_kern_src)
 
-$(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/%
+$(addprefix $(obj)/,$(zliblinuxheader-y)): $(obj)/%: $(srctree)/include/linux/%
$(call cmd,copy_kern_src)
 
 quiet_cmd_copy_libfdt = COPY$@
@@ -153,7 +159,7 @@ $(obj)/zImage.lds: $(obj)/%: $(srctree)/$(src)/%.S
 $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S
$(Q)cp $< $@
 
-clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \
+clean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \
$(libfdt) $(libfdtheader) \
empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
 
-- 
2.5.5



[PATCH 1/6] powerpc/boot: add sed script

2016-09-22 Thread Oliver O'Halloran
The powerpc boot wrapper is compiled with a separate "bootcc" toolchain
rather than the toolchain used for the rest of the kernel. The main
problem with this is that the wrapper does not have access to the kernel
headers (without a lot of gross hacks). To get around this the required
headers are copied into the build directory via several sed scripts
which rewrite problematic includes. This patch moves these fixups out of
the makefile into a separate .sed script file to clean up makefile
slightly.

Signed-off-by: Oliver O'Halloran 
---
 arch/powerpc/boot/Makefile  | 16 +---
 arch/powerpc/boot/fixup-headers.sed | 12 
 2 files changed, 17 insertions(+), 11 deletions(-)
 create mode 100644 arch/powerpc/boot/fixup-headers.sed

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index df0fd406aed1..7d6768253caa 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -125,23 +125,17 @@ obj-wlib := $(addsuffix .o, $(basename $(addprefix 
$(obj)/, $(src-wlib
 obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat
 obj-plat: $(libfdt)
 
-quiet_cmd_copy_zlib = COPY$@
-  cmd_copy_zlib = sed "s@__used@@;s@]*\).*@\"\1\"@" $< > $@
-
-quiet_cmd_copy_zlibheader = COPY$@
-  cmd_copy_zlibheader = sed "s@]*\).*@\"\1\"@" $< > $@
-# stddef.h for NULL
-quiet_cmd_copy_zliblinuxheader = COPY$@
-  cmd_copy_zliblinuxheader = sed 
"s@@\"string.h\"@;s@@@;s@]*\).*@\"\1\"@"
 $< > $@
+quiet_cmd_copy_kern_src = COPY$@
+  cmd_copy_kern_src = sed -f 
$(srctree)/arch/powerpc/boot/fixup-headers.sed $< > $@
 
 $(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
-   $(call cmd,copy_zlib)
+   $(call cmd,copy_kern_src)
 
 $(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
-   $(call cmd,copy_zlibheader)
+   $(call cmd,copy_kern_src)
 
 $(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/%
-   $(call cmd,copy_zliblinuxheader)
+   $(call cmd,copy_kern_src)
 
 quiet_cmd_copy_libfdt = COPY$@
   cmd_copy_libfdt = cp $< $@
diff --git a/arch/powerpc/boot/fixup-headers.sed 
b/arch/powerpc/boot/fixup-headers.sed
new file mode 100644
index ..96362428eb37
--- /dev/null
+++ b/arch/powerpc/boot/fixup-headers.sed
@@ -0,0 +1,12 @@
+# Copyright 2016 IBM Corporation.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+
+s@#include @@;
+s@\"zlib_inflate/\([^\"]*\).*@"\1"@;
+s@@@;
+
+s@__used@@;
+s@]*\).*@"\1"@;
-- 
2.5.5



[v3] XZ compressed zImage support

2016-09-22 Thread Oliver O'Halloran
This series adds support for using XZ compression in addition to gzip in the
kernel boot wrapper. Currently this is only enabled for 64bit Book3S processors
since it seems that some embedded platforms rely on uBoot (or similar) to
decompress the image rather than having the kernel decompress itself. Enabling
it for other platforms should be fairly straight forward though.

Supporting other compression algorithms (like ARM and x86 do) is possible, but
painful. Each algorithm includes some kernel headers even when the #defines
that are supposed to make them usable in a pre-boot environment are set.
Including kernel headers is an issue because on powerpc  the boot wrapper is
compiled with a different toolchain and possibly for a different target for
backwards compatibility reasons*. This makes it difficult to include kernel
headers since the include paths, etc are not setup for BOOTCC.

This can be worked around by rewriting parts of the each decompressor with sed
scripts, but the rewriting requried is specific to each decompressor.

-oliver

*powermacs have 32bit firmware that cannot directly load a 64bit kernel. A 64
bit big endian kernel has a 32bit wrapper to work around this. On 64bit little
endian we don't have this legacy problem so the wrapper is also 64bit little
endian, but the toolchain issues are still there.

---
Changes from v1:
fixed some missing dependecies in the Makefile that were causing random
build breaks.

Fixed "make clean" so that it would remove the files copied into
arch/powerpc/boot/ when the wrapper was built.

previously this series renamed "zlibheader" to "zlibheaders". There were
consequences.

Changes from v2:
Adding missing stdint.h and stdbool.h

Reduced XZ compression level from -9 to -6. Using compression levels
above -6 requires the decompressor to construct a 64MB dictionary. The
firmware on some platforms cannot satisfy large allocations (even when
the memory is physically present) causing decompression failures.
Luckily using the lower compression level doesn't have much of a
penalty.
---


[PATCH] Work around for enabling CONFIG_CMDLINE on ppc64le

2016-09-22 Thread Akshay Adiga
Observed that boot arguments (passed as CONFIG_CMDLINE)  are not being
picked up by kernel while using gcc-ppc64-linux-gnu v5.4.0 and v6.1.1.
While it works as expected with v5.3.1 .

Found that in init/main.c in  setup_command_line() the pointers passed to
strcpy() is messed up.

source for setup_command_line from init/main.c:
void setup_command_line(char *command_line)
{
saved_command_line =
memblock_virt_alloc(strlen(boot_command_line) + 1, 0);
initcall_command_line =
memblock_virt_alloc(strlen(boot_command_line) + 1, 0);
static_command_line = memblock_virt_alloc(strlen(command_line) + 1, 0);
strcpy(saved_command_line, boot_command_line);
strcpy(static_command_line, command_line);
}

Following is the asm dump for strcpy:

char *strcpy(char *dest, const char *src)
{
c0161408:   ff ff 84 38 addir4,r4,-1
c016140c:   ff ff 43 39 addir10,r3,-1
char *tmp = dest;

while ((*dest++ = *src++) != '\0')
c0161410:   01 00 24 8d lbzur9,1(r4)
c0161414:   00 00 a9 2f cmpdi   cr7,r9,0
c0161418:   01 00 2a 9d stbur9,1(r10)
c016141c:   f4 ff 9e 40 bne cr7,c0161410

/* nothing */;
return tmp;
}

Following are the asm dump for the working and non working binaries which
concluded that the argument for the second strcpy() is not loaded into r3 and
is getting clobbered with the return value of previous strcpy().

Not Working asm dump :

c03308d8:   38 c4 6a f8 std r3,-15304(r10)
strcpy(saved_command_line, boot_command_line);
c03308dc:   06 00 62 3c addis   r3,r2,6
c03308e0:   28 c4 63 e8 ld  r3,-15320(r3)
c03308e4:   25 0b e3 4b bl  c0161408

c03308e8:   00 00 00 60 nop
strcpy(static_command_line, command_line);
c03308ec:   78 f3 c4 7f mr  r4,r30
c03308f0:   19 0b e3 4b bl  c0161408

c03308f4:   00 00 00 60 nop

Working asm dump :

c03308d4:   38 c4 c3 fb std r30,-15304(r3)
strcpy(saved_command_line, boot_command_line);
c03308d8:   06 00 62 3c addis   r3,r2,6
c03308dc:   28 c4 63 e8 ld  r3,-15320(r3)
c03308e0:   6d 08 e3 4b bl  c016114c

c03308e4:   00 00 00 60 nop
strcpy(static_command_line, command_line);
c03308e8:   78 eb a4 7f mr  r4,r29
c03308ec:   78 f3 c3 7f mr  r3,r30
c03308f0:   5d 08 e3 4b bl  c016114c

c03308f4:   00 00 00 60 nop

The problem goes away when compiler optimization is restricted to -O1.

Reported-by: Madhavan Srinivasan 
Signed-off-by: Akshay Adiga 
---
 init/main.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/init/main.c b/init/main.c
index a8a58e2..4259c42 100644
--- a/init/main.c
+++ b/init/main.c
@@ -358,7 +358,13 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) 
{ }
  * parsing is performed in place, and we should allow a component to
  * store reference of name/value for future reference.
  */
-static void __init setup_command_line(char *command_line)
+static void __init
+#ifdef CONFIG_PPC64
+   #if  GCC_VERSION > 50301
+   __attribute__((optimize("-O1")))
+   #endif
+#endif
+   setup_command_line(char *command_line)
 {
saved_command_line =
memblock_virt_alloc(strlen(boot_command_line) + 1, 0);
-- 
2.5.5