Re: [PATCH V2] ASoC: fsl_esai: fix register setting issue in RIGHT_J mode

2019-02-18 Thread Greg KH
On Mon, Feb 18, 2019 at 02:08:52AM +, S.j. Wang wrote:
> Fixes commit 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver")
> 
> The ESAI_xCR_xWA is xCR's bit, not the xCCR's bit, driver set it to
> wrong register, correct it.
> 
> Signed-off-by: Shengjiu Wang 
> Reviewed-by: Fabio Estevam 
> Ackedy-by: Nicolin Chen 
> ---
> Changes in v2
> - add Fixes tag and cc stable kernel.



This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.




RE: [PATCH V2] ASoC: fsl_esai: fix register setting issue in RIGHT_J mode

2019-02-18 Thread S.j. Wang
Thanks, will send the patch again.

Best regards
Wang shengjiu
> 
> On Mon, Feb 18, 2019 at 02:08:52AM +, S.j. Wang wrote:
> > Fixes commit 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver")
> >
> > The ESAI_xCR_xWA is xCR's bit, not the xCCR's bit, driver set it to
> > wrong register, correct it.
> >
> > Signed-off-by: Shengjiu Wang 
> > Reviewed-by: Fabio Estevam 
> > Ackedy-by: Nicolin Chen 
> > ---
> > Changes in v2
> > - add Fixes tag and cc stable kernel.
> 
> 
> 
> This is not the correct way to submit patches for inclusion in the stable
> kernel tree.  Please read:
> 
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
> w.kernel.org%2Fdoc%2Fhtml%2Flatest%2Fprocess%2Fstable-kernel-
> rules.html&data=02%7C01%7Cshengjiu.wang%40nxp.com%7C16b1bd8
> d2f1c43b82dd108d695779d87%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C
> 0%7C0%7C636860738312039576&sdata=l5OkD8ToHrcGa4dbXOuHdFTIF
> pVdN9u5AzCZKj2C5Ew%3D&reserved=0
> for how to do this properly.
> 
> 


[PATCH V3] ASoC: fsl_esai: fix register setting issue in RIGHT_J mode

2019-02-18 Thread S.j. Wang
The ESAI_xCR_xWA is xCR's bit, not the xCCR's bit, driver set it to
wrong register, correct it.

Fixes 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver")
Cc: 
Signed-off-by: Shengjiu Wang 
Reviewed-by: Fabio Estevam 
Ackedy-by: Nicolin Chen 
---
Changes in v3
- Add Cc: 

 sound/soc/fsl/fsl_esai.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index 57b484768a58..afe67c865330 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -398,7 +398,8 @@ static int fsl_esai_set_dai_fmt(struct snd_soc_dai *dai, 
unsigned int fmt)
break;
case SND_SOC_DAIFMT_RIGHT_J:
/* Data on rising edge of bclk, frame high, right aligned */
-   xccr |= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP | ESAI_xCR_xWA;
+   xccr |= ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP;
+   xcr  |= ESAI_xCR_xWA;
break;
case SND_SOC_DAIFMT_DSP_A:
/* Data on rising edge of bclk, frame high, 1clk before data */
@@ -455,12 +456,12 @@ static int fsl_esai_set_dai_fmt(struct snd_soc_dai *dai, 
unsigned int fmt)
return -EINVAL;
}
 
-   mask = ESAI_xCR_xFSL | ESAI_xCR_xFSR;
+   mask = ESAI_xCR_xFSL | ESAI_xCR_xFSR | ESAI_xCR_xWA;
regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, mask, xcr);
regmap_update_bits(esai_priv->regmap, REG_ESAI_RCR, mask, xcr);
 
mask = ESAI_xCCR_xCKP | ESAI_xCCR_xHCKP | ESAI_xCCR_xFSP |
-   ESAI_xCCR_xFSD | ESAI_xCCR_xCKD | ESAI_xCR_xWA;
+   ESAI_xCCR_xFSD | ESAI_xCCR_xCKD;
regmap_update_bits(esai_priv->regmap, REG_ESAI_TCCR, mask, xccr);
regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR, mask, xccr);
 
-- 
1.9.1



Re: [RFC PATCH 4/5] powerpc: move KASAN into its own subdirectory

2019-02-18 Thread Michael Ellerman
christophe leroy  writes:

> Le 15/02/2019 à 01:04, Daniel Axtens a écrit :
>> In preparation for adding ppc64 implementations, break out the
>> code into its own subdirectory.
>
> That's not a bad idea, arch/powerpc/mm is rather messy with lot of
> subarch stuff.

I'm always happy to have more directories with more focused content.

cheers


Re: [PATCH v5 3/3] powerpc/32: Add KASAN support

2019-02-18 Thread Michael Ellerman
Christophe Leroy  writes:

> diff --git a/arch/powerpc/include/asm/ppc_asm.h 
> b/arch/powerpc/include/asm/ppc_asm.h
> index e0637730a8e7..dba2c1038363 100644
> --- a/arch/powerpc/include/asm/ppc_asm.h
> +++ b/arch/powerpc/include/asm/ppc_asm.h
> @@ -251,6 +251,10 @@ GLUE(.,name):
>  
>  #define _GLOBAL_TOC(name) _GLOBAL(name)
>  
> +#define KASAN_OVERRIDE(x, y) \
> + .weak x; \
> + .set x, y
> +

Can you add a comment describing what that does and why?

> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> index 879b36602748..fc4c42262694 100644
> --- a/arch/powerpc/kernel/Makefile
> +++ b/arch/powerpc/kernel/Makefile
> @@ -16,8 +16,9 @@ CFLAGS_prom_init.o  += -fPIC
>  CFLAGS_btext.o   += -fPIC
>  endif
>  
> -CFLAGS_cputable.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
> -CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
> +CFLAGS_early_32.o += -DDISABLE_BRANCH_PROFILING
> +CFLAGS_cputable.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) 
> -DDISABLE_BRANCH_PROFILING
> +CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) 
> -DDISABLE_BRANCH_PROFILING

Why do we need to disable branch profiling now?

I'd probably be happier if all the CFLAGS changes were done in a leadup
patch to make them more obvious.

> diff --git a/arch/powerpc/kernel/prom_init_check.sh 
> b/arch/powerpc/kernel/prom_init_check.sh
> index 667df97d2595..da6bb16e0876 100644
> --- a/arch/powerpc/kernel/prom_init_check.sh
> +++ b/arch/powerpc/kernel/prom_init_check.sh
> @@ -16,8 +16,16 @@
>  # If you really need to reference something from prom_init.o add
>  # it to the list below:
>  
> +grep CONFIG_KASAN=y .config >/dev/null

Just to be safe "^CONFIG_KASAN=y$" ?

> +if [ $? -eq 0 ]
> +then
> + MEMFCT="__memcpy __memset"
> +else
> + MEMFCT="memcpy memset"
> +fi

MEM_FUNCS ?

> diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
> index 3bf9fc6fd36c..ce8d4a9f810a 100644
> --- a/arch/powerpc/lib/Makefile
> +++ b/arch/powerpc/lib/Makefile
> @@ -8,6 +8,14 @@ ccflags-$(CONFIG_PPC64)  := $(NO_MINIMAL_TOC)
>  CFLAGS_REMOVE_code-patching.o = $(CC_FLAGS_FTRACE)
>  CFLAGS_REMOVE_feature-fixups.o = $(CC_FLAGS_FTRACE)
>  
> +KASAN_SANITIZE_code-patching.o := n
> +KASAN_SANITIZE_feature-fixups.o := n
> +
> +ifdef CONFIG_KASAN
> +CFLAGS_code-patching.o += -DDISABLE_BRANCH_PROFILING
> +CFLAGS_feature-fixups.o += -DDISABLE_BRANCH_PROFILING
> +endif

There's that branch profiling again, though here it's only if KASAN is enabled.

> diff --git a/arch/powerpc/mm/kasan_init.c b/arch/powerpc/mm/kasan_init.c
> new file mode 100644
> index ..bd8e0a263e12
> --- /dev/null
> +++ b/arch/powerpc/mm/kasan_init.c
> @@ -0,0 +1,114 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#define DISABLE_BRANCH_PROFILING
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +void __init kasan_early_init(void)
> +{
> + unsigned long addr = KASAN_SHADOW_START;
> + unsigned long end = KASAN_SHADOW_END;
> + unsigned long next;
> + pmd_t *pmd = pmd_offset(pud_offset(pgd_offset_k(addr), addr), addr);

Can none of those fail?


cheers


Re: [PATCH v04] powerpc/numa: Perform full re-add of CPU for PRRN/VPHN topology update

2019-02-18 Thread Michal Suchánek
On Thu, 14 Feb 2019 09:56:26 -0600
Michael Bringmann  wrote:

Hello,

> To: linuxppc-dev@lists.ozlabs.org
> To: linux-ker...@vger.kernel.org
> Benjamin Herrenschmidt 
> Paul Mackerras 
> Michael Ellerman 
> Nathan Lynch 
> Corentin Labbe 
> Tyrel Datwyler 
> Srikar Dronamraju 
> Guenter Roeck 
> Michael Bringmann 
> "Oliver O'Halloran" 
> Russell Currey 
> Haren Myneni 
> Al Viro 
> Kees Cook 
> Nicholas Piggin 
> Rob Herring 
> Juliet Kim 
> Thomas Falcon 
> Date: 2018-11-05 16:14:12 -0600
> Subject: [PATCH v04] powerpc/numa: Perform full re-add of CPU for PRRN/VPHN 
> topology update

Looks like something went wrong with the e-mail headers.

Maybe you should re-send?

Thanks

Michal

> 
> On pseries systems, performing changes to a partition's affinity
> can result in altering the nodes a CPU is assigned to the
> current system.  For example, some systems are subject to resource
> balancing operations by the operator or control software.  In such
> environments, system CPUs may be in node 1 and 3 at boot, and be
> moved to nodes 2, 3, and 5, for better performance.
> 
> The current implementation attempts to recognize such changes within
> the powerpc-specific version of arch_update_cpu_topology to modify a
> range of system data structures directly.  However, some scheduler
> data structures may be inaccessible, or the timing of a node change
> may still lead to corruption or error in other modules (e.g. user
> space) which do not receive notification of these changes.
> 
> This patch modifies the PRRN/VPHN topology update worker function to
> recognize an affinity change for a CPU, and to perform a full DLPAR
> remove and add of the CPU instead of dynamically changing its node
> to resolve this issue.
> 
> [Based upon patch submission:
> Subject: [PATCH] powerpc/pseries: Perform full re-add of CPU for topology 
> update post-migration
> From: Nathan Fontenot 
> Date: Tue Oct 30 05:43:36 AEDT 2018
> ]
> 
> [Replace patch submission:
> Subject: [PATCH] powerpc/topology: Update numa mask when cpu node mapping 
> changes
> From: Srikar Dronamraju 
> Date: Wed Oct 10 15:24:46 AEDT 2018
> ]
> 
> Signed-off-by: Michael Bringmann 
> ---
> Changes in v04:
>   -- Revise tests in topology_timer_fn to check vphn_enabled before 
> prrn_enabled
>   -- Remove unnecessary changes to numa_update_cpu_topology
> Changes in v03:
>   -- Fixed under-scheduling of topo updates.
> Changes in v02:
>   -- Reuse more of the previous implementation to reduce patch size
>   -- Replace former calls to numa_update_cpu_topology(false) by
>  topology_schedule_update
>   -- Make sure that we report topology changes back through
>  arch_update_cpu_topology
>   -- Fix problem observed in powerpc next kernel with updating
>  cpu_associativity_changes_mask in timer_topology_fn when both
>  prrn_enabled and vphn_enabled, and many extra CPUs are possible,
>  but not installed.
>   -- Fix problem with updating cpu_associativity_changes_mask when
>  VPHN associativity information does not arrive until after first
>  call to update topology occurs.
> ---
>  arch/powerpc/include/asm/topology.h |7 +
>  arch/powerpc/kernel/rtasd.c |2 +
>  arch/powerpc/mm/numa.c  |   47 
> +++
>  3 files changed, 34 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/topology.h 
> b/arch/powerpc/include/asm/topology.h
> index f85e2b01c3df..79505c371fd5 100644
> --- a/arch/powerpc/include/asm/topology.h
> +++ b/arch/powerpc/include/asm/topology.h
> @@ -42,7 +42,7 @@ extern void __init dump_numa_cpu_topology(void);
>  
>  extern int sysfs_add_device_to_node(struct device *dev, int nid);
>  extern void sysfs_remove_device_from_node(struct device *dev, int nid);
> -extern int numa_update_cpu_topology(bool cpus_locked);
> +extern void topology_schedule_update(void);
>  
>  static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node)
>  {
> @@ -77,10 +77,7 @@ static inline void sysfs_remove_device_from_node(struct 
> device *dev,
>  {
>  }
>  
> -static inline int numa_update_cpu_topology(bool cpus_locked)
> -{
> - return 0;
> -}
> +static inline void topology_schedule_update(void) {}
>  
>  static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) 
> {}
>  
> diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c
> index 8a1746d755c9..b1828de7ab78 100644
> --- a/arch/powerpc/kernel/rtasd.c
> +++ b/arch/powerpc/kernel/rtasd.c
> @@ -285,7 +285,7 @@ static void handle_prrn_event(s32 scope)
>* the RTAS event.
>*/
>   pseries_devicetree_update(-scope);
> - numa_update_cpu_topology(false);
> + topology_schedule_update();
>  }
>  
>  static void handle_rtas_event(const struct rtas_error_log *log)
> diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
> index b5d1c45c1475..eb63479f09d7 100644
> --- a/arch/powerpc/mm/numa.c
> +++ b/arch/powerpc/mm/numa.c
> @@ -1077,6 +1077,8 @@ s

[PATCH] powerpc: dump as a single line areas mapping a single physical page.

2019-02-18 Thread Christophe Leroy
When using KASAN, there are parts of the shadow area where all
pages are mapped to the kasan_early_shadow_page. It is pointless
to dump one line for each of those pages (in the example below there
are 7168 entries pointing to the same physical page).

~# cat /sys/kernel/debug/kernel_page_tables
 ...
---[ kasan shadow mem start ]---
0xf7c0-0xf8bf 0x06fac000   16Mrw   present   
dirty  accessed
0xf8c0-0xf8c03fff 0x00cd   16Krpresent   
dirty  accessed
0xf8c04000-0xf8c07fff 0x00cd   16Krpresent   
dirty  accessed
0xf8c08000-0xf8c0bfff 0x00cd   16Krpresent   
dirty  accessed
0xf8c0c000-0xf8c0 0x00cd   16Krpresent   
dirty  accessed
0xf8c1-0xf8c13fff 0x00cd   16Krpresent   
dirty  accessed
 ... 7168 identical lines
0xffbfc000-0xffbf 0x00cd   16Krpresent   
dirty  accessed
---[ kasan shadow mem end ]---
 ...

This patch modifies linux table dump to dump as a single line areas
where all addresses points to the same physical page. That physical
address is put inside [] to show that all virt pages points to the
same phys page.

~# cat /sys/kernel/debug/kernel_page_tables
 ...
---[ kasan shadow mem start ]---
0xf7c0-0xf8bf  0x06fac00016Mrw   present   
dirty  accessed
0xf8c0-0xffbf [0x00cd]   16Krpresent   
dirty  accessed
---[ kasan shadow mem end ]---
 ...

Signed-off-by: Christophe Leroy 

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/mm/dump_linuxpagetables.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/mm/dump_linuxpagetables.c 
b/arch/powerpc/mm/dump_linuxpagetables.c
index 6aa41669ac1a..b0da447197d4 100644
--- a/arch/powerpc/mm/dump_linuxpagetables.c
+++ b/arch/powerpc/mm/dump_linuxpagetables.c
@@ -143,14 +143,19 @@ static void dump_addr(struct pg_state *st, unsigned long 
addr)
unsigned long delta;
 
 #ifdef CONFIG_PPC64
-   seq_printf(st->seq, "0x%016lx-0x%016lx ", st->start_address, addr-1);
-   seq_printf(st->seq, "0x%016lx ", st->start_pa);
+#define REG"0x%016lx"
 #else
-   seq_printf(st->seq, "0x%08lx-0x%08lx ", st->start_address, addr - 1);
-   seq_printf(st->seq, "0x%08lx ", st->start_pa);
+#define REG"0x%08lx"
 #endif
 
-   delta = (addr - st->start_address) >> 10;
+   seq_printf(st->seq, REG "-" REG " ", st->start_address, addr - 1);
+   if (st->start_pa == st->last_pa && st->start_address + PAGE_SIZE != 
addr) {
+   seq_printf(st->seq, "[" REG "]", st->start_pa);
+   delta = PAGE_SIZE >> 10;
+   } else {
+   seq_printf(st->seq, " " REG " ", st->start_pa);
+   delta = (addr - st->start_address) >> 10;
+   }
/* Work out what appropriate unit to use */
while (!(delta & 1023) && unit[1]) {
delta >>= 10;
@@ -184,7 +189,8 @@ static void note_page(struct pg_state *st, unsigned long 
addr,
 */
} else if (flag != st->current_flags || level != st->level ||
   addr >= st->marker[1].start_address ||
-  pa != st->last_pa + PAGE_SIZE) {
+  (pa != st->last_pa + PAGE_SIZE &&
+   (pa != st->start_pa || st->start_pa != st->last_pa))) {
 
/* Check the PTE flags */
if (st->current_flags) {
-- 
2.13.3



Re: [RFC PATCH 4/5] powerpc: move KASAN into its own subdirectory

2019-02-18 Thread Christophe Leroy




Le 18/02/2019 à 10:14, Michael Ellerman a écrit :

christophe leroy  writes:


Le 15/02/2019 à 01:04, Daniel Axtens a écrit :

In preparation for adding ppc64 implementations, break out the
code into its own subdirectory.


That's not a bad idea, arch/powerpc/mm is rather messy with lot of
subarch stuff.


I'm always happy to have more directories with more focused content.



Nice to know how to make you happy :)

I'll send you a patch for moving all page table dumping stuff into a 
subdirectory.


Christophe


[PATCH] powerpc: Move page table dump files in a dedicated subdirectory

2019-02-18 Thread Christophe Leroy
This patch moves the files related to page table dump in a
dedicated subdirectory.

The purpose is to clean a bit arch/powerpc/mm by regrouping
multiple files handling a dedicated function.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/Kconfig.debug   |  4 
 arch/powerpc/mm/Makefile | 10 +-
 arch/powerpc/mm/ptdump/Makefile  |  9 +
 arch/powerpc/mm/{ => ptdump}/dump_bats.c |  0
 arch/powerpc/mm/{ => ptdump}/dump_hashpagetable.c|  0
 arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables-8xx.c  |  0
 arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables-book3s64.c |  0
 arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables-generic.c  |  0
 arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables.c  |  0
 arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables.h  |  0
 arch/powerpc/mm/{ => ptdump}/dump_sr.c   |  0
 11 files changed, 10 insertions(+), 13 deletions(-)
 create mode 100644 arch/powerpc/mm/ptdump/Makefile
 rename arch/powerpc/mm/{ => ptdump}/dump_bats.c (100%)
 rename arch/powerpc/mm/{ => ptdump}/dump_hashpagetable.c (100%)
 rename arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables-8xx.c (100%)
 rename arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables-book3s64.c (100%)
 rename arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables-generic.c (100%)
 rename arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables.c (100%)
 rename arch/powerpc/mm/{ => ptdump}/dump_linuxpagetables.h (100%)
 rename arch/powerpc/mm/{ => ptdump}/dump_sr.c (100%)

diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index f4961fbcb48d..4e00cb0a5464 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -361,10 +361,6 @@ config PPC_PTDUMP
 
  If you are unsure, say N.
 
-config PPC_HTDUMP
-   def_bool y
-   depends on PPC_PTDUMP && PPC_BOOK3S_64
-
 config PPC_FAST_ENDIAN_SWITCH
bool "Deprecated fast endian-switch syscall"
 depends on DEBUG_KERNEL && PPC_BOOK3S_64
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index d974f7bcb177..ab2ed80d224d 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -47,14 +47,6 @@ obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o
 obj-$(CONFIG_HIGHMEM)  += highmem.o
 obj-$(CONFIG_PPC_COPRO_BASE)   += copro_fault.o
 obj-$(CONFIG_SPAPR_TCE_IOMMU)  += mmu_context_iommu.o
-obj-$(CONFIG_PPC_PTDUMP)   += dump_linuxpagetables.o
-ifdef CONFIG_PPC_PTDUMP
-obj-$(CONFIG_4xx)  += dump_linuxpagetables-generic.o
-obj-$(CONFIG_PPC_8xx)  += dump_linuxpagetables-8xx.o
-obj-$(CONFIG_PPC_BOOK3E_MMU)   += dump_linuxpagetables-generic.o
-obj-$(CONFIG_PPC_BOOK3S_32)+= dump_linuxpagetables-generic.o dump_bats.o 
dump_sr.o
-obj-$(CONFIG_PPC_BOOK3S_64)+= dump_linuxpagetables-book3s64.o
-endif
-obj-$(CONFIG_PPC_HTDUMP)   += dump_hashpagetable.o
+obj-$(CONFIG_PPC_PTDUMP)   += ptdump/
 obj-$(CONFIG_PPC_MEM_KEYS) += pkeys.o
 obj-$(CONFIG_KASAN)+= kasan/
diff --git a/arch/powerpc/mm/ptdump/Makefile b/arch/powerpc/mm/ptdump/Makefile
new file mode 100644
index ..c60578d16ac4
--- /dev/null
+++ b/arch/powerpc/mm/ptdump/Makefile
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-y  += dump_linuxpagetables.o
+
+obj-$(CONFIG_4xx)  += dump_linuxpagetables-generic.o
+obj-$(CONFIG_PPC_8xx)  += dump_linuxpagetables-8xx.o
+obj-$(CONFIG_PPC_BOOK3E_MMU)   += dump_linuxpagetables-generic.o
+obj-$(CONFIG_PPC_BOOK3S_32)+= dump_linuxpagetables-generic.o dump_bats.o 
dump_sr.o
+obj-$(CONFIG_PPC_BOOK3S_64)+= dump_linuxpagetables-book3s64.o 
dump_hashpagetable.o
diff --git a/arch/powerpc/mm/dump_bats.c b/arch/powerpc/mm/ptdump/dump_bats.c
similarity index 100%
rename from arch/powerpc/mm/dump_bats.c
rename to arch/powerpc/mm/ptdump/dump_bats.c
diff --git a/arch/powerpc/mm/dump_hashpagetable.c 
b/arch/powerpc/mm/ptdump/dump_hashpagetable.c
similarity index 100%
rename from arch/powerpc/mm/dump_hashpagetable.c
rename to arch/powerpc/mm/ptdump/dump_hashpagetable.c
diff --git a/arch/powerpc/mm/dump_linuxpagetables-8xx.c 
b/arch/powerpc/mm/ptdump/dump_linuxpagetables-8xx.c
similarity index 100%
rename from arch/powerpc/mm/dump_linuxpagetables-8xx.c
rename to arch/powerpc/mm/ptdump/dump_linuxpagetables-8xx.c
diff --git a/arch/powerpc/mm/dump_linuxpagetables-book3s64.c 
b/arch/powerpc/mm/ptdump/dump_linuxpagetables-book3s64.c
similarity index 100%
rename from arch/powerpc/mm/dump_linuxpagetables-book3s64.c
rename to arch/powerpc/mm/ptdump/dump_linuxpagetables-book3s64.c
diff --git a/arch/powerpc/mm/dump_linuxpagetables-generic.c 
b/arch/powerpc/mm/ptdump/dump_linuxpagetables-generic.c
similarity index 100%
rename from arch/powerpc/mm/dump_linuxpagetables-generic.c
rename to arch/powerpc/mm/ptdump/dump_linuxpagetables-generic.c
diff --git a/arch/powerpc/mm/dump_linuxpagetables.c 
b/

[PATCH -next] powerpc/pseries: Drop pointless static qualifier in vpa_debugfs_init()

2019-02-18 Thread YueHaibing
There is no need to have the 'struct dentry *vpa_dir' variable static
since new value always be assigned before use it.

Signed-off-by: YueHaibing 
---
 arch/powerpc/platforms/pseries/lpar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/lpar.c 
b/arch/powerpc/platforms/pseries/lpar.c
index f2a9f0adc2d3..f649c1b652eb 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -1263,7 +1263,7 @@ static int __init vpa_debugfs_init(void)
 {
char name[16];
long i;
-   static struct dentry *vpa_dir;
+   struct dentry *vpa_dir;
 
if (!firmware_has_feature(FW_FEATURE_SPLPAR))
return 0;





[PATCH -next] powerpc/pseries: Fix platform_no_drv_owner.cocci warnings

2019-02-18 Thread YueHaibing
Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: YueHaibing 
---
 arch/powerpc/platforms/pseries/papr_scm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/papr_scm.c 
b/arch/powerpc/platforms/pseries/papr_scm.c
index bba281b1fe1b..e3f5c1a01950 100644
--- a/arch/powerpc/platforms/pseries/papr_scm.c
+++ b/arch/powerpc/platforms/pseries/papr_scm.c
@@ -21,6 +21,7 @@
 (1ul << ND_CMD_GET_CONFIG_DATA) | \
 (1ul << ND_CMD_SET_CONFIG_DATA))
 
+
 struct papr_scm_priv {
struct platform_device *pdev;
struct device_node *dn;
@@ -358,7 +359,6 @@ static struct platform_driver papr_scm_driver = {
.remove = papr_scm_remove,
.driver = {
.name = "papr_scm",
-   .owner = THIS_MODULE,
.of_match_table = papr_scm_match,
},
 };





Re: [PATCH -next] powerpc/pseries: Fix platform_no_drv_owner.cocci warnings

2019-02-18 Thread Julia Lawall



On Mon, 18 Feb 2019, YueHaibing wrote:

> Remove .owner field if calls are used which set it automatically
> Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
>
> Signed-off-by: YueHaibing 
> ---
>  arch/powerpc/platforms/pseries/papr_scm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c 
> b/arch/powerpc/platforms/pseries/papr_scm.c
> index bba281b1fe1b..e3f5c1a01950 100644
> --- a/arch/powerpc/platforms/pseries/papr_scm.c
> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
> @@ -21,6 +21,7 @@
>(1ul << ND_CMD_GET_CONFIG_DATA) | \
>(1ul << ND_CMD_SET_CONFIG_DATA))
>
> +

No need to add a blank line.

julia

>  struct papr_scm_priv {
>   struct platform_device *pdev;
>   struct device_node *dn;
> @@ -358,7 +359,6 @@ static struct platform_driver papr_scm_driver = {
>   .remove = papr_scm_remove,
>   .driver = {
>   .name = "papr_scm",
> - .owner = THIS_MODULE,
>   .of_match_table = papr_scm_match,
>   },
>  };
>
>
>
>


Re: [PATCH -next] powerpc/pseries: Fix platform_no_drv_owner.cocci warnings

2019-02-18 Thread YueHaibing
On 2019/2/18 20:53, Julia Lawall wrote:
> 
> 
> On Mon, 18 Feb 2019, YueHaibing wrote:
> 
>> Remove .owner field if calls are used which set it automatically
>> Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
>>
>> Signed-off-by: YueHaibing 
>> ---
>>  arch/powerpc/platforms/pseries/papr_scm.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c 
>> b/arch/powerpc/platforms/pseries/papr_scm.c
>> index bba281b1fe1b..e3f5c1a01950 100644
>> --- a/arch/powerpc/platforms/pseries/papr_scm.c
>> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
>> @@ -21,6 +21,7 @@
>>   (1ul << ND_CMD_GET_CONFIG_DATA) | \
>>   (1ul << ND_CMD_SET_CONFIG_DATA))
>>
>> +
> 
> No need to add a blank line.

Yes, will fix it.

> 
> julia
> 
>>  struct papr_scm_priv {
>>  struct platform_device *pdev;
>>  struct device_node *dn;
>> @@ -358,7 +359,6 @@ static struct platform_driver papr_scm_driver = {
>>  .remove = papr_scm_remove,
>>  .driver = {
>>  .name = "papr_scm",
>> -.owner = THIS_MODULE,
>>  .of_match_table = papr_scm_match,
>>  },
>>  };
>>
>>
>>
>>
> 
> .
> 



[PATCH v2 -next] powerpc/pseries: Fix platform_no_drv_owner.cocci warnings

2019-02-18 Thread YueHaibing
Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: YueHaibing 
---
 arch/powerpc/platforms/pseries/papr_scm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/papr_scm.c 
b/arch/powerpc/platforms/pseries/papr_scm.c
index bba281b1fe1b..679bf2420bc1 100644
--- a/arch/powerpc/platforms/pseries/papr_scm.c
+++ b/arch/powerpc/platforms/pseries/papr_scm.c
@@ -358,7 +358,6 @@ static struct platform_driver papr_scm_driver = {
.remove = papr_scm_remove,
.driver = {
.name = "papr_scm",
-   .owner = THIS_MODULE,
.of_match_table = papr_scm_match,
},
 };





[PATCH 4.4 068/143] block/swim3: Fix -EBUSY error when re-opening device after unmount

2019-02-18 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 296dcc40f2f2e402facf7cd26cf3f2c8f4b17d47 ]

When the block device is opened with FMODE_EXCL, ref_count is set to -1.
This value doesn't get reset when the device is closed which means the
device cannot be opened again. Fix this by checking for refcount <= 0
in the release method.

Reported-and-tested-by: Stan Johnson 
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Finn Thain 
Signed-off-by: Jens Axboe 
Signed-off-by: Sasha Levin 
---
 drivers/block/swim3.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index c264f2d284a7..2e0a9e2531cb 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -1027,7 +1027,11 @@ static void floppy_release(struct gendisk *disk, fmode_t 
mode)
struct swim3 __iomem *sw = fs->swim3;
 
mutex_lock(&swim3_mutex);
-   if (fs->ref_count > 0 && --fs->ref_count == 0) {
+   if (fs->ref_count > 0)
+   --fs->ref_count;
+   else if (fs->ref_count == -1)
+   fs->ref_count = 0;
+   if (fs->ref_count == 0) {
swim3_action(fs, MOTOR_OFF);
out_8(&sw->control_bic, 0xff);
swim3_select(fs, RELAX);
-- 
2.19.1





[PATCH 3.18 052/108] block/swim3: Fix -EBUSY error when re-opening device after unmount

2019-02-18 Thread Greg Kroah-Hartman
3.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 296dcc40f2f2e402facf7cd26cf3f2c8f4b17d47 ]

When the block device is opened with FMODE_EXCL, ref_count is set to -1.
This value doesn't get reset when the device is closed which means the
device cannot be opened again. Fix this by checking for refcount <= 0
in the release method.

Reported-and-tested-by: Stan Johnson 
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Finn Thain 
Signed-off-by: Jens Axboe 
Signed-off-by: Sasha Levin 
---
 drivers/block/swim3.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index 523ee8fd4c15..eaf1336623aa 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -1027,7 +1027,11 @@ static void floppy_release(struct gendisk *disk, fmode_t 
mode)
struct swim3 __iomem *sw = fs->swim3;
 
mutex_lock(&swim3_mutex);
-   if (fs->ref_count > 0 && --fs->ref_count == 0) {
+   if (fs->ref_count > 0)
+   --fs->ref_count;
+   else if (fs->ref_count == -1)
+   fs->ref_count = 0;
+   if (fs->ref_count == 0) {
swim3_action(fs, MOTOR_OFF);
out_8(&sw->control_bic, 0xff);
swim3_select(fs, RELAX);
-- 
2.19.1





[PATCH] ASoC: fsl_spdif: fix TXCLK_DF mask

2019-02-18 Thread Viorel Suman
According to RM SPDIF TXCLK_DF mask is 7-bit wide.

Signed-off-by: Viorel Suman 
---
 sound/soc/fsl/fsl_spdif.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_spdif.h b/sound/soc/fsl/fsl_spdif.h
index 7666dab..e6c61e0 100644
--- a/sound/soc/fsl/fsl_spdif.h
+++ b/sound/soc/fsl/fsl_spdif.h
@@ -152,7 +152,7 @@ enum spdif_gainsel {
 #define STC_TXCLK_ALL_EN_MASK  (1 << STC_TXCLK_ALL_EN_OFFSET)
 #define STC_TXCLK_ALL_EN   (1 << STC_TXCLK_ALL_EN_OFFSET)
 #define STC_TXCLK_DF_OFFSET0
-#define STC_TXCLK_DF_MASK  (0x7ff << STC_TXCLK_DF_OFFSET)
+#define STC_TXCLK_DF_MASK  (0x7f << STC_TXCLK_DF_OFFSET)
 #define STC_TXCLK_DF(x)x) - 1) << STC_TXCLK_DF_OFFSET) & 
STC_TXCLK_DF_MASK)
 #define STC_TXCLK_SRC_MAX  8
 
-- 
2.7.4



Re: [PATCH v04] powerpc/numa: Perform full re-add of CPU for PRRN/VPHN topology update

2019-02-18 Thread Michal Suchánek
On Mon, 18 Feb 2019 11:49:17 +0100
Michal Suchánek  wrote:

Nevermind

Looks like some version of the patch is queued in powerpc/next already.

Thanks

Michal


Re: [PATCH 3/8] drivers/clocksource: timer-fsl-ftm: use common header for FlexTimer #defines

2019-02-18 Thread Daniel Lezcano
On 18/02/2019 15:03, Patrick Havelange wrote:

Changelog please

> Signed-off-by: Patrick Havelange 
> Reviewed-by: Esben Haabendal 
> ---
>  drivers/clocksource/timer-fsl-ftm.c | 15 ++-
>  1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/clocksource/timer-fsl-ftm.c 
> b/drivers/clocksource/timer-fsl-ftm.c
> index 846d18daf893..e1c34b2f53a5 100644
> --- a/drivers/clocksource/timer-fsl-ftm.c
> +++ b/drivers/clocksource/timer-fsl-ftm.c
> @@ -19,20 +19,9 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
> -#define FTM_SC   0x00
> -#define FTM_SC_CLK_SHIFT 3
> -#define FTM_SC_CLK_MASK  (0x3 << FTM_SC_CLK_SHIFT)
> -#define FTM_SC_CLK(c)((c) << FTM_SC_CLK_SHIFT)
> -#define FTM_SC_PS_MASK   0x7
> -#define FTM_SC_TOIE  BIT(6)
> -#define FTM_SC_TOF   BIT(7)
> -
> -#define FTM_CNT  0x04
> -#define FTM_MOD  0x08
> -#define FTM_CNTIN0x4C
> -
> -#define FTM_PS_MAX   7
> +#define FTM_SC_CLK(c)((c) << FTM_SC_CLK_MASK_SHIFT)
>  
>  struct ftm_clock_device {
>   void __iomem *clksrc_base;
> 


-- 
  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:   Facebook |
 Twitter |
 Blog



Re: [PATCH v4 0/3] locking/rwsem: Rwsem rearchitecture part 0

2019-02-18 Thread Will Deacon
On Fri, Feb 15, 2019 at 01:58:34PM -0500, Waiman Long wrote:
> On 02/15/2019 01:40 PM, Will Deacon wrote:
> > On Thu, Feb 14, 2019 at 11:37:15AM +0100, Peter Zijlstra wrote:
> >> On Wed, Feb 13, 2019 at 05:00:14PM -0500, Waiman Long wrote:
> >>> v4:
> >>>  - Remove rwsem-spinlock.c and make all archs use rwsem-xadd.c.
> >>>
> >>> v3:
> >>>  - Optimize __down_read_trylock() for the uncontended case as suggested
> >>>by Linus.
> >>>
> >>> v2:
> >>>  - Add patch 2 to optimize __down_read_trylock() as suggested by PeterZ.
> >>>  - Update performance test data in patch 1.
> >>>
> >>> The goal of this patchset is to remove the architecture specific files
> >>> for rwsem-xadd to make it easer to add enhancements in the later rwsem
> >>> patches. It also removes the legacy rwsem-spinlock.c file and make all
> >>> the architectures use one single implementation of rwsem - rwsem-xadd.c.
> >>>
> >>> Waiman Long (3):
> >>>   locking/rwsem: Remove arch specific rwsem files
> >>>   locking/rwsem: Remove rwsem-spinlock.c & use rwsem-xadd.c for all
> >>> archs
> >>>   locking/rwsem: Optimize down_read_trylock()
> >> Acked-by: Peter Zijlstra (Intel) 
> >>
> >> with the caveat that I'm happy to exchange patch 3 back to my earlier
> >> suggestion in case Will expesses concerns wrt the ARM64 performance of
> >> Linus' suggestion.
> > Right, the current proposal doesn't work well for us, unfortunately. Which
> > was your earlier suggestion?
> >
> > Will
> 
> In my posting yesterday, I showed that most of the trylocks done were
> actually uncontended. Assuming that pattern hold for the most of the
> workloads, it will not that bad after all.

That's fair enough; if you're going to sit in a tight trylock() loop like the
benchmark does, then you're much better off just calling lock() if you care
at all about scalability.

Will


[PATCH 1/3] SoC: imx-sgtl5000: add missing put_device()

2019-02-18 Thread Wen Yang
The of_find_device_by_node() takes a reference to the underlying device
structure, we should release that reference.

Detected by coccinelle with the following warnings:
./sound/soc/fsl/imx-sgtl5000.c:169:1-7: ERROR: missing put_device;
call of_find_device_by_node on line 105, but without a corresponding
object release within this function.
./sound/soc/fsl/imx-sgtl5000.c:177:1-7: ERROR: missing put_device;
call of_find_device_by_node on line 105, but without a corresponding
object release within this function.

Signed-off-by: Wen Yang 
Cc: Timur Tabi 
Cc: Nicolin Chen 
Cc: Xiubo Li 
Cc: Fabio Estevam 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: Shawn Guo 
Cc: Sascha Hauer 
Cc: Pengutronix Kernel Team 
Cc: NXP Linux Team 
Cc: alsa-de...@alsa-project.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-ker...@vger.kernel.org
---
 sound/soc/fsl/imx-sgtl5000.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index b6cb80480b60..bf8597f57dce 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -108,6 +108,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
ret = -EPROBE_DEFER;
goto fail;
}
+   put_device(&ssi_pdev->dev);
codec_dev = of_find_i2c_device_by_node(codec_np);
if (!codec_dev) {
dev_dbg(&pdev->dev, "failed to find codec platform device\n");
-- 
2.20.1



[PATCH] ASoC: fsl_spdif: fix sysclk_df type

2019-02-18 Thread Viorel Suman
According to RM SPDIF STC SYSCLK_DF field is 9-bit wide, values
being in 0..511 range. Use a proper type to handle sysclk_df.

Signed-off-by: Viorel Suman 
---
 sound/soc/fsl/fsl_spdif.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index a26686e..4842e6d 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -96,7 +96,7 @@ struct fsl_spdif_priv {
bool dpll_locked;
u32 txrate[SPDIF_TXRATE_MAX];
u8 txclk_df[SPDIF_TXRATE_MAX];
-   u8 sysclk_df[SPDIF_TXRATE_MAX];
+   u16 sysclk_df[SPDIF_TXRATE_MAX];
u8 txclk_src[SPDIF_TXRATE_MAX];
u8 rxclk_src;
struct clk *txclk[SPDIF_TXRATE_MAX];
@@ -376,7 +376,8 @@ static int spdif_set_sample_rate(struct snd_pcm_substream 
*substream,
struct platform_device *pdev = spdif_priv->pdev;
unsigned long csfs = 0;
u32 stc, mask, rate;
-   u8 clk, txclk_df, sysclk_df;
+   u16 sysclk_df;
+   u8 clk, txclk_df;
int ret;
 
switch (sample_rate) {
@@ -1109,8 +1110,9 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv 
*spdif_priv,
static const u32 rate[] = { 32000, 44100, 48000, 96000, 192000 };
bool is_sysclk = clk_is_match(clk, spdif_priv->sysclk);
u64 rate_ideal, rate_actual, sub;
-   u32 sysclk_dfmin, sysclk_dfmax;
-   u32 txclk_df, sysclk_df, arate;
+   u32 arate;
+   u16 sysclk_dfmin, sysclk_dfmax, sysclk_df;
+   u8 txclk_df;
 
/* The sysclk has an extra divisor [2, 512] */
sysclk_dfmin = is_sysclk ? 2 : 1;
-- 
2.7.4



Re: [PATCH v04] powerpc/numa: Perform full re-add of CPU for PRRN/VPHN topology update

2019-02-18 Thread Michael Bringmann



On 2/18/19 8:15 AM, Michal Suchánek wrote:
> On Mon, 18 Feb 2019 11:49:17 +0100
> Michal Suchánek  wrote:
> 
> Nevermind
> 
> Looks like some version of the patch is queued in powerpc/next already.

Might you be referring to,
[PATCH] powerpc/pseries: Perform full re-add of CPU for topology update 
post-migration
aka
81b6132 powerpc/pseries: Perform full re-add of CPU for topology update post-mig
in the powerpc-next tree?

That is for the case of device-tree changes observed after a migration.
This patch builds upon it for CPU affinity changes observed via PRRN/VPHN 
events.

> 
> Thanks
> 
> Michal

Thanks.

-- 
Michael W. Bringmann
Linux Technology Center
IBM Corporation
Tie-Line  363-5196
External: (512) 286-5196
Cell:   (512) 466-0650
m...@linux.vnet.ibm.com



Applied "ASoC: fsl_spdif: fix TXCLK_DF mask" to the asoc tree

2019-02-18 Thread Mark Brown
The patch

   ASoC: fsl_spdif: fix TXCLK_DF mask

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 30c498a10ac6586778062062c064ae54e3897762 Mon Sep 17 00:00:00 2001
From: Viorel Suman 
Date: Mon, 18 Feb 2019 14:12:17 +
Subject: [PATCH] ASoC: fsl_spdif: fix TXCLK_DF mask

According to RM SPDIF TXCLK_DF mask is 7-bit wide.

Signed-off-by: Viorel Suman 
Signed-off-by: Mark Brown 
---
 sound/soc/fsl/fsl_spdif.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_spdif.h b/sound/soc/fsl/fsl_spdif.h
index 7666dabaccfd..e6c61e07bc1a 100644
--- a/sound/soc/fsl/fsl_spdif.h
+++ b/sound/soc/fsl/fsl_spdif.h
@@ -152,7 +152,7 @@ enum spdif_gainsel {
 #define STC_TXCLK_ALL_EN_MASK  (1 << STC_TXCLK_ALL_EN_OFFSET)
 #define STC_TXCLK_ALL_EN   (1 << STC_TXCLK_ALL_EN_OFFSET)
 #define STC_TXCLK_DF_OFFSET0
-#define STC_TXCLK_DF_MASK  (0x7ff << STC_TXCLK_DF_OFFSET)
+#define STC_TXCLK_DF_MASK  (0x7f << STC_TXCLK_DF_OFFSET)
 #define STC_TXCLK_DF(x)x) - 1) << STC_TXCLK_DF_OFFSET) & 
STC_TXCLK_DF_MASK)
 #define STC_TXCLK_SRC_MAX  8
 
-- 
2.20.1



Applied "ASoC: fsl_spdif: fix sysclk_df type" to the asoc tree

2019-02-18 Thread Mark Brown
The patch

   ASoC: fsl_spdif: fix sysclk_df type

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 2231609a2c0a4807c017822ecb5834bbb7f59fb9 Mon Sep 17 00:00:00 2001
From: Viorel Suman 
Date: Mon, 18 Feb 2019 15:25:00 +
Subject: [PATCH] ASoC: fsl_spdif: fix sysclk_df type

According to RM SPDIF STC SYSCLK_DF field is 9-bit wide, values
being in 0..511 range. Use a proper type to handle sysclk_df.

Signed-off-by: Viorel Suman 
Signed-off-by: Mark Brown 
---
 sound/soc/fsl/fsl_spdif.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index a26686e7281c..4842e6df9a2d 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -96,7 +96,7 @@ struct fsl_spdif_priv {
bool dpll_locked;
u32 txrate[SPDIF_TXRATE_MAX];
u8 txclk_df[SPDIF_TXRATE_MAX];
-   u8 sysclk_df[SPDIF_TXRATE_MAX];
+   u16 sysclk_df[SPDIF_TXRATE_MAX];
u8 txclk_src[SPDIF_TXRATE_MAX];
u8 rxclk_src;
struct clk *txclk[SPDIF_TXRATE_MAX];
@@ -376,7 +376,8 @@ static int spdif_set_sample_rate(struct snd_pcm_substream 
*substream,
struct platform_device *pdev = spdif_priv->pdev;
unsigned long csfs = 0;
u32 stc, mask, rate;
-   u8 clk, txclk_df, sysclk_df;
+   u16 sysclk_df;
+   u8 clk, txclk_df;
int ret;
 
switch (sample_rate) {
@@ -1109,8 +1110,9 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv 
*spdif_priv,
static const u32 rate[] = { 32000, 44100, 48000, 96000, 192000 };
bool is_sysclk = clk_is_match(clk, spdif_priv->sysclk);
u64 rate_ideal, rate_actual, sub;
-   u32 sysclk_dfmin, sysclk_dfmax;
-   u32 txclk_df, sysclk_df, arate;
+   u32 arate;
+   u16 sysclk_dfmin, sysclk_dfmax, sysclk_df;
+   u8 txclk_df;
 
/* The sysclk has an extra divisor [2, 512] */
sysclk_dfmin = is_sysclk ? 2 : 1;
-- 
2.20.1



Applied "ASoC: fsl_spdif: fix sysclk_df type" to the asoc tree

2019-02-18 Thread Mark Brown
The patch

   ASoC: fsl_spdif: fix sysclk_df type

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 2231609a2c0a4807c017822ecb5834bbb7f59fb9 Mon Sep 17 00:00:00 2001
From: Viorel Suman 
Date: Mon, 18 Feb 2019 15:25:00 +
Subject: [PATCH] ASoC: fsl_spdif: fix sysclk_df type

According to RM SPDIF STC SYSCLK_DF field is 9-bit wide, values
being in 0..511 range. Use a proper type to handle sysclk_df.

Signed-off-by: Viorel Suman 
Signed-off-by: Mark Brown 
---
 sound/soc/fsl/fsl_spdif.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index a26686e7281c..4842e6df9a2d 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -96,7 +96,7 @@ struct fsl_spdif_priv {
bool dpll_locked;
u32 txrate[SPDIF_TXRATE_MAX];
u8 txclk_df[SPDIF_TXRATE_MAX];
-   u8 sysclk_df[SPDIF_TXRATE_MAX];
+   u16 sysclk_df[SPDIF_TXRATE_MAX];
u8 txclk_src[SPDIF_TXRATE_MAX];
u8 rxclk_src;
struct clk *txclk[SPDIF_TXRATE_MAX];
@@ -376,7 +376,8 @@ static int spdif_set_sample_rate(struct snd_pcm_substream 
*substream,
struct platform_device *pdev = spdif_priv->pdev;
unsigned long csfs = 0;
u32 stc, mask, rate;
-   u8 clk, txclk_df, sysclk_df;
+   u16 sysclk_df;
+   u8 clk, txclk_df;
int ret;
 
switch (sample_rate) {
@@ -1109,8 +1110,9 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv 
*spdif_priv,
static const u32 rate[] = { 32000, 44100, 48000, 96000, 192000 };
bool is_sysclk = clk_is_match(clk, spdif_priv->sysclk);
u64 rate_ideal, rate_actual, sub;
-   u32 sysclk_dfmin, sysclk_dfmax;
-   u32 txclk_df, sysclk_df, arate;
+   u32 arate;
+   u16 sysclk_dfmin, sysclk_dfmax, sysclk_df;
+   u8 txclk_df;
 
/* The sysclk has an extra divisor [2, 512] */
sysclk_dfmin = is_sysclk ? 2 : 1;
-- 
2.20.1



Re: [RFC PATCH 5/5] powerpc: KASAN for 64bit Book3E

2019-02-18 Thread Christophe Leroy




Le 15/02/2019 à 01:04, Daniel Axtens a écrit :

Wire up KASAN. Only outline instrumentation is supported.

The KASAN shadow area is mapped into vmemmap space:
0x8000 0400   to 0x8000 0600  .
To do this we require that vmemmap be disabled. (This is the default
in the kernel config that QorIQ provides for the machine in their
SDK anyway - they use flat memory.)

Only the kernel linear mapping (0xc000...) is checked. The vmalloc and
ioremap areas (also in 0x800...) are all mapped to a zero page. As
with the Book3S hash series, this requires overriding the memory <->
shadow mapping.

Also, as with both previous 64-bit series, early instrumentation is not
supported.  It would allow us to drop the check_return_arch_not_ready()
hook in the KASAN core, but it's tricky to get it set up early enough:
we need it setup before the first call to instrumented code like printk().
Perhaps in the future.

Only KASAN_MINIMAL works.

Lightly tested on e6500. KVM, kexec and xmon have not been tested.

The test_kasan module fires warnings as expected, except for the
following tests:

  - Expected/by design:
kasan test: memcg_accounted_kmem_cache allocate memcg accounted object

  - Due to only supporting KASAN_MINIMAL:
kasan test: kasan_stack_oob out-of-bounds on stack
kasan test: kasan_global_oob out-of-bounds global variable
kasan test: kasan_alloca_oob_left out-of-bounds to left on alloca
kasan test: kasan_alloca_oob_right out-of-bounds to right on alloca
kasan test: use_after_scope_test use-after-scope on int
kasan test: use_after_scope_test use-after-scope on array

Thanks to those who have done the heavy lifting over the past several years:
  - Christophe's 32 bit series: 
https://lists.ozlabs.org/pipermail/linuxppc-dev/2019-February/185379.html
  - Aneesh's Book3S hash series: https://lwn.net/Articles/655642/
  - Balbir's Book3S radix series: https://patchwork.ozlabs.org/patch/795211/

Cc: Christophe Leroy 
Cc: Aneesh Kumar K.V 
Cc: Balbir Singh 
Signed-off-by: Daniel Axtens 

---

While useful if you have a book3e device, this is mostly intended
as a warm-up exercise for reviving Aneesh's series for book3s hash.
In particular, changes to the kasan core are going to be required
for hash and radix as well.
---
  arch/powerpc/Kconfig |  1 +
  arch/powerpc/Makefile|  2 +
  arch/powerpc/include/asm/kasan.h | 77 ++--
  arch/powerpc/include/asm/ppc_asm.h   |  7 ++
  arch/powerpc/include/asm/string.h|  7 +-
  arch/powerpc/lib/mem_64.S|  6 +-
  arch/powerpc/lib/memcmp_64.S |  5 +-
  arch/powerpc/lib/memcpy_64.S |  3 +-
  arch/powerpc/lib/string.S| 15 ++--
  arch/powerpc/mm/Makefile |  2 +
  arch/powerpc/mm/kasan/Makefile   |  1 +
  arch/powerpc/mm/kasan/kasan_init_book3e_64.c | 53 ++
  arch/powerpc/purgatory/Makefile  |  3 +
  arch/powerpc/xmon/Makefile   |  1 +
  14 files changed, 164 insertions(+), 19 deletions(-)
  create mode 100644 arch/powerpc/mm/kasan/kasan_init_book3e_64.c


[snip]


diff --git a/arch/powerpc/mm/kasan/kasan_init_book3e_64.c 
b/arch/powerpc/mm/kasan/kasan_init_book3e_64.c
new file mode 100644
index ..93b9afcf1020
--- /dev/null
+++ b/arch/powerpc/mm/kasan/kasan_init_book3e_64.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define DISABLE_BRANCH_PROFILING
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DEFINE_STATIC_KEY_FALSE(powerpc_kasan_enabled_key);
+EXPORT_SYMBOL(powerpc_kasan_enabled_key);


Why does this symbol need to be exported ?

Christophe



[PATCH 5/8] iio/counter: add FlexTimer Module Quadrature decoder counter driver

2019-02-18 Thread Patrick Havelange
This driver exposes the counter for the quadrature decoder of the
FlexTimer Module, present in the LS1021A soc.

Signed-off-by: Patrick Havelange 
Reviewed-by: Esben Haabendal 
---
 drivers/iio/counter/Kconfig   |  10 +
 drivers/iio/counter/Makefile  |   1 +
 drivers/iio/counter/ftm-quaddec.c | 294 ++
 3 files changed, 305 insertions(+)
 create mode 100644 drivers/iio/counter/ftm-quaddec.c

diff --git a/drivers/iio/counter/Kconfig b/drivers/iio/counter/Kconfig
index bf1e559ad7cd..4641cb2e752a 100644
--- a/drivers/iio/counter/Kconfig
+++ b/drivers/iio/counter/Kconfig
@@ -31,4 +31,14 @@ config STM32_LPTIMER_CNT
 
  To compile this driver as a module, choose M here: the
  module will be called stm32-lptimer-cnt.
+
+config FTM_QUADDEC
+   tristate "Flex Timer Module Quadrature decoder driver"
+   help
+ Select this option to enable the Flex Timer Quadrature decoder
+ driver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ftm-quaddec.
+
 endmenu
diff --git a/drivers/iio/counter/Makefile b/drivers/iio/counter/Makefile
index 1b9a896eb488..757c1f4196af 100644
--- a/drivers/iio/counter/Makefile
+++ b/drivers/iio/counter/Makefile
@@ -6,3 +6,4 @@
 
 obj-$(CONFIG_104_QUAD_8)   += 104-quad-8.o
 obj-$(CONFIG_STM32_LPTIMER_CNT)+= stm32-lptimer-cnt.o
+obj-$(CONFIG_FTM_QUADDEC)  += ftm-quaddec.o
diff --git a/drivers/iio/counter/ftm-quaddec.c 
b/drivers/iio/counter/ftm-quaddec.c
new file mode 100644
index ..ca7e55a9ab3f
--- /dev/null
+++ b/drivers/iio/counter/ftm-quaddec.c
@@ -0,0 +1,294 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Flex Timer Module Quadrature decoder
+ *
+ * This module implements a driver for decoding the FTM quadrature
+ * of ex. a LS1021A
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct ftm_quaddec {
+   struct platform_device *pdev;
+   void __iomem *ftm_base;
+   bool big_endian;
+   struct mutex ftm_quaddec_mutex;
+};
+
+#define HASFLAGS(flag, bits) ((flag & bits) ? 1 : 0)
+
+#define DEFAULT_POLL_INTERVAL100 /* in msec */
+
+static void ftm_read(struct ftm_quaddec *ftm, uint32_t offset, uint32_t *data)
+{
+   if (ftm->big_endian)
+   *data = ioread32be(ftm->ftm_base + offset);
+   else
+   *data = ioread32(ftm->ftm_base + offset);
+}
+
+static void ftm_write(struct ftm_quaddec *ftm, uint32_t offset, uint32_t data)
+{
+   if (ftm->big_endian)
+   iowrite32be(data, ftm->ftm_base + offset);
+   else
+   iowrite32(data, ftm->ftm_base + offset);
+}
+
+/* take mutex
+ * call ftm_clear_write_protection
+ * update settings
+ * call ftm_set_write_protection
+ * release mutex
+ */
+static void ftm_clear_write_protection(struct ftm_quaddec *ftm)
+{
+   uint32_t flag;
+
+   /* First see if it is enabled */
+   ftm_read(ftm, FTM_FMS, &flag);
+
+   if (flag & FTM_FMS_WPEN) {
+   ftm_read(ftm, FTM_MODE, &flag);
+   ftm_write(ftm, FTM_MODE, flag | FTM_MODE_WPDIS);
+   }
+}
+
+static void ftm_set_write_protection(struct ftm_quaddec *ftm)
+{
+   ftm_write(ftm, FTM_FMS, FTM_FMS_WPEN);
+}
+
+static void ftm_reset_counter(struct ftm_quaddec *ftm)
+{
+   /* Reset hardware counter to CNTIN */
+   ftm_write(ftm, FTM_CNT, 0x0);
+}
+
+static void ftm_quaddec_init(struct ftm_quaddec *ftm)
+{
+   ftm_clear_write_protection(ftm);
+
+   /* Do not write in the region from the CNTIN register through the
+* PWMLOAD register when FTMEN = 0.
+*/
+   ftm_write(ftm, FTM_MODE, FTM_MODE_FTMEN); /* enable FTM */
+   ftm_write(ftm, FTM_CNTIN, 0x); /* zero init value */
+   ftm_write(ftm, FTM_MOD, 0x);/* max overflow value */
+   ftm_write(ftm, FTM_CNT, 0x0);   /* reset counter value */
+   ftm_write(ftm, FTM_SC, FTM_SC_PS_1);/* prescale with x1 */
+   /* Select quad mode */
+   ftm_write(ftm, FTM_QDCTRL, FTM_QDCTRL_QUADEN);
+
+   /* Unused features and reset to default section */
+   ftm_write(ftm, FTM_POL, 0x0); /* polarity is active high */
+   ftm_write(ftm, FTM_FLTCTRL, 0x0); /* all faults disabled */
+   ftm_write(ftm, FTM_SYNCONF, 0x0); /* disable all sync */
+   ftm_write(ftm, FTM_SYNC, 0x);
+
+   /* Lock the FTM */
+   ftm_set_write_protection(ftm);
+}
+
+static int ftm_quaddec_read_raw(struct iio_dev *indio_dev,
+   struct iio_chan_spec const *chan,
+   int *val, int *val2, long mask)
+{
+   struct ftm_quaddec *ftm = iio_priv(indio_dev);
+   uint32_t counter;
+
+   switch (mask) {
+   case IIO_CHAN_INFO_RAW:
+   ftm_read(ftm, FTM_CNT, &counter);
+   *val = counter;
+   

[PATCH 3/8] drivers/clocksource: timer-fsl-ftm: use common header for FlexTimer #defines

2019-02-18 Thread Patrick Havelange
Signed-off-by: Patrick Havelange 
Reviewed-by: Esben Haabendal 
---
 drivers/clocksource/timer-fsl-ftm.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/clocksource/timer-fsl-ftm.c 
b/drivers/clocksource/timer-fsl-ftm.c
index 846d18daf893..e1c34b2f53a5 100644
--- a/drivers/clocksource/timer-fsl-ftm.c
+++ b/drivers/clocksource/timer-fsl-ftm.c
@@ -19,20 +19,9 @@
 #include 
 #include 
 #include 
+#include 
 
-#define FTM_SC 0x00
-#define FTM_SC_CLK_SHIFT   3
-#define FTM_SC_CLK_MASK(0x3 << FTM_SC_CLK_SHIFT)
-#define FTM_SC_CLK(c)  ((c) << FTM_SC_CLK_SHIFT)
-#define FTM_SC_PS_MASK 0x7
-#define FTM_SC_TOIEBIT(6)
-#define FTM_SC_TOF BIT(7)
-
-#define FTM_CNT0x04
-#define FTM_MOD0x08
-#define FTM_CNTIN  0x4C
-
-#define FTM_PS_MAX 7
+#define FTM_SC_CLK(c)  ((c) << FTM_SC_CLK_MASK_SHIFT)
 
 struct ftm_clock_device {
void __iomem *clksrc_base;
-- 
2.17.1



[PATCH 1/8] include/fsl: add common FlexTimer #defines in a separate header.

2019-02-18 Thread Patrick Havelange
Signed-off-by: Patrick Havelange 
Reviewed-by: Esben Haabendal 
---
 include/linux/fsl/ftm.h | 88 +
 1 file changed, 88 insertions(+)
 create mode 100644 include/linux/fsl/ftm.h

diff --git a/include/linux/fsl/ftm.h b/include/linux/fsl/ftm.h
new file mode 100644
index ..d59011acf66c
--- /dev/null
+++ b/include/linux/fsl/ftm.h
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef __FSL_FTM_H__
+#define __FSL_FTM_H__
+
+#define FTM_SC   0x0 /* Status And Control */
+#define FTM_CNT  0x4 /* Counter */
+#define FTM_MOD  0x8 /* Modulo */
+
+#define FTM_CNTIN0x4C /* Counter Initial Value */
+#define FTM_STATUS   0x50 /* Capture And Compare Status */
+#define FTM_MODE 0x54 /* Features Mode Selection */
+#define FTM_SYNC 0x58 /* Synchronization */
+#define FTM_OUTINIT  0x5C /* Initial State For Channels Output */
+#define FTM_OUTMASK  0x60 /* Output Mask */
+#define FTM_COMBINE  0x64 /* Function For Linked Channels */
+#define FTM_DEADTIME 0x68 /* Deadtime Insertion Control */
+#define FTM_EXTTRIG  0x6C /* FTM External Trigger */
+#define FTM_POL  0x70 /* Channels Polarity */
+#define FTM_FMS  0x74 /* Fault Mode Status */
+#define FTM_FILTER   0x78 /* Input Capture Filter Control */
+#define FTM_FLTCTRL  0x7C /* Fault Control */
+#define FTM_QDCTRL   0x80 /* Quadrature Decoder Control And Status */
+#define FTM_CONF 0x84 /* Configuration */
+#define FTM_FLTPOL   0x88 /* FTM Fault Input Polarity */
+#define FTM_SYNCONF  0x8C /* Synchronization Configuration */
+#define FTM_INVCTRL  0x90 /* FTM Inverting Control */
+#define FTM_SWOCTRL  0x94 /* FTM Software Output Control */
+#define FTM_PWMLOAD  0x98 /* FTM PWM Load */
+
+#define FTM_SC_CLK_MASK_SHIFT  3
+#define FTM_SC_CLK_MASK(3 << FTM_SC_CLK_MASK_SHIFT)
+#define FTM_SC_TOF 0x80
+#define FTM_SC_TOIE0x40
+#define FTM_SC_CPWMS   0x20
+#define FTM_SC_CLKS0x18
+#define FTM_SC_PS_10x0
+#define FTM_SC_PS_20x1
+#define FTM_SC_PS_40x2
+#define FTM_SC_PS_80x3
+#define FTM_SC_PS_16   0x4
+#define FTM_SC_PS_32   0x5
+#define FTM_SC_PS_64   0x6
+#define FTM_SC_PS_128  0x7
+#define FTM_SC_PS_MASK 0x7
+
+#define FTM_MODE_FAULTIE   0x80
+#define FTM_MODE_FAULTM0x60
+#define FTM_MODE_CAPTEST   0x10
+#define FTM_MODE_PWMSYNC   0x8
+#define FTM_MODE_WPDIS 0x4
+#define FTM_MODE_INIT  0x2
+#define FTM_MODE_FTMEN 0x1
+
+/* NXP Errata: The PHAFLTREN and PHBFLTREN bits are tide to zero internally
+ * and these bits cannot be set. Flextimer cannot use Filter in
+ * Quadrature Decoder Mode.
+ * https://community.nxp.com/thread/467648#comment-1010319
+ */
+#define FTM_QDCTRL_PHAFLTREN   0x80
+#define FTM_QDCTRL_PHBFLTREN   0x40
+#define FTM_QDCTRL_PHAPOL  0x20
+#define FTM_QDCTRL_PHBPOL  0x10
+#define FTM_QDCTRL_QUADMODE0x8
+#define FTM_QDCTRL_QUADDIR 0x4
+#define FTM_QDCTRL_TOFDIR  0x2
+#define FTM_QDCTRL_QUADEN  0x1
+
+#define FTM_FMS_FAULTF 0x80
+#define FTM_FMS_WPEN   0x40
+#define FTM_FMS_FAULTIN0x10
+#define FTM_FMS_FAULTF30x8
+#define FTM_FMS_FAULTF20x4
+#define FTM_FMS_FAULTF10x2
+#define FTM_FMS_FAULTF00x1
+
+#define FTM_CSC_BASE   0xC
+#define FTM_CSC_MSB0x20
+#define FTM_CSC_MSA0x10
+#define FTM_CSC_ELSB   0x8
+#define FTM_CSC_ELSA   0x4
+#define FTM_CSC(_channel)  (FTM_CSC_BASE + ((_channel) * 8))
+
+#define FTM_CV_BASE0x10
+#define FTM_CV(_channel)   (FTM_CV_BASE + ((_channel) * 8))
+
+#define FTM_PS_MAX 7
+
+#endif
-- 
2.17.1



[PATCH 2/8] drivers/pwm: pwm-fsl-ftm: use common header for FlexTimer #defines

2019-02-18 Thread Patrick Havelange
This also fixes the wrong value for the previously defined
FTM_MODE_INIT macro (it was not used).

Signed-off-by: Patrick Havelange 
Reviewed-by: Esben Haabendal 
---
 drivers/pwm/pwm-fsl-ftm.c | 44 +--
 1 file changed, 1 insertion(+), 43 deletions(-)

diff --git a/drivers/pwm/pwm-fsl-ftm.c b/drivers/pwm/pwm-fsl-ftm.c
index 883378d055c6..f21ea1b97116 100644
--- a/drivers/pwm/pwm-fsl-ftm.c
+++ b/drivers/pwm/pwm-fsl-ftm.c
@@ -22,51 +22,9 @@
 #include 
 #include 
 #include 
+#include 
 
-#define FTM_SC 0x00
-#define FTM_SC_CLK_MASK_SHIFT  3
-#define FTM_SC_CLK_MASK(3 << FTM_SC_CLK_MASK_SHIFT)
 #define FTM_SC_CLK(c)  (((c) + 1) << FTM_SC_CLK_MASK_SHIFT)
-#define FTM_SC_PS_MASK 0x7
-
-#define FTM_CNT0x04
-#define FTM_MOD0x08
-
-#define FTM_CSC_BASE   0x0C
-#define FTM_CSC_MSBBIT(5)
-#define FTM_CSC_MSABIT(4)
-#define FTM_CSC_ELSB   BIT(3)
-#define FTM_CSC_ELSA   BIT(2)
-#define FTM_CSC(_channel)  (FTM_CSC_BASE + ((_channel) * 8))
-
-#define FTM_CV_BASE0x10
-#define FTM_CV(_channel)   (FTM_CV_BASE + ((_channel) * 8))
-
-#define FTM_CNTIN  0x4C
-#define FTM_STATUS 0x50
-
-#define FTM_MODE   0x54
-#define FTM_MODE_FTMEN BIT(0)
-#define FTM_MODE_INIT  BIT(2)
-#define FTM_MODE_PWMSYNC   BIT(3)
-
-#define FTM_SYNC   0x58
-#define FTM_OUTINIT0x5C
-#define FTM_OUTMASK0x60
-#define FTM_COMBINE0x64
-#define FTM_DEADTIME   0x68
-#define FTM_EXTTRIG0x6C
-#define FTM_POL0x70
-#define FTM_FMS0x74
-#define FTM_FILTER 0x78
-#define FTM_FLTCTRL0x7C
-#define FTM_QDCTRL 0x80
-#define FTM_CONF   0x84
-#define FTM_FLTPOL 0x88
-#define FTM_SYNCONF0x8C
-#define FTM_INVCTRL0x90
-#define FTM_SWOCTRL0x94
-#define FTM_PWMLOAD0x98
 
 enum fsl_pwm_clk {
FSL_PWM_CLK_SYS,
-- 
2.17.1



[PATCH 6/8] LS1021A: dtsi: add ftm quad decoder entries

2019-02-18 Thread Patrick Havelange
Add the 4 Quadrature counters for this board.

Signed-off-by: Patrick Havelange 
Reviewed-by: Esben Haabendal 
---
 arch/arm/boot/dts/ls1021a.dtsi | 28 
 1 file changed, 28 insertions(+)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index ed0941292172..0168fb62590a 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -433,6 +433,34 @@
status = "disabled";
};
 
+   counter0: counter@29d {
+   compatible = "fsl,ftm-quaddec";
+   reg = <0x0 0x29d 0x0 0x1>;
+   big-endian;
+   status = "disabled";
+   };
+
+   counter1: counter@29e {
+   compatible = "fsl,ftm-quaddec";
+   reg = <0x0 0x29e 0x0 0x1>;
+   big-endian;
+   status = "disabled";
+   };
+
+   counter2: counter@29f {
+   compatible = "fsl,ftm-quaddec";
+   reg = <0x0 0x29f 0x0 0x1>;
+   big-endian;
+   status = "disabled";
+   };
+
+   counter3: counter@2a0 {
+   compatible = "fsl,ftm-quaddec";
+   reg = <0x0 0x2a0 0x0 0x1>;
+   big-endian;
+   status = "disabled";
+   };
+
gpio0: gpio@230 {
compatible = "fsl,ls1021a-gpio", "fsl,qoriq-gpio";
reg = <0x0 0x230 0x0 0x1>;
-- 
2.17.1



[PATCH 7/8] dt-bindings: iio/counter: ftm-quaddec: add poll-interval parameter

2019-02-18 Thread Patrick Havelange
New optional parameter supported by updated driver.

Signed-off-by: Patrick Havelange 
Reviewed-by: Esben Haabendal 
---
 .../devicetree/bindings/iio/counter/ftm-quaddec.txt   | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iio/counter/ftm-quaddec.txt 
b/Documentation/devicetree/bindings/iio/counter/ftm-quaddec.txt
index 4d18cd722074..60554e6c4367 100644
--- a/Documentation/devicetree/bindings/iio/counter/ftm-quaddec.txt
+++ b/Documentation/devicetree/bindings/iio/counter/ftm-quaddec.txt
@@ -6,8 +6,14 @@ Required properties:
 - compatible:  Must be "fsl,ftm-quaddec".
 - reg: Must be set to the memory region of the flextimer.
 
-Optional property:
+Optional properties:
 - big-endian:  Access the device registers in big-endian mode.
+- poll-intervalPoll interval time in milliseconds for detecting
+   the under/overflow of the counter. Default value
+   is 100.
+   A value of 0 disables polling. This value can also
+   be set at runtime, but not to less than this initial
+   value (except 0 for disabling).
 
 Example:
counter0: counter@29d {
-- 
2.17.1



[PATCH 4/8] dt-bindings: iio/counter: ftm-quaddec

2019-02-18 Thread Patrick Havelange
FlexTimer quadrature decoder driver.

Signed-off-by: Patrick Havelange 
Reviewed-by: Esben Haabendal 
---
 .../bindings/iio/counter/ftm-quaddec.txt   | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/counter/ftm-quaddec.txt

diff --git a/Documentation/devicetree/bindings/iio/counter/ftm-quaddec.txt 
b/Documentation/devicetree/bindings/iio/counter/ftm-quaddec.txt
new file mode 100644
index ..4d18cd722074
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/counter/ftm-quaddec.txt
@@ -0,0 +1,18 @@
+FlexTimer Quadrature decoder counter
+
+This driver exposes a simple counter for the quadrature decoder mode.
+
+Required properties:
+- compatible:  Must be "fsl,ftm-quaddec".
+- reg: Must be set to the memory region of the flextimer.
+
+Optional property:
+- big-endian:  Access the device registers in big-endian mode.
+
+Example:
+   counter0: counter@29d {
+   compatible = "fsl,ftm-quaddec";
+   reg = <0x0 0x29d 0x0 0x1>;
+   big-endian;
+   status = "disabled";
+   };
-- 
2.17.1



[PATCH 8/8] iio/counter/ftm-quaddec: add handling of under/overflow of the counter.

2019-02-18 Thread Patrick Havelange
This is implemented by polling the counter value. A new parameter
"poll-interval" can be set in the device tree, or can be changed
at runtime. The reason for the polling is to avoid interrupts flooding.
If the quadrature input is going up and down around the overflow value
(or around 0), the interrupt will be triggering all the time. Thus,
polling is an easy way to handle overflow in a consistent way.
Polling can still be disabled by setting poll-interval to 0.

Signed-off-by: Patrick Havelange 
Reviewed-by: Esben Haabendal 
---
 drivers/iio/counter/ftm-quaddec.c | 199 +-
 1 file changed, 193 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/counter/ftm-quaddec.c 
b/drivers/iio/counter/ftm-quaddec.c
index ca7e55a9ab3f..3a0395c3ef33 100644
--- a/drivers/iio/counter/ftm-quaddec.c
+++ b/drivers/iio/counter/ftm-quaddec.c
@@ -25,11 +25,33 @@
 
 struct ftm_quaddec {
struct platform_device *pdev;
+   struct delayed_work delayedcounterwork;
void __iomem *ftm_base;
bool big_endian;
+
+   /* Offset added to the counter to adjust for overflows of the
+* 16 bit HW counter. Only the 16 MSB are set.
+*/
+   uint32_t counteroffset;
+
+   /* Store the counter on each read, this is used to detect
+* if the counter readout if we over or underflow
+*/
+   uint8_t lastregion;
+
+   /* Poll-interval, in ms before delayed work must poll counter */
+   uint16_t poll_interval;
+
struct mutex ftm_quaddec_mutex;
 };
 
+struct counter_result {
+   /* 16 MSB are from the counteroffset
+* 16 LSB are from the hardware counter
+*/
+   uint32_t value;
+};
+
 #define HASFLAGS(flag, bits) ((flag & bits) ? 1 : 0)
 
 #define DEFAULT_POLL_INTERVAL100 /* in msec */
@@ -74,8 +96,75 @@ static void ftm_set_write_protection(struct ftm_quaddec *ftm)
ftm_write(ftm, FTM_FMS, FTM_FMS_WPEN);
 }
 
+/* must be called with mutex locked */
+static void ftm_work_reschedule(struct ftm_quaddec *ftm)
+{
+   cancel_delayed_work(&ftm->delayedcounterwork);
+   if (ftm->poll_interval > 0)
+   schedule_delayed_work(&ftm->delayedcounterwork,
+  msecs_to_jiffies(ftm->poll_interval));
+}
+
+/* Reports the hardware counter added the offset counter.
+ *
+ * The quadrature decodes does not use interrupts, because it cannot be
+ * guaranteed that the counter won't flip between 0x and 0x at a high
+ * rate, causing Real Time performance degration. Instead the counter must be
+ * read frequently enough - the assumption is 150 KHz input can be handled with
+ * 100 ms read cycles.
+ */
+static void ftm_work_counter(struct ftm_quaddec *ftm,
+struct counter_result *returndata)
+{
+   /* only 16bits filled in*/
+   uint32_t hwcounter;
+   uint8_t currentregion;
+
+   mutex_lock(&ftm->ftm_quaddec_mutex);
+
+   ftm_read(ftm, FTM_CNT, &hwcounter);
+
+   /* Divide the counter in four regions:
+*   0x-0x4000-0x8000-0xC000-0x
+* When the hwcounter changes between region 0 and 3 there is an
+* over/underflow
+*/
+   currentregion = hwcounter / 0x4000;
+
+   if (ftm->lastregion == 3 && currentregion == 0)
+   ftm->counteroffset += 0x1;
+
+   if (ftm->lastregion == 0 && currentregion == 3)
+   ftm->counteroffset -= 0x1;
+
+   ftm->lastregion = currentregion;
+
+   if (returndata)
+   returndata->value = ftm->counteroffset + hwcounter;
+
+   ftm_work_reschedule(ftm);
+
+   mutex_unlock(&ftm->ftm_quaddec_mutex);
+}
+
+/* wrapper around the real function */
+static void ftm_work_counter_delay(struct work_struct *workptr)
+{
+   struct delayed_work *work;
+   struct ftm_quaddec *ftm;
+
+   work = container_of(workptr, struct delayed_work, work);
+   ftm = container_of(work, struct ftm_quaddec, delayedcounterwork);
+
+   ftm_work_counter(ftm, NULL);
+}
+
+/* must be called with mutex locked */
 static void ftm_reset_counter(struct ftm_quaddec *ftm)
 {
+   ftm->counteroffset = 0;
+   ftm->lastregion = 0;
+
/* Reset hardware counter to CNTIN */
ftm_write(ftm, FTM_CNT, 0x0);
 }
@@ -110,18 +199,91 @@ static int ftm_quaddec_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask)
 {
struct ftm_quaddec *ftm = iio_priv(indio_dev);
-   uint32_t counter;
+   struct counter_result counter;
 
switch (mask) {
case IIO_CHAN_INFO_RAW:
-   ftm_read(ftm, FTM_CNT, &counter);
-   *val = counter;
+   case IIO_CHAN_INFO_PROCESSED:
+   ftm_work_counter(ftm, &counter);
+   if (mask == IIO_CHAN_INFO_RAW)
+   counter.value &= 0x;
+
+   *val = counter.value;
+
return IIO_VAL_INT;
default:
return 

Re: [RFC PATCH 5/5] powerpc: KASAN for 64bit Book3E

2019-02-18 Thread Daniel Axtens
>> diff --git a/arch/powerpc/mm/kasan/kasan_init_book3e_64.c 
>> b/arch/powerpc/mm/kasan/kasan_init_book3e_64.c
>> new file mode 100644
>> index ..93b9afcf1020
>> --- /dev/null
>> +++ b/arch/powerpc/mm/kasan/kasan_init_book3e_64.c
>> @@ -0,0 +1,53 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +
>> +#define DISABLE_BRANCH_PROFILING
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +DEFINE_STATIC_KEY_FALSE(powerpc_kasan_enabled_key);
>> +EXPORT_SYMBOL(powerpc_kasan_enabled_key);
>
> Why does this symbol need to be exported ?

I suppose it probably doesn't! I copied Balbir's code without much
thought as it seemed a lot smarter than my random global variable code.

Regards,
Daniel

>
> Christophe


Re: [RFC PATCH 4/5] powerpc: move KASAN into its own subdirectory

2019-02-18 Thread Michael Ellerman
Christophe Leroy  writes:

> Le 18/02/2019 à 10:14, Michael Ellerman a écrit :
>> christophe leroy  writes:
>> 
>>> Le 15/02/2019 à 01:04, Daniel Axtens a écrit :
 In preparation for adding ppc64 implementations, break out the
 code into its own subdirectory.
>>>
>>> That's not a bad idea, arch/powerpc/mm is rather messy with lot of
>>> subarch stuff.
>> 
>> I'm always happy to have more directories with more focused content.
>> 
>
> Nice to know how to make you happy :)

Haha, well there is also beer :)

> I'll send you a patch for moving all page table dumping stuff into a 
> subdirectory.

Thanks.

cheers


Re: [PATCH kernel] powerpc/powernv/sriov: Register IOMMU groups for VFs

2019-02-18 Thread David Gibson
On Mon, Feb 18, 2019 at 04:58:01PM +1100, Alexey Kardashevskiy wrote:
> The compound IOMMU group rework moved iommu_register_group() together in
> pnv_pci_ioda_setup_iommu_api() (which is a part of ppc_md.pcibios_fixup).
> As the result, pnv_ioda_setup_bus_iommu_group() does not create groups
> any more, it only adds devices to groups.
> 
> This works fine for boot time devices. However IOMMU groups for SRIOV's
> VFs were added by pnv_ioda_setup_bus_iommu_group() so this got broken:
> pnv_tce_iommu_bus_notifier() expects a group to be registered for VF
> and it is not.
> 
> This adds missing group registration and adds a NULL pointer check into
> the bus notifier so we won't stop in xmon if there is no group, although
> it is not expected to happen now.
> 
> Fixes: 0bd971676e68 "powerpc/powernv/npu: Add compound IOMMU groups"
> Signed-off-by: Alexey Kardashevskiy 

Reviewed-by: David Gibson 

> ---
> 
> Fixes https://bugzilla.linux.ibm.com/show_bug.cgi?id=175550
> "Kernel Oops while creating SRIOV VF's."
> 
> 
> ---
>  arch/powerpc/platforms/powernv/pci-ioda.c | 2 ++
>  arch/powerpc/platforms/powernv/pci.c  | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
> b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 7db3119..145373f 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -1593,6 +1593,8 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, 
> u16 num_vfs)
>  
>   pnv_pci_ioda2_setup_dma_pe(phb, pe);
>  #ifdef CONFIG_IOMMU_API
> + iommu_register_group(&pe->table_group,
> + pe->phb->hose->global_number, pe->pe_number);
>   pnv_ioda_setup_bus_iommu_group(pe, &pe->table_group, NULL);
>  #endif
>   }
> diff --git a/arch/powerpc/platforms/powernv/pci.c 
> b/arch/powerpc/platforms/powernv/pci.c
> index 45fb70b..ef9448a 100644
> --- a/arch/powerpc/platforms/powernv/pci.c
> +++ b/arch/powerpc/platforms/powernv/pci.c
> @@ -1147,6 +1147,8 @@ static int pnv_tce_iommu_bus_notifier(struct 
> notifier_block *nb,
>   return 0;
>  
>   pe = &phb->ioda.pe_array[pdn->pe_number];
> + if (!pe->table_group.group)
> + return 0;
>   iommu_add_device(&pe->table_group, dev);
>   return 0;
>   case BUS_NOTIFY_DEL_DEVICE:

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [PATCH] powerpc/ptrace: Simplify vr_get/set() to avoid GCC warning

2019-02-18 Thread Michael Ellerman
Meelis Roos  writes:

>> Rather than relying on that we can pass an explict end_pos based on
>> the sizeof(vrsave). The result should be exactly the same but it's
>> more obviously not over-reading/writing the stack and it avoids the
>> compiler warning.
>
> It works on my PowerMac G4 with Debian-ports unstable with gcc 8.

Thanks.

cheers


Re: [PATCH 05/11] tracing: consolidate the TRACE_IRQFLAGS_SUPPORT symbol

2019-02-18 Thread Ley Foon Tan
On Fri, 2019-02-15 at 16:55 +0900, Masahiro Yamada wrote:
> +CC: Ley Foon Tan 
> +CC: nios2-...@lists.rocketboards.org
> 
> 
> On Thu, Feb 14, 2019 at 2:40 AM Christoph Hellwig  wrote:
> 
> > 
> > diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
> > index 715e6c09b4a5..3b50689007f5 100644
> > --- a/arch/nios2/Kconfig
> > +++ b/arch/nios2/Kconfig
> > @@ -20,6 +20,7 @@ config NIOS2
> > select OF_EARLY_FLATTREE
> > select SOC_BUS
> > select SPARSE_IRQ
> > +   select TRACE_IRQFLAGS_SUPPORT
> 
> This is a behavior change of nios2.
> 
> TRACE_IRQFLAGS_SUPPORT was previously 'n',
> and this commit is changing it to 'y'.
> 
> 
> 
> 
> Strangely, nios2 defines TRACE_IRQFLAGS_SUPPORT twice
> with different default values.
> 
> In Kconfig, the first one becomes effective.
> 
> In this case, 'def_bool n' in arch/nios2/Kconfig is used.
> 'def_bool y' in arch/nios2/Kconfig.debug is dead code.
> 
> 
> I think this select should be dropped
> to keep the current behavior,
> but I hope the NIOS2 maintainer will give us
> some comments just in case.
> 
Yes, please drop this patch to keep original behavior.
Thanks.

Regards
Ley Foon
> 
> 
> 
> > 
> > select USB_ARCH_HAS_HCD if USB_SUPPORT
> > select CPU_NO_EFFICIENT_FFS
> > select ARCH_DISCARD_MEMBLOCK
> > @@ -39,9 +40,6 @@ config NO_IOPORT_MAP
> >  config FPU
> > def_bool n
> > 
> > -config TRACE_IRQFLAGS_SUPPORT
> > -   def_bool n
> > -
> >  menu "Kernel features"
> > 
> >  source "kernel/Kconfig.hz"
> > diff --git a/arch/nios2/Kconfig.debug b/arch/nios2/Kconfig.debug
> > index f1da8a7b17ff..a8bc06e96ef5 100644
> > --- a/arch/nios2/Kconfig.debug
> > +++ b/arch/nios2/Kconfig.debug
> > @@ -1,8 +1,5 @@
> >  # SPDX-License-Identifier: GPL-2.0
> > 
> > -config TRACE_IRQFLAGS_SUPPORT
> > -   def_bool y
> > -
> >  config EARLY_PRINTK
> > bool "Activate early kernel debugging"
> > default y
> --
> Best Regards
> Masahiro Yamada
> 
> 
> 
> Confidentiality Notice.
> This message may contain information that is confidential or
> otherwise protected from disclosure. If you are not the intended
> recipient, you are hereby notified that any use, disclosure,
> dissemination, distribution, or copying of this message, or any
> attachments, is strictly prohibited. If you have received this
> message in error, please advise the sender by reply e-mail, and
> delete the message and any attachments. Thank you.


Re: [RFC PATCH v3 3/4] kvmppc: H_SVM_INIT_START and H_SVM_INIT_DONE hcalls

2019-02-18 Thread Paul Mackerras
On Wed, Jan 30, 2019 at 11:37:25AM +0530, Bharata B Rao wrote:
> H_SVM_INIT_START: Initiate securing a VM
> H_SVM_INIT_DONE: Conclude securing a VM
> 
> During early guest init, these hcalls will be issued by UV.
> As part of these hcalls, [un]register memslots with UV.

That last sentence is a bit misleading as it implies that
H_SVM_INIT_DONE causes us to unregister the memslots with the UV,
which is not the case.  Shouldn't it be "As part of H_SVM_INIT_START,
register all existing memslots with the UV"?

Also, do we subsequently communicate changes in the memslots to the
UV?

Paul.


Re: [RFC PATCH v3 3/4] kvmppc: H_SVM_INIT_START and H_SVM_INIT_DONE hcalls

2019-02-18 Thread Bharata B Rao
On Tue, Feb 19, 2019 at 02:21:40PM +1100, Paul Mackerras wrote:
> On Wed, Jan 30, 2019 at 11:37:25AM +0530, Bharata B Rao wrote:
> > H_SVM_INIT_START: Initiate securing a VM
> > H_SVM_INIT_DONE: Conclude securing a VM
> > 
> > During early guest init, these hcalls will be issued by UV.
> > As part of these hcalls, [un]register memslots with UV.
> 
> That last sentence is a bit misleading as it implies that
> H_SVM_INIT_DONE causes us to unregister the memslots with the UV,
> which is not the case.  Shouldn't it be "As part of H_SVM_INIT_START,
> register all existing memslots with the UV"?

Ok, makes sense to rephrase.

> 
> Also, do we subsequently communicate changes in the memslots to the
> UV?

Yes, currently handing KVM_MR_DELETE, yet to handle KVM_MR_MOVE

Regards,
Bharata.



Re: [PATCH -next] powerpc/pseries: Drop pointless static qualifier in vpa_debugfs_init()

2019-02-18 Thread Daniel Axtens
Hi YueHaibing,  writes:

> There is no need to have the 'struct dentry *vpa_dir' variable static
> since new value always be assigned before use it.
>

Much to my surprise this seems to be a correct change. I don't know why
the struct was ever static but it seems to have been this way since the
commit went in in October 2018. And yes, it is set every time when the
function is called (which is exactly once, it's an initcall). I wonder
if once upon a time in an earlier spin of the patch there was a method
to tear the debugfs down, so it was global, and in the revisions that
went away but the static qualifier remained.

Anyway, I think your commit message should have:

Fixes: c6c26fb55e8e ("powerpc/pseries: Export raw per-CPU VPA data via debugfs")

as this is the commit that introduced the issue.

With that change:
Reviewed-by: Daniel Axtens 

Regards,
Daniel

> Signed-off-by: YueHaibing 
> ---
>  arch/powerpc/platforms/pseries/lpar.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/pseries/lpar.c 
> b/arch/powerpc/platforms/pseries/lpar.c
> index f2a9f0adc2d3..f649c1b652eb 100644
> --- a/arch/powerpc/platforms/pseries/lpar.c
> +++ b/arch/powerpc/platforms/pseries/lpar.c
> @@ -1263,7 +1263,7 @@ static int __init vpa_debugfs_init(void)
>  {
>   char name[16];
>   long i;
> - static struct dentry *vpa_dir;
> + struct dentry *vpa_dir;
>  
>   if (!firmware_has_feature(FW_FEATURE_SPLPAR))
>   return 0;


[PATCH v2] KVM: PPC: Book3S: Add KVM stat largepages_[2M/1G]

2019-02-18 Thread Suraj Jitindar Singh
This adds an entry to the kvm_stats_debugfs directory which provides the
number of large (2M or 1G) pages which have been used to setup the guest
mappings.

Signed-off-by: Suraj Jitindar Singh 
---

V1 -> V2:
- Rename debugfs files from num_[2M/1G]_pages to largepages_[2M/1G] to match
  x86

 arch/powerpc/include/asm/kvm_host.h|  2 ++
 arch/powerpc/kvm/book3s.c  |  3 +++
 arch/powerpc/kvm/book3s_64_mmu_radix.c | 15 ++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/kvm_host.h 
b/arch/powerpc/include/asm/kvm_host.h
index 0f98f00da2ea..cbb090010312 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -99,6 +99,8 @@ struct kvm_nested_guest;
 
 struct kvm_vm_stat {
ulong remote_tlb_flush;
+   ulong num_2M_pages;
+   ulong num_1G_pages;
 };
 
 struct kvm_vcpu_stat {
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index bd1a677dd9e4..72fd7d44379b 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -39,6 +39,7 @@
 #include "book3s.h"
 #include "trace.h"
 
+#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM
 #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
 
 /* #define EXIT_DEBUG */
@@ -71,6 +72,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
{ "pthru_all",   VCPU_STAT(pthru_all) },
{ "pthru_host",  VCPU_STAT(pthru_host) },
{ "pthru_bad_aff",   VCPU_STAT(pthru_bad_aff) },
+   { "largepages_2M",VM_STAT(num_2M_pages) },
+   { "largepages_1G",VM_STAT(num_1G_pages) },
{ NULL }
 };
 
diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c 
b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index 1b821c6efdef..f55ef071883f 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -403,8 +403,13 @@ void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, 
unsigned long gpa,
if (!memslot)
return;
}
-   if (shift)
+   if (shift) { /* 1GB or 2MB page */
page_size = 1ul << shift;
+   if (shift == PMD_SHIFT)
+   kvm->stat.num_2M_pages--;
+   else if (shift == PUD_SHIFT)
+   kvm->stat.num_1G_pages--;
+   }
 
gpa &= ~(page_size - 1);
hpa = old & PTE_RPN_MASK;
@@ -878,6 +883,14 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,
put_page(page);
}
 
+   /* Increment number of large pages if we (successfully) inserted one */
+   if (!ret) {
+   if (level == 1)
+   kvm->stat.num_2M_pages++;
+   else if (level == 2)
+   kvm->stat.num_1G_pages++;
+   }
+
return ret;
 }
 
-- 
2.13.6



Re: [PATCH v6] powerpc/64s: reimplement book3s idle code in C

2019-02-18 Thread Nicholas Piggin
Paul Mackerras's on February 18, 2019 9:06 am:
> On Sat, Oct 13, 2018 at 10:04:09PM +1000, Nicholas Piggin wrote:
>> Reimplement Book3S idle code in C, moving POWER7/8/9 implementation
>> speific HV idle code to the powernv platform code.
>> 
> 
> [...]
> 
>> @@ -2760,21 +2744,47 @@ BEGIN_FTR_SECTION
>>  li  r4, LPCR_PECE_HVEE@higher
>>  sldir4, r4, 32
>>  or  r5, r5, r4
>> -END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
>> +FTR_SECTION_ELSE
>> +li  r3, PNV_THREAD_NAP
>> +ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300)
>>  mtspr   SPRN_LPCR,r5
>>  isync
>> -li  r0, 0
>> -std r0, HSTATE_SCRATCH0(r13)
>> -ptesync
>> -ld  r0, HSTATE_SCRATCH0(r13)
>> -1:  cmpdr0, r0
>> -bne 1b
>> +
>> +mr  r0, r1
>> +ld  r1, PACAEMERGSP(r13)
>> +subir1, r1, STACK_FRAME_OVERHEAD
>> +std r0, 0(r1)
>> +ld  r0, PACAR1(r13)
>> +std r0, 8(r1)
> 
> This bit seems wrong to me.  If this is a secondary thread on POWER8,
> we were already on the emergency stack, and now we've reset r1 back to
> the top of the emergency stack and we're overwriting it.

I'll have to find some time to take another look at this stuff. The KVM
stuff was a bit hasty.

> I wonder why you didn't see secondary threads going off into lala land
> in your tests?

It must have been because I wasn't testing the guest SMT properly 
because I did get it to break trivially sometime after posting this 
patch out. So we were on the emergency stack here, that should make
things easier, that may be what's wrong.

Thanks,
Nick



Re: [PATCH] powerpc: fix 32-bit KVM-PR lockup and panic with MacOS guest

2019-02-18 Thread Michael Ellerman
Mark Cave-Ayland  writes:
> On 08/02/2019 14:45, Christophe Leroy wrote:
>
>> Le 08/02/2019 à 15:33, Mark Cave-Ayland a écrit :
>>> Commit 8792468da5e1 "powerpc: Add the ability to save FPU without giving it 
>>> up"
>> 
>> Expected format for the above is:
>> 
>> Commit 123456789abc ("text")
>
> Hi Christophe,
>
> Apologies - I'm fairly new at submitting kernel patches, but I can re-send it 
> in the
> correct format later if required.
>
>>> unexpectedly removed the MSR_FE0 and MSR_FE1 bits from the bitmask used to
>>> update the MSR of the previous thread in __giveup_fpu() causing a KVM-PR 
>>> MacOS
>>> guest to lockup and panic the kernel.

Which kernel is panicking? The guest or the host?

>>> Reinstate these bits to the MSR bitmask to enable MacOS guests to run under
>>> 32-bit KVM-PR once again without issue.
>>>
>>> Signed-off-by: Mark Cave-Ayland 
>> 
>> Should include a Fixes: and a Cc to stable ?
>> 
>> Fixes: 8792468da5e1 ("powerpc: Add the ability to save FPU without giving it 
>> up")
>> Cc: sta...@vger.kernel.org
>
> Indeed, but there are still some questions to be asked here:
>
> 1) Why were these bits removed from the original bitmask in the first place 
> without
> it being documented in the commit message?

It was almost certainly an accident.

> 2) Is this the right fix? I'm told that MacOS guests already run without this 
> patch
> on a G5 under 64-bit KVM-PR which may suggest that this is a workaround for 
> another
> bug elsewhere in the 32-bit powerpc code.

That's slightly worrying. It's hard to say without more detail on why
the guest is crashing.

I think your patch looks OK based just on the fact that it restores the
previous behaviour, so I'll pick it up and pass it through my usual
testing. If nothing breaks I'll merge it.

cheers


Re: [PATCH] powerpc/powernv/idle: Restore IAMR after idle

2019-02-18 Thread Nicholas Piggin
Michael Ellerman's on February 8, 2019 11:04 am:
> Nicholas Piggin  writes:
>> Russell Currey's on February 6, 2019 4:28 pm:
>>> Without restoring the IAMR after idle, execution prevention on POWER9
>>> with Radix MMU is overwritten and the kernel can freely execute userspace 
>>> without
>>> faulting.
>>> 
>>> This is necessary when returning from any stop state that modifies user
>>> state, as well as hypervisor state.
>>> 
>>> To test how this fails without this patch, load the lkdtm driver and
>>> do the following:
>>> 
>>>echo EXEC_USERSPACE > /sys/kernel/debug/provoke-crash/DIRECT
>>> 
>>> which won't fault, then boot the kernel with powersave=off, where it
>>> will fault.  Applying this patch will fix this.
>>> 
>>> Fixes: 3b10d0095a1e ("powerpc/mm/radix: Prevent kernel execution of user
>>> space")
>>> Cc: 
>>> Signed-off-by: Russell Currey 
>>
>> Good catch and debugging. This really should be a quirk, we don't want 
>> to have to restore this thing on a thread switch.
> 
> I'm not sure I follow. We don't context switch it on Radix, but we do
> on hash if pkeys are enabled.

Badly worded, I mean a hardware quirk. It should follow thread
switches. Still, avoiding it for the no-loss case is better than
nothing. We can just revisit it as an optimization if future
hardware does not require the restore.

>> Can we put it under a CONFIG option if we're not using IAMR?
> 
> We'll always be using it with Radix, and we might be using it for pkeys
> on hash, unless pkeys are compiled out. But I don't really expect anyone
> to be running with pkeys compiled out.
> 
> So I think the only case we could optimise is that we're on hash and the
> current thread has an IAMR of 0, then we could just not restore
> (assuming we come out of idle with IAMR=0).
> 
> But maybe I'm not understanding.

Nah it sounds like more trouble than it's worth in that case.

Thanks,
Nick


Re: [PATCH] powerpc: fix 32-bit KVM-PR lockup and panic with MacOS guest

2019-02-18 Thread Michael Ellerman
Mark Cave-Ayland  writes:
> On 11/02/2019 00:30, Benjamin Herrenschmidt wrote:
>
>> On Fri, 2019-02-08 at 14:51 +, Mark Cave-Ayland wrote:
>>>
>>> Indeed, but there are still some questions to be asked here:
>>>
>>> 1) Why were these bits removed from the original bitmask in the first place 
>>> without
>>> it being documented in the commit message?
>>>
>>> 2) Is this the right fix? I'm told that MacOS guests already run without 
>>> this patch
>>> on a G5 under 64-bit KVM-PR which may suggest that this is a workaround for 
>>> another
>>> bug elsewhere in the 32-bit powerpc code.
>>>
>>>
>>> If you think that these points don't matter, then I'm happy to resubmit the 
>>> patch
>>> as-is based upon your comments above.
>> 
>> We should write a test case to verify that FE0/FE1 are properly
>> preserved/context-switched etc... I bet if we accidentally wiped them,
>> we wouldn't notice 99.9% of the time.
>
> Right I guess it's more likely to cause in issue in the KVM PR case because 
> the guest
> can alter the flags in a way that doesn't go through the normal process 
> switch mechanism.
>
> The original patchset at
> https://www.mail-archive.com/linuxppc-dev@lists.ozlabs.org/msg98326.html does 
> include
> some tests in the first few patches, but AFAICT they are concerned with the 
> contents
> of the FP registers rather than the related MSRs.

fpu_preempt.c should be able to be adapted to also check the MSR bits.

> Who is the right person to ask about fixing issues related to context 
> switching with
> KVM PR?

KVM PR doesn't really have a maintainer TBH. Feel like volunteering? :)

> I did add the original author's email address to my first few emails but have
> had no response back :/

Cyril who wrote the original FPU patch has moved on to other things.

cheers


Re: [RFC PATCH v1] powerpc/accounting: do not account system time on transition to user.

2019-02-18 Thread Nicholas Piggin
Christophe Leroy's on February 9, 2019 12:40 am:
> Time spent in kernel mode don't need to be accounted on transition
> to user space. As far as the time spent in user is known, it
> is possible to calculate the time spent in kernel by substracting
> the time spent in user.
> 
> To do so, this patch modifies vtime_delta() to substract the
> time spent in user since the last call to vtime_delta().
> 
> This patch gives a 2% improvment of null_syscall() selftest on a 83xx.
> 
> Signed-off-by: Christophe Leroy 

This looks like a clever little optimization, although I don't know
this time accounting code very well.

> ---
> But surprisingly, this patch degrades the null_syscall selftest by 20% on the 
> 8xx. Any idea of the reason ?

I don't know microarchitecture of any of those CPUs I'm afraid.
On the 64s CPUs, mftb is what hurts.

> 
>  arch/powerpc/include/asm/accounting.h | 1 +
>  arch/powerpc/include/asm/ppc_asm.h| 8 +---
>  arch/powerpc/kernel/asm-offsets.c | 8 ++--
>  arch/powerpc/kernel/time.c| 4 +++-
>  4 files changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/accounting.h 
> b/arch/powerpc/include/asm/accounting.h
> index c607c5d835cc..2f1ff5f9fd7a 100644
> --- a/arch/powerpc/include/asm/accounting.h
> +++ b/arch/powerpc/include/asm/accounting.h
> @@ -27,6 +27,7 @@ struct cpu_accounting_data {
>   /* Internal counters */
>   unsigned long starttime;/* TB value snapshot */
>   unsigned long starttime_user;   /* TB value on exit to usermode */
> + unsigned long utime_asm;
>  #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME
>   unsigned long startspurr;   /* SPURR value snapshot */
>   unsigned long utime_sspurr; /* ->user_time when ->startspurr set */
> diff --git a/arch/powerpc/include/asm/ppc_asm.h 
> b/arch/powerpc/include/asm/ppc_asm.h
> index e0637730a8e7..be17d570d484 100644
> --- a/arch/powerpc/include/asm/ppc_asm.h
> +++ b/arch/powerpc/include/asm/ppc_asm.h
> @@ -28,9 +28,8 @@
>  #define ACCOUNT_STOLEN_TIME
>  #else
>  #define ACCOUNT_CPU_USER_ENTRY(ptr, ra, rb)  \
> - MFTB(ra);   /* get timebase */  \
>   PPC_LL  rb, ACCOUNT_STARTTIME_USER(ptr);\
> - PPC_STL ra, ACCOUNT_STARTTIME(ptr); \
> + MFTB(ra);   /* get timebase */  \
>   subfrb,rb,ra;   /* subtract start value */  \
>   PPC_LL  ra, ACCOUNT_USER_TIME(ptr); \
>   add ra,ra,rb;   /* add on to user time */   \
> @@ -38,12 +37,7 @@
>  
>  #define ACCOUNT_CPU_USER_EXIT(ptr, ra, rb)   \
>   MFTB(ra);   /* get timebase */  \
> - PPC_LL  rb, ACCOUNT_STARTTIME(ptr); \
>   PPC_STL ra, ACCOUNT_STARTTIME_USER(ptr);\
> - subfrb,rb,ra;   /* subtract start value */  \
> - PPC_LL  ra, ACCOUNT_SYSTEM_TIME(ptr);   \
> - add ra,ra,rb;   /* add on to system time */ \
> - PPC_STL ra, ACCOUNT_SYSTEM_TIME(ptr)
>  
>  #ifdef CONFIG_PPC_SPLPAR
>  #define ACCOUNT_STOLEN_TIME  \
> diff --git a/arch/powerpc/kernel/asm-offsets.c 
> b/arch/powerpc/kernel/asm-offsets.c
> index 7a1b93c5af63..f2ba7735f56f 100644
> --- a/arch/powerpc/kernel/asm-offsets.c
> +++ b/arch/powerpc/kernel/asm-offsets.c
> @@ -260,19 +260,15 @@ int main(void)
>   OFFSET(PACAHWCPUID, paca_struct, hw_cpu_id);
>   OFFSET(PACAKEXECSTATE, paca_struct, kexec_state);
>   OFFSET(PACA_DSCR_DEFAULT, paca_struct, dscr_default);
> - OFFSET(ACCOUNT_STARTTIME, paca_struct, accounting.starttime);
>   OFFSET(ACCOUNT_STARTTIME_USER, paca_struct, accounting.starttime_user);
> - OFFSET(ACCOUNT_USER_TIME, paca_struct, accounting.utime);
> - OFFSET(ACCOUNT_SYSTEM_TIME, paca_struct, accounting.stime);
> + OFFSET(ACCOUNT_USER_TIME, paca_struct, accounting.utime_asm);
>   OFFSET(PACA_TRAP_SAVE, paca_struct, trap_save);
>   OFFSET(PACA_NAPSTATELOST, paca_struct, nap_state_lost);
>   OFFSET(PACA_SPRG_VDSO, paca_struct, sprg_vdso);
>  #else /* CONFIG_PPC64 */
>  #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
> - OFFSET(ACCOUNT_STARTTIME, thread_info, accounting.starttime);
>   OFFSET(ACCOUNT_STARTTIME_USER, thread_info, accounting.starttime_user);
> - OFFSET(ACCOUNT_USER_TIME, thread_info, accounting.utime);
> - OFFSET(ACCOUNT_SYSTEM_TIME, thread_info, accounting.stime);
> + OFFSET(ACCOUNT_USER_TIME, thread_info, accounting.utime_asm);
>  #endif
>  #endif /* CONFIG_PPC64 */
>  
> diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
> index bc0503ef9c9c..79420643b45f 100644
> --- a/arch/powerpc/kernel/time.c
> +++ b/arch/powerpc/kernel/time.c
> @@ -331,8 +331,10 @@ static unsigned long vtime

Re: [PATCH] powerpc/book3s: Remove a few page table update interfaces.

2019-02-18 Thread Nicholas Piggin
Aneesh Kumar K.V's on February 14, 2019 4:45 pm:
> When updating page tables, we need to make sure we fill the page table
> entry valid bit. We should be using page table populate interface for
> updating the table entries. The page table 'set' interface allows
> updating the raw value of page table entry. This can result in
> updating the entry wrongly. Remove the 'set' interface so that we avoid
> its future usage.

Removing a pointless indirection is fine by me, but I can't
figure out how this change could help to prevent entry being updated
incorrectly.

Thanks,
Nick

> 
> Signed-off-by: Aneesh Kumar K.V 
> ---
>  arch/powerpc/include/asm/book3s/64/pgalloc.h |  8 
>  arch/powerpc/include/asm/book3s/64/pgtable.h | 14 --
>  2 files changed, 4 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h 
> b/arch/powerpc/include/asm/book3s/64/pgalloc.h
> index 9c1173283b96..138bc2ecc0c4 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgalloc.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h
> @@ -111,7 +111,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t 
> *pgd)
>  
>  static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
>  {
> - pgd_set(pgd, __pgtable_ptr_val(pud) | PGD_VAL_BITS);
> + *pgd =  __pgd(__pgtable_ptr_val(pud) | PGD_VAL_BITS);
>  }
>  
>  static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
> @@ -138,7 +138,7 @@ static inline void pud_free(struct mm_struct *mm, pud_t 
> *pud)
>  
>  static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
>  {
> - pud_set(pud, __pgtable_ptr_val(pmd) | PUD_VAL_BITS);
> + *pud = __pud(__pgtable_ptr_val(pmd) | PUD_VAL_BITS);
>  }
>  
>  static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
> @@ -176,13 +176,13 @@ static inline void __pmd_free_tlb(struct mmu_gather 
> *tlb, pmd_t *pmd,
>  static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
>  pte_t *pte)
>  {
> - pmd_set(pmd, __pgtable_ptr_val(pte) | PMD_VAL_BITS);
> + *pmd = __pmd(__pgtable_ptr_val(pte) | PMD_VAL_BITS);
>  }
>  
>  static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
>   pgtable_t pte_page)
>  {
> - pmd_set(pmd, __pgtable_ptr_val(pte_page) | PMD_VAL_BITS);
> + *pmd = __pmd(__pgtable_ptr_val(pte_page) | PMD_VAL_BITS);
>  }
>  
>  static inline pgtable_t pmd_pgtable(pmd_t pmd)
> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
> b/arch/powerpc/include/asm/book3s/64/pgtable.h
> index dc71e2b92003..a24e00fb7fa7 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
> @@ -853,11 +853,6 @@ static inline bool pte_ci(pte_t pte)
>   return false;
>  }
>  
> -static inline void pmd_set(pmd_t *pmdp, unsigned long val)
> -{
> - *pmdp = __pmd(val);
> -}
> -
>  static inline void pmd_clear(pmd_t *pmdp)
>  {
>   *pmdp = __pmd(0);
> @@ -889,11 +884,6 @@ static inline int pmd_bad(pmd_t pmd)
>   return hash__pmd_bad(pmd);
>  }
>  
> -static inline void pud_set(pud_t *pudp, unsigned long val)
> -{
> - *pudp = __pud(val);
> -}
> -
>  static inline void pud_clear(pud_t *pudp)
>  {
>   *pudp = __pud(0);
> @@ -936,10 +926,6 @@ static inline bool pud_access_permitted(pud_t pud, bool 
> write)
>  }
>  
>  #define pgd_write(pgd)   pte_write(pgd_pte(pgd))
> -static inline void pgd_set(pgd_t *pgdp, unsigned long val)
> -{
> - *pgdp = __pgd(val);
> -}
>  
>  static inline void pgd_clear(pgd_t *pgdp)
>  {
> -- 
> 2.20.1
> 
> 


Re: [PATCH] powerpc/book3s: Remove a few page table update interfaces.

2019-02-18 Thread Aneesh Kumar K.V

On 2/19/19 11:23 AM, Nicholas Piggin wrote:

Aneesh Kumar K.V's on February 14, 2019 4:45 pm:

When updating page tables, we need to make sure we fill the page table
entry valid bit. We should be using page table populate interface for
updating the table entries. The page table 'set' interface allows
updating the raw value of page table entry. This can result in
updating the entry wrongly. Remove the 'set' interface so that we avoid
its future usage.


Removing a pointless indirection is fine by me, but I can't
figure out how this change could help to prevent entry being updated
incorrectly.



I guess my commit message is confusing. What I meant is this avoid the 
usage of pgd/pud_set from other kernel code without updating the page 
table entry valid bits. The idea is to make pgd_populate as the only 
interface for update pgd entries.


-aneesh



Re: [RFC PATCH 2/2] powerpc/mm/hash64: Map all the kernel mapping in the same 0xc range

2019-02-18 Thread Nicholas Piggin
Aneesh Kumar K.V's on February 17, 2019 3:16 pm:
> This patch maps vmap, IO and vmemap regions in the 0xc address range
> instead of the current 0xd and 0xf range. This brings the mapping closer
> to radix translation mode.

What was the reason for that address layout in the first place?

Thanks,
Nick



Re: [RFC PATCH 2/2] powerpc/mm/hash64: Map all the kernel mapping in the same 0xc range

2019-02-18 Thread Aneesh Kumar K.V

On 2/19/19 11:28 AM, Nicholas Piggin wrote:

Aneesh Kumar K.V's on February 17, 2019 3:16 pm:

This patch maps vmap, IO and vmemap regions in the 0xc address range
instead of the current 0xd and 0xf range. This brings the mapping closer
to radix translation mode.


What was the reason for that address layout in the first place?



To bring in closer to radix translation mode and it should also help 
with KASAN implementation.


-aneesh



Re: [RFC PATCH 0/5] powerpc: KASAN for 64-bit Book3E

2019-02-18 Thread Daniel Axtens
Hi Balbir,


> Thanks for following through with this, could you please share details on
> how you've been testing this?
>
> I know qemu supports qemu -cpu e6500, but beyond that what does the machine
> look like?

I've been using a T4240RDB, so real hardware. It boots both the QorIQ
Yocto-based distro and Debian ppc64. I have run parts of kselftest and
am currently running LTP - so far no errors have triggered.

Regards,
Daniel

>
> Balbir Singh. 


Re: [RFC PATCH 5/5] powerpc: KASAN for 64bit Book3E

2019-02-18 Thread Daniel Axtens
Dmitry Vyukov  writes:

> On Fri, Feb 15, 2019 at 1:05 AM Daniel Axtens  wrote:
>>
>> Wire up KASAN. Only outline instrumentation is supported.
>>
>> The KASAN shadow area is mapped into vmemmap space:
>> 0x8000 0400   to 0x8000 0600  .
>> To do this we require that vmemmap be disabled. (This is the default
>> in the kernel config that QorIQ provides for the machine in their
>> SDK anyway - they use flat memory.)
>>
>> Only the kernel linear mapping (0xc000...) is checked. The vmalloc and
>> ioremap areas (also in 0x800...) are all mapped to a zero page. As
>> with the Book3S hash series, this requires overriding the memory <->
>> shadow mapping.
>>
>> Also, as with both previous 64-bit series, early instrumentation is not
>> supported.  It would allow us to drop the check_return_arch_not_ready()
>> hook in the KASAN core, but it's tricky to get it set up early enough:
>> we need it setup before the first call to instrumented code like printk().
>> Perhaps in the future.
>>
>> Only KASAN_MINIMAL works.
>>
>> Lightly tested on e6500. KVM, kexec and xmon have not been tested.
>
> Hi Daniel,
>
> This is great!
>
> Not related to the patch, but if you booted a real devices and used it
> to some degree, I wonder if you hit any KASAN reports?

Not yet, but the hope is that I will be able to extend this to book3s
and then it will be more useful in combination with syzkaller.

Regards,
Daniel

>
> Thanks
>
>> The test_kasan module fires warnings as expected, except for the
>> following tests:
>>
>>  - Expected/by design:
>> kasan test: memcg_accounted_kmem_cache allocate memcg accounted object
>>
>>  - Due to only supporting KASAN_MINIMAL:
>> kasan test: kasan_stack_oob out-of-bounds on stack
>> kasan test: kasan_global_oob out-of-bounds global variable
>> kasan test: kasan_alloca_oob_left out-of-bounds to left on alloca
>> kasan test: kasan_alloca_oob_right out-of-bounds to right on alloca
>> kasan test: use_after_scope_test use-after-scope on int
>> kasan test: use_after_scope_test use-after-scope on array
>>
>> Thanks to those who have done the heavy lifting over the past several years:
>>  - Christophe's 32 bit series: 
>> https://lists.ozlabs.org/pipermail/linuxppc-dev/2019-February/185379.html
>>  - Aneesh's Book3S hash series: https://lwn.net/Articles/655642/
>>  - Balbir's Book3S radix series: https://patchwork.ozlabs.org/patch/795211/
>>
>> Cc: Christophe Leroy 
>> Cc: Aneesh Kumar K.V 
>> Cc: Balbir Singh 
>> Signed-off-by: Daniel Axtens 
>>
>> ---
>>
>> While useful if you have a book3e device, this is mostly intended
>> as a warm-up exercise for reviving Aneesh's series for book3s hash.
>> In particular, changes to the kasan core are going to be required
>> for hash and radix as well.
>> ---
>>  arch/powerpc/Kconfig |  1 +
>>  arch/powerpc/Makefile|  2 +
>>  arch/powerpc/include/asm/kasan.h | 77 ++--
>>  arch/powerpc/include/asm/ppc_asm.h   |  7 ++
>>  arch/powerpc/include/asm/string.h|  7 +-
>>  arch/powerpc/lib/mem_64.S|  6 +-
>>  arch/powerpc/lib/memcmp_64.S |  5 +-
>>  arch/powerpc/lib/memcpy_64.S |  3 +-
>>  arch/powerpc/lib/string.S| 15 ++--
>>  arch/powerpc/mm/Makefile |  2 +
>>  arch/powerpc/mm/kasan/Makefile   |  1 +
>>  arch/powerpc/mm/kasan/kasan_init_book3e_64.c | 53 ++
>>  arch/powerpc/purgatory/Makefile  |  3 +
>>  arch/powerpc/xmon/Makefile   |  1 +
>>  14 files changed, 164 insertions(+), 19 deletions(-)
>>  create mode 100644 arch/powerpc/mm/kasan/kasan_init_book3e_64.c
>>
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 850b06def84f..2c7c20d52778 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -176,6 +176,7 @@ config PPC
>> select HAVE_ARCH_AUDITSYSCALL
>> select HAVE_ARCH_JUMP_LABEL
>> select HAVE_ARCH_KASAN  if PPC32
>> +   select HAVE_ARCH_KASAN  if PPC_BOOK3E_64 && 
>> !SPARSEMEM_VMEMMAP
>> select HAVE_ARCH_KGDB
>> select HAVE_ARCH_MMAP_RND_BITS
>> select HAVE_ARCH_MMAP_RND_COMPAT_BITS   if COMPAT
>> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
>> index f0738099e31e..21c2dadf0315 100644
>> --- a/arch/powerpc/Makefile
>> +++ b/arch/powerpc/Makefile
>> @@ -428,11 +428,13 @@ endif
>>  endif
>>
>>  ifdef CONFIG_KASAN
>> +ifdef CONFIG_PPC32
>>  prepare: kasan_prepare
>>
>>  kasan_prepare: prepare0
>> $(eval KASAN_SHADOW_OFFSET = $(shell awk '{if ($$2 == 
>> "KASAN_SHADOW_OFFSET") print $$3;}' include/generated/asm-offsets.h))
>>  endif
>> +endif
>>
>>  # Check toolchain versions:
>>  # - gcc-4.6 is the minimum kernel-wide version so nothing required.
>> diff --git a/arch/powerpc/include/asm/kasan.h 
>> b/arch/powerpc/include/asm/kasan.h
>> index 5d0088429b62..c2f6f05dfaa3 100644
>> --- 

RE: [PATCHv6 1/4] dt-bindings: add DT binding for the layerscape PCIe controller with EP mode

2019-02-18 Thread Xiaowei Bao


-Original Message-
From: Lorenzo Pieralisi  
Sent: 2019年2月6日 2:03
To: Xiaowei Bao 
Cc: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; 
shawn...@kernel.org; Leo Li ; kis...@ti.com; a...@arndb.de; 
gre...@linuxfoundation.org; M.h. Lian ; Mingkai Hu 
; Roy Zang ; 
kstew...@linuxfoundation.org; cyrille.pitc...@free-electrons.com; 
pombreda...@nexb.com; shawn@rock-chips.com; linux-...@vger.kernel.org; 
devicet...@vger.kernel.org; linux-ker...@vger.kernel.org; 
linux-arm-ker...@lists.infradead.org; linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCHv6 1/4] dt-bindings: add DT binding for the layerscape PCIe 
controller with EP mode

On Tue, Jan 22, 2019 at 02:33:25PM +0800, Xiaowei Bao wrote:
> Add the documentation for the Device Tree binding for the layerscape 
> PCIe controller with EP mode.
> 
> Signed-off-by: Xiaowei Bao 
> Reviewed-by: Minghuan Lian 
> Reviewed-by: Zhiqiang Hou 
> Reviewed-by: Rob Herring 
> ---
> v2:
>  - Add the SoC specific compatibles.
> v3:
>  - modify the commit message.
> v4:
>  - no change.
> v5:
>  - no change.
> v6:
>  - no change.
> 
>  .../devicetree/bindings/pci/layerscape-pci.txt |3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)

Applied the series to pci/layerscape for v5.1, thanks.
[Xiaowei Bao] Hi Lorenzo, thank a lot.

Lorenzo
> diff --git a/Documentation/devicetree/bindings/pci/layerscape-pci.txt 
> b/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> index 9b2b8d6..e20ceaa 100644
> --- a/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> +++ b/Documentation/devicetree/bindings/pci/layerscape-pci.txt
> @@ -13,6 +13,7 @@ information.
>  
>  Required properties:
>  - compatible: should contain the platform identifier such as:
> +  RC mode:
>  "fsl,ls1021a-pcie"
>  "fsl,ls2080a-pcie", "fsl,ls2085a-pcie"
>  "fsl,ls2088a-pcie"
> @@ -20,6 +21,8 @@ Required properties:
>  "fsl,ls1046a-pcie"
>  "fsl,ls1043a-pcie"
>  "fsl,ls1012a-pcie"
> +  EP mode:
> + "fsl,ls1046a-pcie-ep", "fsl,ls-pcie-ep"
>  - reg: base addresses and lengths of the PCIe controller register blocks.
>  - interrupts: A list of interrupt outputs of the controller. Must contain an
>entry for each entry in the interrupt-names property.
> --
> 1.7.1
> 


Re: [RFC PATCH 2/2] powerpc/mm/hash64: Map all the kernel mapping in the same 0xc range

2019-02-18 Thread Nicholas Piggin
Aneesh Kumar K.V's on February 19, 2019 4:00 pm:
> On 2/19/19 11:28 AM, Nicholas Piggin wrote:
>> Aneesh Kumar K.V's on February 17, 2019 3:16 pm:
>>> This patch maps vmap, IO and vmemap regions in the 0xc address range
>>> instead of the current 0xd and 0xf range. This brings the mapping closer
>>> to radix translation mode.
>> 
>> What was the reason for that address layout in the first place?
>> 
> 
> To bring in closer to radix translation mode and it should also help 
> with KASAN implementation.

No I mean the old implementation. Your change seems fine, it would just
be good to know what the downside (if any) is from changing. Maybe it 
was just to make debugging slightly simpler?

Thanks,
Nick


Re: [PATCH] powerpc: fix 32-bit KVM-PR lockup and panic with MacOS guest

2019-02-18 Thread Mark Cave-Ayland
On 19/02/2019 04:20, Michael Ellerman wrote:

Hi Michael,

> Mark Cave-Ayland  writes:
>> On 08/02/2019 14:45, Christophe Leroy wrote:
>>
>>> Le 08/02/2019 à 15:33, Mark Cave-Ayland a écrit :
 Commit 8792468da5e1 "powerpc: Add the ability to save FPU without giving 
 it up"
>>>
>>> Expected format for the above is:
>>>
>>> Commit 123456789abc ("text")
>>
>> Hi Christophe,
>>
>> Apologies - I'm fairly new at submitting kernel patches, but I can re-send 
>> it in the
>> correct format later if required.
>>
 unexpectedly removed the MSR_FE0 and MSR_FE1 bits from the bitmask used to
 update the MSR of the previous thread in __giveup_fpu() causing a KVM-PR 
 MacOS
 guest to lockup and panic the kernel.
> 
> Which kernel is panicking? The guest or the host?

It's the host kernel. As long as you occasionally tap a few keys to keep the 
screen
blanking disabled then you can see the panic on the physical console.

I've uploaded a photo I took during the bisection containing the panic when 
booting
MacOS X 10.2 under qemu-system-ppc to
https://www.ilande.co.uk/tmp/qemu/macmini-kvm.jpg in case you find it useful.

Given that it's really easy to recreate, let me know if you want me to do a git
pull/rebuild and/or if you need any debugging information as it's easy for me to
reproduce.

 Reinstate these bits to the MSR bitmask to enable MacOS guests to run under
 32-bit KVM-PR once again without issue.

 Signed-off-by: Mark Cave-Ayland 
>>>
>>> Should include a Fixes: and a Cc to stable ?
>>>
>>> Fixes: 8792468da5e1 ("powerpc: Add the ability to save FPU without giving 
>>> it up")
>>> Cc: sta...@vger.kernel.org
>>
>> Indeed, but there are still some questions to be asked here:
>>
>> 1) Why were these bits removed from the original bitmask in the first place 
>> without
>> it being documented in the commit message?
> 
> It was almost certainly an accident.

Heh, okay :)

>> 2) Is this the right fix? I'm told that MacOS guests already run without 
>> this patch
>> on a G5 under 64-bit KVM-PR which may suggest that this is a workaround for 
>> another
>> bug elsewhere in the 32-bit powerpc code.
> 
> That's slightly worrying. It's hard to say without more detail on why
> the guest is crashing.
> 
> I think your patch looks OK based just on the fact that it restores the
> previous behaviour, so I'll pick it up and pass it through my usual
> testing. If nothing breaks I'll merge it.

That would be great! Does it need a CC to stable too? It would be great if this 
would
get picked up in the next set of Debian ports kernels, for example.


ATB,

Mark.