Re: [PATCH v3] powerpc: kvm: make _PAGE_NUMA take effect

2014-04-14 Thread Alexander Graf


On 13.04.14 04:27, Liu ping fan wrote:

On Fri, Apr 11, 2014 at 10:03 PM, Alexander Graf ag...@suse.de wrote:

On 11.04.2014, at 13:45, Liu Ping Fan pingf...@linux.vnet.ibm.com wrote:


When we mark pte with _PAGE_NUMA we already call 
mmu_notifier_invalidate_range_start
and mmu_notifier_invalidate_range_end, which will mark existing guest hpte
entry as HPTE_V_ABSENT. Now we need to do that when we are inserting new
guest hpte entries.

What happens when we don't? Why do we need the check? Why isn't it done 
implicitly? What happens when we treat a NUMA marked page as non-present? Why 
does it work out for us?

Assume you have no idea what PAGE_NUMA is, but try to figure out what this 
patch does and whether you need to cherry-pick it into your downstream kernel. 
The description as is still is not very helpful for that. It doesn't even 
explain what really changes with this patch applied.


Yeah.  what about appending the following description?  Can it make
the context clear?
Guest should not setup a hpte for the page whose pte is marked with
_PAGE_NUMA, so on the host, the numa-fault mechanism can take effect
to check whether the page is placed correctly or not.


Try to come up with a text that answers the following questions in order:

  - What does _PAGE_NUMA mean?
  - How does page migration with _PAGE_NUMA work?
  - Why should we not map pages when _PAGE_NUMA is set?
  - Which part of what needs to be done did the previous _PAGE_NUMA 
patch address?

  - What's the situation without this patch?
  - Which scenario does this patch fix?

Once you have a text that answers those, you should have a good patch 
description :).


Alex

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

Re: Change MINSIGSTKSZ and SIGSTKSIZE

2014-04-14 Thread Alan Modra
On Sat, Apr 12, 2014 at 02:59:55AM -0700, Haren Myneni wrote:
 Alan, 
   LTP test (signalstack02) is failing.

Ignore the stupid test.  Do *NOT* change the kernel value to match
glibc.  The two sets of constants are independent.

The glibc constants are for user code, to allocate correctly sized
signal stacks for all known kernels.  These constants are therefore
the maximum values needed for known kernels.

The kernel constants are to check that user code is setting up a large
enough signal stack *for that specific kernel, and user binary*.  If
you make the kernel constants match current glibc, then old binaries
that don't use htm or vsx will fail when run on a newer kernel.

Ideally the kernel would detect whether a binary was going to use htm
or vsx and adjust the minimum sizes, but it's a wee bit difficult for
the kernel to know that ahead of time.

 This test expects -ENOMEM from
 kernel when passing less than stack size (passing 4095). MINSIGSTKSZ in
 signal.h (glibc) is changed to 4096 to support VSX changes
 (https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f7c399cff5bd04ee9dc117fb6b0f39597dc047c6)
   We should also change these values in kernel to match with glibc. Any 
 issues? 
 
 diff --git a/arch/powerpc/include/uapi/asm/signal.h
 b/arch/powerpc/include/uapi/
 index 6c69ee9..18f498e 100644
 --- a/arch/powerpc/include/uapi/asm/signal.h
 +++ b/arch/powerpc/include/uapi/asm/signal.h
 @@ -85,8 +85,8 @@ typedef struct {
  
  #define SA_RESTORER0x0400U
  
 -#define MINSIGSTKSZ2048
 -#define SIGSTKSZ   8192
 +#define MINSIGSTKSZ4096
 +#define SIGSTKSZ   16384
 
 Thanks
 Haren

-- 
Alan Modra
Australia Development Lab, IBM
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/2] PCI/MSI: Phase out pci_enable_msi_block()

2014-04-14 Thread Alexander Gordeev
There are no users of pci_enable_msi_block() function have
left. Obsolete it in favor of pci_enable_msi_range() and
pci_enable_msi_exact() functions.

Up until now, when enabling MSI mode for a device, a single
successful call to arch_msi_check_device() was followed by
a single call to arch_setup_msi_irqs() function.

Yet, if arch_msi_check_device() returned success we should be
able to call arch_setup_msi_irqs() multiple times - while it
returns a number of MSI vectors that could have been allocated
(a third state).

This update makes use of the assumption described above. It
could have broke things had the architectures done any pre-
allocations or switch to some state in a call to function
arch_msi_check_device(). But because arch_msi_check_device()
is expected stateless and MSI resources are allocated in a
follow-up call to arch_setup_msi_irqs() we should be fine.

Signed-off-by: Alexander Gordeev agord...@redhat.com
Cc: linux-m...@linux-mips.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-...@vger.kernel.org
---
 drivers/pci/msi.c   |   79 +-
 include/linux/pci.h |5 +--
 2 files changed, 34 insertions(+), 50 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 955ab79..fc669ab 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -883,50 +883,6 @@ int pci_msi_vec_count(struct pci_dev *dev)
 }
 EXPORT_SYMBOL(pci_msi_vec_count);
 
-/**
- * pci_enable_msi_block - configure device's MSI capability structure
- * @dev: device to configure
- * @nvec: number of interrupts to configure
- *
- * Allocate IRQs for a device with the MSI capability.
- * This function returns a negative errno if an error occurs.  If it
- * is unable to allocate the number of interrupts requested, it returns
- * the number of interrupts it might be able to allocate.  If it successfully
- * allocates at least the number of interrupts requested, it returns 0 and
- * updates the @dev's irq member to the lowest new interrupt number; the
- * other interrupt numbers allocated to this device are consecutive.
- */
-int pci_enable_msi_block(struct pci_dev *dev, int nvec)
-{
-   int status, maxvec;
-
-   if (dev-current_state != PCI_D0)
-   return -EINVAL;
-
-   maxvec = pci_msi_vec_count(dev);
-   if (maxvec  0)
-   return maxvec;
-   if (nvec  maxvec)
-   return maxvec;
-
-   status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI);
-   if (status)
-   return status;
-
-   WARN_ON(!!dev-msi_enabled);
-
-   /* Check whether driver already requested MSI-X irqs */
-   if (dev-msix_enabled) {
-   dev_info(dev-dev, can't enable MSI 
-(MSI-X already enabled)\n);
-   return -EINVAL;
-   }
-
-   status = msi_capability_init(dev, nvec);
-   return status;
-}
-EXPORT_SYMBOL(pci_enable_msi_block);
-
 void pci_msi_shutdown(struct pci_dev *dev)
 {
struct msi_desc *desc;
@@ -1132,14 +1088,45 @@ void pci_msi_init_pci_dev(struct pci_dev *dev)
  **/
 int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
 {
-   int nvec = maxvec;
+   int nvec;
int rc;
 
+   if (dev-current_state != PCI_D0)
+   return -EINVAL;
+
+   WARN_ON(!!dev-msi_enabled);
+
+   /* Check whether driver already requested MSI-X irqs */
+   if (dev-msix_enabled) {
+   dev_info(dev-dev,
+can't enable MSI (MSI-X already enabled)\n);
+   return -EINVAL;
+   }
+
if (maxvec  minvec)
return -ERANGE;
 
+   nvec = pci_msi_vec_count(dev);
+   if (nvec  0)
+   return nvec;
+   else if (nvec  minvec)
+   return -EINVAL;
+   else if (nvec  maxvec)
+   nvec = maxvec;
+
+   do {
+   rc = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI);
+   if (rc  0) {
+   return rc;
+   } else if (rc  0) {
+   if (rc  minvec)
+   return -ENOSPC;
+   nvec = rc;
+   }
+   } while (rc);
+
do {
-   rc = pci_enable_msi_block(dev, nvec);
+   rc = msi_capability_init(dev, nvec);
if (rc  0) {
return rc;
} else if (rc  0) {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index aab57b4..d8104f4 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1158,7 +1158,6 @@ struct msix_entry {
 
 #ifdef CONFIG_PCI_MSI
 int pci_msi_vec_count(struct pci_dev *dev);
-int pci_enable_msi_block(struct pci_dev *dev, int nvec);
 void pci_msi_shutdown(struct pci_dev *dev);
 void pci_disable_msi(struct pci_dev *dev);
 int pci_msix_vec_count(struct pci_dev *dev);
@@ -1188,8 +1187,6 @@ static inline int pci_enable_msix_exact(struct pci_dev 
*dev,
 }

[PATCH v2 01/15] powerpc/boot: fix do_div for 64bit wrapper

2014-04-14 Thread Cédric Le Goater
When the boot wrapper is compiled in 64bit, there is no need to
use __div64_32.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/stdio.c |   14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/powerpc/boot/stdio.c b/arch/powerpc/boot/stdio.c
index 5b57800bbc67..a701261b1781 100644
--- a/arch/powerpc/boot/stdio.c
+++ b/arch/powerpc/boot/stdio.c
@@ -21,6 +21,18 @@ size_t strnlen(const char * s, size_t count)
return sc - s;
 }
 
+#ifdef __powerpc64__
+
+# define do_div(n, base) ({\
+   unsigned int __base = (base);   \
+   unsigned int __rem; \
+   __rem = ((unsigned long long)(n)) % __base; \
+   (n) = ((unsigned long long)(n)) / __base;   \
+   __rem;  \
+})
+
+#else
+
 extern unsigned int __div64_32(unsigned long long *dividend,
   unsigned int divisor);
 
@@ -39,6 +51,8 @@ extern unsigned int __div64_32(unsigned long long *dividend,
__rem;  \
  })
 
+#endif /* __powerpc64__ */
+
 static int skip_atoi(const char **s)
 {
int i, c;
-- 
1.7.10.4

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

[PATCH v2 00/15] powerpc/boot: 64bit little endian wrapper

2014-04-14 Thread Cédric Le Goater
Hi,

The following patchset adds support for 64bit little endian boot 
wrapper. It is based on original code from Andrew Tauferner. 

The first patches provide fixes for 64bit support. I also changed 
the prom code to make it converge with the prom_init kernel code. 
They have a lot in common and they could probably be merged.

  powerpc/boot: fix do_div for 64bit wrapper
  powerpc/boot: use a common prom_args struct in oflib
  powerpc/boot: use prom_arg_t in oflib
  powerpc/boot: add byteswapping routines in oflib
  powerpc/boot: add PROM_ERROR define in oflib
  powerpc/boot: rework of_claim() to make it 64bit friendly
  powerpc/boot: define typedef ihandle as u32
  powerpc/boot: fix compile warning in 64bit

These are for little endian only:

  powerpc/boot: define byteswapping routines for little endian
  powerpc/boot: add 64bit and little endian support to addnote
  powerpc/boot: add little endian support to elf utils

and finally, these add support for the 64bit little endian boot 
wrapper :

  powerpc/boot: define a routine to enter prom
  powerpc/boot: modify entry point for 64bit
  powerpc/boot: add a global entry point for pseries
  powerpc/boot: add support for 64bit little endian wrapper

Here are some topics to discuss :

  - to compile in 64bit, -m64 is added to the cross32 compiler.
  - There are still some compile warnings due to 64bit, in addnote 
and in the device tree library.
  - the wrapper is compiled as a position independent executable. 

This patchset is based on a 3.15-rc1 and was tested on qemu with 
the -kernel option, yaboot and grub for little and big endian 
guests. Tests were also done to check that the PowerVM stack was
not broken by these changes.

It is also available from :

https://github.com/legoater/linux zimagev2 

Cheers,

C. 

Changes since v1 :

  - Fixed Makefile for platforms generating a zImage.pseries 
  - used PROM_ERROR (-1u) to test return addr when claiming memory
  - removed patch modifying the call to the kernel entry point
  - merged last 3 patches to preserve bisectability 

Cédric Le Goater (15):
  powerpc/boot: fix do_div for 64bit wrapper
  powerpc/boot: use a common prom_args struct in oflib
  powerpc/boot: use prom_arg_t in oflib
  powerpc/boot: add byteswapping routines in oflib
  powerpc/boot: add PROM_ERROR define in oflib
  powerpc/boot: rework of_claim() to make it 64bit friendly
  powerpc/boot: define typedef ihandle as u32
  powerpc/boot: fix compile warning in 64bit
  powerpc/boot: define byteswapping routines for little endian
  powerpc/boot: add 64bit and little endian support to addnote
  powerpc/boot: add little endian support to elf utils
  powerpc/boot: define a routine to enter prom
  powerpc/boot: modify entry point for 64bit
  powerpc/boot: add a global entry point for pseries
  powerpc/boot: add support for 64bit little endian wrapper

 arch/powerpc/boot/Makefile |   21 +++-
 arch/powerpc/boot/addnote.c|  128 +++
 arch/powerpc/boot/crt0.S   |  180 +++-
 arch/powerpc/boot/elf_util.c   |4 +
 arch/powerpc/boot/of.c |4 +-
 arch/powerpc/boot/of.h |   19 +++-
 arch/powerpc/boot/ofconsole.c  |6 +-
 arch/powerpc/boot/oflib.c  |   92 
 arch/powerpc/boot/ppc_asm.h|   12 +++
 arch/powerpc/boot/pseries-head.S   |8 ++
 arch/powerpc/boot/stdio.c  |   14 +++
 arch/powerpc/boot/swab.h   |   29 +
 arch/powerpc/boot/wrapper  |   17 ++-
 arch/powerpc/boot/zImage.lds.S |   25 -
 arch/powerpc/platforms/Kconfig.cputype |5 +
 15 files changed, 464 insertions(+), 100 deletions(-)
 create mode 100644 arch/powerpc/boot/pseries-head.S
 create mode 100644 arch/powerpc/boot/swab.h

-- 
1.7.10.4

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

[PATCH v2 02/15] powerpc/boot: use a common prom_args struct in oflib

2014-04-14 Thread Cédric Le Goater
This patch fixes warnings when the wrapper is compiled in 64bit and
updates the boot wrapper code related to prom to converge with the
kernel code in prom_init. This should make the review of changes easier.

The kernel has a different number of possible arguments (10) when
entering prom. There does not seem to be any good reason to have
12 in the wrapper, so the patch changes this value to args[10] in
the prom_args struct.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/of.h|2 ++
 arch/powerpc/boot/oflib.c |   29 +++--
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/boot/of.h b/arch/powerpc/boot/of.h
index e4c68f7391c5..5da03d9b9463 100644
--- a/arch/powerpc/boot/of.h
+++ b/arch/powerpc/boot/of.h
@@ -18,4 +18,6 @@ int of_setprop(const void *phandle, const char *name, const 
void *buf,
 /* Console functions */
 void of_console_init(void);
 
+typedef u32__be32;
+
 #endif /* _PPC_BOOT_OF_H_ */
diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index b0ec9cf3eaaf..c3288a3446b3 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -16,6 +16,15 @@
 
 #include of.h
 
+/* The following structure is used to communicate with open firmware.
+ * All arguments in and out are in big endian format. */
+struct prom_args {
+   __be32 service; /* Address of service name string. */
+   __be32 nargs;   /* Number of input arguments. */
+   __be32 nret;/* Number of output arguments. */
+   __be32 args[10];/* Input/output arguments. */
+};
+
 static int (*prom) (void *);
 
 void of_init(void *promptr)
@@ -23,18 +32,15 @@ void of_init(void *promptr)
prom = (int (*)(void *))promptr;
 }
 
+#define ADDR(x)(u32)(unsigned long)(x)
+
 int of_call_prom(const char *service, int nargs, int nret, ...)
 {
int i;
-   struct prom_args {
-   const char *service;
-   int nargs;
-   int nret;
-   unsigned int args[12];
-   } args;
+   struct prom_args args;
va_list list;
 
-   args.service = service;
+   args.service = ADDR(service);
args.nargs = nargs;
args.nret = nret;
 
@@ -56,15 +62,10 @@ static int of_call_prom_ret(const char *service, int nargs, 
int nret,
unsigned int *rets, ...)
 {
int i;
-   struct prom_args {
-   const char *service;
-   int nargs;
-   int nret;
-   unsigned int args[12];
-   } args;
+   struct prom_args args;
va_list list;
 
-   args.service = service;
+   args.service = ADDR(service);
args.nargs = nargs;
args.nret = nret;
 
-- 
1.7.10.4

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

[PATCH v2 03/15] powerpc/boot: use prom_arg_t in oflib

2014-04-14 Thread Cédric Le Goater
This patch updates the wrapper code to converge with the kernel code in
prom_init.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/oflib.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index c3288a3446b3..3b0c9458504f 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -16,6 +16,8 @@
 
 #include of.h
 
+typedef u32 prom_arg_t;
+
 /* The following structure is used to communicate with open firmware.
  * All arguments in and out are in big endian format. */
 struct prom_args {
@@ -46,7 +48,7 @@ int of_call_prom(const char *service, int nargs, int nret, 
...)
 
va_start(list, nret);
for (i = 0; i  nargs; i++)
-   args.args[i] = va_arg(list, unsigned int);
+   args.args[i] = va_arg(list, prom_arg_t);
va_end(list);
 
for (i = 0; i  nret; i++)
@@ -59,7 +61,7 @@ int of_call_prom(const char *service, int nargs, int nret, 
...)
 }
 
 static int of_call_prom_ret(const char *service, int nargs, int nret,
-   unsigned int *rets, ...)
+   prom_arg_t *rets, ...)
 {
int i;
struct prom_args args;
@@ -71,7 +73,7 @@ static int of_call_prom_ret(const char *service, int nargs, 
int nret,
 
va_start(list, rets);
for (i = 0; i  nargs; i++)
-   args.args[i] = va_arg(list, unsigned int);
+   args.args[i] = va_arg(list, prom_arg_t);
va_end(list);
 
for (i = 0; i  nret; i++)
@@ -148,7 +150,7 @@ static int check_of_version(void)
 void *of_claim(unsigned long virt, unsigned long size, unsigned long align)
 {
int ret;
-   unsigned int result;
+   prom_arg_t result;
 
if (need_map  0)
need_map = check_of_version();
-- 
1.7.10.4

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

[PATCH v2 04/15] powerpc/boot: add byteswapping routines in oflib

2014-04-14 Thread Cédric Le Goater
Values will need to be byte-swapped when calling prom (big endian) from
a little endian boot wrapper.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/of.h|3 +++
 arch/powerpc/boot/ofconsole.c |6 --
 arch/powerpc/boot/oflib.c |   22 +++---
 3 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/boot/of.h b/arch/powerpc/boot/of.h
index 5da03d9b9463..40d95bf7402b 100644
--- a/arch/powerpc/boot/of.h
+++ b/arch/powerpc/boot/of.h
@@ -20,4 +20,7 @@ void of_console_init(void);
 
 typedef u32__be32;
 
+#define cpu_to_be32(x) (x)
+#define be32_to_cpu(x) (x)
+
 #endif /* _PPC_BOOT_OF_H_ */
diff --git a/arch/powerpc/boot/ofconsole.c b/arch/powerpc/boot/ofconsole.c
index ce0e02424453..8b754702460a 100644
--- a/arch/powerpc/boot/ofconsole.c
+++ b/arch/powerpc/boot/ofconsole.c
@@ -18,7 +18,7 @@
 
 #include of.h
 
-static void *of_stdout_handle;
+static unsigned int of_stdout_handle;
 
 static int of_console_open(void)
 {
@@ -27,8 +27,10 @@ static int of_console_open(void)
if (((devp = of_finddevice(/chosen)) != NULL)
 (of_getprop(devp, stdout, of_stdout_handle,
   sizeof(of_stdout_handle))
-   == sizeof(of_stdout_handle)))
+   == sizeof(of_stdout_handle))) {
+   of_stdout_handle = be32_to_cpu(of_stdout_handle);
return 0;
+   }
 
return -1;
 }
diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index 3b0c9458504f..0f72b1a42133 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -42,13 +42,13 @@ int of_call_prom(const char *service, int nargs, int nret, 
...)
struct prom_args args;
va_list list;
 
-   args.service = ADDR(service);
-   args.nargs = nargs;
-   args.nret = nret;
+   args.service = cpu_to_be32(ADDR(service));
+   args.nargs = cpu_to_be32(nargs);
+   args.nret = cpu_to_be32(nret);
 
va_start(list, nret);
for (i = 0; i  nargs; i++)
-   args.args[i] = va_arg(list, prom_arg_t);
+   args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t));
va_end(list);
 
for (i = 0; i  nret; i++)
@@ -57,7 +57,7 @@ int of_call_prom(const char *service, int nargs, int nret, 
...)
if (prom(args)  0)
return -1;
 
-   return (nret  0)? args.args[nargs]: 0;
+   return (nret  0) ? be32_to_cpu(args.args[nargs]) : 0;
 }
 
 static int of_call_prom_ret(const char *service, int nargs, int nret,
@@ -67,13 +67,13 @@ static int of_call_prom_ret(const char *service, int nargs, 
int nret,
struct prom_args args;
va_list list;
 
-   args.service = ADDR(service);
-   args.nargs = nargs;
-   args.nret = nret;
+   args.service = cpu_to_be32(ADDR(service));
+   args.nargs = cpu_to_be32(nargs);
+   args.nret = cpu_to_be32(nret);
 
va_start(list, rets);
for (i = 0; i  nargs; i++)
-   args.args[i] = va_arg(list, prom_arg_t);
+   args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t));
va_end(list);
 
for (i = 0; i  nret; i++)
@@ -84,9 +84,9 @@ static int of_call_prom_ret(const char *service, int nargs, 
int nret,
 
if (rets != (void *) 0)
for (i = 1; i  nret; ++i)
-   rets[i-1] = args.args[nargs+i];
+   rets[i-1] = be32_to_cpu(args.args[nargs+i]);
 
-   return (nret  0)? args.args[nargs]: 0;
+   return (nret  0) ? be32_to_cpu(args.args[nargs]) : 0;
 }
 
 /* returns true if s2 is a prefix of s1 */
-- 
1.7.10.4

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

[PATCH v2 08/15] powerpc/boot: fix compile warning in 64bit

2014-04-14 Thread Cédric Le Goater
 arch/powerpc/boot/oflib.c:211:9: warning: cast to pointer from integer of \
  different size [-Wint-to-pointer-cast]
  return (phandle) of_call_prom(finddevice, 1, 1, name);

This is a work around. The definite solution would be to define the
phandle typedef as a u32, as in the kernel, but this would break the
device tree ops API.

Let it be for the moment.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/oflib.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index 956443fb9f65..cdfe762d2b2b 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -201,7 +201,7 @@ void of_exit(void)
  */
 void *of_finddevice(const char *name)
 {
-   return (phandle) of_call_prom(finddevice, 1, 1, name);
+   return (void *) (unsigned long) of_call_prom(finddevice, 1, 1, name);
 }
 
 int of_getprop(const void *phandle, const char *name, void *buf,
-- 
1.7.10.4

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

[PATCH v2 05/15] powerpc/boot: add PROM_ERROR define in oflib

2014-04-14 Thread Cédric Le Goater
This is mostly useful to make to the boot wrapper code closer with
the kernel code in prom_init.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---

Changes since v1:

 - moved PROM_ERROR definition in of.h. of_try_claim() will make 
   use of it in the next patch.

 arch/powerpc/boot/of.h|2 ++
 arch/powerpc/boot/oflib.c |6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/boot/of.h b/arch/powerpc/boot/of.h
index 40d95bf7402b..0f058ef69521 100644
--- a/arch/powerpc/boot/of.h
+++ b/arch/powerpc/boot/of.h
@@ -23,4 +23,6 @@ typedef u32   __be32;
 #define cpu_to_be32(x) (x)
 #define be32_to_cpu(x) (x)
 
+#define PROM_ERROR (-1u)
+
 #endif /* _PPC_BOOT_OF_H_ */
diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index 0f72b1a42133..7f61f2eb5653 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -55,7 +55,7 @@ int of_call_prom(const char *service, int nargs, int nret, 
...)
args.args[nargs+i] = 0;
 
if (prom(args)  0)
-   return -1;
+   return PROM_ERROR;
 
return (nret  0) ? be32_to_cpu(args.args[nargs]) : 0;
 }
@@ -80,9 +80,9 @@ static int of_call_prom_ret(const char *service, int nargs, 
int nret,
args.args[nargs+i] = 0;
 
if (prom(args)  0)
-   return -1;
+   return PROM_ERROR;
 
-   if (rets != (void *) 0)
+   if (rets != NULL)
for (i = 1; i  nret; ++i)
rets[i-1] = be32_to_cpu(args.args[nargs+i]);
 
-- 
1.7.10.4

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

[PATCH v2 09/15] powerpc/boot: define byteswapping routines for little endian

2014-04-14 Thread Cédric Le Goater
These are not the most efficient versions of swab but the wrapper does
not do much byte swapping. On a big endian cpu, these routines are
a no-op.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/of.h   |7 +++
 arch/powerpc/boot/swab.h |   29 +
 2 files changed, 36 insertions(+)
 create mode 100644 arch/powerpc/boot/swab.h

diff --git a/arch/powerpc/boot/of.h b/arch/powerpc/boot/of.h
index e1ef620082f7..c8c1750aba0c 100644
--- a/arch/powerpc/boot/of.h
+++ b/arch/powerpc/boot/of.h
@@ -1,6 +1,8 @@
 #ifndef _PPC_BOOT_OF_H_
 #define _PPC_BOOT_OF_H_
 
+#include swab.h
+
 typedef void *phandle;
 typedef u32 ihandle;
 
@@ -21,8 +23,13 @@ void of_console_init(void);
 
 typedef u32__be32;
 
+#ifdef __LITTLE_ENDIAN__
+#define cpu_to_be32(x) swab32(x)
+#define be32_to_cpu(x) swab32(x)
+#else
 #define cpu_to_be32(x) (x)
 #define be32_to_cpu(x) (x)
+#endif
 
 #define PROM_ERROR (-1u)
 
diff --git a/arch/powerpc/boot/swab.h b/arch/powerpc/boot/swab.h
new file mode 100644
index ..d0e1431084ca
--- /dev/null
+++ b/arch/powerpc/boot/swab.h
@@ -0,0 +1,29 @@
+#ifndef _PPC_BOOT_SWAB_H_
+#define _PPC_BOOT_SWAB_H_
+
+static inline u16 swab16(u16 x)
+{
+   return  ((x  (u16)0x00ffU)  8) |
+   ((x  (u16)0xff00U)  8);
+}
+
+static inline u32 swab32(u32 x)
+{
+   return  ((x  (u32)0x00ffUL)  24) |
+   ((x  (u32)0xff00UL)   8) |
+   ((x  (u32)0x00ffUL)   8) |
+   ((x  (u32)0xff00UL)  24);
+}
+
+static inline u64 swab64(u64 x)
+{
+   return  (u64)((x  (u64)0x00ffULL)  56) |
+   (u64)((x  (u64)0xff00ULL)  40) |
+   (u64)((x  (u64)0x00ffULL)  24) |
+   (u64)((x  (u64)0xff00ULL)   8) |
+   (u64)((x  (u64)0x00ffULL)   8) |
+   (u64)((x  (u64)0xff00ULL)  24) |
+   (u64)((x  (u64)0x00ffULL)  40) |
+   (u64)((x  (u64)0xff00ULL)  56);
+}
+#endif /* _PPC_BOOT_SWAB_H_ */
-- 
1.7.10.4

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

[PATCH v2 06/15] powerpc/boot: rework of_claim() to make it 64bit friendly

2014-04-14 Thread Cédric Le Goater
This patch fixes 64bit compile warnings and updates the wrapper code
to converge the kernel code in prom_init.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---

Changes since v1:

 - use PROM_ERROR to test return addr

 arch/powerpc/boot/of.c|4 ++--
 arch/powerpc/boot/of.h|3 ++-
 arch/powerpc/boot/oflib.c |   15 ---
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/boot/of.c b/arch/powerpc/boot/of.c
index 62e2f43ec1df..7ca910cb2fc6 100644
--- a/arch/powerpc/boot/of.c
+++ b/arch/powerpc/boot/of.c
@@ -40,8 +40,8 @@ static void *of_try_claim(unsigned long size)
 #ifdef DEBUG
printf(trying: 0x%08lx\n\r, claim_base);
 #endif
-   addr = (unsigned long)of_claim(claim_base, size, 0);
-   if ((void *)addr != (void *)-1)
+   addr = (unsigned long) of_claim(claim_base, size, 0);
+   if (addr != PROM_ERROR)
break;
}
if (addr == 0)
diff --git a/arch/powerpc/boot/of.h b/arch/powerpc/boot/of.h
index 0f058ef69521..504a0a31b685 100644
--- a/arch/powerpc/boot/of.h
+++ b/arch/powerpc/boot/of.h
@@ -6,7 +6,8 @@ typedef void *ihandle;
 
 void of_init(void *promptr);
 int of_call_prom(const char *service, int nargs, int nret, ...);
-void *of_claim(unsigned long virt, unsigned long size, unsigned long align);
+unsigned int of_claim(unsigned long virt, unsigned long size,
+   unsigned long align);
 void *of_vmlinux_alloc(unsigned long size);
 void of_exit(void);
 void *of_finddevice(const char *name);
diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index 7f61f2eb5653..329437d0e943 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -147,7 +147,8 @@ static int check_of_version(void)
return 1;
 }
 
-void *of_claim(unsigned long virt, unsigned long size, unsigned long align)
+unsigned int of_claim(unsigned long virt, unsigned long size,
+ unsigned long align)
 {
int ret;
prom_arg_t result;
@@ -155,32 +156,32 @@ void *of_claim(unsigned long virt, unsigned long size, 
unsigned long align)
if (need_map  0)
need_map = check_of_version();
if (align || !need_map)
-   return (void *) of_call_prom(claim, 3, 1, virt, size, align);
+   return of_call_prom(claim, 3, 1, virt, size, align);
 
ret = of_call_prom_ret(call-method, 5, 2, result, claim, memory,
   align, size, virt);
if (ret != 0 || result == -1)
-   return (void *) -1;
+   return  -1;
ret = of_call_prom_ret(call-method, 5, 2, result, claim, 
chosen_mmu,
   align, size, virt);
/* 0x12 == coherent + read/write */
ret = of_call_prom(call-method, 6, 1, map, chosen_mmu,
   0x12, size, virt, virt);
-   return (void *) virt;
+   return virt;
 }
 
 void *of_vmlinux_alloc(unsigned long size)
 {
unsigned long start = (unsigned long)_start, end = (unsigned long)_end;
-   void *addr;
+   unsigned long addr;
void *p;
 
/* With some older POWER4 firmware we need to claim the area the kernel
 * will reside in.  Newer firmwares don't need this so we just ignore
 * the return value.
 */
-   addr = of_claim(start, end - start, 0);
-   printf(Trying to claim from 0x%lx to 0x%lx (0x%lx) got %p\r\n,
+   addr = (unsigned long) of_claim(start, end - start, 0);
+   printf(Trying to claim from 0x%lx to 0x%lx (0x%lx) got %lx\r\n,
   start, end, end - start, addr);
 
p = malloc(size);
-- 
1.7.10.4

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

[PATCH v2 10/15] powerpc/boot: add 64bit and little endian support to addnote

2014-04-14 Thread Cédric Le Goater
It could certainly be improved using Elf macros and byteswapping
routines, but the initial version of the code is organised to be a
single file program with limited dependencies. yaboot is the same.

Please scream if you want a total rewrite.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---

Changes since RFC:

 - fixed the note creation which was done with the wrong endianess 
 - increased 'buf' as ELF structures are larger in 64bit

 arch/powerpc/boot/addnote.c |  128 ---
 1 file changed, 85 insertions(+), 43 deletions(-)

diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
index 349b5530d2c4..9d9f6f334d3c 100644
--- a/arch/powerpc/boot/addnote.c
+++ b/arch/powerpc/boot/addnote.c
@@ -6,6 +6,8 @@
  *
  * Copyright 2000 Paul Mackerras.
  *
+ * Adapted for 64 bit little endian images by Andrew Tauferner.
+ *
  * 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
@@ -55,36 +57,61 @@ unsigned int rpanote[N_RPA_DESCR] = {
 
 #define ROUNDUP(len)   (((len) + 3)  ~3)
 
-unsigned char buf[512];
+unsigned char buf[1024];
+#define ELFDATA2LSB 1
+#define ELFDATA2MSB 2
+static int e_data = ELFDATA2MSB;
+#define ELFCLASS32  1
+#define ELFCLASS64  2
+static int e_class = ELFCLASS32;
 
 #define GET_16BE(off)  ((buf[off]  8) + (buf[(off)+1]))
-#define GET_32BE(off)  ((GET_16BE(off)  16) + GET_16BE((off)+2))
-
-#define PUT_16BE(off, v)   (buf[off] = ((v)  8)  0xff, \
-buf[(off) + 1] = (v)  0xff)
-#define PUT_32BE(off, v)   (PUT_16BE((off), (v)  16), \
-PUT_16BE((off) + 2, (v)))
+#define GET_32BE(off)  ((GET_16BE(off)  16U) + GET_16BE((off)+2U))
+#define GET_64BE(off)  unsigned long long)GET_32BE(off))  32ULL) + \
+   ((unsigned long long)GET_32BE((off)+4ULL)))
+#define PUT_16BE(off, v)(buf[off] = ((v)  8)  0xff, \
+buf[(off) + 1] = (v)  0xff)
+#define PUT_32BE(off, v)(PUT_16BE((off), (v)  16L), PUT_16BE((off) + 2, (v)))
+#define PUT_64BE(off, v)((PUT_32BE((off), (v)  32L), \
+ PUT_32BE((off) + 4, (v
+
+#define GET_16LE(off)  ((buf[off]) + (buf[(off)+1]  8))
+#define GET_32LE(off)  (GET_16LE(off) + (GET_16LE((off)+2U)  16U))
+#define GET_64LE(off)  ((unsigned long long)GET_32LE(off) + \
+   (((unsigned long long)GET_32LE((off)+4ULL))  32ULL))
+#define PUT_16LE(off, v) (buf[off] = (v)  0xff, \
+ buf[(off) + 1] = ((v)  8)  0xff)
+#define PUT_32LE(off, v) (PUT_16LE((off), (v)), PUT_16LE((off) + 2, (v)  
16L))
+#define PUT_64LE(off, v) (PUT_32LE((off), (v)), PUT_32LE((off) + 4, (v)  
32L))
+
+#define GET_16(off)(e_data == ELFDATA2MSB ? GET_16BE(off) : GET_16LE(off))
+#define GET_32(off)(e_data == ELFDATA2MSB ? GET_32BE(off) : GET_32LE(off))
+#define GET_64(off)(e_data == ELFDATA2MSB ? GET_64BE(off) : GET_64LE(off))
+#define PUT_16(off, v) (e_data == ELFDATA2MSB ? PUT_16BE(off, v) : \
+PUT_16LE(off, v))
+#define PUT_32(off, v)  (e_data == ELFDATA2MSB ? PUT_32BE(off, v) : \
+PUT_32LE(off, v))
+#define PUT_64(off, v)  (e_data == ELFDATA2MSB ? PUT_64BE(off, v) : \
+PUT_64LE(off, v))
 
 /* Structure of an ELF file */
 #define E_IDENT0   /* ELF header */
-#defineE_PHOFF 28
-#define E_PHENTSIZE42
-#define E_PHNUM44
-#define E_HSIZE52  /* size of ELF header */
+#defineE_PHOFF (e_class == ELFCLASS32 ? 28 : 32)
+#define E_PHENTSIZE(e_class == ELFCLASS32 ? 42 : 54)
+#define E_PHNUM(e_class == ELFCLASS32 ? 44 : 56)
+#define E_HSIZE(e_class == ELFCLASS32 ? 52 : 64)
 
 #define EI_MAGIC   0   /* offsets in E_IDENT area */
 #define EI_CLASS   4
 #define EI_DATA5
 
 #define PH_TYPE0   /* ELF program header */
-#define PH_OFFSET  4
-#define PH_FILESZ  16
-#define PH_HSIZE   32  /* size of program header */
+#define PH_OFFSET  (e_class == ELFCLASS32 ? 4 : 8)
+#define PH_FILESZ  (e_class == ELFCLASS32 ? 16 : 32)
+#define PH_HSIZE   (e_class == ELFCLASS32 ? 32 : 56)
 
 #define PT_NOTE4   /* Program header type = note */
 
-#define ELFCLASS32 1
-#define ELFDATA2MSB2
 
 unsigned char elf_magic[4] = { 0x7f, 'E', 'L', 'F' };
 
@@ -92,8 +119,8 @@ int
 main(int ac, char **av)
 {
int fd, n, i;
-   int ph, ps, np;
-   int nnote, nnote2, ns;
+   unsigned long ph, ps, np;
+   long nnote, nnote2, ns;
 
if (ac != 2) {
fprintf(stderr, Usage: %s elf-file\n, av[0]);
@@ -114,26 +141,27 @@ main(int ac, char **av)
exit(1);
}
 
-   if (n  E_HSIZE || 

[PATCH v2 13/15] powerpc/boot: modify entry point for 64bit

2014-04-14 Thread Cédric Le Goater
This patch adds support a 64bit wrapper entry point. As in 32bit, the
entry point does its own relocation and can be loaded at any address
by the firmware.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/crt0.S |  108 --
 1 file changed, 104 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index dbd99d064828..689290561e69 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -1,17 +1,20 @@
 /*
  * Copyright (C) Paul Mackerras 1997.
  *
+ * Adapted for 64 bit LE PowerPC by Andrew Tauferner
+ *
  * 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.
  *
- * NOTE: this code runs in 32 bit mode, is position-independent,
- * and is packaged as ELF32.
  */
 
 #include ppc_asm.h
 
+RELA = 7
+RELACOUNT = 0x6ff9
+
.text
/* A procedure descriptor used when booting this as a COFF file.
 * When making COFF, this comes first in the link and we're
@@ -21,6 +24,20 @@
 _zimage_start_opd:
.long   0x50, 0, 0, 0
 
+#ifdef __powerpc64__
+.balign 8
+p_start:   .llong  _start
+p_etext:   .llong  _etext
+p_bss_start:   .llong  __bss_start
+p_end: .llong  _end
+
+p_toc: .llong  __toc_start + 0x8000 - p_base
+p_dyn: .llong  __dynamic_start - p_base
+p_rela:.llong  __rela_dyn_start - p_base
+p_prom:.llong  0
+   .weak   _platform_stack_top
+p_pstack:  .llong  _platform_stack_top
+#else
 p_start:   .long   _start
 p_etext:   .long   _etext
 p_bss_start:   .long   __bss_start
@@ -28,6 +45,7 @@ p_end:.long   _end
 
.weak   _platform_stack_top
 p_pstack:  .long   _platform_stack_top
+#endif
 
.weak   _zimage_start
.globl  _zimage_start
@@ -38,6 +56,7 @@ _zimage_start_lib:
   and the address where we're running. */
bl  .+4
 p_base:mflrr10 /* r10 now points to runtime addr of 
p_base */
+#ifndef __powerpc64__
/* grab the link address of the dynamic section in r11 */
addis   r11,r10,(_GLOBAL_OFFSET_TABLE_-p_base)@ha
lwz r11,(_GLOBAL_OFFSET_TABLE_-p_base)@l(r11)
@@ -51,8 +70,6 @@ p_base:   mflrr10 /* r10 now points to 
runtime addr of p_base */
 
/* The dynamic section contains a series of tagged entries.
 * We need the RELA and RELACOUNT entries. */
-RELA = 7
-RELACOUNT = 0x6ff9
li  r9,0
li  r0,0
 9: lwz r8,0(r12)   /* get tag */
@@ -120,7 +137,90 @@ RELACOUNT = 0x6ff9
li  r0,0
stwur0,-16(r1)  /* establish a stack frame */
 6:
+#else /* __powerpc64__ */
+   /* Save the prom pointer at p_prom. */
+   std r5,(p_prom-p_base)(r10)
+
+   /* Set r2 to the TOC. */
+   ld  r2,(p_toc-p_base)(r10)
+   add r2,r2,r10
+
+   /* Grab the link address of the dynamic section in r11. */
+   ld  r11,-32768(r2)
+   cmpwi   r11,0
+   beq 3f  /* if not linked -pie then no dynamic section */
+
+   ld  r11,(p_dyn-p_base)(r10)
+   add r11,r11,r10
+   ld  r9,(p_rela-p_base)(r10)
+   add r9,r9,r10
+
+   li  r7,0
+   li  r8,0
+9: ld  r6,0(r11)   /* get tag */
+   cmpdi   r6,0
+   beq 12f  /* end of list */
+   cmpdi   r6,RELA
+   bne 10f
+   ld  r7,8(r11)   /* get RELA pointer in r7 */
+   b   11f
+10:addis   r6,r6,(-RELACOUNT)@ha
+   cmpdi   r6,RELACOUNT@l
+   bne 11f
+   ld  r8,8(r11)   /* get RELACOUNT value in r8 */
+11:addir11,r11,16
+   b   9b
+12:
+   cmpdi   r7,0/* check we have both RELA and RELACOUNT */
+   cmpdi   cr1,r8,0
+   beq 3f
+   beq cr1,3f
+
+   /* Calcuate the runtime offset. */
+   subfr7,r7,r9
 
+   /* Run through the list of relocations and process the
+* R_PPC64_RELATIVE ones. */
+   mtctr   r8
+13:ld  r0,8(r9)/* ELF64_R_TYPE(reloc-r_info) */
+   cmpdi   r0,22   /* R_PPC64_RELATIVE */
+   bne 3f
+   ld  r6,0(r9)/* reloc-r_offset */
+   ld  r0,16(r9)   /* reloc-r_addend */
+   add r0,r0,r7
+   stdxr0,r7,r6
+   addir9,r9,24
+   bdnz13b
+
+   /* Do a cache flush for our text, in case the loader didn't */
+3: ld  r9,p_start-p_base(r10)  /* note: these are relocated now */
+   ld  r8,p_etext-p_base(r10)
+4: dcbfr0,r9
+   icbir0,r9
+   addir9,r9,0x20
+   cmpld   cr0,r9,r8
+   blt 4b
+   sync
+   isync
+
+   /* Clear the BSS */
+   

[PATCH v2 11/15] powerpc/boot: add little endian support to elf utils

2014-04-14 Thread Cédric Le Goater
Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/elf_util.c |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/boot/elf_util.c b/arch/powerpc/boot/elf_util.c
index 1567a0c0f05c..316552dea4d8 100644
--- a/arch/powerpc/boot/elf_util.c
+++ b/arch/powerpc/boot/elf_util.c
@@ -26,7 +26,11 @@ int parse_elf64(void *hdr, struct elf_info *info)
  elf64-e_ident[EI_MAG2]  == ELFMAG2   
  elf64-e_ident[EI_MAG3]  == ELFMAG3   
  elf64-e_ident[EI_CLASS] == ELFCLASS64
+#ifdef __LITTLE_ENDIAN__
+ elf64-e_ident[EI_DATA]  == ELFDATA2LSB   
+#else
  elf64-e_ident[EI_DATA]  == ELFDATA2MSB   
+#endif
  (elf64-e_type== ET_EXEC ||
   elf64-e_type== ET_DYN)  
  elf64-e_machine == EM_PPC64))
-- 
1.7.10.4

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

[PATCH v2 12/15] powerpc/boot: define a routine to enter prom

2014-04-14 Thread Cédric Le Goater
This patch defines a 'prom' routine similar to 'enter_prom' in the
kernel.

The difference is in the MSR which is built before entering prom. Big
endian order is enforced as in the kernel but 32bit mode is not. It
prepares ground for the next patches which will introduce Little endian
order.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/crt0.S  |   71 +
 arch/powerpc/boot/oflib.c |6 
 2 files changed, 77 insertions(+)

diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index 0f7428a37efb..dbd99d064828 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -126,3 +126,74 @@ RELACOUNT = 0x6ff9
 
/* Call start */
b   start
+
+#ifdef __powerpc64__
+
+#define PROM_FRAME_SIZE 512
+#define SAVE_GPR(n, base)   std n,8*(n)(base)
+#define REST_GPR(n, base)   ld  n,8*(n)(base)
+#define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base)
+#define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base)
+#define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base)
+#define SAVE_10GPRS(n, base)SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base)
+#define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base)
+#define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base)
+#define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base)
+#define REST_10GPRS(n, base)REST_8GPRS(n, base); REST_2GPRS(n+8, base)
+
+/* prom handles the jump into and return from firmware.  The prom args pointer
+   is loaded in r3. */
+.globl prom
+prom:
+   mflrr0
+   std r0,16(r1)
+   stdur1,-PROM_FRAME_SIZE(r1) /* Save SP and create stack space */
+
+   SAVE_GPR(2, r1)
+   SAVE_GPR(13, r1)
+   SAVE_8GPRS(14, r1)
+   SAVE_10GPRS(22, r1)
+   mfcrr10
+   std r10,8*32(r1)
+   mfmsr   r10
+   std r10,8*33(r1)
+
+   /* remove MSR_LE from msr but keep MSR_SF */
+   mfmsr   r10
+   rldicr  r10,r10,0,62
+   mtsrr1  r10
+
+   /* Load FW address, set LR to label 1, and jump to FW */
+   bl  0f
+0: mflrr10
+   addir11,r10,(1f-0b)
+   mtlrr11
+
+   ld  r10,(p_prom-0b)(r10)
+   mtsrr0  r10
+
+   rfid
+
+1: /* Return from OF */
+
+   /* Restore registers and return. */
+   rldicl  r1,r1,0,32
+
+   /* Restore the MSR (back to 64 bits) */
+   ld  r10,8*(33)(r1)
+   mtmsr   r10
+   isync
+
+   /* Restore other registers */
+   REST_GPR(2, r1)
+   REST_GPR(13, r1)
+   REST_8GPRS(14, r1)
+   REST_10GPRS(22, r1)
+   ld  r10,8*32(r1)
+   mtcrr10
+
+   addir1,r1,PROM_FRAME_SIZE
+   ld  r0,16(r1)
+   mtlrr0
+   blr
+#endif
diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index cdfe762d2b2b..46c98a47d949 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -27,11 +27,17 @@ struct prom_args {
__be32 args[10];/* Input/output arguments. */
 };
 
+#ifdef __powerpc64__
+extern int prom(void *);
+#else
 static int (*prom) (void *);
+#endif
 
 void of_init(void *promptr)
 {
+#ifndef __powerpc64__
prom = (int (*)(void *))promptr;
+#endif
 }
 
 #define ADDR(x)(u32)(unsigned long)(x)
-- 
1.7.10.4

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

[PATCH v2 14/15] powerpc/boot: add a global entry point for pseries

2014-04-14 Thread Cédric Le Goater
When entering the boot wrapper in little endian, we will need to fix
the endian order using a fixup trampoline like in the kernel. This
patch overrides the _zimage_start entry point for this purpose.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---

Changes since v1:

 - pseries is not the only platform generating a zImage.pseries boot 
   wrapper. Fixed Makefile for these. 

 arch/powerpc/boot/Makefile   |5 +
 arch/powerpc/boot/pseries-head.S |5 +
 arch/powerpc/boot/wrapper|2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/boot/pseries-head.S

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index a1f8c7f1ec60..bed660ddf48c 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -99,6 +99,11 @@ src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c 
cuboot-mpc7448hpc2.c \
 src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
 src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
 src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
+src-plat-$(CONFIG_PPC_PSERIES) += pseries-head.S
+src-plat-$(CONFIG_PPC_POWERNV) += pseries-head.S
+src-plat-$(CONFIG_PPC_IBM_CELL_BLADE) += pseries-head.S
+src-plat-$(CONFIG_PPC_CELLEB) += pseries-head.S
+src-plat-$(CONFIG_PPC_CELL_QPACE) += pseries-head.S
 
 src-wlib := $(sort $(src-wlib-y))
 src-plat := $(sort $(src-plat-y))
diff --git a/arch/powerpc/boot/pseries-head.S b/arch/powerpc/boot/pseries-head.S
new file mode 100644
index ..655c3d2c321b
--- /dev/null
+++ b/arch/powerpc/boot/pseries-head.S
@@ -0,0 +1,5 @@
+   .text
+
+   .globl _zimage_start
+_zimage_start:
+   b _zimage_start_lib
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index d27a25518b01..5889c440a66a 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -152,7 +152,7 @@ of)
 make_space=n
 ;;
 pseries)
-platformo=$object/of.o $object/epapr.o
+platformo=$object/pseries-head.o $object/of.o $object/epapr.o
 link_address='0x400'
 make_space=n
 ;;
-- 
1.7.10.4

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

[PATCH v2 15/15] powerpc/boot: add support for 64bit little endian wrapper

2014-04-14 Thread Cédric Le Goater
The code is only slightly modified : entry points now use the
FIXUP_ENDIAN trampoline to switch endian order. The 32bit wrapper
is kept for big endian kernels and 64bit is enforced for little
endian kernels with a PPC64_BOOT_WRAPPER config option.

The linker script is generated using the kernel preprocessor flags
to make use of the CONFIG_* definitions and the wrapper script is
modified to take into account the new elf64ppc format.

Finally, the zImage file is compiled as a position independent
executable (-pie) which makes it loadable at any address by the
firmware.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---

Changes since v1:

 - merge last 3 patches to preserve bisectability 

 arch/powerpc/boot/Makefile |   16 +---
 arch/powerpc/boot/crt0.S   |1 +
 arch/powerpc/boot/ppc_asm.h|   12 
 arch/powerpc/boot/pseries-head.S   |3 +++
 arch/powerpc/boot/wrapper  |   15 ++-
 arch/powerpc/boot/zImage.lds.S |   25 -
 arch/powerpc/platforms/Kconfig.cputype |5 +
 7 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index bed660ddf48c..a33c23308e97 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -22,8 +22,14 @@ all: $(obj)/zImage
 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) \
--mbig-endian
+-isystem $(shell $(CROSS32CC) -print-file-name=include)
+ifdef CONFIG_PPC64_BOOT_WRAPPER
+BOOTCFLAGS += -m64
+endif
+ifdef CONFIG_CPU_BIG_ENDIAN
+BOOTCFLAGS += -mbig-endian
+endif
+
 BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
 
 ifdef CONFIG_DEBUG_INFO
@@ -142,7 +148,11 @@ $(addprefix $(obj)/,$(libfdt) $(libfdtheader)): $(obj)/%: 
$(srctree)/scripts/dtc
 $(obj)/empty.c:
@touch $@
 
-$(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds: $(obj)/%: 
$(srctree)/$(src)/%.S
+$(obj)/zImage.lds: $(obj)/%: $(srctree)/$(src)/%.S
+   $(CROSS32CC) $(cpp_flags) -E -Wp,-MD,$(depfile) -P -Upowerpc \
+   -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $
+
+$(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S
@cp $ $@
 
 clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \
diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index 689290561e69..14de4f8778a7 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -275,6 +275,7 @@ prom:
rfid
 
 1: /* Return from OF */
+   FIXUP_ENDIAN
 
/* Restore registers and return. */
rldicl  r1,r1,0,32
diff --git a/arch/powerpc/boot/ppc_asm.h b/arch/powerpc/boot/ppc_asm.h
index eb0e98be69e0..35ea60c1f070 100644
--- a/arch/powerpc/boot/ppc_asm.h
+++ b/arch/powerpc/boot/ppc_asm.h
@@ -62,4 +62,16 @@
 #define SPRN_TBRL  268
 #define SPRN_TBRU  269
 
+#define FIXUP_ENDIAN  \
+   tdi   0, 0, 0x48; /* Reverse endian of b . + 8  */ \
+   b $+36;   /* Skip trampoline if endian is good  */ \
+   .long 0x05009f42; /* bcl 20,31,$+4  */ \
+   .long 0xa602487d; /* mflr r10   */ \
+   .long 0x1c004a39; /* addi r10,r10,28*/ \
+   .long 0xa600607d; /* mfmsr r11  */ \
+   .long 0x01006b69; /* xori r11,r11,1 */ \
+   .long 0xa6035a7d; /* mtsrr0 r10 */ \
+   .long 0xa6037b7d; /* mtsrr1 r11 */ \
+   .long 0x244c  /* rfid   */
+
 #endif /* _PPC64_PPC_ASM_H */
diff --git a/arch/powerpc/boot/pseries-head.S b/arch/powerpc/boot/pseries-head.S
index 655c3d2c321b..6ef6e02e80f9 100644
--- a/arch/powerpc/boot/pseries-head.S
+++ b/arch/powerpc/boot/pseries-head.S
@@ -1,5 +1,8 @@
+#include ppc_asm.h
+
.text
 
.globl _zimage_start
 _zimage_start:
+   FIXUP_ENDIAN
b _zimage_start_lib
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 5889c440a66a..1948cf8b8a40 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -40,6 +40,7 @@ cacheit=
 binary=
 gzip=.gz
 pie=
+format=
 
 # cross-compilation prefix
 CROSS=
@@ -136,6 +137,14 @@ if [ -z $kernel ]; then
 kernel=vmlinux
 fi
 
+elfformat=`${CROSS}objdump -p $kernel | grep 'file format' | awk '{print 
$4}'`
+case $elfformat in
+elf64-powerpcle)   format=elf64lppc;;
+elf64-powerpc) format=elf32ppc ;;
+elf32-powerpc) format=elf32ppc ;;
+esac
+
+
 platformo=$object/$platform.o
 lds=$object/zImage.lds
 ext=strip
@@ -154,6 +163,10 @@ of)
 pseries)
 

[PATCH v2 07/15] powerpc/boot: define typedef ihandle as u32

2014-04-14 Thread Cédric Le Goater
This makes ihandle 64bit friendly.

Signed-off-by: Cédric Le Goater c...@fr.ibm.com
---
 arch/powerpc/boot/of.h|2 +-
 arch/powerpc/boot/oflib.c |   10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/boot/of.h b/arch/powerpc/boot/of.h
index 504a0a31b685..e1ef620082f7 100644
--- a/arch/powerpc/boot/of.h
+++ b/arch/powerpc/boot/of.h
@@ -2,7 +2,7 @@
 #define _PPC_BOOT_OF_H_
 
 typedef void *phandle;
-typedef void *ihandle;
+typedef u32 ihandle;
 
 void of_init(void *promptr);
 int of_call_prom(const char *service, int nargs, int nret, ...);
diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index 329437d0e943..956443fb9f65 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -106,7 +106,7 @@ static int string_match(const char *s1, const char *s2)
  */
 static int need_map = -1;
 static ihandle chosen_mmu;
-static phandle memory;
+static ihandle memory;
 
 static int check_of_version(void)
 {
@@ -135,10 +135,10 @@ static int check_of_version(void)
printf(no mmu\n);
return 0;
}
-   memory = (ihandle) of_call_prom(open, 1, 1, /memory);
-   if (memory == (ihandle) -1) {
-   memory = (ihandle) of_call_prom(open, 1, 1, /memory@0);
-   if (memory == (ihandle) -1) {
+   memory = of_call_prom(open, 1, 1, /memory);
+   if (memory == PROM_ERROR) {
+   memory = of_call_prom(open, 1, 1, /memory@0);
+   if (memory == PROM_ERROR) {
printf(no memory node\n);
return 0;
}
-- 
1.7.10.4

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

Re: [PATCH v3] powerpc: kvm: make _PAGE_NUMA take effect

2014-04-14 Thread liu ping fan
On Mon, Apr 14, 2014 at 2:43 PM, Alexander Graf ag...@suse.de wrote:

 On 13.04.14 04:27, Liu ping fan wrote:

 On Fri, Apr 11, 2014 at 10:03 PM, Alexander Graf ag...@suse.de wrote:

 On 11.04.2014, at 13:45, Liu Ping Fan pingf...@linux.vnet.ibm.com
 wrote:

 When we mark pte with _PAGE_NUMA we already call
 mmu_notifier_invalidate_range_start
 and mmu_notifier_invalidate_range_end, which will mark existing guest
 hpte
 entry as HPTE_V_ABSENT. Now we need to do that when we are inserting new
 guest hpte entries.

 What happens when we don't? Why do we need the check? Why isn't it done
 implicitly? What happens when we treat a NUMA marked page as non-present?
 Why does it work out for us?

 Assume you have no idea what PAGE_NUMA is, but try to figure out what
 this patch does and whether you need to cherry-pick it into your downstream
 kernel. The description as is still is not very helpful for that. It doesn't
 even explain what really changes with this patch applied.

 Yeah.  what about appending the following description?  Can it make
 the context clear?
 Guest should not setup a hpte for the page whose pte is marked with
 _PAGE_NUMA, so on the host, the numa-fault mechanism can take effect
 to check whether the page is placed correctly or not.


 Try to come up with a text that answers the following questions in order:

I divide them into 3 groups, and answer them by 3 sections. Seems that
it has the total story :)
Please take a look.

   - What does _PAGE_NUMA mean?
Group 1 - section 2

   - How does page migration with _PAGE_NUMA work?
   - Why should we not map pages when _PAGE_NUMA is set?
Group 2 - section 1
(Note: for the 1st question in this group, I am not sure about the
details, except that we can fix numa balancing by moving task or
moving page.  So I comment as  migration should be involved to cut
down the distance between the cpu and pages)

   - Which part of what needs to be done did the previous _PAGE_NUMA patch
 address?
   - What's the situation without this patch?
   - Which scenario does this patch fix?

Group 3 - section 3


Numa fault is a method which help to achieve auto numa balancing.
When such a page fault takes place, the page fault handler will check
whether the page is placed correctly. If not, migration should be
involved to cut down the distance between the cpu and pages.

A pte with _PAGE_NUMA help to implement numa fault. It means not to
allow the MMU to access the page directly. So a page fault is triggered
and numa fault handler gets the opportunity to run checker.

As for the access of MMU, we need special handling for the powernv's guest.
When we mark a pte with _PAGE_NUMA, we already call mmu_notifier to
invalidate it in guest's htab, but when we tried to re-insert them,
we firstly try to fix it in real-mode. Only after this fails, we fallback
to virt mode, and most of important, we run numa fault handler in virt
mode.  This patch guards the way of real-mode to ensure that if a pte is
marked with _PAGE_NUMA, it will NOT be fixed in real mode, instead, it will
be fixed in virt mode and have the opportunity to be checked with placement.


Thx,
Fan


 Once you have a text that answers those, you should have a good patch
 description :).

 Alex


 --
 To unsubscribe from this list: send the line unsubscribe kvm in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v3] powerpc: kvm: make _PAGE_NUMA take effect

2014-04-14 Thread Alexander Graf


On 14.04.14 10:08, liu ping fan wrote:

On Mon, Apr 14, 2014 at 2:43 PM, Alexander Graf ag...@suse.de wrote:

On 13.04.14 04:27, Liu ping fan wrote:

On Fri, Apr 11, 2014 at 10:03 PM, Alexander Graf ag...@suse.de wrote:

On 11.04.2014, at 13:45, Liu Ping Fan pingf...@linux.vnet.ibm.com
wrote:


When we mark pte with _PAGE_NUMA we already call
mmu_notifier_invalidate_range_start
and mmu_notifier_invalidate_range_end, which will mark existing guest
hpte
entry as HPTE_V_ABSENT. Now we need to do that when we are inserting new
guest hpte entries.

What happens when we don't? Why do we need the check? Why isn't it done
implicitly? What happens when we treat a NUMA marked page as non-present?
Why does it work out for us?

Assume you have no idea what PAGE_NUMA is, but try to figure out what
this patch does and whether you need to cherry-pick it into your downstream
kernel. The description as is still is not very helpful for that. It doesn't
even explain what really changes with this patch applied.


Yeah.  what about appending the following description?  Can it make
the context clear?
Guest should not setup a hpte for the page whose pte is marked with
_PAGE_NUMA, so on the host, the numa-fault mechanism can take effect
to check whether the page is placed correctly or not.


Try to come up with a text that answers the following questions in order:


I divide them into 3 groups, and answer them by 3 sections. Seems that
it has the total story :)
Please take a look.


   - What does _PAGE_NUMA mean?

Group 1 - section 2


   - How does page migration with _PAGE_NUMA work?
   - Why should we not map pages when _PAGE_NUMA is set?

Group 2 - section 1
(Note: for the 1st question in this group, I am not sure about the
details, except that we can fix numa balancing by moving task or
moving page.  So I comment as  migration should be involved to cut
down the distance between the cpu and pages)


   - Which part of what needs to be done did the previous _PAGE_NUMA patch
address?
   - What's the situation without this patch?
   - Which scenario does this patch fix?


Group 3 - section 3


Numa fault is a method which help to achieve auto numa balancing.
When such a page fault takes place, the page fault handler will check
whether the page is placed correctly. If not, migration should be
involved to cut down the distance between the cpu and pages.

A pte with _PAGE_NUMA help to implement numa fault. It means not to
allow the MMU to access the page directly. So a page fault is triggered
and numa fault handler gets the opportunity to run checker.

As for the access of MMU, we need special handling for the powernv's guest.
When we mark a pte with _PAGE_NUMA, we already call mmu_notifier to
invalidate it in guest's htab, but when we tried to re-insert them,
we firstly try to fix it in real-mode. Only after this fails, we fallback
to virt mode, and most of important, we run numa fault handler in virt
mode.  This patch guards the way of real-mode to ensure that if a pte is
marked with _PAGE_NUMA, it will NOT be fixed in real mode, instead, it will
be fixed in virt mode and have the opportunity to be checked with placement.


s/fixed/mapped/g

Otherwise works as patch description for me :).


Alex

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

[PATCH] powerpc: Fix error return in rtas_flash module init

2014-04-14 Thread Anton Blanchard
module_init should return 0 or a negative errno.

Signed-off-by: Anton Blanchard an...@samba.org
---

diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 2f3cdb0..658e89d 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -705,7 +705,7 @@ static int __init rtas_flash_init(void)
if (rtas_token(ibm,update-flash-64-and-reboot) ==
   RTAS_UNKNOWN_SERVICE) {
pr_info(rtas_flash: no firmware flash support\n);
-   return 1;
+   return -EINVAL;
}
 
rtas_validate_flash_data.buf = kzalloc(VALIDATE_BUF_SIZE, GFP_KERNEL);
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 1/3] powerpc: Rename duplicate COMMAND_LINE_SIZE define

2014-04-14 Thread Anton Blanchard
We have two definitions of COMMAND_LINE_SIZE, one for the kernel
and one for the boot wrapper. I assume this is so the boot
wrapper can be self sufficient and not rely on kernel headers.

Having two defines with the same name is confusing, I just
updated the wrong one when trying to bump it.

Make the boot wrapper define unique by calling it
BOOT_COMMAND_LINE_SIZE.

Signed-off-by: Anton Blanchard an...@samba.org
---

diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index a28f021..d367a0a 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -139,18 +139,18 @@ static struct addr_range prep_initrd(struct addr_range 
vmlinux, void *chosen,
  * edit the command line passed to vmlinux (by setting /chosen/bootargs).
  * The buffer is put in it's own section so that tools may locate it easier.
  */
-static char cmdline[COMMAND_LINE_SIZE]
+static char cmdline[BOOT_COMMAND_LINE_SIZE]
__attribute__((__section__(__builtin_cmdline)));
 
 static void prep_cmdline(void *chosen)
 {
if (cmdline[0] == '\0')
-   getprop(chosen, bootargs, cmdline, COMMAND_LINE_SIZE-1);
+   getprop(chosen, bootargs, cmdline, BOOT_COMMAND_LINE_SIZE-1);
 
printf(\n\rLinux/PowerPC load: %s, cmdline);
/* If possible, edit the command line */
if (console_ops.edit_cmdline)
-   console_ops.edit_cmdline(cmdline, COMMAND_LINE_SIZE);
+   console_ops.edit_cmdline(cmdline, BOOT_COMMAND_LINE_SIZE);
printf(\n\r);
 
/* Put the command line back into the devtree for the kernel */
@@ -174,7 +174,7 @@ void start(void)
 * built-in command line wasn't set by an external tool */
if ((loader_info.cmdline_len  0)  (cmdline[0] == '\0'))
memmove(cmdline, loader_info.cmdline,
-   min(loader_info.cmdline_len, COMMAND_LINE_SIZE-1));
+   min(loader_info.cmdline_len, BOOT_COMMAND_LINE_SIZE-1));
 
if (console_ops.open  (console_ops.open()  0))
exit();
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index b3218ce..339e041 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -15,7 +15,7 @@
 #include types.h
 #include string.h
 
-#defineCOMMAND_LINE_SIZE   512
+#defineBOOT_COMMAND_LINE_SIZE  512
 #defineMAX_PATH_LEN256
 #defineMAX_PROP_LEN256 /* What should this be? */
 
diff --git a/arch/powerpc/boot/ps3.c b/arch/powerpc/boot/ps3.c
index 9954d98..4ec2d86 100644
--- a/arch/powerpc/boot/ps3.c
+++ b/arch/powerpc/boot/ps3.c
@@ -47,13 +47,13 @@ BSS_STACK(4096);
  * The buffer is put in it's own section so that tools may locate it easier.
  */
 
-static char cmdline[COMMAND_LINE_SIZE]
+static char cmdline[BOOT_COMMAND_LINE_SIZE]
__attribute__((__section__(__builtin_cmdline)));
 
 static void prep_cmdline(void *chosen)
 {
if (cmdline[0] == '\0')
-   getprop(chosen, bootargs, cmdline, COMMAND_LINE_SIZE-1);
+   getprop(chosen, bootargs, cmdline, BOOT_COMMAND_LINE_SIZE-1);
else
setprop_str(chosen, bootargs, cmdline);
 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/3] powerpc: Bump COMMAND_LINE_SIZE to 2048

2014-04-14 Thread Anton Blanchard
I've had a report that the current limit is too small for
an automated network based installer. Bump it.

Signed-off-by: Anton Blanchard an...@samba.org
---

diff --git a/arch/powerpc/include/uapi/asm/setup.h 
b/arch/powerpc/include/uapi/asm/setup.h
index 552df83..0516e97 100644
--- a/arch/powerpc/include/uapi/asm/setup.h
+++ b/arch/powerpc/include/uapi/asm/setup.h
@@ -1 +1,6 @@
-#include asm-generic/setup.h
+#ifndef _UAPI_ASM_POWERPC_SETUP_H
+#define _UAPI_ASM_POWERPC_SETUP_H
+
+#define COMMAND_LINE_SIZE  2048
+
+#endif /* _UAPI_ASM_POWERPC_SETUP_H */

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

[PATCH 3/3] powerpc: Bump BOOT_COMMAND_LINE_SIZE to 2048

2014-04-14 Thread Anton Blanchard
Bump the boot wrapper BOOT_COMMAND_LINE_SIZE to match the
kernel.

Signed-off-by: Anton Blanchard an...@samba.org
---

We export this in an ELF section so userspace tools can edit it.
We should be safe so long as we are only increasing it shouldn't we?

Index: b/arch/powerpc/boot/ops.h
===
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -15,7 +15,7 @@
 #include types.h
 #include string.h
 
-#defineBOOT_COMMAND_LINE_SIZE  512
+#defineBOOT_COMMAND_LINE_SIZE  2048
 #defineMAX_PATH_LEN256
 #defineMAX_PROP_LEN256 /* What should this be? */
 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 2/2] PCI/MSI: Phase out pci_enable_msi_block()

2014-04-14 Thread Alexander Gordeev
On Mon, Apr 14, 2014 at 09:14:07AM +0200, Alexander Gordeev wrote:
 @@ -1244,7 +1241,7 @@ static inline void pcie_set_ecrc_checking(struct 
 pci_dev *dev) { }
  static inline void pcie_ecrc_get_policy(char *str) { }
  #endif
  
 -#define pci_enable_msi(pdev) pci_enable_msi_block(pdev, 1)
 +#define pci_enable_msi(pdev) pci_enable_msi_range(pdev, 1, 1)

Self-Nack, it should have been pci_enable_msi_exact(pdev, 1) ^^^

  #ifdef CONFIG_HT_IRQ
  /* The functions a driver should call */

-- 
Regards,
Alexander Gordeev
agord...@redhat.com
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc/85xx: Add OCA4080 board support

2014-04-14 Thread Martijn de Gouw
From: Martijn de Gouw martijn.de.g...@prodrive.nl

OCA4080 overview:
- 1.466 GHz Freescale QorIQ P4080E Processor
- 4Gbyte DDR3 on board
- 8Mbyte Nor flash
- Serial RapidIO 1.2
- 1 x 10/100/1000 BASE-T front ethernet
- 1 x 1000 BASE-BX ethernet on AMC connector

Signed-off-by: Martijn de Gouw martijn.de.g...@prodrive-technologies.com
---
 arch/powerpc/boot/dts/oca4080.dts |  148 +
 arch/powerpc/configs/corenet32_smp_defconfig  |1 +
 arch/powerpc/platforms/85xx/Kconfig   |2 +-
 arch/powerpc/platforms/85xx/corenet_generic.c |4 +-
 4 files changed, 152 insertions(+), 3 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/oca4080.dts

diff --git a/arch/powerpc/boot/dts/oca4080.dts 
b/arch/powerpc/boot/dts/oca4080.dts
new file mode 100644
index 000..8926a61
--- /dev/null
+++ b/arch/powerpc/boot/dts/oca4080.dts
@@ -0,0 +1,148 @@
+/*
+ * OCA4080 Device Tree Source
+ *
+ * Copyright 2014 Prodrive Technologies B.V.
+ *
+ * Based on:
+ * P4080DS Device Tree Source
+ * Copyright 2009-2011 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/ fsl/p4080si-pre.dtsi
+
+/ {
+   model = fsl,OCA4080;
+   compatible = fsl,OCA4080;
+   #address-cells = 2;
+   #size-cells = 2;
+   interrupt-parent = mpic;
+
+   memory {
+   device_type = memory;
+   };
+
+   dcsr: dcsr@f {
+   ranges = 0x 0xf 0x 0x01008000;
+   };
+
+   soc: soc@ffe00 {
+   ranges = 0x 0xf 0xfe00 0x100;
+   reg = 0xf 0xfe00 0 0x1000;
+
+   i2c@118000 {
+   status = disabled;
+   };
+
+   i2c@118100 {
+   status = disabled;
+   };
+
+   i2c@119000 {
+   status = disabled;
+   };
+
+   i2c@119100 {
+   status = disabled;
+   };
+
+   usb0: usb@21 {
+   status = disabled;
+   };
+
+   usb1: usb@211000 {
+   status = disabled;
+   };
+   };
+
+   rio: rapidio@ffe0c {
+   reg = 0xf 0xfe0c 0 0x11000;
+
+   port1 {
+   ranges = 0 0 0xc 0x2000 0 0x1000;
+   };
+   };
+
+   lbc: localbus@ffe124000 {
+   reg = 0xf 0xfe124000 0 0x1000;
+   ranges = 0 0 0xf 0xef80 0x80;
+
+   flash@0,0 {
+   #address-cells = 1;
+   #size-cells = 1;
+   compatible = cfi-flash;
+   reg = 0 0 0x0080;
+   bank-width = 2;
+   device-width = 2;
+   partition@rcw {
+   label = rcw;
+   reg = 0x 0x0002;
+   };
+   partition@fman-ucode {
+   label = fman-ucode;
+   reg = 0x0002 0x0002;
+   };
+   partition@user {
+  

[PATCH 2/2] PCI/MSI: Phase out pci_enable_msi_block()

2014-04-14 Thread Alexander Gordeev
There are no users of pci_enable_msi_block() function have
left. Obsolete it in favor of pci_enable_msi_range() and
pci_enable_msi_exact() functions.

Up until now, when enabling MSI mode for a device a single
successful call to arch_msi_check_device() was followed by
a single call to arch_setup_msi_irqs() function.

Yet, if arch_msi_check_device() returned success we should be
able to call arch_setup_msi_irqs() multiple times - while it
returns a number of MSI vectors that could have been allocated
(a third state).

This update makes use of the assumption described above. It
could have broke things had the architectures done any pre-
allocations or switch to some state in a call to function
arch_msi_check_device(). But because arch_msi_check_device()
is expected stateless and MSI resources are allocated in a
follow-up call to arch_setup_msi_irqs() we should be fine.

Signed-off-by: Alexander Gordeev agord...@redhat.com
Cc: linux-m...@linux-mips.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-...@vger.kernel.org
---
 drivers/pci/msi.c   |   79 +-
 include/linux/pci.h |5 +--
 2 files changed, 34 insertions(+), 50 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 955ab79..fc669ab 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -883,50 +883,6 @@ int pci_msi_vec_count(struct pci_dev *dev)
 }
 EXPORT_SYMBOL(pci_msi_vec_count);
 
-/**
- * pci_enable_msi_block - configure device's MSI capability structure
- * @dev: device to configure
- * @nvec: number of interrupts to configure
- *
- * Allocate IRQs for a device with the MSI capability.
- * This function returns a negative errno if an error occurs.  If it
- * is unable to allocate the number of interrupts requested, it returns
- * the number of interrupts it might be able to allocate.  If it successfully
- * allocates at least the number of interrupts requested, it returns 0 and
- * updates the @dev's irq member to the lowest new interrupt number; the
- * other interrupt numbers allocated to this device are consecutive.
- */
-int pci_enable_msi_block(struct pci_dev *dev, int nvec)
-{
-   int status, maxvec;
-
-   if (dev-current_state != PCI_D0)
-   return -EINVAL;
-
-   maxvec = pci_msi_vec_count(dev);
-   if (maxvec  0)
-   return maxvec;
-   if (nvec  maxvec)
-   return maxvec;
-
-   status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI);
-   if (status)
-   return status;
-
-   WARN_ON(!!dev-msi_enabled);
-
-   /* Check whether driver already requested MSI-X irqs */
-   if (dev-msix_enabled) {
-   dev_info(dev-dev, can't enable MSI 
-(MSI-X already enabled)\n);
-   return -EINVAL;
-   }
-
-   status = msi_capability_init(dev, nvec);
-   return status;
-}
-EXPORT_SYMBOL(pci_enable_msi_block);
-
 void pci_msi_shutdown(struct pci_dev *dev)
 {
struct msi_desc *desc;
@@ -1132,14 +1088,45 @@ void pci_msi_init_pci_dev(struct pci_dev *dev)
  **/
 int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
 {
-   int nvec = maxvec;
+   int nvec;
int rc;
 
+   if (dev-current_state != PCI_D0)
+   return -EINVAL;
+
+   WARN_ON(!!dev-msi_enabled);
+
+   /* Check whether driver already requested MSI-X irqs */
+   if (dev-msix_enabled) {
+   dev_info(dev-dev,
+can't enable MSI (MSI-X already enabled)\n);
+   return -EINVAL;
+   }
+
if (maxvec  minvec)
return -ERANGE;
 
+   nvec = pci_msi_vec_count(dev);
+   if (nvec  0)
+   return nvec;
+   else if (nvec  minvec)
+   return -EINVAL;
+   else if (nvec  maxvec)
+   nvec = maxvec;
+
+   do {
+   rc = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI);
+   if (rc  0) {
+   return rc;
+   } else if (rc  0) {
+   if (rc  minvec)
+   return -ENOSPC;
+   nvec = rc;
+   }
+   } while (rc);
+
do {
-   rc = pci_enable_msi_block(dev, nvec);
+   rc = msi_capability_init(dev, nvec);
if (rc  0) {
return rc;
} else if (rc  0) {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index aab57b4..499755e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1158,7 +1158,6 @@ struct msix_entry {
 
 #ifdef CONFIG_PCI_MSI
 int pci_msi_vec_count(struct pci_dev *dev);
-int pci_enable_msi_block(struct pci_dev *dev, int nvec);
 void pci_msi_shutdown(struct pci_dev *dev);
 void pci_disable_msi(struct pci_dev *dev);
 int pci_msix_vec_count(struct pci_dev *dev);
@@ -1188,8 +1187,6 @@ static inline int pci_enable_msix_exact(struct pci_dev 
*dev,
 }
 

Re: [PATCH v3 4/8] DMA: Freescale: add fsl_dma_free_descriptor() to reduce code duplication

2014-04-14 Thread Andy Shevchenko
On Fri, 2014-04-11 at 16:14 +0800, Hongbo Zhang wrote:
 On 04/10/2014 07:29 PM, Andy Shevchenko wrote:
  On Thu, 2014-04-10 at 15:10 +0800, hongbo.zh...@freescale.com wrote:

[]

  @@ -819,8 +826,7 @@ static void fsldma_cleanup_descriptor(struct 
  fsldma_chan *chan,
 dma_run_dependencies(txd);

 dma_descriptor_unmap(txd);
  -  chan_dbg(chan, LD %p free\n, desc);
  -  dma_pool_free(chan-desc_pool, desc, txd-phys);
  +  fsl_dma_free_descriptor(chan, desc);
  Here is no list_del() call since it's been called in dma_do_tasklet().
  What will be the result of double list_del() against the same node?
 
 Not clear with your point.
 This patch is only introducing a common fsl_dma_free_descriptor() to 
 reduce code duplication. And later in the patch 6/8 the 
 fsldma_cleanup_descriptor() is replaced by fsldma_cleanup_descriptorS().

In the last case you could have a broken kernel which will fails on
double list_del(). I think it's better to leave this one untouched and
you may remove it later.

Or move this patch after you have removed that lines.

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy

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

Re: [PATCH v3 6/8] DMA: Freescale: change descriptor release process for supporting async_tx

2014-04-14 Thread Andy Shevchenko
On Fri, 2014-04-11 at 16:33 +0800, Hongbo Zhang wrote:

  + * hardware channel, subsequent descriptors are either in
  + * process or have not been submitted
  Dot at the eol. Check in all comments.
 
  Even though I saw there are other comments without the dots, I think 
  it is better to have it.
  Thanks, all.
 
 Hmm... think it again, it it really necessary to have it?
 Even I have it in my patch, there are already so many comments exists 
 without it.

For my opinion is better to keep style in your patches. Better if it
commonly used style in the driver. But comment against comments is
really minor thing.

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy

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

Re: [PATCH] ASoC: fsl_sai: Fix incorrect condition check in trigger()

2014-04-14 Thread Mark Brown
On Fri, Apr 11, 2014 at 10:10:00PM +0800, Nicolin Chen wrote:

 + /* Check if the opposite FRDE is also disabled */
 + if (!(tx ? rcsr  FSL_SAI_CSR_FRDE : tcsr  FSL_SAI_CSR_FRDE)) {

I've applied this since it's a fix but this is *not* a triumph of
legibility, the ternery operator is often not helpful.


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

Re: [PATCH v2 2/2] ARM: dts: Append clock bindings for sai2 on VF610 platform

2014-04-14 Thread Mark Brown
On Wed, Apr 02, 2014 at 06:10:20PM +0800, Nicolin Chen wrote:
 Since we added fours clock to the DT binding, we should update the current
 SAI dts/dtsi so as not to break their functions.

This doesn't apply against v3.15-rc1, can you please check and resend?


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

Re: [PATCH v2 1/2] ASoC: fsl_sai: Add clock controls for SAI

2014-04-14 Thread Mark Brown
On Wed, Apr 02, 2014 at 06:10:19PM +0800, Nicolin Chen wrote:

 -- clock-names : Must include the sai entry.
 +- clock-names : Must include the bus for register access and mclk1 
 mclk2
 +  mclk3 for bit clock and frame clock providing.

This breaks compatibilty with old DTs - it just removes the sai name.
It's OK to deprecate the sai clock name but you need to keep support
for DTs that only specify that, there's no code for that left in the
driver.


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

Re: [PATCH] ASoC: fsl_sai: Use FSL_SAI_xXR() and regmap_update_bits() to simplify code

2014-04-14 Thread Mark Brown
On Fri, Apr 11, 2014 at 06:30:09PM +0800, Nicolin Chen wrote:
 By doing this, the driver can drop around 50 lines and become neater.

Applied, thanks.


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

[PATCH 1/1] powerpc: Increase COMMAND_LINE_SIZE to 2048 from 512.

2014-04-14 Thread Joseph Salisbury
BugLink: http://bugs.launchpad.net/bugs/1306677

While booting the PPC64EL kernel, the command line gets truncated to 512 
characters. This is due to a hard limit of 512 defined for COMMAND_LINE_SIZE.  
It would be beneficial to have a command line longer than 512 characters, as 
iscsi targets and cloud-init parameters are passed through the kernel command 
line.

Signed-off-by: Joseph Salisbury joseph.salisb...@canonical.com
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org (supporter:LINUX FOR 
POWERPC...)
Cc: Paul Mackerras pau...@samba.org (supporter:LINUX FOR POWERPC...)
Cc: linuxppc-dev@lists.ozlabs.org (open list:LINUX FOR POWERPC...)
Cc: linux-ker...@vger.kernel.org (open list)
Cc: sta...@vger.kernel.org

---
 arch/powerpc/boot/ops.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index b3218ce..5a01fb1 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -15,7 +15,7 @@
 #include types.h
 #include string.h
 
-#defineCOMMAND_LINE_SIZE   512
+#defineCOMMAND_LINE_SIZE   2048
 #defineMAX_PATH_LEN256
 #defineMAX_PROP_LEN256 /* What should this be? */
 
-- 
1.7.9.5

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

Re: [PATCH 1/1] powerpc: Increase COMMAND_LINE_SIZE to 2048 from 512.

2014-04-14 Thread Joseph Salisbury
On 04/14/2014 11:30 AM, Joseph Salisbury wrote:
 BugLink: http://bugs.launchpad.net/bugs/1306677

 While booting the PPC64EL kernel, the command line gets truncated to 512 
 characters. This is due to a hard limit of 512 defined for COMMAND_LINE_SIZE. 
  It would be beneficial to have a command line longer than 512 characters, as 
 iscsi targets and cloud-init parameters are passed through the kernel command 
 line.

 Signed-off-by: Joseph Salisbury joseph.salisb...@canonical.com
 Cc: Benjamin Herrenschmidt b...@kernel.crashing.org (supporter:LINUX FOR 
 POWERPC...)
 Cc: Paul Mackerras pau...@samba.org (supporter:LINUX FOR POWERPC...)
 Cc: linuxppc-dev@lists.ozlabs.org (open list:LINUX FOR POWERPC...)
 Cc: linux-ker...@vger.kernel.org (open list)
 Cc: sta...@vger.kernel.org

 ---
  arch/powerpc/boot/ops.h |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
 index b3218ce..5a01fb1 100644
 --- a/arch/powerpc/boot/ops.h
 +++ b/arch/powerpc/boot/ops.h
 @@ -15,7 +15,7 @@
  #include types.h
  #include string.h
  
 -#define  COMMAND_LINE_SIZE   512
 +#define  COMMAND_LINE_SIZE   2048
  #define  MAX_PATH_LEN256
  #define  MAX_PROP_LEN256 /* What should this be? */
  

After further review, it appears ppc does not actually use the define in
the ppc headers but uses the common generic
default(include/uapi/asm-generic/setup.h).  COMMAND_LINE_SIZE should
probably become a kernel config option.  Do folks agree that is the
correct thing to do?  If so, I can re-work the patch.

Thanks,

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

[PATCH 18/20] cpufreq: pasemi: Use cpufreq_for_each_entry macro for iteration

2014-04-14 Thread Stratos Karafotis
The cpufreq core supports the cpufreq_for_each_entry macro helper
for iteration over the cpufreq_frequency_table, so use it.

It should have no functional changes.

Signed-off-by: Stratos Karafotis strat...@semaphore.gr
---

Please note that I was no able to compile test this patch due to 
lack of cross compiler.

 drivers/cpufreq/pasemi-cpufreq.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 84c84b5..9a64492 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -136,9 +136,10 @@ void restore_astate(int cpu)
 
 static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
 {
+   struct cpufreq_frequency_table *pos;
const u32 *max_freqp;
u32 max_freq;
-   int i, cur_astate;
+   int cur_astate;
struct resource res;
struct device_node *cpu, *dn;
int err = -ENODEV;
@@ -197,10 +198,9 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy 
*policy)
pr_debug(initializing frequency table\n);
 
/* initialize frequency table */
-   for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {
-   pas_freqs[i].frequency =
-   get_astate_freq(pas_freqs[i].driver_data) * 10;
-   pr_debug(%d: %d\n, i, pas_freqs[i].frequency);
+   cpufreq_for_each_entry(pos, pas_freqs) {
+   pos-frequency = get_astate_freq(pos-driver_data) * 10;
+   pr_debug(%lu: %d\n, pos - pas_freqs, pos-frequency);
}
 
cur_astate = get_cur_astate(policy-cpu);
-- 
1.9.0
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc/85xx: Add OCA4080 board support

2014-04-14 Thread Scott Wood
On Mon, 2014-04-14 at 14:35 +0200, Martijn de Gouw wrote:
 + lbc: localbus@ffe124000 {
 + reg = 0xf 0xfe124000 0 0x1000;
 + ranges = 0 0 0xf 0xef80 0x80;
 +
 + flash@0,0 {
 + #address-cells = 1;
 + #size-cells = 1;
 + compatible = cfi-flash;
 + reg = 0 0 0x0080;
 + bank-width = 2;
 + device-width = 2;
 + partition@rcw {
 + label = rcw;
 + reg = 0x 0x0002;
 + };
 + partition@fman-ucode {
 + label = fman-ucode;
 + reg = 0x0002 0x0002;
 + };
 + partition@user {
 + label = user;
 + reg = 0x0004 0x0068;
 + };
 + partition@env0 {
 + label = env0;
 + reg = 0x006c 0x0002;
 + };
 + partition@env1 {
 + label = env1;
 + reg = 0x006e 0x0002;
 + };
 + partition@u-boot {
 + label = u-boot;
 + reg = 0x0070 0x0008;
 + };
 + partition@u-boot-backup {
 + label = u-boot-backup;
 + reg = 0x0078 0x0008;
 + };

These are not valid unit addresses.  Regardless, please don't put
partition info in the dts.

-Scott


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

Re: [PATCH 1/2] powerpc/mpc85xx: add two functions to get suspend state which is standby or mem

2014-04-14 Thread Scott Wood
On Mon, 2014-04-14 at 10:24 +0800, Dongsheng Wang wrote:
 From: Wang Dongsheng dongsheng.w...@freescale.com
 
 Add set_pm_suspend_state  pm_suspend_state functions to set/get suspend 
 state.
 When system going to sleep, devices can get the system suspend 
 state(STANDBY/MEM)
 through pm_suspend_state function and handle different situations.
 
 Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
 
 diff --git a/arch/powerpc/platforms/85xx/common.c 
 b/arch/powerpc/platforms/85xx/common.c
 index b564b5e..3853d43 100644
 --- a/arch/powerpc/platforms/85xx/common.c
 +++ b/arch/powerpc/platforms/85xx/common.c
 @@ -8,6 +8,7 @@
  
  #include linux/of_irq.h
  #include linux/of_platform.h
 +#include linux/suspend.h
  
  #include asm/qe.h
  #include sysdev/cpm2_pic.h
 @@ -47,6 +48,19 @@ int __init mpc85xx_common_publish_devices(void)
  {
   return of_platform_bus_probe(NULL, mpc85xx_common_ids, NULL);
  }
 +
 +static suspend_state_t pm_state;
 +
 +void set_pm_suspend_state(suspend_state_t state)
 +{
 + pm_state = state;
 +}
 +
 +suspend_state_t pm_suspend_state(void)
 +{
 + return pm_state;
 +}

These need to be namespaced to indicate that they apply only to mpc85xx.
Where do you plan on using these from, that mpc85xx can be safely
assumed?

This seems like a feature that should be implemented in generic code
instead.

-Scott


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

Re: [PATCH 2/2] fsl/mpic_timer: make mpic_timer to support deep sleep feature

2014-04-14 Thread Scott Wood
On Mon, 2014-04-14 at 10:24 +0800, Dongsheng Wang wrote:
 From: Wang Dongsheng dongsheng.w...@freescale.com
 
 At T104x platfrom the timer clock will be changed when system going to
 deep sleep.

Could you elaborate on what is changing and why?

 +#include asm/mpc85xx.h
  #include asm/mpic_timer.h

So much for, The driver currently is only tested on fsl chip, but it
can potentially support other global timers complying to OpenPIC
standard.

  #define FSL_GLOBAL_TIMER 0x1
 @@ -71,8 +74,10 @@ struct timer_group_priv {
   struct timer_regs __iomem   *regs;
   struct mpic_timer   timer[TIMERS_PER_GROUP];
   struct list_headnode;
 + unsigned long   idle;
   unsigned inttimerfreq;
 - unsigned intidle;

Why?

 + unsigned intsuspended_timerfreq;
 + unsigned intresume_timerfreq;
   unsigned intflags;
   spinlock_t  lock;
   void __iomem*group_tcr;
 @@ -88,6 +93,7 @@ static struct cascade_priv cascade_timer[] = {
  };
  
  static LIST_HEAD(timer_group_list);
 +static int switch_freq_flag;

Needs documentation, and based on _flag it should probably be a bool.

  static void convert_ticks_to_time(struct timer_group_priv *priv,
   const u64 ticks, struct timeval *time)
 @@ -423,6 +429,33 @@ struct mpic_timer *mpic_request_timer(irq_handler_t fn, 
 void *dev,
  }
  EXPORT_SYMBOL(mpic_request_timer);
  
 +static void timer_group_get_suspended_freq(struct timer_group_priv *priv)
 +{
 + struct device_node *np;
 +
 + np = of_find_compatible_node(NULL, NULL, fsl,qoriq-clockgen-2.0);
 + if (!np) {
 + pr_err(mpic timer: Missing clockgen device node.\n);

Why is it an error to not have a 2.0 QorIQ clockgen?

 + return;
 + }
 +
 + of_property_read_u32(np, clock-frequency, priv-suspended_timerfreq);
 + of_node_put(np);

Shouldn't this go through the clock API?

 +}
 +
 +static int need_to_switch_freq(void)
 +{
 + u32 svr;
 +
 + svr = mfspr(SPRN_SVR);
 + if (SVR_SOC_VER(svr) == SVR_T1040 ||
 + SVR_SOC_VER(svr) == SVR_T1042)
 + return 1;

Explain why this is specific to T104x.

-Scott


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

Re: [PATCH v3] dmaengine: driver support for FSL RaidEngine device.

2014-04-14 Thread Dan Williams
On Sun, Apr 13, 2014 at 7:48 PM, Xuelin Shi xuelin@freescale.com wrote:
 Hi Dan,

 fsl dma device and fsl raid device are two differenct devices that both 
 provide async_memcpy
 capability, so I use !FSL_DMA to disable the fsl dma device.

 That's to say, either select fsldma device, either fsl raid device.


Right, but that's not what your proposed Kconfig dependency line does.

You want something like depends on FSL_SOC  !(FSL_DMA || FSL_DMA=m)

However, the more problematic option is ASYNC_TX_CHANNEL_SWITCH.  That
option is problematic for RAID, so I propose depend on
!ASYNC_TX_CHANNEL_SWITCH since that addresses both problems.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH 1/2] powerpc/mpc85xx: add two functions to get suspend state which is standby or mem

2014-04-14 Thread dongsheng.w...@freescale.com


 -Original Message-
 From: Wood Scott-B07421
 Sent: Tuesday, April 15, 2014 7:27 AM
 To: Wang Dongsheng-B40534
 Cc: Jin Zhengxiong-R64188; Li Yang-Leo-R58472; Zhao Chenhui-B35336; linuxppc-
 d...@lists.ozlabs.org
 Subject: Re: [PATCH 1/2] powerpc/mpc85xx: add two functions to get suspend 
 state
 which is standby or mem
 
 On Mon, 2014-04-14 at 10:24 +0800, Dongsheng Wang wrote:
  From: Wang Dongsheng dongsheng.w...@freescale.com
 
  Add set_pm_suspend_state  pm_suspend_state functions to set/get suspend 
  state.
  When system going to sleep, devices can get the system suspend
  state(STANDBY/MEM) through pm_suspend_state function and handle different
 situations.
 
  Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
 
  diff --git a/arch/powerpc/platforms/85xx/common.c
  b/arch/powerpc/platforms/85xx/common.c
  index b564b5e..3853d43 100644
  --- a/arch/powerpc/platforms/85xx/common.c
  +++ b/arch/powerpc/platforms/85xx/common.c
  @@ -8,6 +8,7 @@
 
   #include linux/of_irq.h
   #include linux/of_platform.h
  +#include linux/suspend.h
 
   #include asm/qe.h
   #include sysdev/cpm2_pic.h
  @@ -47,6 +48,19 @@ int __init mpc85xx_common_publish_devices(void)
   {
  return of_platform_bus_probe(NULL, mpc85xx_common_ids, NULL);  }
  +
  +static suspend_state_t pm_state;
  +
  +void set_pm_suspend_state(suspend_state_t state) {
  +   pm_state = state;
  +}
  +
  +suspend_state_t pm_suspend_state(void) {
  +   return pm_state;
  +}
 
 These need to be namespaced to indicate that they apply only to mpc85xx.
 Where do you plan on using these from, that mpc85xx can be safely assumed?
 

Mpic timer and PCIe driver.

 This seems like a feature that should be implemented in generic code instead.
 

OK, I will move this to a generic path.

Regards,
-Dongsheng

 -Scott
 

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

Re: [PATCH v2 1/2] ASoC: fsl_sai: Add clock controls for SAI

2014-04-14 Thread Nicolin Chen
On Mon, Apr 14, 2014 at 09:43:31PM +0100, Mark Brown wrote:
 On Wed, Apr 02, 2014 at 06:10:19PM +0800, Nicolin Chen wrote:
 
  -- clock-names : Must include the sai entry.
  +- clock-names : Must include the bus for register access and mclk1 
  mclk2
  +  mclk3 for bit clock and frame clock providing.
 
 This breaks compatibilty with old DTs - it just removes the sai name.
 It's OK to deprecate the sai clock name but you need to keep support
 for DTs that only specify that, there's no code for that left in the
 driver.

Sir, you've already applied the v6 of this patch last week :)
And I can still find it in topic/fsl-sai.

ca3e35c ASoC: fsl_sai: Add clock controls for SAI

And regarding the old DTs compatibilty, Shawn has already reminded me
in his comments against one of the version. I took his advice and made
the patch compatible with the old 'sai' clock binding within that v6.

Thank you,
Nicolin

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

Re: [PATCH v2 2/2] ARM: dts: Append clock bindings for sai2 on VF610 platform

2014-04-14 Thread Nicolin Chen
On Mon, Apr 14, 2014 at 09:38:51PM +0100, Mark Brown wrote:
 On Wed, Apr 02, 2014 at 06:10:20PM +0800, Nicolin Chen wrote:
  Since we added fours clock to the DT binding, we should update the current
  SAI dts/dtsi so as not to break their functions.
 
 This doesn't apply against v3.15-rc1, can you please check and resend?

Please disregard this patch, since my v6 patch was compatible with the old
binding, the patch here is provisionally useless and I can later send it
via Shawn's tree.

Thank you,
Nicolin

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

Re: [PATCH] ASoC: fsl_sai: Fix incorrect condition check in trigger()

2014-04-14 Thread Nicolin Chen
On Mon, Apr 14, 2014 at 09:31:26PM +0100, Mark Brown wrote:
 On Fri, Apr 11, 2014 at 10:10:00PM +0800, Nicolin Chen wrote:
 
  +   /* Check if the opposite FRDE is also disabled */
  +   if (!(tx ? rcsr  FSL_SAI_CSR_FRDE : tcsr  FSL_SAI_CSR_FRDE)) {
 
 I've applied this since it's a fix but this is *not* a triumph of
 legibility, the ternery operator is often not helpful.

It looks like I've got a bad habit again. I'll be careful next time.

Thank you for reminding me,
Nicolin

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

RE: [PATCH v3] dmaengine: driver support for FSL RaidEngine device.

2014-04-14 Thread Xuelin Shi
Yes, depend on !ASYNC_TX_CHANNEL_SWITCH is better since fsldma selects this 
condition.

Thanks,
Xuelin Shi

-Original Message-
From: Dan Williams [mailto:dan.j.willi...@intel.com] 
Sent: 2014年4月15日 8:30
To: Shi Xuelin-B29237
Cc: Koul, Vinod; andriy.shevche...@intel.com; dmaeng...@vger.kernel.org; 
linuxppc-dev; Rai Harninder-B01044; Burmi Naveen-B16502
Subject: Re: [PATCH v3] dmaengine: driver support for FSL RaidEngine device.

On Sun, Apr 13, 2014 at 7:48 PM, Xuelin Shi xuelin@freescale.com wrote:
 Hi Dan,

 fsl dma device and fsl raid device are two differenct devices that 
 both provide async_memcpy capability, so I use !FSL_DMA to disable the fsl 
 dma device.

 That's to say, either select fsldma device, either fsl raid device.


Right, but that's not what your proposed Kconfig dependency line does.

You want something like depends on FSL_SOC  !(FSL_DMA || FSL_DMA=m)

However, the more problematic option is ASYNC_TX_CHANNEL_SWITCH.  That option 
is problematic for RAID, so I propose depend on !ASYNC_TX_CHANNEL_SWITCH 
since that addresses both problems.


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

RE: [PATCH 2/2] fsl/mpic_timer: make mpic_timer to support deep sleep feature

2014-04-14 Thread dongsheng.w...@freescale.com


 -Original Message-
 From: Wood Scott-B07421
 Sent: Tuesday, April 15, 2014 7:36 AM
 To: Wang Dongsheng-B40534
 Cc: Jin Zhengxiong-R64188; Li Yang-Leo-R58472; Zhao Chenhui-B35336; linuxppc-
 d...@lists.ozlabs.org
 Subject: Re: [PATCH 2/2] fsl/mpic_timer: make mpic_timer to support deep sleep
 feature
 
 On Mon, 2014-04-14 at 10:24 +0800, Dongsheng Wang wrote:
  From: Wang Dongsheng dongsheng.w...@freescale.com
 
  At T104x platfrom the timer clock will be changed when system going to
  deep sleep.
 
 Could you elaborate on what is changing and why?
 

Okay.

  +#include asm/mpc85xx.h
   #include asm/mpic_timer.h
 
 So much for, The driver currently is only tested on fsl chip, but it can
 potentially support other global timers complying to OpenPIC standard.
 
   #define FSL_GLOBAL_TIMER   0x1
  @@ -71,8 +74,10 @@ struct timer_group_priv {
  struct timer_regs __iomem   *regs;
  struct mpic_timer   timer[TIMERS_PER_GROUP];
  struct list_headnode;
  +   unsigned long   idle;
  unsigned inttimerfreq;
  -   unsigned intidle;
 
 Why?
 

Um... It shouldn't be happened...i will remove this.

  +   unsigned intsuspended_timerfreq;
  +   unsigned intresume_timerfreq;
  unsigned intflags;
  spinlock_t  lock;
  void __iomem*group_tcr;
  @@ -88,6 +93,7 @@ static struct cascade_priv cascade_timer[] = {  };
 
   static LIST_HEAD(timer_group_list);
  +static int switch_freq_flag;
 
 Needs documentation, and based on _flag it should probably be a bool.
 

Okay.

   static void convert_ticks_to_time(struct timer_group_priv *priv,
  const u64 ticks, struct timeval *time) @@ -423,6 +429,33 @@ 
  struct
  mpic_timer *mpic_request_timer(irq_handler_t fn, void *dev,  }
  EXPORT_SYMBOL(mpic_request_timer);
 
  +static void timer_group_get_suspended_freq(struct timer_group_priv
  +*priv) {
  +   struct device_node *np;
  +
  +   np = of_find_compatible_node(NULL, NULL, fsl,qoriq-clockgen-2.0);
  +   if (!np) {
  +   pr_err(mpic timer: Missing clockgen device node.\n);
 
 Why is it an error to not have a 2.0 QorIQ clockgen?
 

This will affect the accuracy of the timer. But not means the timer cannot work.
Maybe you are right, this pr_err should be a pr_warn.

  +   return;
  +   }
  +
  +   of_property_read_u32(np, clock-frequency, priv-suspended_timerfreq);
  +   of_node_put(np);
 
 Shouldn't this go through the clock API?
 

Sorry, I'm not clear about clock API, you mean fsl_get_sys_freq()? Or ?

The timer operates on sys_ref_clk frequency during deep sleep. And The timer 
runs on
platform clock/2 during normal operation.

fsl_get_sys_freq() can get platform clock, but cannot get sys_ref_clk.

  +}
  +
  +static int need_to_switch_freq(void)
  +{
  +   u32 svr;
  +
  +   svr = mfspr(SPRN_SVR);
  +   if (SVR_SOC_VER(svr) == SVR_T1040 ||
  +   SVR_SOC_VER(svr) == SVR_T1042)
  +   return 1;
 
 Explain why this is specific to T104x.
 

Mpic timer freq will be change when system going to deep sleep. So we need to 
recalculate the time.

 -Scott
 

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

[PATCH v2 2/2] fsl/corenet_generic: add t104x platform diu special initialization

2014-04-14 Thread Dongsheng Wang
From: Wang Dongsheng dongsheng.w...@freescale.com

T104x Platforms based on corenet_generic. The platforms DIU-block
that need a special initialization to solve some callback functions,
those functions depend on platform handle.

Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
---
This patch is *depends on* Prabhakar Kushwaha support T104x patchset.

v2: No change.
diff --git a/arch/powerpc/platforms/85xx/fix/Makefile 
b/arch/powerpc/platforms/85xx/fix/Makefile
index a8e8154..0530acd 100644
--- a/arch/powerpc/platforms/85xx/fix/Makefile
+++ b/arch/powerpc/platforms/85xx/fix/Makefile
@@ -1 +1,3 @@
 obj-y += fix.o
+
+obj-y += t104x_diu.o
diff --git a/arch/powerpc/platforms/85xx/fix/fix.c 
b/arch/powerpc/platforms/85xx/fix/fix.c
index 7b59a52..c278eb1 100644
--- a/arch/powerpc/platforms/85xx/fix/fix.c
+++ b/arch/powerpc/platforms/85xx/fix/fix.c
@@ -21,6 +21,19 @@
 
 static int fix_platform_init(void)
 {
+   u32 svr;
+
+   svr = SVR_SOC_VER(mfspr(SPRN_SVR));
+
+   switch (svr) {
+   case SVR_T1040:
+   case SVR_T1042:
+   fix_t104x_diu_init();
+   break;
+   default:
+   pr_info(Platform is not need to fix anything\n);
+   }
+
return 0;
 }
 early_initcall(fix_platform_init);
diff --git a/arch/powerpc/platforms/85xx/fix/fix.h 
b/arch/powerpc/platforms/85xx/fix/fix.h
index 5a8c80e3..d27635f 100644
--- a/arch/powerpc/platforms/85xx/fix/fix.h
+++ b/arch/powerpc/platforms/85xx/fix/fix.h
@@ -1,4 +1,6 @@
 #ifndef __CORENET_GENERIC_FIX_H__
 #define __CORENET_GENERIC_FIX_H__
 
+extern void fix_t104x_diu_init(void);
+
 #endif
diff --git a/arch/powerpc/platforms/85xx/fix/t104x_diu.c 
b/arch/powerpc/platforms/85xx/fix/t104x_diu.c
new file mode 100644
index 000..39c7242
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/fix/t104x_diu.c
@@ -0,0 +1,155 @@
+/*
+ * T104x RDB Particular Setup
+ * Should apply for RDB platform of T1040 and it's personalities.
+ * viz T1040/T1042
+ *
+ * Copyright 2014 Freescale Semiconductor Inc.
+ *
+ * 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 linux/kernel.h
+#include linux/of.h
+#include linux/of_address.h
+
+#include asm/io.h
+#include sysdev/fsl_soc.h
+
+#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
+/*DIU Pixel ClockCR offset in scfg*/
+#define CCSR_SCFG_PIXCLKCR  0x28
+
+/* DIU Pixel Clock bits of the PIXCLKCR */
+#define PIXCLKCR_PXCKEN0x8000
+#define PIXCLKCR_PXCKINV   0x4000
+#define PIXCLKCR_PXCKDLY   0xFF00
+#define PIXCLKCR_PXCLK_MASK0x00FF
+
+/* Some CPLD register definitions */
+#define CPLD_DIUCSR0x16
+#define CPLD_DIUCSR_DVIEN  0x80
+#define CPLD_DIUCSR_BACKLIGHT  0x0f
+
+/**
+ * t104xrdb_set_monitor_port: switch the output to a different monitor port
+ */
+static void t104xrdb_set_monitor_port(enum fsl_diu_monitor_port port)
+{
+   struct device_node *cpld_node;
+   static void __iomem *cpld_base;
+
+   cpld_node = of_find_compatible_node(NULL, NULL, fsl,t104xrdb-cpld);
+   if (!cpld_node) {
+   pr_err(T104xRDB: missing CPLD node\n);
+   return;
+   }
+
+   cpld_base = of_iomap(cpld_node, 0);
+   if (!cpld_base) {
+   pr_err(T104xRDB: could not map cpld registers\n);
+   goto exit;
+   }
+
+   switch (port) {
+   case FSL_DIU_PORT_DVI:
+   /* Enable the DVI(HDMI) port, disable the DFP and
+* the backlight
+*/
+   clrbits8(cpld_base + CPLD_DIUCSR, CPLD_DIUCSR_DVIEN);
+   break;
+   case FSL_DIU_PORT_LVDS:
+   /*
+* LVDS also needs backlight enabled, otherwise the display
+* will be blank.
+*/
+   /* Enable the DFP port, disable the DVI*/
+   setbits8(cpld_base + CPLD_DIUCSR, 0x01  8);
+   setbits8(cpld_base + CPLD_DIUCSR, 0x01  4);
+   setbits8(cpld_base + CPLD_DIUCSR, CPLD_DIUCSR_BACKLIGHT);
+   break;
+   default:
+   pr_err(T104xRDB: unsupported monitor port %i\n, port);
+   }
+
+exit:
+   of_node_put(cpld_node);
+}
+
+/**
+ * t104xrdb_set_pixel_clock: program the DIU's clock
+ *
+ * @pixclock: the wavelength, in picoseconds, of the clock
+ */
+static void t104xrdb_set_pixel_clock(unsigned int pixclock)
+{
+   struct device_node *scfg_np = NULL;
+   void __iomem *scfg;
+   unsigned long freq;
+   u64 temp;
+   u32 pxclk;
+
+   /* Map the global utilities registers. */
+   scfg_np = of_find_compatible_node(NULL, NULL, fsl,t1040-scfg);
+   if (!scfg_np) {
+   freq = temp;
+   pr_err(T104xRDB: missing supplemental configuration unit 

[PATCH v2 1/2] fsl/corenet_generic: add a particular initialization for platform

2014-04-14 Thread Dongsheng Wang
From: Wang Dongsheng dongsheng.w...@freescale.com

Corenet_generic is a generic platform initialization. Those based on
the corenet_generic board maybe need a particular initialize to
enable/set some IP-Blocks. So add Fix Generic Initialization to solve
this kind of special cases.

Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
---
*v2*
 1/ Split DIU code.
 2/ make fix.c as a independent driver.
diff --git a/arch/powerpc/platforms/85xx/Kconfig 
b/arch/powerpc/platforms/85xx/Kconfig
index c17aae8..fce2341 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -269,6 +269,17 @@ config CORENET_GENERIC
  The following boards are supported for both 32bit and 64bit kernel:
P5020 DS and P5040 DS
 
+config FIX_GENERIC_PLATFORM_INIT
+   bool Fix Generic Initialization
+   depends on CORENET_GENERIC
+   default y
+   help
+ This option will create a initialization that is a append 
initialization
+ for a particular platfrom. And this particular platform also based on
+ Freescale CoreNet Generic.
+
+ e.g. DIU need a special initialization at T104x platform.
+
 endif # FSL_SOC_BOOKE
 
 config TQM85xx
diff --git a/arch/powerpc/platforms/85xx/Makefile 
b/arch/powerpc/platforms/85xx/Makefile
index 25cebe7..1162ac7 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_P1022_RDK)   += p1022_rdk.o
 obj-$(CONFIG_P1023_RDS)   += p1023_rds.o
 obj-$(CONFIG_TWR_P102x)   += twr_p102x.o
 obj-$(CONFIG_CORENET_GENERIC)   += corenet_generic.o
+obj-$(CONFIG_FIX_GENERIC_PLATFORM_INIT) += fix/
 obj-$(CONFIG_STX_GP3)+= stx_gp3.o
 obj-$(CONFIG_TQM85xx)+= tqm85xx.o
 obj-$(CONFIG_SBC8548) += sbc8548.o
diff --git a/arch/powerpc/platforms/85xx/fix/Makefile 
b/arch/powerpc/platforms/85xx/fix/Makefile
new file mode 100644
index 000..a8e8154
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/fix/Makefile
@@ -0,0 +1 @@
+obj-y += fix.o
diff --git a/arch/powerpc/platforms/85xx/fix/fix.c 
b/arch/powerpc/platforms/85xx/fix/fix.c
new file mode 100644
index 000..7b59a52
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/fix/fix.c
@@ -0,0 +1,26 @@
+/*
+ * Fix Different Boards Particular Initialization
+ *
+ * Author: Wang Dongsheng dongsheng.w...@freescale.com
+ *
+ * Copyright 2014 Freescale Semiconductor Inc.
+ *
+ * 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 linux/kernel.h
+
+#include asm/mpc85xx.h
+#include asm/reg.h
+#include asm/reg_booke.h
+
+#include fix.h
+
+static int fix_platform_init(void)
+{
+   return 0;
+}
+early_initcall(fix_platform_init);
diff --git a/arch/powerpc/platforms/85xx/fix/fix.h 
b/arch/powerpc/platforms/85xx/fix/fix.h
new file mode 100644
index 000..5a8c80e3
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/fix/fix.h
@@ -0,0 +1,4 @@
+#ifndef __CORENET_GENERIC_FIX_H__
+#define __CORENET_GENERIC_FIX_H__
+
+#endif
-- 
1.8.5


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