Re: [RFC PATCH v2 5/5] powerpc/syscalls: Allow none instead of sys_ni_syscall

2019-01-17 Thread Firoz Khan
Hi Arnd,

On Wed, 16 Jan 2019 at 19:23, Arnd Bergmann  wrote:
>
> On Wed, Jan 16, 2019 at 2:27 PM Michael Ellerman  wrote:
> > @@ -24,28 +24,28 @@
> >  14 common  mknod   sys_mknod
> >  15 common  chmod   sys_chmod
> >  16 common  lchown  sys_lchown
> > -17 common  break   sys_ni_syscall
> > -18 32  oldstat sys_stat
> > sys_ni_syscall
> > -18 64  oldstat sys_ni_syscall
> > +17 common  break   none
> > +18 32  oldstat sys_stat
> > none
> > +18 64  oldstat none
>
> The '64 oldstat' line can simply get dropped here, it has no value
> (I failed to notice this earlier).

The initial requirement is to replace uapi and syscalltbl file with
the script as it is.
If I'm right, for oldstat has uapi header and syscalltbl entry is
sys_ni_syscall. So
the above change will replace uapi and syscalltbl as it is.

We'll do a cleanup for all 10 architectures, so that time we can
remove this (and similer)
entries.

Thanks
Firoz


Re: [RFC PATCH v2 2/5] powerpc/syscalls: Remove unused offset parameter

2019-01-17 Thread Firoz Khan
Hi Michael,

On Wed, 16 Jan 2019 at 18:57, Michael Ellerman  wrote:
>
> We never pass a value for offset, nor do we need to, so remove the
> offset logic.

The idea behind all these effort is to come up with a common script for alpha,
ia64, m68k, microblaze, mips, parisc, powerpc, sh, sparc and xtensa. If I'm
right, ia64 and mips pass offset and rest of the architecture doesn't. Inorder
to come up with a offset logic to accommodate those 2 archs requirements.

I think x86, arm and s390 can use the same support with minor changes. So
prefix also need to use it.

I already create a patch series for powerpc with unified script. the changes u
suggested will make difficult to make unified script.

Thanks
Firoz


Re: [RFC PATCH 4/5] powerpc/syscalls: Allow none instead of sys_ni_syscall

2019-01-17 Thread Firoz Khan
Hi Michael,

On Mon, 14 Jan 2019 at 17:06, Michael Ellerman  wrote:
>
> sys_ni_syscall is the "not-implemented" syscall syscall, which just
> returns -ENOSYS.
>
> But unless you know that it's not obvious what it does, and even if
> you do know what it means it doesn't stand out that well from other
> real syscalls.
>
> So teach the scripts to treat "none" as a synonym for
> "sys_ni_syscall". This makes the table more readable.

The idea of the first patch series for system call table generation support
is to replace uapi and syscall table as it is. That's why u can find places
where sys_ni_syscalls present. I have a plan for cleanup in the uapi header
and syscall table files. By that time all sys_ni_syscall removed from the
table (Hopefully).

I can post the cleanup patch asap.

> +   if [ "$t_entry" = "none" ]; then
> +   t_entry="sys_ni_syscall"
> +   fi
> +

In that case I don't this above change is required.

Thanks
Firoz


[PATCH] powerpc/powernv: Force an freset if IODA reset fails

2019-01-17 Thread Oliver O'Halloran
The IODA reset can fail in cases where the PHB has encounted a fatal error
during early boot. Typically this is due a malfunctioning device directly below
the root complex, but can occur for other reasons. This patch fixes the problem
by forcing a reset of the PHB if we get an error back from firmware when doing
the IODA reset.

Signed-off-by: Oliver O'Halloran 
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index 1d6406a..53982f8 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -3943,9 +3943,12 @@ static void __init pnv_pci_init_ioda_phb(struct 
device_node *np,
 * shutdown PCI devices correctly. We already got IODA table
 * cleaned out. So we have to issue PHB reset to stop all PCI
 * transactions from previous kernel. The ppc_pci_reset_phbs
-* kernel parameter will force this reset too.
+* kernel parameter will force this reset too. Additionally,
+* if the IODA reset above failed then use a bigger hammer.
+* This can happen if we get a PHB fatal error in very early
+* boot.
 */
-   if (is_kdump_kernel() || pci_reset_phbs) {
+   if (is_kdump_kernel() || pci_reset_phbs || rc) {
pr_info("  Issue PHB reset ...\n");
pnv_eeh_phb_reset(hose, EEH_RESET_FUNDAMENTAL);
pnv_eeh_phb_reset(hose, EEH_RESET_DEACTIVATE);
-- 
2.9.4



Re: [PATCH 0/3] powerpc: some header search path cleanups

2019-01-17 Thread Masahiro Yamada
Hi Michael,


On Fri, Jan 11, 2019 at 2:20 PM Masahiro Yamada
 wrote:
>
> I am trying to get rid of crappy magic from Kbuild core makefiles.
>
> Before that, I want to drop as many useless paths as possible.
> Actually, many Makefiles are adding around pointless options.
>
> This series cleans some powerpc Makefiles.
> (only compile-tested by 0day bot)


Could you apply this series to ppc tree if you are fine with it?





> Masahiro Yamada (3):
>   KVM: powerpc: remove -I. header search paths
>   powerpc: remove redundant header search path additions
>   powerpc: math-emu: remove unneeded header search paths
>
>  arch/powerpc/Makefile  | 4 ++--
>  arch/powerpc/kvm/Makefile  | 5 -
>  arch/powerpc/math-emu/Makefile | 2 +-
>  3 files changed, 3 insertions(+), 8 deletions(-)
>
> --
> 2.7.4
>


-- 
Best Regards
Masahiro Yamada


Re: G5 Quad hangs early on 4.20.2 / 5.0-rc2+

2019-01-17 Thread Paul Mackerras
On Tue, Jan 15, 2019 at 11:49:45PM +0100, Tobias Ulmer wrote:
> Hi,
> 
> both the latest stable 4.20.2 and 5.0 rc2+ hang early on the G5 Quad.

Interesting, I just built v4.20 with g5_defconfig for my quad and it
booted just fine.  I'll try Linus' latest.

It could be config-related; could you send me your .config (off-list)?

Paul.


[PATCH] hugetlb: allow to free gigantic pages regardless of the configuration

2019-01-17 Thread Alexandre Ghiti
From: Alexandre Ghiti 

On systems without CMA or (MEMORY_ISOLATION && COMPACTION) activated but
that support gigantic pages, boottime reserved gigantic pages can not be
freed at all. This patchs simply enables the possibility to hand back
those pages to memory allocator.

This commit then renames gigantic_page_supported and
ARCH_HAS_GIGANTIC_PAGE to make them more accurate. Indeed, those values
being false does not mean that the system cannot use gigantic pages: it
just means that runtime allocation of gigantic pages is not supported,
one can still allocate boottime gigantic pages if the architecture supports
it.

Signed-off-by: Alexandre Ghiti 
---

- Compiled on all architectures
- Tested on riscv architecture

 arch/arm64/Kconfig   |  2 +-
 arch/arm64/include/asm/hugetlb.h |  7 +++--
 arch/powerpc/include/asm/book3s/64/hugetlb.h |  4 +--
 arch/powerpc/platforms/Kconfig.cputype   |  2 +-
 arch/s390/Kconfig|  2 +-
 arch/s390/include/asm/hugetlb.h  |  7 +++--
 arch/x86/Kconfig |  2 +-
 arch/x86/include/asm/hugetlb.h   |  7 +++--
 fs/Kconfig   |  2 +-
 include/linux/gfp.h  |  2 +-
 mm/hugetlb.c | 43 +++-
 mm/page_alloc.c  |  4 +--
 12 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index a4168d366127..18239cbd7fcd 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -18,7 +18,7 @@ config ARM64
select ARCH_HAS_FAST_MULTIPLIER
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_GCOV_PROFILE_ALL
-   select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
+   select ARCH_HAS_GIGANTIC_PAGE_RUNTIME_ALLOCATION if (MEMORY_ISOLATION 
&& COMPACTION) || CMA
select ARCH_HAS_KCOV
select ARCH_HAS_MEMBARRIER_SYNC_CORE
select ARCH_HAS_PTE_SPECIAL
diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h
index fb6609875455..797fc77eabcd 100644
--- a/arch/arm64/include/asm/hugetlb.h
+++ b/arch/arm64/include/asm/hugetlb.h
@@ -65,8 +65,11 @@ extern void set_huge_swap_pte_at(struct mm_struct *mm, 
unsigned long addr,
 
 #include 
 
-#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
-static inline bool gigantic_page_supported(void) { return true; }
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE_RUNTIME_ALLOCATION
+static inline bool gigantic_page_runtime_allocation_supported(void)
+{
+   return true;
+}
 #endif
 
 #endif /* __ASM_HUGETLB_H */
diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h 
b/arch/powerpc/include/asm/book3s/64/hugetlb.h
index 5b0177733994..7711f0e2c7e5 100644
--- a/arch/powerpc/include/asm/book3s/64/hugetlb.h
+++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h
@@ -32,8 +32,8 @@ static inline int hstate_get_psize(struct hstate *hstate)
}
 }
 
-#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
-static inline bool gigantic_page_supported(void)
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE_RUNTIME_ALLOCATION
+static inline bool gigantic_page_runtime_allocation_supported(void)
 {
return true;
 }
diff --git a/arch/powerpc/platforms/Kconfig.cputype 
b/arch/powerpc/platforms/Kconfig.cputype
index 8c7464c3f27f..779e06bac697 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -319,7 +319,7 @@ config ARCH_ENABLE_SPLIT_PMD_PTLOCK
 config PPC_RADIX_MMU
bool "Radix MMU Support"
depends on PPC_BOOK3S_64
-   select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
+   select ARCH_HAS_GIGANTIC_PAGE_RUNTIME_ALLOCATION if (MEMORY_ISOLATION 
&& COMPACTION) || CMA
default y
help
  Enable support for the Power ISA 3.0 Radix style MMU. Currently this
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index ed554b09eb3f..6776eef6a9ae 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -69,7 +69,7 @@ config S390
select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_GCOV_PROFILE_ALL
-   select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
+   select ARCH_HAS_GIGANTIC_PAGE_RUNTIME_ALLOCATION if (MEMORY_ISOLATION 
&& COMPACTION) || CMA
select ARCH_HAS_KCOV
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_SET_MEMORY
diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
index 2d1afa58a4b6..57c952f5388e 100644
--- a/arch/s390/include/asm/hugetlb.h
+++ b/arch/s390/include/asm/hugetlb.h
@@ -116,7 +116,10 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t 
newprot)
return pte_modify(pte, newprot);
 }
 
-#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
-static inline bool gigantic_page_supported(void) { return true; }
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE_RUNTIME_ALLOCATION
+static inline bool gigantic_page_runtime_al

Re: G5 Quad hangs early on 4.20.2 / 5.0-rc2+

2019-01-17 Thread Tobias Ulmer
On Fri, Jan 18, 2019 at 09:32:07AM +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2019-01-17 at 10:42 +0100, Tobias Ulmer wrote:
> > On Wed, Jan 16, 2019 at 12:15:14PM +1100, Benjamin Herrenschmidt wrote:
> > > On Tue, 2019-01-15 at 23:49 +0100, Tobias Ulmer wrote:
> > > > Hi,
> > > > 
> > > > both the latest stable 4.20.2 and 5.0 rc2+ hang early on the G5 Quad.
> > > > 
> > > > Surely I'm not the first to run into this, but I couldn't find any
> > > > discussion or bug report. Sorry if you're already aware.
> > > > 
> > > > You can see it hang here (5.0 rc2+, 4.20.2 is nearly identical) until
> > > > the watchdog triggers a reboot:
> > > > 
> > > > https://i.imgur.com/UiCVRuG.jpg
> > > > 
...
> I'll be back on monday or tuesday, let me know where you got up to then
> and I'll take it from there. Also email me your .config please.


Hi,

this was caused by 5c63e407aaabb0464236cfc6279a2d79aede7073
(fbdev: Convert to using %pOFn instead of device_node.name)

name can't be NULL into offb_init_fb, there's a printk and the call to
offb_init_palette_hacks where name is matched against OF device names.

With the partial revert below, both 5.0-rc2+ and 4.20 are happy.

diff --git a/drivers/video/fbdev/offb.c b/drivers/video/fbdev/offb.c
index 31f769d67195..77c0a2f45b3b 100644
--- a/drivers/video/fbdev/offb.c
+++ b/drivers/video/fbdev/offb.c
@@ -419,13 +419,9 @@ static void __init offb_init_fb(const char *name,
var = &info->var;
info->par = par;
 
-   if (name) {
-   strcpy(fix->id, "OFfb ");
-   strncat(fix->id, name, sizeof(fix->id) - sizeof("OFfb "));
-   fix->id[sizeof(fix->id) - 1] = '\0';
-   } else
-   snprintf(fix->id, sizeof(fix->id), "OFfb %pOFn", dp);
-
+   strcpy(fix->id, "OFfb ");
+   strncat(fix->id, name, sizeof(fix->id) - sizeof("OFfb "));
+   fix->id[sizeof(fix->id) - 1] = '\0';
 
var->xres = var->xres_virtual = width;
var->yres = var->yres_virtual = height;
@@ -648,7 +644,7 @@ static void __init offb_init_nodriver(struct device_node 
*dp, int no_real_node)
/* kludge for valkyrie */
if (strcmp(dp->name, "valkyrie") == 0)
address += 0x1000;
-   offb_init_fb(no_real_node ? "bootx" : NULL,
+   offb_init_fb(no_real_node ? "bootx" : dp->name,
 width, height, depth, pitch, address,
 foreign_endian, no_real_node ? NULL : dp);
}


Re: G5 Quad hangs early on 4.20.2 / 5.0-rc2+

2019-01-17 Thread Benjamin Herrenschmidt
On Thu, 2019-01-17 at 10:42 +0100, Tobias Ulmer wrote:
> On Wed, Jan 16, 2019 at 12:15:14PM +1100, Benjamin Herrenschmidt wrote:
> > On Tue, 2019-01-15 at 23:49 +0100, Tobias Ulmer wrote:
> > > Hi,
> > > 
> > > both the latest stable 4.20.2 and 5.0 rc2+ hang early on the G5 Quad.
> > > 
> > > Surely I'm not the first to run into this, but I couldn't find any
> > > discussion or bug report. Sorry if you're already aware.
> > > 
> > > You can see it hang here (5.0 rc2+, 4.20.2 is nearly identical) until
> > > the watchdog triggers a reboot:
> > > 
> > > https://i.imgur.com/UiCVRuG.jpg
> > > 
> > > If I had to make an uneducated guess, it seems to boot into the same
> > > codepath twice (mpic was already initialized, then it starts again right
> > > after smp bringup). Maybe on a second CPU?
> > > 
> > > To narrow it down a little, my last known good was 4.18.9
> > 
> > I don't think it's an MPIC related problem but it does appear to hang
> > about when interrupts get turned on.
> 
> When they get turned on for the second time, for some reason. You can see the
> end of the first time just on top of the screen.

No, that top of screen init is something else.

> It repeats part of the startup initialization right after it's done with
> smp bringup.

That's just the BootX console hanging over to the main console and
replaying the messages I think.

> > I have one of these critters in the office, but I'm working remotely
> > this week so I won't be able to dig into this until next week.
> > 
> > It might help if you could bisect in the meantime.
> 
> I'm bisecting it now, but it's slow going since I don't have much time
> to babysit the machine. The problem shows up somewhere between v4.19 and
> v4.20.

Ok, thanks.

I'll be back on monday or tuesday, let me know where you got up to then
and I'll take it from there. Also email me your .config please.

Cheers,
Ben.

> > Cheers,
> > Ben.
> > 
> > 



Re: [PATCH v3 0/4] Add NXP AUDMIX device and machine drivers

2019-01-17 Thread Nicolin Chen
On Thu, Jan 17, 2019 at 02:22:18PM -0800, Nicolin Chen wrote:
> On Thu, Jan 17, 2019 at 12:46:25PM +, Viorel Suman wrote:
> > The patchset adds NXP Audio Mixer (AUDMIX) device and machine
> > drivers and related DT bindings documentation.
> > 
> > Changes since V2:
> > 1. Moved "dais" node from machine driver DTS node to device driver DTS node
> >   as suggested by Rob.
> 
> Yea, it makes a lot of sense. Otherwise, since the connection
> between IP blocks is fixed inside the SoC, the virtual sound
> node would need to be put in the soc-level dtsi, which sounds
> odd to me.
> 
> > Changes since V1:
> > 1. Original patch split into distinct patches for the device driver and
> >   DT binding documentation.
> > 2. Replaced AMIX with AUDMIX in both code and file names as it looks more
> >   RM-compliant.
> > 3. Removed polarity control from CPU DAI driver as suggested by Nicolin.
> > 4. Added machine driver and related DT binding documentation.
> > 
> > Viorel Suman (4):
> >   ASoC: fsl: Add Audio Mixer CPU DAI driver
> >   ASoC: add fsl_audmix DT binding documentation
> >   ASoC: fsl: Add Audio Mixer machine driver
> >   ASoC: add imx-audmix DT binding documentation
> 
> Reviewed-by: Nicolin Chen 

Oops. Just saw Rob's new reply. The drivers look good to me though.


Re: [PATCH v3 0/4] Add NXP AUDMIX device and machine drivers

2019-01-17 Thread Nicolin Chen
On Thu, Jan 17, 2019 at 12:46:25PM +, Viorel Suman wrote:
> The patchset adds NXP Audio Mixer (AUDMIX) device and machine
> drivers and related DT bindings documentation.
> 
> Changes since V2:
> 1. Moved "dais" node from machine driver DTS node to device driver DTS node
>   as suggested by Rob.

Yea, it makes a lot of sense. Otherwise, since the connection
between IP blocks is fixed inside the SoC, the virtual sound
node would need to be put in the soc-level dtsi, which sounds
odd to me.

> Changes since V1:
> 1. Original patch split into distinct patches for the device driver and
>   DT binding documentation.
> 2. Replaced AMIX with AUDMIX in both code and file names as it looks more
>   RM-compliant.
> 3. Removed polarity control from CPU DAI driver as suggested by Nicolin.
> 4. Added machine driver and related DT binding documentation.
> 
> Viorel Suman (4):
>   ASoC: fsl: Add Audio Mixer CPU DAI driver
>   ASoC: add fsl_audmix DT binding documentation
>   ASoC: fsl: Add Audio Mixer machine driver
>   ASoC: add imx-audmix DT binding documentation

Reviewed-by: Nicolin Chen 


Re: [PATCH] hugetlb: allow to free gigantic pages regardless of the configuration

2019-01-17 Thread Mike Kravetz
On 1/17/19 10:39 AM, Alexandre Ghiti wrote:
> From: Alexandre Ghiti 
> 
> On systems without CMA or (MEMORY_ISOLATION && COMPACTION) activated but
> that support gigantic pages, boottime reserved gigantic pages can not be
> freed at all. This patchs simply enables the possibility to hand back
> those pages to memory allocator.
> 
> This commit then renames gigantic_page_supported and
> ARCH_HAS_GIGANTIC_PAGE to make them more accurate. Indeed, those values
> being false does not mean that the system cannot use gigantic pages: it
> just means that runtime allocation of gigantic pages is not supported,
> one can still allocate boottime gigantic pages if the architecture supports
> it.
> 
> Signed-off-by: Alexandre Ghiti 

Thank you for doing this!

Reviewed-by: Mike Kravetz 

> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -589,8 +589,8 @@ static inline bool pm_suspended_storage(void)
>  /* The below functions must be run on a range from a single zone. */
>  extern int alloc_contig_range(unsigned long start, unsigned long end,
> unsigned migratetype, gfp_t gfp_mask);
> -extern void free_contig_range(unsigned long pfn, unsigned nr_pages);
>  #endif
> +extern void free_contig_range(unsigned long pfn, unsigned int nr_pages);

I think nr_pages should be an unsigned long in cma_release() and here
as well, but that is beyond the scope of this patch.  Most callers of
cma_release pass in a truncated unsigned long.  The truncation is unlikely
to cause any issues, just would be nice if types were consistent.  I have
a patch to do that as part of a contiguous allocation series that I will
get back to someday.

> @@ -2350,9 +2355,10 @@ static unsigned long set_max_huge_pages(struct hstate 
> *h, unsigned long count,
>   break;
>   }
>  out:
> - ret = persistent_huge_pages(h);
> + h->max_huge_pages = persistent_huge_pages(h);
>   spin_unlock(&hugetlb_lock);
> - return ret;
> +
> + return 0;
>  }
>  
>  #define HSTATE_ATTR_RO(_name) \
> @@ -2404,11 +2410,6 @@ static ssize_t __nr_hugepages_store_common(bool 
> obey_mempolicy,
>   int err;
>   NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY);
>  
> - if (hstate_is_gigantic(h) && !gigantic_page_supported()) {
> - err = -EINVAL;
> - goto out;
> - }
> -
>   if (nid == NUMA_NO_NODE) {
>   /*
>* global hstate attribute
> @@ -2428,7 +2429,9 @@ static ssize_t __nr_hugepages_store_common(bool 
> obey_mempolicy,
>   } else
>   nodes_allowed = &node_states[N_MEMORY];
>  
> - h->max_huge_pages = set_max_huge_pages(h, count, nodes_allowed);
> + err = set_max_huge_pages(h, count, nodes_allowed);
> + if (err)
> + goto out;
>  
>   if (nodes_allowed != &node_states[N_MEMORY])
>   NODEMASK_FREE(nodes_allowed);

Yeah!  Those changes causes max_huge_pages to be modified while holding
hugetlb_lock as it should be.
-- 
Mike Kravetz


Re: [PATCH] powerpc/cell: Remove duplicate header

2019-01-17 Thread Souptick Joarder
On Thu, Jan 17, 2019 at 9:49 PM Sabyasachi Gupta
 wrote:
>
> Remove linux/syscalls.h which is included more than once
>
> Signed-off-by: Sabyasachi Gupta 

Acked-by: Souptick Joarder 

> ---
>  arch/powerpc/platforms/cell/spu_syscalls.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c 
> b/arch/powerpc/platforms/cell/spu_syscalls.c
> index 263413a..b95d6af 100644
> --- a/arch/powerpc/platforms/cell/spu_syscalls.c
> +++ b/arch/powerpc/platforms/cell/spu_syscalls.c
> @@ -26,7 +26,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>
>  #include 
>
> --
> 2.7.4
>


Re: [PATCH 3/3] videobuf2: replace a layering violation with dma_map_resource

2019-01-17 Thread Christoph Hellwig
On Mon, Jan 14, 2019 at 01:42:26PM +0100, Marek Szyprowski wrote:
> Hi Christoph,
> 
> On 2019-01-11 19:17, Christoph Hellwig wrote:
> > vb2_dc_get_userptr pokes into arm direct mapping details to get the
> > resemblance of a dma address for a a physical address that does is
> > not backed by a page struct.  Not only is this not portable to other
> > architectures with dma direct mapping offsets, but also not to uses
> > of IOMMUs of any kind.  Switch to the proper dma_map_resource /
> > dma_unmap_resource interface instead.
> >
> > Signed-off-by: Christoph Hellwig 
> 
> There are checks for IOMMU presence in other places in vb2-dma-contig,
> so it was used only when no IOMMU is available, but I agree that the
> hacky code should be replaced by a generic code if possible.
> 
> Tested-by: Marek Szyprowski 
> 
> V4L2 pipeline works fine on older Exynos-based boards with CMA and IOMMU
> disabled.

Do you know if these rely on the offsets?  E.g. would they still work
with the patch below applied on top.  That would keep the map_resource
semantics as-is as solve the issue pointed out by Robin for now.

If not I can only think of a flag to bypass the offseting for now, but
that would be pretty ugly.  Or go for the long-term solution of
discovering the relationship between the two devices, as done by the
PCIe P2P code..

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 8e0359b04957..25bd19974223 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -359,7 +359,7 @@ EXPORT_SYMBOL(dma_direct_map_sg);
 dma_addr_t dma_direct_map_resource(struct device *dev, phys_addr_t paddr,
size_t size, enum dma_data_direction dir, unsigned long attrs)
 {
-   dma_addr_t dma_addr = phys_to_dma(dev, paddr);
+   dma_addr_t dma_addr = paddr;
 
if (unlikely(!dma_direct_possible(dev, dma_addr, size))) {
report_addr(dev, dma_addr, size);



[PATCH] Selftests/powerpc: Add a signal fuzzer selftest

2019-01-17 Thread Breno Leitao
This is a new selftest that raises SIGUSR1 signals and handles it in a set
of different ways, trying to create different scenario for testing
purpose.

This test works raising a signal and calling sigreturn interleaved with
TM operations, as starting, suspending and terminating a transaction. The
test depends on random numbers, and, based on them, it sets different TM
states.

Other than that, the test fills out the user context struct that is passed
to the sigreturn system call with random data, in order to make sure that
the signal handler syscall can handle different and invalid states
properly.

This selftest has command line parameters to control what kind of tests the
user wants to run, as for example, if a transaction should be started prior
to signal being raised, or, after the signal being raised and before the
sigreturn. If no parameter is given, the default is enabling all options.

This test does not check if the user context is being read and set
properly by the kernel. Its purpose, at this time, is basically
guaranteeing that the kernel does not crash on invalid scenarios.

Signed-off-by: Breno Leitao 
---
 tools/testing/selftests/powerpc/harness.c |   6 +-
 tools/testing/selftests/powerpc/include/reg.h |   2 +
 .../testing/selftests/powerpc/signal/Makefile |   3 +-
 .../testing/selftests/powerpc/signal/sigfuz.c | 325 ++
 4 files changed, 333 insertions(+), 3 deletions(-)
 create mode 100644 tools/testing/selftests/powerpc/signal/sigfuz.c

diff --git a/tools/testing/selftests/powerpc/harness.c 
b/tools/testing/selftests/powerpc/harness.c
index 9d7166dfad1e..ba89353abfcc 100644
--- a/tools/testing/selftests/powerpc/harness.c
+++ b/tools/testing/selftests/powerpc/harness.c
@@ -21,6 +21,7 @@
 
 #define KILL_TIMEOUT   5
 
+/* Setting timeout to -1 disables the alarm */
 static uint64_t timeout = 120;
 
 int run_test(int (test_function)(void), char *name)
@@ -43,8 +44,9 @@ int run_test(int (test_function)(void), char *name)
 
setpgid(pid, pid);
 
-   /* Wake us up in timeout seconds */
-   alarm(timeout);
+   if (timeout != -1)
+   /* Wake us up in timeout seconds */
+   alarm(timeout);
terminated = false;
 
 wait:
diff --git a/tools/testing/selftests/powerpc/include/reg.h 
b/tools/testing/selftests/powerpc/include/reg.h
index a69ab6e2afd9..d577a7ecf3e5 100644
--- a/tools/testing/selftests/powerpc/include/reg.h
+++ b/tools/testing/selftests/powerpc/include/reg.h
@@ -79,11 +79,13 @@
 
 /* MSR register bits */
 #define MSR_TS_S_LG 33  /* Trans Mem state: Suspended */
+#define MSR_TS_T_LG 34  /* Trans Mem state: Active */
 
 #define __MASK(X)   (1UL<<(X))
 
 /* macros to check TM MSR bits */
 #define MSR_TS_S__MASK(MSR_TS_S_LG)   /* Transaction Suspended */
+#define MSR_TS_T__MASK(MSR_TS_T_LG)   /* Transaction Transactional */
 
 /* Vector Instructions */
 #define VSX_XX1(xs, ra, rb)(((xs) & 0x1f) << 21 | ((ra) << 16) |  \
diff --git a/tools/testing/selftests/powerpc/signal/Makefile 
b/tools/testing/selftests/powerpc/signal/Makefile
index 209a958dca12..113838fbbe7f 100644
--- a/tools/testing/selftests/powerpc/signal/Makefile
+++ b/tools/testing/selftests/powerpc/signal/Makefile
@@ -1,8 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
-TEST_GEN_PROGS := signal signal_tm
+TEST_GEN_PROGS := signal signal_tm sigfuz
 
 CFLAGS += -maltivec
 $(OUTPUT)/signal_tm: CFLAGS += -mhtm
+$(OUTPUT)/sigfuz: CFLAGS += -pthread -m64
 
 top_srcdir = ../../../../..
 include ../../lib.mk
diff --git a/tools/testing/selftests/powerpc/signal/sigfuz.c 
b/tools/testing/selftests/powerpc/signal/sigfuz.c
new file mode 100644
index ..d0b9468b2f37
--- /dev/null
+++ b/tools/testing/selftests/powerpc/signal/sigfuz.c
@@ -0,0 +1,325 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2018, Breno Leitao, IBM Corp.
+ * Licensed under GPLv2.
+ *
+ * Sigfuz(tm): A PowerPC TM-aware signal fuzzer.
+ *
+ * This is a new selftest that raises SIGUSR1 signals and handles it in a set
+ * of different ways, trying to create different scenario for testing
+ * purpose.
+ *
+ * This test works raising a signal and calling sigreturn interleaved with
+ * TM operations, as starting, suspending and terminating a transaction. The
+ * test depends on random numbers, and, based on them, it sets different TM
+ * states.
+ *
+ * Other than that, the test fills out the user context struct that is passed
+ * to the sigreturn system call with random data, in order to make sure that
+ * the signal handler syscall can handle different and invalid states
+ * properly.
+ *
+ * This selftest has command line parameters to control what kind of tests the
+ * user wants to run, as for example, if a transaction should be started prior
+ * to signal being raised, or, after the signal being raised and before the
+ * sigreturn. If no parameter is given, the default is enabling all options.
+ *
+ * This test does not check if the user c

Re: [PATCH 2/4] powerpc/64s: Add slb_full_bitmap rather than hard-coding U32_MAX

2019-01-17 Thread Segher Boessenkool
On Thu, Jan 17, 2019 at 11:13:26PM +1100, Michael Ellerman wrote:
> The recent rewrite of the SLB code into C included the assumption that
> all CPUs we run on have at least 32 SLB entries. This is currently
> true but a bit fragile as the SLB size is actually defined by the
> device tree and so could theoretically change at any time.

It also is guaranteed by the architecture, since at least 2.02, FWIW.


Segher


[PATCH] powerpc/cell: Remove duplicate header

2019-01-17 Thread Sabyasachi Gupta
Remove linux/syscalls.h which is included more than once

Signed-off-by: Sabyasachi Gupta 
---
 arch/powerpc/platforms/cell/spu_syscalls.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c 
b/arch/powerpc/platforms/cell/spu_syscalls.c
index 263413a..b95d6af 100644
--- a/arch/powerpc/platforms/cell/spu_syscalls.c
+++ b/arch/powerpc/platforms/cell/spu_syscalls.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
-- 
2.7.4



Re: [PATCH v3 0/4] Add NXP AUDMIX device and machine drivers

2019-01-17 Thread Rob Herring
On Thu, Jan 17, 2019 at 12:46:25PM +, Viorel Suman wrote:
> The patchset adds NXP Audio Mixer (AUDMIX) device and machine
> drivers and related DT bindings documentation.
> 
> Changes since V2:
> 1. Moved "dais" node from machine driver DTS node to device driver DTS node
>   as suggested by Rob.

That was not what I suggested. You still have a virtual node which looks 
to me to be unnecessary.

> 
> Changes since V1:
> 1. Original patch split into distinct patches for the device driver and
>   DT binding documentation.
> 2. Replaced AMIX with AUDMIX in both code and file names as it looks more
>   RM-compliant.
> 3. Removed polarity control from CPU DAI driver as suggested by Nicolin.
> 4. Added machine driver and related DT binding documentation.
> 
> Viorel Suman (4):
>   ASoC: fsl: Add Audio Mixer CPU DAI driver
>   ASoC: add fsl_audmix DT binding documentation
>   ASoC: fsl: Add Audio Mixer machine driver
>   ASoC: add imx-audmix DT binding documentation
> 
>  .../devicetree/bindings/sound/fsl,audmix.txt   |  50 ++
>  .../devicetree/bindings/sound/imx-audmix.txt   |  18 +
>  sound/soc/fsl/Kconfig  |  16 +
>  sound/soc/fsl/Makefile |   5 +
>  sound/soc/fsl/fsl_audmix.c | 551 
> +
>  sound/soc/fsl/fsl_audmix.h | 102 
>  sound/soc/fsl/imx-audmix.c | 334 +
>  7 files changed, 1076 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/fsl,audmix.txt
>  create mode 100644 Documentation/devicetree/bindings/sound/imx-audmix.txt
>  create mode 100644 sound/soc/fsl/fsl_audmix.c
>  create mode 100644 sound/soc/fsl/fsl_audmix.h
>  create mode 100644 sound/soc/fsl/imx-audmix.c
> 
> -- 
> 2.7.4
> 


[PATCH] powerpc/powernv: Remove duplicate header

2019-01-17 Thread Sabyasachi Gupta
Remove linux/printk.h which is included more than once.

Signed-off-by: Sabyasachi Gupta 
---
 arch/powerpc/platforms/powernv/opal.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/opal.c 
b/arch/powerpc/platforms/powernv/opal.c
index beed86f..802de0d 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.7.4



Re: [RESENDING PATCH] powerpc/wii: properly disable use of BATs when requested.

2019-01-17 Thread Jonathan Neuschäfer
On Thu, Jan 17, 2019 at 11:29:06AM +0100, Christophe Leroy wrote:
[...]
> > >   /* MEM2 64MB@0x1000 */
> > >   delta = wii_hole_start + wii_hole_size;
> > > + if (__map_without_bats)
> > > + return delta;
> > > +
> > 
> > Nothing is visibly broken without this patch, even with
> > CONFIG_DEBUG_PAGEALLOC (tested on top of v5.0-rc2), but the patch still
> > looks correct.
> 
> Obviously, CONFIG_DEBUG_PAGEALLOC cannot work without this patch.
> The purpose of CONFIG_DEBUG_PAGEALLOC is to unmap unused parts of memory so
> that any access to them will pagefault.
> 
> As this function inconditionnaly sets a BAT for the second block of RAM, any
> access to free area in the upper block will be granted without a fault.
> 
> I think you can test it by doing a kmalloc() then a kfree(), then try to
> read in that area (hopefully kmalloc() allocates memory from the top so it
> should go in the upper block). Maybe there is an LKDTM test for that.

Ah, makes sense, thanks for the explanation.

> 
> > 
> > I'd prefer the 'if' block to be before the whole delta/size calculation,
> > to make the code slightly more readable because the delta and size
> > calculations stay in one visual block. It doesn't need to happen after
> > delta is calculated.
> 
> Euh ... the function has to return 'delta', so if I put the if block before
> the calculation of delta, it means we have to calculate delta twice:

Oh, sorry, I misread the code, but you're completely right (I shouldn't
answer mails while tired).

> 
>   if (__map_without_bats)
>   return wii_hole_start + wii_hole_size;
> 
>   delta = wii_hole_start + wii_hole_size;
> 
> My eyes don't really like it, so if we want to keep delta and size
> calculation together, the 'if' will go after calculation of size.

I agree.

> In anycase, this change is only really for fixing stable releases because
> this function will go away with my other serie.

ACK


Thanks,
Jonathan


signature.asc
Description: PGP signature


Re: ppc64le reliable stack unwinder and scheduled tasks

2019-01-17 Thread Segher Boessenkool
On Sun, Jan 13, 2019 at 11:33:56PM +1100, Balbir Singh wrote:
> On Sat, Jan 12, 2019 at 02:45:41AM -0600, Segher Boessenkool wrote:
> > On Sat, Jan 12, 2019 at 12:09:14PM +1100, Balbir Singh wrote:
> > > Could you please define interesting frame on top a bit more? Usually
> > > the topmost return address is in LR
> > 
> > There is no reliable way (other than DWARF unwind info) to find out where
> > the value of LR at function entry currently lives (if anywhere). It may or
> > may not be still available in LR, it may or may not be saved to the return
> > stack slot.  It can also live in some GPR, or in some other stack slot.
> > 
> > (The same is true for all other registers).
> > 
> > The only thing the ABI guarantees you is that you can find all stack frames
> > via the back chain.  If you want more you can use some heuristics and do
> > some heroics (like GDB does), but this is not fully reliable.  Using DWARF
> > unwind info is, but that requires big tables.
> >
> 
> Thanks, so are you suggesting that a reliable stack is not possible on
> ppc64le? Even with the restricted scope of the kernel?

It depends on what you mean with "reliable stack unwinder".  You can unwind
the stack reliably on Power, but you want more, you want to know where some
state local to functions is kept on the stack.


Segher


Re: [PATCH] kbuild: mark prepare0 as PHONY to fix external module build

2019-01-17 Thread Michael Ellerman
Masahiro Yamada  writes:
> On Tue, Jan 15, 2019 at 5:07 PM Masahiro Yamada
>  wrote:
>>
>> Commit c3ff2a5193fa ("powerpc/32: add stack protector support")
>> caused kernel panic on PowerPC if an external module is used with
>> CONFIG_STACKPROTECTOR because the 'prepare' target was not executed
>> for the external module build.
>>
>> Commit e07db28eea38 ("kbuild: fix single target build for external
>> module") turned it into a build error because the 'prepare' target is
>> now executed but the 'prepare0' target is missing for the external
>> module build.
>>
>> External module on arm/arm64 with CONFIG_STACKPROTECTOR_PER_TASK is
>> also broken in the same way.
>>
>> Move 'PHONY += prepare0' to the common place. Make is fine with missing
>> rule for phony targets.
>>
>> I minimize the change so it can be easily backported to 4.20.x
>>
>> To fix v4.20 for external modules of PowerPC, please backport
>> e07db28eea38 ("kbuild: fix single target build for external module"),
>> and then this commit.
>>
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=201891
>> Fixes: e07db28eea38 ("kbuild: fix single target build for external module")
>> Fixes: c3ff2a5193fa ("powerpc/32: add stack protector support")
>> Fixes: 189af4657186 ("ARM: smp: add support for per-task stack canaries")
>> Fixes: 0a1213fa7432 ("arm64: enable per-task stack canaries")
>> Cc: linux-stable  # v4.20
>> Reported-by: Samuel Holland 
>> Reported-by: Alexey Kardashevskiy 
>> Signed-off-by: Masahiro Yamada 
>> ---
>
> Applied to linux-kbuild/fixes.

Thanks.

cheers


Re: G5 Quad hangs early on 4.20.2 / 5.0-rc2+

2019-01-17 Thread Michael Ellerman
Tobias Ulmer  writes:
> On Wed, Jan 16, 2019 at 12:15:14PM +1100, Benjamin Herrenschmidt wrote:
>> On Tue, 2019-01-15 at 23:49 +0100, Tobias Ulmer wrote:
>> > Hi,
>> > 
>> > both the latest stable 4.20.2 and 5.0 rc2+ hang early on the G5 Quad.
>> > 
>> > Surely I'm not the first to run into this, but I couldn't find any
>> > discussion or bug report. Sorry if you're already aware.
>> > 
>> > You can see it hang here (5.0 rc2+, 4.20.2 is nearly identical) until
>> > the watchdog triggers a reboot:
>> > 
>> > https://i.imgur.com/UiCVRuG.jpg
>> > 
>> > If I had to make an uneducated guess, it seems to boot into the same
>> > codepath twice (mpic was already initialized, then it starts again right
>> > after smp bringup). Maybe on a second CPU?
>> > 
>> > To narrow it down a little, my last known good was 4.18.9
>> 
>> I don't think it's an MPIC related problem but it does appear to hang
>> about when interrupts get turned on.
>
> When they get turned on for the second time, for some reason. You can see the
> end of the first time just on top of the screen.
>
> It repeats part of the startup initialization right after it's done with
> smp bringup.
>
>> 
>> I have one of these critters in the office, but I'm working remotely
>> this week so I won't be able to dig into this until next week.
>> 
>> It might help if you could bisect in the meantime.
>
> I'm bisecting it now, but it's slow going since I don't have much time
> to babysit the machine. The problem shows up somewhere between v4.19 and
> v4.20.

Can you try:

58cfbac25b1f ("Revert "selftests/powerpc: Fix out-of-tree build errors"")

If that's bad and v4.19 is good that would isolate it to about 222
commits.

cheers


[PATCH v2 7/7] powerpc/pseries: Add firmware details to dump stack arch description

2019-01-17 Thread Michael Ellerman
Once we have unflattened the device tree we can easily grab these
firmware version details and add them to dump stack arch description,
which is printed in case of an oops.

Currently /hypervisor only exists on KVM, so if we don't find that look
for something that suggests we're on phyp and if so that's probably a
good guess. The actual content of the ibm,fw-net-version seems to be
a full path so is too long to add to the description.

Hardware name: ... of:'IBM,FW860.42 (SV860_138)' hv:phyp

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/platforms/pseries/setup.c | 35 ++
 1 file changed, 35 insertions(+)

v2: Use 'of' rather than 'prom' for the open firmware value.

diff --git a/arch/powerpc/platforms/pseries/setup.c 
b/arch/powerpc/platforms/pseries/setup.c
index 41f62ca27c63..dfb084f5a573 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -923,6 +923,39 @@ static void pSeries_cmo_feature_init(void)
pr_debug(" <- fw_cmo_feature_init()\n");
 }
 
+static void __init pseries_add_dump_stack_arch_desc(void)
+{
+   struct device_node *dn;
+   const char *prop;
+
+   dn = of_find_node_by_path("/openprom");
+   if (dn) {
+   prop = of_get_property(dn, "model", NULL);
+   if (prop)
+   dump_stack_add_arch_desc("of:'%s'", prop);
+
+   of_node_put(dn);
+   }
+
+   dn = of_find_node_by_path("/hypervisor");
+   if (dn) {
+   prop = of_get_property(dn, "compatible", NULL);
+   if (prop)
+   dump_stack_add_arch_desc("hv:%s", prop);
+
+   of_node_put(dn);
+   } else {
+   dn = of_find_node_by_path("/");
+   if (dn) {
+   prop = of_get_property(dn, "ibm,fw-net-version", NULL);
+   if (prop)
+   dump_stack_add_arch_desc("hv:phyp");
+
+   of_node_put(dn);
+   }
+   }
+}
+
 /*
  * Early initialization.  Relocation is on but do not reference unbolted pages
  */
@@ -930,6 +963,8 @@ static void __init pseries_init(void)
 {
pr_debug(" -> pseries_init()\n");
 
+   pseries_add_dump_stack_arch_desc();
+
 #ifdef CONFIG_HVC_CONSOLE
if (firmware_has_feature(FW_FEATURE_LPAR))
hvc_vio_init_early();
-- 
2.20.1



[PATCH v2 6/7] powerpc/powernv: Add opal details to dump stack arch description

2019-01-17 Thread Michael Ellerman
Once we have unflattened the device tree we can easily grab these opal
version details and add them to dump stack arch description, which is
printed in case of an oops.

eg: Hardware name: ... opal:v6.2

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/platforms/powernv/setup.c | 25 +
 1 file changed, 25 insertions(+)

v2: Qualify the string with 'opal' and 'mi'. Only use git-id if version
is missing.

diff --git a/arch/powerpc/platforms/powernv/setup.c 
b/arch/powerpc/platforms/powernv/setup.c
index 14befee4b3f1..1bfb422436fb 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -156,8 +156,33 @@ static void __init pnv_setup_arch(void)
/* XXX PMCS */
 }
 
+static void __init pnv_add_dump_stack_arch_desc(void)
+{
+   struct device_node *dn;
+   const char *version;
+
+   dn = of_find_node_by_path("/ibm,opal/firmware");
+   if (!dn)
+   return;
+
+   version = of_get_property(dn, "version", NULL);
+   if (!version)
+   version = of_get_property(dn, "git-id", NULL);
+
+   if (version)
+   dump_stack_add_arch_desc("opal:%s", version);
+
+   version = of_get_property(dn, "mi-version", NULL);
+   if (version)
+   dump_stack_add_arch_desc("mi:%s", version);
+
+   of_node_put(dn);
+}
+
 static void __init pnv_init(void)
 {
+   pnv_add_dump_stack_arch_desc();
+
/*
 * Initialize the LPC bus now so that legacy serial
 * ports can be found on it
-- 
2.20.1



[PATCH v2 5/7] powerpc: Add ppc_md.name to dump stack arch description

2019-01-17 Thread Michael Ellerman
As soon as we know the name of the machine description we're using, add
it to the dump stack arch description, which is printed in case of an
oops.

eg: Hardware name: ... machine:pSeries

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/setup-common.c | 3 +++
 1 file changed, 3 insertions(+)

v2: Qualify the string with 'machine'.

diff --git a/arch/powerpc/kernel/setup-common.c 
b/arch/powerpc/kernel/setup-common.c
index ca00fbb97cf8..00d900b1e584 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -638,6 +639,8 @@ void probe_machine(void)
for (;;);
}
 
+   dump_stack_add_arch_desc("machine:%s", ppc_md.name);
+
printk(KERN_INFO "Using %s machine description\n", ppc_md.name);
 }
 
-- 
2.20.1



[PATCH v2 4/7] powerpc: Add device-tree model to dump stack arch description

2019-01-17 Thread Michael Ellerman
As soon as we know the model of the machine we're on, add it to the
dump stack arch description, which is printed in case of an oops.

eg: Hardware name: model:'IBM,8247-22L'

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/prom.c | 20 
 1 file changed, 20 insertions(+)

v2: Qualify the string with 'model'.

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 38a90097469a..70af26a1eedd 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -687,6 +688,23 @@ static void __init tm_init(void)
 static void tm_init(void) { }
 #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
 
+static int __init
+early_init_dt_scan_model(unsigned long node, const char *uname,
+int depth, void *data)
+{
+   const char *prop;
+
+   if (depth != 0)
+   return 0;
+
+   prop = of_get_flat_dt_prop(node, "model", NULL);
+   if (prop)
+   dump_stack_add_arch_desc("model:'%s'", prop);
+
+   /* break now */
+   return 1;
+}
+
 void __init early_init_devtree(void *params)
 {
phys_addr_t limit;
@@ -697,6 +715,8 @@ void __init early_init_devtree(void *params)
if (!early_init_dt_verify(params))
panic("BUG: Failed verifying flat device tree, bad version?");
 
+   of_scan_flat_dt(early_init_dt_scan_model, NULL);
+
 #ifdef CONFIG_PPC_RTAS
/* Some machines might need RTAS info for debugging, grab it now. */
of_scan_flat_dt(early_init_dt_scan_rtas, NULL);
-- 
2.20.1



[PATCH v2 3/7] powerpc/64: Add logical PVR to the dump stack arch description

2019-01-17 Thread Michael Ellerman
If we detect a logical PVR add that to the dump stack arch
description, which is printed in case of an oops.

eg: Hardware name: ... lpvr:0xf04

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/prom.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

v2: new.

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index ea2c3498067d..38a90097469a 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -371,8 +371,10 @@ static int __init early_init_dt_scan_cpus(unsigned long 
node,
 */
if (!dt_cpu_ftrs_in_use()) {
prop = of_get_flat_dt_prop(node, "cpu-version", NULL);
-   if (prop && (be32_to_cpup(prop) & 0xff00) == 0x0f00)
+   if (prop && (be32_to_cpup(prop) & 0xff00) == 0x0f00) {
identify_cpu(0, be32_to_cpup(prop));
+   dump_stack_add_arch_desc("lpvr:0x%04x", 
be32_to_cpup(prop));
+   }
 
check_cpu_feature_properties(node);
check_cpu_pa_features(node);
-- 
2.20.1



[PATCH v2 2/7] powerpc: Add PVR & CPU name to dump stack arch description

2019-01-17 Thread Michael Ellerman
As soon as we've done some basic setup, add the PVR and CPU name to
the dump stack arch description, which is printed in case of an oops.

eg: Hardware name: ... POWER8E (raw) pvr:0x4b0201

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/cputable.c | 1 +
 arch/powerpc/kernel/prom.c | 4 
 2 files changed, 5 insertions(+)

v2: Show the PVR as well.

diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 1eab54bc6ee9..8b4520a84612 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 4181ec715f88..ea2c3498067d 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -761,6 +761,10 @@ void __init early_init_devtree(void *params)
 
dt_cpu_ftrs_scan();
 
+   /* We can now set the CPU name & PVR for the oops output */
+   dump_stack_add_arch_desc("%s pvr:0x%04lx", cur_cpu_spec->cpu_name,
+mfspr(SPRN_PVR));
+
/* Retrieve CPU related informations from the flat tree
 * (altivec support, boot CPU ID, ...)
 */
-- 
2.20.1



[PATCH v2 1/7] dump_stack: Support adding to the dump stack arch description

2019-01-17 Thread Michael Ellerman
Arch code can set a "dump stack arch description string" which is
displayed with oops output to describe the hardware platform.

It is useful to initialise this as early as possible, so that an early
oops will have the hardware description.

However in practice we discover the hardware platform in stages, so it
would be useful to be able to incrementally fill in the hardware
description as we discover it.

This patch adds that ability, by creating dump_stack_add_arch_desc().

If there is no existing string it behaves exactly like
dump_stack_set_arch_desc(). However if there is an existing string it
appends to it, with a leading space.

This makes it easy to call it multiple times from different parts of the
code and get a reasonable looking result.

Signed-off-by: Michael Ellerman 
---
 include/linux/printk.h |  5 
 lib/dump_stack.c   | 58 ++
 2 files changed, 63 insertions(+)

v2: Add a smp_wmb() and comment.

v1 is here for reference 
https://lore.kernel.org/lkml/1430824337-15339-1-git-send-email-...@ellerman.id.au/

I'll take this series via the powerpc tree if no one minds?

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 77740a506ebb..d5fb4f960271 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -198,6 +198,7 @@ u32 log_buf_len_get(void);
 void log_buf_vmcoreinfo_setup(void);
 void __init setup_log_buf(int early);
 __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...);
+__printf(1, 2) void dump_stack_add_arch_desc(const char *fmt, ...);
 void dump_stack_print_info(const char *log_lvl);
 void show_regs_print_info(const char *log_lvl);
 extern asmlinkage void dump_stack(void) __cold;
@@ -256,6 +257,10 @@ static inline __printf(1, 2) void 
dump_stack_set_arch_desc(const char *fmt, ...)
 {
 }
 
+static inline __printf(1, 2) void dump_stack_add_arch_desc(const char *fmt, 
...)
+{
+}
+
 static inline void dump_stack_print_info(const char *log_lvl)
 {
 }
diff --git a/lib/dump_stack.c b/lib/dump_stack.c
index 5cff72f18c4a..69b710ff92b5 100644
--- a/lib/dump_stack.c
+++ b/lib/dump_stack.c
@@ -35,6 +35,64 @@ void __init dump_stack_set_arch_desc(const char *fmt, ...)
va_end(args);
 }
 
+/**
+ * dump_stack_add_arch_desc - add arch-specific info to show with task dumps
+ * @fmt: printf-style format string
+ * @...: arguments for the format string
+ *
+ * See dump_stack_set_arch_desc() for why you'd want to use this.
+ *
+ * This version adds to any existing string already created with either
+ * dump_stack_set_arch_desc() or dump_stack_add_arch_desc(). If there is an
+ * existing string a space will be prepended to the passed string.
+ */
+void __init dump_stack_add_arch_desc(const char *fmt, ...)
+{
+   va_list args;
+   int pos, len;
+   char *p;
+
+   /*
+* If there's an existing string we snprintf() past the end of it, and
+* then turn the terminating NULL of the existing string into a space
+* to create one string separated by a space.
+*
+* If there's no existing string we just snprintf() to the buffer, like
+* dump_stack_set_arch_desc(), but without calling it because we'd need
+* a varargs version.
+*/
+   len = strnlen(dump_stack_arch_desc_str, 
sizeof(dump_stack_arch_desc_str));
+   pos = len;
+
+   if (len)
+   pos++;
+
+   if (pos >= sizeof(dump_stack_arch_desc_str))
+   return; /* Ran out of space */
+
+   p = &dump_stack_arch_desc_str[pos];
+
+   va_start(args, fmt);
+   vsnprintf(p, sizeof(dump_stack_arch_desc_str) - pos, fmt, args);
+   va_end(args);
+
+   if (len) {
+   /*
+* Order the stores above in vsnprintf() vs the store of the
+* space below which joins the two strings. Note this doesn't
+* make the code truly race free because there is no barrier on
+* the read side. ie. Another CPU might load the uninitialised
+* tail of the buffer first and then the space below (rather
+* than the NULL that was there previously), and so print the
+* uninitialised tail. But the whole string lives in BSS so in
+* practice it should just see NULLs.
+*/
+   smp_wmb();
+
+   dump_stack_arch_desc_str[len] = ' ';
+   }
+}
+
 /**
  * dump_stack_print_info - print generic debug info for dump_stack()
  * @log_lvl: log level
-- 
2.20.1



[PATCH v3 4/4] ASoC: add imx-audmix DT binding documentation

2019-01-17 Thread Viorel Suman
Add the DT binding documentation for Audio Mixer
machine driver.

Signed-off-by: Viorel Suman 
---
 Documentation/devicetree/bindings/sound/imx-audmix.txt | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/imx-audmix.txt

diff --git a/Documentation/devicetree/bindings/sound/imx-audmix.txt 
b/Documentation/devicetree/bindings/sound/imx-audmix.txt
new file mode 100644
index 000..c840ed5
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/imx-audmix.txt
@@ -0,0 +1,18 @@
+NXP Audio Mixer (AUDMIX) machine driver.
+
+Required properties:
+===
+  - compatible : Compatible list, contains "fsl,imx-audmix"
+
+  - model  : Short audio card description.
+
+  - audmix-controller  : Must contain the phandle to the AUDMIX device node.
+
+Machine driver configuration example:
+
+  sound-audmix-sai {
+compatible = "fsl,imx-audmix";
+model = "audmix-sai";
+audmix-controller = <&audmix>;
+  };
+
-- 
2.7.4



[PATCH v3 0/4] Add NXP AUDMIX device and machine drivers

2019-01-17 Thread Viorel Suman
The patchset adds NXP Audio Mixer (AUDMIX) device and machine
drivers and related DT bindings documentation.

Changes since V2:
1. Moved "dais" node from machine driver DTS node to device driver DTS node
  as suggested by Rob.

Changes since V1:
1. Original patch split into distinct patches for the device driver and
  DT binding documentation.
2. Replaced AMIX with AUDMIX in both code and file names as it looks more
  RM-compliant.
3. Removed polarity control from CPU DAI driver as suggested by Nicolin.
4. Added machine driver and related DT binding documentation.

Viorel Suman (4):
  ASoC: fsl: Add Audio Mixer CPU DAI driver
  ASoC: add fsl_audmix DT binding documentation
  ASoC: fsl: Add Audio Mixer machine driver
  ASoC: add imx-audmix DT binding documentation

 .../devicetree/bindings/sound/fsl,audmix.txt   |  50 ++
 .../devicetree/bindings/sound/imx-audmix.txt   |  18 +
 sound/soc/fsl/Kconfig  |  16 +
 sound/soc/fsl/Makefile |   5 +
 sound/soc/fsl/fsl_audmix.c | 551 +
 sound/soc/fsl/fsl_audmix.h | 102 
 sound/soc/fsl/imx-audmix.c | 334 +
 7 files changed, 1076 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/fsl,audmix.txt
 create mode 100644 Documentation/devicetree/bindings/sound/imx-audmix.txt
 create mode 100644 sound/soc/fsl/fsl_audmix.c
 create mode 100644 sound/soc/fsl/fsl_audmix.h
 create mode 100644 sound/soc/fsl/imx-audmix.c

-- 
2.7.4



[PATCH v3 3/4] ASoC: fsl: Add Audio Mixer machine driver

2019-01-17 Thread Viorel Suman
This patch implements Audio Mixer machine driver for NXP iMX8 SOCs.
It connects together Audio Mixer and related SAI instances.

Signed-off-by: Viorel Suman 
---
 sound/soc/fsl/Kconfig  |   9 ++
 sound/soc/fsl/Makefile |   2 +
 sound/soc/fsl/imx-audmix.c | 334 +
 3 files changed, 345 insertions(+)
 create mode 100644 sound/soc/fsl/imx-audmix.c

diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 0af2e056..d87c842 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -303,6 +303,15 @@ config SND_SOC_FSL_ASOC_CARD
 CS4271, CS4272 and SGTL5000.
 Say Y if you want to add support for Freescale Generic ASoC Sound Card.
 
+config SND_SOC_IMX_AUDMIX
+   tristate "SoC Audio support for i.MX boards with AUDMIX"
+   select SND_SOC_FSL_AUDMIX
+   select SND_SOC_FSL_SAI
+   help
+ SoC Audio support for i.MX boards with Audio Mixer
+ Say Y if you want to add support for SoC audio on an i.MX board with
+ an Audio Mixer.
+
 endif # SND_IMX_SOC
 
 endmenu
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index 4172d5a..c0dd044 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -62,6 +62,7 @@ snd-soc-imx-es8328-objs := imx-es8328.o
 snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o
 snd-soc-imx-spdif-objs := imx-spdif.o
 snd-soc-imx-mc13783-objs := imx-mc13783.o
+snd-soc-imx-audmix-objs := imx-audmix.o
 
 obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
 obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o
@@ -71,3 +72,4 @@ obj-$(CONFIG_SND_SOC_IMX_ES8328) += snd-soc-imx-es8328.o
 obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o
 obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o
 obj-$(CONFIG_SND_SOC_IMX_MC13783) += snd-soc-imx-mc13783.o
+obj-$(CONFIG_SND_SOC_IMX_AUDMIX) += snd-soc-imx-audmix.o
diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c
new file mode 100644
index 000..30396e4
--- /dev/null
+++ b/sound/soc/fsl/imx-audmix.c
@@ -0,0 +1,334 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2017 NXP
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "fsl_sai.h"
+#include "fsl_audmix.h"
+
+struct imx_audmix {
+   struct platform_device *pdev;
+   struct snd_soc_card card;
+   struct platform_device *audmix_pdev;
+   struct platform_device *out_pdev;
+   struct clk *cpu_mclk;
+   int num_dai;
+   struct snd_soc_dai_link *dai;
+   int num_dai_conf;
+   struct snd_soc_codec_conf *dai_conf;
+   int num_dapm_routes;
+   struct snd_soc_dapm_route *dapm_routes;
+};
+
+static const u32 imx_audmix_rates[] = {
+   8000, 12000, 16000, 24000, 32000, 48000, 64000, 96000,
+};
+
+static const struct snd_pcm_hw_constraint_list imx_audmix_rate_constraints = {
+   .count = ARRAY_SIZE(imx_audmix_rates),
+   .list = imx_audmix_rates,
+};
+
+static int imx_audmix_fe_startup(struct snd_pcm_substream *substream)
+{
+   struct snd_soc_pcm_runtime *rtd = substream->private_data;
+   struct imx_audmix *priv = snd_soc_card_get_drvdata(rtd->card);
+   struct snd_pcm_runtime *runtime = substream->runtime;
+   struct device *dev = rtd->card->dev;
+   unsigned long clk_rate = clk_get_rate(priv->cpu_mclk);
+   int ret;
+
+   if (clk_rate % 24576000 == 0) {
+   ret = snd_pcm_hw_constraint_list(runtime, 0,
+SNDRV_PCM_HW_PARAM_RATE,
+&imx_audmix_rate_constraints);
+   if (ret < 0)
+   return ret;
+   } else {
+   dev_warn(dev, "mclk may be not supported %lu\n", clk_rate);
+   }
+
+   ret = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS,
+  1, 8);
+   if (ret < 0)
+   return ret;
+
+   return snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT,
+   FSL_AUDMIX_FORMATS);
+}
+
+static int imx_audmix_fe_hw_params(struct snd_pcm_substream *substream,
+  struct snd_pcm_hw_params *params)
+{
+   struct snd_soc_pcm_runtime *rtd = substream->private_data;
+   struct device *dev = rtd->card->dev;
+   bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
+   unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
+   u32 channels = params_channels(params);
+   int ret, dir;
+
+   /* For playback the AUDMIX is slave, and for record is master */
+   fmt |= tx ? SND_SOC_DAIFMT_CBS_CF

[PATCH v3 2/4] ASoC: add fsl_audmix DT binding documentation

2019-01-17 Thread Viorel Suman
Add the DT binding documentation for NXP Audio Mixer
CPU DAI driver.

Signed-off-by: Viorel Suman 
---
 .../devicetree/bindings/sound/fsl,audmix.txt   | 50 ++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/fsl,audmix.txt

diff --git a/Documentation/devicetree/bindings/sound/fsl,audmix.txt 
b/Documentation/devicetree/bindings/sound/fsl,audmix.txt
new file mode 100644
index 000..840b7e0
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/fsl,audmix.txt
@@ -0,0 +1,50 @@
+NXP Audio Mixer (AUDMIX).
+
+The Audio Mixer is a on-chip functional module that allows mixing of two
+audio streams into a single audio stream. Audio Mixer has two input serial
+audio interfaces. These are driven by two Synchronous Audio interface
+modules (SAI). Each input serial interface carries 8 audio channels in its
+frame in TDM manner. Mixer mixes audio samples of corresponding channels
+from two interfaces into a single sample. Before mixing, audio samples of
+two inputs can be attenuated based on configuration. The output of the
+Audio Mixer is also a serial audio interface. Like input interfaces it has
+the same TDM frame format. This output is used to drive the serial DAC TDM
+interface of audio codec and also sent to the external pins along with the
+receive path of normal audio SAI module for readback by the CPU.
+
+The output of Audio Mixer can be selected from any of the three streams
+ - serial audio input 1
+ - serial audio input 2
+ - mixed audio
+
+Mixing operation is independent of audio sample rate but the two audio
+input streams must have same audio sample rate with same number of channels
+in TDM frame to be eligible for mixing.
+
+Device driver required properties:
+=
+  - compatible : Compatible list, contains "fsl,imx8qm-audmix"
+
+  - reg: Offset and length of the register set for the 
device.
+
+  - clocks : Must contain an entry for each entry in clock-names.
+
+  - clock-names: Must include the "ipg" for register access.
+
+  - power-domains  : Must contain the phandle to AUDMIX power domain node
+
+  - dais   : Must contain a list of phandles to AUDMIX connected
+ DAIs. The current implementation requires two phandles
+ to SAI interfaces to be provided, the first SAI in the
+ list being used to route the AUDMIX output.
+
+Device driver configuration example:
+==
+  audmix: audmix@5984 {
+compatible = "fsl,imx8qm-audmix";
+reg = <0x0 0x5984 0x0 0x1>;
+clocks = <&clk IMX8QXP_AUD_AUDMIX_IPG>;
+clock-names = "ipg";
+power-domains = <&pd_audmix>;
+dais = <&sai4>, <&sai5>;
+  };
-- 
2.7.4



[PATCH v3 1/4] ASoC: fsl: Add Audio Mixer CPU DAI driver

2019-01-17 Thread Viorel Suman
This patch implements Audio Mixer CPU DAI driver for NXP iMX8 SOCs.
The Audio Mixer is a on-chip functional module that allows mixing of
two audio streams into a single audio stream.

Audio Mixer datasheet is available here:
https://www.nxp.com/docs/en/reference-manual/IMX8DQXPRM.pdf

Signed-off-by: Viorel Suman 
---
 sound/soc/fsl/Kconfig  |   7 +
 sound/soc/fsl/Makefile |   3 +
 sound/soc/fsl/fsl_audmix.c | 551 +
 sound/soc/fsl/fsl_audmix.h | 102 +
 4 files changed, 663 insertions(+)
 create mode 100644 sound/soc/fsl/fsl_audmix.c
 create mode 100644 sound/soc/fsl/fsl_audmix.h

diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 7b1d997..0af2e056 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -24,6 +24,13 @@ config SND_SOC_FSL_SAI
  This option is only useful for out-of-tree drivers since
  in-tree drivers select it automatically.
 
+config SND_SOC_FSL_AUDMIX
+   tristate "Audio Mixer (AUDMIX) module support"
+   select REGMAP_MMIO
+   help
+ Say Y if you want to add Audio Mixer (AUDMIX)
+ support for the NXP iMX CPUs.
+
 config SND_SOC_FSL_SSI
tristate "Synchronous Serial Interface module (SSI) support"
select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index 3c0ff31..4172d5a 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -12,6 +12,7 @@ snd-soc-p1022-rdk-objs := p1022_rdk.o
 obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o
 
 # Freescale SSI/DMA/SAI/SPDIF Support
+snd-soc-fsl-audmix-objs := fsl_audmix.o
 snd-soc-fsl-asoc-card-objs := fsl-asoc-card.o
 snd-soc-fsl-asrc-objs := fsl_asrc.o fsl_asrc_dma.o
 snd-soc-fsl-sai-objs := fsl_sai.o
@@ -22,6 +23,8 @@ snd-soc-fsl-esai-objs := fsl_esai.o
 snd-soc-fsl-micfil-objs := fsl_micfil.o
 snd-soc-fsl-utils-objs := fsl_utils.o
 snd-soc-fsl-dma-objs := fsl_dma.o
+
+obj-$(CONFIG_SND_SOC_FSL_AUDMIX) += snd-soc-fsl-audmix.o
 obj-$(CONFIG_SND_SOC_FSL_ASOC_CARD) += snd-soc-fsl-asoc-card.o
 obj-$(CONFIG_SND_SOC_FSL_ASRC) += snd-soc-fsl-asrc.o
 obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o
diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c
new file mode 100644
index 000..f1267e5
--- /dev/null
+++ b/sound/soc/fsl/fsl_audmix.c
@@ -0,0 +1,551 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * NXP AUDMIX ALSA SoC Digital Audio Interface (DAI) driver
+ *
+ * Copyright 2017 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "fsl_audmix.h"
+
+#define SOC_ENUM_SINGLE_S(xreg, xshift, xtexts) \
+   SOC_ENUM_SINGLE(xreg, xshift, ARRAY_SIZE(xtexts), xtexts)
+
+static const char
+   *tdm_sel[] = { "TDM1", "TDM2", },
+   *mode_sel[] = { "Disabled", "TDM1", "TDM2", "Mixed", },
+   *width_sel[] = { "16b", "18b", "20b", "24b", "32b", },
+   *endis_sel[] = { "Disabled", "Enabled", },
+   *updn_sel[] = { "Downward", "Upward", },
+   *mask_sel[] = { "Unmask", "Mask", };
+
+static const struct soc_enum fsl_audmix_enum[] = {
+/* FSL_AUDMIX_CTR enums */
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_CTR, FSL_AUDMIX_CTR_MIXCLK_SHIFT, tdm_sel),
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_CTR, FSL_AUDMIX_CTR_OUTSRC_SHIFT, mode_sel),
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_CTR, FSL_AUDMIX_CTR_OUTWIDTH_SHIFT, width_sel),
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_CTR, FSL_AUDMIX_CTR_MASKRTDF_SHIFT, mask_sel),
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_CTR, FSL_AUDMIX_CTR_MASKCKDF_SHIFT, mask_sel),
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_CTR, FSL_AUDMIX_CTR_SYNCMODE_SHIFT, endis_sel),
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_CTR, FSL_AUDMIX_CTR_SYNCSRC_SHIFT, tdm_sel),
+/* FSL_AUDMIX_ATCR0 enums */
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_ATCR0, 0, endis_sel),
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_ATCR0, 1, updn_sel),
+/* FSL_AUDMIX_ATCR1 enums */
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_ATCR1, 0, endis_sel),
+SOC_ENUM_SINGLE_S(FSL_AUDMIX_ATCR1, 1, updn_sel),
+};
+
+struct fsl_audmix_state {
+   u8 tdms;
+   u8 clk;
+   char msg[64];
+};
+
+static const struct fsl_audmix_state prms[4][4] = {{
+   /* DIS->DIS, do nothing */
+   { .tdms = 0, .clk = 0, .msg = "" },
+   /* DIS->TDM1*/
+   { .tdms = 1, .clk = 1, .msg = "DIS->TDM1: TDM1 not started!\n" },
+   /* DIS->TDM2*/
+   { .tdms = 2, .clk = 2, .msg = "DIS->TDM2: TDM2 not started!\n" },
+   /* DIS->MIX */
+   { .tdms = 3, .clk = 0, .msg = "DIS->MIX: Please start both TDMs!\n" }
+}, {   /* TDM1->DIS */
+   { .tdms = 1, .clk = 0, .msg = "TDM1->DIS: TDM1 not started!\n" },
+   /* TDM1->TDM1, do nothing */
+   { .tdms = 0, .clk = 0, .msg = "" },
+   /* TDM1->TDM2 */
+   { .tdms = 3, .clk = 2, .msg = "TDM1->TDM2: Please start both TDMs!\n" },
+   /* TDM1->MIX */
+   { .tdms = 3, .clk = 0, .msg = "TDM1->MIX: Please start both TDMs!\n" }
+}, {   /* TDM2->DIS */
+   { .tdms = 2, .clk = 0, .msg = "TDM2->DIS: TDM2 not started!\n" },
+   /* TDM2->TDM1 */
+   { .tdms = 3, .clk

Re: [RFC PATCH v2 5/5] powerpc/syscalls: Allow none instead of sys_ni_syscall

2019-01-17 Thread Arnd Bergmann
On Thu, Jan 17, 2019 at 11:35 AM Michael Ellerman  wrote:
>
> Hi Arnd,
>
> Arnd Bergmann  writes:
> > On Wed, Jan 16, 2019 at 2:27 PM Michael Ellerman  
> > wrote:
> >>
> >> sys_ni_syscall is the "not-implemented" syscall syscall, which just
> >> returns -ENOSYS.
> >>
> >> But unless you know that it's not obvious what it does, and even if
> >> you do know what it means it doesn't stand out that well from other
> >> real syscalls.
> >>
> >> So teach the scripts to treat "none" as a synonym for
> >> "sys_ni_syscall". This makes the table more readable.
> >
> > Hmm, this actually breaks the proposed script to find bugs
> > in the compat handling, i.e. detecting those that have no
> > compat handler but only a native one.
>
> I don't understand how? It just makes none an alias for sys_ni_syscall,
> so surely the worse case is that script will need to do the reverse
> transformation?

I mean it's broken to have a common script when architectures do it
differently. It would be fine if you changed all architectures at the same
time though.

> > For break, i.e. a syscall number without any implementation,
> > we use a different syntax on x86 (leaving out the sys_* entirely),
> > and on s390 (using '-', which is visually better than 'none' IMHO).
>
> Except a blank compat syscall doesn't mean the syscall doesn't exist for
> compat tasks, it means they get the non-compat entry point. So blank or
> '-' are not explicit enough IMO because the script might have some
> default logic which you can't see by looking at the table.
>
> "none" is pretty explicit I thought. Possibly better is a literal
> "ENOSYS", which stands out well and should be obvious to new comers.

ENOSYS is fine with me as well, but most importantly please don't make
powerpc different from the other ones for a matter of personal preference.
Whatever you want to change it to, please make the patch change all
syscall.tbl files at once, and explain in the patch why we should do this
across all architectures, then see if anyone objects.

> > We might also just remove those entirely across all architectures.
> > Some have already done this, and some have done it partially.
> > I can only see a couple of syscalls that got removed in the entire
> > git history (set_zone_reclaim, nfsservctl, vm86, timerfd), any other
> > ones are now literally pre-historic, and presumably nobody would
> > miss the macros when building a program that has no chance to
> > run on any kernel since at least 2.6.12.
>
> I don't see the benefit, a single missing #define could be a build break
> for some random pieces of software out there.

It certainly could, the question is whether that is a bad thing or not.

Once again, I think it's most important to be consistent across
architectures, and either define them everywhere or nowhere so we
don't end up with applications that are only broken on less common
architectures but work on fine on others.

Most of these only still exist in a few architectures anyway:

$ git grep sys_ni_syscall arch/{*/,}*/*/syscall*.tbl | grep -v
'\<\(osf\|available\|reserved\|unused\)' | awk '{ print $3; }' | sort
| uniq -c
  7 afs_syscall
  3 break
  8 create_module
  1 dipc
  1 exec_with_loader
  1 fadvise64_64
  3 ftime
  8 get_kernel_syms
  1 get_mempolicy
  7 getpmsg
  3 getrlimit
  1 get_thread_area
  3 gtty
  3 idle
  3 ioperm
  3 iopl
  1 ipc
  1 kern_features
  1 kexec_load
  3 lock
  1 mbind
  1 migrate_pages
  3 modify_ldt
  3 mpx
  1 multiplexer
 11 nfsservctl
  1 ni_syscall
  3 oldfstat
  3 oldlstat
  3 oldolduname
  3 oldstat
  3 olduname
  3 prof
  3 profil
  7 putpmsg
  8 query_module
  3 readdir
  4 select
  1 set_mempolicy
  1 set_thread_area
  3 sigaction
  1 sigaltstack
  1 signal
  2 sigpending
  2 sigprocmask
  3 sigreturn
  3 sigsuspend
  1 spill
  3 stty
  1 swapcontext
  2 switch_endian
  3 sys_debug_setcontext
  5 timerfd
  2 tuxcall
  3 ulimit
  2 umount
  1 uselib
  4 vm86
  2 vm86old
  6 vserver
  1 xtensa

I would guess that there are enough syscall names here that are more likely to
cause problems if the macro is defined then when it is missing, e.g. a common
method in glibc is to check for the older symbol first:

int
__renameat (int oldfd, const char *old, int newfd, const char *new)
{
#ifdef __NR_renameat
  return INLINE_SYSCALL_CALL (renameat, oldfd, old, newfd, new);
#else
  return INLINE_SYSCALL_CALL (renameat2, oldfd, old, newfd, new, 0);
#endif
}

and this breaks if __NR_renameat is sys_ni_syscall. I could not find
any such example that is actually broken with glibc today (presumably
others have checked before me), but other software may do similar
things.

> > For 32-bit oldstat, I'd argue that this should actually get fixed by adding
> > the compat syscall logic. I think this 

[PATCH 3/4] powerpc/64s: Move SLB init into hash_utils_64.c

2019-01-17 Thread Michael Ellerman
The SLB initialisation code is spread around a bit between prom.c and
hash_utils_64.c. Consolidate it all in hash_utils_64.c.

This slightly changes the timing of when mmu_slb_size is initialised,
but that should have no effect.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/prom.c  | 16 
 arch/powerpc/mm/hash_utils_64.c | 15 ++-
 2 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 14693f8ccb80..018ededd1948 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -229,21 +229,6 @@ static void __init check_cpu_pa_features(unsigned long 
node)
  ibm_pa_features, ARRAY_SIZE(ibm_pa_features));
 }
 
-#ifdef CONFIG_PPC_BOOK3S_64
-static void __init init_mmu_slb_size(unsigned long node)
-{
-   const __be32 *slb_size_ptr;
-
-   slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL) ? :
-   of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
-
-   if (slb_size_ptr)
-   slb_set_size(be32_to_cpup(slb_size_ptr));
-}
-#else
-#define init_mmu_slb_size(node) do { } while(0)
-#endif
-
 static struct feature_property {
const char *name;
u32 min_value;
@@ -379,7 +364,6 @@ static int __init early_init_dt_scan_cpus(unsigned long 
node,
}
 
identical_pvr_fixup(node);
-   init_mmu_slb_size(node);
 
 #ifdef CONFIG_PPC64
if (nthreads == 1)
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 4aa0797000f7..33ce76be17de 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -344,9 +344,8 @@ static int __init parse_disable_1tb_segments(char *p)
 }
 early_param("disable_1tb_segments", parse_disable_1tb_segments);
 
-static int __init htab_dt_scan_seg_sizes(unsigned long node,
-const char *uname, int depth,
-void *data)
+static int __init htab_dt_scan_slb(unsigned long node, const char *uname,
+  int depth, void *data)
 {
const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
const __be32 *prop;
@@ -356,6 +355,12 @@ static int __init htab_dt_scan_seg_sizes(unsigned long 
node,
if (type == NULL || strcmp(type, "cpu") != 0)
return 0;
 
+   prop = of_get_flat_dt_prop(node, "slb-size", NULL);
+   if (!prop)
+   prop = of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
+   if (prop)
+   slb_set_size(be32_to_cpup(prop));
+
prop = of_get_flat_dt_prop(node, "ibm,processor-segment-sizes", &size);
if (prop == NULL)
return 0;
@@ -954,8 +959,8 @@ static void __init htab_initialize(void)
 
 void __init hash__early_init_devtree(void)
 {
-   /* Initialize segment sizes */
-   of_scan_flat_dt(htab_dt_scan_seg_sizes, NULL);
+   /* Initialize SLB size and segment sizes */
+   of_scan_flat_dt(htab_dt_scan_slb, NULL);
 
/* Initialize page sizes */
htab_scan_page_sizes();
-- 
2.20.1



[PATCH 4/4] powerpc/64s: Support shrinking the SLB for debugging

2019-01-17 Thread Michael Ellerman
On machines with 1TB segments and a 32-entry SLB it's quite hard to
cause sufficient SLB pressure to trigger bugs caused due to badly
timed SLB faults.

We have seen this in the past and a few years ago added the
disable_1tb_segments command line option to force the use of 256MB
segments. However even this allows some bugs to slip through testing
if the SLB entry in question was recently accessed.

So add a new command line parameter for debugging which shrinks the
SLB to the minimum size we can support. Currently that size is 3, two
bolted SLBs and 1 for dynamic use. This creates the maximal SLB
pressure while still allowing the kernel to operate.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/mm/slb.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index 61450a9cf30d..0f33e28f97da 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -506,10 +506,24 @@ void switch_slb(struct task_struct *tsk, struct mm_struct 
*mm)
asm volatile("isync" : : : "memory");
 }
 
+static bool shrink_slb = false;
+
+static int __init parse_shrink_slb(char *p)
+{
+   shrink_slb = true;
+   slb_set_size(0);
+
+   return 0;
+}
+early_param("shrink_slb", parse_shrink_slb);
+
 static u32 slb_full_bitmap;
 
 void slb_set_size(u16 size)
 {
+   if (shrink_slb)
+   size = SLB_NUM_BOLTED + 1;
+
mmu_slb_size = size;
 
if (size >= 32)
-- 
2.20.1



[PATCH 2/4] powerpc/64s: Add slb_full_bitmap rather than hard-coding U32_MAX

2019-01-17 Thread Michael Ellerman
The recent rewrite of the SLB code into C included the assumption that
all CPUs we run on have at least 32 SLB entries. This is currently
true but a bit fragile as the SLB size is actually defined by the
device tree and so could theoretically change at any time.

The assumption is encoded in the fact that we use U32_MAX as the value
for a full SLB bitmap. Instead, calculate what the full bitmap would
be based on the SLB size we're given and store it. This still requires
the SLB size to be a power of 2.

Fixes: 126b11b294d1 ("powerpc/64s/hash: Add SLB allocation status bitmaps")
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/mm/slb.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index bc3914d54e26..61450a9cf30d 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -506,9 +506,16 @@ void switch_slb(struct task_struct *tsk, struct mm_struct 
*mm)
asm volatile("isync" : : : "memory");
 }
 
+static u32 slb_full_bitmap;
+
 void slb_set_size(u16 size)
 {
mmu_slb_size = size;
+
+   if (size >= 32)
+   slb_full_bitmap = U32_MAX;
+   else
+   slb_full_bitmap = (1ul << size) - 1;
 }
 
 void slb_initialize(void)
@@ -611,7 +618,7 @@ static enum slb_index alloc_slb_index(bool kernel)
 * POWER7/8/9 have 32 SLB entries, this could be expanded if a
 * future CPU has more.
 */
-   if (local_paca->slb_used_bitmap != U32_MAX) {
+   if (local_paca->slb_used_bitmap != slb_full_bitmap) {
index = ffz(local_paca->slb_used_bitmap);
local_paca->slb_used_bitmap |= 1U << index;
if (kernel)
-- 
2.20.1



[PATCH 1/4] powerpc/64s: Always set mmu_slb_size using slb_set_size()

2019-01-17 Thread Michael Ellerman
It's easier to reason about the code if we only set mmu_slb_size in
one place, so convert open-coded assignments to use slb_set_size().

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/prom.c  | 2 +-
 arch/powerpc/mm/pgtable-radix.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 4181ec715f88..14693f8ccb80 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -238,7 +238,7 @@ static void __init init_mmu_slb_size(unsigned long node)
of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
 
if (slb_size_ptr)
-   mmu_slb_size = be32_to_cpup(slb_size_ptr);
+   slb_set_size(be32_to_cpup(slb_size_ptr));
 }
 #else
 #define init_mmu_slb_size(node) do { } while(0)
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index 931156069a81..949fbc96b237 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -328,7 +328,8 @@ void __init radix_init_pgtable(void)
struct memblock_region *reg;
 
/* We don't support slb for radix */
-   mmu_slb_size = 0;
+   slb_set_size(0);
+
/*
 * Create the linear mapping, using standard page size for now
 */
-- 
2.20.1



Re: [PATCH] powerpc/tm: Limit TM code inside PPC_TRANSACTIONAL_MEM

2019-01-17 Thread Breno Leitao
hi Sasha,

On 1/16/19 11:35 AM, Sasha Levin wrote:
> Hi,
> 
> [This is an automated email]
> 
> This commit has been processed because it contains a "Fixes:" tag,
> fixing commit: e1c3743e1a20 powerpc/tm: Set MSR[TS] just prior to 
> recheckpoint.
> 
> The bot has tested the following trees: v4.20.2, v4.19.15, v4.14.93, v4.9.150.
> 
> v4.20.2: Failed to apply! Possible dependencies:
> Unable to calculate
> 
> v4.19.15: Failed to apply! Possible dependencies:
> Unable to calculate
> 
> v4.14.93: Failed to apply! Possible dependencies:
> 0d60619e1c0c ("powerpc: Add missing prototype for sys_debug_setcontext()")
> 67b464a89c21 ("powerpc/32: Mark both tmp variables as unused")
> 6f5b9f018f4c ("powerpc/tm: Unset MSR[TS] if not recheckpointing")
> b53875c4b4f2 ("powerpc: Add missing prototypes for sys_sigreturn() & 
> sys_rt_sigreturn()")
> bf7fb32dd5fc ("powerpc: Add missing prototypes for ppc_select() & 
> ppc_fadvise64_64()")
> f3675644e172 ("powerpc/syscalls: signal_{32, 64} - switch to 
> SYSCALL_DEFINE")
> 
> v4.9.150: Failed to apply! Possible dependencies:
> 0d60619e1c0c ("powerpc: Add missing prototype for sys_debug_setcontext()")
> 67b464a89c21 ("powerpc/32: Mark both tmp variables as unused")
> 6f5b9f018f4c ("powerpc/tm: Unset MSR[TS] if not recheckpointing")
> b53875c4b4f2 ("powerpc: Add missing prototypes for sys_sigreturn() & 
> sys_rt_sigreturn()")
> bf7fb32dd5fc ("powerpc: Add missing prototypes for ppc_select() & 
> ppc_fadvise64_64()")
> f3675644e172 ("powerpc/syscalls: signal_{32, 64} - switch to 
> SYSCALL_DEFINE")
> 
> 
> How should we proceed with this patch?

I understand that the commit that this patch fixes is not integrated into
stable tree.

I think it does not need to make stable at this moment, thus.

Thanks,
Breno


[PATCH] powerpc/64s: Remove MSR_RI optimisation in system_call_exit()

2019-01-17 Thread Michael Ellerman
Currently in system_call_exit() we have an optimisation where we
disable MSR_RI (recoverable interrupt) and MSR_EE (external interrupt
enable) in a single mtmsrd instruction.

Unfortunately this will no longer work with THREAD_INFO_IN_TASK,
because then the load of TI_FLAGS might fault and faulting with MSR_RI
clear is treated as an unrecoverable exception which leads to a
panic().

So change the code to only clear MSR_EE prior to loading TI_FLAGS,
leaving the clear of MSR_RI until later. We have some latitude in
where do the clear of MSR_RI. A bit of experimentation has shown that
this location gives the least slow down.

This still causes a noticeable slow down in our null_syscall
performance. On a Power9 DD2.2:

  BeforeAfter Delta Delta %
  955 cycles999 cycles-44   -4.6%

On the plus side this does simplify the code somewhat, because we
don't have to reenable MSR_RI on the restore_math() or
syscall_exit_work() paths which was necessitated previously by the
optimisation.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/entry_64.S | 34 ++
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 83bddacd7a17..b1aea6680a9d 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -236,18 +236,14 @@ system_call:  /* label this so stack 
traces look sane */
/*
 * Disable interrupts so current_thread_info()->flags can't change,
 * and so that we don't get interrupted after loading SRR0/1.
+*
+* Leave MSR_RI enabled for now, because with THREAD_INFO_IN_TASK we
+* could fault on the load of the TI_FLAGS below.
 */
 #ifdef CONFIG_PPC_BOOK3E
wrteei  0
 #else
-   /*
-* For performance reasons we clear RI the same time that we
-* clear EE. We only need to clear RI just before we restore r13
-* below, but batching it with EE saves us one expensive mtmsrd call.
-* We have to be careful to restore RI if we branch anywhere from
-* here (eg syscall_exit_work).
-*/
-   li  r11,0
+   li  r11,MSR_RI
mtmsrd  r11,1
 #endif /* CONFIG_PPC_BOOK3E */
 
@@ -263,15 +259,7 @@ system_call:   /* label this so stack 
traces look sane */
bne 3f
 #endif
 2: addir3,r1,STACK_FRAME_OVERHEAD
-#ifdef CONFIG_PPC_BOOK3S
-   li  r10,MSR_RI
-   mtmsrd  r10,1   /* Restore RI */
-#endif
bl  restore_math
-#ifdef CONFIG_PPC_BOOK3S
-   li  r11,0
-   mtmsrd  r11,1
-#endif
ld  r8,_MSR(r1)
ld  r3,RESULT(r1)
li  r11,-MAX_ERRNO
@@ -287,6 +275,16 @@ END_FTR_SECTION_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
andi.   r6,r8,MSR_PR
ld  r4,_LINK(r1)
 
+#ifdef CONFIG_PPC_BOOK3S
+   /*
+* Clear MSR_RI, MSR_EE is already and remains disabled. We could do
+* this later, but testing shows that doing it here causes less slow
+* down than doing it closer to the rfid.
+*/
+   li  r11,0
+   mtmsrd  r11,1
+#endif
+
beq-1f
ACCOUNT_CPU_USER_EXIT(r13, r11, r12)
 
@@ -363,10 +361,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
b   .Lsyscall_exit

 .Lsyscall_exit_work:
-#ifdef CONFIG_PPC_BOOK3S
-   li  r10,MSR_RI
-   mtmsrd  r10,1   /* Restore RI */
-#endif
/* If TIF_RESTOREALL is set, don't scribble on either r3 or ccr.
 If TIF_NOERROR is set, just save r3 as it is. */
 
-- 
2.20.1



[PATCH v2] powerpc/wii: properly disable use of BATs when requested.

2019-01-17 Thread Christophe Leroy
'nobats' kernel parameter or some options like CONFIG_DEBUG_PAGEALLOC
deny the use of BATS for mapping memory.

This patch makes sure that the specific wii RAM mapping function
takes it into account as well.

Fixes: de32400dd26e ("wii: use both mem1 and mem2 as ram")
Cc: sta...@vger.kernel.org
Reviewed-by: Jonathan Neuschafer 
Signed-off-by: Christophe Leroy 
---
 arch/powerpc/platforms/embedded6xx/wii.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/platforms/embedded6xx/wii.c 
b/arch/powerpc/platforms/embedded6xx/wii.c
index ecf703ee3a76..ac4ee88efc80 100644
--- a/arch/powerpc/platforms/embedded6xx/wii.c
+++ b/arch/powerpc/platforms/embedded6xx/wii.c
@@ -83,6 +83,10 @@ unsigned long __init wii_mmu_mapin_mem2(unsigned long top)
/* MEM2 64MB@0x1000 */
delta = wii_hole_start + wii_hole_size;
size = top - delta;
+
+   if (__map_without_bats)
+   return delta;
+
for (bl = 128<<10; bl < max_size; bl <<= 1) {
if (bl * 2 > size)
break;
-- 
2.13.3



Re: [PATCH v2 00/15] powerpc/32s: Use BATs/LTLBs for STRICT_KERNEL_RWX

2019-01-17 Thread Christophe Leroy




Le 17/01/2019 à 00:48, Jonathan Neuschäfer a écrit :

On Wed, Jan 16, 2019 at 02:34:53PM +0100, Christophe Leroy wrote:

Le 16/01/2019 à 14:16, Jonathan Neuschäfer a écrit :

On Wed, Jan 16, 2019 at 07:55:29AM +0100, Christophe Leroy wrote:

Le 16/01/2019 à 01:35, Jonathan Neuschäfer a écrit :

Thinning the kernel down a bit actually makes it boot again. Ooops...!
Maybe enabling CONFIG_STRICT_KERNEL_RWX has made it just large enough to
fail the hash table allocation, but there may have been other factors
involved (I'm not sure exactly).  Sorry for the confusion!


Ok, that must be the reason. Thanks for testing.

What about the following modification which maps a second 256Mb BAT, does it
helps ?



diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index c2f564690778..ea574596de37 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -1160,6 +1160,14 @@ initial_bats:
mtspr   SPRN_DBAT0U,r11 /* bit in upper BAT register */
mtspr   SPRN_IBAT0L,r8
mtspr   SPRN_IBAT0U,r11
+#ifdef CONFIG_WII
+   addis   r11,r11,0x1000@h
+   addis   r8,r8,0x1000@h
+   mtspr   SPRN_DBAT2L,r8
+   mtspr   SPRN_DBAT2U,r11
+   mtspr   SPRN_IBAT2L,r8
+   mtspr   SPRN_IBAT2U,r11
+#endif
isync
blr

diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c
index 3f4193201ee7..a334fd5210a8 100644
--- a/arch/powerpc/mm/ppc_mmu_32.c
+++ b/arch/powerpc/mm/ppc_mmu_32.c
@@ -259,6 +259,8 @@ void setup_initial_memory_limit(phys_addr_t
first_memblock_base,
/* 601 can only access 16MB at the moment */
if (PVR_VER(mfspr(SPRN_PVR)) == 1)
memblock_set_current_limit(min_t(u64, first_memblock_size, 
0x0100));
+   else if (IS_ENABLED(CONFIG_WII))
+   memblock_set_current_limit(min_t(u64, first_memblock_size, 
0x2000));
else /* Anything else has 256M mapped */
memblock_set_current_limit(min_t(u64, first_memblock_size, 
0x1000));
   }


I haven't tested it, but this patch won't be enough, because we're only
looking at the first memblock, and the additional memory in the Wii
(MEM2) is the second memblock.



Yes right.


Would the following work instead ?

memblock_set_current_limit(0x2000);


With the config at 
https://gist.githubusercontent.com/neuschaefer/12ccc87ff8aeff543fad558e8742cd2b/raw/d49d321709cac364779e6893bbd91ff5a80bcb03/config
it still doesn't boot, but with a different error:

top of MEM2 @ 13F0

zImage starting: loaded at 0x0100 (sp: 0x0178afa0)
Allocating 0x166b2c8 bytes for kernel...
Decompressing (0x <- 0x01011000:0x01788799)...
Done! Decompressed 0xf421f4 bytes

Linux/PowerPC load: root=/dev/mmcblk0p2 rootwait console=usbgecko1
Finalizing device tree... flat tree at 0x178b7a0
[0.00] printk: bootconsole [udbg0] enabled
[0.00] __memblock_find_range_top_down(1000:2000, 10:10, 
, 0)
[0.00] __memblock_find_range_top_down: in loop, 1000:13f0
[0.00] Total memory = 319MB; using 1024kB for hash table (at d3e0)
[0.00] __memblock_find_range_top_down(1000:2000, 1000:1000, 
, 0)
[0.00] __memblock_find_range_top_down: in loop, 1000:13e0
[0.00] __memblock_find_range_top_down(1000:2000, 1000:1000, 
, 0)
[0.00] __memblock_find_range_top_down: in loop, 1000:13dff000
[0.00] BUG: Unable to handle kernel data access at 0xc106a434
[0.00] Faulting instruction address: 0xc0071bf4
[0.00] Oops: Kernel access of bad area, sig: 11 [#1]
[0.00] BE PREEMPT
[0.00] Modules linked in:
[0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 
5.0.0-rc1-wii-00038-gc34b70d591b6-dirty #1337
[0.00] NIP:  c0071bf4 LR: c00727d8 CTR: 
[0.00] REGS: c0f1fd30 TRAP: 0300   Not tainted  
(5.0.0-rc1-wii-00038-gc34b70d591b6-dirty)
[0.00] MSR:  1032   CR: 44002842  XER: 
[0.00] DAR: c106a434 DSISR: 4000
[0.00] GPR00: c0074a98 c0f1fde0 c0ead4a0 c0ead4a0 c0ead9c8 0008 
 
[0.00] GPR08: 0003 c106a418 0258 0001 24000444 fb43ef5b 
c0f3 7561f327
[0.00] GPR16: c0f4 691cfd11 38afe359 f161e513  c0ead9c8 
0001 
[0.00] GPR24:  c0f46288  c0ead4a0 c0ead9c8 0008 
c0ead4a0 0100
[0.00] NIP [c0071bf4] mark_lock+0x64/0x858
[0.00] LR [c00727d8] __lock_acquire+0x334/0x1a40
[0.00] Call Trace:
[0.00] [c0f1fe20] [0006] 0x6
[0.00] [c0f1fed0] [c0074a98] lock_acquire+0x110/0x20c
[0.00] [c0f1ff10] [c085e8cc] _raw_spin_lock+0x44/0x60
[0.00] [c0f1ff30] [c007f220] vprintk_emit+0xa0/0x328
[0.00] [c0f1ff70] [c007fc48] printk+0x5c/0x84
[0.00] [c0f1ffb0] [c0c00854] start_kernel+0x64/0x460
[0.00] [c0f1fff0] [3438] 0x3438
[0.00] Instructio

Re: [RESENDING PATCH] powerpc/wii: properly disable use of BATs when requested.

2019-01-17 Thread Christophe Leroy




Le 17/01/2019 à 02:05, Jonathan Neuschäfer a écrit :

Hi again,

On Tue, Jan 15, 2019 at 04:43:20PM +, Christophe Leroy wrote:

'nobats' kernel parameter or some options like CONFIG_DEBUG_PAGEALLOC
deny the use of BATS for mapping memory.

This patch makes sure that the specific wii RAM mapping function
takes it into account as well.

Fixes: de32400dd26e ("wii: use both mem1 and mem2 as ram")
Cc: sta...@vger.kernel.org
Signed-off-by: Christophe Leroy 
---

[...]

/* MEM2 64MB@0x1000 */
delta = wii_hole_start + wii_hole_size;
+   if (__map_without_bats)
+   return delta;
+


Nothing is visibly broken without this patch, even with
CONFIG_DEBUG_PAGEALLOC (tested on top of v5.0-rc2), but the patch still
looks correct.


Obviously, CONFIG_DEBUG_PAGEALLOC cannot work without this patch.
The purpose of CONFIG_DEBUG_PAGEALLOC is to unmap unused parts of memory 
so that any access to them will pagefault.


As this function inconditionnaly sets a BAT for the second block of RAM, 
any access to free area in the upper block will be granted without a fault.


I think you can test it by doing a kmalloc() then a kfree(), then try to 
read in that area (hopefully kmalloc() allocates memory from the top so 
it should go in the upper block). Maybe there is an LKDTM test for that.




I'd prefer the 'if' block to be before the whole delta/size calculation,
to make the code slightly more readable because the delta and size
calculations stay in one visual block. It doesn't need to happen after
delta is calculated.


Euh ... the function has to return 'delta', so if I put the if block 
before the calculation of delta, it means we have to calculate delta twice:


if (__map_without_bats)
return wii_hole_start + wii_hole_size;

delta = wii_hole_start + wii_hole_size;

My eyes don't really like it, so if we want to keep delta and size 
calculation together, the 'if' will go after calculation of size.


In anycase, this change is only really for fixing stable releases 
because this function will go away with my other serie.


Christophe



tentatively,
Reviewed-by: Jonathan Neuschäfer 


Thanks,
Jonathan



Re: [PATCH 19/21] treewide: add checks for the return value of memblock_alloc*()

2019-01-17 Thread Guo Ren
On Wed, Jan 16, 2019 at 03:44:19PM +0200, Mike Rapoport wrote:
>  arch/csky/mm/highmem.c|  5 +
...
> diff --git a/arch/csky/mm/highmem.c b/arch/csky/mm/highmem.c
> index 53b1bfa..3317b774 100644
> --- a/arch/csky/mm/highmem.c
> +++ b/arch/csky/mm/highmem.c
> @@ -141,6 +141,11 @@ static void __init fixrange_init(unsigned long start, 
> unsigned long end,
>   for (; (k < PTRS_PER_PMD) && (vaddr != end); pmd++, 
> k++) {
>   if (pmd_none(*pmd)) {
>   pte = (pte_t *) 
> memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
> + if (!pte)
> + panic("%s: Failed to allocate 
> %lu bytes align=%lx\n",
> +   __func__, PAGE_SIZE,
> +   PAGE_SIZE);
> +
>   set_pmd(pmd, __pmd(__pa(pte)));
>   BUG_ON(pte != pte_offset_kernel(pmd, 
> 0));
>   }

Looks good for me and panic is ok.

Reviewed-by: Guo Ren 


Re: [RFC PATCH v2 5/5] powerpc/syscalls: Allow none instead of sys_ni_syscall

2019-01-17 Thread Michael Ellerman
Hi Arnd,

Arnd Bergmann  writes:
> On Wed, Jan 16, 2019 at 2:27 PM Michael Ellerman  wrote:
>>
>> sys_ni_syscall is the "not-implemented" syscall syscall, which just
>> returns -ENOSYS.
>>
>> But unless you know that it's not obvious what it does, and even if
>> you do know what it means it doesn't stand out that well from other
>> real syscalls.
>>
>> So teach the scripts to treat "none" as a synonym for
>> "sys_ni_syscall". This makes the table more readable.
>
> Hmm, this actually breaks the proposed script to find bugs
> in the compat handling, i.e. detecting those that have no
> compat handler but only a native one.

I don't understand how? It just makes none an alias for sys_ni_syscall,
so surely the worse case is that script will need to do the reverse
transformation?

>> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl 
>> b/arch/powerpc/kernel/syscalls/syscall.tbl
>> index c5907a2dbc86..988a7e29245f 100644
>> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
>> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
>> @@ -24,28 +24,28 @@
>>  14 common  mknod   sys_mknod
>>  15 common  chmod   sys_chmod
>>  16 common  lchown  sys_lchown
>> -17 common  break   sys_ni_syscall
>> -18 32  oldstat sys_stat 
>>sys_ni_syscall
>> -18 64  oldstat sys_ni_syscall
>> +17 common  break   none
>> +18 32  oldstat sys_stat 
>>none
>> +18 64  oldstat none
>
> The '64 oldstat' line can simply get dropped here, it has no value
> (I failed to notice this earlier).

It does add value. It causes the syscall number to be defined in
unistd.h (now unistd_64.h).

If you remove it then that syscall number is no longer defined which
changes the uapi header and could break something.

Sure arguably it shouldn't be defined, and it's old etc. but it was
previously defined, so removing it seems risky.


> For break, i.e. a syscall number without any implementation,
> we use a different syntax on x86 (leaving out the sys_* entirely),
> and on s390 (using '-', which is visually better than 'none' IMHO).

Except a blank compat syscall doesn't mean the syscall doesn't exist for
compat tasks, it means they get the non-compat entry point. So blank or
'-' are not explicit enough IMO because the script might have some
default logic which you can't see by looking at the table.

"none" is pretty explicit I thought. Possibly better is a literal
"ENOSYS", which stands out well and should be obvious to new comers.

> We might also just remove those entirely across all architectures.
> Some have already done this, and some have done it partially.
> I can only see a couple of syscalls that got removed in the entire
> git history (set_zone_reclaim, nfsservctl, vm86, timerfd), any other
> ones are now literally pre-historic, and presumably nobody would
> miss the macros when building a program that has no chance to
> run on any kernel since at least 2.6.12.

I don't see the benefit, a single missing #define could be a build break
for some random pieces of software out there.


> For 32-bit oldstat, I'd argue that this should actually get fixed by adding
> the compat syscall logic. I think this was discussed when Firoz
> first posted his patches. Something like this:

I'm not clear why we would do that? If there were programs out there
that wanted oldstat in compat mode surely we would have got a bug report
by now.

So this just wires up a syscall that no one will ever use?

cheers

> diff --git a/arch/powerpc/include/asm/unistd.h
> b/arch/powerpc/include/asm/unistd.h
> index f44dbc65e38e..d954c2fc4e2f 100644
> --- a/arch/powerpc/include/asm/unistd.h
> +++ b/arch/powerpc/include/asm/unistd.h
> @@ -41,9 +41,7 @@
>  #define __ARCH_WANT_SYS_OLDUMOUNT
>  #define __ARCH_WANT_SYS_SIGPENDING
>  #define __ARCH_WANT_SYS_SIGPROCMASK
> -#ifdef CONFIG_PPC32
>  #define __ARCH_WANT_OLD_STAT
> -#endif
>  #ifdef CONFIG_PPC64
>  #define __ARCH_WANT_SYS_TIME
>  #define __ARCH_WANT_SYS_UTIME
> diff --git a/arch/powerpc/include/uapi/asm/stat.h
> b/arch/powerpc/include/uapi/asm/stat.h
> index afd25f2ff4e8..8331b350c12b 100644
> --- a/arch/powerpc/include/uapi/asm/stat.h
> +++ b/arch/powerpc/include/uapi/asm/stat.h
> @@ -11,7 +11,7 @@
>
>  #define STAT_HAVE_NSEC 1
>
> -#ifndef __powerpc64__
> +#if defined(__KERNEL__) || !defined(__powerpc64__)
>  struct __old_kernel_stat {
> unsigned short st_dev;
> unsigned short st_ino;
> @@ -25,7 +25,7 @@ struct __old_kernel_stat {
> unsigned long  st_mtime;
> unsigned long  st_ctime;
>  };
> -#endif /* !__powerpc64__ */
> +#endif /* __KERNEL__ || !__powerpc64__ */
>
>  struct stat {
> unsigned long   st_dev;
> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl
> b/arch/powerpc/kernel/s

[PATCH v2 3/4] kbuild: add real-prereqs shorthand for $(filter-out FORCE, $^)

2019-01-17 Thread Masahiro Yamada
In Kbuild, if_changed and friends must have FORCE as a prerequisite.

Hence, $(filter-out FORCE,$^) or $(filter-out $(PHONY),$^) is a common
pattern to get the names of all the prerequisites except phony targets.

Add real-prereqs as a shorthand.

Note:
We cannot replace $(filter %.o,$^) in cmd_link_multi-m because $^ may
include auto-generated dependencies from the .*.cmd file when a single
object module is changed into a multi object module. Refer to commit
69ea912fda74 ("kbuild: remove unneeded link_multi_deps"). I added some
comment to avoid accidental breakage.

Signed-off-by: Masahiro Yamada 
---

The patch context depends on some other ones.
Please use 'git am -C1' if you want to test this
on Linus' tree.


Changes in v2:
  - clean up arch/s390/boot/Makefile as well

 Documentation/devicetree/bindings/Makefile |  2 +-
 arch/mips/boot/Makefile|  2 +-
 arch/powerpc/boot/Makefile |  2 +-
 arch/s390/boot/Makefile|  2 +-
 arch/x86/realmode/rm/Makefile  |  3 +--
 scripts/Kbuild.include |  4 
 scripts/Makefile.build |  9 ++---
 scripts/Makefile.lib   | 18 +-
 scripts/Makefile.modpost   |  2 +-
 9 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/Documentation/devicetree/bindings/Makefile 
b/Documentation/devicetree/bindings/Makefile
index 6e5cef0..e4eb5d1 100644
--- a/Documentation/devicetree/bindings/Makefile
+++ b/Documentation/devicetree/bindings/Makefile
@@ -15,7 +15,7 @@ DT_TMP_SCHEMA := processed-schema.yaml
 extra-y += $(DT_TMP_SCHEMA)
 
 quiet_cmd_mk_schema = SCHEMA  $@
-  cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(filter-out 
FORCE, $^)
+  cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ 
$(real-prereqs)
 
 DT_DOCS = $(shell cd $(srctree)/$(src) && find * -name '*.yaml')
 DT_SCHEMA_FILES ?= $(addprefix $(src)/,$(DT_DOCS))
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index 35704c2..3ce4dd5 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -115,7 +115,7 @@ endif
 targets += vmlinux.its.S
 
 quiet_cmd_its_cat = CAT $@
-  cmd_its_cat = cat $(filter-out $(PHONY), $^) >$@
+  cmd_its_cat = cat $(real-prereqs) >$@
 
 $(obj)/vmlinux.its.S: $(addprefix 
$(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
$(call if_changed,its_cat)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 0e8dadd..73d1f35 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -218,7 +218,7 @@ quiet_cmd_bootas = BOOTAS  $@
   cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
 
 quiet_cmd_bootar = BOOTAR  $@
-  cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@. $(filter-out FORCE,$^); mv 
$@. $@
+  cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@. $(real-prereqs); mv 
$@. $@
 
 $(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
$(call if_changed_dep,bootcc)
diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile
index b4d8a42..11ca879 100644
--- a/arch/s390/boot/Makefile
+++ b/arch/s390/boot/Makefile
@@ -58,7 +58,7 @@ $(obj)/compressed/vmlinux: $(obj)/startup.a FORCE
$(Q)$(MAKE) $(build)=$(obj)/compressed $@
 
 quiet_cmd_ar = AR  $@
-  cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(filter $(OBJECTS), 
$^)
+  cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
 
 $(obj)/startup.a: $(OBJECTS) FORCE
$(call if_changed,ar)
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
index 4463fa7..394377c 100644
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -37,8 +37,7 @@ REALMODE_OBJS = $(addprefix $(obj)/,$(realmode-y))
 sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p'
 
 quiet_cmd_pasyms = PASYMS  $@
-  cmd_pasyms = $(NM) $(filter-out FORCE,$^) | \
-  sed $(sed-pasyms) | sort | uniq > $@
+  cmd_pasyms = $(NM) $(real-prereqs) | sed $(sed-pasyms) | sort | uniq > $@
 
 targets += pasyms.h
 $(obj)/pasyms.h: $(REALMODE_OBJS) FORCE
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 3081603..d93250b 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -24,6 +24,10 @@ depfile = $(subst $(comma),_,$(dot-target).d)
 basetarget = $(basename $(notdir $@))
 
 ###
+# real prerequisites without phony targets
+real-prereqs = $(filter-out $(PHONY), $^)
+
+###
 # Escape single quote for use in echo statements
 escsq = $(subst $(squote),'\$(squote)',$1)
 
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 681ab58..9800178 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -399,8 +399,7 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
 ifdef builtin-target
 
 quiet_cmd_ar_builtin = AR  $@
-  cmd_ar_builtin = rm -f $@; \
- $(AR) rcSTP$(KBUILD_ARFLAGS) $

Re: [PATCH V2] mm: Introduce GFP_PGTABLE

2019-01-17 Thread Michael Ellerman
Matthew Wilcox  writes:

> On Wed, Jan 16, 2019 at 07:57:03AM +0100, Michal Hocko wrote:
>> On Wed 16-01-19 11:51:32, Anshuman Khandual wrote:
>> > All architectures have been defining their own PGALLOC_GFP as (GFP_KERNEL |
>> > __GFP_ZERO) and using it for allocating page table pages. This causes some
>> > code duplication which can be easily avoided. GFP_KERNEL allocated and
>> > cleared out pages (__GFP_ZERO) are required for page tables on any given
>> > architecture. This creates a new generic GFP flag flag which can be used
>> > for any page table page allocation. Does not cause any functional change.
>> > 
>> > GFP_PGTABLE is being added into include/asm-generic/pgtable.h which is the
>> > generic page tabe header just to prevent it's potential misuse as a general
>> > allocation flag if included in include/linux/gfp.h.
>> 
>> I haven't reviewed the patch yet but I am wondering whether this is
>> really worth it without going all the way down to unify the common code
>> and remove much more code duplication. Or is this not possible for some
>> reason?
>
> Exactly what I suggested doing in response to v1.
>
> Also, the approach taken here is crazy.  x86 has a feature that no other
> architecture has bothered to implement yet -- accounting page tables
> to the process.

powerpc does __GFP_ACCOUNT for user page tables too. Shamelessly cribbed
from the x86 version of course :)

cheers


Re: G5 Quad hangs early on 4.20.2 / 5.0-rc2+

2019-01-17 Thread Tobias Ulmer
On Wed, Jan 16, 2019 at 12:15:14PM +1100, Benjamin Herrenschmidt wrote:
> On Tue, 2019-01-15 at 23:49 +0100, Tobias Ulmer wrote:
> > Hi,
> > 
> > both the latest stable 4.20.2 and 5.0 rc2+ hang early on the G5 Quad.
> > 
> > Surely I'm not the first to run into this, but I couldn't find any
> > discussion or bug report. Sorry if you're already aware.
> > 
> > You can see it hang here (5.0 rc2+, 4.20.2 is nearly identical) until
> > the watchdog triggers a reboot:
> > 
> > https://i.imgur.com/UiCVRuG.jpg
> > 
> > If I had to make an uneducated guess, it seems to boot into the same
> > codepath twice (mpic was already initialized, then it starts again right
> > after smp bringup). Maybe on a second CPU?
> > 
> > To narrow it down a little, my last known good was 4.18.9
> 
> I don't think it's an MPIC related problem but it does appear to hang
> about when interrupts get turned on.

When they get turned on for the second time, for some reason. You can see the
end of the first time just on top of the screen.

It repeats part of the startup initialization right after it's done with
smp bringup.

> 
> I have one of these critters in the office, but I'm working remotely
> this week so I won't be able to dig into this until next week.
> 
> It might help if you could bisect in the meantime.

I'm bisecting it now, but it's slow going since I don't have much time
to babysit the machine. The problem shows up somewhere between v4.19 and
v4.20.

> 
> Cheers,
> Ben.
> 
> 


Re: use generic DMA mapping code in powerpc V4

2019-01-17 Thread Christoph Hellwig
On Thu, Jan 17, 2019 at 10:21:11AM +0100, Christian Zigotzky wrote:
> The X1000 boots and the PASEMI onboard ethernet works!
>
> Bad news for the X5000 (P5020 board). U-Boot loads the kernel and the dtb 
> file. Then the kernel starts but it doesn't find any hard disks 
> (partitions).

Thanks for bisecting so far, and lets stop here until I manage to
resolve the problem.

Can you send me the .config and the dtb file for this board?


Re: [PATCH 21/21] memblock: drop memblock_alloc_*_nopanic() variants

2019-01-17 Thread Petr Mladek
On Wed 2019-01-16 15:44:21, Mike Rapoport wrote:
> As all the memblock allocation functions return NULL in case of error
> rather than panic(), the duplicates with _nopanic suffix can be removed.

[...]

> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index c4f0a41..ae65221 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1147,17 +1147,14 @@ void __init setup_log_buf(int early)
>   if (!new_log_buf_len)
>   return;
>  
> - if (early) {
> - new_log_buf =
> - memblock_alloc(new_log_buf_len, LOG_ALIGN);
> - } else {
> - new_log_buf = memblock_alloc_nopanic(new_log_buf_len,
> -   LOG_ALIGN);
> - }
> -
> + new_log_buf = memblock_alloc(new_log_buf_len, LOG_ALIGN);

The above change is enough.

>   if (unlikely(!new_log_buf)) {
> - pr_err("log_buf_len: %lu bytes not available\n",
> - new_log_buf_len);
> + if (early)
> + panic("log_buf_len: %lu bytes not available\n",
> + new_log_buf_len);

panic() is not needed here. printk() will just continue using
the (smaller) static buffer.

> + else
> + pr_err("log_buf_len: %lu bytes not available\n",
> +new_log_buf_len);
>   return;
>   }

Best Regards,
Petr


Re: use generic DMA mapping code in powerpc V4

2019-01-17 Thread Christian Zigotzky

Hi All,

I compiled the fixed '257002094bc5935dd63207a380d9698ab81f0775' 
(powerpc/dma: use the dma-direct allocator for coherent platforms) today.


git clone git://git.infradead.org/users/hch/misc.git -b powerpc-dma.6 a

git checkout 257002094bc5935dd63207a380d9698ab81f0775

Link to the Git: 
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/powerpc-dma.6 



env LANG=C make CROSS_COMPILE=powerpc-linux-gnu- ARCH=powerpc zImage

env LANG=C make CROSS_COMPILE=powerpc-linux-gnu- ARCH=powerpc uImage

The X1000 boots and the PASEMI onboard ethernet works!

Bad news for the X5000 (P5020 board). U-Boot loads the kernel and the 
dtb file. Then the kernel starts but it doesn't find any hard disks 
(partitions).


Cheers,
Christian


On 15 January 2019 at 4:17PM, Christoph Hellwig wrote:

So 257002094bc5935dd63207a380d9698ab81f0775 above is the fixed version
for the commit - this switched the ifdef in dma.c around that I had
inverted.  Can you try that one instead?  And then move on with the
commits after it in the updated powerpc-dma.6 branch - they are
identical to the original branch except for carrying this fix forward.