[PATCH] cpuidle: fix unremovable issue for module driver

2013-07-30 Thread Dongsheng Wang
From: Wang Dongsheng dongsheng.w...@freescale.com

After __cpuidle_register_device, the cpu incs are added up, but decs
are not, thus the module refcount is not match. So the module exit
function can not be executed when we do remove operation. Move
module_put into __cpuidle_register_device to fix it.

Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index d75040d..e964ada 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -351,11 +351,8 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device);
 
 static void __cpuidle_unregister_device(struct cpuidle_device *dev)
 {
-   struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
-
list_del(dev-device_list);
per_cpu(cpuidle_devices, dev-cpu) = NULL;
-   module_put(drv-owner);
 }
 
 static int __cpuidle_device_init(struct cpuidle_device *dev)
@@ -384,6 +381,8 @@ static int __cpuidle_register_device(struct cpuidle_device 
*dev)
per_cpu(cpuidle_devices, dev-cpu) = dev;
list_add(dev-device_list, cpuidle_detected_devices);
 
+   module_put(drv-owner);
+
ret = cpuidle_coupled_register_device(dev);
if (ret) {
__cpuidle_unregister_device(dev);
-- 
1.8.0


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


[PATCH] cpuidle: add freescale e500 family porcessors idle support

2013-07-30 Thread Dongsheng Wang
From: Wang Dongsheng dongsheng.w...@freescale.com

Add cpuidle support for e500 family, using cpuidle framework to
manage various low power modes. The new implementation will remain
compatible with original idle method.

Initially, this supports PW10, and subsequent patches will support
PW20/DOZE/NAP.

Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
---
This patch keep using cpuidle_register_device(), because we need to support cpu
hotplug. I will fix device issue in this driver, after
Deepthi Dharwar deep...@linux.vnet.ibm.com add a hotplug handler into cpuidle
freamwork.

diff --git a/arch/powerpc/include/asm/machdep.h 
b/arch/powerpc/include/asm/machdep.h
index 8b48090..cbdbe25 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -271,6 +271,16 @@ extern void power7_idle(void);
 extern void ppc6xx_idle(void);
 extern void book3e_idle(void);
 
+/* Wait for Interrupt */
+static inline void fsl_cpuidle_wait(void)
+{
+#ifdef CONFIG_PPC64
+   book3e_idle();
+#else
+   e500_idle();
+#endif
+}
+
 /*
  * ppc_md contains a copy of the machine description structure for the
  * current platform. machine_id contains the initial address where the
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index b3fb81d..7ed114b 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -35,6 +35,11 @@ depends on ARM
 source drivers/cpuidle/Kconfig.arm
 endmenu
 
+menu PowerPC CPU Idle Drivers
+depends on PPC32 || PPC64
+source drivers/cpuidle/Kconfig.powerpc
+endmenu
+
 endif
 
 config ARCH_NEEDS_CPU_IDLE_COUPLED
diff --git a/drivers/cpuidle/Kconfig.powerpc b/drivers/cpuidle/Kconfig.powerpc
new file mode 100644
index 000..9f3f5ef
--- /dev/null
+++ b/drivers/cpuidle/Kconfig.powerpc
@@ -0,0 +1,9 @@
+#
+# PowerPC CPU Idle drivers
+#
+
+config PPC_E500_CPUIDLE
+   bool CPU Idle Driver for E500 family processors
+   depends on FSL_SOC_BOOKE
+   help
+ Select this to enable cpuidle on e500 family processors.
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index 0b9d200..0dde3db 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -11,3 +11,7 @@ obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE)+= cpuidle-calxeda.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE) += cpuidle-kirkwood.o
 obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o
 obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o
+
+##
+# PowerPC platform drivers
+obj-$(CONFIG_PPC_E500_CPUIDLE) += cpuidle-e500.o
diff --git a/drivers/cpuidle/cpuidle-e500.c b/drivers/cpuidle/cpuidle-e500.c
new file mode 100644
index 000..1919cea
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-e500.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * CPU Idle driver for Freescale PowerPC e500 family processors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Author: Wang Dongsheng dongsheng.w...@freescale.com
+ */
+
+#include linux/cpu.h
+#include linux/cpuidle.h
+#include linux/init.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/notifier.h
+
+#include asm/machdep.h
+
+static struct cpuidle_driver e500_idle_driver = {
+   .name = e500_idle,
+   .owner = THIS_MODULE,
+};
+
+static struct cpuidle_device __percpu *e500_cpuidle_devices;
+
+static void e500_cpuidle(void)
+{
+   /*
+* This would call on the cpuidle framework, and the back-end
+* driver to go to idle states.
+*/
+   if (cpuidle_idle_call()) {
+   /*
+* On error, execute default handler
+* to go into low thread priority and possibly
+* low power mode.
+*/
+   HMT_low();
+   HMT_very_low();
+   }
+}
+
+static int pw10_enter(struct cpuidle_device *dev,
+   struct cpuidle_driver *drv, int index)
+{
+   fsl_cpuidle_wait();
+   return index;
+}
+
+static struct cpuidle_state fsl_pw_idle_states[] = {
+   {
+   .name = pw10,
+   .desc = pw10,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .exit_latency = 0,
+   .target_residency = 0,
+   .enter = pw10_enter
+   },
+};
+
+static int cpu_hotplug_notify(struct notifier_block *n,
+   unsigned long action, void *hcpu)
+{
+   unsigned long hotcpu = (unsigned long)hcpu;
+   struct cpuidle_device *dev =
+   per_cpu_ptr(e500_cpuidle_devices, hotcpu);
+
+   if (dev  cpuidle_get_driver()) {
+   switch (action) {
+   case CPU_ONLINE:
+   case CPU_ONLINE_FROZEN:
+   cpuidle_pause_and_lock();
+   

Re: Build regressions/improvements in v3.11-rc3

2013-07-30 Thread Geert Uytterhoeven
On Tue, 30 Jul 2013, Geert Uytterhoeven wrote:
 JFYI, when comparing v3.11-rc3 to v3.11-rc2[3], the summaries are:
   - build errors: +38/-14

  + arch/powerpc/kvm/book3s_emulate.c: error: 'bat' may be used uninitialized 
in this function [-Werror=uninitialized]:  = 349:2
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_ANDCOND' undeclared (first use 
in this function):  = 161:17, 86:16
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_AVPN' undeclared (first use in 
this function):  = 160:17, 85:16, 192:16
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_BULK_REMOVE' undeclared (first 
use in this function):  = 246:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_CEDE' undeclared (first use in 
this function):  = 250:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_CPPR' undeclared (first use in 
this function):  = 257:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_ENTER' undeclared (first use 
in this function):  = 240:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_EOI' undeclared (first use in 
this function):  = 258:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_EXACT' undeclared (first use 
in this function):  = 50:6
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_IPI' undeclared (first use in 
this function):  = 259:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_IPOLL' undeclared (first use 
in this function):  = 260:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_NOT_FOUND' undeclared (first 
use in this function):  = 193:27, 87:27
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_PARAMETER' undeclared (first 
use in this function):  = 138:10
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_PROTECT' undeclared (first use 
in this function):  = 244:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_PTEG_FULL' undeclared (first 
use in this function):  = 54:12
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_PUT_TCE' undeclared (first use 
in this function):  = 248:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_REMOVE' undeclared (first use 
in this function):  = 242:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_RTAS' undeclared (first use in 
this function):  = 265:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_SUCCESS' undeclared (first use 
in this function):  = 67:26, 96:26, 211:26, 125:12
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_TOO_HARD' undeclared (first 
use in this function):  = 224:12
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_XIRR' undeclared (first use in 
this function):  = 256:7
  + arch/powerpc/kvm/book3s_pr_papr.c: error: 'H_XIRR_X' undeclared (first use 
in this function):  = 261:7
  + arch/powerpc/platforms/pseries/hotplug-memory.c: error: 'SECTION_SIZE_BITS' 
undeclared (first use in this function):  = 24:31
  + mm/memory_hotplug.c: error: 'PAGES_PER_SECTION' undeclared (first use in 
this function):  = 1630:46
  + mm/memory_hotplug.c: error: implicit declaration of function 
'__nr_to_section' [-Werror=implicit-function-declaration]:  = 1635:3
  + mm/memory_hotplug.c: error: implicit declaration of function 
'find_memory_block_hinted' [-Werror=implicit-function-declaration]:  = 1642:3
  + mm/memory_hotplug.c: error: implicit declaration of function 
'pfn_to_section_nr' [-Werror=implicit-function-declaration]:  = 1631:3
  + mm/memory_hotplug.c: error: implicit declaration of function 
'present_section_nr' [-Werror=implicit-function-declaration]:  = 1632:3

powerpc-randconfig

  + drivers/md/dm-cache-policy-mq.c: error: conflicting types for 
'remove_mapping':  = 962:13

sparc-allmodconfig, not a regression (was hidden due to a sparc64/sparc32
mixup on kissb), patch submitted

  + error: usb_add_gadget_udc [drivers/usb/chipidea/ci_hdrc.ko] undefined!:  
= N/A
  + error: usb_del_gadget_udc [drivers/usb/chipidea/ci_hdrc.ko] undefined!:  
= N/A
  + error: usb_gadget_map_request [drivers/usb/chipidea/ci_hdrc.ko] 
undefined!:  = N/A
  + error: usb_gadget_unmap_request [drivers/usb/chipidea/ci_hdrc.ko] 
undefined!:  = N/A

x86_64-randconfig

 [1] http://kisskb.ellerman.id.au/kisskb/head/6490/ (all 120 configs)
 [3] http://kisskb.ellerman.id.au/kisskb/head/6461/ (all 120 configs)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] cpuidle: fix unremovable issue for module driver

2013-07-30 Thread Daniel Lezcano
On 07/30/2013 08:55 AM, Dongsheng Wang wrote:
 From: Wang Dongsheng dongsheng.w...@freescale.com
 
 After __cpuidle_register_device, the cpu incs are added up, but decs
 are not, thus the module refcount is not match. So the module exit
 function can not be executed when we do remove operation. Move
 module_put into __cpuidle_register_device to fix it.

Sorry, I still don't get it :/

register-module_get
unregister-module_put

you change it by:

register-module_get
register-module_put
unregister-none

which is wrong.

Can you describe the problem you are facing ? (a bit more than I can't
unload the module).

 Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
 
 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
 index d75040d..e964ada 100644
 --- a/drivers/cpuidle/cpuidle.c
 +++ b/drivers/cpuidle/cpuidle.c
 @@ -351,11 +351,8 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device);
  
  static void __cpuidle_unregister_device(struct cpuidle_device *dev)
  {
 - struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
 -
   list_del(dev-device_list);
   per_cpu(cpuidle_devices, dev-cpu) = NULL;
 - module_put(drv-owner);
  }
  
  static int __cpuidle_device_init(struct cpuidle_device *dev)
 @@ -384,6 +381,8 @@ static int __cpuidle_register_device(struct 
 cpuidle_device *dev)
   per_cpu(cpuidle_devices, dev-cpu) = dev;
   list_add(dev-device_list, cpuidle_detected_devices);
  
 + module_put(drv-owner);
 +
   ret = cpuidle_coupled_register_device(dev);
   if (ret) {
   __cpuidle_unregister_device(dev);
 


-- 
 http://www.linaro.org/ Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  http://www.facebook.com/pages/Linaro Facebook |
http://twitter.com/#!/linaroorg Twitter |
http://www.linaro.org/linaro-blog/ Blog

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

[PATCH v3 1/3] powerpc/85xx: Add SEC6.0 device tree

2013-07-30 Thread Po Liu
From: Mingkai Hu mingkai...@freescale.com

Add device tree for SEC 6.0 used on C29x silicon.

Signed-off-by: Mingkai Hu mingkai...@freescale.com
Signed-off-by: Po Liu po@freescale.com
---
Changes for v2:
- Remove the compatible sec v4.0/v4.4/v5.0;
- Add the device tree binding file fsl-sec6.txt;
Changes for v3:
- Change some comments in fsl-sec6.txt

 .../devicetree/bindings/crypto/fsl-sec6.txt| 155 +
 arch/powerpc/boot/dts/fsl/qoriq-sec6.0-0.dtsi  |  56 
 2 files changed, 211 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/fsl-sec6.txt
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-sec6.0-0.dtsi

diff --git a/Documentation/devicetree/bindings/crypto/fsl-sec6.txt 
b/Documentation/devicetree/bindings/crypto/fsl-sec6.txt
new file mode 100644
index 000..a2a78e3
--- /dev/null
+++ b/Documentation/devicetree/bindings/crypto/fsl-sec6.txt
@@ -0,0 +1,155 @@
+SEC 6 is as Freescale's Cryptographic Accelerator and Assurance Module (CAAM).
+Currently Freescale powerpc chip C29X is embeded with SEC 6.
+SEC 6 device tree binding include:
+   -SEC 6 Node
+   -Job Ring Node
+   -Full Example
+
+=
+SEC 6 Node
+
+Description
+
+Node defines the base address of the SEC 6 block.
+This block specifies the address range of all global
+configuration registers for the SEC 6 block.
+For example, In C293, we could see three SEC 6 node.
+
+PROPERTIES
+
+   - compatible
+  Usage: required
+  Value type: string
+  Definition: Must include fsl,sec-v6.0.
+
+   - fsl,sec-era
+  Usage: optional
+  Value type: u32
+  Definition: A standard property. Define the 'ERA' of the SEC
+  device.
+
+   - #address-cells
+   Usage: required
+   Value type: u32
+   Definition: A standard property.  Defines the number of cells
+   for representing physical addresses in child nodes.
+
+   - #size-cells
+   Usage: required
+   Value type: u32
+   Definition: A standard property.  Defines the number of cells
+   for representing the size of physical addresses in
+   child nodes.
+
+   - reg
+  Usage: required
+  Value type: prop-encoded-array
+  Definition: A standard property.  Specifies the physical
+  address and length of the SEC 6 configuration registers.
+
+   - ranges
+   Usage: required
+   Value type: prop-encoded-array
+   Definition: A standard property.  Specifies the physical address
+   range of the SEC 6.0 register space (-SNVS not included).  A
+   triplet that includes the child address, parent address, 
+   length.
+
+   Note: All other standard properties (see the ePAPR) are allowed
+   but are optional.
+
+EXAMPLE
+   crypto@a {
+   compatible = fsl,sec-v6.0;
+   fsl,sec-era = 6;
+   #address-cells = 1;
+   #size-cells = 1;
+   reg = 0xa 0x2;
+   ranges = 0 0xa 0x2;
+   };
+
+=
+Job Ring (JR) Node
+
+Child of the crypto node defines data processing interface to SEC 6
+across the peripheral bus for purposes of processing
+cryptographic descriptors. The specified address
+range can be made visible to one (or more) cores.
+The interrupt defined for this node is controlled within
+the address range of this node.
+
+  - compatible
+  Usage: required
+  Value type: string
+  Definition: Must include fsl,sec-v6.0-job-ring.
+
+  - reg
+  Usage: required
+  Value type: prop-encoded-array
+  Definition: Specifies a two JR parameters:  an offset from
+   the parent physical address and the length the JR registers.
+
+   - interrupts
+  Usage: required
+  Value type: prop_encoded-array
+  Definition:  Specifies the interrupts generated by this
+   device.  The value of the interrupts property
+   consists of one interrupt specifier. The format
+   of the specifier is defined by the binding document
+   describing the node's interrupt parent.
+
+EXAMPLE
+   jr@1000 {
+   compatible = fsl,sec-v6.0-job-ring;
+   reg = 0x1000 0x1000;
+   interrupts = 49 2 0 0;
+   };
+
+===
+Full Example
+
+Since some chips may contain more than one SEC, the dtsi contains
+only the node contents, not the node itself.  A chip using the SEC
+should include the dtsi inside each SEC node.  Example:
+
+In qoriq-sec6.0.dtsi:
+
+   compatible = fsl,sec-v6.0;
+   fsl,sec-era = 6;
+   #address-cells = 1;
+   #size-cells = 1;
+
+   jr@1000 {
+   compatible = fsl,sec-v6.0-job-ring,
+fsl,sec-v5.2-job-ring,
+

[PATCH v3 2/3] powerpc/85xx: Add silicon device tree for C293

2013-07-30 Thread Po Liu
From: Mingkai Hu mingkai...@freescale.com

Signed-off-by: Mingkai Hu mingkai...@freescale.com
Signed-off-by: Po Liu po@freescale.com
---
Changes for v2:
- None
Changes for v3:
- None

 arch/powerpc/boot/dts/fsl/c293si-post.dtsi | 193 +
 arch/powerpc/boot/dts/fsl/c293si-pre.dtsi  |  63 ++
 2 files changed, 256 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/fsl/c293si-post.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/c293si-pre.dtsi

diff --git a/arch/powerpc/boot/dts/fsl/c293si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
new file mode 100644
index 000..bd20832
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
@@ -0,0 +1,193 @@
+/*
+ * C293 Silicon/SoC Device Tree Source (post include)
+ *
+ * Copyright 2012 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.
+ */
+
+ifc {
+   #address-cells = 2;
+   #size-cells = 1;
+   compatible = fsl,ifc, simple-bus;
+   interrupts = 19 2 0 0;
+};
+
+/* controller at 0xa000 */
+pci0 {
+   compatible = fsl,qoriq-pcie-v2.2, fsl,qoriq-pcie;
+   device_type = pci;
+   #size-cells = 2;
+   #address-cells = 3;
+   bus-range = 0 255;
+   clock-frequency = ;
+   interrupts = 16 2 0 0;
+
+   pcie@0 {
+   reg = 0 0 0 0 0;
+   #interrupt-cells = 1;
+   #size-cells = 2;
+   #address-cells = 3;
+   device_type = pci;
+   interrupts = 16 2 0 0;
+   interrupt-map-mask = 0xf800 0 0 7;
+   interrupt-map = 
+   /* IDSEL 0x0 */
+    0x0 0x0 0x1 mpic 0x0 0x1 0x0 0x0
+    0x0 0x0 0x2 mpic 0x1 0x1 0x0 0x0
+    0x0 0x0 0x3 mpic 0x2 0x1 0x0 0x0
+    0x0 0x0 0x4 mpic 0x3 0x1 0x0 0x0
+   ;
+   };
+};
+
+soc {
+   #address-cells = 1;
+   #size-cells = 1;
+   device_type = soc;
+   compatible = simple-bus;
+   bus-frequency = 0;// Filled out by uboot.
+
+   ecm-law@0 {
+   compatible = fsl,ecm-law;
+   reg = 0x0 0x1000;
+   fsl,num-laws = 12;
+   };
+
+   ecm@1000 {
+   compatible = fsl,c293-ecm, fsl,ecm;
+   reg = 0x1000 0x1000;
+   interrupts = 16 2 0 0;
+   };
+
+   memory-controller@2000 {
+   compatible = fsl,c293-memory-controller;
+   reg = 0x2000 0x1000;
+   interrupts = 16 2 0 0;
+   };
+
+/include/ pq3-i2c-0.dtsi
+/include/ pq3-i2c-1.dtsi
+/include/ pq3-duart-0.dtsi
+/include/ pq3-espi-0.dtsi
+   spi0: spi@7000 {
+   fsl,espi-num-chipselects = 1;
+   };
+
+/include/ pq3-gpio-0.dtsi
+   L2: l2-cache-controller@2 {
+   compatible = fsl,c293-l2-cache-controller;
+   reg = 0x2 0x1000;
+   cache-line-size = 32; // 32 bytes
+   cache-size = 0x8; // L2,512K
+   interrupts = 16 2 0 0;
+   };
+
+/include/ pq3-dma-0.dtsi
+/include/ pq3-esdhc-0.dtsi
+   sdhc@2e000 {
+   compatible = fsl,c293-esdhc, fsl,esdhc;
+

[PATCH v3 3/3] powerpc/85xx: Add C293PCIE board support

2013-07-30 Thread Po Liu
From: Mingkai Hu mingkai...@freescale.com

C293PCIE board is a series of Freescale PCIe add-in cards to perform
as public key crypto accelerator or secure key management module.

 - 512KB platform SRAM in addition to 512K L2 Cache/SRAM
 - 512MB soldered DDR3 32bit memory
 - CPLD System Logic
 - 64MB x16 NOR flash and 4GB x8 NAND flash
 - 16MB SPI flash

Signed-off-by: Mingkai Hu mingkai...@freescale.com
Signed-off-by: Po Liu po@freescale.com
---
Changes for v2:
- Remove the JFFS2 partitions in NOR/NAND/SPI flash;
- Implement the NAND partitions;
- Remove the no use descriptions for cpld node;
- Add mpc85xx_smp_defconfig and mpc85xx_defconfig for C293;
- Remove the no use includes in c293pcie.c
Changes for v3:
- Remove some partitions for NAND, merge them into RFS
- Modify the SPI RFS partition expression
- Remove #address-cells #size-cells in cpld node

 arch/powerpc/boot/dts/c293pcie.dts | 223 +
 arch/powerpc/configs/mpc85xx_defconfig |   1 +
 arch/powerpc/configs/mpc85xx_smp_defconfig |   1 +
 arch/powerpc/platforms/85xx/Kconfig|   6 +
 arch/powerpc/platforms/85xx/Makefile   |   1 +
 arch/powerpc/platforms/85xx/c293pcie.c |  75 ++
 6 files changed, 307 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/c293pcie.dts
 create mode 100644 arch/powerpc/platforms/85xx/c293pcie.c

diff --git a/arch/powerpc/boot/dts/c293pcie.dts 
b/arch/powerpc/boot/dts/c293pcie.dts
new file mode 100644
index 000..24a2cdd
--- /dev/null
+++ b/arch/powerpc/boot/dts/c293pcie.dts
@@ -0,0 +1,223 @@
+/*
+ * C293 PCIE Device Tree Source
+ *
+ * Copyright 2013 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/c293si-pre.dtsi
+
+/ {
+   model = fsl,C293PCIE;
+   compatible = fsl,C293PCIE;
+
+   memory {
+   device_type = memory;
+   };
+
+   ifc: ifc@fffe1e000 {
+   reg = 0xf 0xffe1e000 0 0x2000;
+   ranges = 0x0 0x0 0xf 0xec00 0x0400
+ 0x2 0x0 0xf 0xffdf 0x0001;
+
+   };
+
+   soc: soc@fffe0 {
+   ranges = 0x0 0xf 0xffe0 0x10;
+   };
+
+   pci0: pcie@fffe0a000 {
+   reg = 0xf 0xffe0a000 0 0x1000;
+   ranges = 0x200 0x0 0x8000 0xc 0x 0x0 0x2000
+ 0x100 0x0 0x 0xf 0xffc0 0x0 0x1;
+   pcie@0 {
+   ranges = 0x200 0x0 0x8000
+ 0x200 0x0 0x8000
+ 0x0 0x2000
+
+ 0x100 0x0 0x0
+ 0x100 0x0 0x0
+ 0x0 0x10;
+   };
+   };
+};
+
+ifc {
+   nor@0,0 {
+   #address-cells = 1;
+   #size-cells = 1;
+   compatible = cfi-flash;
+   reg = 0x0 0x0 0x400;
+   bank-width = 2;
+   device-width = 1;
+
+   partition@0 {
+   /* 1MB for DTB Image */
+   reg = 0x0 0x0010;
+   label 

Re: [PATCH] cpuidle: add freescale e500 family porcessors idle support

2013-07-30 Thread Daniel Lezcano
On 07/30/2013 09:00 AM, Dongsheng Wang wrote:
 From: Wang Dongsheng dongsheng.w...@freescale.com
 
 Add cpuidle support for e500 family, using cpuidle framework to
 manage various low power modes. The new implementation will remain
 compatible with original idle method.
 
 Initially, this supports PW10, and subsequent patches will support
 PW20/DOZE/NAP.
 
 Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
 ---
 This patch keep using cpuidle_register_device(), because we need to support 
 cpu
 hotplug. I will fix device issue in this driver, after
 Deepthi Dharwar deep...@linux.vnet.ibm.com add a hotplug handler into 
 cpuidle
 freamwork.
 
 diff --git a/arch/powerpc/include/asm/machdep.h 
 b/arch/powerpc/include/asm/machdep.h
 index 8b48090..cbdbe25 100644
 --- a/arch/powerpc/include/asm/machdep.h
 +++ b/arch/powerpc/include/asm/machdep.h
 @@ -271,6 +271,16 @@ extern void power7_idle(void);
  extern void ppc6xx_idle(void);
  extern void book3e_idle(void);
  
 +/* Wait for Interrupt */
 +static inline void fsl_cpuidle_wait(void)
 +{
 +#ifdef CONFIG_PPC64
 + book3e_idle();
 +#else
 + e500_idle();
 +#endif
 +}
 +
  /*
   * ppc_md contains a copy of the machine description structure for the
   * current platform. machine_id contains the initial address where the
 diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
 index b3fb81d..7ed114b 100644
 --- a/drivers/cpuidle/Kconfig
 +++ b/drivers/cpuidle/Kconfig
 @@ -35,6 +35,11 @@ depends on ARM
  source drivers/cpuidle/Kconfig.arm
  endmenu
  
 +menu PowerPC CPU Idle Drivers
 +depends on PPC32 || PPC64
 +source drivers/cpuidle/Kconfig.powerpc
 +endmenu
 +
  endif
  
  config ARCH_NEEDS_CPU_IDLE_COUPLED
 diff --git a/drivers/cpuidle/Kconfig.powerpc b/drivers/cpuidle/Kconfig.powerpc
 new file mode 100644
 index 000..9f3f5ef
 --- /dev/null
 +++ b/drivers/cpuidle/Kconfig.powerpc
 @@ -0,0 +1,9 @@
 +#
 +# PowerPC CPU Idle drivers
 +#
 +
 +config PPC_E500_CPUIDLE
 + bool CPU Idle Driver for E500 family processors
 + depends on FSL_SOC_BOOKE
 + help
 +   Select this to enable cpuidle on e500 family processors.
 diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
 index 0b9d200..0dde3db 100644
 --- a/drivers/cpuidle/Makefile
 +++ b/drivers/cpuidle/Makefile
 @@ -11,3 +11,7 @@ obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE)  += cpuidle-calxeda.o
  obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE)   += cpuidle-kirkwood.o
  obj-$(CONFIG_ARM_ZYNQ_CPUIDLE)   += cpuidle-zynq.o
  obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o
 +
 +##
 +# PowerPC platform drivers
 +obj-$(CONFIG_PPC_E500_CPUIDLE)   += cpuidle-e500.o
 diff --git a/drivers/cpuidle/cpuidle-e500.c b/drivers/cpuidle/cpuidle-e500.c
 new file mode 100644
 index 000..1919cea
 --- /dev/null
 +++ b/drivers/cpuidle/cpuidle-e500.c
 @@ -0,0 +1,222 @@
 +/*
 + * Copyright 2013 Freescale Semiconductor, Inc.
 + *
 + * CPU Idle driver for Freescale PowerPC e500 family processors.
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + *
 + * Author: Wang Dongsheng dongsheng.w...@freescale.com
 + */
 +
 +#include linux/cpu.h
 +#include linux/cpuidle.h
 +#include linux/init.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/notifier.h
 +
 +#include asm/machdep.h
 +
 +static struct cpuidle_driver e500_idle_driver = {
 + .name = e500_idle,
 + .owner = THIS_MODULE,
 +};
 +
 +static struct cpuidle_device __percpu *e500_cpuidle_devices;
 +
 +static void e500_cpuidle(void)
 +{
 + /*
 +  * This would call on the cpuidle framework, and the back-end
 +  * driver to go to idle states.
 +  */
 + if (cpuidle_idle_call()) {
 + /*
 +  * On error, execute default handler
 +  * to go into low thread priority and possibly
 +  * low power mode.
 +  */
 + HMT_low();
 + HMT_very_low();
 + }
 +}

Nope, this is not the place to add such function.

 +static int pw10_enter(struct cpuidle_device *dev,
 + struct cpuidle_driver *drv, int index)
 +{
 + fsl_cpuidle_wait();
 + return index;
 +}
 +
 +static struct cpuidle_state fsl_pw_idle_states[] = {
 + {
 + .name = pw10,
 + .desc = pw10,
 + .flags = CPUIDLE_FLAG_TIME_VALID,
 + .exit_latency = 0,
 + .target_residency = 0,
 + .enter = pw10_enter
 + },
 +};
 +
 +static int cpu_hotplug_notify(struct notifier_block *n,
 + unsigned long action, void *hcpu)
 +{
 + unsigned long hotcpu = (unsigned long)hcpu;
 + struct cpuidle_device *dev =
 + per_cpu_ptr(e500_cpuidle_devices, hotcpu);
 +
 + if (dev  cpuidle_get_driver()) {
 + 

Re: powerpc/85xx: Add P1023RDB board support

2013-07-30 Thread Chunhe Lan


On 07/30/2013 09:09 AM, Scott Wood wrote:

On Fri, Jun 14, 2013 at 04:26:20PM +0800, Chunhe Lan wrote:

Ethernet:
eTSEC1: Connected to Atheros AR8035 GETH PHY
eTSEC2: Connected to Atheros AR8035 GETH PHY

Where are the PHYs in the device tree?
Atheros AR8035 GETH PHY driver is module_init driver. It uses the 
two structs of static struct phy_driver at8035_driver and
static struct mdio_device_id __maybe_unused atheros_tbl to 
register at8035_driver.


So do not need to add PHYs in the device tree.

Thanks,
-Chunhe



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


RE: [PATCH] cpuidle: fix unremovable issue for module driver

2013-07-30 Thread Wang Dongsheng-B40534


 -Original Message-
 From: Daniel Lezcano [mailto:daniel.lezc...@linaro.org]
 Sent: Tuesday, July 30, 2013 5:28 PM
 To: Wang Dongsheng-B40534
 Cc: r...@sisk.pl; linux...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
 Subject: Re: [PATCH] cpuidle: fix unremovable issue for module driver
 
 On 07/30/2013 08:55 AM, Dongsheng Wang wrote:
  From: Wang Dongsheng dongsheng.w...@freescale.com
 
  After __cpuidle_register_device, the cpu incs are added up, but decs
  are not, thus the module refcount is not match. So the module exit
  function can not be executed when we do remove operation. Move
  module_put into __cpuidle_register_device to fix it.
 
 Sorry, I still don't get it :/
 
 register-module_get
 unregister-module_put
 
 you change it by:
 
 register-module_get
 register-module_put
 unregister-none
 
 which is wrong.
 
module_get-set per cpu incs=1
module_put-set per cpu decs=1

module_refcount- incs - decs;

unregister usually call in module-exit function. 
But if module_refcount is not zero, the module-exit() cannot be executed.

See, kernel/module.c +874
delete_module()--try_stop_module();

Test Log:
root:~# rmmod cpuidle-e500
module_refcount: incs[9], decs[1]
rmmod: can't unload 'cpuidle_e500': Resource temporarily unavailable

 Can you describe the problem you are facing ? (a bit more than I can't
 unload the module).
 
  Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
 
  diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
  index d75040d..e964ada 100644
  --- a/drivers/cpuidle/cpuidle.c
  +++ b/drivers/cpuidle/cpuidle.c
  @@ -351,11 +351,8 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device);
 
   static void __cpuidle_unregister_device(struct cpuidle_device *dev)
  {
  -   struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
  -
  list_del(dev-device_list);
  per_cpu(cpuidle_devices, dev-cpu) = NULL;
  -   module_put(drv-owner);
   }
 
   static int __cpuidle_device_init(struct cpuidle_device *dev) @@
  -384,6 +381,8 @@ static int __cpuidle_register_device(struct
 cpuidle_device *dev)
  per_cpu(cpuidle_devices, dev-cpu) = dev;
  list_add(dev-device_list, cpuidle_detected_devices);
 
  +   module_put(drv-owner);
  +
  ret = cpuidle_coupled_register_device(dev);
  if (ret) {
  __cpuidle_unregister_device(dev);
 
 
 
 --
  http://www.linaro.org/ Linaro.org │ Open source software for ARM SoCs
 
 Follow Linaro:  http://www.facebook.com/pages/Linaro Facebook |
 http://twitter.com/#!/linaroorg Twitter |
 http://www.linaro.org/linaro-blog/ Blog
 

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

RE: [PATCH] cpuidle: add freescale e500 family porcessors idle support

2013-07-30 Thread Wang Dongsheng-B40534


 -Original Message-
 From: Daniel Lezcano [mailto:daniel.lezc...@linaro.org]
 Sent: Tuesday, July 30, 2013 5:51 PM
 To: Wang Dongsheng-B40534
 Cc: Wood Scott-B07421; r...@sisk.pl; b...@kernel.crashing.org; Li Yang-
 R58472; Zhao Chenhui-B35336; linux...@vger.kernel.org; linuxppc-
 d...@lists.ozlabs.org
 Subject: Re: [PATCH] cpuidle: add freescale e500 family porcessors idle
 support
 
 On 07/30/2013 09:00 AM, Dongsheng Wang wrote:
  From: Wang Dongsheng dongsheng.w...@freescale.com
 
  Add cpuidle support for e500 family, using cpuidle framework to manage
  various low power modes. The new implementation will remain compatible
  with original idle method.
 
  Initially, this supports PW10, and subsequent patches will support
  PW20/DOZE/NAP.
 
  Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
  ---
  This patch keep using cpuidle_register_device(), because we need to
  support cpu hotplug. I will fix device issue in this driver, after
  Deepthi Dharwar deep...@linux.vnet.ibm.com add a hotplug handler
  into cpuidle freamwork.
 
  diff --git a/arch/powerpc/include/asm/machdep.h
  b/arch/powerpc/include/asm/machdep.h
  index 8b48090..cbdbe25 100644
  --- a/arch/powerpc/include/asm/machdep.h
  +++ b/arch/powerpc/include/asm/machdep.h
  @@ -271,6 +271,16 @@ extern void power7_idle(void);  extern void
  ppc6xx_idle(void);  extern void book3e_idle(void);
 
  +/* Wait for Interrupt */
  +static inline void fsl_cpuidle_wait(void) { #ifdef CONFIG_PPC64
  +   book3e_idle();
  +#else
  +   e500_idle();
  +#endif
  +}
  +
   /*
* ppc_md contains a copy of the machine description structure for the
* current platform. machine_id contains the initial address where the
  diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
  index b3fb81d..7ed114b 100644
  --- a/drivers/cpuidle/Kconfig
  +++ b/drivers/cpuidle/Kconfig
  @@ -35,6 +35,11 @@ depends on ARM
   source drivers/cpuidle/Kconfig.arm
   endmenu
 
  +menu PowerPC CPU Idle Drivers
  +depends on PPC32 || PPC64
  +source drivers/cpuidle/Kconfig.powerpc
  +endmenu
  +
   endif
 
   config ARCH_NEEDS_CPU_IDLE_COUPLED
  diff --git a/drivers/cpuidle/Kconfig.powerpc
 b/drivers/cpuidle/Kconfig.powerpc
  new file mode 100644
  index 000..9f3f5ef
  --- /dev/null
  +++ b/drivers/cpuidle/Kconfig.powerpc
  @@ -0,0 +1,9 @@
  +#
  +# PowerPC CPU Idle drivers
  +#
  +
  +config PPC_E500_CPUIDLE
  +   bool CPU Idle Driver for E500 family processors
  +   depends on FSL_SOC_BOOKE
  +   help
  + Select this to enable cpuidle on e500 family processors.
  diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
  index 0b9d200..0dde3db 100644
  --- a/drivers/cpuidle/Makefile
  +++ b/drivers/cpuidle/Makefile
  @@ -11,3 +11,7 @@ obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE)+= cpuidle-
 calxeda.o
   obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE) += cpuidle-kirkwood.o
   obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o
   obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o
  +
 
 +
 ##
  +# PowerPC platform drivers
  +obj-$(CONFIG_PPC_E500_CPUIDLE) += cpuidle-e500.o
  diff --git a/drivers/cpuidle/cpuidle-e500.c b/drivers/cpuidle/cpuidle-
 e500.c
  new file mode 100644
  index 000..1919cea
  --- /dev/null
  +++ b/drivers/cpuidle/cpuidle-e500.c
  @@ -0,0 +1,222 @@
  +/*
  + * Copyright 2013 Freescale Semiconductor, Inc.
  + *
  + * CPU Idle driver for Freescale PowerPC e500 family processors.
  + *
  + * This program is free software; you can redistribute it and/or
 modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + *
  + * Author: Wang Dongsheng dongsheng.w...@freescale.com
  + */
  +
  +#include linux/cpu.h
  +#include linux/cpuidle.h
  +#include linux/init.h
  +#include linux/kernel.h
  +#include linux/module.h
  +#include linux/notifier.h
  +
  +#include asm/machdep.h
  +
  +static struct cpuidle_driver e500_idle_driver = {
  +   .name = e500_idle,
  +   .owner = THIS_MODULE,
  +};
  +
  +static struct cpuidle_device __percpu *e500_cpuidle_devices;
  +
  +static void e500_cpuidle(void)
  +{
  +   /*
  +* This would call on the cpuidle framework, and the back-end
  +* driver to go to idle states.
  +*/
  +   if (cpuidle_idle_call()) {
  +   /*
  +* On error, execute default handler
  +* to go into low thread priority and possibly
  +* low power mode.
  +*/
  +   HMT_low();
  +   HMT_very_low();
  +   }
  +}
 
 Nope, this is not the place to add such function.
 
Thanks.

But Why not? On powerpc there is already have a cpuidle method. We need to 
compatible them.

Um.. arch/powerpc/platforms/xxx ?

  +static int pw10_enter(struct cpuidle_device *dev,
  +   struct cpuidle_driver *drv, int index)
  +{
  +   fsl_cpuidle_wait();
  +   return index;
  +}
  +
  +static 

Re: [PATCH] cpuidle: fix unremovable issue for module driver

2013-07-30 Thread Daniel Lezcano
On 07/30/2013 12:48 PM, Wang Dongsheng-B40534 wrote:
 
 
 -Original Message-
 From: Daniel Lezcano [mailto:daniel.lezc...@linaro.org]
 Sent: Tuesday, July 30, 2013 5:28 PM
 To: Wang Dongsheng-B40534
 Cc: r...@sisk.pl; linux...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
 Subject: Re: [PATCH] cpuidle: fix unremovable issue for module driver

 On 07/30/2013 08:55 AM, Dongsheng Wang wrote:
 From: Wang Dongsheng dongsheng.w...@freescale.com

 After __cpuidle_register_device, the cpu incs are added up, but decs
 are not, thus the module refcount is not match. So the module exit
 function can not be executed when we do remove operation. Move
 module_put into __cpuidle_register_device to fix it.

 Sorry, I still don't get it :/

 register-module_get
 unregister-module_put

 you change it by:

 register-module_get
 register-module_put
 unregister-none

 which is wrong.

 module_get-set per cpu incs=1
 module_put-set per cpu decs=1
 
 module_refcount- incs - decs;
 
 unregister usually call in module-exit function. 
 But if module_refcount is not zero, the module-exit() cannot be executed.

Ok, IIUC, the refcount is decremented in the unregister function but
this one is never called because the refcount is not zero.

Funny, that means the module format was *never* used at all as it does
not work.

I am wondering if we shouldn't just remove the module support for
cpuidle. Rafael ?

 See, kernel/module.c +874
 delete_module()--try_stop_module();

Thanks, I believe I understand the refcount mechanism.

 Test Log:
 root:~# rmmod cpuidle-e500
 module_refcount: incs[9], decs[1]
 rmmod: can't unload 'cpuidle_e500': Resource temporarily unavailable
 
 Can you describe the problem you are facing ? (a bit more than I can't
 unload the module).

 Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com

 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
 index d75040d..e964ada 100644
 --- a/drivers/cpuidle/cpuidle.c
 +++ b/drivers/cpuidle/cpuidle.c
 @@ -351,11 +351,8 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device);

  static void __cpuidle_unregister_device(struct cpuidle_device *dev)
 {
 -   struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
 -
 list_del(dev-device_list);
 per_cpu(cpuidle_devices, dev-cpu) = NULL;
 -   module_put(drv-owner);
  }

  static int __cpuidle_device_init(struct cpuidle_device *dev) @@
 -384,6 +381,8 @@ static int __cpuidle_register_device(struct
 cpuidle_device *dev)
 per_cpu(cpuidle_devices, dev-cpu) = dev;
 list_add(dev-device_list, cpuidle_detected_devices);

 +   module_put(drv-owner);
 +
 ret = cpuidle_coupled_register_device(dev);
 if (ret) {
 __cpuidle_unregister_device(dev);




-- 
 http://www.linaro.org/ Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  http://www.facebook.com/pages/Linaro Facebook |
http://twitter.com/#!/linaroorg Twitter |
http://www.linaro.org/linaro-blog/ Blog

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

[PATCH v2] powerpc/85xx: Add P1023RDB board support

2013-07-30 Thread Chunhe Lan
P1023RDB Specification:
---
Memory subsystem:
   512MB DDR3 (Fixed DDR on board)
   64MB NOR flash
   128MB NAND flash

Ethernet:
   eTSEC1: Connected to Atheros AR8035 GETH PHY
   eTSEC2: Connected to Atheros AR8035 GETH PHY

PCIe:
   Three mini-PCIe slots

USB:
   Two USB2.0 Type A ports

I2C:
   AT24C08 8K Board EEPROM (8 bit address)

Signed-off-by: Chunhe Lan chunhe@freescale.com
Cc: Scott Wood scottw...@freescale.com
---
 arch/powerpc/boot/dts/p1023rdb.dts   |  237 ++
 arch/powerpc/configs/85xx/p1023_defconfig|  183 
 arch/powerpc/configs/85xx/p1023rds_defconfig |  169 --
 arch/powerpc/platforms/85xx/Kconfig  |4 +-
 arch/powerpc/platforms/85xx/p1023_rds.c  |   24 +++-
 5 files changed, 445 insertions(+), 172 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/p1023rdb.dts
 create mode 100644 arch/powerpc/configs/85xx/p1023_defconfig
 delete mode 100644 arch/powerpc/configs/85xx/p1023rds_defconfig

diff --git a/arch/powerpc/boot/dts/p1023rdb.dts 
b/arch/powerpc/boot/dts/p1023rdb.dts
new file mode 100644
index 000..107c676
--- /dev/null
+++ b/arch/powerpc/boot/dts/p1023rdb.dts
@@ -0,0 +1,237 @@
+/*
+ * P1023 RDB Device Tree Source
+ *
+ *Copyright 2013 Freescale Semiconductor Inc.
+ *
+ * Author: Chunhe Lan chunhe@freescale.com
+ *
+ * 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/p1023si-pre.dtsi
+
+/ {
+   model = fsl,P1023;
+   compatible = fsl,P1023RDB;
+   #address-cells = 2;
+   #size-cells = 2;
+   interrupt-parent = mpic;
+
+   memory {
+   device_type = memory;
+   };
+
+   soc: soc@ff60 {
+   ranges = 0x0 0x0 0xff60 0x20;
+
+   i2c@3000 {
+   eeprom@53 {
+   compatible = at24,24c04;
+   reg = 0x53;
+   };
+
+   rtc@6f {
+   compatible = microchip,mcp7941x;
+   reg = 0x6f;
+   };
+   };
+
+   usb@22000 {
+   dr_mode = host;
+   phy_type = ulpi;
+   };
+   };
+
+   lbc: localbus@ff605000 {
+   reg = 0 0xff605000 0 0x1000;
+
+   /* NOR, NAND Flashes */
+   ranges = 0x0 0x0 0x0 0xec00 0x0400
+ 0x1 0x0 0x0 0xffa0 0x0800;
+
+   nor@0,0 {
+   #address-cells = 1;
+   #size-cells = 1;
+   compatible = cfi-flash;
+   reg = 0x0 0x0 0x0400;
+   bank-width = 2;
+   device-width = 1;
+
+   partition@0 {
+   /* 48MB for JFFS2 based Root file System */
+   reg = 0x 0x0300;
+   label = NOR JFFS2 Root File System;
+   };
+   partition@300 {
+   /* 1MB for DTB Image */
+   reg = 0x0300 0x0010;
+  

[PATCH v3] powerpc: Update compilation flags with core specific options

2013-07-30 Thread Catalin Udma
If CONFIG_E500 is enabled, the compilation flags are updated
specifying the target core -mcpu=e5500/e500mc/8540
Also remove -Wa,-me500, being incompatible with -mcpu=e5500/e6500
The assembler option is redundant if the -mcpu= flag is set.
The patch fixes the kernel compilation problem for e5500/e6500
when using gcc option -mcpu=e5500/e6500.

Signed-off-by: Catalin Udma catalin.u...@freescale.com
---
changes for v2:
- update also KBUILD_AFLAGS with -mcpu and -msoft-float flags
changes for v3:
- add -msoft-float to KBUILD_AFLAGS one time instead of adding it
  for each e500 core.

 arch/powerpc/Makefile |   18 --
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 0624909..1893fb9 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -101,7 +101,7 @@ CFLAGS-$(CONFIG_POWER7_CPU) += $(call 
cc-option,-mcpu=power7)
 CFLAGS-$(CONFIG_TUNE_CELL) += $(call cc-option,-mtune=cell)
 
 KBUILD_CPPFLAGS+= -Iarch/$(ARCH)
-KBUILD_AFLAGS  += -Iarch/$(ARCH)
+KBUILD_AFLAGS  += -msoft-float -Iarch/$(ARCH)
 KBUILD_CFLAGS  += -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y)
 CPP= $(CC) -E $(KBUILD_CFLAGS)
 
@@ -140,6 +140,21 @@ ifeq ($(CONFIG_6xx),y)
 KBUILD_CFLAGS  += -mcpu=powerpc
 endif
 
+ifeq ($(CONFIG_E500),y)
+ifeq ($(CONFIG_64BIT),y)
+KBUILD_CFLAGS  += -mcpu=e5500
+KBUILD_AFLAGS  += -mcpu=e5500
+else
+ifeq ($(CONFIG_PPC_E500MC),y)
+KBUILD_CFLAGS  += -mcpu=e500mc
+KBUILD_AFLAGS  += -mcpu=e500mc
+else
+KBUILD_CFLAGS  += -mcpu=8540
+KBUILD_AFLAGS  += -mcpu=8540
+endif
+endif
+endif
+
 # Work around a gcc code-gen bug with -fno-omit-frame-pointer.
 ifeq ($(CONFIG_FUNCTION_TRACER),y)
 KBUILD_CFLAGS  += -mno-sched-epilog
@@ -147,7 +162,6 @@ endif
 
 cpu-as-$(CONFIG_4xx)   += -Wa,-m405
 cpu-as-$(CONFIG_ALTIVEC)   += -Wa,-maltivec
-cpu-as-$(CONFIG_E500)  += -Wa,-me500
 cpu-as-$(CONFIG_E200)  += -Wa,-me200
 
 KBUILD_AFLAGS += $(cpu-as-y)
-- 
1.7.8


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


Re: [PATCH] cpuidle: fix unremovable issue for module driver

2013-07-30 Thread Rafael J. Wysocki
On Tuesday, July 30, 2013 01:19:46 PM Daniel Lezcano wrote:
 On 07/30/2013 12:48 PM, Wang Dongsheng-B40534 wrote:
  
  
  -Original Message-
  From: Daniel Lezcano [mailto:daniel.lezc...@linaro.org]
  Sent: Tuesday, July 30, 2013 5:28 PM
  To: Wang Dongsheng-B40534
  Cc: r...@sisk.pl; linux...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
  Subject: Re: [PATCH] cpuidle: fix unremovable issue for module driver
 
  On 07/30/2013 08:55 AM, Dongsheng Wang wrote:
  From: Wang Dongsheng dongsheng.w...@freescale.com
 
  After __cpuidle_register_device, the cpu incs are added up, but decs
  are not, thus the module refcount is not match. So the module exit
  function can not be executed when we do remove operation. Move
  module_put into __cpuidle_register_device to fix it.
 
  Sorry, I still don't get it :/
 
  register-module_get
  unregister-module_put
 
  you change it by:
 
  register-module_get
  register-module_put
  unregister-none
 
  which is wrong.
 
  module_get-set per cpu incs=1
  module_put-set per cpu decs=1
  
  module_refcount- incs - decs;
  
  unregister usually call in module-exit function. 
  But if module_refcount is not zero, the module-exit() cannot be executed.
 
 Ok, IIUC, the refcount is decremented in the unregister function but
 this one is never called because the refcount is not zero.
 
 Funny, that means the module format was *never* used at all as it does
 not work.
 
 I am wondering if we shouldn't just remove the module support for
 cpuidle. Rafael ?

That would be the simplest thing to do and possibly the most correct one too,
but I need to double check how inte_idle/ACPI idle interactions depend on that.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: powerpc/85xx: Add P1023RDB board support

2013-07-30 Thread Scott Wood

On 07/30/2013 05:22:11 AM, Chunhe Lan wrote:


On 07/30/2013 09:09 AM, Scott Wood wrote:

On Fri, Jun 14, 2013 at 04:26:20PM +0800, Chunhe Lan wrote:

Ethernet:
eTSEC1: Connected to Atheros AR8035 GETH PHY
eTSEC2: Connected to Atheros AR8035 GETH PHY

Where are the PHYs in the device tree?
Atheros AR8035 GETH PHY driver is module_init driver. It uses  
the two structs of static struct phy_driver at8035_driver and
static struct mdio_device_id __maybe_unused atheros_tbl to  
register at8035_driver.


So do not need to add PHYs in the device tree.


Huh?  How does registering a driver eliminate the need to describe the  
devices in the device tree?  If you're trying to say that the device  
can be probed (like a PCI device), how do you determine which PHY goes  
to which MAC?  I suspect the actual answer is this chip has datapath  
ethernet, and datapath stuff is not upstream (still!).  That's no  
excuse for not describing it in the device tree, though.  The device  
tree describes the hardware, not what Linux has drivers for.


FWIW, I don't see the string at8035_driver anywhere in the kernel  
(except in the SDK, which doesn't count here).  Maybe you meant  
at803x_driver?


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


RE: [PATCH 4/4] kvm: powerpc: set cache coherency only for RAM pages

2013-07-30 Thread Bhushan Bharat-R65777


 -Original Message-
 From: Benjamin Herrenschmidt [mailto:b...@kernel.crashing.org]
 Sent: Saturday, July 27, 2013 3:57 AM
 To: Bhushan Bharat-R65777
 Cc: Alexander Graf; kvm-...@vger.kernel.org; k...@vger.kernel.org; linuxppc-
 d...@lists.ozlabs.org; Wood Scott-B07421
 Subject: Re: [PATCH 4/4] kvm: powerpc: set cache coherency only for RAM pages
 
 On Fri, 2013-07-26 at 15:03 +, Bhushan Bharat-R65777 wrote:
  Will not searching the Linux PTE is a overkill?
 
 That's the best approach. Also we are searching it already to resolve the page
 fault. That does mean we search twice but on the other hand that also means 
 it's
 hot in the cache.


Below is early git diff (not a proper cleanup patch), to be sure that this is 
what we want on PowerPC and take early feedback. Also I run some benchmark to 
understand the overhead if any. 

Using kvm_is_mmio_pfn(); what the current patch does:   

Real: 0m46.616s + 0m49.517s + 0m49.510s + 0m46.936s + 0m46.889s + 0m46.684s = 
Avg; 47.692s
User: 0m31.636s + 0m31.816s + 0m31.456s + 0m31.752s + 0m32.028s + 0m31.848s = 
Avg; 31.756s
Sys:  0m11.596s + 0m11.868s + 0m12.244s + 0m11.672s + 0m11.356s + 0m11.432s = 
Avg; 11.695s


Using kernel page table search (below changes):
Real: 0m46.431s + 0m50.269s + 0m46.724s + 0m46.645s + 0m46.670s + 0m50.259s = 
Avg; 47.833s
User: 0m31.568s + 0m31.816s + 0m31.444s + 0m31.808s + 0m31.312s + 0m31.740s = 
Avg; 31.614s
Sys:  0m11.516s + 0m12.060s + 0m11.872s + 0m11.476s + 0m12.000s + 0m12.152s = 
Avg; 11.846s

--
diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
index 3328353..d6d0dac 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -532,6 +532,7 @@ struct kvm_vcpu_arch {
u32 epr;
u32 crit_save;
struct kvmppc_booke_debug_reg dbg_reg;
+   pgd_t *pgdir;
 #endif
gpa_t paddr_accessed;
gva_t vaddr_accessed;
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 17722d8..eb2 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -697,7 +697,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct 
kvm_vcpu *vcpu)
 #endif
 
kvmppc_fix_ee_before_entry();
-
+   vcpu-arch.pgdir = current-mm-pgd;
ret = __kvmppc_vcpu_run(kvm_run, vcpu);
 
/* No need for kvm_guest_exit. It's done in handle_exit.
diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h
index 4fd9650..fc4b2f6 100644
--- a/arch/powerpc/kvm/e500.h
+++ b/arch/powerpc/kvm/e500.h
@@ -31,11 +31,13 @@ enum vcpu_ftr {
 #define E500_TLB_NUM   2
 
 /* entry is mapped somewhere in host TLB */
-#define E500_TLB_VALID (1  0)
+#define E500_TLB_VALID (1  31)
 /* TLB1 entry is mapped by host TLB1, tracked by bitmaps */
-#define E500_TLB_BITMAP(1  1)
+#define E500_TLB_BITMAP(1  30)
 /* TLB1 entry is mapped by host TLB0 */
-#define E500_TLB_TLB0  (1  2)
+#define E500_TLB_TLB0  (1  29)
+/* Lower 5 bits have WIMGE value */
+#define E500_TLB_WIMGE_MASK(0x1f)
 
 struct tlbe_ref {
pfn_t pfn;  /* valid only for TLB0, except briefly */
diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index 5cbdc8f..a48c13f 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -40,6 +40,84 @@
 
 static struct kvmppc_e500_tlb_params host_tlb_params[E500_TLB_NUM];
 
+/*
+ * find_linux_pte returns the address of a linux pte for a given
+ * effective address and directory.  If not found, it returns zero.
+ */
+static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea)
+{
+pgd_t *pg;
+pud_t *pu;
+pmd_t *pm;
+pte_t *pt = NULL;
+
+pg = pgdir + pgd_index(ea);
+if (!pgd_none(*pg)) {
+pu = pud_offset(pg, ea);
+if (!pud_none(*pu)) {
+pm = pmd_offset(pu, ea);
+if (pmd_present(*pm))
+pt = pte_offset_kernel(pm, ea);
+}
+}
+return pt;
+}
+
+#ifdef CONFIG_HUGETLB_PAGE
+pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
+ unsigned *shift);
+#else
+static inline pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
+   unsigned *shift)
+{
+if (shift)
+*shift = 0;
+return find_linux_pte(pgdir, ea);
+}
+#endif /* !CONFIG_HUGETLB_PAGE */
+
+/*
+ * Lock and read a linux PTE.  If it's present and writable, atomically
+ * set dirty and referenced bits and return the PTE, otherwise return 0.
+ */
+static inline pte_t kvmppc_read_update_linux_pte(pte_t *p, int writing)
+{
+   pte_t pte = pte_val(*p);
+
+   if (pte_present(pte)) {
+   pte = 

Re: [PATCH v3 2/3] powerpc/85xx: Add silicon device tree for C293

2013-07-30 Thread Scott Wood

On 07/30/2013 03:49:22 AM, Po Liu wrote:

From: Mingkai Hu mingkai...@freescale.com

Signed-off-by: Mingkai Hu mingkai...@freescale.com
Signed-off-by: Po Liu po@freescale.com
---
Changes for v2:
- None
Changes for v3:
- None

 arch/powerpc/boot/dts/fsl/c293si-post.dtsi | 193  
+

 arch/powerpc/boot/dts/fsl/c293si-pre.dtsi  |  63 ++
 2 files changed, 256 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/fsl/c293si-post.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/c293si-pre.dtsi

diff --git a/arch/powerpc/boot/dts/fsl/c293si-post.dtsi  
b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi

new file mode 100644
index 000..bd20832
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
@@ -0,0 +1,193 @@
+/*
+ * C293 Silicon/SoC Device Tree Source (post include)
+ *
+ * Copyright 2012 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.
+ */
+
+ifc {
+   #address-cells = 2;
+   #size-cells = 1;
+   compatible = fsl,ifc, simple-bus;
+   interrupts = 19 2 0 0;
+};
+
+/* controller at 0xa000 */
+pci0 {
+   compatible = fsl,qoriq-pcie-v2.2, fsl,qoriq-pcie;
+   device_type = pci;
+   #size-cells = 2;
+   #address-cells = 3;
+   bus-range = 0 255;
+   clock-frequency = ;
+   interrupts = 16 2 0 0;


Remove clock-frequency (surely PCIe is not running at 33 MHz).


+   crypto@8 {
+/include/ qoriq-sec6.0-0.dtsi
+   };
+
+   crypto@8 {
+   reg = 0x8 0x2;
+   ranges = 0x0 0x8 0x2;
+
+   jr@1000{
+   interrupts = 45 2 0 0;
+   };
+   jr@2000{
+   interrupts = 57 2 0 0;
+   };
+   };


Do these inline the way the example shows.

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


Re: [PATCH v3 3/3] powerpc/85xx: Add C293PCIE board support

2013-07-30 Thread Scott Wood

On 07/30/2013 03:49:23 AM, Po Liu wrote:

+   nand@1,0 {
+   #address-cells = 1;
+   #size-cells = 1;
+   compatible = fsl,ifc-nand;
+   reg = 0x1 0x0 0x1;
+
+   partition@0 {
+   /* This location must not be altered  */
+   /* 1MB for u-boot Bootloader Image */
+   reg = 0x0 0x0010;
+   label = NAND U-Boot Image;
+   read-only;
+   };
+
+   partition@10 {
+   /* 1MB for DTB Image */
+   reg = 0x0010 0x0010;
+   label = NAND DTB Image;
+   };
+
+   partition@20 {
+   /* 4MB for Linux Kernel Image */
+   reg = 0x0020 0x0040;
+   label = NAND Linux Kernel Image;
+   };
+
+   partition@60 {
+   /* 4090MB for Root file System Image */
+   reg = 0x0060 0xffa0;
+   label = NAND RFS Image;
+   };
+   };


Might want to leave a bit more room for the kernel image, given the  
size of NAND.


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


Re: [PATCH 4/4] kvm: powerpc: set cache coherency only for RAM pages

2013-07-30 Thread Scott Wood

On 07/30/2013 11:22:54 AM, Bhushan Bharat-R65777 wrote:
diff --git a/arch/powerpc/kvm/e500_mmu_host.c  
b/arch/powerpc/kvm/e500_mmu_host.c

index 5cbdc8f..a48c13f 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -40,6 +40,84 @@

 static struct kvmppc_e500_tlb_params host_tlb_params[E500_TLB_NUM];

+/*
+ * find_linux_pte returns the address of a linux pte for a given
+ * effective address and directory.  If not found, it returns zero.
+ */
+static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea)
+{
+pgd_t *pg;
+pud_t *pu;
+pmd_t *pm;
+pte_t *pt = NULL;
+
+pg = pgdir + pgd_index(ea);
+if (!pgd_none(*pg)) {
+pu = pud_offset(pg, ea);
+if (!pud_none(*pu)) {
+pm = pmd_offset(pu, ea);
+if (pmd_present(*pm))
+pt = pte_offset_kernel(pm, ea);
+}
+}
+return pt;
+}


How is this specific to KVM or e500?


+#ifdef CONFIG_HUGETLB_PAGE
+pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
+ unsigned *shift);
+#else
+static inline pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir,  
unsigned long ea,

+   unsigned *shift)
+{
+if (shift)
+*shift = 0;
+return find_linux_pte(pgdir, ea);
+}
+#endif /* !CONFIG_HUGETLB_PAGE */


This is already declared in asm/pgtable.h.  If we need a non-hugepage  
alternative, that should also go in asm/pgtable.h.



+/*
+ * Lock and read a linux PTE.  If it's present and writable,  
atomically
+ * set dirty and referenced bits and return the PTE, otherwise  
return 0.

+ */
+static inline pte_t kvmppc_read_update_linux_pte(pte_t *p, int  
writing)

+{
+   pte_t pte = pte_val(*p);
+
+   if (pte_present(pte)) {
+   pte = pte_mkyoung(pte);
+   if (writing  pte_write(pte))
+   pte = pte_mkdirty(pte);
+   }
+
+   *p = pte;
+
+   return pte;
+}
+
+static pte_t lookup_linux_pte(pgd_t *pgdir, unsigned long hva,
+ int writing, unsigned long *pte_sizep)
+{
+   pte_t *ptep;
+   unsigned long ps = *pte_sizep;
+   unsigned int shift;
+
+   ptep = find_linux_pte_or_hugepte(pgdir, hva, shift);
+   if (!ptep)
+   return __pte(0);
+   if (shift)
+   *pte_sizep = 1ul  shift;
+   else
+   *pte_sizep = PAGE_SIZE;
+
+   if (ps  *pte_sizep)
+   return __pte(0);
+   if (!pte_present(*ptep))
+   return __pte(0);
+
+   return kvmppc_read_update_linux_pte(ptep, writing);
+}
+


None of this belongs in this file either.


@@ -326,8 +405,8 @@ static void kvmppc_e500_setup_stlbe(

/* Force IPROT=0 for all guest mappings. */
stlbe-mas1 = MAS1_TSIZE(tsize) | get_tlb_sts(gtlbe) |  
MAS1_VALID;

-   stlbe-mas2 = (gvaddr  MAS2_EPN) |
- e500_shadow_mas2_attrib(gtlbe-mas2, pfn);
+   stlbe-mas2 = (gvaddr  MAS2_EPN) | (ref-flags   
E500_TLB_WIMGE_MASK);

+//   e500_shadow_mas2_attrib(gtlbe-mas2, pfn);


MAS2_E and MAS2_G should be safe to come from the guest.

How does this work for TLB1?  One ref corresponds to one guest entry,  
which may correspond to multiple host entries, potentially each with  
different WIM settings.



stlbe-mas7_3 = ((u64)pfn  PAGE_SHIFT) |
e500_shadow_mas3_attrib(gtlbe-mas7_3, pr);

@@ -346,6 +425,8 @@ static inline int kvmppc_e500_shadow_map(struct  
kvmppc_vcpu_e500 *vcpu_e500,

unsigned long hva;
int pfnmap = 0;
int tsize = BOOK3E_PAGESZ_4K;
+   pte_t pte;
+   int wimg = 0;

/*
 * Translate guest physical to true physical, acquiring
@@ -451,6 +532,8 @@ static inline int kvmppc_e500_shadow_map(struct  
kvmppc_vcpu_e500 *vcpu_e500,


if (likely(!pfnmap)) {
unsigned long tsize_pages = 1  (tsize + 10 -  
PAGE_SHIFT);

+   pgd_t *pgdir;
+
pfn = gfn_to_pfn_memslot(slot, gfn);
if (is_error_noslot_pfn(pfn)) {
printk(KERN_ERR Couldn't get real page for  
gfn %lx!\n,
@@ -461,9 +544,15 @@ static inline int kvmppc_e500_shadow_map(struct  
kvmppc_vcpu_e500 *vcpu_e500,
/* Align guest and physical address to page map  
boundaries */

pfn = ~(tsize_pages - 1);
gvaddr = ~((tsize_pages  PAGE_SHIFT) - 1);
+   pgdir = vcpu_e500-vcpu.arch.pgdir;
+   pte = lookup_linux_pte(pgdir, hva, 1, tsize_pages);
+   if (pte_present(pte))
+   wimg = (pte  PTE_WIMGE_SHIFT)   
MAS2_WIMGE_MASK;

+   else
+   wimg = MAS2_I | MAS2_G;


If the PTE is not present, then we can't map it, right?  So why I+G?

-Scott

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

2013-07-30 Thread Scott Wood

On 07/30/2013 06:40:29 AM, Chunhe Lan wrote:

P1023RDB Specification:
---
Memory subsystem:
   512MB DDR3 (Fixed DDR on board)
   64MB NOR flash
   128MB NAND flash

Ethernet:
   eTSEC1: Connected to Atheros AR8035 GETH PHY
   eTSEC2: Connected to Atheros AR8035 GETH PHY

PCIe:
   Three mini-PCIe slots

USB:
   Two USB2.0 Type A ports

I2C:
   AT24C08 8K Board EEPROM (8 bit address)

Signed-off-by: Chunhe Lan chunhe@freescale.com
Cc: Scott Wood scottw...@freescale.com
---
 arch/powerpc/boot/dts/p1023rdb.dts   |  237  
++
 arch/powerpc/configs/85xx/p1023_defconfig|  183  

 arch/powerpc/configs/85xx/p1023rds_defconfig |  169  
--

 arch/powerpc/platforms/85xx/Kconfig  |4 +-
 arch/powerpc/platforms/85xx/p1023_rds.c  |   24 +++-
 5 files changed, 445 insertions(+), 172 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/p1023rdb.dts
 create mode 100644 arch/powerpc/configs/85xx/p1023_defconfig
 delete mode 100644 arch/powerpc/configs/85xx/p1023rds_defconfig


Please indicate changes from the previous version under the ---



diff --git a/arch/powerpc/boot/dts/p1023rdb.dts  
b/arch/powerpc/boot/dts/p1023rdb.dts

new file mode 100644
index 000..107c676
--- /dev/null
+++ b/arch/powerpc/boot/dts/p1023rdb.dts
@@ -0,0 +1,237 @@
+/*
+ * P1023 RDB Device Tree Source
+ *
+ *Copyright 2013 Freescale Semiconductor Inc.
+ *
+ * Author: Chunhe Lan chunhe@freescale.com
+ *
+ * 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/p1023si-pre.dtsi
+
+/ {
+   model = fsl,P1023;
+   compatible = fsl,P1023RDB;
+   #address-cells = 2;
+   #size-cells = 2;
+   interrupt-parent = mpic;
+
+   memory {
+   device_type = memory;
+   };
+
+   soc: soc@ff60 {
+   ranges = 0x0 0x0 0xff60 0x20;
+
+   i2c@3000 {
+   eeprom@53 {
+   compatible = at24,24c04;
+   reg = 0x53;
+   };
+
+   rtc@6f {
+   compatible = microchip,mcp7941x;
+   reg = 0x6f;
+   };
+   };
+
+   usb@22000 {
+   dr_mode = host;
+   phy_type = ulpi;
+   };
+   };
+
+   lbc: localbus@ff605000 {
+   reg = 0 0xff605000 0 0x1000;
+
+   /* NOR, NAND Flashes */
+   ranges = 0x0 0x0 0x0 0xec00 0x0400
+ 0x1 0x0 0x0 0xffa0 0x0800;


Is there no FPGA attached to eLBC?


+   nor@0,0 {
+   #address-cells = 1;
+   #size-cells = 1;
+   compatible = cfi-flash;
+   reg = 0x0 0x0 0x0400;
+   bank-width = 2;
+   device-width = 1;
+
+   partition@0 {
+/* 48MB for JFFS2 based Root file  
System */

+   reg = 0x 0x0300;
+   label = NOR JFFS2 Root File System;
+  

Re: [PATCH] cpuidle: add freescale e500 family porcessors idle support

2013-07-30 Thread Scott Wood

On 07/30/2013 02:00:03 AM, Dongsheng Wang wrote:

From: Wang Dongsheng dongsheng.w...@freescale.com

Add cpuidle support for e500 family, using cpuidle framework to
manage various low power modes. The new implementation will remain
compatible with original idle method.

Initially, this supports PW10, and subsequent patches will support
PW20/DOZE/NAP.


Could you explain what the cpuidle framework does for us that the  
current

idle code doesn't?

In particular, what scenario do you see where we would require a  
software

governor to choose between idle states, and how much power is saved
compared to a simpler approach?  There is timer that can be used to
automatically enter PW20 after a certain amount of time in PW10.  How
much better results do you get from a software governor?  Do we even  
have

the right data to characterize each state so that a software governor
could make good decisions?  Is cpuidle capable of governing the interval
of such a timer, rather than directly governing states?

As for doze/nap, why would we want to use those on newer cores?  Do you
have numbers for how much power each mode saves?

Active governors may be useful on older cores that only have doze/nap,  
to
select between them, but if that's the use case then why start with  
pw10?

And I'd want to see numbers for how much power nap saves versus doze.


Signed-off-by: Wang Dongsheng dongsheng.w...@freescale.com
---
This patch keep using cpuidle_register_device(), because we need to  
support cpu

hotplug. I will fix device issue in this driver, after
Deepthi Dharwar deep...@linux.vnet.ibm.com add a hotplug handler  
into cpuidle

freamwork.


Where's the diffstat?

diff --git a/arch/powerpc/include/asm/machdep.h  
b/arch/powerpc/include/asm/machdep.h

index 8b48090..cbdbe25 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -271,6 +271,16 @@ extern void power7_idle(void);
 extern void ppc6xx_idle(void);
 extern void book3e_idle(void);

+/* Wait for Interrupt */
+static inline void fsl_cpuidle_wait(void)
+{
+#ifdef CONFIG_PPC64
+   book3e_idle();
+#else
+   e500_idle();
+#endif
+}


Where is this used?


+
 /*
  * ppc_md contains a copy of the machine description structure for  
the
  * current platform. machine_id contains the initial address where  
the

diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index b3fb81d..7ed114b 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -35,6 +35,11 @@ depends on ARM
 source drivers/cpuidle/Kconfig.arm
 endmenu

+menu PowerPC CPU Idle Drivers
+depends on PPC32 || PPC64


depends on PPC

diff --git a/drivers/cpuidle/Kconfig.powerpc  
b/drivers/cpuidle/Kconfig.powerpc

new file mode 100644
index 000..9f3f5ef
--- /dev/null
+++ b/drivers/cpuidle/Kconfig.powerpc
@@ -0,0 +1,9 @@
+#
+# PowerPC CPU Idle drivers
+#
+
+config PPC_E500_CPUIDLE
+   bool CPU Idle Driver for E500 family processors
+   depends on FSL_SOC_BOOKE
+   help
+ Select this to enable cpuidle on e500 family processors.


FSL_SOC_BOOKE is more than just e500


diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index 0b9d200..0dde3db 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -11,3 +11,7 @@ obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE)	+=  
cpuidle-calxeda.o

 obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE) += cpuidle-kirkwood.o
 obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o
 obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o
+
+##
+# PowerPC platform drivers
+obj-$(CONFIG_PPC_E500_CPUIDLE) += cpuidle-e500.o
diff --git a/drivers/cpuidle/cpuidle-e500.c  
b/drivers/cpuidle/cpuidle-e500.c

new file mode 100644
index 000..1919cea
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-e500.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * CPU Idle driver for Freescale PowerPC e500 family processors.
+ *
+ * This program is free software; you can redistribute it and/or  
modify

+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Author: Wang Dongsheng dongsheng.w...@freescale.com
+ */


Is this derived from some other file?  It looks like it...  Where's the
attribution?


+#include linux/cpu.h
+#include linux/cpuidle.h
+#include linux/init.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/notifier.h
+
+#include asm/machdep.h
+
+static struct cpuidle_driver e500_idle_driver = {
+   .name = e500_idle,
+   .owner = THIS_MODULE,
+};
+
+static struct cpuidle_device __percpu *e500_cpuidle_devices;
+
+static void e500_cpuidle(void)
+{
+   /*
+* This would call on the cpuidle framework, and the back-end
+* driver to go to idle states.
+*/
+   if (cpuidle_idle_call()) {
+   /*
+* On error, execute default handler
+ 

Re: [PATCH 1/3] mmc:core: parse voltage from device-tree

2013-07-30 Thread Scott Wood

On 07/29/2013 08:34:29 PM, Zhang Haijun wrote:

On 07/30/2013 06:07 AM, Scott Wood wrote:

On 07/28/2013 09:56:33 PM, Haijun Zhang wrote:

Add function to support get voltage from device-tree.
If there are voltage-range specified in device-tree node, this  
function

will parse it and return the avail voltage mask.

Signed-off-by: Haijun Zhang haijun.zh...@freescale.com
---
 drivers/mmc/core/core.c  | 48  


 include/linux/mmc/core.h |  1 +
 2 files changed, 49 insertions(+)


Move the code rather than copying it.

-Scott

Hi, Scott

You mean?


The point of factoring this out is to avoid duplicating the code.  If  
you don't remove it from the place you copied it from (and have that  
code call here instead), then you're not avoiding the duplication.


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


Re: [4/4] Added device tree entries for Legerity SLIC node on various Freescale Platforms

2013-07-30 Thread Scott Wood
On Thu, Mar 07, 2013 at 04:57:48PM +0530, Sandeep Singh wrote:
 diff --git a/arch/powerpc/boot/dts/p1024rdb.dtsi 
 b/arch/powerpc/boot/dts/p1024rdb.dtsi
 index b05dcb4..cec36a3 100644
 --- a/arch/powerpc/boot/dts/p1024rdb.dtsi
 +++ b/arch/powerpc/boot/dts/p1024rdb.dtsi
 @@ -164,6 +164,19 @@
   label = SPI JFFS2 RFS;
   };
   };
 +
 +tdm_phy_0: slic@0 {
 +compatible = zarlink,le88266, tdm-phy-slic;
 + reg = 1;
 + spi-max-frequency = 800;
 + };
 +
 +tdm_phy_1: slic@1 {
 +compatible = zarlink,le88266, tdm-phy-slic;
 + reg = 2;
 + spi-max-frequency = 800;
 + };
 +
   };
  
   i2c@3000 {
 @@ -173,6 +186,11 @@
   };
   };
  
 +tdm@16000 {
 +num-phy = 2;
 +phy-handle = tdm_phy_0, tdm_phy_1;
 +};
 +
   usb@22000 {
   phy_type = ulpi;
   };

Whitespace

What is tdm-phy-slic?  num-phy?  Document these in the binding and
use proper vendor prefixes.

Why tdm_phy_0, tdm_phy_1 rather than tdm_phy_0 tdm_phy_1? 
And can you just use the length of phy-handle rather than having a
separate num-phy property?

-Scott
 

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


RE: [PATCH v3 2/3] powerpc/85xx: Add silicon device tree for C293

2013-07-30 Thread Liu Po-B43644

  -Original Message-
  From: Wood Scott-B07421
  Sent: Wednesday, July 31, 2013 2:28 AM
  To: Liu Po-B43644
  Cc: linuxppc-...@ozlabs.org; ga...@kernel.crashing.org; Fleming Andy-
  AFLEMING; Hu Mingkai-B21284; Liu Po-B43644
  Subject: Re: [PATCH v3 2/3] powerpc/85xx: Add silicon device tree for
  C293
  
  On 07/30/2013 03:49:22 AM, Po Liu wrote:
   From: Mingkai Hu mingkai...@freescale.com
  
   Signed-off-by: Mingkai Hu mingkai...@freescale.com
   Signed-off-by: Po Liu po@freescale.com
   ---
   Changes for v2:
  - None
   Changes for v3:
  - None
  
arch/powerpc/boot/dts/fsl/c293si-post.dtsi | 193
   +
arch/powerpc/boot/dts/fsl/c293si-pre.dtsi  |  63 ++
2 files changed, 256 insertions(+)
create mode 100644 arch/powerpc/boot/dts/fsl/c293si-post.dtsi
create mode 100644 arch/powerpc/boot/dts/fsl/c293si-pre.dtsi
  
   diff --git a/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
   b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
   new file mode 100644
   index 000..bd20832
   --- /dev/null
   +++ b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
   @@ -0,0 +1,193 @@
   +/*
   + * C293 Silicon/SoC Device Tree Source (post include)
   + *
   + * Copyright 2012 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.
   + */
   +
   +ifc {
   +  #address-cells = 2;
   +  #size-cells = 1;
   +  compatible = fsl,ifc, simple-bus;
   +  interrupts = 19 2 0 0;
   +};
   +
   +/* controller at 0xa000 */
   +pci0 {
   +  compatible = fsl,qoriq-pcie-v2.2, fsl,qoriq-pcie;
   +  device_type = pci;
   +  #size-cells = 2;
   +  #address-cells = 3;
   +  bus-range = 0 255;
   +  clock-frequency = ;
   +  interrupts = 16 2 0 0;
  
  Remove clock-frequency (surely PCIe is not running at 33 MHz).
  
   +  crypto@8 {
   +/include/ qoriq-sec6.0-0.dtsi
   +  };
   +
   +  crypto@8 {
   +  reg = 0x8 0x2;
   +  ranges = 0x0 0x8 0x2;
   +
   +  jr@1000{
   +  interrupts = 45 2 0 0;
   +  };
   +  jr@2000{
   +  interrupts = 57 2 0 0;
   +  };
   +  };
  
  Do these inline the way the example shows.
Sorry, Scott, I just remember in this way, the node can't be recognized by 
system when run Uboot. The include can't be in the crypto@8. See the 
discussion in http://git.am.freescale.net:8181/#/c/736/  .
Maybe I should re-modify the example file.
  
  -Scott

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


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

2013-07-30 Thread Chunhe Lan

On 07/31/2013 02:57 AM, Scott Wood wrote:

On 07/30/2013 06:40:29 AM, Chunhe Lan wrote: +

+lbc: localbus@ff605000 {
+reg = 0 0xff605000 0 0x1000;
+
+/* NOR, NAND Flashes */
+ranges = 0x0 0x0 0x0 0xec00 0x0400
+  0x1 0x0 0x0 0xffa0 0x0800;


Is there no FPGA attached to eLBC?


Yes, p1023rdb does not have FPGA attached to eLBC.

Thanks,
-Chunhe


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


[PATCH] powerpc/dts: fix sRIO error interrupt for b4860

2013-07-30 Thread Minghuan Lian
For B4 platform, MPIC EISR register is in reversed bitmap order,
instead of Error interrupt source 0-31. Bit 0 represents SRC0.
the correct ordering is Error interrupt source 0-31. Bit 0
represents SRC31. This patch is to fix sRIO EISR bit value
of error interrupt in dts node.

Signed-off-by: Minghuan Lian minghuan.l...@freescale.com
---
 arch/powerpc/boot/dts/fsl/b4860si-post.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
index e5cf6c8..9813975 100644
--- a/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
@@ -41,7 +41,7 @@
 
 rio {
compatible = fsl,srio;
-   interrupts = 16 2 1 11;
+   interrupts = 16 2 1 20;
#address-cells = 2;
#size-cells = 2;
fsl,iommu-parent = pamu0;
-- 
1.8.1.2


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


[PATCH V2 1/6] cpuidle/pseries: Fix kernel command line parameter smt-snooze-delay

2013-07-30 Thread Deepthi Dharwar
smt-snooze-delay is tunable provided currently on powerpc to delay the
entry of an idle cpu to NAP state. By default, the value is 100us,
which is entry criteria for NAP state i.e only if the idle period is
above 100us it would enter NAP. Value of -1 disables entry into NAP.
This value can be set either through sysfs, ppc64_cpu util or by
passing it via kernel command line. Currently this feature is broken
when the value is passed via the kernel command line.

This patch aims to fix this, by taking the appropritate action
based on the value after the pseries driver is registered.
This check is carried on in the backend driver rather in
setup_smt_snooze_delay() as one is not sure if the cpuidle driver
is even registered when setup routine is executed.
Also, this fixes re-enabling of NAP states by setting appropriate
value without having to reboot.

Also, to note is, smt-snooze-delay is per-cpu variable.
This can be used to enable/disable NAP on per-cpu
basis using sysfs but when this variable is passed
via kernel command line or using the smt-snooze-delay
it applies to all the cpus. Per-cpu tuning can
only be done via sysfs.

Signed-off-by: Deepthi Dharwar deep...@linux.vnet.ibm.com
---
 arch/powerpc/platforms/pseries/processor_idle.c |   35 ++-
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/processor_idle.c 
b/arch/powerpc/platforms/pseries/processor_idle.c
index 4644efa0..d6a1caa 100644
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ b/arch/powerpc/platforms/pseries/processor_idle.c
@@ -170,18 +170,37 @@ static struct cpuidle_state 
shared_states[MAX_IDLE_STATE_COUNT] = {
 void update_smt_snooze_delay(int cpu, int residency)
 {
struct cpuidle_driver *drv = cpuidle_get_driver();
-   struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
+   struct cpuidle_device *dev;
 
if (cpuidle_state_table != dedicated_states)
return;
 
-   if (residency  0) {
-   /* Disable the Nap state on that cpu */
-   if (dev)
-   dev-states_usage[1].disable = 1;
-   } else
-   if (drv)
+   if (!drv)
+   return;
+
+   if (cpu == -1) {
+   if (residency  0) {
+   /* Disable NAP on all cpus */
+   drv-states[1].disabled = true;
+   return;
+   } else {
drv-states[1].target_residency = residency;
+   drv-states[1].disabled = false;
+   return;
+   }
+   }
+
+   dev = per_cpu(cpuidle_devices, cpu);
+   if (!dev)
+   return;
+
+   if (residency  0)
+   dev-states_usage[1].disable = 1;
+   else {
+   drv-states[1].target_residency = residency;
+   drv-states[1].disabled = false;
+   dev-states_usage[1].disable = 0;
+   }
 }
 
 static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n,
@@ -331,6 +350,8 @@ static int __init pseries_processor_idle_init(void)
return retval;
}
 
+   update_smt_snooze_delay(-1, per_cpu(smt_snooze_delay, 0));
+
retval = pseries_idle_devices_init();
if (retval) {
pseries_idle_devices_uninit();

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


[PATCH V2 2/6] cpuidle/pseries: Remove dependency of pseries.h file

2013-07-30 Thread Deepthi Dharwar
As a part of pseries_idle cleanup to make the backend driver
code common to both pseries and powernv, this patch
is essential to remove the dependency of pseries.h
header file.

Move the declaration of smt_snooze_delay from pseries.h
to processor_idle.c. smt_snooze_delay variable is
needed for both pseries and powernv.

/* Snooze Delay, pseries_idle */
DECLARE_PER_CPU(long, smt_snooze_delay);

Signed-off-by: Deepthi Dharwar deep...@linux.vnet.ibm.com
---
 arch/powerpc/platforms/pseries/processor_idle.c |4 +++-
 arch/powerpc/platforms/pseries/pseries.h|3 ---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/processor_idle.c 
b/arch/powerpc/platforms/pseries/processor_idle.c
index d6a1caa..64da5cc 100644
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ b/arch/powerpc/platforms/pseries/processor_idle.c
@@ -20,7 +20,9 @@
 #include asm/runlatch.h
 
 #include plpar_wrappers.h
-#include pseries.h
+
+/* Snooze Delay, pseries_idle */
+DECLARE_PER_CPU(long, smt_snooze_delay);
 
 struct cpuidle_driver pseries_idle_driver = {
.name = pseries_idle,
diff --git a/arch/powerpc/platforms/pseries/pseries.h 
b/arch/powerpc/platforms/pseries/pseries.h
index c2a3a25..d1b07e6 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -60,9 +60,6 @@ extern struct device_node *dlpar_configure_connector(u32);
 extern int dlpar_attach_node(struct device_node *);
 extern int dlpar_detach_node(struct device_node *);
 
-/* Snooze Delay, pseries_idle */
-DECLARE_PER_CPU(long, smt_snooze_delay);
-
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
 int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);

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


[PATCH V2 0/6] cpuidle/powerpc: POWERPC cpuidle driver for POWER and POWERNV platforms

2013-07-30 Thread Deepthi Dharwar
Following patch series consolidates backend cpuidle driver
for pseries and powernv platforms. 

Current existing backend driver for pseries has been moved to
arch/powerpc/sysdev and has been extended to accommodate 
powernv idle power mgmt states. 
As seen in V1 of this patch series, too much code duplication persists
having separate back-end driver for individual platforms.

Moving the idle states over to cpuidle framework can take advantage 
of advanced heuristics, tunables and features provided by cpuidle 
framework. Additional idle states can be exploited using the cpuidle 
framework. The statistics and tracing infrastructure provided by 
the cpuidle framework also helps in enabling power management 
related tools and help tune the system and applications.

This series aims to maintain compatibility and functionality to
existing pseries and powernv idle cpu management code.  
There are no new functions or idle states added as part of this series. 
This can be extended by adding more states to this existing framework.

With this patch series the powernv cpuidle functionalities
are on-par with pSeries idle management. Other POWERPC
platforms can use this to exploit CPUIDLE framework.

This patch mainly focus on an integrated CPUIDLE backend
driver for POWERPC. Minor cpuidle clean-ups will be
taken up going further.

One need to enable POWERPC_IDLE config option to exploit these
backend drivers.

V1 - http://lkml.org/lkml/2013/7/23/143

 Deepthi Dharwar (6):
  cpuidle/pseries: Fix kernel command line parameter smt-snooze-delay
  cpuidle/pseries: Remove dependency of pseries.h file
  pseries: Move plpar_wrapper.h to powerpc common include/asm location.
  cpuidle/pseries: Move the pseries_idle backend driver to sysdev.
  cpuidle/powerpc: Backend-powerpc idle driver for powernv and pseries.
  cpuidle/powernv: Enable idle powernv cpu to call into the cpuidle 
framework.


  arch/powerpc/include/asm/plpar_wrappers.h   |  324 ++
 arch/powerpc/include/asm/processor.h|2 
 arch/powerpc/platforms/powernv/setup.c  |   12 +
 arch/powerpc/platforms/pseries/Kconfig  |9 
 arch/powerpc/platforms/pseries/Makefile |1 
 arch/powerpc/platforms/pseries/cmm.c|3 
 arch/powerpc/platforms/pseries/dtl.c|3 
 arch/powerpc/platforms/pseries/hotplug-cpu.c|3 
 arch/powerpc/platforms/pseries/hvconsole.c  |2 
 arch/powerpc/platforms/pseries/iommu.c  |3 
 arch/powerpc/platforms/pseries/kexec.c  |2 
 arch/powerpc/platforms/pseries/lpar.c   |2 
 arch/powerpc/platforms/pseries/plpar_wrappers.h |  324 --
 arch/powerpc/platforms/pseries/processor_idle.c |  362 
 arch/powerpc/platforms/pseries/pseries.h|3 
 arch/powerpc/platforms/pseries/setup.c  |2 
 arch/powerpc/platforms/pseries/smp.c|2 
 arch/powerpc/sysdev/Kconfig |9 
 arch/powerpc/sysdev/Makefile|1 
 arch/powerpc/sysdev/processor_idle.c|  424 +++
 20 files changed, 780 insertions(+), 713 deletions(-)
 create mode 100644 arch/powerpc/include/asm/plpar_wrappers.h
 delete mode 100644 arch/powerpc/platforms/pseries/plpar_wrappers.h
 delete mode 100644 arch/powerpc/platforms/pseries/processor_idle.c
 create mode 100644 arch/powerpc/sysdev/processor_idle.c


-- Deepthi

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


[PATCH V2 6/6] cpuidle/powernv: Enable idle powernv cpu to call into the cpuidle framework.

2013-07-30 Thread Deepthi Dharwar
This patch enables idle powernv cpu to hook on to the cpuidle
framework, if available, else call on to default idle platform
code.

Signed-off-by: Deepthi Dharwar deep...@linux.vnet.ibm.com
---
 arch/powerpc/platforms/powernv/setup.c |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/setup.c 
b/arch/powerpc/platforms/powernv/setup.c
index 84438af..d4283dd 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -25,6 +25,7 @@
 #include linux/of.h
 #include linux/interrupt.h
 #include linux/bug.h
+#include linux/cpuidle.h
 
 #include asm/machdep.h
 #include asm/firmware.h
@@ -196,6 +197,15 @@ static int __init pnv_probe(void)
return 1;
 }
 
+void powernv_idle(void)
+{
+   /* Hook to cpuidle framework if available, else
+* call on default platform idle code
+   */
+   if (cpuidle_idle_call())
+   power7_idle();
+}
+
 define_machine(powernv) {
.name   = PowerNV,
.probe  = pnv_probe,
@@ -205,7 +215,7 @@ define_machine(powernv) {
.show_cpuinfo   = pnv_show_cpuinfo,
.progress   = pnv_progress,
.machine_shutdown   = pnv_shutdown,
-   .power_save = power7_idle,
+   .power_save = powernv_idle,
.calibrate_decr = generic_calibrate_decr,
 #ifdef CONFIG_KEXEC
.kexec_cpu_down = pnv_kexec_cpu_down,

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


[PATCH V2 4/6] cpuidle/pseries: Move the pseries_idle backend driver to sysdev.

2013-07-30 Thread Deepthi Dharwar
Move pseries_idle backend driver code to arch/powerpc/sysdev
so that the code can be used for a common driver for powernv
and pseries. This removes a lot of code duplicacy.

Signed-off-by: Deepthi Dharwar deep...@linux.vnet.ibm.com
---
 arch/powerpc/platforms/pseries/Kconfig  |9 -
 arch/powerpc/platforms/pseries/Makefile |1 
 arch/powerpc/platforms/pseries/processor_idle.c |  384 ---
 arch/powerpc/sysdev/Kconfig |9 +
 arch/powerpc/sysdev/Makefile|1 
 arch/powerpc/sysdev/processor_idle.c|  384 +++
 6 files changed, 394 insertions(+), 394 deletions(-)
 delete mode 100644 arch/powerpc/platforms/pseries/processor_idle.c
 create mode 100644 arch/powerpc/sysdev/processor_idle.c

diff --git a/arch/powerpc/platforms/pseries/Kconfig 
b/arch/powerpc/platforms/pseries/Kconfig
index 62b4f80..bb59bb0 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -119,12 +119,3 @@ config DTL
  which are accessible through a debugfs file.
 
  Say N if you are unsure.
-
-config PSERIES_IDLE
-   bool Cpuidle driver for pSeries platforms
-   depends on CPU_IDLE
-   depends on PPC_PSERIES
-   default y
-   help
- Select this option to enable processor idle state management
- through cpuidle subsystem.
diff --git a/arch/powerpc/platforms/pseries/Makefile 
b/arch/powerpc/platforms/pseries/Makefile
index 8ae0103..4b22379 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -21,7 +21,6 @@ obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o
 obj-$(CONFIG_CMM)  += cmm.o
 obj-$(CONFIG_DTL)  += dtl.o
 obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o
-obj-$(CONFIG_PSERIES_IDLE) += processor_idle.o
 
 ifeq ($(CONFIG_PPC_PSERIES),y)
 obj-$(CONFIG_SUSPEND)  += suspend.o
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c 
b/arch/powerpc/platforms/pseries/processor_idle.c
deleted file mode 100644
index 0d75a54..000
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- *  processor_idle - idle state cpuidle driver.
- *  Adapted from drivers/idle/intel_idle.c and
- *  drivers/acpi/processor_idle.c
- *
- */
-
-#include linux/kernel.h
-#include linux/module.h
-#include linux/init.h
-#include linux/moduleparam.h
-#include linux/cpuidle.h
-#include linux/cpu.h
-#include linux/notifier.h
-
-#include asm/paca.h
-#include asm/reg.h
-#include asm/machdep.h
-#include asm/firmware.h
-#include asm/runlatch.h
-#include asm/plpar_wrappers.h
-
-/* Snooze Delay, pseries_idle */
-DECLARE_PER_CPU(long, smt_snooze_delay);
-
-struct cpuidle_driver pseries_idle_driver = {
-   .name = pseries_idle,
-   .owner= THIS_MODULE,
-};
-
-#define MAX_IDLE_STATE_COUNT   2
-
-static int max_idle_state = MAX_IDLE_STATE_COUNT - 1;
-static struct cpuidle_device __percpu *pseries_cpuidle_devices;
-static struct cpuidle_state *cpuidle_state_table;
-
-static inline void idle_loop_prolog(unsigned long *in_purr)
-{
-   *in_purr = mfspr(SPRN_PURR);
-   /*
-* Indicate to the HV that we are idle. Now would be
-* a good time to find other work to dispatch.
-*/
-   get_lppaca()-idle = 1;
-}
-
-static inline void idle_loop_epilog(unsigned long in_purr)
-{
-   get_lppaca()-wait_state_cycles += mfspr(SPRN_PURR) - in_purr;
-   get_lppaca()-idle = 0;
-}
-
-static int snooze_loop(struct cpuidle_device *dev,
-   struct cpuidle_driver *drv,
-   int index)
-{
-   unsigned long in_purr;
-   int cpu = dev-cpu;
-
-   idle_loop_prolog(in_purr);
-   local_irq_enable();
-   set_thread_flag(TIF_POLLING_NRFLAG);
-
-   while ((!need_resched())  cpu_online(cpu)) {
-   ppc64_runlatch_off();
-   HMT_low();
-   HMT_very_low();
-   }
-
-   HMT_medium();
-   clear_thread_flag(TIF_POLLING_NRFLAG);
-   smp_mb();
-
-   idle_loop_epilog(in_purr);
-
-   return index;
-}
-
-static void check_and_cede_processor(void)
-{
-   /*
-* Ensure our interrupt state is properly tracked,
-* also checks if no interrupt has occurred while we
-* were soft-disabled
-*/
-   if (prep_irq_for_idle()) {
-   cede_processor();
-#ifdef CONFIG_TRACE_IRQFLAGS
-   /* Ensure that H_CEDE returns with IRQs on */
-   if (WARN_ON(!(mfmsr()  MSR_EE)))
-   __hard_irq_enable();
-#endif
-   }
-}
-
-static int dedicated_cede_loop(struct cpuidle_device *dev,
-   struct cpuidle_driver *drv,
-   int index)
-{
-   unsigned long in_purr;
-
-   idle_loop_prolog(in_purr);
-   get_lppaca()-donate_dedicated_cpu = 1;
-
-   ppc64_runlatch_off();
-   

[PATCH V2 3/6] pseries: Move plpar_wrapper.h to powerpc common include/asm location.

2013-07-30 Thread Deepthi Dharwar
As a part of pseries_idle backend driver cleanup to make
the code common to both pseries and powernv archs, it
is necessary to move the backend-driver code to powerpc/sysdev.

As a pre-requisite to that, it is essential to move plpar_wrapper.h
to include/asm.

Signed-off-by: Deepthi Dharwar deep...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/plpar_wrappers.h   |  324 +++
 arch/powerpc/platforms/pseries/cmm.c|3 
 arch/powerpc/platforms/pseries/dtl.c|3 
 arch/powerpc/platforms/pseries/hotplug-cpu.c|3 
 arch/powerpc/platforms/pseries/hvconsole.c  |2 
 arch/powerpc/platforms/pseries/iommu.c  |3 
 arch/powerpc/platforms/pseries/kexec.c  |2 
 arch/powerpc/platforms/pseries/lpar.c   |2 
 arch/powerpc/platforms/pseries/plpar_wrappers.h |  324 ---
 arch/powerpc/platforms/pseries/processor_idle.c |3 
 arch/powerpc/platforms/pseries/setup.c  |2 
 arch/powerpc/platforms/pseries/smp.c|2 
 12 files changed, 335 insertions(+), 338 deletions(-)
 create mode 100644 arch/powerpc/include/asm/plpar_wrappers.h
 delete mode 100644 arch/powerpc/platforms/pseries/plpar_wrappers.h

diff --git a/arch/powerpc/include/asm/plpar_wrappers.h 
b/arch/powerpc/include/asm/plpar_wrappers.h
new file mode 100644
index 000..f35787b
--- /dev/null
+++ b/arch/powerpc/include/asm/plpar_wrappers.h
@@ -0,0 +1,324 @@
+#ifndef _PSERIES_PLPAR_WRAPPERS_H
+#define _PSERIES_PLPAR_WRAPPERS_H
+
+#include linux/string.h
+#include linux/irqflags.h
+
+#include asm/hvcall.h
+#include asm/paca.h
+#include asm/page.h
+
+/* Get state of physical CPU from query_cpu_stopped */
+int smp_query_cpu_stopped(unsigned int pcpu);
+#define QCSS_STOPPED 0
+#define QCSS_STOPPING 1
+#define QCSS_NOT_STOPPED 2
+#define QCSS_HARDWARE_ERROR -1
+#define QCSS_HARDWARE_BUSY -2
+
+static inline long poll_pending(void)
+{
+   return plpar_hcall_norets(H_POLL_PENDING);
+}
+
+static inline u8 get_cede_latency_hint(void)
+{
+   return get_lppaca()-cede_latency_hint;
+}
+
+static inline void set_cede_latency_hint(u8 latency_hint)
+{
+   get_lppaca()-cede_latency_hint = latency_hint;
+}
+
+static inline long cede_processor(void)
+{
+   return plpar_hcall_norets(H_CEDE);
+}
+
+static inline long extended_cede_processor(unsigned long latency_hint)
+{
+   long rc;
+   u8 old_latency_hint = get_cede_latency_hint();
+
+   set_cede_latency_hint(latency_hint);
+
+   rc = cede_processor();
+#ifdef CONFIG_TRACE_IRQFLAGS
+   /* Ensure that H_CEDE returns with IRQs on */
+   if (WARN_ON(!(mfmsr()  MSR_EE)))
+   __hard_irq_enable();
+#endif
+
+   set_cede_latency_hint(old_latency_hint);
+
+   return rc;
+}
+
+static inline long vpa_call(unsigned long flags, unsigned long cpu,
+   unsigned long vpa)
+{
+   flags = flags  H_VPA_FUNC_SHIFT;
+
+   return plpar_hcall_norets(H_REGISTER_VPA, flags, cpu, vpa);
+}
+
+static inline long unregister_vpa(unsigned long cpu)
+{
+   return vpa_call(H_VPA_DEREG_VPA, cpu, 0);
+}
+
+static inline long register_vpa(unsigned long cpu, unsigned long vpa)
+{
+   return vpa_call(H_VPA_REG_VPA, cpu, vpa);
+}
+
+static inline long unregister_slb_shadow(unsigned long cpu)
+{
+   return vpa_call(H_VPA_DEREG_SLB, cpu, 0);
+}
+
+static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
+{
+   return vpa_call(H_VPA_REG_SLB, cpu, vpa);
+}
+
+static inline long unregister_dtl(unsigned long cpu)
+{
+   return vpa_call(H_VPA_DEREG_DTL, cpu, 0);
+}
+
+static inline long register_dtl(unsigned long cpu, unsigned long vpa)
+{
+   return vpa_call(H_VPA_REG_DTL, cpu, vpa);
+}
+
+static inline long plpar_page_set_loaned(unsigned long vpa)
+{
+   unsigned long cmo_page_sz = cmo_get_page_size();
+   long rc = 0;
+   int i;
+
+   for (i = 0; !rc  i  PAGE_SIZE; i += cmo_page_sz)
+   rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa + 
i, 0);
+
+   for (i -= cmo_page_sz; rc  i != 0; i -= cmo_page_sz)
+   plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE,
+  vpa + i - cmo_page_sz, 0);
+
+   return rc;
+}
+
+static inline long plpar_page_set_active(unsigned long vpa)
+{
+   unsigned long cmo_page_sz = cmo_get_page_size();
+   long rc = 0;
+   int i;
+
+   for (i = 0; !rc  i  PAGE_SIZE; i += cmo_page_sz)
+   rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa + 
i, 0);
+
+   for (i -= cmo_page_sz; rc  i != 0; i -= cmo_page_sz)
+   plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED,
+  vpa + i - cmo_page_sz, 0);
+
+   return rc;
+}
+
+extern void vpa_init(int cpu);
+
+static inline long plpar_pte_enter(unsigned long flags,
+   unsigned long hpte_group, unsigned long hpte_v,
+   unsigned long 

[PATCH V2 5/6] cpuidle/powerpc: Backend-powerpc idle driver for powernv and pseries.

2013-07-30 Thread Deepthi Dharwar
The following patch extends the current pseries backend
idle driver to powernv platform.

Signed-off-by: Deepthi Dharwar deep...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/processor.h |2 -
 arch/powerpc/sysdev/Kconfig  |8 +-
 arch/powerpc/sysdev/Makefile |2 -
 arch/powerpc/sysdev/processor_idle.c |  132 ++
 4 files changed, 92 insertions(+), 52 deletions(-)

diff --git a/arch/powerpc/include/asm/processor.h 
b/arch/powerpc/include/asm/processor.h
index 47a35b0..e64b817 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -426,7 +426,7 @@ enum idle_boot_override {IDLE_NO_OVERRIDE = 0, 
IDLE_POWERSAVE_OFF};
 extern int powersave_nap;  /* set if nap mode can be used in idle loop */
 extern void power7_nap(void);
 
-#ifdef CONFIG_PSERIES_IDLE
+#ifdef CONFIG_POWERPC_IDLE
 extern void update_smt_snooze_delay(int cpu, int residency);
 #else
 static inline void update_smt_snooze_delay(int cpu, int residency) {}
diff --git a/arch/powerpc/sysdev/Kconfig b/arch/powerpc/sysdev/Kconfig
index 8564a3f..f61d794 100644
--- a/arch/powerpc/sysdev/Kconfig
+++ b/arch/powerpc/sysdev/Kconfig
@@ -35,11 +35,11 @@ config GE_FPGA
bool
default n
 
-config PSERIES_IDLE
-   bool Cpuidle driver for pSeries platforms
+config POWERPC_IDLE
+   bool Cpuidle driver for POWERPC platforms
depends on CPU_IDLE
-   depends on PPC_PSERIES
+   depends on PPC_PSERIES || PPC_POWERNV
default y
help
  Select this option to enable processor idle state management
- for pSeries through cpuidle subsystem.
+ for POWER and POWERNV through cpuidle subsystem.
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 93d2cdd..ec290e2 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -49,7 +49,7 @@ endif
 obj-$(CONFIG_PPC4xx_MSI)   += ppc4xx_msi.o
 obj-$(CONFIG_PPC4xx_CPM)   += ppc4xx_cpm.o
 obj-$(CONFIG_PPC4xx_GPIO)  += ppc4xx_gpio.o
-obj-$(CONFIG_PSERIES_IDLE) += processor_idle.o
+obj-$(CONFIG_POWERPC_IDLE) += processor_idle.o
 
 obj-$(CONFIG_CPM)  += cpm_common.o
 obj-$(CONFIG_CPM2) += cpm2.o cpm2_pic.o
diff --git a/arch/powerpc/sysdev/processor_idle.c 
b/arch/powerpc/sysdev/processor_idle.c
index 0d75a54..d152f540d 100644
--- a/arch/powerpc/sysdev/processor_idle.c
+++ b/arch/powerpc/sysdev/processor_idle.c
@@ -20,18 +20,18 @@
 #include asm/runlatch.h
 #include asm/plpar_wrappers.h
 
-/* Snooze Delay, pseries_idle */
+/* Snooze Delay, powerpc_idle */
 DECLARE_PER_CPU(long, smt_snooze_delay);
 
-struct cpuidle_driver pseries_idle_driver = {
-   .name = pseries_idle,
+struct cpuidle_driver powerpc_idle_driver = {
+   .name = powerpc_idle,
.owner= THIS_MODULE,
 };
 
 #define MAX_IDLE_STATE_COUNT   2
 
 static int max_idle_state = MAX_IDLE_STATE_COUNT - 1;
-static struct cpuidle_device __percpu *pseries_cpuidle_devices;
+static struct cpuidle_device __percpu *powerpc_cpuidle_devices;
 static struct cpuidle_state *cpuidle_state_table;
 
 static inline void idle_loop_prolog(unsigned long *in_purr)
@@ -55,13 +55,14 @@ static int snooze_loop(struct cpuidle_device *dev,
int index)
 {
unsigned long in_purr;
-   int cpu = dev-cpu;
 
+#ifndef PPC_POWERNV
idle_loop_prolog(in_purr);
+#endif
local_irq_enable();
set_thread_flag(TIF_POLLING_NRFLAG);
 
-   while ((!need_resched())  cpu_online(cpu)) {
+   while (!need_resched()) {
ppc64_runlatch_off();
HMT_low();
HMT_very_low();
@@ -71,7 +72,9 @@ static int snooze_loop(struct cpuidle_device *dev,
clear_thread_flag(TIF_POLLING_NRFLAG);
smp_mb();
 
+#ifndef PPC_POWERNV
idle_loop_epilog(in_purr);
+#endif
 
return index;
 }
@@ -135,10 +138,21 @@ static int shared_cede_loop(struct cpuidle_device *dev,
return index;
 }
 
+#ifdef PPC_POWERNV
+static int nap_loop(struct cpuidle_device *dev,
+   struct cpuidle_driver *drv,
+   int index)
+{
+   ppc64_runlatch_off();
+   power7_idle();
+   return index;
+}
+#endif
+
 /*
  * States for dedicated partition case.
  */
-static struct cpuidle_state dedicated_states[MAX_IDLE_STATE_COUNT] = {
+static struct cpuidle_state pseries_dedicated_states[MAX_IDLE_STATE_COUNT] = {
{ /* Snooze */
.name = snooze,
.desc = snooze,
@@ -158,7 +172,7 @@ static struct cpuidle_state 
dedicated_states[MAX_IDLE_STATE_COUNT] = {
 /*
  * States for shared partition case.
  */
-static struct cpuidle_state shared_states[MAX_IDLE_STATE_COUNT] = {
+static struct cpuidle_state pseries_shared_states[MAX_IDLE_STATE_COUNT] = {
{ /* Shared Cede */
.name = Shared Cede,
.desc = Shared Cede,
@@ -168,13 +182,34 

RE: [PATCH V2 4/6] cpuidle/pseries: Move the pseries_idle backend driver to sysdev.

2013-07-30 Thread Wang Dongsheng-B40534


 -Original Message-
 From: Deepthi Dharwar [mailto:deep...@linux.vnet.ibm.com]
 Sent: Wednesday, July 31, 2013 10:59 AM
 To: b...@kernel.crashing.org; daniel.lezc...@linaro.org; linux-
 ker...@vger.kernel.org; mich...@ellerman.id.au;
 srivatsa.b...@linux.vnet.ibm.com; pre...@linux.vnet.ibm.com;
 sva...@linux.vnet.ibm.com; linuxppc-dev@lists.ozlabs.org
 Cc: r...@sisk.pl; Wang Dongsheng-B40534; linux...@vger.kernel.org
 Subject: [PATCH V2 4/6] cpuidle/pseries: Move the pseries_idle backend
 driver to sysdev.
 
 Move pseries_idle backend driver code to arch/powerpc/sysdev
 so that the code can be used for a common driver for powernv
 and pseries. This removes a lot of code duplicacy.
 
Why not drivers/cpuidle/?

I think it should be move to drivers/cpuidle.

-dongsheng

 Signed-off-by: Deepthi Dharwar deep...@linux.vnet.ibm.com
 ---
  arch/powerpc/platforms/pseries/Kconfig  |9 -
  arch/powerpc/platforms/pseries/Makefile |1
  arch/powerpc/platforms/pseries/processor_idle.c |  384 -
 --
  arch/powerpc/sysdev/Kconfig |9 +
  arch/powerpc/sysdev/Makefile|1
  arch/powerpc/sysdev/processor_idle.c|  384
 +++
  6 files changed, 394 insertions(+), 394 deletions(-)
  delete mode 100644 arch/powerpc/platforms/pseries/processor_idle.c
  create mode 100644 arch/powerpc/sysdev/processor_idle.c
 
 diff --git a/arch/powerpc/platforms/pseries/Kconfig
 b/arch/powerpc/platforms/pseries/Kconfig
 index 62b4f80..bb59bb0 100644
 --- a/arch/powerpc/platforms/pseries/Kconfig
 +++ b/arch/powerpc/platforms/pseries/Kconfig
 @@ -119,12 +119,3 @@ config DTL
 which are accessible through a debugfs file.
 
 Say N if you are unsure.
 -
 -config PSERIES_IDLE
 - bool Cpuidle driver for pSeries platforms
 - depends on CPU_IDLE
 - depends on PPC_PSERIES
 - default y
 - help
 -   Select this option to enable processor idle state management
 -   through cpuidle subsystem.
 diff --git a/arch/powerpc/platforms/pseries/Makefile
 b/arch/powerpc/platforms/pseries/Makefile
 index 8ae0103..4b22379 100644
 --- a/arch/powerpc/platforms/pseries/Makefile
 +++ b/arch/powerpc/platforms/pseries/Makefile
 @@ -21,7 +21,6 @@ obj-$(CONFIG_HCALL_STATS)   += hvCall_inst.o
  obj-$(CONFIG_CMM)+= cmm.o
  obj-$(CONFIG_DTL)+= dtl.o
  obj-$(CONFIG_IO_EVENT_IRQ)   += io_event_irq.o
 -obj-$(CONFIG_PSERIES_IDLE)   += processor_idle.o
 
  ifeq ($(CONFIG_PPC_PSERIES),y)
  obj-$(CONFIG_SUSPEND)+= suspend.o
 diff --git a/arch/powerpc/platforms/pseries/processor_idle.c
 b/arch/powerpc/platforms/pseries/processor_idle.c
 deleted file mode 100644
 index 0d75a54..000
 --- a/arch/powerpc/platforms/pseries/processor_idle.c
 +++ /dev/null
 @@ -1,384 +0,0 @@
 -/*
 - *  processor_idle - idle state cpuidle driver.
 - *  Adapted from drivers/idle/intel_idle.c and
 - *  drivers/acpi/processor_idle.c
 - *
 - */
 -
 -#include linux/kernel.h
 -#include linux/module.h
 -#include linux/init.h
 -#include linux/moduleparam.h
 -#include linux/cpuidle.h
 -#include linux/cpu.h
 -#include linux/notifier.h
 -
 -#include asm/paca.h
 -#include asm/reg.h
 -#include asm/machdep.h
 -#include asm/firmware.h
 -#include asm/runlatch.h
 -#include asm/plpar_wrappers.h
 -
 -/* Snooze Delay, pseries_idle */
 -DECLARE_PER_CPU(long, smt_snooze_delay);
 -
 -struct cpuidle_driver pseries_idle_driver = {
 - .name = pseries_idle,
 - .owner= THIS_MODULE,
 -};
 -
 -#define MAX_IDLE_STATE_COUNT 2
 -
 -static int max_idle_state = MAX_IDLE_STATE_COUNT - 1;
 -static struct cpuidle_device __percpu *pseries_cpuidle_devices;
 -static struct cpuidle_state *cpuidle_state_table;
 -
 -static inline void idle_loop_prolog(unsigned long *in_purr)
 -{
 - *in_purr = mfspr(SPRN_PURR);
 - /*
 -  * Indicate to the HV that we are idle. Now would be
 -  * a good time to find other work to dispatch.
 -  */
 - get_lppaca()-idle = 1;
 -}
 -
 -static inline void idle_loop_epilog(unsigned long in_purr)
 -{
 - get_lppaca()-wait_state_cycles += mfspr(SPRN_PURR) - in_purr;
 - get_lppaca()-idle = 0;
 -}
 -
 -static int snooze_loop(struct cpuidle_device *dev,
 - struct cpuidle_driver *drv,
 - int index)
 -{
 - unsigned long in_purr;
 - int cpu = dev-cpu;
 -
 - idle_loop_prolog(in_purr);
 - local_irq_enable();
 - set_thread_flag(TIF_POLLING_NRFLAG);
 -
 - while ((!need_resched())  cpu_online(cpu)) {
 - ppc64_runlatch_off();
 - HMT_low();
 - HMT_very_low();
 - }
 -
 - HMT_medium();
 - clear_thread_flag(TIF_POLLING_NRFLAG);
 - smp_mb();
 -
 - idle_loop_epilog(in_purr);
 -
 - return index;
 -}
 -
 -static void check_and_cede_processor(void)
 -{
 - /*
 -  * Ensure our interrupt state is properly tracked,
 -  * also checks if no interrupt has 

RE: [PATCH V2 5/6] cpuidle/powerpc: Backend-powerpc idle driver for powernv and pseries.

2013-07-30 Thread Wang Dongsheng-B40534


 
 -static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n,
 +static int powerpc_cpuidle_add_cpu_notifier(struct notifier_block *n,
   unsigned long action, void *hcpu)
  {
   int hotcpu = (unsigned long)hcpu;
   struct cpuidle_device *dev =
 - per_cpu_ptr(pseries_cpuidle_devices, hotcpu);
 + per_cpu_ptr(powerpc_cpuidle_devices, hotcpu);
 
   if (dev  cpuidle_get_driver()) {
   switch (action) {
 @@ -235,16 +270,16 @@ static int pseries_cpuidle_add_cpu_notifier(struct
 notifier_block *n,
  }
 
  static struct notifier_block setup_hotplug_notifier = {
 - .notifier_call = pseries_cpuidle_add_cpu_notifier,
 + .notifier_call = powerpc_cpuidle_add_cpu_notifier,
  };
 
I think Daniel means move the notifier to cpuidle framework, not just powerpc.

And should be remove all about *device*. If the notifier handle using device,
you can use cpuidle_devices.

- dongsheng

 -static int __init pseries_processor_idle_init(void)
 +static int __init powerpc_processor_idle_init(void)
  {
   int retval;
 
 - retval = pseries_idle_probe();
 + retval = powerpc_idle_probe();
   if (retval)
   return retval;
 
 - pseries_cpuidle_driver_init();
 - retval = cpuidle_register_driver(pseries_idle_driver);
 + powerpc_cpuidle_driver_init();
 + retval = cpuidle_register_driver(powerpc_idle_driver);
   if (retval) {
 - printk(KERN_DEBUG Registration of pseries driver failed.\n);
 + printk(KERN_DEBUG Registration of powerpc driver failed.\n);
   return retval;
   }
 
   update_smt_snooze_delay(-1, per_cpu(smt_snooze_delay, 0));
 
 - retval = pseries_idle_devices_init();
 + retval = powerpc_idle_devices_init();
Should be remove all *device*, using cpuidle_register.

- dongsheng

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


Re: [PATCH V2 4/6] cpuidle/pseries: Move the pseries_idle backend driver to sysdev.

2013-07-30 Thread Preeti U Murthy
Hi Dongsheng,

On 07/31/2013 08:52 AM, Wang Dongsheng-B40534 wrote:
 
 
 -Original Message-
 From: Deepthi Dharwar [mailto:deep...@linux.vnet.ibm.com]
 Sent: Wednesday, July 31, 2013 10:59 AM
 To: b...@kernel.crashing.org; daniel.lezc...@linaro.org; linux-
 ker...@vger.kernel.org; mich...@ellerman.id.au;
 srivatsa.b...@linux.vnet.ibm.com; pre...@linux.vnet.ibm.com;
 sva...@linux.vnet.ibm.com; linuxppc-dev@lists.ozlabs.org
 Cc: r...@sisk.pl; Wang Dongsheng-B40534; linux...@vger.kernel.org
 Subject: [PATCH V2 4/6] cpuidle/pseries: Move the pseries_idle backend
 driver to sysdev.

 Move pseries_idle backend driver code to arch/powerpc/sysdev
 so that the code can be used for a common driver for powernv
 and pseries. This removes a lot of code duplicacy.

 Why not drivers/cpuidle/?
 
 I think it should be move to drivers/cpuidle.

Please take a look at what the cpuidle under drivers has to provide.
cpuidle has two parts to it. The front end and the back end. The front
end constitutes the cpuidle governors, registering of arch specific
cpuidle drivers, disabling and enabling of cpuidle feature. It is this
front end code which is present under drivers/cpuidle.

The arch specific cpuidle drivers which decide what needs to be done to
enter a specific idle state chosen by the cpuidle governor is what
constitutes the back end of cpuidle. This will not be in drivers/cpuidle
but in an arch/ specific code.

The cpuidle under drivers/cpuidle drives the idle power management, but
the low level handling of the entry into idle states should be taken
care of by the architecture.

Your recent patch :
cpuidle: add freescale e500 family porcessors idle support IMO should
hook onto the backend cpuidle driver that this patchset provides.

Regards
Preeti U Murthy

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


[PATCH 1/3] selftests: Add infrastructure for powerpc selftests

2013-07-30 Thread Michael Ellerman
This commit adds a powerpc subdirectory to tools/testing/selftests,
for tests that are powerpc specific.

On other architectures nothing is built. The makefile supports cross
compilation if the user sets ARCH and CROSS_COMPILE.

Signed-off-by: Michael Ellerman mich...@ellerman.id.au
---
 tools/testing/selftests/Makefile |  1 +
 tools/testing/selftests/powerpc/Makefile | 35 
 2 files changed, 36 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/Makefile

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 4cb14ca..9f3eae2 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -8,6 +8,7 @@ TARGETS += net
 TARGETS += ptrace
 TARGETS += timers
 TARGETS += vm
+TARGETS += powerpc
 
 all:
for TARGET in $(TARGETS); do \
diff --git a/tools/testing/selftests/powerpc/Makefile 
b/tools/testing/selftests/powerpc/Makefile
new file mode 100644
index 000..bade865
--- /dev/null
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -0,0 +1,35 @@
+# Makefile for powerpc selftests
+
+# ARCH can be overridden by the user for cross compiling
+ARCH ?= $(shell uname -m)
+ARCH := $(shell echo $(ARCH) | sed -e s/ppc.*/powerpc/)
+
+ifeq ($(ARCH),powerpc)
+
+GIT_VERSION = $(shell git describe --always --long --dirty || echo unknown)
+
+CC := $(CROSS_COMPILE)$(CC)
+CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='$(GIT_VERSION)' 
-I$(CURDIR) $(CFLAGS)
+
+export CC CFLAGS
+
+TARGETS =
+
+endif
+
+all:
+   @for TARGET in $(TARGETS); do \
+   $(MAKE) -C $$TARGET all; \
+   done;
+
+run_tests: all
+   @for TARGET in $(TARGETS); do \
+   $(MAKE) -C $$TARGET run_tests; \
+   done;
+
+clean:
+   @for TARGET in $(TARGETS); do \
+   $(MAKE) -C $$TARGET clean; \
+   done;
+
+.PHONY: all run_tests clean
-- 
1.8.1.2

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


[PATCH 2/3] selftests: Add support files for powerpc tests

2013-07-30 Thread Michael Ellerman
This commit adds support code used by upcoming powerpc tests.

Signed-off-by: Michael Ellerman mich...@ellerman.id.au
---
 tools/testing/selftests/powerpc/harness.c | 83 +++
 tools/testing/selftests/powerpc/subunit.h | 47 +
 tools/testing/selftests/powerpc/utils.h   | 34 +
 3 files changed, 164 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/harness.c
 create mode 100644 tools/testing/selftests/powerpc/subunit.h
 create mode 100644 tools/testing/selftests/powerpc/utils.h

diff --git a/tools/testing/selftests/powerpc/harness.c 
b/tools/testing/selftests/powerpc/harness.c
new file mode 100644
index 000..ad73a34
--- /dev/null
+++ b/tools/testing/selftests/powerpc/harness.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2013, Michael Ellerman, IBM Corp.
+ * Licensed under GPLv2.
+ */
+
+#include errno.h
+#include stdbool.h
+#include stdio.h
+#include stdlib.h
+#include sys/types.h
+#include sys/wait.h
+#include unistd.h
+
+#include subunit.h
+#include utils.h
+
+#define TIMEOUT120
+#define KILL_TIMEOUT   5
+
+
+int run_test(int (test_function)(void), char *name)
+{
+   bool terminated;
+   int rc, status;
+   pid_t pid;
+
+   /* Make sure output is flushed before forking */
+   fflush(stdout);
+
+   pid = fork();
+   if (pid == 0) {
+   exit(test_function());
+   } else if (pid == -1) {
+   perror(fork);
+   return 1;
+   }
+
+   /* Wake us up in timeout seconds */
+   alarm(TIMEOUT);
+   terminated = false;
+
+wait:
+   rc = waitpid(pid, status, 0);
+   if (rc == -1) {
+   if (errno != EINTR) {
+   printf(unknown error from waitpid\n);
+   return 1;
+   }
+
+   if (terminated) {
+   printf(!! force killing %s\n, name);
+   kill(pid, SIGKILL);
+   return 1;
+   } else {
+   printf(!! killing %s\n, name);
+   kill(pid, SIGTERM);
+   terminated = true;
+   alarm(KILL_TIMEOUT);
+   goto wait;
+   }
+   }
+
+   if (WIFEXITED(status))
+   status = WEXITSTATUS(status);
+   else
+   status = 1; /* Signal or other */
+
+   return status;
+}
+
+int test_harness(int (test_function)(void), char *name)
+{
+   int rc;
+
+   test_start(name);
+   test_set_git_version(GIT_VERSION);
+
+   rc = run_test(test_function, name);
+
+   test_finish(name, rc);
+
+   return rc;
+}
diff --git a/tools/testing/selftests/powerpc/subunit.h 
b/tools/testing/selftests/powerpc/subunit.h
new file mode 100644
index 000..98a2292
--- /dev/null
+++ b/tools/testing/selftests/powerpc/subunit.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2013, Michael Ellerman, IBM Corp.
+ * Licensed under GPLv2.
+ */
+
+#ifndef _SELFTESTS_POWERPC_SUBUNIT_H
+#define _SELFTESTS_POWERPC_SUBUNIT_H
+
+static inline void test_start(char *name)
+{
+   printf(test: %s\n, name);
+}
+
+static inline void test_failure_detail(char *name, char *detail)
+{
+   printf(failure: %s [%s]\n, name, detail);
+}
+
+static inline void test_failure(char *name)
+{
+   printf(failure: %s\n, name);
+}
+
+static inline void test_error(char *name)
+{
+   printf(error: %s\n, name);
+}
+
+static inline void test_success(char *name)
+{
+   printf(success: %s\n, name);
+}
+
+static inline void test_finish(char *name, int status)
+{
+   if (status)
+   test_failure(name);
+   else
+   test_success(name);
+}
+
+static inline void test_set_git_version(char *value)
+{
+   printf(tags: git_version:%s\n, value);
+}
+
+#endif /* _SELFTESTS_POWERPC_SUBUNIT_H */
diff --git a/tools/testing/selftests/powerpc/utils.h 
b/tools/testing/selftests/powerpc/utils.h
new file mode 100644
index 000..5851c4b
--- /dev/null
+++ b/tools/testing/selftests/powerpc/utils.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2013, Michael Ellerman, IBM Corp.
+ * Licensed under GPLv2.
+ */
+
+#ifndef _SELFTESTS_POWERPC_UTILS_H
+#define _SELFTESTS_POWERPC_UTILS_H
+
+#include stdint.h
+#include stdbool.h
+
+/* Avoid headaches with PRI?64 - just use %ll? always */
+typedef unsigned long long u64;
+typedef   signed long long s64;
+
+/* Just for familiarity */
+typedef uint32_t u32;
+typedef uint8_t u8;
+
+
+int test_harness(int (test_function)(void), char *name);
+
+
+/* Yes, this is evil */
+#define FAIL_IF(x) \
+do {   \
+   if ((x)) {  \
+   fprintf(stderr, \
+   [FAIL] Test FAILED on line %d\n, __LINE__);   \
+   return 1;   \
+   }   

[PATCH 3/3] selftests: Add test of PMU instruction counting on powerpc

2013-07-30 Thread Michael Ellerman
This commit adds a test of instruction counting using the PMU on powerpc.

Although the bulk of the code is architecture agnostic, the code needs to
run a precisely sized loop which is implemented in assembler.

Signed-off-by: Michael Ellerman mich...@ellerman.id.au
---
 tools/testing/selftests/powerpc/Makefile   |   2 +-
 tools/testing/selftests/powerpc/pmu/Makefile   |  23 
 .../selftests/powerpc/pmu/count_instructions.c | 135 +
 tools/testing/selftests/powerpc/pmu/event.c| 105 
 tools/testing/selftests/powerpc/pmu/event.h|  39 ++
 tools/testing/selftests/powerpc/pmu/loop.S |  46 +++
 6 files changed, 349 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/powerpc/pmu/Makefile
 create mode 100644 tools/testing/selftests/powerpc/pmu/count_instructions.c
 create mode 100644 tools/testing/selftests/powerpc/pmu/event.c
 create mode 100644 tools/testing/selftests/powerpc/pmu/event.h
 create mode 100644 tools/testing/selftests/powerpc/pmu/loop.S

diff --git a/tools/testing/selftests/powerpc/Makefile 
b/tools/testing/selftests/powerpc/Makefile
index bade865..7cb4744 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -13,7 +13,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror 
-DGIT_VERSION='$(GIT_VERSION)' -I$(CUR
 
 export CC CFLAGS
 
-TARGETS =
+TARGETS = pmu
 
 endif
 
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile 
b/tools/testing/selftests/powerpc/pmu/Makefile
new file mode 100644
index 000..7216f00
--- /dev/null
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -0,0 +1,23 @@
+noarg:
+   $(MAKE) -C ../
+
+PROGS := count_instructions
+EXTRA_SOURCES := ../harness.c event.c
+
+all: $(PROGS)
+
+$(PROGS): $(EXTRA_SOURCES)
+
+# loop.S can only be built 64-bit
+count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES)
+   $(CC) $(CFLAGS) -m64 -o $@ $^
+
+run_tests: all
+   @-for PROG in $(PROGS); do \
+   ./$$PROG; \
+   done;
+
+clean:
+   rm -f $(PROGS) loop.o
+
+.PHONY: all run_tests clean
diff --git a/tools/testing/selftests/powerpc/pmu/count_instructions.c 
b/tools/testing/selftests/powerpc/pmu/count_instructions.c
new file mode 100644
index 000..312b4f0
--- /dev/null
+++ b/tools/testing/selftests/powerpc/pmu/count_instructions.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2013, Michael Ellerman, IBM Corp.
+ * Licensed under GPLv2.
+ */
+
+#define _GNU_SOURCE
+
+#include stdio.h
+#include stdbool.h
+#include string.h
+#include sys/prctl.h
+
+#include event.h
+#include utils.h
+
+extern void thirty_two_instruction_loop(u64 loops);
+
+static void setup_event(struct event *e, u64 config, char *name)
+{
+   event_init_opts(e, config, PERF_TYPE_HARDWARE, name);
+
+   e-attr.disabled = 1;
+   e-attr.exclude_kernel = 1;
+   e-attr.exclude_hv = 1;
+   e-attr.exclude_idle = 1;
+}
+
+static int do_count_loop(struct event *events, u64 instructions,
+u64 overhead, bool report)
+{
+   s64 difference, expected;
+   double percentage;
+
+   prctl(PR_TASK_PERF_EVENTS_ENABLE);
+
+   /* Run for 1M instructions */
+   thirty_two_instruction_loop(instructions  5);
+
+   prctl(PR_TASK_PERF_EVENTS_DISABLE);
+
+   event_read(events[0]);
+   event_read(events[1]);
+
+   expected = instructions + overhead;
+   difference = events[0].result.value - expected;
+   percentage = (double)difference / events[0].result.value * 100;
+
+   if (report) {
+   event_report(events[0]);
+   event_report(events[1]);
+
+   printf(Looped for %llu instructions, overhead %llu\n, 
instructions, overhead);
+   printf(Expected %llu\n, expected);
+   printf(Actual   %llu\n, events[0].result.value);
+   printf(Delta%lld, %f%%\n, difference, percentage);
+   }
+
+   event_reset(events[0]);
+   event_reset(events[1]);
+
+   if (difference  0)
+   difference = -difference;
+
+   /* Tolerate a difference below 0.0001 % */
+   difference *= 1 * 100;
+   if (difference / events[0].result.value)
+   return -1;
+
+   return 0;
+}
+
+/* Count how many instructions it takes to do a null loop */
+static u64 determine_overhead(struct event *events)
+{
+   u64 current, overhead;
+   int i;
+
+   do_count_loop(events, 0, 0, false);
+   overhead = events[0].result.value;
+
+   for (i = 0; i  100; i++) {
+   do_count_loop(events, 0, 0, false);
+   current = events[0].result.value;
+   if (current  overhead) {
+   printf(Replacing overhead %llu with %llu\n, overhead, 
current);
+   overhead = current;
+   }
+   }
+
+   return overhead;
+}
+
+static int count_instructions(void)
+{
+   struct event events[2];
+   u64 

[PATCH] powerpc: handle unaligned ldbrx/stdbrx

2013-07-30 Thread Anton Blanchard

Normally when we haven't implemented an alignment handler for
a load or store instruction the process will be terminated.

The alignment handler uses the DSISR (or a pseudo one) to locate
the right handler. Unfortunately ldbrx and stdbrx overlap lfs and
stfs so we incorrectly think ldbrx is an lfs and stdbrx is an
stfs.

This bug is particularly nasty - instead of terminating the
process we apply an incorrect fixup and continue on.

With more and more overlapping instructions we should stop
creating a pseudo DSISR and index using the instruction directly,
but for now add a special case to catch ldbrx/stdbrx.

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

Index: b/arch/powerpc/kernel/align.c
===
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -764,6 +764,16 @@ int fix_alignment(struct pt_regs *regs)
nb = aligninfo[instr].len;
flags = aligninfo[instr].flags;
 
+   /* ldbrx/stdbrx overlap lfs/stfs in the DSISR unfortunately */
+   if (IS_XFORM(instruction)  ((instruction  1)  0x3ff) == 532) {
+   nb = 8;
+   flags = LD+SW;
+   } else if (IS_XFORM(instruction) 
+  ((instruction  1)  0x3ff) == 660) {
+   nb = 8;
+   flags = ST+SW;
+   }
+
/* Byteswap little endian loads and stores */
swiz = 0;
if (regs-msr  MSR_LE) {
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH 4/4] kvm: powerpc: set cache coherency only for RAM pages

2013-07-30 Thread Bhushan Bharat-R65777


 -Original Message-
 From: Wood Scott-B07421
 Sent: Wednesday, July 31, 2013 12:19 AM
 To: Bhushan Bharat-R65777
 Cc: Benjamin Herrenschmidt; Alexander Graf; kvm-...@vger.kernel.org;
 k...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421
 Subject: Re: [PATCH 4/4] kvm: powerpc: set cache coherency only for RAM pages
 
 On 07/30/2013 11:22:54 AM, Bhushan Bharat-R65777 wrote:
  diff --git a/arch/powerpc/kvm/e500_mmu_host.c
  b/arch/powerpc/kvm/e500_mmu_host.c
  index 5cbdc8f..a48c13f 100644
  --- a/arch/powerpc/kvm/e500_mmu_host.c
  +++ b/arch/powerpc/kvm/e500_mmu_host.c
  @@ -40,6 +40,84 @@
 
   static struct kvmppc_e500_tlb_params host_tlb_params[E500_TLB_NUM];
 
  +/*
  + * find_linux_pte returns the address of a linux pte for a given
  + * effective address and directory.  If not found, it returns zero.
  + */
  +static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea) {
  +pgd_t *pg;
  +pud_t *pu;
  +pmd_t *pm;
  +pte_t *pt = NULL;
  +
  +pg = pgdir + pgd_index(ea);
  +if (!pgd_none(*pg)) {
  +pu = pud_offset(pg, ea);
  +if (!pud_none(*pu)) {
  +pm = pmd_offset(pu, ea);
  +if (pmd_present(*pm))
  +pt = pte_offset_kernel(pm, ea);
  +}
  +}
  +return pt;
  +}
 
 How is this specific to KVM or e500?
 
  +#ifdef CONFIG_HUGETLB_PAGE
  +pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
  + unsigned *shift); #else static
  +inline pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir,
  unsigned long ea,
  +   unsigned *shift) {
  +if (shift)
  +*shift = 0;
  +return find_linux_pte(pgdir, ea); } #endif /*
  +!CONFIG_HUGETLB_PAGE */
 
 This is already declared in asm/pgtable.h.  If we need a non-hugepage
 alternative, that should also go in asm/pgtable.h.
 
  +/*
  + * Lock and read a linux PTE.  If it's present and writable,
  atomically
  + * set dirty and referenced bits and return the PTE, otherwise
  return 0.
  + */
  +static inline pte_t kvmppc_read_update_linux_pte(pte_t *p, int
  writing)
  +{
  +   pte_t pte = pte_val(*p);
  +
  +   if (pte_present(pte)) {
  +   pte = pte_mkyoung(pte);
  +   if (writing  pte_write(pte))
  +   pte = pte_mkdirty(pte);
  +   }
  +
  +   *p = pte;
  +
  +   return pte;
  +}
  +
  +static pte_t lookup_linux_pte(pgd_t *pgdir, unsigned long hva,
  + int writing, unsigned long *pte_sizep) {
  +   pte_t *ptep;
  +   unsigned long ps = *pte_sizep;
  +   unsigned int shift;
  +
  +   ptep = find_linux_pte_or_hugepte(pgdir, hva, shift);
  +   if (!ptep)
  +   return __pte(0);
  +   if (shift)
  +   *pte_sizep = 1ul  shift;
  +   else
  +   *pte_sizep = PAGE_SIZE;
  +
  +   if (ps  *pte_sizep)
  +   return __pte(0);
  +   if (!pte_present(*ptep))
  +   return __pte(0);
  +
  +   return kvmppc_read_update_linux_pte(ptep, writing); }
  +
 
 None of this belongs in this file either.
 
  @@ -326,8 +405,8 @@ static void kvmppc_e500_setup_stlbe(
 
  /* Force IPROT=0 for all guest mappings. */
  stlbe-mas1 = MAS1_TSIZE(tsize) | get_tlb_sts(gtlbe) |
  MAS1_VALID;
  -   stlbe-mas2 = (gvaddr  MAS2_EPN) |
  - e500_shadow_mas2_attrib(gtlbe-mas2, pfn);
  +   stlbe-mas2 = (gvaddr  MAS2_EPN) | (ref-flags 
  E500_TLB_WIMGE_MASK);
  +//   e500_shadow_mas2_attrib(gtlbe-mas2, pfn);
 
 MAS2_E and MAS2_G should be safe to come from the guest.

This is handled when setting WIMGE in ref-flags.

 
 How does this work for TLB1?  One ref corresponds to one guest entry, which 
 may
 correspond to multiple host entries, potentially each with different WIM
 settings.

Yes, one ref corresponds to one guest entry. To understand how this will work 
when a one guest tlb1 entry may maps to many host tlb0/1 entry; 
on guest tlbwe, KVM setup one guest tlb entry and then pre-map one host tlb 
entry (out of many) and ref (ref-pfn etc) points to this pre-map entry for 
that guest entry.
Now a guest TLB miss happens which falls on same guest tlb entry and but 
demands another host tlb entry. In that flow we change/overwrite ref (ref-pfn 
etc) to point to new host mapping for same guest mapping.

 
  stlbe-mas7_3 = ((u64)pfn  PAGE_SHIFT) |
  e500_shadow_mas3_attrib(gtlbe-mas7_3, pr);
 
  @@ -346,6 +425,8 @@ static inline int kvmppc_e500_shadow_map(struct
  kvmppc_vcpu_e500 *vcpu_e500,
  unsigned long hva;
  int pfnmap = 0;
  int tsize = BOOK3E_PAGESZ_4K;
  +   pte_t pte;
  +   int wimg = 0;
 
  /*
   * Translate guest physical to true physical, acquiring @@

RE: [PATCH V2 4/6] cpuidle/pseries: Move the pseries_idle backend driver to sysdev.

2013-07-30 Thread Wang Dongsheng-B40534
Hi Preeti,

 -Original Message-
 From: Preeti U Murthy [mailto:pre...@linux.vnet.ibm.com]
 Sent: Wednesday, July 31, 2013 12:00 PM
 To: Wang Dongsheng-B40534
 Cc: Deepthi Dharwar; b...@kernel.crashing.org; daniel.lezc...@linaro.org;
 linux-ker...@vger.kernel.org; mich...@ellerman.id.au;
 srivatsa.b...@linux.vnet.ibm.com; sva...@linux.vnet.ibm.com; linuxppc-
 d...@lists.ozlabs.org; r...@sisk.pl; linux...@vger.kernel.org
 Subject: Re: [PATCH V2 4/6] cpuidle/pseries: Move the pseries_idle
 backend driver to sysdev.
 
 Hi Dongsheng,
 
 On 07/31/2013 08:52 AM, Wang Dongsheng-B40534 wrote:
 
 
  -Original Message-
  From: Deepthi Dharwar [mailto:deep...@linux.vnet.ibm.com]
  Sent: Wednesday, July 31, 2013 10:59 AM
  To: b...@kernel.crashing.org; daniel.lezc...@linaro.org; linux-
  ker...@vger.kernel.org; mich...@ellerman.id.au;
  srivatsa.b...@linux.vnet.ibm.com; pre...@linux.vnet.ibm.com;
  sva...@linux.vnet.ibm.com; linuxppc-dev@lists.ozlabs.org
  Cc: r...@sisk.pl; Wang Dongsheng-B40534; linux...@vger.kernel.org
  Subject: [PATCH V2 4/6] cpuidle/pseries: Move the pseries_idle
  backend driver to sysdev.
 
  Move pseries_idle backend driver code to arch/powerpc/sysdev so that
  the code can be used for a common driver for powernv and pseries.
  This removes a lot of code duplicacy.
 
  Why not drivers/cpuidle/?
 
  I think it should be move to drivers/cpuidle.
 
 Please take a look at what the cpuidle under drivers has to provide.
 cpuidle has two parts to it. The front end and the back end. The front
 end constitutes the cpuidle governors, registering of arch specific
 cpuidle drivers, disabling and enabling of cpuidle feature. It is this
 front end code which is present under drivers/cpuidle.
 
 The arch specific cpuidle drivers which decide what needs to be done to
 enter a specific idle state chosen by the cpuidle governor is what
 constitutes the back end of cpuidle. This will not be in drivers/cpuidle
 but in an arch/ specific code.
 
 The cpuidle under drivers/cpuidle drives the idle power management, but
 the low level handling of the entry into idle states should be taken care
 of by the architecture.
 
 Your recent patch :
 cpuidle: add freescale e500 family porcessors idle support IMO should
 hook onto the backend cpuidle driver that this patchset provides.
 
Sorry, I don't think so, cpuidle framework has been already very common.
Here we just need to do state definition and handling. I wonder whether
we need this layer.

If your handle is platform dependent, it should be in arch/platform.

If it is only for some platforms and the operation of these platforms can be
multiplexed, Why cannot as a driver to put into driver/cpuidle?

If it a general driver, I think we can put some common operating to 
driver/cpuidle
and make the platform specific code to arch/powerpc/platform.

This patch include front end and back end, not just back end.

This patch include too many state of different platforms and handle function. 
This state
and handle that should belong to itself platforms. Not a general way. If 
Deepthi will do
a general powerpc cpuidle, I think, it's cannot just using the macro to 
distinguish
platform. the front end code maybe move to driver/cpuidle(drvier register) 
should be better,
make the Low Power State and what should be handle to arch/powerpc/platform/**, 
because different
platforms have different state of low power consumption, and the processing 
method.
The front end can provide some general methods to register into general powerpc 
cpuidle driver.

-dongsheng

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