kisskb: OK linus/axs103_smp_defconfig/arcv2 Thu Nov 01, 16:07

2018-10-31 Thread noreply
OK linus/axs103_smp_defconfig/arcv2 Thu Nov 01, 16:07

http://kisskb.ellerman.id.au/kisskb/buildresult/13570849/

Commit:   Merge branch 'akpm' (patches from Andrew)
  59fc453b21f767f2fb0ff4dc0a947e9b9c9e6d14
Compiler: arc-linux-gcc.br_real (Buildroot 2016.11-git-00613-ge98b4dd) 6.2.1 
20160824

Possible errors
---

arch/arc/boot/dts/axs103_idu.dtb: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x54: I2C bus unit address format error, expected 
"54"
arch/arc/boot/dts/axs103_idu.dtb: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x57: I2C bus unit address format error, expected 
"57"
 #define KERN_ERR KERN_SOH "3" /* error conditions */
 #define KERN_ERR KERN_SOH "3" /* error conditions */
 #define KERN_ERR KERN_SOH "3" /* error conditions */

Possible warnings (82)
--

arch/arc/boot/dts/axs103_idu.dtb: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x54: I2C bus unit address format error, expected 
"54"
arch/arc/boot/dts/axs103_idu.dtb: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x57: I2C bus unit address format error, expected 
"57"
kernel/dma/direct.c:47:5: warning: format '%zu' expects argument of type 
'size_t', but argument 5 has type 'unsigned int' [-Wformat=]
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
arch/arc/mm/tlb.c:914:2: warning: ISO C90 forbids variable length array 'pd0' 
[-Wvla]
drivers/base/regmap/regmap.c:1531:22: warning: format '%zu' expects argument of 
type 'size_t', but argument 5 has type 'unsigned int' [-Wformat=]
drivers/base/component.c:174:24: warning: format '%zu' expects argument of type 
'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
drivers/base/regmap/regcache.c:719:20: warning: format '%zu' expects argument 
of type 'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
fs/ext4/inode.c:3653:12: warning: format '%zd' expects argument of type 'signed 
size_t', but argument 6 has type 'ssize_t {aka int}' [-Wformat=]
mm/percpu.c:1382:17: warning: format '%zu' expects argument of type 'size_t', 
but argument 4 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1382:17: warning: format '%zu' expects argument of type 'size_t', 
but argument 5 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
 #define KERN_WARNING KERN_SOH "4" /* warning conditions */
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 3 has type 'unsigned int' [-Wformat=]
 #define KERN_WARNING KERN_SOH "4" /* warning conditions */
mm/percpu.c:1948:27: warning: format '%zu' expects argument of type 'size_t', 
but argument 3 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:32: warning: format '%zu' expects argument of type 'size_t', 
but argument 4 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:37: warning: format '%zu' expects argument of type 'size_t', 
but argument 5 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:42: warning: format '%zu' expects argument of type 'size_t', 
but argument 6 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:52: warning: format '%zu' expects argument of type 'size_t', 
but argument 7 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:56: warning: format '%zu' expects argument of type 'size_t', 
but argument 8 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 5 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 6 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 7 has type 'unsigned int' [-Wformat=]
include/linux/overflow.h:53:15: warning: comparison of distinct pointer types 
lacks a cast
include/linux/overflow.h:54:15: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: wa

kisskb: OK linus/axs101_defconfig/arcompact Thu Nov 01, 16:08

2018-10-31 Thread noreply
OK linus/axs101_defconfig/arcompact Thu Nov 01, 16:08

http://kisskb.ellerman.id.au/kisskb/buildresult/13570850/

Commit:   Merge branch 'akpm' (patches from Andrew)
  59fc453b21f767f2fb0ff4dc0a947e9b9c9e6d14
Compiler: arc-buildroot-linux-uclibc-gcc (Buildroot 2015.08.1) 4.8.4

Possible errors
---

arch/arc/boot/dts/axs101.dtb: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x54: I2C bus unit address format error, expected 
"54"
arch/arc/boot/dts/axs101.dtb: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x57: I2C bus unit address format error, expected 
"57"

Possible warnings (6)
--

arch/arc/boot/dts/axs101.dtb: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x54: I2C bus unit address format error, expected 
"54"
arch/arc/boot/dts/axs101.dtb: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x57: I2C bus unit address format error, expected 
"57"
arch/arc/mm/tlb.c:914:2: warning: variable length array 'pd0' is used [-Wvla]
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast [enabled by default]
net/ipv4/tcp_input.c:4311:49: warning: array subscript is above array bounds 
[-Warray-bounds]
arch/arc/include/asm/cmpxchg.h:95:29: warning: value computed is not used 
[-Wunused-value]


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH RFC] mm: arc: fix potential double realease of mmap_sem

2018-10-31 Thread Peter Xu
In do_page_fault() of ARC we have:

...
fault = handle_mm_fault(vma, address, flags);

/* If Pagefault was interrupted by SIGKILL, exit page fault "early" */
if (unlikely(fatal_signal_pending(current))) {
if ((fault & VM_FAULT_ERROR) && !(fault & VM_FAULT_RETRY))
up_read(&mm->mmap_sem); < [1]
if (user_mode(regs))
return;
}
...
if (likely(!(fault & VM_FAULT_ERROR))) {
...
return;
}

if (fault & VM_FAULT_OOM)
goto out_of_memory;<- [2]
else if (fault & VM_FAULT_SIGSEGV)
goto bad_area; <- [3]
else if (fault & VM_FAULT_SIGBUS)
goto do_sigbus;<- [4]

Logically it's possible that we might try to release the mmap_sem twice
by having a scenario like:

- task received SIGKILL,
- task handled kernel mode page fault,
- handle_mm_fault() returned with one of VM_FAULT_ERROR,

Then we'll go into path [1] to release the mmap_sem, however we won't
return immediately since user_mode(regs) check will fail (a kernel page
fault).  Then we might go into either [2]-[4] and either of them will
try to release the mmap_sem again.

To fix this, we only release the mmap_sem at [1] when we're sure we'll
quit immediately (after we checked with user_mode(regs)).

CC: Vineet Gupta 
CC: "Eric W. Biederman" 
CC: Peter Xu 
CC: Andrew Morton 
CC: Souptick Joarder 
CC: Andrea Arcangeli 
CC: linux-snps-arc@lists.infradead.org
CC: linux-ker...@vger.kernel.org
Signed-off-by: Peter Xu 
---

I noticed this only by reading the code.  Neither have I verified the
issue, nor have I tested the patch since I even don't know how to (I'm
totally unfamiliar with the arc architecture).  However I'm posting this
out first to see whether there's any quick feedback, and in case it's a
valid issue that we've ignored.
---
 arch/arc/mm/fault.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index c9da6102eb4f..2d28c3dad5c1 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -142,11 +142,10 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
fault = handle_mm_fault(vma, address, flags);
 
/* If Pagefault was interrupted by SIGKILL, exit page fault "early" */
-   if (unlikely(fatal_signal_pending(current))) {
-   if ((fault & VM_FAULT_ERROR) && !(fault & VM_FAULT_RETRY))
+   if (unlikely(fatal_signal_pending(current) && user_mode(regs))) {
+   if (!(fault & VM_FAULT_RETRY))
up_read(&mm->mmap_sem);
-   if (user_mode(regs))
-   return;
+   return;
}
 
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 2/2] kgdb: Fix kgdb_roundup_cpus() for arches who used smp_call_function()

2018-10-31 Thread Doug Anderson
Hi,

On Wed, Oct 31, 2018 at 11:40 AM Daniel Thompson
 wrote:
>
> On Tue, Oct 30, 2018 at 03:18:43PM -0700, Douglas Anderson wrote:
> > diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
> > index f3cadda45f07..9a3f952de6ed 100644
> > --- a/kernel/debug/debug_core.c
> > +++ b/kernel/debug/debug_core.c
> > @@ -55,6 +55,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include 
> >  #include 
> > @@ -220,6 +221,39 @@ int __weak kgdb_skipexception(int exception, struct 
> > pt_regs *regs)
> >   return 0;
> >  }
> >
> > +/*
> > + * Default (weak) implementation for kgdb_roundup_cpus
> > + */
> > +
> > +static DEFINE_PER_CPU(call_single_data_t, kgdb_roundup_csd);
> > +
> > +void __weak kgdb_call_nmi_hook(void *ignored)
> > +{
> > + kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
> > +}
> > +
> > +void __weak kgdb_roundup_cpus(void)
> > +{
> > + call_single_data_t *csd;
> > + int cpu;
> > +
> > + for_each_cpu(cpu, cpu_online_mask) {
> > + csd = &per_cpu(kgdb_roundup_csd, cpu);
> > + smp_call_function_single_async(cpu, csd);
> > + }
>
> smp_call_function() automatically skips the calling CPU but this code does
> not. It isn't a hard bug since kgdb_nmicallback() does a re-entrancy
> check but I'd still prefer to skip the calling CPU.

I'll incorporate this into the next version.


> As mentioned in another part of the thread we can also add robustness
> by skipping a cpu where csd->flags != 0 (and adding an appropriately
> large comment regarding why). Doing the check directly is abusing
> internal knowledge that smp.c normally keeps to itself so an accessor
> of some kind would be needed.

Sure.  I could add smp_async_func_finished() that just looked like:

int smp_async_func_finished(call_single_data_t *csd)
{
  return !(csd->flags & CSD_FLAG_LOCK);
}

My understanding of all the mutual exclusion / memory barrier concepts
employed by smp.c is pretty weak, though.  I'm hoping that it's safe
to just access the structure and check the bit directly.

...but do you think adding a generic accessor like this is better than
just keeping track of this in kgdb directly?  I could avoid the
accessor by adding a "rounding_up" member to "struct
debuggerinfo_struct" and doing something like this in roundup:

  /* If it didn't round up last time, don't try again */
  if (kgdb_info[cpu].rounding_up)
continue

  kgdb_info[cpu].rounding_up = true
  smp_call_function_single_async(cpu, csd);

...and then in kgdb_nmicallback() I could just add:

  kgdb_info[cpu].rounding_up = false

In that case we're not adding a generic accessor to smp.c that most
people should never use.


I'll wait to hear back from you if you think the accessor is OK.  It
seems like it might be nice not to have to add something to smp.c just
for this one use case.


> > +}
> > +
> > +static void kgdb_generic_roundup_init(void)
> > +{
> > + call_single_data_t *csd;
> > + int cpu;
> > +
> > + for_each_possible_cpu(cpu) {
> > + csd = &per_cpu(kgdb_roundup_csd, cpu);
> > + csd->func = kgdb_call_nmi_hook;
> > + }
> > +}
>
> I can't help noticing this code is very similar to kgdb_roundup_cpus. Do
> we really gain much from ahead-of-time initializing csd->func?

Oh!  Right...  At first I thought about just trying to put the "csd"
on the stack in kgdb_roundup_cpus() but then I realized that it needed
to persist past the end of kgdb_roundup_cpus().  ...and once I gave up
on the idea of putting it on the stack I decided I needed the init.

...but you're right that I don't really.  The only thing I'm initting
is the function pointer and it totally wouldn't hurt to just init that
over and over again every time kgdb_roundup_cpus() is called.

-Doug

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v3 6/6] arch: Move initrd= parsing into do_mounts_initrd.c

2018-10-31 Thread Florian Fainelli
ARC, ARM, ARM64 and Unicore32 are all capable of parsing the "initrd="
command line parameter to allow specifying the physical address and size
of an initrd. Move that parsing into init/do_mounts_initrd.c such that
we no longer duplicate that logic.

Signed-off-by: Florian Fainelli 
---
 arch/arc/mm/init.c   | 25 +
 arch/arm/mm/init.c   | 17 -
 arch/arm64/mm/init.c | 18 --
 arch/unicore32/mm/init.c | 18 --
 init/do_mounts_initrd.c  | 17 +
 5 files changed, 22 insertions(+), 73 deletions(-)

diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ba145065c579..55879a9dee0d 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -79,24 +79,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
base, TO_MB(size), !in_use ? "Not used":"");
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static int __init early_initrd(char *p)
-{
-   unsigned long start, size;
-   char *endp;
-
-   start = memparse(p, &endp);
-   if (*endp == ',') {
-   size = memparse(endp + 1, NULL);
-
-   initrd_start = (unsigned long)__va(start);
-   initrd_end = (unsigned long)__va(start + size);
-   }
-   return 0;
-}
-early_param("initrd", early_initrd);
-#endif
-
 /*
  * First memory setup routine called from setup_arch()
  * 1. setup swapper's mm @init_mm
@@ -141,8 +123,11 @@ void __init setup_arch_memory(void)
memblock_reserve(low_mem_start, __pa(_end) - low_mem_start);
 
 #ifdef CONFIG_BLK_DEV_INITRD
-   if (initrd_start)
-   memblock_reserve(__pa(initrd_start), initrd_end - initrd_start);
+   if (phys_initrd_size) {
+   memblock_reserve(phys_initrd_start, phys_initrd_size);
+   initrd_start = (unsigned long)__va(phys_initrd_start);
+   initrd_end = initrd_start + phys_initrd_size;
+   }
 #endif
 
early_init_fdt_reserve_self();
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 4bfa08e27319..58ec68709606 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -52,23 +52,6 @@ unsigned long __init __clear_cr(unsigned long mask)
 #endif
 
 #ifdef CONFIG_BLK_DEV_INITRD
-static int __init early_initrd(char *p)
-{
-   phys_addr_t start;
-   unsigned long size;
-   char *endp;
-
-   start = memparse(p, &endp);
-   if (*endp == ',') {
-   size = memparse(endp + 1, NULL);
-
-   phys_initrd_start = start;
-   phys_initrd_size = size;
-   }
-   return 0;
-}
-early_param("initrd", early_initrd);
-
 static int __init parse_tag_initrd(const struct tag *tag)
 {
pr_warn("ATAG_INITRD is deprecated; "
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 00ef2166bb73..d95a6cb205b8 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -62,24 +62,6 @@
 s64 memstart_addr __ro_after_init = -1;
 phys_addr_t arm64_dma_phys_limit __ro_after_init;
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static int __init early_initrd(char *p)
-{
-   unsigned long start, size;
-   char *endp;
-
-   start = memparse(p, &endp);
-   if (*endp == ',') {
-   size = memparse(endp + 1, NULL);
-
-   phys_initrd_start = start;
-   phys_initrd_size = size;
-   }
-   return 0;
-}
-early_param("initrd", early_initrd);
-#endif
-
 #ifdef CONFIG_KEXEC_CORE
 /*
  * reserve_crashkernel() - reserves memory for crash kernel
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index f2f815d46846..99acdb829a7e 100644
--- a/arch/unicore32/mm/init.c
+++ b/arch/unicore32/mm/init.c
@@ -31,24 +31,6 @@
 
 #include "mm.h"
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static int __init early_initrd(char *p)
-{
-   unsigned long start, size;
-   char *endp;
-
-   start = memparse(p, &endp);
-   if (*endp == ',') {
-   size = memparse(endp + 1, NULL);
-
-   phys_initrd_start = start;
-   phys_initrd_size = size;
-   }
-   return 0;
-}
-early_param("initrd", early_initrd);
-#endif
-
 /*
  * This keeps memory configuration data used by a couple memory
  * initialization functions, as well as show_mem() for the skipping
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 45865b72f4ea..732d21f4a637 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -27,6 +27,23 @@ static int __init no_initrd(char *str)
 
 __setup("noinitrd", no_initrd);
 
+static int __init early_initrd(char *p)
+{
+   phys_addr_t start;
+   unsigned long size;
+   char *endp;
+
+   start = memparse(p, &endp);
+   if (*endp == ',') {
+   size = memparse(endp + 1, NULL);
+
+   phys_initrd_start = start;
+   phys_initrd_size = size;
+   }
+   return 0;
+}
+early_param("initrd", early_initrd);
+
 static int init_linuxrc(struct subprocess_info *info, struct cred *new)
 {
ksys_u

[PATCH v3 5/6] of/fdt: Remove custom __early_init_dt_declare_initrd() implementation

2018-10-31 Thread Florian Fainelli
Now that ARM64 uses phys_initrd_start/phys_initrd_size, we can get rid
of its custom __early_init_dt_declare_initrd() which causes a fair
amount of objects rebuild when changing CONFIG_BLK_DEV_INITRD. In order
to make sure ARM64 does not produce a BUG() when VM debugging is turned
on though, we must avoid early calls to __va() which is what
__early_init_dt_declare_initrd() does and wrap this around to avoid
running that code on ARM64.

Signed-off-by: Florian Fainelli 
---
 arch/arm64/include/asm/memory.h |  8 
 drivers/of/fdt.c| 15 ++-
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index b96442960aea..dc3ca21ba240 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -168,14 +168,6 @@
 #define IOREMAP_MAX_ORDER  (PMD_SHIFT)
 #endif
 
-#ifdef CONFIG_BLK_DEV_INITRD
-#define __early_init_dt_declare_initrd(__start, __end) \
-   do {\
-   initrd_start = (__start);   \
-   initrd_end = (__end);   \
-   } while (0)
-#endif
-
 #ifndef __ASSEMBLY__
 
 #include 
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e34cb49231b5..4118a344cf45 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -892,15 +892,20 @@ const void * __init of_flat_dt_match_machine(const void 
*default_match,
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-#ifndef __early_init_dt_declare_initrd
 static void __early_init_dt_declare_initrd(unsigned long start,
   unsigned long end)
 {
-   initrd_start = (unsigned long)__va(start);
-   initrd_end = (unsigned long)__va(end);
-   initrd_below_start_ok = 1;
+   /* ARM64 would cause a BUG to occur here when CONFIG_DEBUG_VM is
+* enabled since __va() is called too early. ARM64 does make use
+* of phys_initrd_start/phys_initrd_size so we can skip this
+* conversion.
+*/
+   if (!IS_ENABLED(CONFIG_ARM64)) {
+   initrd_start = (unsigned long)__va(start);
+   initrd_end = (unsigned long)__va(end);
+   initrd_below_start_ok = 1;
+   }
 }
-#endif
 
 /**
  * early_init_dt_check_for_initrd - Decode initrd location from flat tree
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v3 2/6] arch: Make phys_initrd_start and phys_initrd_size global variables

2018-10-31 Thread Florian Fainelli
Make phys_initrd_start and phys_initrd_size global variables declared in
init/do_mounts_initrd.c such that we can later have generic code in
drivers/of/fdt.c populate those variables for us.

This requires both the ARM and unicore32 implementations to be properly
guarded against CONFIG_BLK_DEV_INITRD, and also initialize the variables
to the expected default values (unicore32).

Signed-off-by: Florian Fainelli 
---
 arch/arm/mm/init.c   |  5 ++---
 arch/unicore32/mm/init.c | 10 +++---
 include/linux/initrd.h   |  3 +++
 init/do_mounts_initrd.c  |  3 +++
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 0cc8e04295a4..87d59a53861d 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -51,9 +51,7 @@ unsigned long __init __clear_cr(unsigned long mask)
 }
 #endif
 
-static phys_addr_t phys_initrd_start __initdata = 0;
-static unsigned long phys_initrd_size __initdata = 0;
-
+#ifdef CONFIG_BLK_DEV_INITRD
 static int __init early_initrd(char *p)
 {
phys_addr_t start;
@@ -90,6 +88,7 @@ static int __init parse_tag_initrd2(const struct tag *tag)
 }
 
 __tagtable(ATAG_INITRD2, parse_tag_initrd2);
+#endif
 
 static void __init find_limits(unsigned long *min, unsigned long *max_low,
   unsigned long *max_high)
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index 8f8699e62bd5..f2f815d46846 100644
--- a/arch/unicore32/mm/init.c
+++ b/arch/unicore32/mm/init.c
@@ -31,9 +31,7 @@
 
 #include "mm.h"
 
-static unsigned long phys_initrd_start __initdata = 0x0100;
-static unsigned long phys_initrd_size __initdata = SZ_8M;
-
+#ifdef CONFIG_BLK_DEV_INITRD
 static int __init early_initrd(char *p)
 {
unsigned long start, size;
@@ -49,6 +47,7 @@ static int __init early_initrd(char *p)
return 0;
 }
 early_param("initrd", early_initrd);
+#endif
 
 /*
  * This keeps memory configuration data used by a couple memory
@@ -157,6 +156,11 @@ void __init uc32_memblock_init(struct meminfo *mi)
memblock_reserve(__pa(_text), _end - _text);
 
 #ifdef CONFIG_BLK_DEV_INITRD
+   if (!phys_initrd_size) {
+   phys_initrd_start = 0x0100;
+   phys_initrd_size = SZ_8M;
+   }
+
if (phys_initrd_size) {
memblock_reserve(phys_initrd_start, phys_initrd_size);
 
diff --git a/include/linux/initrd.h b/include/linux/initrd.h
index 84b423044088..14beaff9b445 100644
--- a/include/linux/initrd.h
+++ b/include/linux/initrd.h
@@ -21,4 +21,7 @@ extern int initrd_below_start_ok;
 extern unsigned long initrd_start, initrd_end;
 extern void free_initrd_mem(unsigned long, unsigned long);
 
+extern phys_addr_t phys_initrd_start;
+extern unsigned long phys_initrd_size;
+
 extern unsigned int real_root_dev;
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index d1a5d885ce13..45865b72f4ea 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -16,6 +16,9 @@ int initrd_below_start_ok;
 unsigned int real_root_dev;/* do_proc_dointvec cannot handle kdev_t */
 static int __initdata mount_initrd = 1;
 
+phys_addr_t phys_initrd_start __initdata;
+unsigned long phys_initrd_size __initdata;
+
 static int __init no_initrd(char *str)
 {
mount_initrd = 0;
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v3 1/6] nds32: Remove phys_initrd_start and phys_initrd_size

2018-10-31 Thread Florian Fainelli
This will conflict with a subsequent change making phys_initrd_start and
phys_initrd_size global variables. nds32 does not make use of those nor
provides a suitable declarations so just get rid of them.

Signed-off-by: Florian Fainelli 
---
 arch/nds32/mm/init.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/nds32/mm/init.c b/arch/nds32/mm/init.c
index c713d2ad55dc..32f55a24ccbb 100644
--- a/arch/nds32/mm/init.c
+++ b/arch/nds32/mm/init.c
@@ -22,8 +22,6 @@
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 DEFINE_SPINLOCK(anon_alias_lock);
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
-extern unsigned long phys_initrd_start;
-extern unsigned long phys_initrd_size;
 
 /*
  * empty_zero_page is a special page that is used for
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v3 4/6] arm64: Utilize phys_initrd_start/phys_initrd_size

2018-10-31 Thread Florian Fainelli
ARM64 is the only architecture that re-defines
__early_init_dt_declare_initrd() in order for that function to populate
initrd_start/initrd_end with physical addresses instead of virtual
addresses. Instead of having an override we can leverage
drivers/of/fdt.c populating phys_initrd_start/phys_initrd_size to
populate those variables for us.

Signed-off-by: Florian Fainelli 
---
 arch/arm64/mm/init.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 3cf87341859f..00ef2166bb73 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -72,8 +72,8 @@ static int __init early_initrd(char *p)
if (*endp == ',') {
size = memparse(endp + 1, NULL);
 
-   initrd_start = start;
-   initrd_end = start + size;
+   phys_initrd_start = start;
+   phys_initrd_size = size;
}
return 0;
 }
@@ -408,14 +408,14 @@ void __init arm64_memblock_init(void)
memblock_add(__pa_symbol(_text), (u64)(_end - _text));
}
 
-   if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) {
+   if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) {
/*
 * Add back the memory we just removed if it results in the
 * initrd to become inaccessible via the linear mapping.
 * Otherwise, this is a no-op
 */
-   u64 base = initrd_start & PAGE_MASK;
-   u64 size = PAGE_ALIGN(initrd_end) - base;
+   u64 base = phys_initrd_start & PAGE_MASK;
+   u64 size = PAGE_ALIGN(phys_initrd_size);
 
/*
 * We can only add back the initrd memory if we don't end up
@@ -460,12 +460,11 @@ void __init arm64_memblock_init(void)
 */
memblock_reserve(__pa_symbol(_text), _end - _text);
 #ifdef CONFIG_BLK_DEV_INITRD
-   if (initrd_start) {
-   memblock_reserve(initrd_start, initrd_end - initrd_start);
-
+   if (phys_initrd_size) {
/* the generic initrd code expects virtual addresses */
-   initrd_start = __phys_to_virt(initrd_start);
-   initrd_end = __phys_to_virt(initrd_end);
+   initrd_start = __phys_to_virt(phys_initrd_start);
+   initrd_end = initrd_start + phys_initrd_size;
+   initrd_below_start_ok = 0;
}
 #endif
 
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v3 3/6] of/fdt: Populate phys_initrd_start/phys_initrd_size from FDT

2018-10-31 Thread Florian Fainelli
Now that we have central and global variables holding the physical
address and size of the initrd, we can have
early_init_dt_check_for_initrd() populate
phys_initrd_start/phys_initrd_size for us.

This allows us to remove a chunk of code from arch/arm/mm/init.c
introduced with commit 65939301acdb ("arm: set initrd_start/initrd_end
for fdt scan").

Signed-off-by: Florian Fainelli 
---
 arch/arm/mm/init.c | 6 --
 drivers/of/fdt.c   | 2 ++
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 87d59a53861d..4bfa08e27319 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -236,12 +236,6 @@ static void __init arm_initrd_init(void)
phys_addr_t start;
unsigned long size;
 
-   /* FDT scan will populate initrd_start */
-   if (initrd_start && !phys_initrd_size) {
-   phys_initrd_start = __virt_to_phys(initrd_start);
-   phys_initrd_size = initrd_end - initrd_start;
-   }
-
initrd_start = initrd_end = 0;
 
if (!phys_initrd_size)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 76c83c1ffeda..e34cb49231b5 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -925,6 +925,8 @@ static void __init early_init_dt_check_for_initrd(unsigned 
long node)
end = of_read_number(prop, len/4);
 
__early_init_dt_declare_initrd(start, end);
+   phys_initrd_start = start;
+   phys_initrd_size = end - start;
 
pr_debug("initrd_start=0x%llx  initrd_end=0x%llx\n",
 (unsigned long long)start, (unsigned long long)end);
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v3 0/6] arm64: Get rid of __early_init_dt_declare_initrd()

2018-10-31 Thread Florian Fainelli
Hi all,

Changes in v3:

- use C conditionals in drivers/of/fdt.c
- added check on phys_initrd_size in arch/arm64/mm/init.c to determine
  whether initrd_start must be populated
- fixed a build warning with ARC that was just missing an (unsigned
  long) cast

Changes in v2:

- get rid of ARCH_HAS_PHYS_INITRD and instead define
  phys_initrd_start/phys_initrd_size in init/do_mounts_initrd.c

- make __early_init_dt_declare_initrd() account for ARM64 specific
  behavior with __va() when having CONFIG_DEBUG_VM enabled

- consolidate early_initrd() command line parsing into
  init/do_mounts_initrd.c

Because phys_initrd_start/phys_initrd_size are now compiled in
ini/do_mounts_initrd.c which is only built with CONFIG_BLK_DEV_INITRD=y,
we need to be a bit careful about the uses throughout architecture
specific code.

Previous discussions/submissions list here:

v3:
https://www.spinics.net/lists/arm-kernel/msg683566.html
v2:
https://lkml.org/lkml/2018/10/25/4

Florian Fainelli (6):
  nds32: Remove phys_initrd_start and phys_initrd_size
  arch: Make phys_initrd_start and phys_initrd_size global variables
  of/fdt: Populate phys_initrd_start/phys_initrd_size from FDT
  arm64: Utilize phys_initrd_start/phys_initrd_size
  of/fdt: Remove custom __early_init_dt_declare_initrd() implementation
  arch: Move initrd= parsing into do_mounts_initrd.c

 arch/arc/mm/init.c  | 25 +
 arch/arm/mm/init.c  | 28 ++--
 arch/arm64/include/asm/memory.h |  8 
 arch/arm64/mm/init.c| 33 +++--
 arch/nds32/mm/init.c|  2 --
 arch/unicore32/mm/init.c| 24 +---
 drivers/of/fdt.c| 17 -
 include/linux/initrd.h  |  3 +++
 init/do_mounts_initrd.c | 20 
 9 files changed, 54 insertions(+), 106 deletions(-)

-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] ARC: [plat-hsdk] Enable DW APB GPIO support

2018-10-31 Thread Alexey Brodkin
Hi Vineet,

On Tue, 2018-10-30 at 10:25 -0700, Vineet Gupta wrote:
> On 10/23/18 5:09 AM, Eugeniy Paltsev wrote:
> > Enable GPIO support on HSDK. HSDK SoC includes Synopsys
> > DesignWare DW_apb_gpio IP with 24 GPIOs mapped onto port A.
> > 
> > Signed-off-by: Eugeniy Paltsev 
> 
> @Alexey, u happy with this ?
> 
> -Vineet

Acked-by: Alexey Brodkin 
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] perf: Disable libunwind for ARC & RISCV64

2018-10-31 Thread Alexey Brodkin
libunwind is not yet ported for ARC & RISCV64 and on attempt
to build it for those arches we just get an error message.

If we explicitly disable libunwind it is gracefully handled by
perf build system and it just gets configured to not use it
so perf is still usable even on those arches.

Signed-off-by: Alexey Brodkin 
Cc: Khem Raj 
---
 meta/recipes-kernel/perf/perf.bb | 4 
 1 file changed, 4 insertions(+)

diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
index af099043e1..bae4948751 100644
--- a/meta/recipes-kernel/perf/perf.bb
+++ b/meta/recipes-kernel/perf/perf.bb
@@ -26,6 +26,10 @@ PACKAGECONFIG[jvmti] = ",NO_JVMTI=1"
 PACKAGECONFIG[audit] = ",NO_LIBAUDIT=1,audit"
 PACKAGECONFIG[manpages] = ",,xmlto-native asciidoc-native"
 
+# libunwind is not yet ported for some architectures
+PACKAGECONFIG_remove_arc = "libunwind"
+PACKAGECONFIG_remove_riscv64 = "libunwind"
+
 DEPENDS = " \
 virtual/${MLPREFIX}libc \
 ${MLPREFIX}elfutils \
-- 
2.16.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 2/2] kgdb: Fix kgdb_roundup_cpus() for arches who used smp_call_function()

2018-10-31 Thread Daniel Thompson
On Tue, Oct 30, 2018 at 03:18:43PM -0700, Douglas Anderson wrote:
> diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
> index f3cadda45f07..9a3f952de6ed 100644
> --- a/kernel/debug/debug_core.c
> +++ b/kernel/debug/debug_core.c
> @@ -55,6 +55,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -220,6 +221,39 @@ int __weak kgdb_skipexception(int exception, struct 
> pt_regs *regs)
>   return 0;
>  }
>  
> +/*
> + * Default (weak) implementation for kgdb_roundup_cpus
> + */
> +
> +static DEFINE_PER_CPU(call_single_data_t, kgdb_roundup_csd);
> +
> +void __weak kgdb_call_nmi_hook(void *ignored)
> +{
> + kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
> +}
> +
> +void __weak kgdb_roundup_cpus(void)
> +{
> + call_single_data_t *csd;
> + int cpu;
> +
> + for_each_cpu(cpu, cpu_online_mask) {
> + csd = &per_cpu(kgdb_roundup_csd, cpu);
> + smp_call_function_single_async(cpu, csd);
> + }

smp_call_function() automatically skips the calling CPU but this code does
not. It isn't a hard bug since kgdb_nmicallback() does a re-entrancy
check but I'd still prefer to skip the calling CPU.

As mentioned in another part of the thread we can also add robustness
by skipping a cpu where csd->flags != 0 (and adding an appropriately
large comment regarding why). Doing the check directly is abusing
internal knowledge that smp.c normally keeps to itself so an accessor
of some kind would be needed.


> +}
> +
> +static void kgdb_generic_roundup_init(void)
> +{
> + call_single_data_t *csd;
> + int cpu;
> +
> + for_each_possible_cpu(cpu) {
> + csd = &per_cpu(kgdb_roundup_csd, cpu);
> + csd->func = kgdb_call_nmi_hook;
> + }
> +}

I can't help noticing this code is very similar to kgdb_roundup_cpus. Do
we really gain much from ahead-of-time initializing csd->func?


Daniel.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 4/6] arm64: Utilize phys_initrd_start/phys_initrd_size

2018-10-31 Thread Florian Fainelli
On 10/31/18 12:03 AM, Mike Rapoport wrote:
> On Tue, Oct 30, 2018 at 04:07:19PM -0700, Florian Fainelli wrote:
>> ARM64 is the only architecture that re-defines
>> __early_init_dt_declare_initrd() in order for that function to populate
>> initrd_start/initrd_end with physical addresses instead of virtual
>> addresses. Instead of having an override we can leverage
>> drivers/of/fdt.c populating phys_initrd_start/phys_initrd_size to
>> populate those variables for us.
>>
>> Signed-off-by: Florian Fainelli 
>> ---
>>  arch/arm64/mm/init.c | 21 +
>>  1 file changed, 9 insertions(+), 12 deletions(-)
>>
>> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
>> index 3cf87341859f..e95cee656a55 100644
>> --- a/arch/arm64/mm/init.c
>> +++ b/arch/arm64/mm/init.c
>> @@ -72,8 +72,8 @@ static int __init early_initrd(char *p)
>>  if (*endp == ',') {
>>  size = memparse(endp + 1, NULL);
>>  
>> -initrd_start = start;
>> -initrd_end = start + size;
>> +phys_initrd_start = start;
>> +phys_initrd_size = size;
>>  }
>>  return 0;
>>  }
>> @@ -408,14 +408,14 @@ void __init arm64_memblock_init(void)
>>  memblock_add(__pa_symbol(_text), (u64)(_end - _text));
>>  }
>>  
>> -if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) {
>> +if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) {
>>  /*
>>   * Add back the memory we just removed if it results in the
>>   * initrd to become inaccessible via the linear mapping.
>>   * Otherwise, this is a no-op
>>   */
>> -u64 base = initrd_start & PAGE_MASK;
>> -u64 size = PAGE_ALIGN(initrd_end) - base;
>> +u64 base = phys_initrd_start & PAGE_MASK;
>> +u64 size = PAGE_ALIGN(phys_initrd_size);
>>  
>>  /*
>>   * We can only add back the initrd memory if we don't end up
>> @@ -460,13 +460,10 @@ void __init arm64_memblock_init(void)
>>   */
>>  memblock_reserve(__pa_symbol(_text), _end - _text);
>>  #ifdef CONFIG_BLK_DEV_INITRD
>> -if (initrd_start) {
> 
> There may be no initrd at all, so the condition here would rather become
> 
>   if (phys_initrd_start)

Or use phys_initrd_size, which would be consistent with how other
architectures typically test for this.

> 
>> -memblock_reserve(initrd_start, initrd_end - initrd_start);
>> -
>> -/* the generic initrd code expects virtual addresses */
>> -initrd_start = __phys_to_virt(initrd_start);
>> -initrd_end = __phys_to_virt(initrd_end);
>> -}
>> +/* the generic initrd code expects virtual addresses */
>> +initrd_start = __phys_to_virt(phys_initrd_start);
>> +initrd_end = initrd_start + phys_initrd_size;
>> +initrd_below_start_ok = 0;
>>  #endif
> 
> I also wonder what is the reason to keep memstart_addr randomization and
> initrd setup interleaved?
> 
> What we have now is roughly:
> 
> 1) set memstart_addr
> 2) enforce memory_limit
> 3) reserve initrd
> 4) randomize memstart_addr
> 5) reserve text + data
> 6) reserve initrd again and set virtual addresses of initrd_{start,end}
> 
> Maybe it's possible to merge (3) into (6) ?

That's kind of orthogonal to this patch series, but it's a valid
question, not sure I would want to tackle that just now though :)
-- 
Florian

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 2/2] kgdb: Fix kgdb_roundup_cpus() for arches who used smp_call_function()

2018-10-31 Thread Daniel Thompson
On Wed, Oct 31, 2018 at 02:49:26PM +0100, Peter Zijlstra wrote:
> On Tue, Oct 30, 2018 at 03:18:43PM -0700, Douglas Anderson wrote:
> > Looking closely at it, it seems like a really bad idea to be calling
> > local_irq_enable() in kgdb_roundup_cpus().  If nothing else that seems
> > like it could violate spinlock semantics and cause a deadlock.
> > 
> > Instead, let's use a private csd alongside
> > smp_call_function_single_async() to round up the other CPUs.  Using
> > smp_call_function_single_async() doesn't require interrupts to be
> > enabled so we can remove the offending bit of code.
> 
> You might want to mention that the only reason this isn't a deadlock
> itself is because there is a timeout on waiting for the slaves to
> check-in.

dbg_master_lock must be owned to call kgdb_roundup_cpus() so
the calls to smp_call_function_single_async() should never deadlock the
calling CPU unless there has been a previous failure to round up (e.g.
cores that cannot react to the round up signal).

When there is a failure to round up when we resume, there is a window (before
whatever locks that prevented the IPI being serviced are released) during which
the system will deadlock if the debugger is re entered.

I don't think there is any point trying to round up a CPU that did not
previously respond... it should still have an IPI pending. The deadlock
can be eliminated by getting the round up code to avoid CPUs whose csd->flags
are non-zero either by checking the flag in the kgdb code or adding something
like smp_trycall_function_single_async().


Daniel.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v4] devres: Align data[] to ARCH_KMALLOC_MINALIGN

2018-10-31 Thread Alexey Brodkin
Initially we bumped into problem with 32-bit aligned atomic64_t
on ARC, see [1]. And then during quite lengthly discussion Peter Z.
mentioned ARCH_KMALLOC_MINALIGN which IMHO makes perfect sense.
If allocation is done by plain kmalloc() obtained buffer will be
ARCH_KMALLOC_MINALIGN aligned and then why buffer obtained via
devm_kmalloc() should have any other alignment?

This way we at least get the same behavior for both types of
allocation.

[1] http://lists.infradead.org/pipermail/linux-snps-arc/2018-July/004009.html
[2] http://lists.infradead.org/pipermail/linux-snps-arc/2018-July/004036.html

Signed-off-by: Alexey Brodkin 
Cc: Greg Kroah-Hartman 
Cc: Geert Uytterhoeven 
Cc: David Laight 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vineet Gupta 
Cc: Will Deacon 
Cc: Greg KH 
Cc:  # 4.8+
---

Changes v3 -> v4:

 * Use ARCH_KMALLOC_MINALIGN for alignment instead of "8" [Peter]

Changes v2 -> v3:

 * Align explicitly to 8 bytes [David]
 * Rephrased in-line comment [David]
 * Added more techinical details to commit message [Greg]
 * Mention more alignment options in commit message [Geert]

Changes v1 -> v2:

 * Reworded commit message
 * Inserted comment right in source [Thomas]

 drivers/base/devres.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 4aaf00d2098b..e038e2b3b7ea 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -26,8 +26,14 @@ struct devres_node {
 
 struct devres {
struct devres_node  node;
-   /* -- 3 pointers */
-   unsigned long long  data[]; /* guarantee ull alignment */
+   /*
+* Some archs want to perform DMA into kmalloc caches
+* and need a guaranteed alignment larger than
+* the alignment of a 64-bit integer.
+* Thus we use ARCH_KMALLOC_MINALIGN here and get exactly the same
+* buffer alignment as if it was allocated by plain kmalloc().
+*/
+   u8 __aligned(ARCH_KMALLOC_MINALIGN) data[];
 };
 
 struct devres_group {
-- 
2.17.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 2/2] kgdb: Fix kgdb_roundup_cpus() for arches who used smp_call_function()

2018-10-31 Thread Peter Zijlstra
On Tue, Oct 30, 2018 at 03:18:43PM -0700, Douglas Anderson wrote:
> Looking closely at it, it seems like a really bad idea to be calling
> local_irq_enable() in kgdb_roundup_cpus().  If nothing else that seems
> like it could violate spinlock semantics and cause a deadlock.
> 
> Instead, let's use a private csd alongside
> smp_call_function_single_async() to round up the other CPUs.  Using
> smp_call_function_single_async() doesn't require interrupts to be
> enabled so we can remove the offending bit of code.

You might want to mention that the only reason this isn't a deadlock
itself is because there is a timeout on waiting for the slaves to
check-in.

> --- a/kernel/debug/debug_core.c
> +++ b/kernel/debug/debug_core.c
> @@ -55,6 +55,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -220,6 +221,39 @@ int __weak kgdb_skipexception(int exception, struct 
> pt_regs *regs)
>   return 0;
>  }
>  
> +/*
> + * Default (weak) implementation for kgdb_roundup_cpus
> + */
> +
> +static DEFINE_PER_CPU(call_single_data_t, kgdb_roundup_csd);
> +
> +void __weak kgdb_call_nmi_hook(void *ignored)
> +{
> + kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
> +}
> +
> +void __weak kgdb_roundup_cpus(void)
> +{
> + call_single_data_t *csd;
> + int cpu;
> +
> + for_each_cpu(cpu, cpu_online_mask) {
> + csd = &per_cpu(kgdb_roundup_csd, cpu);
> + smp_call_function_single_async(cpu, csd);
> + }
> +}
> +
> +static void kgdb_generic_roundup_init(void)
> +{
> + call_single_data_t *csd;
> + int cpu;
> +
> + for_each_possible_cpu(cpu) {
> + csd = &per_cpu(kgdb_roundup_csd, cpu);
> + csd->func = kgdb_call_nmi_hook;
> + }
> +}
> +
>  /*
>   * Some architectures need cache flushes when we set/clear a
>   * breakpoint:
> @@ -993,6 +1027,8 @@ int kgdb_register_io_module(struct kgdb_io 
> *new_dbg_io_ops)
>   return -EBUSY;
>   }
>  
> + kgdb_generic_roundup_init();
> +
>   if (new_dbg_io_ops->init) {
>   err = new_dbg_io_ops->init();
>   if (err) {

That's a little bit of overhead for those architectures not using that
generic code; but I suppose we can live with that.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 5/6] of/fdt: Remove custom __early_init_dt_declare_initrd() implementation

2018-10-31 Thread Rob Herring
On Tue, Oct 30, 2018 at 6:07 PM Florian Fainelli  wrote:
>
> Now that ARM64 uses phys_initrd_start/phys_initrd_size, we can get rid
> of its custom __early_init_dt_declare_initrd() which causes a fair
> amount of objects rebuild when changing CONFIG_BLK_DEV_INITRD. In order
> to make sure ARM64 does not produce a BUG() when VM debugging is turned
> on though, we must avoid early calls to __va() which is what
> __early_init_dt_declare_initrd() does and wrap this around to avoid
> running that code on ARM64.
>
> Signed-off-by: Florian Fainelli 
> ---
>  arch/arm64/include/asm/memory.h | 8 
>  drivers/of/fdt.c| 9 +++--
>  2 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index b96442960aea..dc3ca21ba240 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -168,14 +168,6 @@
>  #define IOREMAP_MAX_ORDER  (PMD_SHIFT)
>  #endif
>
> -#ifdef CONFIG_BLK_DEV_INITRD
> -#define __early_init_dt_declare_initrd(__start, __end) \
> -   do {\
> -   initrd_start = (__start);   \
> -   initrd_end = (__end);   \
> -   } while (0)
> -#endif
> -
>  #ifndef __ASSEMBLY__
>
>  #include 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index e34cb49231b5..f2b5becae96a 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -892,15 +892,20 @@ const void * __init of_flat_dt_match_machine(const void 
> *default_match,
>  }
>
>  #ifdef CONFIG_BLK_DEV_INITRD
> -#ifndef __early_init_dt_declare_initrd
>  static void __early_init_dt_declare_initrd(unsigned long start,
>unsigned long end)
>  {
> +   /* ARM64 would cause a BUG to occur here when CONFIG_DEBUG_VM is
> +* enabled since __va() is called too early. ARM64 does make use
> +* of phys_initrd_start/phys_initrd_size so we can skip this
> +* conversion.
> +*/
> +#if (!IS_ENABLED(CONFIG_ARM64))

Use 'if' not '#if'. Use C code rather than preprocessor whenever possible.

> initrd_start = (unsigned long)__va(start);
> initrd_end = (unsigned long)__va(end);
> initrd_below_start_ok = 1;
> -}
>  #endif
> +}
>
>  /**
>   * early_init_dt_check_for_initrd - Decode initrd location from flat tree
> --
> 2.17.1
>

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 4/6] arm64: Utilize phys_initrd_start/phys_initrd_size

2018-10-31 Thread Mike Rapoport
On Tue, Oct 30, 2018 at 04:07:19PM -0700, Florian Fainelli wrote:
> ARM64 is the only architecture that re-defines
> __early_init_dt_declare_initrd() in order for that function to populate
> initrd_start/initrd_end with physical addresses instead of virtual
> addresses. Instead of having an override we can leverage
> drivers/of/fdt.c populating phys_initrd_start/phys_initrd_size to
> populate those variables for us.
> 
> Signed-off-by: Florian Fainelli 
> ---
>  arch/arm64/mm/init.c | 21 +
>  1 file changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 3cf87341859f..e95cee656a55 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -72,8 +72,8 @@ static int __init early_initrd(char *p)
>   if (*endp == ',') {
>   size = memparse(endp + 1, NULL);
>  
> - initrd_start = start;
> - initrd_end = start + size;
> + phys_initrd_start = start;
> + phys_initrd_size = size;
>   }
>   return 0;
>  }
> @@ -408,14 +408,14 @@ void __init arm64_memblock_init(void)
>   memblock_add(__pa_symbol(_text), (u64)(_end - _text));
>   }
>  
> - if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_start) {
> + if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) {
>   /*
>* Add back the memory we just removed if it results in the
>* initrd to become inaccessible via the linear mapping.
>* Otherwise, this is a no-op
>*/
> - u64 base = initrd_start & PAGE_MASK;
> - u64 size = PAGE_ALIGN(initrd_end) - base;
> + u64 base = phys_initrd_start & PAGE_MASK;
> + u64 size = PAGE_ALIGN(phys_initrd_size);
>  
>   /*
>* We can only add back the initrd memory if we don't end up
> @@ -460,13 +460,10 @@ void __init arm64_memblock_init(void)
>*/
>   memblock_reserve(__pa_symbol(_text), _end - _text);
>  #ifdef CONFIG_BLK_DEV_INITRD
> - if (initrd_start) {

There may be no initrd at all, so the condition here would rather become

if (phys_initrd_start)

> - memblock_reserve(initrd_start, initrd_end - initrd_start);
> -
> - /* the generic initrd code expects virtual addresses */
> - initrd_start = __phys_to_virt(initrd_start);
> - initrd_end = __phys_to_virt(initrd_end);
> - }
> + /* the generic initrd code expects virtual addresses */
> + initrd_start = __phys_to_virt(phys_initrd_start);
> + initrd_end = initrd_start + phys_initrd_size;
> + initrd_below_start_ok = 0;
>  #endif

I also wonder what is the reason to keep memstart_addr randomization and
initrd setup interleaved?

What we have now is roughly:

1) set memstart_addr
2) enforce memory_limit
3) reserve initrd
4) randomize memstart_addr
5) reserve text + data
6) reserve initrd again and set virtual addresses of initrd_{start,end}

Maybe it's possible to merge (3) into (6) ?

>   early_init_fdt_scan_reserved_mem();
> -- 
> 2.17.1
> 

-- 
Sincerely yours,
Mike.


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc