RE: [PATCH V2] QorIQ/TMU: add TMU node to device tree for QorIQ T104x

2015-05-25 Thread Hongtao Jia
Hi Scott,

Eduardo indicated that "calibration" property should add "fsl" prefix.
I updated the patch.
Any other comments?
If not I will send V3 soon.

Thanks.

---
Best Regards,
Hongtao


> -Original Message-
> From: Jia Hongtao [mailto:hongtao@freescale.com]
> Sent: Wednesday, April 15, 2015 4:18 PM
> To: Wood Scott-B07421
> Cc: linuxppc-dev@lists.ozlabs.org; devicet...@vger.kernel.org;
> robh...@kernel.org; rui.zh...@intel.com; Jia Hongtao-B38951
> Subject: [PATCH V2] QorIQ/TMU: add TMU node to device tree for QorIQ
> T104x
> 
> This is Thermal Monitoring Unit for QorIQ platform.
> 
> Signed-off-by: Jia Hongtao 
> ---
> Changes from V1:
> * Provide more details on compatible and calibration properties.
> 
>  .../devicetree/bindings/thermal/qoriq-thermal.txt  | 68
> ++
>  arch/powerpc/boot/dts/fsl/qoriq-tmu-t104xsi.dtsi   | 82
> ++
>  arch/powerpc/boot/dts/fsl/t1040si-post.dtsi|  1 +
>  3 files changed, 151 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/thermal/qoriq-
> thermal.txt
>  create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-tmu-t104xsi.dtsi
> 
> diff --git a/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
> b/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
> new file mode 100644
> index 000..48e7fff
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
> @@ -0,0 +1,68 @@
> +* Thermal Monitoring Unit (TMU) on Freescale QorIQ SoCs
> +
> +Required properties:
> +- compatible : Must include "fsl,qoriq-tmu". The version of the device
> is
> + determined by the TMU IP Block Revision Register (IPBRR0) at
> + offset 0x0BF8.
> + Table of correspondences between IPBRR0 values and example  chips:
> + Value   Device
> + --  -
> + 0x01900102  T1040
> +- reg : Address range of TMU registers.
> +- interrupts : Contains the interrupt for TMU.
> +- calibration : Calibration table for TMU. This is required to determine
> + what a specific sensor reading translates to in degrees Celsius.
> + There are four calibration config ranges, for each range we need
> + a couple of calibration data formatted like .
> + Freescale provides the data required.
> +
> +Example:
> +
> +tmu@f {
> + compatible = "fsl,qoriq-tmu";
> + reg = <0xf 0x1000>;
> + interrupts = <18 2 0 0>;
> + calibration = <0x 0x000f
> +0x0001 0x0017
> +0x0002 0x001e
> +0x0003 0x0026
> +0x0004 0x002e
> +0x0005 0x0035
> +0x0006 0x003d
> +0x0007 0x0044
> +0x0008 0x004c
> +0x0009 0x0053
> +0x000a 0x005b
> +0x000b 0x0062
> +
> +0x0001 0x0011
> +0x00010001 0x0019
> +0x00010002 0x0021
> +0x00010003 0x002a
> +0x00010004 0x0032
> +0x00010005 0x003a
> +0x00010006 0x0042
> +0x00010007 0x004b
> +0x00010008 0x0053
> +0x00010009 0x005b
> +0x0001000a 0x0063
> +
> +0x0002 0x0012
> +0x00020001 0x001b
> +0x00020002 0x0024
> +0x00020003 0x002c
> +0x00020004 0x0035
> +0x00020005 0x003d
> +0x00020006 0x0046
> +0x00020007 0x004e
> +0x00020008 0x0057
> +
> +0x0003 0x0009
> +0x00030001 0x0011
> +0x00030002 0x0019
> +0x00030003 0x0021
> +0x00030004 0x0029
> +0x00030005 0x0031
> +0x00030006 0x0039
> +0x00030007 0x0041>;
> +};
> diff --git a/arch/powerpc/boot/dts/fsl/qoriq-tmu-t104xsi.dtsi
> b/arch/powerpc/boot/dts/fsl/qoriq-tmu-t104xsi.dtsi
> new file mode 100644
> index 000..d85c77d
> --- /dev/null
> +++ b/arch/powerpc/boot/dts/fsl/qoriq-tmu-t104xsi.dtsi
> @@ -0,0 +1,82 @@
> +/*
> + * QorIQ TMU device tree stub [ controller @ offset 0xf ]
> + *
> + * Copyright 2015 Freescale Semiconductor Inc.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> are met:
> + * * Redistributions of source code must retain the above copyright
> + *   notice, this list of conditions and the following disclaimer.
> + * * Redistributions in binary fo

[PATCH 2/2] powerpc: Non relocatable system call doesn't need a trampoline

2015-05-25 Thread Anton Blanchard
We need to use a trampoline when using LOAD_HANDLER(), because the
destination needs to be in the first 64kB. An absolute branch has
no such limitations, so just jump there.

Signed-off-by: Anton Blanchard 
---
 arch/powerpc/kernel/exceptions-64s.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index cf8c1b5..0a0399c2 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -79,7 +79,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
\
mfspr   r12,SPRN_SRR1 ; \
li  r10,MSR_RI ;\
mtmsrd  r10,1 ; /* Set RI (EE=0) */ \
-   b   system_call_entry ;
+   b   system_call_common ;
 #endif
 
 /*
-- 
2.1.4

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

[PATCH 1/2] powerpc: Relocatable system call no longer uses the LR

2015-05-25 Thread Anton Blanchard
We had some code to restore the LR in the relocatable system call path
back when we used the LR to do an indirect branch.

Commit 6a404806dfce ("powerpc: Avoid link stack corruption in MMU
on syscall entry path") changed this to use the CTR which is volatile
across system calls so does not need restoring.

Remove the stale comment and the restore of the LR.

Signed-off-by: Anton Blanchard 
---
 arch/powerpc/kernel/exceptions-64s.S | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 9519e6b..cf8c1b5 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -59,14 +59,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)  
\
 
 #if defined(CONFIG_RELOCATABLE)
/*
-* We can't branch directly; in the direct case we use LR
-* and system_call_entry restores LR.  (We thus need to move
-* LR to r10 in the RFID case too.)
+* We can't branch directly so we do it via the CTR which
+* is volatile across system calls.
 */
 #define SYSCALL_PSERIES_2_DIRECT   \
mflrr10 ;   \
ld  r12,PACAKBASE(r13) ;\
-   LOAD_HANDLER(r12, system_call_entry_direct) ;   \
+   LOAD_HANDLER(r12, system_call_entry) ;  \
mtctr   r12 ;   \
mfspr   r12,SPRN_SRR1 ; \
/* Re-use of r13... No spare regs to do this */ \
@@ -80,7 +79,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
\
mfspr   r12,SPRN_SRR1 ; \
li  r10,MSR_RI ;\
mtmsrd  r10,1 ; /* Set RI (EE=0) */ \
-   b   system_call_entry_direct ;
+   b   system_call_entry ;
 #endif
 
 /*
@@ -969,13 +968,6 @@ hv_facility_unavailable_relon_trampoline:
 __end_interrupts:
 
.align  7
-system_call_entry_direct:
-#if defined(CONFIG_RELOCATABLE)
-   /* The first level prologue may have used LR to get here, saving
-* orig in r10.  To save hacking/ifdeffing common code, restore here.
-*/
-   mtlrr10
-#endif
 system_call_entry:
b   system_call_common
 
-- 
2.1.4

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

[PATCH] powerpc/perf: Fix book3s kernel to userspace backtraces

2015-05-25 Thread Anton Blanchard
When we take a PMU exception or a software event we call
perf_read_regs(). This overloads regs->result with a boolean that
describes if we should use the sampled instruction address register
(SIAR) or the regs.

If the exception is in kernel, we start with the kernel regs and
backtrace through the kernel stack. At this point we switch to the
userspace regs and backtrace the user stack with perf_callchain_user().

Unfortunately these regs have not got the perf_read_regs() treatment,
so regs->result could be anything. If it is non zero,
perf_instruction_pointer() decides to use the SIAR, and we get issues
like this:

0.11%  qemu-system-ppc  [kernel.kallsyms][k] _raw_spin_lock_irqsave
   |
   ---_raw_spin_lock_irqsave
  |
  |--52.35%-- 0
  |  |
  |  |--46.39%-- __hrtimer_start_range_ns
  |  |  kvmppc_run_core
  |  |  kvmppc_vcpu_run_hv
  |  |  kvmppc_vcpu_run
  |  |  kvm_arch_vcpu_ioctl_run
  |  |  kvm_vcpu_ioctl
  |  |  do_vfs_ioctl
  |  |  sys_ioctl
  |  |  system_call
  |  |  |
  |  |  |--67.08%-- _raw_spin_lock_irqsave <--- hi mum
  |  |  |  |
  |  |  |   --100.00%-- 0x7e714
  |  |  | 0x7e714

Notice the bogus _raw_spin_irqsave when we transition from kernel
(system_call) to userspace (0x7e714). We inserted what was in the SIAR.

Add a check in regs_use_siar() to check that the regs in question
are from a PMU exception. With this fix the backtrace makes sense:

 0.47%  qemu-system-ppc  [kernel.vmlinux] [k] _raw_spin_lock_irqsave
|
---_raw_spin_lock_irqsave
   |
   |--53.83%-- 0
   |  |
   |  |--44.73%-- hrtimer_try_to_cancel
   |  |  kvmppc_start_thread
   |  |  kvmppc_run_core
   |  |  kvmppc_vcpu_run_hv
   |  |  kvmppc_vcpu_run
   |  |  kvm_arch_vcpu_ioctl_run
   |  |  kvm_vcpu_ioctl
   |  |  do_vfs_ioctl
   |  |  sys_ioctl
   |  |  system_call
   |  |  __ioctl
   |  |  0x7e714
   |  |  0x7e714

Signed-off-by: Anton Blanchard 
---
 arch/powerpc/perf/core-book3s.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 12b6384..42a3725 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -131,7 +131,10 @@ static void pmao_restore_workaround(bool ebb) { }
 
 static bool regs_use_siar(struct pt_regs *regs)
 {
-   return !!regs->result;
+   if ((TRAP(regs) == 0xf00) && regs->result)
+   return true;
+
+   return false;
 }
 
 /*
-- 
2.1.4

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

Re: [PATCH V2 2/2] powerpc/configs: Replace pseries_le_defconfig with a Makefile target using merge_config

2015-05-25 Thread Samuel Mendoza-Jonas
Reviewed-by: Samuel Mendoza-Jonas 

On 26/05/15 11:36, Cyril Bur wrote:
> Rather than continuing to maintain a copy of pseries_defconfig with enabled
> CONFIG_CPU_LITTLE_ENDIAN, use the generic merge_config script and use an
> le.config to enable little endian on top of pseries_defconfig without the
> need for a duplicated _defconfig file.
> 
> This method will require less maintenance in the future and will ensure
> that both 'defconfigs' are always in sync.
> 
> It is worth noting that the seemingly more simple approach of:
> pseries_le_defconfig: pseries_defconfig
>   $(Q)$(MAKE) le.config
> Will not work when building using O=builddir.
> The obvious fix to that
> pseries_le_defconfig:
>   $(Q)$(MAKE) -f $(srctree)/Makefile pseries_defconfig le.config
> Will result in options that get selected by other options having 'select
> CONFIG_FOO' in the defconfig file possibly remaining selected after the
> merge with le.config, when they would not have been set by using an actual
> pseries_le_defconfig file. As a result this has caused differences in the
> generated .config files from when there were actual pseries_le_defconfig
> and pseries_defconfg files.
> 
> The solution is to ensure to only invoke a config target once so that it
> has all the information it needs to correctly set all the parameters. This
> is done through the explicit call to make olddefconfig
> 
> Signed-off-by: Cyril Bur 
> ---
> V2: Rework to have olddefconfig (or equivalent) only called once.
> Improved to make writing *_defconfig targets easier and have the
>   targets look cleaner.
> 
>  arch/powerpc/Makefile |  15 ++
>  arch/powerpc/configs/le.config|   1 +
>  arch/powerpc/configs/pseries_le_defconfig | 319 
> --
>  3 files changed, 16 insertions(+), 319 deletions(-)
>  create mode 100644 arch/powerpc/configs/le.config
>  delete mode 100644 arch/powerpc/configs/pseries_le_defconfig
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 07a4808..2cafce6 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -269,6 +269,21 @@ bootwrapper_install:
>  %.dtb: scripts
>   $(Q)$(MAKE) ARCH=ppc64 $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
>  
> +#Used to create 'merged defconfigs'
> +#Should be $(call)'ed with the first argument as the defconfig on which to
> +#base and with a space separated list of .config files to merge, without
> +#the .config suffix.
> +define merge_into_defconfig
> +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
> + -m -O $(objtree) $(srctree)/arch/$(SRCARCH)/configs/$(1) \
> + $(foreach 
> config,$(2),$(srctree)/arch/$(SRCARCH)/configs/$(config).config)
> +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
> +endef
> +
> +PHONY += pseries_le_defconfig
> +pseries_le_defconfig:
> + $(call merge_into_defconfig,pseries_defconfig,le)
> +
>  define archhelp
>@echo '* zImage  - Build default images selected by kernel config'
>@echo '  zImage.*- Compressed kernel image 
> (arch/$(ARCH)/boot/zImage.*)'
> diff --git a/arch/powerpc/configs/le.config b/arch/powerpc/configs/le.config
> new file mode 100644
> index 000..ee43fdb
> --- /dev/null
> +++ b/arch/powerpc/configs/le.config
> @@ -0,0 +1 @@
> +CONFIG_CPU_LITTLE_ENDIAN=y
> diff --git a/arch/powerpc/configs/pseries_le_defconfig 
> b/arch/powerpc/configs/pseries_le_defconfig
> deleted file mode 100644
> index 09bc96e..000
> --- a/arch/powerpc/configs/pseries_le_defconfig
> +++ /dev/null
> @@ -1,319 +0,0 @@
> -CONFIG_PPC64=y
> -CONFIG_SMP=y
> -CONFIG_NR_CPUS=2048
> -CONFIG_CPU_LITTLE_ENDIAN=y
> -CONFIG_SYSVIPC=y
> -CONFIG_POSIX_MQUEUE=y
> -CONFIG_FHANDLE=y
> -CONFIG_AUDIT=y
> -CONFIG_AUDITSYSCALL=y
> -CONFIG_IRQ_DOMAIN_DEBUG=y
> -CONFIG_NO_HZ=y
> -CONFIG_HIGH_RES_TIMERS=y
> -CONFIG_TASKSTATS=y
> -CONFIG_TASK_DELAY_ACCT=y
> -CONFIG_TASK_XACCT=y
> -CONFIG_TASK_IO_ACCOUNTING=y
> -CONFIG_IKCONFIG=y
> -CONFIG_IKCONFIG_PROC=y
> -CONFIG_NUMA_BALANCING=y
> -CONFIG_NUMA_BALANCING_DEFAULT_ENABLED=y
> -CONFIG_CGROUPS=y
> -CONFIG_CGROUP_FREEZER=y
> -CONFIG_CGROUP_DEVICE=y
> -CONFIG_CPUSETS=y
> -CONFIG_CGROUP_CPUACCT=y
> -CONFIG_MEMCG=y
> -CONFIG_MEMCG_SWAP=y
> -CONFIG_CGROUP_PERF=y
> -CONFIG_CGROUP_SCHED=y
> -CONFIG_USER_NS=y
> -CONFIG_BLK_DEV_INITRD=y
> -# CONFIG_COMPAT_BRK is not set
> -CONFIG_PROFILING=y
> -CONFIG_OPROFILE=y
> -CONFIG_KPROBES=y
> -CONFIG_JUMP_LABEL=y
> -CONFIG_MODULES=y
> -CONFIG_MODULE_UNLOAD=y
> -CONFIG_MODVERSIONS=y
> -CONFIG_MODULE_SRCVERSION_ALL=y
> -CONFIG_PARTITION_ADVANCED=y
> -CONFIG_PPC_SPLPAR=y
> -CONFIG_SCANLOG=m
> -CONFIG_PPC_SMLPAR=y
> -CONFIG_DTL=y
> -# CONFIG_PPC_PMAC is not set
> -CONFIG_RTAS_FLASH=m
> -CONFIG_IBMEBUS=y
> -CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
> -CONFIG_HZ_100=y
> -CONFIG_BINFMT_MISC=m
> -CONFIG_PPC_TRANSACTIONAL_MEM=y
> -CONFIG_KEXEC=y
> -CONFIG_IRQ_ALL_CPUS=y
> -CONFIG_MEMORY_HOTPLUG=y
> -CONFIG_MEMORY_HOTREMOVE=y
> -CONFIG_KSM=y
> -CONFIG_TRANSPARENT_HUGEPAGE=y

[PATCH V2 1/2] powerpc/configs: Merge pseries_defconfig and pseries_le_defconfig

2015-05-25 Thread Cyril Bur
These two configs should be identical with the exception of big or little
endian.

The big endian version has XMON_DEFAULT turned on while the little endian
has XMON_DEFAULT not set. It makes the most sense for defconfigs not to use
xmon by default, production systems should get back up as quickly as
possible, not sit in xmon.

In the event debugging is required, the option can be enabled or xmon=on
can be specified on commandline.

Signed-off-by: Cyril Bur 
---
V2: Removes XMON_DEFAULT from big endian after Antons suggestion that it
should be a default for production systems. 

 arch/powerpc/configs/pseries_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/configs/pseries_defconfig 
b/arch/powerpc/configs/pseries_defconfig
index c2e39f6..4da8260 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -297,7 +297,6 @@ CONFIG_CODE_PATCHING_SELFTEST=y
 CONFIG_FTR_FIXUP_SELFTEST=y
 CONFIG_MSI_BITMAP_SELFTEST=y
 CONFIG_XMON=y
-CONFIG_XMON_DEFAULT=y
 CONFIG_CRYPTO_TEST=m
 CONFIG_CRYPTO_PCBC=m
 CONFIG_CRYPTO_HMAC=y
-- 
1.9.1

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

[PATCH V2 2/2] powerpc/configs: Replace pseries_le_defconfig with a Makefile target using merge_config

2015-05-25 Thread Cyril Bur
Rather than continuing to maintain a copy of pseries_defconfig with enabled
CONFIG_CPU_LITTLE_ENDIAN, use the generic merge_config script and use an
le.config to enable little endian on top of pseries_defconfig without the
need for a duplicated _defconfig file.

This method will require less maintenance in the future and will ensure
that both 'defconfigs' are always in sync.

It is worth noting that the seemingly more simple approach of:
pseries_le_defconfig: pseries_defconfig
$(Q)$(MAKE) le.config
Will not work when building using O=builddir.
The obvious fix to that
pseries_le_defconfig:
$(Q)$(MAKE) -f $(srctree)/Makefile pseries_defconfig le.config
Will result in options that get selected by other options having 'select
CONFIG_FOO' in the defconfig file possibly remaining selected after the
merge with le.config, when they would not have been set by using an actual
pseries_le_defconfig file. As a result this has caused differences in the
generated .config files from when there were actual pseries_le_defconfig
and pseries_defconfg files.

The solution is to ensure to only invoke a config target once so that it
has all the information it needs to correctly set all the parameters. This
is done through the explicit call to make olddefconfig

Signed-off-by: Cyril Bur 
---
V2: Rework to have olddefconfig (or equivalent) only called once.
Improved to make writing *_defconfig targets easier and have the
  targets look cleaner.

 arch/powerpc/Makefile |  15 ++
 arch/powerpc/configs/le.config|   1 +
 arch/powerpc/configs/pseries_le_defconfig | 319 --
 3 files changed, 16 insertions(+), 319 deletions(-)
 create mode 100644 arch/powerpc/configs/le.config
 delete mode 100644 arch/powerpc/configs/pseries_le_defconfig

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 07a4808..2cafce6 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -269,6 +269,21 @@ bootwrapper_install:
 %.dtb: scripts
$(Q)$(MAKE) ARCH=ppc64 $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
 
+#Used to create 'merged defconfigs'
+#Should be $(call)'ed with the first argument as the defconfig on which to
+#base and with a space separated list of .config files to merge, without
+#the .config suffix.
+define merge_into_defconfig
+$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
+   -m -O $(objtree) $(srctree)/arch/$(SRCARCH)/configs/$(1) \
+   $(foreach 
config,$(2),$(srctree)/arch/$(SRCARCH)/configs/$(config).config)
+$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
+endef
+
+PHONY += pseries_le_defconfig
+pseries_le_defconfig:
+   $(call merge_into_defconfig,pseries_defconfig,le)
+
 define archhelp
   @echo '* zImage  - Build default images selected by kernel config'
   @echo '  zImage.*- Compressed kernel image 
(arch/$(ARCH)/boot/zImage.*)'
diff --git a/arch/powerpc/configs/le.config b/arch/powerpc/configs/le.config
new file mode 100644
index 000..ee43fdb
--- /dev/null
+++ b/arch/powerpc/configs/le.config
@@ -0,0 +1 @@
+CONFIG_CPU_LITTLE_ENDIAN=y
diff --git a/arch/powerpc/configs/pseries_le_defconfig 
b/arch/powerpc/configs/pseries_le_defconfig
deleted file mode 100644
index 09bc96e..000
--- a/arch/powerpc/configs/pseries_le_defconfig
+++ /dev/null
@@ -1,319 +0,0 @@
-CONFIG_PPC64=y
-CONFIG_SMP=y
-CONFIG_NR_CPUS=2048
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_SYSVIPC=y
-CONFIG_POSIX_MQUEUE=y
-CONFIG_FHANDLE=y
-CONFIG_AUDIT=y
-CONFIG_AUDITSYSCALL=y
-CONFIG_IRQ_DOMAIN_DEBUG=y
-CONFIG_NO_HZ=y
-CONFIG_HIGH_RES_TIMERS=y
-CONFIG_TASKSTATS=y
-CONFIG_TASK_DELAY_ACCT=y
-CONFIG_TASK_XACCT=y
-CONFIG_TASK_IO_ACCOUNTING=y
-CONFIG_IKCONFIG=y
-CONFIG_IKCONFIG_PROC=y
-CONFIG_NUMA_BALANCING=y
-CONFIG_NUMA_BALANCING_DEFAULT_ENABLED=y
-CONFIG_CGROUPS=y
-CONFIG_CGROUP_FREEZER=y
-CONFIG_CGROUP_DEVICE=y
-CONFIG_CPUSETS=y
-CONFIG_CGROUP_CPUACCT=y
-CONFIG_MEMCG=y
-CONFIG_MEMCG_SWAP=y
-CONFIG_CGROUP_PERF=y
-CONFIG_CGROUP_SCHED=y
-CONFIG_USER_NS=y
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_COMPAT_BRK is not set
-CONFIG_PROFILING=y
-CONFIG_OPROFILE=y
-CONFIG_KPROBES=y
-CONFIG_JUMP_LABEL=y
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-CONFIG_MODVERSIONS=y
-CONFIG_MODULE_SRCVERSION_ALL=y
-CONFIG_PARTITION_ADVANCED=y
-CONFIG_PPC_SPLPAR=y
-CONFIG_SCANLOG=m
-CONFIG_PPC_SMLPAR=y
-CONFIG_DTL=y
-# CONFIG_PPC_PMAC is not set
-CONFIG_RTAS_FLASH=m
-CONFIG_IBMEBUS=y
-CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
-CONFIG_HZ_100=y
-CONFIG_BINFMT_MISC=m
-CONFIG_PPC_TRANSACTIONAL_MEM=y
-CONFIG_KEXEC=y
-CONFIG_IRQ_ALL_CPUS=y
-CONFIG_MEMORY_HOTPLUG=y
-CONFIG_MEMORY_HOTREMOVE=y
-CONFIG_KSM=y
-CONFIG_TRANSPARENT_HUGEPAGE=y
-CONFIG_PPC_64K_PAGES=y
-CONFIG_PPC_SUBPAGE_PROT=y
-CONFIG_SCHED_SMT=y
-CONFIG_HOTPLUG_PCI=y
-CONFIG_HOTPLUG_PCI_RPA=m
-CONFIG_HOTPLUG_PCI_RPA_DLPAR=m
-CONFIG_NET=y
-CONFIG_PACKET=y
-CONFIG_UNIX=y
-CONFIG_XFRM_USER=m
-CONFIG_NET_KEY=m
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-CONFIG_NET_IPIP=y
-CONFIG_SYN_COOKIES=y
-CONFIG_INET_AH=m
-CONFIG_

Re: [PATCH 12/19] cxl: Export some symbols

2015-05-25 Thread Michael Neuling
On Thu, 2015-05-21 at 19:16 +1000, Ian Munsie wrote:
> > +void assign_psn_space(struct cxl_context *ctx);
> 
> Should we consider renaming this to cxl_assign_psn_space to namespace it
> now that it's potentially callable from elsewhere in the kernel?
> 
> > +int afu_check_and_enable(struct cxl_afu *afu);
> 
> Likewise?

Yep, I just resent with cxl_ added.

Mikey

> Acked-by: Ian Munsie 
> 
> -Ian
> 

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

[PATCH v2 1/1] KVM: PPC: Book3S: correct width in XER handling

2015-05-25 Thread Sam Bobroff
In 64 bit kernels, the Fixed Point Exception Register (XER) is a 64
bit field (e.g. in kvm_regs and kvm_vcpu_arch) and in most places it is
accessed as such.

This patch corrects places where it is accessed as a 32 bit field by a
64 bit kernel.  In some cases this is via a 32 bit load or store
instruction which, depending on endianness, will cause either the
lower or upper 32 bits to be missed.  In another case it is cast as a
u32, causing the upper 32 bits to be cleared.

This patch corrects those places by extending the access methods to
64 bits.

Signed-off-by: Sam Bobroff 
---

v2:

Also extend kvmppc_book3s_shadow_vcpu.xer to 64 bit.

 arch/powerpc/include/asm/kvm_book3s.h |4 ++--
 arch/powerpc/include/asm/kvm_book3s_asm.h |2 +-
 arch/powerpc/kvm/book3s_hv_rmhandlers.S   |6 +++---
 arch/powerpc/kvm/book3s_segment.S |4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_book3s.h 
b/arch/powerpc/include/asm/kvm_book3s.h
index b91e74a..05a875a 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -225,12 +225,12 @@ static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
return vcpu->arch.cr;
 }
 
-static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
+static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
 {
vcpu->arch.xer = val;
 }
 
-static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
+static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
 {
return vcpu->arch.xer;
 }
diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h 
b/arch/powerpc/include/asm/kvm_book3s_asm.h
index 5bdfb5d..c4ccd2d 100644
--- a/arch/powerpc/include/asm/kvm_book3s_asm.h
+++ b/arch/powerpc/include/asm/kvm_book3s_asm.h
@@ -112,7 +112,7 @@ struct kvmppc_book3s_shadow_vcpu {
bool in_use;
ulong gpr[14];
u32 cr;
-   u32 xer;
+   ulong xer;
ulong ctr;
ulong lr;
ulong pc;
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S 
b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 4d70df2..d75be59 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -870,7 +870,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
blt hdec_soon
 
ld  r6, VCPU_CTR(r4)
-   lwz r7, VCPU_XER(r4)
+   ld  r7, VCPU_XER(r4)
 
mtctr   r6
mtxer   r7
@@ -1103,7 +1103,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
mfctr   r3
mfxer   r4
std r3, VCPU_CTR(r9)
-   stw r4, VCPU_XER(r9)
+   std r4, VCPU_XER(r9)
 
/* If this is a page table miss then see if it's theirs or ours */
cmpwi   r12, BOOK3S_INTERRUPT_H_DATA_STORAGE
@@ -1675,7 +1675,7 @@ kvmppc_hdsi:
bl  kvmppc_msr_interrupt
 fast_interrupt_c_return:
 6: ld  r7, VCPU_CTR(r9)
-   lwz r8, VCPU_XER(r9)
+   ld  r8, VCPU_XER(r9)
mtctr   r7
mtxer   r8
mr  r4, r9
diff --git a/arch/powerpc/kvm/book3s_segment.S 
b/arch/powerpc/kvm/book3s_segment.S
index acee37c..ca8f174 100644
--- a/arch/powerpc/kvm/book3s_segment.S
+++ b/arch/powerpc/kvm/book3s_segment.S
@@ -123,7 +123,7 @@ no_dcbz32_on:
PPC_LL  r8, SVCPU_CTR(r3)
PPC_LL  r9, SVCPU_LR(r3)
lwz r10, SVCPU_CR(r3)
-   lwz r11, SVCPU_XER(r3)
+   PPC_LL  r11, SVCPU_XER(r3)
 
mtctr   r8
mtlrr9
@@ -237,7 +237,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
mfctr   r8
mflrr9
 
-   stw r5, SVCPU_XER(r13)
+   PPC_STL r5, SVCPU_XER(r13)
PPC_STL r6, SVCPU_FAULT_DAR(r13)
stw r7, SVCPU_FAULT_DSISR(r13)
PPC_STL r8, SVCPU_CTR(r13)
-- 
1.7.10.4

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

[PATCH v2 21/21] cxl: Add AFU virtual PHB and kernel API

2015-05-25 Thread Michael Neuling
This patch does two things.

Firstly it presents the Accelerator Function Unit (AFUs) behind the POWER
Service Layer (PSL) as PCI devices on a virtual PCI Host Bridge (vPHB).  This
in in addition to the PSL being a PCI device itself.

As part of the Coherent Accelerator Interface Architecture (CAIA) AFUs can
provide an AFU configuration.  This AFU configuration recored is architected to
be the same as a PCI config space.

This patch sets discovers the AFU configuration records, provides AFU config
space read/write functions to these configuration records.  It then enumerates
the PCI bus.  It also hooks in PCI ops where appropriate.  It also destroys the
vPHB when the physical card is removed.

Secondly, it add an in kernel API for AFU to use CXL.  AFUs must present a
driver that firstly binds as a PCI device.  This PCI device can then be using
to do CXL specific operations (that can't sit in the PCI ops) using this API.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/Makefile |   1 +
 drivers/misc/cxl/api.c| 325 ++
 drivers/misc/cxl/cxl.h|   5 +
 drivers/misc/cxl/pci.c|  17 ++-
 drivers/misc/cxl/vphb.c   | 268 ++
 include/misc/cxl.h| 201 
 6 files changed, 813 insertions(+), 4 deletions(-)
 create mode 100644 drivers/misc/cxl/api.c
 create mode 100644 drivers/misc/cxl/vphb.c
 create mode 100644 include/misc/cxl.h

diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile
index f9f5514..14e3f82 100644
--- a/drivers/misc/cxl/Makefile
+++ b/drivers/misc/cxl/Makefile
@@ -1,5 +1,6 @@
 cxl-y  += main.o file.o irq.o fault.o native.o
 cxl-y  += context.o sysfs.o debugfs.o pci.o trace.o
+cxl-y  += vphb.o api.o
 obj-$(CONFIG_CXL)  += cxl.o
 obj-$(CONFIG_CXL_BASE) += base.o
 
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
new file mode 100644
index 000..be44b9f
--- /dev/null
+++ b/drivers/misc/cxl/api.c
@@ -0,0 +1,325 @@
+/*
+ * Copyright 2014 IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cxl.h"
+
+struct cxl_context *cxl_dev_context_init(struct pci_dev *dev)
+{
+   struct cxl_afu *afu;
+   struct cxl_context  *ctx;
+   int rc;
+
+   afu = cxl_pci_to_afu(dev);
+
+   ctx = cxl_context_alloc();
+   if (IS_ERR(ctx))
+   return ctx;
+
+   /* Make it a slave context.  We can promote it later? */
+   rc = cxl_context_init(ctx, afu, false, NULL);
+   if (rc) {
+   kfree(ctx);
+   return ERR_PTR(-ENOMEM);
+   }
+   cxl_assign_psn_space(ctx);
+
+   return ctx;
+}
+EXPORT_SYMBOL_GPL(cxl_dev_context_init);
+
+struct cxl_context *cxl_get_context(struct pci_dev *dev)
+{
+   return dev->dev.archdata.cxl_ctx;
+}
+EXPORT_SYMBOL_GPL(cxl_get_context);
+
+struct device *cxl_get_phys_dev(struct pci_dev *dev)
+{
+   struct cxl_afu *afu;
+
+   afu = cxl_pci_to_afu(dev);
+
+   return afu->adapter->dev.parent;
+}
+EXPORT_SYMBOL_GPL(cxl_get_phys_dev);
+
+int cxl_release_context(struct cxl_context *ctx)
+{
+   if (ctx->status != CLOSED)
+   return -EBUSY;
+
+   cxl_context_free(ctx);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(cxl_release_context);
+
+int cxl_allocate_afu_irqs(struct cxl_context *ctx, int num)
+{
+   if (num == 0)
+   num = ctx->afu->pp_irqs;
+   return afu_allocate_irqs(ctx, num);
+}
+EXPORT_SYMBOL_GPL(cxl_allocate_afu_irqs);
+
+void cxl_free_afu_irqs(struct cxl_context *ctx)
+{
+   cxl_release_irq_ranges(&ctx->irqs, ctx->afu->adapter);
+}
+EXPORT_SYMBOL_GPL(cxl_free_afu_irqs);
+
+static irq_hw_number_t cxl_find_afu_irq(struct cxl_context *ctx, int num)
+{
+   __u16 range;
+   int r;
+
+   WARN_ON(num == 0);
+
+   for (r = 0; r < CXL_IRQ_RANGES; r++) {
+   range = ctx->irqs.range[r];
+   if (num < range) {
+   return ctx->irqs.offset[r] + num;
+   }
+   num -= range;
+   }
+   return 0;
+}
+
+int cxl_map_afu_irq(struct cxl_context *ctx, int num,
+   irq_handler_t handler, void *cookie, char *name)
+{
+   irq_hw_number_t hwirq;
+
+   /*
+* Find interrupt we are to register.
+*/
+   hwirq = cxl_find_afu_irq(ctx, num);
+   if (!hwirq)
+   return -ENOENT;
+
+   return cxl_map_irq(ctx->afu->adapter, hwirq, handler, cookie, name);
+}
+EXPORT_SYMBOL_GPL(cxl_map_afu_irq);
+
+void cxl_unmap_afu_irq(struct cxl_context *ctx, int num, void *cookie)
+{
+   irq_hw_number_t hwirq

[PATCH v2 20/21] cxl: Export file ops for use by API

2015-05-25 Thread Michael Neuling
The cxl kernel API will allow drivers other than cxl to export a file
descriptor which has the same userspace API.  These file descriptors will be
able to be used against libcxl.

This exports those file ops for use by other drivers.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/cxl.h  |  9 +
 drivers/misc/cxl/file.c | 23 ++-
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index f3b071e..af67c4b 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -670,4 +671,12 @@ void cxl_stop_trace(struct cxl *cxl);
 extern struct pci_driver cxl_pci_driver;
 int afu_allocate_irqs(struct cxl_context *ctx, u32 count);
 
+int afu_open(struct inode *inode, struct file *file);
+int afu_release(struct inode *inode, struct file *file);
+long afu_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+int afu_mmap(struct file *file, struct vm_area_struct *vm);
+unsigned int afu_poll(struct file *file, struct poll_table_struct *poll);
+ssize_t afu_read(struct file *file, char __user *buf, size_t count, loff_t 
*off);
+extern const struct file_operations afu_fops;
+
 #endif
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
index f7653fc..72fe168 100644
--- a/drivers/misc/cxl/file.c
+++ b/drivers/misc/cxl/file.c
@@ -96,7 +96,8 @@ err_put_adapter:
put_device(&adapter->dev);
return rc;
 }
-static int afu_open(struct inode *inode, struct file *file)
+
+int afu_open(struct inode *inode, struct file *file)
 {
return __afu_open(inode, file, false);
 }
@@ -106,7 +107,7 @@ static int afu_master_open(struct inode *inode, struct file 
*file)
return __afu_open(inode, file, true);
 }
 
-static int afu_release(struct inode *inode, struct file *file)
+int afu_release(struct inode *inode, struct file *file)
 {
struct cxl_context *ctx = file->private_data;
 
@@ -211,7 +212,7 @@ static long afu_ioctl_process_element(struct cxl_context 
*ctx,
return 0;
 }
 
-static long afu_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+long afu_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
struct cxl_context *ctx = file->private_data;
 
@@ -228,13 +229,13 @@ static long afu_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
return -EINVAL;
 }
 
-static long afu_compat_ioctl(struct file *file, unsigned int cmd,
+long afu_compat_ioctl(struct file *file, unsigned int cmd,
 unsigned long arg)
 {
return afu_ioctl(file, cmd, arg);
 }
 
-static int afu_mmap(struct file *file, struct vm_area_struct *vm)
+int afu_mmap(struct file *file, struct vm_area_struct *vm)
 {
struct cxl_context *ctx = file->private_data;
 
@@ -245,7 +246,7 @@ static int afu_mmap(struct file *file, struct 
vm_area_struct *vm)
return cxl_context_iomap(ctx, vm);
 }
 
-static unsigned int afu_poll(struct file *file, struct poll_table_struct *poll)
+unsigned int afu_poll(struct file *file, struct poll_table_struct *poll)
 {
struct cxl_context *ctx = file->private_data;
int mask = 0;
@@ -277,7 +278,7 @@ static inline int ctx_event_pending(struct cxl_context *ctx)
ctx->pending_afu_err || (ctx->status == CLOSED));
 }
 
-static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
+ssize_t afu_read(struct file *file, char __user *buf, size_t count,
loff_t *off)
 {
struct cxl_context *ctx = file->private_data;
@@ -358,7 +359,11 @@ out:
return rc;
 }
 
-static const struct file_operations afu_fops = {
+/* 
+ * Note: if this is updated, we need to update api.c to patch the new ones in
+ * too
+ */
+const struct file_operations afu_fops = {
.owner  = THIS_MODULE,
.open   = afu_open,
.poll   = afu_poll,
@@ -369,7 +374,7 @@ static const struct file_operations afu_fops = {
.mmap   = afu_mmap,
 };
 
-static const struct file_operations afu_master_fops = {
+const struct file_operations afu_master_fops = {
.owner  = THIS_MODULE,
.open   = afu_master_open,
.poll   = afu_poll,
-- 
2.1.0

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

Re: [PATCH 1/1] KVM: PPC: Book3S: correct width in XER handling

2015-05-25 Thread Alexander Graf


On 26.05.15 02:14, Sam Bobroff wrote:
> On Mon, May 25, 2015 at 11:08:08PM +0200, Alexander Graf wrote:
>>
>>
>> On 20.05.15 07:26, Sam Bobroff wrote:
>>> In 64 bit kernels, the Fixed Point Exception Register (XER) is a 64
>>> bit field (e.g. in kvm_regs and kvm_vcpu_arch) and in most places it is
>>> accessed as such.
>>>
>>> This patch corrects places where it is accessed as a 32 bit field by a
>>> 64 bit kernel.  In some cases this is via a 32 bit load or store
>>> instruction which, depending on endianness, will cause either the
>>> lower or upper 32 bits to be missed.  In another case it is cast as a
>>> u32, causing the upper 32 bits to be cleared.
>>>
>>> This patch corrects those places by extending the access methods to
>>> 64 bits.
>>>
>>> Signed-off-by: Sam Bobroff 
>>> ---
>>>
>>>  arch/powerpc/include/asm/kvm_book3s.h   |4 ++--
>>>  arch/powerpc/kvm/book3s_hv_rmhandlers.S |6 +++---
>>>  arch/powerpc/kvm/book3s_segment.S   |4 ++--
>>>  3 files changed, 7 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/arch/powerpc/include/asm/kvm_book3s.h 
>>> b/arch/powerpc/include/asm/kvm_book3s.h
>>> index b91e74a..05a875a 100644
>>> --- a/arch/powerpc/include/asm/kvm_book3s.h
>>> +++ b/arch/powerpc/include/asm/kvm_book3s.h
>>> @@ -225,12 +225,12 @@ static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
>>> return vcpu->arch.cr;
>>>  }
>>>  
>>> -static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
>>> +static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
>>>  {
>>> vcpu->arch.xer = val;
>>>  }
>>>  
>>> -static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
>>> +static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
>>>  {
>>> return vcpu->arch.xer;
>>>  }
>>> diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S 
>>> b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
>>> index 4d70df2..d75be59 100644
>>> --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
>>> +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
>>> @@ -870,7 +870,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
>>> blt hdec_soon
>>>  
>>> ld  r6, VCPU_CTR(r4)
>>> -   lwz r7, VCPU_XER(r4)
>>> +   ld  r7, VCPU_XER(r4)
>>>  
>>> mtctr   r6
>>> mtxer   r7
>>> @@ -1103,7 +1103,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
>>> mfctr   r3
>>> mfxer   r4
>>> std r3, VCPU_CTR(r9)
>>> -   stw r4, VCPU_XER(r9)
>>> +   std r4, VCPU_XER(r9)
>>>  
>>> /* If this is a page table miss then see if it's theirs or ours */
>>> cmpwi   r12, BOOK3S_INTERRUPT_H_DATA_STORAGE
>>> @@ -1675,7 +1675,7 @@ kvmppc_hdsi:
>>> bl  kvmppc_msr_interrupt
>>>  fast_interrupt_c_return:
>>>  6: ld  r7, VCPU_CTR(r9)
>>> -   lwz r8, VCPU_XER(r9)
>>> +   ld  r8, VCPU_XER(r9)
>>> mtctr   r7
>>> mtxer   r8
>>> mr  r4, r9
>>> diff --git a/arch/powerpc/kvm/book3s_segment.S 
>>> b/arch/powerpc/kvm/book3s_segment.S
>>> index acee37c..ca8f174 100644
>>> --- a/arch/powerpc/kvm/book3s_segment.S
>>> +++ b/arch/powerpc/kvm/book3s_segment.S
>>> @@ -123,7 +123,7 @@ no_dcbz32_on:
>>> PPC_LL  r8, SVCPU_CTR(r3)
>>> PPC_LL  r9, SVCPU_LR(r3)
>>> lwz r10, SVCPU_CR(r3)
>>> -   lwz r11, SVCPU_XER(r3)
>>> +   PPC_LL  r11, SVCPU_XER(r3)
>>
>> struct kvmppc_book3s_shadow_vcpu {
>> bool in_use;
>> ulong gpr[14];
>> u32 cr;
>> u32 xer;
>> [...]
>>
>> so at least this change looks wrong. Please double-check all fields in
>> your patch again.
>>
>>
>> Alex
> 
> Thanks for the review and the catch!
> 
> The xer field in kvm_vcpu_arch is already ulong, so it looks like the one in
> kvmppc_book3s_shadow_vcpu is the only other case. I'll fix that and repost.

I guess given that the one in pt_regs is also ulong going ulong rather
than u32 is the better choice, yes.

While at it, could you please just do a grep -i xer across all kvm (.c
and .h) files and just sanity check that we're staying in sync?


Thanks!

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

[PATCH v2 19/21] cxl: Move include file cxl.h -> cxl-base.h

2015-05-25 Thread Michael Neuling
This moves the current include file from cxl.h -> cxl-base.h.  This current
include file is used only to pass information between the base driver that
needs to be built into the kernel and the cxl module.

This is to make way for a new include/misc/cxl.h which will
contain just the kernel API for other driver to use

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 MAINTAINERS   | 2 +-
 arch/powerpc/include/asm/pnv-pci.h| 2 +-
 arch/powerpc/mm/copro_fault.c | 2 +-
 arch/powerpc/mm/hash_native_64.c  | 2 +-
 arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
 drivers/misc/cxl/base.c   | 2 +-
 drivers/misc/cxl/cxl.h| 2 +-
 drivers/misc/cxl/irq.c| 2 +-
 drivers/misc/cxl/main.c   | 2 +-
 drivers/misc/cxl/native.c | 2 +-
 include/misc/{cxl.h => cxl-base.h}| 4 ++--
 11 files changed, 12 insertions(+), 12 deletions(-)
 rename include/misc/{cxl.h => cxl-base.h} (95%)

diff --git a/MAINTAINERS b/MAINTAINERS
index f8e0afb..10f6001 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2956,7 +2956,7 @@ M:Michael Neuling 
 L: linuxppc-dev@lists.ozlabs.org
 S: Supported
 F: drivers/misc/cxl/
-F: include/misc/cxl.h
+F: include/misc/cxl*
 F: include/uapi/misc/cxl.h
 F: Documentation/powerpc/cxl.txt
 F: Documentation/powerpc/cxl.txt
diff --git a/arch/powerpc/include/asm/pnv-pci.h 
b/arch/powerpc/include/asm/pnv-pci.h
index f9b4982..6f77f71 100644
--- a/arch/powerpc/include/asm/pnv-pci.h
+++ b/arch/powerpc/include/asm/pnv-pci.h
@@ -11,7 +11,7 @@
 #define _ASM_PNV_PCI_H
 
 #include 
-#include 
+#include 
 
 int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode);
 int pnv_cxl_ioda_msi_setup(struct pci_dev *dev, unsigned int hwirq,
diff --git a/arch/powerpc/mm/copro_fault.c b/arch/powerpc/mm/copro_fault.c
index 7a71d7f..6527882 100644
--- a/arch/powerpc/mm/copro_fault.c
+++ b/arch/powerpc/mm/copro_fault.c
@@ -26,7 +26,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /*
  * This ought to be kept in sync with the powerpc specific do_page_fault
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index 9c4880d..13befa35 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -29,7 +29,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #ifdef DEBUG_LOW
 #define DBG_LOW(fmt...) udbg_printf(fmt)
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index 2eaf6f7..d21ceba 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -39,7 +39,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #include "powernv.h"
 #include "pci.h"
diff --git a/drivers/misc/cxl/base.c b/drivers/misc/cxl/base.c
index 0654ad8..a9f0dd3 100644
--- a/drivers/misc/cxl/base.c
+++ b/drivers/misc/cxl/base.c
@@ -10,7 +10,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include "cxl.h"
 
 /* protected by rcu */
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index bbc7fd0..f3b071e 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -21,7 +21,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c
index 212790b..680cd26 100644
--- a/drivers/misc/cxl/irq.c
+++ b/drivers/misc/cxl/irq.c
@@ -14,7 +14,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "cxl.h"
 #include "trace.h"
diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c
index de1b19a..403780e 100644
--- a/drivers/misc/cxl/main.c
+++ b/drivers/misc/cxl/main.c
@@ -20,7 +20,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "cxl.h"
 #include "trace.h"
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index a4b40d7..10567f2 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -15,7 +15,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "cxl.h"
 #include "trace.h"
diff --git a/include/misc/cxl.h b/include/misc/cxl-base.h
similarity index 95%
rename from include/misc/cxl.h
rename to include/misc/cxl-base.h
index 975cc78..5ae9625 100644
--- a/include/misc/cxl.h
+++ b/include/misc/cxl-base.h
@@ -7,8 +7,8 @@
  * 2 of the License, or (at your option) any later version.
  */
 
-#ifndef _MISC_CXL_H
-#define _MISC_CXL_H
+#ifndef _MISC_CXL_BASE_H
+#define _MISC_CXL_BASE_H
 
 #ifdef CONFIG_CXL_BASE
 
-- 
2.1.0

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

[PATCH v2 18/21] cxl: Cleanup Makefile

2015-05-25 Thread Michael Neuling
Cleanup Makefile by fixing line wrapping.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/Makefile b/drivers/misc/cxl/Makefile
index edb494d..f9f5514 100644
--- a/drivers/misc/cxl/Makefile
+++ b/drivers/misc/cxl/Makefile
@@ -1,4 +1,5 @@
-cxl-y  += main.o file.o irq.o fault.o native.o 
context.o sysfs.o debugfs.o pci.o trace.o
+cxl-y  += main.o file.o irq.o fault.o native.o
+cxl-y  += context.o sysfs.o debugfs.o pci.o trace.o
 obj-$(CONFIG_CXL)  += cxl.o
 obj-$(CONFIG_CXL_BASE) += base.o
 
-- 
2.1.0

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

[PATCH v2 17/21] cxl: Rework context lifetimes

2015-05-25 Thread Michael Neuling
This reworks contexts lifetimes a bit to enable the kernel API where we may
want to reuse contexts. Here we will want to start and stop contexts without
freeing them.

Start context does the get pid & ctx so stop context will need to do the puts.
Here we move put pid & ctx to the detach context path which will become part of
the stop context path.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/context.c | 5 +++--
 drivers/misc/cxl/file.c| 1 -
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c
index 7d857b7..2a4c80a 100644
--- a/drivers/misc/cxl/context.c
+++ b/drivers/misc/cxl/context.c
@@ -186,6 +186,9 @@ int __detach_context(struct cxl_context *ctx)
return -EBUSY;
 
WARN_ON(cxl_detach_process(ctx));
+   flush_work(&ctx->fault_work); /* Only needed for dedicated process */
+   put_pid(ctx->pid);
+   cxl_ctx_put();
return 0;
 }
 
@@ -204,7 +207,6 @@ void cxl_context_detach(struct cxl_context *ctx)
return;
 
afu_release_irqs(ctx, ctx);
-   flush_work(&ctx->fault_work); /* Only needed for dedicated process */
wake_up_all(&ctx->wq);
 }
 
@@ -245,7 +247,6 @@ static void reclaim_ctx(struct rcu_head *rcu)
free_page((u64)ctx->sstp);
ctx->sstp = NULL;
 
-   put_pid(ctx->pid);
kfree(ctx);
 }
 
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
index 5377c8b..f7653fc 100644
--- a/drivers/misc/cxl/file.c
+++ b/drivers/misc/cxl/file.c
@@ -128,7 +128,6 @@ static int afu_release(struct inode *inode, struct file 
*file)
 */
cxl_context_free(ctx);
 
-   cxl_ctx_put();
return 0;
 }
 
-- 
2.1.0

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

[PATCH v2 16/21] cxl: Configure PSL for kernel contexts and merge code

2015-05-25 Thread Michael Neuling
This updates AFU directed and dedicated modes for contexts attached to the
kernel.

The SR (similar to the MSR in the core) calculation is getting
quite complex and is duplicated in AFU directed and dedicated
modes.  This patch also merges this SR calculation for these modes.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/native.c | 63 ++-
 1 file changed, 35 insertions(+), 28 deletions(-)

diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index 615ccbf..a4b40d7 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -430,9 +430,30 @@ err:
 #define set_endian(sr) ((sr) &= ~(CXL_PSL_SR_An_LE))
 #endif
 
+static u64 calculate_sr(struct cxl_context *ctx)
+{
+   u64 sr = 0;
+
+   if (ctx->master)
+   sr |= CXL_PSL_SR_An_MP;
+   if (mfspr(SPRN_LPCR) & LPCR_TC)
+   sr |= CXL_PSL_SR_An_TC;
+   if (ctx->kernel) {
+   sr |= CXL_PSL_SR_An_R | (mfmsr() & MSR_SF);
+   sr |= CXL_PSL_SR_An_HV;
+   } else {
+   sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
+   set_endian(sr);
+   sr &= ~(CXL_PSL_SR_An_HV);
+   if (!test_tsk_thread_flag(current, TIF_32BIT))
+   sr |= CXL_PSL_SR_An_SF;
+   }
+   return sr;
+}
+
 static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr)
 {
-   u64 sr;
+   u32 pid;
int r, result;
 
cxl_assign_psn_space(ctx);
@@ -442,22 +463,13 @@ static int attach_afu_directed(struct cxl_context *ctx, 
u64 wed, u64 amr)
ctx->elem->haurp = 0; /* disable */
ctx->elem->sdr = cpu_to_be64(mfspr(SPRN_SDR1));
 
-   sr = 0;
-   if (ctx->master)
-   sr |= CXL_PSL_SR_An_MP;
-   if (mfspr(SPRN_LPCR) & LPCR_TC)
-   sr |= CXL_PSL_SR_An_TC;
-   /* HV=0, PR=1, R=1 for userspace
-* For kernel contexts: this would need to change
-*/
-   sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
-   set_endian(sr);
-   sr &= ~(CXL_PSL_SR_An_HV);
-   if (!test_tsk_thread_flag(current, TIF_32BIT))
-   sr |= CXL_PSL_SR_An_SF;
-   ctx->elem->common.pid = cpu_to_be32(current->pid);
+   pid = current->pid;
+   if (ctx->kernel)
+   pid = 0;
ctx->elem->common.tid = 0;
-   ctx->elem->sr = cpu_to_be64(sr);
+   ctx->elem->common.pid = cpu_to_be32(pid);
+
+   ctx->elem->sr = cpu_to_be64(calculate_sr(ctx));
 
ctx->elem->common.csrp = 0; /* disable */
ctx->elem->common.aurp0 = 0; /* disable */
@@ -530,20 +542,15 @@ static int activate_dedicated_process(struct cxl_afu *afu)
 static int attach_dedicated(struct cxl_context *ctx, u64 wed, u64 amr)
 {
struct cxl_afu *afu = ctx->afu;
-   u64 sr;
+   u64 pid;
int rc;
 
-   sr = 0;
-   set_endian(sr);
-   if (ctx->master)
-   sr |= CXL_PSL_SR_An_MP;
-   if (mfspr(SPRN_LPCR) & LPCR_TC)
-   sr |= CXL_PSL_SR_An_TC;
-   sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
-   if (!test_tsk_thread_flag(current, TIF_32BIT))
-   sr |= CXL_PSL_SR_An_SF;
-   cxl_p2n_write(afu, CXL_PSL_PID_TID_An, (u64)current->pid << 32);
-   cxl_p1n_write(afu, CXL_PSL_SR_An, sr);
+   pid = (u64)current->pid << 32;
+   if (ctx->kernel)
+   pid = 0;
+   cxl_p2n_write(afu, CXL_PSL_PID_TID_An, pid);
+
+   cxl_p1n_write(afu, CXL_PSL_SR_An, calculate_sr(ctx));
 
if ((rc = cxl_write_sstp(afu, ctx->sstp0, ctx->sstp1)))
return rc;
-- 
2.1.0

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

[PATCH v2 15/21] cxl: Split afu_register_irqs() function

2015-05-25 Thread Michael Neuling
Split the afu_register_irqs() function so that different parts can
be useful elsewhere.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/cxl.h |  1 +
 drivers/misc/cxl/irq.c | 31 ---
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 58a9b2b..bbc7fd0 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -668,5 +668,6 @@ int cxl_psl_purge(struct cxl_afu *afu);
 void cxl_stop_trace(struct cxl *cxl);
 
 extern struct pci_driver cxl_pci_driver;
+int afu_allocate_irqs(struct cxl_context *ctx, u32 count);
 
 #endif
diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c
index c740c7b..212790b 100644
--- a/drivers/misc/cxl/irq.c
+++ b/drivers/misc/cxl/irq.c
@@ -416,9 +416,8 @@ void afu_irq_name_free(struct cxl_context *ctx)
}
 }
 
-int afu_register_irqs(struct cxl_context *ctx, u32 count)
+int afu_allocate_irqs(struct cxl_context *ctx, u32 count)
 {
-   irq_hw_number_t hwirq;
int rc, r, i, j = 1;
struct cxl_irq_name *irq_name;
 
@@ -458,6 +457,18 @@ int afu_register_irqs(struct cxl_context *ctx, u32 count)
j++;
}
}
+   return 0;
+
+out:
+   afu_irq_name_free(ctx);
+   return -ENOMEM;
+}
+
+void afu_register_hwirqs(struct cxl_context *ctx)
+{
+   irq_hw_number_t hwirq;
+   struct cxl_irq_name *irq_name;
+   int r,i;
 
/* We've allocated all memory now, so let's do the irq allocations */
irq_name = list_first_entry(&ctx->irq_names, struct cxl_irq_name, list);
@@ -469,13 +480,19 @@ int afu_register_irqs(struct cxl_context *ctx, u32 count)
irq_name = list_next_entry(irq_name, list);
}
}
+}
 
-   return 0;
+int afu_register_irqs(struct cxl_context *ctx, u32 count)
+{
+   int rc;
 
-out:
-   afu_irq_name_free(ctx);
-   return -ENOMEM;
-}
+   rc = afu_allocate_irqs(ctx, count);
+   if (rc)
+   return rc;
+
+   afu_register_hwirqs(ctx);
+   return 0;
+ }
 
 void afu_release_irqs(struct cxl_context *ctx, void *cookie)
 {
-- 
2.1.0

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

[PATCH v2 14/21] cxl: Only check pid for userspace contexts

2015-05-25 Thread Michael Neuling
We only need to check the pid attached to this context for userspace contexts.
Kernel contexts can skip this check.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/fault.c | 34 +++---
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c
index 5286b8b..25a5418 100644
--- a/drivers/misc/cxl/fault.c
+++ b/drivers/misc/cxl/fault.c
@@ -172,8 +172,8 @@ void cxl_handle_fault(struct work_struct *fault_work)
container_of(fault_work, struct cxl_context, fault_work);
u64 dsisr = ctx->dsisr;
u64 dar = ctx->dar;
-   struct task_struct *task;
-   struct mm_struct *mm;
+   struct task_struct *task = NULL;
+   struct mm_struct *mm = NULL;
 
if (cxl_p2n_read(ctx->afu, CXL_PSL_DSISR_An) != dsisr ||
cxl_p2n_read(ctx->afu, CXL_PSL_DAR_An) != dar ||
@@ -194,17 +194,19 @@ void cxl_handle_fault(struct work_struct *fault_work)
pr_devel("CXL BOTTOM HALF handling fault for afu pe: %i. "
"DSISR: %#llx DAR: %#llx\n", ctx->pe, dsisr, dar);
 
-   if (!(task = get_pid_task(ctx->pid, PIDTYPE_PID))) {
-   pr_devel("cxl_handle_fault unable to get task %i\n",
-pid_nr(ctx->pid));
-   cxl_ack_ae(ctx);
-   return;
-   }
-   if (!(mm = get_task_mm(task))) {
-   pr_devel("cxl_handle_fault unable to get mm %i\n",
-pid_nr(ctx->pid));
-   cxl_ack_ae(ctx);
-   goto out;
+   if (!ctx->kernel) {
+   if (!(task = get_pid_task(ctx->pid, PIDTYPE_PID))) {
+   pr_devel("cxl_handle_fault unable to get task %i\n",
+pid_nr(ctx->pid));
+   cxl_ack_ae(ctx);
+   return;
+   }
+   if (!(mm = get_task_mm(task))) {
+   pr_devel("cxl_handle_fault unable to get mm %i\n",
+pid_nr(ctx->pid));
+   cxl_ack_ae(ctx);
+   goto out;
+   }
}
 
if (dsisr & CXL_PSL_DSISR_An_DS)
@@ -214,9 +216,11 @@ void cxl_handle_fault(struct work_struct *fault_work)
else
WARN(1, "cxl_handle_fault has nothing to handle\n");
 
-   mmput(mm);
+   if (mm)
+   mmput(mm);
 out:
-   put_task_struct(task);
+   if (task)
+   put_task_struct(task);
 }
 
 static void cxl_prefault_one(struct cxl_context *ctx, u64 ea)
-- 
2.1.0

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

[PATCH v2 13/21] cxl: Export some symbols

2015-05-25 Thread Michael Neuling
Export some symbols which will soon be used elsewhere in this driver.

Now they are global we rename them so to avoid collisions.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/cxl.h|  5 +
 drivers/misc/cxl/native.c | 10 +-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 8180680..58a9b2b 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -632,6 +632,9 @@ int cxl_context_init(struct cxl_context *ctx, struct 
cxl_afu *afu, bool master,
 struct address_space *mapping);
 void cxl_context_free(struct cxl_context *ctx);
 int cxl_context_iomap(struct cxl_context *ctx, struct vm_area_struct *vma);
+unsigned int cxl_map_irq(struct cxl *adapter, irq_hw_number_t hwirq,
+irq_handler_t handler, void *cookie, const char *name);
+void cxl_unmap_irq(unsigned int virq, void *cookie);
 int __detach_context(struct cxl_context *ctx);
 
 /* This matches the layout of the H_COLLECT_CA_INT_INFO retbuf */
@@ -646,6 +649,7 @@ struct cxl_irq_info {
u64 padding[3]; /* to match the expected retbuf size for plpar_hcall9 */
 };
 
+void cxl_assign_psn_space(struct cxl_context *ctx);
 int cxl_attach_process(struct cxl_context *ctx, bool kernel, u64 wed,
u64 amr);
 int cxl_detach_process(struct cxl_context *ctx);
@@ -658,6 +662,7 @@ int cxl_afu_slbia(struct cxl_afu *afu);
 int cxl_tlb_slb_invalidate(struct cxl *adapter);
 int cxl_afu_disable(struct cxl_afu *afu);
 int __cxl_afu_reset(struct cxl_afu *afu);
+int cxl_afu_check_and_enable(struct cxl_afu *afu);
 int cxl_psl_purge(struct cxl_afu *afu);
 
 void cxl_stop_trace(struct cxl *cxl);
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index f85b6ae..615ccbf 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -83,7 +83,7 @@ int __cxl_afu_reset(struct cxl_afu *afu)
   false);
 }
 
-static int afu_check_and_enable(struct cxl_afu *afu)
+int cxl_afu_check_and_enable(struct cxl_afu *afu)
 {
if (afu->enabled)
return 0;
@@ -379,7 +379,7 @@ static int remove_process_element(struct cxl_context *ctx)
 }
 
 
-static void assign_psn_space(struct cxl_context *ctx)
+void cxl_assign_psn_space(struct cxl_context *ctx)
 {
if (!ctx->afu->pp_size || ctx->master) {
ctx->psn_phys = ctx->afu->psn_phys;
@@ -435,7 +435,7 @@ static int attach_afu_directed(struct cxl_context *ctx, u64 
wed, u64 amr)
u64 sr;
int r, result;
 
-   assign_psn_space(ctx);
+   cxl_assign_psn_space(ctx);
 
ctx->elem->ctxtime = 0; /* disable */
ctx->elem->lpid = cpu_to_be32(mfspr(SPRN_LPID));
@@ -477,7 +477,7 @@ static int attach_afu_directed(struct cxl_context *ctx, u64 
wed, u64 amr)
ctx->elem->common.wed = cpu_to_be64(wed);
 
/* first guy needs to enable */
-   if ((result = afu_check_and_enable(ctx->afu)))
+   if ((result = cxl_afu_check_and_enable(ctx->afu)))
return result;
 
add_process_element(ctx);
@@ -564,7 +564,7 @@ static int attach_dedicated(struct cxl_context *ctx, u64 
wed, u64 amr)
cxl_p2n_write(afu, CXL_PSL_AMR_An, amr);
 
/* master only context for dedicated */
-   assign_psn_space(ctx);
+   cxl_assign_psn_space(ctx);
 
if ((rc = __cxl_afu_reset(afu)))
return rc;
-- 
2.1.0

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

[PATCH v2 12/21] cxl: cxl_afu_reset() -> __cxl_afu_reset()

2015-05-25 Thread Michael Neuling
Rename cxl_afu_reset() to __cxl_afu_reset() to we can reuse this function name
in the API.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/cxl.h| 2 +-
 drivers/misc/cxl/native.c | 8 
 drivers/misc/cxl/pci.c| 4 ++--
 drivers/misc/cxl/sysfs.c  | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 296a077..8180680 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -657,7 +657,7 @@ int cxl_check_error(struct cxl_afu *afu);
 int cxl_afu_slbia(struct cxl_afu *afu);
 int cxl_tlb_slb_invalidate(struct cxl *adapter);
 int cxl_afu_disable(struct cxl_afu *afu);
-int cxl_afu_reset(struct cxl_afu *afu);
+int __cxl_afu_reset(struct cxl_afu *afu);
 int cxl_psl_purge(struct cxl_afu *afu);
 
 void cxl_stop_trace(struct cxl *cxl);
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index 29185fc..f85b6ae 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -73,7 +73,7 @@ int cxl_afu_disable(struct cxl_afu *afu)
 }
 
 /* This will disable as well as reset */
-int cxl_afu_reset(struct cxl_afu *afu)
+int __cxl_afu_reset(struct cxl_afu *afu)
 {
pr_devel("AFU reset request\n");
 
@@ -495,7 +495,7 @@ static int deactivate_afu_directed(struct cxl_afu *afu)
cxl_sysfs_afu_m_remove(afu);
cxl_chardev_afu_remove(afu);
 
-   cxl_afu_reset(afu);
+   __cxl_afu_reset(afu);
cxl_afu_disable(afu);
cxl_psl_purge(afu);
 
@@ -566,7 +566,7 @@ static int attach_dedicated(struct cxl_context *ctx, u64 
wed, u64 amr)
/* master only context for dedicated */
assign_psn_space(ctx);
 
-   if ((rc = cxl_afu_reset(afu)))
+   if ((rc = __cxl_afu_reset(afu)))
return rc;
 
cxl_p2n_write(afu, CXL_PSL_WED_An, wed);
@@ -629,7 +629,7 @@ int cxl_attach_process(struct cxl_context *ctx, bool 
kernel, u64 wed, u64 amr)
 
 static inline int detach_process_native_dedicated(struct cxl_context *ctx)
 {
-   cxl_afu_reset(ctx->afu);
+   __cxl_afu_reset(ctx->afu);
cxl_afu_disable(ctx->afu);
cxl_psl_purge(ctx->afu);
return 0;
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 9066a7a..7130c85 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -641,7 +641,7 @@ static int sanitise_afu_regs(struct cxl_afu *afu)
reg = cxl_p2n_read(afu, CXL_AFU_Cntl_An);
if ((reg & CXL_AFU_Cntl_An_ES_MASK) != CXL_AFU_Cntl_An_ES_Disabled) {
dev_warn(&afu->dev, "WARNING: AFU was not disabled: 
%#.16llx\n", reg);
-   if (cxl_afu_reset(afu))
+   if (__cxl_afu_reset(afu))
return -EIO;
if (cxl_afu_disable(afu))
return -EIO;
@@ -701,7 +701,7 @@ static int cxl_init_afu(struct cxl *adapter, int slice, 
struct pci_dev *dev)
goto err2;
 
/* We need to reset the AFU before we can read the AFU descriptor */
-   if ((rc = cxl_afu_reset(afu)))
+   if ((rc = __cxl_afu_reset(afu)))
goto err2;
 
if (cxl_verbose)
diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
index d0c38c7..2d6e104 100644
--- a/drivers/misc/cxl/sysfs.c
+++ b/drivers/misc/cxl/sysfs.c
@@ -185,7 +185,7 @@ static ssize_t reset_store_afu(struct device *device,
goto err;
}
 
-   if ((rc = cxl_afu_reset(afu)))
+   if ((rc = __cxl_afu_reset(afu)))
goto err;
 
rc = count;
-- 
2.1.0

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

[PATCH v2 11/21] cxl: Rework detach context functions

2015-05-25 Thread Michael Neuling
Rework __detach_context() and cxl_context_detach() so we can reuse them in the
kernel API.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/context.c | 20 +---
 drivers/misc/cxl/cxl.h |  1 +
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c
index 36bb8e4..7d857b7 100644
--- a/drivers/misc/cxl/context.c
+++ b/drivers/misc/cxl/context.c
@@ -174,7 +174,7 @@ int cxl_context_iomap(struct cxl_context *ctx, struct 
vm_area_struct *vma)
  * return until all outstanding interrupts for this context have completed. The
  * hardware should no longer access *ctx after this has returned.
  */
-static void __detach_context(struct cxl_context *ctx)
+int __detach_context(struct cxl_context *ctx)
 {
enum cxl_context_status status;
 
@@ -183,12 +183,10 @@ static void __detach_context(struct cxl_context *ctx)
ctx->status = CLOSED;
mutex_unlock(&ctx->status_mutex);
if (status != STARTED)
-   return;
+   return -EBUSY;
 
WARN_ON(cxl_detach_process(ctx));
-   afu_release_irqs(ctx, ctx);
-   flush_work(&ctx->fault_work); /* Only needed for dedicated process */
-   wake_up_all(&ctx->wq);
+   return 0;
 }
 
 /*
@@ -199,7 +197,15 @@ static void __detach_context(struct cxl_context *ctx)
  */
 void cxl_context_detach(struct cxl_context *ctx)
 {
-   __detach_context(ctx);
+   int rc;
+
+   rc = __detach_context(ctx);
+   if (rc)
+   return;
+
+   afu_release_irqs(ctx, ctx);
+   flush_work(&ctx->fault_work); /* Only needed for dedicated process */
+   wake_up_all(&ctx->wq);
 }
 
 /*
@@ -216,7 +222,7 @@ void cxl_context_detach_all(struct cxl_afu *afu)
 * Anything done in here needs to be setup before the IDR is
 * created and torn down after the IDR removed
 */
-   __detach_context(ctx);
+   cxl_context_detach(ctx);
 
/*
 * We are force detaching - remove any active PSA mappings so
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 7c014b8..296a077 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -632,6 +632,7 @@ int cxl_context_init(struct cxl_context *ctx, struct 
cxl_afu *afu, bool master,
 struct address_space *mapping);
 void cxl_context_free(struct cxl_context *ctx);
 int cxl_context_iomap(struct cxl_context *ctx, struct vm_area_struct *vma);
+int __detach_context(struct cxl_context *ctx);
 
 /* This matches the layout of the H_COLLECT_CA_INT_INFO retbuf */
 struct cxl_irq_info {
-- 
2.1.0

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

[PATCH v2 10/21] cxl: Add cookie parameter to afu_release_irqs()

2015-05-25 Thread Michael Neuling
Add cookie parameter to afu_release_irqs() so that we can pass in a different
cookie than the context structure.  This will be useful for other kernel
drivers that want to call this but get their own cookie back in the interrupt
handler.

Update all existing call sites.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/context.c | 2 +-
 drivers/misc/cxl/cxl.h | 2 +-
 drivers/misc/cxl/file.c| 2 +-
 drivers/misc/cxl/irq.c | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c
index 78ce990..36bb8e4 100644
--- a/drivers/misc/cxl/context.c
+++ b/drivers/misc/cxl/context.c
@@ -186,7 +186,7 @@ static void __detach_context(struct cxl_context *ctx)
return;
 
WARN_ON(cxl_detach_process(ctx));
-   afu_release_irqs(ctx);
+   afu_release_irqs(ctx, ctx);
flush_work(&ctx->fault_work); /* Only needed for dedicated process */
wake_up_all(&ctx->wq);
 }
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index f0b6727..7c014b8 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -609,7 +609,7 @@ void cxl_release_psl_err_irq(struct cxl *adapter);
 int cxl_register_serr_irq(struct cxl_afu *afu);
 void cxl_release_serr_irq(struct cxl_afu *afu);
 int afu_register_irqs(struct cxl_context *ctx, u32 count);
-void afu_release_irqs(struct cxl_context *ctx);
+void afu_release_irqs(struct cxl_context *ctx, void *cookie);
 irqreturn_t cxl_slice_irq_err(int irq, void *data);
 
 int cxl_debugfs_init(void);
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
index 2364bca..5377c8b 100644
--- a/drivers/misc/cxl/file.c
+++ b/drivers/misc/cxl/file.c
@@ -191,7 +191,7 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,
 
if ((rc = cxl_attach_process(ctx, false, work.work_element_descriptor,
 amr))) {
-   afu_release_irqs(ctx);
+   afu_release_irqs(ctx, ctx);
goto out;
}
 
diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c
index c8929c5..c740c7b 100644
--- a/drivers/misc/cxl/irq.c
+++ b/drivers/misc/cxl/irq.c
@@ -477,7 +477,7 @@ out:
return -ENOMEM;
 }
 
-void afu_release_irqs(struct cxl_context *ctx)
+void afu_release_irqs(struct cxl_context *ctx, void *cookie)
 {
irq_hw_number_t hwirq;
unsigned int virq;
@@ -488,7 +488,7 @@ void afu_release_irqs(struct cxl_context *ctx)
for (i = 0; i < ctx->irqs.range[r]; hwirq++, i++) {
virq = irq_find_mapping(NULL, hwirq);
if (virq)
-   cxl_unmap_irq(virq, ctx);
+   cxl_unmap_irq(virq, cookie);
}
}
 
-- 
2.1.0

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

[PATCH v2 09/21] cxl: Dump debug info on the AFU configuration record

2015-05-25 Thread Michael Neuling
Now that we parse the AFU Configuration record, dump some info on it when in
debug mode.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/pci.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 1ac2ecf..9066a7a 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -90,6 +90,7 @@
 /* This works a little different than the p1/p2 register accesses to make it
  * easier to pull out individual fields */
 #define AFUD_READ(afu, off)in_be64(afu->afu_desc_mmio + off)
+#define AFUD_READ_LE(afu, off) in_le64(afu->afu_desc_mmio + off)
 #define EXTRACT_PPC_BIT(val, bit)  (!!(val & PPC_BIT(bit)))
 #define EXTRACT_PPC_BITS(val, bs, be)  ((val & PPC_BITMASK(bs, be)) >> 
PPC_BITLSHIFT(be))
 
@@ -286,7 +287,8 @@ static void dump_cxl_config_space(struct pci_dev *dev)
 
 static void dump_afu_descriptor(struct cxl_afu *afu)
 {
-   u64 val;
+   u64 val, afu_cr_num, afu_cr_off, afu_cr_len;
+   int i;
 
 #define show_reg(name, what) \
dev_info(&afu->dev, "afu desc: %30s: %#llx\n", name, what)
@@ -296,6 +298,7 @@ static void dump_afu_descriptor(struct cxl_afu *afu)
show_reg("num_of_processes", AFUD_NUM_PROCS(val));
show_reg("num_of_afu_CRs", AFUD_NUM_CRS(val));
show_reg("req_prog_mode", val & 0xULL);
+   afu_cr_num = AFUD_NUM_CRS(val);
 
val = AFUD_READ(afu, 0x8);
show_reg("Reserved", val);
@@ -307,8 +310,10 @@ static void dump_afu_descriptor(struct cxl_afu *afu)
val = AFUD_READ_CR(afu);
show_reg("Reserved", (val >> (63-7)) & 0xff);
show_reg("AFU_CR_len", AFUD_CR_LEN(val));
+   afu_cr_len = AFUD_CR_LEN(val) * 256;
 
val = AFUD_READ_CR_OFF(afu);
+   afu_cr_off = val;
show_reg("AFU_CR_offset", val);
 
val = AFUD_READ_PPPSA(afu);
@@ -325,6 +330,11 @@ static void dump_afu_descriptor(struct cxl_afu *afu)
val = AFUD_READ_EB_OFF(afu);
show_reg("AFU_EB_offset", val);
 
+   for (i = 0; i < afu_cr_num; i++) {
+   val = AFUD_READ_LE(afu, afu_cr_off + i * afu_cr_len);
+   show_reg("CR Vendor", val & 0x);
+   show_reg("CR Device", (val >> 16) & 0x);
+   }
 #undef show_reg
 }
 
-- 
2.1.0

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

[PATCH v2 08/21] cxl: Re-order card init to check the VSEC earlier

2015-05-25 Thread Michael Neuling
From: Ian Munsie 

When we expose AFUs as virtual PCI devices, they may look like the physical
CAPI PCI card.  ie they may have the same vendor/device IDs.

We want to avoid these AFUs binding to this driver and any init this driver may
do.

Re-order card init to check the VSEC earlier before assigning BARs or
activating CXL.  Also change the dev used in early prints as the adapter struct
may not be inited at this earlier stage.

Signed-off-by: Ian Munsie 
Signed-off-by: Michael Neuling 
---
 drivers/misc/cxl/pci.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index a9c90d2..1ac2ecf 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -884,13 +884,13 @@ static int cxl_read_vsec(struct cxl *adapter, struct 
pci_dev *dev)
u16 vseclen;
 
if (!(vsec = find_cxl_vsec(dev))) {
-   dev_err(&adapter->dev, "ABORTING: CXL VSEC not found!\n");
+   dev_err(&dev->dev, "ABORTING: CXL VSEC not found!\n");
return -ENODEV;
}
 
CXL_READ_VSEC_LENGTH(dev, vsec, &vseclen);
if (vseclen < CXL_VSEC_MIN_SIZE) {
-   pr_err("ABORTING: CXL VSEC too short\n");
+   dev_err(&dev->dev, "ABORTING: CXL VSEC too short\n");
return -EINVAL;
}
 
@@ -927,24 +927,24 @@ static int cxl_vsec_looks_ok(struct cxl *adapter, struct 
pci_dev *dev)
return -EBUSY;
 
if (adapter->vsec_status & CXL_UNSUPPORTED_FEATURES) {
-   dev_err(&adapter->dev, "ABORTING: CXL requires unsupported 
features\n");
+   dev_err(&dev->dev, "ABORTING: CXL requires unsupported 
features\n");
return -EINVAL;
}
 
if (!adapter->slices) {
/* Once we support dynamic reprogramming we can use the card if
 * it supports loadable AFUs */
-   dev_err(&adapter->dev, "ABORTING: Device has no AFUs\n");
+   dev_err(&dev->dev, "ABORTING: Device has no AFUs\n");
return -EINVAL;
}
 
if (!adapter->afu_desc_off || !adapter->afu_desc_size) {
-   dev_err(&adapter->dev, "ABORTING: VSEC shows no AFU 
descriptors\n");
+   dev_err(&dev->dev, "ABORTING: VSEC shows no AFU descriptors\n");
return -EINVAL;
}
 
if (adapter->ps_size > p2_size(dev) - adapter->ps_off) {
-   dev_err(&adapter->dev, "ABORTING: Problem state size larger 
than "
+   dev_err(&dev->dev, "ABORTING: Problem state size larger than "
   "available in BAR2: 0x%llx > 0x%llx\n",
 adapter->ps_size, p2_size(dev) - adapter->ps_off);
return -EINVAL;
@@ -993,6 +993,15 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
if (!(adapter = cxl_alloc_adapter(dev)))
return ERR_PTR(-ENOMEM);
 
+   if ((rc = cxl_read_vsec(adapter, dev)))
+   goto err1;
+
+   if ((rc = cxl_vsec_looks_ok(adapter, dev)))
+   goto err1;
+
+   if ((rc = setup_cxl_bars(dev)))
+   goto err1;
+
if ((rc = switch_card_to_cxl(dev)))
goto err1;
 
@@ -1002,12 +1011,6 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
if ((rc = dev_set_name(&adapter->dev, "card%i", adapter->adapter_num)))
goto err2;
 
-   if ((rc = cxl_read_vsec(adapter, dev)))
-   goto err2;
-
-   if ((rc = cxl_vsec_looks_ok(adapter, dev)))
-   goto err2;
-
if ((rc = cxl_update_image_control(adapter)))
goto err2;
 
@@ -1092,9 +1095,6 @@ static int cxl_probe(struct pci_dev *dev, const struct 
pci_device_id *id)
if (cxl_verbose)
dump_cxl_config_space(dev);
 
-   if ((rc = setup_cxl_bars(dev)))
-   return rc;
-
if ((rc = pci_enable_device(dev))) {
dev_err(&dev->dev, "pci_enable_device failed: %i\n", rc);
return rc;
-- 
2.1.0

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

[PATCH v2 07/21] cxl: Add shutdown hook

2015-05-25 Thread Michael Neuling
Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 drivers/misc/cxl/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index b80f867..a9c90d2 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1135,4 +1135,5 @@ struct pci_driver cxl_pci_driver = {
.id_table = cxl_pci_tbl,
.probe = cxl_probe,
.remove = cxl_remove,
+   .shutdown = cxl_remove,
 };
-- 
2.1.0

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

[PATCH v2 06/21] cxl: Document external user of existing API

2015-05-25 Thread Michael Neuling
Now that libcxl is public, let's document it.

Signed-off-by: Michael Neuling 
Acked-by: Ian Munsie 
---
 Documentation/ABI/testing/sysfs-class-cxl | 22 ++
 Documentation/powerpc/cxl.txt |  4 
 2 files changed, 26 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-cxl 
b/Documentation/ABI/testing/sysfs-class-cxl
index d46bba8..7cd9f2e 100644
--- a/Documentation/ABI/testing/sysfs-class-cxl
+++ b/Documentation/ABI/testing/sysfs-class-cxl
@@ -15,6 +15,7 @@ Description:read/write
 that hardware can support (eg. 2037). Write values will limit
 userspace applications to that many userspace interrupts. Must
 be >= irqs_min.
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//irqs_min
 Date:   September 2014
@@ -24,6 +25,7 @@ Description:read only
 userspace must request on a CXL_START_WORK ioctl. Userspace may
 omit the num_interrupts field in the START_WORK IOCTL to get
 this minimum automatically.
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//mmio_size
 Date:   September 2014
@@ -31,6 +33,7 @@ Contact:linuxppc-dev@lists.ozlabs.org
 Description:read only
 Decimal value of the size of the MMIO space that may be mmaped
 by userspace.
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//modes_supported
 Date:   September 2014
@@ -38,6 +41,7 @@ Contact:linuxppc-dev@lists.ozlabs.org
 Description:read only
 List of the modes this AFU supports. One per line.
 Valid entries are: "dedicated_process" and "afu_directed"
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//mode
 Date:   September 2014
@@ -46,6 +50,7 @@ Description:read/write
 The current mode the AFU is using. Will be one of the modes
 given in modes_supported. Writing will change the mode
 provided that no user contexts are attached.
+Users: https://github.com/ibm-capi/libcxl
 
 
 What:   /sys/class/cxl//prefault_mode
@@ -59,6 +64,7 @@ Description:read/write
  descriptor as an effective address and
  prefault what it points to.
 all: all segments process calling START_WORK maps.
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//reset
 Date:   September 2014
@@ -66,12 +72,14 @@ Contact:linuxppc-dev@lists.ozlabs.org
 Description:write only
 Writing 1 here will reset the AFU provided there are not
 contexts active on the AFU.
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//api_version
 Date:   September 2014
 Contact:linuxppc-dev@lists.ozlabs.org
 Description:read only
 Decimal value of the current version of the kernel/user API.
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//api_version_compatible
 Date:   September 2014
@@ -79,6 +87,7 @@ Contact:linuxppc-dev@lists.ozlabs.org
 Description:read only
 Decimal value of the the lowest version of the userspace API
 this this kernel supports.
+Users: https://github.com/ibm-capi/libcxl
 
 
 AFU configuration records (eg. /sys/class/cxl/afu0.0/cr0):
@@ -92,6 +101,7 @@ Contact:linuxppc-dev@lists.ozlabs.org
 Description:read only
Hexadecimal value of the vendor ID found in this AFU
configuration record.
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//cr/device
 Date:   February 2015
@@ -99,6 +109,7 @@ Contact:linuxppc-dev@lists.ozlabs.org
 Description:read only
Hexadecimal value of the device ID found in this AFU
configuration record.
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//cr/class
 Date:   February 2015
@@ -106,6 +117,7 @@ Contact:linuxppc-dev@lists.ozlabs.org
 Description:read only
Hexadecimal value of the class code found in this AFU
configuration record.
+Users: https://github.com/ibm-capi/libcxl
 
 What:   /sys/class/cxl//cr/config
 Date:   February 2015
@@ -115,6 +127,7 @@ Description:read only
record. The format is expected to match the either the standard
or extended configuration space defined by the PCIe
specification.
+Users: https://github.com/ibm-capi/libcxl
 
 
 
@@ -126,18 +139,21 @@ Contact:linuxppc-dev@lists.ozlabs.org
 Description:read only
 

[PATCH v2 05/21] powerpc/pci: Add shutdown hook to pci_controller_ops

2015-05-25 Thread Michael Neuling
Currently pnv_pci_shutdown() calls the PHB shutdown code for all PHBs in the
system.  It dereferences the private_data assuming it's a powernv PHB, which
won't be the case when we have different PHB in the systems (like when we add
vPHBs for CXL).

This moves the shutdown hook to the pci_controller_ops and fixes the call site
to use that instead.

Signed-off-by: Michael Neuling 
---
 arch/powerpc/include/asm/pci-bridge.h | 2 ++
 arch/powerpc/platforms/powernv/pci-ioda.c | 8 
 arch/powerpc/platforms/powernv/pci.c  | 9 +++--
 arch/powerpc/platforms/powernv/pci.h  | 1 -
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 4cf0caa..3947749 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -40,6 +40,8 @@ struct pci_controller_ops {
 #endif
 
int (*dma_set_mask)(struct pci_dev *dev, u64 dma_mask);
+
+   void(*shutdown)(struct pci_controller *);
 };
 
 /*
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index bb3c0c4..2eaf6f7 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -2645,8 +2645,10 @@ static u32 pnv_ioda_bdfn_to_pe(struct pnv_phb *phb, 
struct pci_bus *bus,
return phb->ioda.pe_rmap[(bus->number << 8) | devfn];
 }
 
-static void pnv_pci_ioda_shutdown(struct pnv_phb *phb)
+static void pnv_pci_ioda_shutdown(struct pci_controller *hose)
 {
+   struct pnv_phb *phb = hose->private_data;
+
opal_pci_reset(phb->opal_id, OPAL_RESET_PCI_IODA_TABLE,
   OPAL_ASSERT_RESET);
 }
@@ -2796,9 +2798,6 @@ static void __init pnv_pci_init_ioda_phb(struct 
device_node *np,
phb->dma_dev_setup = pnv_pci_ioda_dma_dev_setup;
phb->dma_get_required_mask = pnv_pci_ioda_dma_get_required_mask;
 
-   /* Setup shutdown function for kexec */
-   phb->shutdown = pnv_pci_ioda_shutdown;
-
/* Setup MSI support */
pnv_pci_init_ioda_msis(phb);
 
@@ -2879,4 +2878,5 @@ static const struct pci_controller_ops 
pnv_pci_ioda_controller_ops = {
.window_alignment = pnv_pci_window_alignment,
.reset_secondary_bus = pnv_pci_reset_secondary_bus,
.dma_set_mask = pnv_pci_ioda_dma_set_mask,
+   .shutdown = pnv_pci_ioda_shutdown,
 };
diff --git a/arch/powerpc/platforms/powernv/pci.c 
b/arch/powerpc/platforms/powernv/pci.c
index acc0ced..1614d79 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -704,12 +704,9 @@ void pnv_pci_shutdown(void)
 {
struct pci_controller *hose;
 
-   list_for_each_entry(hose, &hose_list, list_node) {
-   struct pnv_phb *phb = hose->private_data;
-
-   if (phb && phb->shutdown)
-   phb->shutdown(phb);
-   }
+   list_for_each_entry(hose, &hose_list, list_node)
+   if (hose->controller_ops.shutdown)
+   hose->controller_ops.shutdown(hose);
 }
 
 /* Fixup wrong class code in p7ioc and p8 root complex */
diff --git a/arch/powerpc/platforms/powernv/pci.h 
b/arch/powerpc/platforms/powernv/pci.h
index 60bb935..7edb54f5 100644
--- a/arch/powerpc/platforms/powernv/pci.h
+++ b/arch/powerpc/platforms/powernv/pci.h
@@ -110,7 +110,6 @@ struct pnv_phb {
 struct pci_dev *pdev);
void (*fixup_phb)(struct pci_controller *hose);
u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn);
-   void (*shutdown)(struct pnv_phb *phb);
int (*init_m64)(struct pnv_phb *phb);
void (*reserve_m64_pe)(struct pnv_phb *phb);
int (*pick_m64_pe)(struct pnv_phb *phb, struct pci_bus *bus, int all);
-- 
2.1.0

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

[PATCH v2 04/21] powerpc: Add cxl context to device archdata

2015-05-25 Thread Michael Neuling
Add cxl context pointer to archdata.  We'll want to create one of these for cxl
PCI devices.  Put them here until we can get a pci_dev specific private data.

This location was suggested by benh.

Signed-off-by: Michael Neuling 
---
 arch/powerpc/include/asm/device.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/include/asm/device.h 
b/arch/powerpc/include/asm/device.h
index 9f1371b..e9bdda8 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -46,6 +46,9 @@ struct dev_archdata {
 #ifdef CONFIG_FAIL_IOMMU
int fail_iommu;
 #endif
+#ifdef CONFIG_CXL_BASE
+   struct cxl_context  *cxl_ctx;
+#endif
 };
 
 struct pdev_archdata {
-- 
2.1.0

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

[PATCH v2 03/21] powerpc/pci: Add release_device() hook to phb ops

2015-05-25 Thread Michael Neuling
Add release_device() hook to phb ops so we can clean up for specific phbs.

Signed-off-by: Michael Neuling 
---
 arch/powerpc/include/asm/pci-bridge.h | 2 ++
 arch/powerpc/kernel/pci-hotplug.c | 5 +
 2 files changed, 7 insertions(+)

diff --git a/arch/powerpc/include/asm/pci-bridge.h 
b/arch/powerpc/include/asm/pci-bridge.h
index 6d17bb8..4cf0caa 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -27,6 +27,8 @@ struct pci_controller_ops {
 * allow assignment/enabling of the device. */
bool(*enable_device_hook)(struct pci_dev *);
 
+   void(*release_device)(struct pci_dev *);
+
/* Called during PCI resource reassignment */
resource_size_t (*window_alignment)(struct pci_bus *, unsigned long 
type);
void(*reset_secondary_bus)(struct pci_dev *dev);
diff --git a/arch/powerpc/kernel/pci-hotplug.c 
b/arch/powerpc/kernel/pci-hotplug.c
index 7ed85a6..7f9ed0c 100644
--- a/arch/powerpc/kernel/pci-hotplug.c
+++ b/arch/powerpc/kernel/pci-hotplug.c
@@ -29,7 +29,12 @@
  */
 void pcibios_release_device(struct pci_dev *dev)
 {
+   struct pci_controller *phb = pci_bus_to_host(dev->bus);
+
eeh_remove_device(dev);
+
+   if (phb->controller_ops.release_device)
+   phb->controller_ops.release_device(dev);
 }
 
 /**
-- 
2.1.0

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

[PATCH v2 02/21] powerpc/pci: Export symbols for CXL

2015-05-25 Thread Michael Neuling
From: Daniel Axtens 

Export pcibios_claim_one_bus, pcibios_scan_phb and pcibios_alloc_controller.

These will be used by the CXL driver.

Signed-off-by: Daniel Axtens 
---
 arch/powerpc/kernel/pci-common.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 0d05406..2040cd2 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -89,6 +89,7 @@ struct pci_controller *pcibios_alloc_controller(struct 
device_node *dev)
 #endif
return phb;
 }
+EXPORT_SYMBOL_GPL(pcibios_alloc_controller);
 
 void pcibios_free_controller(struct pci_controller *phb)
 {
@@ -1447,6 +1448,7 @@ void pcibios_claim_one_bus(struct pci_bus *bus)
list_for_each_entry(child_bus, &bus->children, node)
pcibios_claim_one_bus(child_bus);
 }
+EXPORT_SYMBOL_GPL(pcibios_claim_one_bus);
 
 
 /* pcibios_finish_adding_to_bus
@@ -1680,6 +1682,7 @@ void pcibios_scan_phb(struct pci_controller *hose)
pcie_bus_configure_settings(child);
}
 }
+EXPORT_SYMBOL_GPL(pcibios_scan_phb);
 
 static void fixup_hide_host_resource_fsl(struct pci_dev *dev)
 {
-- 
2.1.0

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

[PATCH v2 01/21] powerpc/copro: Fix faulting kernel segments

2015-05-25 Thread Michael Neuling
This fixes calculating the key bits (KP and KS) in the SLB VSID for kernel
mappings.

I'm not CCing this to stable as there are no uses of this currently.

Signed-off-by: Michael Neuling 
---
 arch/powerpc/mm/copro_fault.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/mm/copro_fault.c b/arch/powerpc/mm/copro_fault.c
index f031a47..7a71d7f 100644
--- a/arch/powerpc/mm/copro_fault.c
+++ b/arch/powerpc/mm/copro_fault.c
@@ -100,7 +100,7 @@ EXPORT_SYMBOL_GPL(copro_handle_mm_fault);
 
 int copro_calculate_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb)
 {
-   u64 vsid;
+   u64 vsid, vsidkey;
int psize, ssize;
 
switch (REGION_ID(ea)) {
@@ -109,6 +109,7 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, 
struct copro_slb *slb)
psize = get_slice_psize(mm, ea);
ssize = user_segment_size(ea);
vsid = get_vsid(mm->context.id, ea, ssize);
+   vsidkey = SLB_VSID_USER;
break;
case VMALLOC_REGION_ID:
pr_devel("%s: 0x%llx -- VMALLOC_REGION_ID\n", __func__, ea);
@@ -118,19 +119,21 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, 
struct copro_slb *slb)
psize = mmu_io_psize;
ssize = mmu_kernel_ssize;
vsid = get_kernel_vsid(ea, mmu_kernel_ssize);
+   vsidkey = SLB_VSID_KERNEL;
break;
case KERNEL_REGION_ID:
pr_devel("%s: 0x%llx -- KERNEL_REGION_ID\n", __func__, ea);
psize = mmu_linear_psize;
ssize = mmu_kernel_ssize;
vsid = get_kernel_vsid(ea, mmu_kernel_ssize);
+   vsidkey = SLB_VSID_KERNEL;
break;
default:
pr_debug("%s: invalid region access at %016llx\n", __func__, 
ea);
return 1;
}
 
-   vsid = (vsid << slb_vsid_shift(ssize)) | SLB_VSID_USER;
+   vsid = (vsid << slb_vsid_shift(ssize)) | vsidkey;
 
vsid |= mmu_psize_defs[psize].sllp |
((ssize == MMU_SEGSIZE_1T) ? SLB_VSID_B_1T : 0);
-- 
2.1.0

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

[PATCH v2 00/21] cxl: Add AFU virtual PHB and in kernel API

2015-05-25 Thread Michael Neuling
This patch series adds the ability to present AFUs as PCI devices on a virtual
PHB.

It also adds an in kernel API (to the existing userspace API) so AFU drivers
can be written as kernel drivers.

This series is dependant on Daniel DMA set mask and MSI PCI controller ops
patch series.

v2:
 - Address comments from Ian
   o Rename some functions now they are global
   o Rework context lifetime
   o Merge and fix SR calculation
   o Added ACKs from Ian
   o correct from Ian on one patch
 - Fixed powernv pci shutdown hook

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

Re: [PATCH 1/1] KVM: PPC: Book3S: correct width in XER handling

2015-05-25 Thread Sam Bobroff
On Mon, May 25, 2015 at 11:08:08PM +0200, Alexander Graf wrote:
> 
> 
> On 20.05.15 07:26, Sam Bobroff wrote:
> > In 64 bit kernels, the Fixed Point Exception Register (XER) is a 64
> > bit field (e.g. in kvm_regs and kvm_vcpu_arch) and in most places it is
> > accessed as such.
> > 
> > This patch corrects places where it is accessed as a 32 bit field by a
> > 64 bit kernel.  In some cases this is via a 32 bit load or store
> > instruction which, depending on endianness, will cause either the
> > lower or upper 32 bits to be missed.  In another case it is cast as a
> > u32, causing the upper 32 bits to be cleared.
> > 
> > This patch corrects those places by extending the access methods to
> > 64 bits.
> > 
> > Signed-off-by: Sam Bobroff 
> > ---
> > 
> >  arch/powerpc/include/asm/kvm_book3s.h   |4 ++--
> >  arch/powerpc/kvm/book3s_hv_rmhandlers.S |6 +++---
> >  arch/powerpc/kvm/book3s_segment.S   |4 ++--
> >  3 files changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/arch/powerpc/include/asm/kvm_book3s.h 
> > b/arch/powerpc/include/asm/kvm_book3s.h
> > index b91e74a..05a875a 100644
> > --- a/arch/powerpc/include/asm/kvm_book3s.h
> > +++ b/arch/powerpc/include/asm/kvm_book3s.h
> > @@ -225,12 +225,12 @@ static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
> > return vcpu->arch.cr;
> >  }
> >  
> > -static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
> > +static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
> >  {
> > vcpu->arch.xer = val;
> >  }
> >  
> > -static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
> > +static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
> >  {
> > return vcpu->arch.xer;
> >  }
> > diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S 
> > b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> > index 4d70df2..d75be59 100644
> > --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> > +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> > @@ -870,7 +870,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
> > blt hdec_soon
> >  
> > ld  r6, VCPU_CTR(r4)
> > -   lwz r7, VCPU_XER(r4)
> > +   ld  r7, VCPU_XER(r4)
> >  
> > mtctr   r6
> > mtxer   r7
> > @@ -1103,7 +1103,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
> > mfctr   r3
> > mfxer   r4
> > std r3, VCPU_CTR(r9)
> > -   stw r4, VCPU_XER(r9)
> > +   std r4, VCPU_XER(r9)
> >  
> > /* If this is a page table miss then see if it's theirs or ours */
> > cmpwi   r12, BOOK3S_INTERRUPT_H_DATA_STORAGE
> > @@ -1675,7 +1675,7 @@ kvmppc_hdsi:
> > bl  kvmppc_msr_interrupt
> >  fast_interrupt_c_return:
> >  6: ld  r7, VCPU_CTR(r9)
> > -   lwz r8, VCPU_XER(r9)
> > +   ld  r8, VCPU_XER(r9)
> > mtctr   r7
> > mtxer   r8
> > mr  r4, r9
> > diff --git a/arch/powerpc/kvm/book3s_segment.S 
> > b/arch/powerpc/kvm/book3s_segment.S
> > index acee37c..ca8f174 100644
> > --- a/arch/powerpc/kvm/book3s_segment.S
> > +++ b/arch/powerpc/kvm/book3s_segment.S
> > @@ -123,7 +123,7 @@ no_dcbz32_on:
> > PPC_LL  r8, SVCPU_CTR(r3)
> > PPC_LL  r9, SVCPU_LR(r3)
> > lwz r10, SVCPU_CR(r3)
> > -   lwz r11, SVCPU_XER(r3)
> > +   PPC_LL  r11, SVCPU_XER(r3)
> 
> struct kvmppc_book3s_shadow_vcpu {
> bool in_use;
> ulong gpr[14];
> u32 cr;
> u32 xer;
> [...]
> 
> so at least this change looks wrong. Please double-check all fields in
> your patch again.
> 
> 
> Alex

Thanks for the review and the catch!

The xer field in kvm_vcpu_arch is already ulong, so it looks like the one in
kvmppc_book3s_shadow_vcpu is the only other case. I'll fix that and repost.

Cheers,
Sam.

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

[PATCH 6/6] llvm: A few Makefile hacks

2015-05-25 Thread Anton Blanchard
llvm accepts -fno-delete-null-pointer-checks but complains about it.
Wrap it to avoid getting enormous numbers of warnings.

Also add -no-integrated-as to disable the llvm integrated assembler,
lots of stuff currently relies on gas.
---
 Makefile | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Makefile b/Makefile
index eae539d..451290f 100644
--- a/Makefile
+++ b/Makefile
@@ -609,7 +609,12 @@ all: vmlinux
 
 include arch/$(SRCARCH)/Makefile
 
+ifneq ($(COMPILER),clang)
 KBUILD_CFLAGS  += $(call cc-option,-fno-delete-null-pointer-checks,)
+endif
+
+KBUILD_CFLAGS  += $(call cc-option,-no-integrated-as,)
+KBUILD_AFLAGS  += $(call cc-option,-no-integrated-as,)
 
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS  += -Os $(call cc-disable-warning,maybe-uninitialized,)
-- 
2.1.4

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

[PATCH 5/6] powerpc: Don't use gcc specific options on clang

2015-05-25 Thread Anton Blanchard
Add a conditional around the code to select various gcc only options:
-mabi=elfv2 vs -mcall-aixdesc, and -mcmodel=medium vs -mminimal-toc.

Signed-off-by: Anton Blanchard 
---
 arch/powerpc/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 9cf7c7c..347c80f6 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -115,6 +115,7 @@ endif
 endif
 
 CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no)
+ifneq ($(COMPILER),clang)
 ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,-mcall-aixdesc)
 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
@@ -122,6 +123,7 @@ else
 CFLAGS-$(CONFIG_PPC64) += -mcall-aixdesc
 endif
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc)
+endif
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
 CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
 
-- 
2.1.4

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

[PATCH 4/6] powerpc: Don't use -mno-strict-align on clang

2015-05-25 Thread Anton Blanchard
We added -mno-strict-align in commit f036b3681962 (powerpc: Work around little
endian gcc bug) to fix gcc bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57134

Clang doesn't understand it. We need to use a conditional because we can't use 
the
simpler call cc-option here.

Signed-off-by: Anton Blanchard 
---
 arch/powerpc/Makefile | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 7c08b4e..9cf7c7c 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -65,7 +65,10 @@ endif
 
 
 ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
-override CC+= -mlittle-endian -mno-strict-align
+override CC+= -mlittle-endian
+ifneq ($(COMPILER),clang)
+override CC+= -mno-strict-align
+endif
 override AS+= -mlittle-endian
 override LD+= -EL
 override CROSS32CC += -mlittle-endian
-- 
2.1.4

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

[PATCH 3/6] powerpc: Only use -mtraceback=no, -mno-string and -msoft-float if toolchain supports it

2015-05-25 Thread Anton Blanchard
These options are not recognised on LLVM, so use call cc-option to check
for support.

Signed-off-by: Anton Blanchard 
---
 arch/powerpc/Makefile | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 7a0daad..7c08b4e 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -111,7 +111,7 @@ else
 endif
 endif
 
-CFLAGS-$(CONFIG_PPC64) := -mtraceback=no
+CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no)
 ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,-mcall-aixdesc)
 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
@@ -158,7 +158,8 @@ asinstr := $(call as-instr,lis 
9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
 
 KBUILD_CPPFLAGS+= -Iarch/$(ARCH) $(asinstr)
 KBUILD_AFLAGS  += -Iarch/$(ARCH) $(AFLAGS-y)
-KBUILD_CFLAGS  += -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y)
+KBUILD_CFLAGS  += $(call cc-option,-msoft-float)
+KBUILD_CFLAGS  += -pipe -Iarch/$(ARCH) $(CFLAGS-y)
 CPP= $(CC) -E $(KBUILD_CFLAGS)
 
 CHECKFLAGS += -m$(CONFIG_WORD_SIZE) -D__powerpc__ 
-D__powerpc$(CONFIG_WORD_SIZE)__
@@ -190,7 +191,7 @@ KBUILD_CFLAGS   += $(call cc-option,-fno-dwarf2-cfi-asm)
 
 # Never use string load/store instructions as they are
 # often slow when they are implemented at all
-KBUILD_CFLAGS  += -mno-string
+KBUILD_CFLAGS  += $(call cc-option,-mno-string)
 
 ifeq ($(CONFIG_6xx),y)
 KBUILD_CFLAGS  += -mcpu=powerpc
-- 
2.1.4

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

[PATCH 2/6] powerpc: Only use -mabi=altivec if toolchain supports it

2015-05-25 Thread Anton Blanchard
The -mabi=altivec option is not recognised on LLVM, so use call cc-option
to check for support.

Signed-off-by: Anton Blanchard 
---
 arch/powerpc/lib/Makefile | 2 +-
 lib/raid6/Makefile| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 7902802..a47e142 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -33,6 +33,6 @@ obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o
 obj-$(CONFIG_FTR_FIXUP_SELFTEST) += feature-fixups-test.o
 
 obj-$(CONFIG_ALTIVEC)  += xor_vmx.o
-CFLAGS_xor_vmx.o += -maltivec -mabi=altivec
+CFLAGS_xor_vmx.o += -maltivec $(call cc-option,-mabi=altivec)
 
 obj-$(CONFIG_PPC64) += $(obj64-y)
diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
index c7dab06..3b10a48 100644
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -15,7 +15,7 @@ quiet_cmd_unroll = UNROLL  $@
< $< > $@ || ( rm -f $@ && exit 1 )
 
 ifeq ($(CONFIG_ALTIVEC),y)
-altivec_flags := -maltivec -mabi=altivec
+altivec_flags := -maltivec $(call cc-option,-mabi=altivec)
 endif
 
 # The GCC option -ffreestanding is required in order to compile code containing
-- 
2.1.4

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

[PATCH 1/6] powerpc: Fix duplicate const clang warning in user access code

2015-05-25 Thread Anton Blanchard
Signed-off-by: Anton Blanchard 
---
 arch/powerpc/include/asm/uaccess.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/uaccess.h 
b/arch/powerpc/include/asm/uaccess.h
index a0c071d..2a8ebae 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -265,7 +265,7 @@ do {
\
 ({ \
long __gu_err;  \
unsigned long __gu_val; \
-   const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
+   __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
__chk_user_ptr(ptr);\
if (!is_kernel_addr((unsigned long)__gu_addr))  \
might_fault();  \
@@ -279,7 +279,7 @@ do {
\
 ({ \
long __gu_err;  \
long long __gu_val; \
-   const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
+   __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
__chk_user_ptr(ptr);\
if (!is_kernel_addr((unsigned long)__gu_addr))  \
might_fault();  \
@@ -293,7 +293,7 @@ do {
\
 ({ \
long __gu_err = -EFAULT;\
unsigned long  __gu_val = 0;\
-   const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
+   __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
might_fault();  \
if (access_ok(VERIFY_READ, __gu_addr, (size)))  \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
@@ -305,7 +305,7 @@ do {
\
 ({ \
long __gu_err;  \
unsigned long __gu_val; \
-   const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
+   __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
__chk_user_ptr(ptr);\
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
(x) = (__force __typeof__(*(ptr)))__gu_val; \
-- 
2.1.4

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

[PATCH 0/6] Build ppc64le kernel with llvm/clang

2015-05-25 Thread Anton Blanchard
Now that Michael has fixed the 32 bit VDSO issue in his next branch, there are 
only
a few remaining things left to get the ppc64le kernel building with clang.

The last patch is a hack to workaround some generic Makefile issues. Hopefully 
the
relevant bits of the LLVMLinux tree will get merged upstream to fix them.

Anton Blanchard (6):
  powerpc: Fix duplicate const clang warning in user access code
  powerpc: Only use -mabi=altivec if toolchain supports it
  powerpc: Only use -mtraceback=no, -mno-string and -msoft-float if
toolchain supports it
  powerpc: Don't use -mno-strict-align on clang
  powerpc: Don't use gcc specific options on clang
  llvm: A few Makefile hacks

 Makefile   |  5 +
 arch/powerpc/Makefile  | 14 ++
 arch/powerpc/include/asm/uaccess.h |  8 
 arch/powerpc/lib/Makefile  |  2 +-
 lib/raid6/Makefile |  2 +-
 5 files changed, 21 insertions(+), 10 deletions(-)

-- 
2.1.4

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

Re: [PATCH 1/1] KVM: PPC: Book3S: correct width in XER handling

2015-05-25 Thread Alexander Graf


On 20.05.15 07:26, Sam Bobroff wrote:
> In 64 bit kernels, the Fixed Point Exception Register (XER) is a 64
> bit field (e.g. in kvm_regs and kvm_vcpu_arch) and in most places it is
> accessed as such.
> 
> This patch corrects places where it is accessed as a 32 bit field by a
> 64 bit kernel.  In some cases this is via a 32 bit load or store
> instruction which, depending on endianness, will cause either the
> lower or upper 32 bits to be missed.  In another case it is cast as a
> u32, causing the upper 32 bits to be cleared.
> 
> This patch corrects those places by extending the access methods to
> 64 bits.
> 
> Signed-off-by: Sam Bobroff 
> ---
> 
>  arch/powerpc/include/asm/kvm_book3s.h   |4 ++--
>  arch/powerpc/kvm/book3s_hv_rmhandlers.S |6 +++---
>  arch/powerpc/kvm/book3s_segment.S   |4 ++--
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/kvm_book3s.h 
> b/arch/powerpc/include/asm/kvm_book3s.h
> index b91e74a..05a875a 100644
> --- a/arch/powerpc/include/asm/kvm_book3s.h
> +++ b/arch/powerpc/include/asm/kvm_book3s.h
> @@ -225,12 +225,12 @@ static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
>   return vcpu->arch.cr;
>  }
>  
> -static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
> +static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
>  {
>   vcpu->arch.xer = val;
>  }
>  
> -static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
> +static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
>  {
>   return vcpu->arch.xer;
>  }
> diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S 
> b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> index 4d70df2..d75be59 100644
> --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> @@ -870,7 +870,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
>   blt hdec_soon
>  
>   ld  r6, VCPU_CTR(r4)
> - lwz r7, VCPU_XER(r4)
> + ld  r7, VCPU_XER(r4)
>  
>   mtctr   r6
>   mtxer   r7
> @@ -1103,7 +1103,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
>   mfctr   r3
>   mfxer   r4
>   std r3, VCPU_CTR(r9)
> - stw r4, VCPU_XER(r9)
> + std r4, VCPU_XER(r9)
>  
>   /* If this is a page table miss then see if it's theirs or ours */
>   cmpwi   r12, BOOK3S_INTERRUPT_H_DATA_STORAGE
> @@ -1675,7 +1675,7 @@ kvmppc_hdsi:
>   bl  kvmppc_msr_interrupt
>  fast_interrupt_c_return:
>  6:   ld  r7, VCPU_CTR(r9)
> - lwz r8, VCPU_XER(r9)
> + ld  r8, VCPU_XER(r9)
>   mtctr   r7
>   mtxer   r8
>   mr  r4, r9
> diff --git a/arch/powerpc/kvm/book3s_segment.S 
> b/arch/powerpc/kvm/book3s_segment.S
> index acee37c..ca8f174 100644
> --- a/arch/powerpc/kvm/book3s_segment.S
> +++ b/arch/powerpc/kvm/book3s_segment.S
> @@ -123,7 +123,7 @@ no_dcbz32_on:
>   PPC_LL  r8, SVCPU_CTR(r3)
>   PPC_LL  r9, SVCPU_LR(r3)
>   lwz r10, SVCPU_CR(r3)
> - lwz r11, SVCPU_XER(r3)
> + PPC_LL  r11, SVCPU_XER(r3)

struct kvmppc_book3s_shadow_vcpu {
bool in_use;
ulong gpr[14];
u32 cr;
u32 xer;
[...]

so at least this change looks wrong. Please double-check all fields in
your patch again.


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

[PATCH] powerpc/fsl: Add FMan Port 10G compatibles

2015-05-25 Thread Igal . Liberman
From: Igal Liberman 

This patch adds two boolean properties to FMan Port.
FMan has 3 types of ports:
- 1G ports
By default, all ports support 1G rate
- 10G Ports
Port which use 10G hardware, and configured as 10G
- 10G Best effort ports
Ports which use 1G hardware, configured as 10G, in this case,
the rate is not guaranteed.
The new properties help to distinguish the different type of ports.

Signed-off-by: Igal Liberman 

---
 .../devicetree/bindings/powerpc/fsl/fman.txt   |   13 +
 1 file changed, 13 insertions(+)

diff --git a/Documentation/devicetree/bindings/powerpc/fsl/fman.txt 
b/Documentation/devicetree/bindings/powerpc/fsl/fman.txt
index edda55f..76a7cba 100644
--- a/Documentation/devicetree/bindings/powerpc/fsl/fman.txt
+++ b/Documentation/devicetree/bindings/powerpc/fsl/fman.txt
@@ -189,6 +189,19 @@ PROPERTIES
Definition: There is one reg region describing the port
configuration registers.
 
+- 10G-support
+   Usage: optional
+   Value type: boolean
+   Definition: The default port rate is 1G.
+   If this property exists, the port is configured as 10G port.
+
+- best-effort-port
+   Usage: optional
+   Value type: boolean
+   Definition: Can be defined only if 10G-support is set.
+   This property marks a best-effort 10G port (1G hardware
+   configured as 10G, 10G rate is not guaranteed).
+
 EXAMPLE
 
 port@a8000 {
-- 
1.7.9.5

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

Re: [alsa-devel] [PATCH] ASoC: fsl_spdif: Don't try to round-up for clock divisor calculation

2015-05-25 Thread Nicolin Chen
On Mon, May 25, 2015 at 12:13:45PM -0300, Fabio Estevam wrote:
> Hi Nicolin,
> 
> On Mon, May 25, 2015 at 12:11 PM, Nicolin Chen  wrote:
> 
> > Hi Mark,
> >
> > Is that possible for you to provisionally revert this patch?
> > I wanted to wait for the test result from Fabio or Zidan in
> > the Cc list because I don't have a test environment for SPDIF
> > even though this change seems to make sense.
> 
> I currently don't have access to a SPDIF receiver to test it.

Okay, let's wait for Zidan then. We only need to test the
playback route of supporting sample rates.

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

Re: [alsa-devel] [PATCH] ASoC: fsl_spdif: Don't try to round-up for clock divisor calculation

2015-05-25 Thread Fabio Estevam
Hi Nicolin,

On Mon, May 25, 2015 at 12:11 PM, Nicolin Chen  wrote:

> Hi Mark,
>
> Is that possible for you to provisionally revert this patch?
> I wanted to wait for the test result from Fabio or Zidan in
> the Cc list because I don't have a test environment for SPDIF
> even though this change seems to make sense.

I currently don't have access to a SPDIF receiver to test it.

Regards,

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

Re: [PATCH] ASoC: fsl_spdif: Don't try to round-up for clock divisor calculation

2015-05-25 Thread Nicolin Chen
On Mon, May 25, 2015 at 12:58:12PM +0100, Mark Brown wrote:
> On Sun, May 24, 2015 at 01:12:41AM -0700, Nicolin Chen wrote:
> > As commit 6c8ca30eec7b ("ASoC: fsl_ssi: Don't try to round-up for PM
> > divisor calculation") mentioned that there's no more need to use a
> > round up work around to get a better divisor since the clk-divider
> > driver has been refined a lot.
> 
> Applied, thanks.

Hi Mark,

Is that possible for you to provisionally revert this patch?
I wanted to wait for the test result from Fabio or Zidan in
the Cc list because I don't have a test environment for SPDIF
even though this change seems to make sense.

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

Re: [PATCH] ASoC: fsl_spdif: Don't try to round-up for clock divisor calculation

2015-05-25 Thread Mark Brown
On Sun, May 24, 2015 at 01:12:41AM -0700, Nicolin Chen wrote:
> As commit 6c8ca30eec7b ("ASoC: fsl_ssi: Don't try to round-up for PM
> divisor calculation") mentioned that there's no more need to use a
> round up work around to get a better divisor since the clk-divider
> driver has been refined a lot.

Applied, thanks.


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

Re: [PATCH V8 00/28] Add new powerpc specific ELF core notes

2015-05-25 Thread Anshuman Khandual
On 05/19/2015 08:37 PM, Anshuman Khandual wrote:
> From: Anshuman Khandual 
> 
>   This patch series adds twelve new ELF core note sections which can
> be used with existing ptrace request PTRACE_GETREGSET-SETREGSET for accessing
> various transactional memory and other miscellaneous debug register sets on
> powerpc platform.
> 
> Previous versions:
> ==
> RFC: https://lkml.org/lkml/2014/4/1/292
> V1:  https://lkml.org/lkml/2014/4/2/43
> V2:  https://lkml.org/lkml/2014/5/5/88
> V3:  https://lkml.org/lkml/2014/5/23/486
> V4:  https://lkml.org/lkml/2014/11/11/6
> V5:  https://lkml.org/lkml/2014/11/25/134
> V6:  https://lkml.org/lkml/2014/12/2/98
> V7:  https://lkml.org/lkml/2015/1/14/19
> 
> Changes in V8:
> --
> - Split the misc register set into individual ELF core notes
> - Implemented support for VSX register set (on and off TM)
> - Implemented support for EBB register set
> - Implemented review comments on previous versions
> - Some code re-arrangements, re-writes and documentation
> - Added comprehensive list of test cases into selftests


These patches are available for pull from this location mentioned below.

https://github.com/akhandual/linux.git ptrace_powerpc_v8

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

Re: [PATCH V5 00/13] POWER DSCR fixes, improvements, docs and tests

2015-05-25 Thread Anshuman Khandual
On 05/21/2015 12:13 PM, Anshuman Khandual wrote:
>   This patch series has patches for POWER DSCR fixes, improvements,
> in code documentaion, kernel support user documentation and selftest based
> test cases. It has got five test cases which are derived from Anton's DSCR
> test bucket which can be listed as follows.
> 
> (1) http://ozlabs.org/~anton/junkcode/dscr_default_test.c
> (2) http://ozlabs.org/~anton/junkcode/dscr_explicit_test.c
> (3) http://ozlabs.org/~anton/junkcode/dscr_inherit_exec_test.c
> (4) http://ozlabs.org/~anton/junkcode/dscr_inherit_test.c
> (5) http://ozlabs.org/~anton/junkcode/user_dscr_test.c
> 
> NOTE1: Anton's original inherit exec test expected the child to have
> system default DSCR value instead of the inherited DSCR value from
> it's parent. But looks like thats not the case when we execute the
> test, it always inherits it's parent's DSCR value over the exec call
> as well. So I have changed the test program assuming its correct to
> have the inherited DSCR value in the fork/execed child program.
> Please let me know if thats not correct and I am missing something
> there.
> 
> Changes in V5:
> -
> - Fixed build problem with get_default_dscr/set_default_dscr functions
>   by checking on the return values of read & write system calls.

These patches are available for pull from this location mentioned below.

https://github.com/akhandual/linux.git dscr_v5

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