Re: [PATCH 1/2] mm: Fix struct page layout on 32-bit systems

2021-04-20 Thread Vineet Gupta
On 4/20/21 12:07 AM, Arnd Bergmann wrote:
> On Tue, Apr 20, 2021 at 5:10 AM Matthew Wilcox  wrote:
>> On Tue, Apr 20, 2021 at 02:48:17AM +0000, Vineet Gupta wrote:
>>>> 32-bit architectures which expect 8-byte alignment for 8-byte integers
>>>> and need 64-bit DMA addresses (arc, arm, mips, ppc) had their struct
>>>> page inadvertently expanded in 2019.
>>> FWIW, ARC doesn't require 8 byte alignment for 8 byte integers. This is
>>> only needed for 8-byte atomics due to the requirements of LLOCKD/SCOND
>>> instructions.
>> Ah, like x86?  OK, great, I'll drop your arch from the list of
>> affected.  Thanks!
> I mistakenly assumed that i386 and m68k were the only supported
> architectures with 32-bit alignment on u64. I checked it now and found
>
> $ for i in /home/arnd/cross/x86_64/gcc-10.1.0-nolibc/*/bin/*-gcc ; do
> echo `echo 'int a = __alignof__(long long);' | $i -xc - -Wall -S -o- |
> grep -A1 a: | tail -n 1 | cut -f 3 -d\   `
> ${i#/home/arnd/cross/x86_64/gcc-10.1.0-nolibc/*/bin/} ; done
> 8 aarch64-linux-gcc
> 8 alpha-linux-gcc
> 4 arc-linux-gcc
> 8 arm-linux-gnueabi-gcc
> 8 c6x-elf-gcc
> 4 csky-linux-gcc
> 4 h8300-linux-gcc
> 8 hppa-linux-gcc
> 8 hppa64-linux-gcc
> 8 i386-linux-gcc
> 8 ia64-linux-gcc
> 2 m68k-linux-gcc
> 4 microblaze-linux-gcc
> 8 mips-linux-gcc
> 8 mips64-linux-gcc
> 8 nds32le-linux-gcc
> 4 nios2-linux-gcc
> 4 or1k-linux-gcc
> 8 powerpc-linux-gcc
> 8 powerpc64-linux-gcc
> 8 riscv32-linux-gcc
> 8 riscv64-linux-gcc
> 8 s390-linux-gcc
> 4 sh2-linux-gcc
> 4 sh4-linux-gcc
> 8 sparc-linux-gcc
> 8 sparc64-linux-gcc
> 8 x86_64-linux-gcc
> 8 xtensa-linux-gcc
>
> which means that half the 32-bit architectures do this. This may
> cause more problems when arc and/or microblaze want to support
> 64-bit kernels and compat mode in the future on their latest hardware,
> as that means duplicating the x86 specific hacks we have for compat.
>
> What is alignof(u64) on 64-bit arc?

$ echo 'int a = __alignof__(long long);' | arc64-linux-gnu-gcc -xc - 
-Wall -S -o - | grep -A1 a: | tail -n 1 | cut -f 3
8

Yeah ARCv2 alignment of 4 for 64-bit data was a bit of surprise finding 
for me as well. When 64-bit load/stores were initially targeted by the 
internal Metaware compiler (llvm based) they decided to keep alignment 
to 4 still (granted hardware allowed this) and then gcc guys decided to 
follow the same ABI. I only found this by accident :-)

Can you point me to some specifics on the compat issue. For better of 
worse, arc64 does''t have a compat 32-bit mode, so everything is 
64-on-64 or 32-on-32 (ARC32 flavor of ARCv3)

Thx,
-Vineet


Re: [PATCH 1/2] mm: Fix struct page layout on 32-bit systems

2021-04-19 Thread Vineet Gupta
Hi Matthew,

On 4/16/21 7:45 PM, Matthew Wilcox wrote:
> Replacement patch to fix compiler warning.
>
> From: "Matthew Wilcox (Oracle)" 
> Date: Fri, 16 Apr 2021 16:34:55 -0400
> Subject: [PATCH 1/2] mm: Fix struct page layout on 32-bit systems
> To: bro...@redhat.com
> Cc: linux-kernel@vger.kernel.org,
>  linux...@kvack.org,
>  net...@vger.kernel.org,
>  linuxppc-...@lists.ozlabs.org,
>  linux-arm-ker...@lists.infradead.org,
>  linux-m...@vger.kernel.org,
>  ilias.apalodi...@linaro.org,
>  mcr...@linux.microsoft.com,
>  grygorii.stras...@ti.com,
>  a...@kernel.org,
>  h...@lst.de,
>  linux-snps-...@lists.infradead.org,
>  mho...@kernel.org,
>  mgor...@suse.de
>
> 32-bit architectures which expect 8-byte alignment for 8-byte integers
> and need 64-bit DMA addresses (arc, arm, mips, ppc) had their struct
> page inadvertently expanded in 2019.

FWIW, ARC doesn't require 8 byte alignment for 8 byte integers. This is 
only needed for 8-byte atomics due to the requirements of LLOCKD/SCOND 
instructions.

> When the dma_addr_t was added,
> it forced the alignment of the union to 8 bytes, which inserted a 4 byte
> gap between 'flags' and the union.
>
> Fix this by storing the dma_addr_t in one or two adjacent unsigned longs.
> This restores the alignment to that of an unsigned long, and also fixes a
> potential problem where (on a big endian platform), the bit used to denote
> PageTail could inadvertently get set, and a racing get_user_pages_fast()
> could dereference a bogus compound_head().
>
> Fixes: c25fff7171be ("mm: add dma_addr_t to struct page")
> Signed-off-by: Matthew Wilcox (Oracle) 
> ---
>   include/linux/mm_types.h |  4 ++--
>   include/net/page_pool.h  | 12 +++-
>   net/core/page_pool.c | 12 +++-
>   3 files changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index 6613b26a8894..5aacc1c10a45 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -97,10 +97,10 @@ struct page {
>   };
>   struct {/* page_pool used by netstack */
>   /**
> -  * @dma_addr: might require a 64-bit value even on
> +  * @dma_addr: might require a 64-bit value on
>* 32-bit architectures.
>*/
> - dma_addr_t dma_addr;
> + unsigned long dma_addr[2];
>   };
>   struct {/* slab, slob and slub */
>   union {
> diff --git a/include/net/page_pool.h b/include/net/page_pool.h
> index b5b195305346..ad6154dc206c 100644
> --- a/include/net/page_pool.h
> +++ b/include/net/page_pool.h
> @@ -198,7 +198,17 @@ static inline void page_pool_recycle_direct(struct 
> page_pool *pool,
>   
>   static inline dma_addr_t page_pool_get_dma_addr(struct page *page)
>   {
> - return page->dma_addr;
> + dma_addr_t ret = page->dma_addr[0];
> + if (sizeof(dma_addr_t) > sizeof(unsigned long))
> + ret |= (dma_addr_t)page->dma_addr[1] << 16 << 16;
> + return ret;
> +}
> +
> +static inline void page_pool_set_dma_addr(struct page *page, dma_addr_t addr)
> +{
> + page->dma_addr[0] = addr;
> + if (sizeof(dma_addr_t) > sizeof(unsigned long))
> + page->dma_addr[1] = addr >> 16 >> 16;
>   }
>   
>   static inline bool is_page_pool_compiled_in(void)
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index ad8b0707af04..f014fd8c19a6 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -174,8 +174,10 @@ static void page_pool_dma_sync_for_device(struct 
> page_pool *pool,
> struct page *page,
> unsigned int dma_sync_size)
>   {
> + dma_addr_t dma_addr = page_pool_get_dma_addr(page);
> +
>   dma_sync_size = min(dma_sync_size, pool->p.max_len);
> - dma_sync_single_range_for_device(pool->p.dev, page->dma_addr,
> + dma_sync_single_range_for_device(pool->p.dev, dma_addr,
>pool->p.offset, dma_sync_size,
>pool->p.dma_dir);
>   }
> @@ -226,7 +228,7 @@ static struct page *__page_pool_alloc_pages_slow(struct 
> page_pool *pool,
>   put_page(page);
>   return NULL;
>   }
> - page->dma_addr = dma;
> + page_pool_set_dma_addr(page, dma);
>   
>   if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV)
>   page_pool_dma_sync_for_device(pool, page, pool->p.max_len);
> @@ -294,13 +296,13 @@ void page_pool_release_page(struct page_pool *pool, 
> struct page *page)
>*/
>   goto skip_dma_unmap;
>   
> - dma = page->dma_addr;
> + dma = page_pool_get_dma_addr(page);
>   
> - /* When page is unmapped, it cannot be returned our pool */
> + /* When page is unmapped, it cannot be 

Re: [PATCH] arc/kernel/signal.c: Fix couple of typos

2021-04-07 Thread Vineet Gupta
On 3/23/21 10:52 PM, Bhaskar Chowdhury wrote:
> s/unconditonally/unconditionally/
> s/gaurantees/guarantees/
>
> Signed-off-by: Bhaskar Chowdhury 

And this one too.

Thx,
-Vineet

> ---
>   arch/arc/kernel/signal.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c
> index a78d8f745a67..cf1788fd3812 100644
> --- a/arch/arc/kernel/signal.c
> +++ b/arch/arc/kernel/signal.c
> @@ -259,7 +259,7 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, 
> struct pt_regs *regs)
>   regs->r2 = (unsigned long)>uc;
>
>   /*
> -  * small optim to avoid unconditonally calling do_sigaltstack
> +  * small optim to avoid unconditionally calling do_sigaltstack
>* in sigreturn path, now that we only have rt_sigreturn
>*/
>   magic = MAGIC_SIGALTSTK;
> @@ -391,7 +391,7 @@ void do_signal(struct pt_regs *regs)
>   void do_notify_resume(struct pt_regs *regs)
>   {
>   /*
> -  * ASM glue gaurantees that this is only called when returning to
> +  * ASM glue guarantees that this is only called when returning to
>* user mode
>*/
>   if (test_thread_flag(TIF_NOTIFY_RESUME))
> --
> 2.30.1
>



Re: [PATCH] arcc/kernel/process: Few mundane typo fixes

2021-04-07 Thread Vineet Gupta
On 3/22/21 5:51 AM, Bhaskar Chowdhury wrote:
> s/defintion/definition/
> s/succeded/succeeded/
> s/commiting/committing/
> s/interrutps/interrupts/
>
> Signed-off-by: Bhaskar Chowdhury 

I've squashed all your 3 patches into one (no reason to break them out) 
and queued for 5.13.

Thx,
-Vineet

> ---
> diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
> index d838d0d57696..3793876f42d9 100644
> --- a/arch/arc/kernel/process.c
> +++ b/arch/arc/kernel/process.c
> @@ -50,14 +50,14 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, 
> expected, int, new)
>   int ret;
>
>   /*
> -  * This is only for old cores lacking LLOCK/SCOND, which by defintion
> +  * This is only for old cores lacking LLOCK/SCOND, which by definition
>* can't possibly be SMP. Thus doesn't need to be SMP safe.
>* And this also helps reduce the overhead for serializing in
>* the UP case
>*/
>   WARN_ON_ONCE(IS_ENABLED(CONFIG_SMP));
>
> - /* Z indicates to userspace if operation succeded */
> + /* Z indicates to userspace if operation succeeded */
>   regs->status32 &= ~STATUS_Z_MASK;
>
>   ret = access_ok(uaddr, sizeof(*uaddr));
> @@ -107,7 +107,7 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, 
> expected, int, new)
>
>   void arch_cpu_idle(void)
>   {
> - /* Re-enable interrupts <= default irq priority before commiting SLEEP 
> */
> + /* Re-enable interrupts <= default irq priority before committing SLEEP 
> */
>   const unsigned int arg = 0x10 | ARCV2_IRQ_DEF_PRIO;
>
>   __asm__ __volatile__(
> @@ -120,7 +120,7 @@ void arch_cpu_idle(void)
>
>   void arch_cpu_idle(void)
>   {
> - /* sleep, but enable both set E1/E2 (levels of interrutps) before 
> committing */
> + /* sleep, but enable both set E1/E2 (levels of interrupts) before 
> committing */
>   __asm__ __volatile__("sleep 0x3 \n");
>   }
>
> --
> 2.31.0
>



Re: [PATCH V2 6/6] mm: Drop redundant HAVE_ARCH_TRANSPARENT_HUGEPAGE

2021-04-01 Thread Vineet Gupta
On 3/31/21 11:44 PM, Anshuman Khandual wrote:
> HAVE_ARCH_TRANSPARENT_HUGEPAGE has duplicate definitions on platforms that
> subscribe it. Drop these reduntant definitions and instead just select it
> on applicable platforms.

Acked-by: Vineet Gupta#arc

Thx,
-Vineet


Re: [PATCH V2 1/6] mm: Generalize ARCH_HAS_CACHE_LINE_SIZE

2021-04-01 Thread Vineet Gupta
On 3/31/21 11:44 PM, Anshuman Khandual wrote:
> ARCH_HAS_CACHE_LINE_SIZE config has duplicate definitions on platforms that
> subscribe it. Instead, just make it a generic option which can be selected
> on applicable platforms. This change reduces code duplication and makes it
> cleaner.

Acked-by: Vineet Gupta#arc


Thx,
-Vineet


Re: [PATCH v2] mm: Move mem_init_print_info() into mm_init()

2021-03-17 Thread Vineet Gupta
On 3/16/21 6:52 PM, Kefeng Wang wrote:
> mem_init_print_info() is called in mem_init() on each architecture,
> and pass NULL argument, so using void argument and move it into mm_init().
> 
> Acked-by: Dave Hansen 
> Signed-off-by: Kefeng Wang 

Acked-by: Vineet Gupta 

Thx,
-Vineet


Re: [PATCH] arc: kernel: Return -EFAULT if copy_to_user() fails

2021-03-02 Thread Vineet Gupta

On 3/1/21 4:05 AM, Wang Qing wrote:

The copy_to_user() function returns the number of bytes remaining to be
copied, but we want to return -EFAULT if the copy doesn't complete.

Signed-off-by: Wang Qing 


Acked-by: Vineet Gupta 

Do you want me to pick this up via ARC tree ?

Thx,
-Vineet


---
  arch/arc/kernel/signal.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c
index a78d8f7..fdbe06c
--- a/arch/arc/kernel/signal.c
+++ b/arch/arc/kernel/signal.c
@@ -96,7 +96,7 @@ stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs 
*regs,
 sizeof(sf->uc.uc_mcontext.regs.scratch));
err |= __copy_to_user(>uc.uc_sigmask, set, sizeof(sigset_t));
  
-	return err;

+   return err ? -EFAULT : 0;
  }
  
  static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf)

@@ -110,7 +110,7 @@ static int restore_usr_regs(struct pt_regs *regs, struct 
rt_sigframe __user *sf)
&(sf->uc.uc_mcontext.regs.scratch),
sizeof(sf->uc.uc_mcontext.regs.scratch));
if (err)
-   return err;
+   return -EFAULT;
  
  	set_current_blocked();

regs->bta= uregs.scratch.bta;





Re: [PATCH 10/11] pragma once: delete few backslashes

2021-03-02 Thread Vineet Gupta

On 2/28/21 9:05 AM, Alexey Dobriyan wrote:

 From 251ca5673886b5bb0a42004944290b9d2b267a4a Mon Sep 17 00:00:00 2001
From: Alexey Dobriyan 
Date: Fri, 19 Feb 2021 13:37:24 +0300
Subject: [PATCH 10/11] pragma once: delete few backslashes

Some macros contain one backslash too many and end up being the last
macro in a header file. When #pragma once conversion script truncates
the last #endif and whitespace before it, such backslash triggers
a warning about "OMG file ends up in a backslash-newline".

Needless to say I don't want to handle another case in my script,
so delete useless backslashes instead.

Signed-off-by: Alexey Dobriyan 


Acked-by: Vineet Gupta#arch/arc bits

Thx,
-Vineet


---
  arch/arc/include/asm/cacheflush.h  | 2 +-
  drivers/net/ethernet/mellanox/mlxsw/item.h | 2 +-
  include/linux/once.h   | 2 +-
  include/media/drv-intf/exynos-fimc.h   | 2 +-
  4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arc/include/asm/cacheflush.h 
b/arch/arc/include/asm/cacheflush.h
index e201b4b1655a..46704c341b17 100644
--- a/arch/arc/include/asm/cacheflush.h
+++ b/arch/arc/include/asm/cacheflush.h
@@ -112,6 +112,6 @@ do {
\
  } while (0)
  
  #define copy_from_user_page(vma, page, vaddr, dst, src, len)		\

-   memcpy(dst, src, len);  \
+   memcpy(dst, src, len)
  
  #endif

diff --git a/drivers/net/ethernet/mellanox/mlxsw/item.h 
b/drivers/net/ethernet/mellanox/mlxsw/item.h
index e92cadc98128..cc0133401dd1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/item.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/item.h
@@ -504,6 +504,6 @@ mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 
index, u8 val) \
return __mlxsw_item_bit_array_set(buf,  
\
  &__ITEM_NAME(_type, _cname, _iname),  
\
  index, val);  
\
-}  
\
+}
  
  #endif

diff --git a/include/linux/once.h b/include/linux/once.h
index 9225ee6d96c7..0af450ff94a5 100644
--- a/include/linux/once.h
+++ b/include/linux/once.h
@@ -55,6 +55,6 @@ void __do_once_done(bool *done, struct static_key_true 
*once_key,
  #define get_random_once(buf, nbytes)   \
DO_ONCE(get_random_bytes, (buf), (nbytes))
  #define get_random_once_wait(buf, nbytes)\
-   DO_ONCE(get_random_bytes_wait, (buf), (nbytes))  \
+   DO_ONCE(get_random_bytes_wait, (buf), (nbytes))
  
  #endif /* _LINUX_ONCE_H */

diff --git a/include/media/drv-intf/exynos-fimc.h 
b/include/media/drv-intf/exynos-fimc.h
index 6b9ef631d6bb..6c5fbdacf4b5 100644
--- a/include/media/drv-intf/exynos-fimc.h
+++ b/include/media/drv-intf/exynos-fimc.h
@@ -152,6 +152,6 @@ static inline struct exynos_video_entity 
*vdev_to_exynos_video_entity(
  #define fimc_pipeline_call(ent, op, args...)\
((!(ent) || !(ent)->pipe) ? -ENOENT : \
(((ent)->pipe->ops && (ent)->pipe->ops->op) ? \
-   (ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD))  \
+   (ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD))
  
  #endif /* S5P_FIMC_H_ */






Re: [PATCH] arc: Replace lkml.org links with lore

2021-02-15 Thread Vineet Gupta

On 2/10/21 3:28 PM, Kees Cook wrote:

As started by commit 05a5f51ca566 ("Documentation: Replace lkml.org
links with lore"), replace lkml.org links with lore to better use a
single source that's more likely to stay available long-term.

Signed-off-by: Kees Cook 


Acked-by: Vineet Gupta 

Let me know if you want me to pick this up.

Thx,
-Vineet


---
  arch/arc/include/asm/irqflags-compact.h | 8 ++--
  arch/arc/mm/dma.c   | 2 +-
  arch/arc/plat-axs10x/axs10x.c   | 2 +-
  arch/arc/plat-hsdk/platform.c   | 2 +-
  4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/arc/include/asm/irqflags-compact.h 
b/arch/arc/include/asm/irqflags-compact.h
index 863d63ad18d6..0d63e568d64c 100644
--- a/arch/arc/include/asm/irqflags-compact.h
+++ b/arch/arc/include/asm/irqflags-compact.h
@@ -50,8 +50,12 @@
   * are redone after IRQs are re-enabled (and gcc doesn't reuse stale register)
   *
   * Noted at the time of Abilis Timer List corruption
- * Orig Bug + Rejected solution: https://lkml.org/lkml/2013/3/29/67
- * Reasoning   : https://lkml.org/lkml/2013/4/8/15
+ *
+ * Orig Bug + Rejected solution:
+ * 
https://lore.kernel.org/lkml/1364553218-31255-1-git-send-email-vgu...@synopsys.com
+ *
+ * Reasoning:
+ * 
https://lore.kernel.org/lkml/ca+55afyfwjpsvqm6m266tkrg_zxjzz-nyejpmxyqxbrr42m...@mail.gmail.com
   *
   **/
  
diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c

index 517988e60cfc..2a7fbbb83b70 100644
--- a/arch/arc/mm/dma.c
+++ b/arch/arc/mm/dma.c
@@ -32,7 +32,7 @@ void arch_dma_prep_coherent(struct page *page, size_t size)
  
  /*

   * Cache operations depending on function and direction argument, inspired by
- * https://lkml.org/lkml/2018/5/18/979
+ * https://lore.kernel.org/lkml/20180518175004.gf17...@n2100.armlinux.org.uk
   * "dma_sync_*_for_cpu and direction=TO_DEVICE (was Re: [PATCH 02/20]
   * dma-mapping: provide a generic dma-noncoherent implementation)"
   *
diff --git a/arch/arc/plat-axs10x/axs10x.c b/arch/arc/plat-axs10x/axs10x.c
index 63ea5a606ecd..b821df7b0089 100644
--- a/arch/arc/plat-axs10x/axs10x.c
+++ b/arch/arc/plat-axs10x/axs10x.c
@@ -50,7 +50,7 @@ static void __init axs10x_enable_gpio_intc_wire(void)
 * Current implementation of "irq-dw-apb-ictl" driver doesn't work well
 * with stacked INTCs. In particular problem happens if its master INTC
 * not yet instantiated. See discussion here -
-* https://lkml.org/lkml/2015/3/4/755
+* https://lore.kernel.org/lkml/54f6fe2c.7020...@synopsys.com
 *
 * So setup the first gpio block as a passive pass thru and hide it from
 * DT hardware topology - connect MB intc directly to cpu intc
diff --git a/arch/arc/plat-hsdk/platform.c b/arch/arc/plat-hsdk/platform.c
index b3ea1fa11f87..c4a875b22352 100644
--- a/arch/arc/plat-hsdk/platform.c
+++ b/arch/arc/plat-hsdk/platform.c
@@ -52,7 +52,7 @@ static void __init hsdk_enable_gpio_intc_wire(void)
 * Current implementation of "irq-dw-apb-ictl" driver doesn't work well
 * with stacked INTCs. In particular problem happens if its master INTC
 * not yet instantiated. See discussion here -
-* https://lkml.org/lkml/2015/3/4/755
+* https://lore.kernel.org/lkml/54f6fe2c.7020...@synopsys.com
 *
 * So setup the first gpio block as a passive pass thru and hide it from
 * DT hardware topology - connect intc directly to cpu intc





Re: [PATCH 03/18] arch: arc: Remove CONFIG_OPROFILE support

2021-01-14 Thread Vineet Gupta
On 1/14/21 3:35 AM, Viresh Kumar wrote:
> The "oprofile" user-space tools don't use the kernel OPROFILE support
> any more, and haven't in a long time. User-space has been converted to
> the perf interfaces.
>
> Remove the old oprofile's architecture specific support.
>
> Suggested-by: Christoph Hellwig 
> Suggested-by: Linus Torvalds 
> Signed-off-by: Viresh Kumar 

Acked-by: Vineet Gupta 

I presume this doesn't need to go through ARC tree.

-Vineet

> ---
>   arch/arc/Kconfig   |  1 -
>   arch/arc/Makefile  |  2 --
>   arch/arc/oprofile/Makefile | 10 --
>   arch/arc/oprofile/common.c | 23 ---
>   4 files changed, 36 deletions(-)
>   delete mode 100644 arch/arc/oprofile/Makefile
>   delete mode 100644 arch/arc/oprofile/common.c
>
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index b55ca77f619b..bc8d6aecfbbd 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -37,7 +37,6 @@ config ARC
>   select HAVE_KPROBES
>   select HAVE_KRETPROBES
>   select HAVE_MOD_ARCH_SPECIFIC
> - select HAVE_OPROFILE
>   select HAVE_PERF_EVENTS
>   select HANDLE_DOMAIN_IRQ
>   select IRQ_DOMAIN
> diff --git a/arch/arc/Makefile b/arch/arc/Makefile
> index 578bdbbb0fa7..4392c9c189c4 100644
> --- a/arch/arc/Makefile
> +++ b/arch/arc/Makefile
> @@ -96,8 +96,6 @@ core-$(CONFIG_ARC_PLAT_TB10X)   += arch/arc/plat-tb10x/
>   core-$(CONFIG_ARC_PLAT_AXS10X)  += arch/arc/plat-axs10x/
>   core-$(CONFIG_ARC_SOC_HSDK) += arch/arc/plat-hsdk/
>   
> -drivers-$(CONFIG_OPROFILE)   += arch/arc/oprofile/
> -
>   libs-y  += arch/arc/lib/ $(LIBGCC)
>   
>   boot:= arch/arc/boot
> diff --git a/arch/arc/oprofile/Makefile b/arch/arc/oprofile/Makefile
> deleted file mode 100644
> index 698367bb41d0..
> --- a/arch/arc/oprofile/Makefile
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0
> -obj-$(CONFIG_OPROFILE) += oprofile.o
> -
> -DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
> - oprof.o cpu_buffer.o buffer_sync.o \
> - event_buffer.o oprofile_files.o \
> - oprofilefs.o oprofile_stats.o \
> - timer_int.o )
> -
> -oprofile-y   := $(DRIVER_OBJS) common.o
> diff --git a/arch/arc/oprofile/common.c b/arch/arc/oprofile/common.c
> deleted file mode 100644
> index 86bf5899533b..
> --- a/arch/arc/oprofile/common.c
> +++ /dev/null
> @@ -1,23 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
> - *
> - * Based on orig code from @author John Levon 
> - */
> -
> -#include 
> -#include 
> -
> -int __init oprofile_arch_init(struct oprofile_operations *ops)
> -{
> - /*
> -  * A failure here, forces oprofile core to switch to Timer based PC
> -  * sampling, which will happen if say perf is not enabled/available
> -  */
> - return oprofile_perf_init(ops);
> -}
> -
> -void oprofile_arch_exit(void)
> -{
> - oprofile_perf_exit();
> -}



[GIT PULL] ARC fixes for 5.11-rc3

2021-01-10 Thread Vineet Gupta
Hi Linus,

I ran into boot failures on ARC, which went unnoticed. This pull request 
addresses that.

Thx,
-Vineet
-->
The following changes since commit f6e7a024bfe5e11d91ccff46bb576e3fb5a516ea:

   Merge tag 'arc-5.11-rc3' of 
git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc (2021-01-05 
12:46:27 -0800)

are available in the Git repository at:

   git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git/ 
tags/arc-5.11-rc3-fixes

for you to fetch changes up to e8deee4f1543eda9b75278f63322f412cad52f6a:

   ARC: [hsdk]: Enable FPU_SAVE_RESTORE (2021-01-08 13:46:58 -0800)


ARC fixes for 5.11-rc3

  - Address the 2nd boot failure due to snafu in signal handling code
(first was generic console ttynull issue)

  - miscll other fixes


Randy Dunlap (1):
   arch/arc: add copy_user_page() to  to fix build error 
on ARC

Vineet Gupta (3):
   include/soc: remove headers for EZChip NPS
   ARC: unbork 5.11 bootup: fix snafu in _TIF_NOTIFY_SIGNAL handling
   ARC: [hsdk]: Enable FPU_SAVE_RESTORE

  arch/arc/include/asm/page.h |   1 +
  arch/arc/kernel/entry.S |   2 +-
  arch/arc/plat-hsdk/Kconfig  |   1 +
  include/soc/nps/common.h| 172 

  include/soc/nps/mtm.h   |  59 ---
  5 files changed, 3 insertions(+), 232 deletions(-)
  delete mode 100644 include/soc/nps/common.h
  delete mode 100644 include/soc/nps/mtm.h


Re: [PATCH 1/1] Revert "init/console: Use ttynull as a fallback when there is no console"

2021-01-08 Thread Vineet Gupta
On 1/8/21 9:45 AM, Petr Mladek wrote:
> On Thu 2021-01-07 11:38:36, Linus Torvalds wrote:
>> On Thu, Jan 7, 2021 at 11:15 AM Greg Kroah-Hartman
>>  wrote:
>>> Linus, can you take this directly, or is this going through some other
>>> tree?
>> I was _assuming_ that I'd get it through the normal printk pull
>> request, it doesn't seem to be that timing-critical.
>>
>> But if there is nothing else pending, I can certainly take it directly
>> as that patch too.
> This is the only printk-related fix at the moment.
>
> I have just pushed v2 (updated commit message, tags) into
> printk/linux.git for linux-next. It is the patch sent as
> https://urldefense.com/v3/__https://lore.kernel.org/lkml/20210108114847.23469-1-pmla...@suse.com/__;!!A4F2R9G_pg!P3n1xyAl156-9Gxs8S-k_6obYq-XjXYYWe1_yGYLUmCFRfU7sqjBq4XE1wuZoiZN$
>
> Feel free to push v2 directly. Or I will create pull request the
> following week after it spends few days in linux-next.

Please have it upstream in the upcoming rc since this affects ARC booting.

-Vineet


Re: ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console)

2021-01-07 Thread Vineet Gupta

On 1/7/21 7:48 PM, Sergey Senozhatsky wrote:

On (21/01/07 09:58), Vineet Gupta wrote:

On 1/7/21 9:04 AM, Petr Mladek wrote:

On Thu 2021-01-07 08:43:16, Vineet Gupta wrote:

Hi John,

On 1/7/21 1:02 AM, John Ogness wrote:

Hi Vineet,

On 2021-01-06, Vineet Gupta  wrote:

This breaks ARC booting (no output on console).


Could you provide the kernel boot arguments that you use? This series is
partly about addressing users that have used boot arguments that are
technically incorrect (even if had worked). Seeing the boot arguments of
users that are not experiencing problems may help to reveal some of the
unusual console usages until now.



Kernel command line: earlycon=uart8250,mmio32,0xf0005000,115200n8
console=ttyS0,115200n8 debug print-fatal-signals=1


This is strange, the problematic patch should use ttynull
only as a fallback. It should not be used when a particular console
is defined on the command line.


What happens in my case is console_on_rootfs() doesn't find /dev/console and
switching to ttynull. /dev is not present because devtmpfs doesn't automount
for initramfs.


I wonder if we'll move the nulltty fallback logic into printk code [1]
will it fix the problem?

[1] https://lore.kernel.org/lkml/X6x%2FAxD1qanC6evJ@jagdpanzerIV.localdomain/


Your reasoning in the post above makes total sense.

I tired the patch: adding register_ttynull_console() call in 
console_device(), removing from console_on_rootfs() band that works too.



| Warning: unable to open an initial console. Fallback to ttynull.
| Warning: Failed to add ttynull console. No stdin, stdout, and stderr 
for the init process!

| Freeing unused kernel memory: 3096K
| This architecture does not have kernel memory protection.
| Run /init as init process
| with arguments:
|/init
|  with environment:
|HOME=/
|TERM=linux
| Starting System logger (syslogd)
| Bringing up loopback device
| Starting inetd
| Mounting Posix Mqueue filesys
| 
CONFIG_INITRAMFS_SOURCE="~/arc/RAMFS/archs/ramfs_2011-GNU-2020-03-glibc-2.32-tiny"

| **
|   Welcome to ARCLinux
| **
| [ARCLinux]#


Re: ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console)

2021-01-07 Thread Vineet Gupta

On 1/7/21 9:04 AM, Petr Mladek wrote:

On Thu 2021-01-07 08:43:16, Vineet Gupta wrote:

Hi John,

On 1/7/21 1:02 AM, John Ogness wrote:

Hi Vineet,

On 2021-01-06, Vineet Gupta  wrote:

This breaks ARC booting (no output on console).


Could you provide the kernel boot arguments that you use? This series is
partly about addressing users that have used boot arguments that are
technically incorrect (even if had worked). Seeing the boot arguments of
users that are not experiencing problems may help to reveal some of the
unusual console usages until now.



Kernel command line: earlycon=uart8250,mmio32,0xf0005000,115200n8
console=ttyS0,115200n8 debug print-fatal-signals=1


This is strange, the problematic patch should use ttynull
only as a fallback. It should not be used when a particular console
is defined on the command line.


What happens in my case is console_on_rootfs() doesn't find /dev/console 
and switching to ttynull. /dev is not present because devtmpfs doesn't 
automount for initramfs.



The only explanation would be that ttyS0 gets registered too late
and ttynull is added as a fallback in the meantime.


I don't know if ttyS0 console should have registered already but even if 
it did - the /dev node missing would not have helped ?




Anyway, I propose the revert the problematic patch for 5.11-rc3,
see
https://lore.kernel.org/lkml/20210107164400.17904-2-pmla...@suse.com/
This mystery is a good reason to avoid bigger changes at this stage.

Best Regards,
Petr





Re: ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console)

2021-01-07 Thread Vineet Gupta

Hi John,

On 1/7/21 1:02 AM, John Ogness wrote:

Hi Vineet,

On 2021-01-06, Vineet Gupta  wrote:

This breaks ARC booting (no output on console).


Could you provide the kernel boot arguments that you use? This series is
partly about addressing users that have used boot arguments that are
technically incorrect (even if had worked). Seeing the boot arguments of
users that are not experiencing problems may help to reveal some of the
unusual console usages until now.



Kernel command line: earlycon=uart8250,mmio32,0xf0005000,115200n8 
console=ttyS0,115200n8 debug print-fatal-signals=1


And we do have serial driver built-in.

Thx,
-Vineet


[PATCH] ARC: unbork 5.11 bootup: fix snafu in _TIF_NOTIFY_SIGNAL handling

2021-01-06 Thread Vineet Gupta
Linux 5.11.rcX was failing to boot on ARC HSDK board. Turns out we have
a couple of issues, this being the first one, and I'm to blame as I
didn't pay attention during review.

TIF_NOTIFY_SIGNAL support requires checking multiple TIF_* bits in
kernel return code path. Old code only needed to check a single bit so
BBIT0  worked. New code needs to check multiple bits so
AND  instruction. So needs to use bit mask variant _TIF_SIGPENDING

Cc: Jens Axboe 
Fixes: 53855e12588743ea128 ("arc: add support for TIF_NOTIFY_SIGNAL")
Link: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/issues/34
Signed-off-by: Vineet Gupta 
---
 arch/arc/kernel/entry.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
index 1f5308abf36d..1743506081da 100644
--- a/arch/arc/kernel/entry.S
+++ b/arch/arc/kernel/entry.S
@@ -307,7 +307,7 @@ resume_user_mode_begin:
mov r0, sp  ; pt_regs for arg to do_signal()/do_notify_resume()
 
GET_CURR_THR_INFO_FLAGS   r9
-   and.f  0,  r9, TIF_SIGPENDING|TIF_NOTIFY_SIGNAL
+   and.f  0,  r9, _TIF_SIGPENDING|_TIF_NOTIFY_SIGNAL
bz .Lchk_notify_resume
 
; Normal Trap/IRQ entry only saves Scratch (caller-saved) regs
-- 
2.25.1



ARC no console output (was Re: [PATCH 1/2] init/console: Use ttynull as a fallback when there is no console)

2021-01-06 Thread Vineet Gupta

+CC Buildroot folks

Hi Petr,

On 11/11/20 5:54 AM, Petr Mladek wrote:

stdin, stdout, and stderr standard I/O stream are created for the init
process. They are not available when there is no console registered
for /dev/console. It might lead to a crash when the init process
tries to use them, see the commit 48021f98130880dd742 ("printk: handle
blank console arguments passed in.").

Normally, ttySX and ttyX consoles are used as a fallback when no consoles
are defined via the command line, device tree, or SPCR. But there
will be no console registered when an invalid console name is configured
or when the configured consoles do not exist on the system.

Users even try to avoid the console intentionally, for example,
by using console="" or console=null. It is used on production
systems where the serial port or terminal are not visible to
users. Pushing messages to these consoles would just unnecessary
slowdown the system.

Make sure that stdin, stdout, stderr, and /dev/console are always
available by a fallback to the existing ttynull driver. It has
been implemented for exactly this purpose but it was used only
when explicitly configured.

Signed-off-by: Petr Mladek 



--- a/init/main.c
+++ b/init/main.c
@@ -1470,8 +1470,14 @@ void __init console_on_rootfs(void)
struct file *file = filp_open("/dev/console", O_RDWR, 0);
  
  	if (IS_ERR(file)) {

-   pr_err("Warning: unable to open an initial console.\n");
-   return;
+   pr_err("Warning: unable to open an initial console. Fallback to 
ttynull.\n");
+   register_ttynull_console();
+
+   file = filp_open("/dev/console", O_RDWR, 0);
+   if (IS_ERR(file)) {
+   pr_err("Warning: Failed to add ttynull console. No stdin, 
stdout, and stderr for the init process!\n");
+   return;
+   }



This breaks ARC booting (no output on console).

Our Buildroot based setup has dynamic /dev where /dev/console doesn't 
exist statically and there's a primoridla /init shell script which does 
following


/bin/mount -t devtmpfs devtmpfs /dev
exec 0/dev/console
exec 2>/dev/console
exec /sbin/init "$@"

Buildroot has had this way of handling missing /dev/console since 2011 
[1] and [2].


Please advise what needs to be done to unbork boot. Otherwise this seems 
like a kernel change which breaks user-space and needs to be backed-out 
(or perhaps conditionalize on CONFIG_NULL_TTY. I'm surprised it hasn't 
been reported by any other  embedded folks


Thx,
-Vineet

[1] http://lists.busybox.net/pipermail/buildroot/2011-July/044505.html
[2] http://lists.busybox.net/pipermail/buildroot/2011-August/044832.html


Re: [PATCH v3] arch/arc: add copy_user_page() to to fix build error on ARC

2021-01-04 Thread Vineet Gupta
On 1/4/21 7:44 PM, Randy Dunlap wrote:
> fs/dax.c uses copy_user_page() but ARC does not provide that interface,
> resulting in a build error.
> 
> Provide copy_user_page() in .
> 
> ../fs/dax.c: In function 'copy_cow_page_dax':
> ../fs/dax.c:702:2: error: implicit declaration of function 'copy_user_page'; 
> did you mean 'copy_to_user_page'? [-Werror=implicit-function-declaration]
> 
> Reported-by: kernel test robot 
> Signed-off-by: Randy Dunlap 
> Cc: Vineet Gupta 
> Cc: linux-snps-...@lists.infradead.org
> Cc: Dan Williams 
> #Acked-by: Vineet Gupta  # v1
> Cc: Andrew Morton 
> Cc: Matthew Wilcox 
> Cc: Jan Kara 
> Cc: linux-fsde...@vger.kernel.org
> Cc: linux-nvd...@lists.01.org
> #Reviewed-by: Ira Weiny  # v2

Added to arc #for-curr.

Thx,
-Vineet

> ---
> v2: rebase, add more Cc:
> v3: add copy_user_page() to arch/arc/include/asm/page.h
> 
>   arch/arc/include/asm/page.h |1 +
> 
> --- lnx-511-rc1.orig/arch/arc/include/asm/page.h
> +++ lnx-511-rc1/arch/arc/include/asm/page.h
> @@ -10,6 +10,7 @@
>   #ifndef __ASSEMBLY__
>   
>   #define clear_page(paddr)   memset((paddr), 0, PAGE_SIZE)
> +#define copy_user_page(to, from, vaddr, pg)  copy_page(to, from)
>   #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
>   
>   struct vm_area_struct;
> 



[GIT PULL] ARC updates for 5.11-rc3

2021-01-04 Thread Vineet Gupta
Hi Linus,

Happy New Year. Sorry for the delayed merge window material - holidays 
got in the way.

Things are quieter on upstreaming front as we are mostly focusing on 
ARCv3/ARC64 port.

Please pull.

Thx,
-Vineet
--->
The following changes since commit b65054597872ce3aefbc6a666385eabdf9e288da:

   Linux 5.10-rc6 (2020-11-29 15:50:50 -0800)

are available in the Git repository at:

   git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git/ 
tags/arc-5.11-rc3

for you to fetch changes up to 3a71e423133a4b1166ffafcb4a7cfa87ddecb910:

   ARC: build: use $(READELF) instead of hard-coded readelf (2020-12-01 
17:24:05 -0800)


ARC updates for 5.11-rc3

  - build system updates from Masahiro Yamada


Masahiro Yamada (6):
   ARC: build: remove non-existing bootpImage from KBUILD_IMAGE
   ARC: build: add uImage.lzma to the top-level target
   ARC: build: add boot_targets to PHONY
   ARC: build: move symlink creation to arch/arc/Makefile to avoid race
   ARC: build: remove unneeded extra-y
   ARC: build: use $(READELF) instead of hard-coded readelf

  arch/arc/Makefile  | 20 +---
  arch/arc/boot/Makefile | 18 --
  2 files changed, 17 insertions(+), 21 deletions(-)


[irqchip: irq/irqchip-next] drivers/irqchip: Remove EZChip NPS interrupt controller

2020-12-11 Thread irqchip-bot for Vineet Gupta
The following commit has been merged into the irq/irqchip-next branch of 
irqchip:

Commit-ID: 04e7f423f4a96ad492fd51bf2234b8982400ab5f
Gitweb:
https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/04e7f423f4a96ad492fd51bf2234b8982400ab5f
Author:Vineet Gupta 
AuthorDate:Thu, 05 Nov 2020 13:22:09 -08:00
Committer: Marc Zyngier 
CommitterDate: Fri, 11 Dec 2020 14:47:50 

drivers/irqchip: Remove EZChip NPS interrupt controller

NPS platform has been removed from ARC port and there are no in-tree
users of it now. So RIP !

Signed-off-by: Vineet Gupta 
Signed-off-by: Marc Zyngier 
Cc: Thomas Gleixner 
Cc: Jason Cooper 
Cc: Marc Zyngier 
Cc: linux-kernel@vger.kernel.org
Link: https://lore.kernel.org/r/20201105212210.1891598-3-vgu...@synopsys.com
---
 drivers/irqchip/Kconfig |   7 +-
 drivers/irqchip/Makefile|   1 +-
 drivers/irqchip/irq-eznps.c | 165 +---
 3 files changed, 173 deletions(-)
 delete mode 100644 drivers/irqchip/irq-eznps.c

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 2aa79c3..94920a5 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -387,13 +387,6 @@ config LS_SCFG_MSI
 config PARTITION_PERCPU
bool
 
-config EZNPS_GIC
-   bool "NPS400 Global Interrupt Manager (GIM)"
-   depends on ARC || (COMPILE_TEST && !64BIT)
-   select IRQ_DOMAIN
-   help
- Support the EZchip NPS400 global interrupt controller
-
 config STM32_EXTI
bool
select IRQ_DOMAIN
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 94c2885..0ac93bf 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -86,7 +86,6 @@ obj-$(CONFIG_MVEBU_PIC)   += 
irq-mvebu-pic.o
 obj-$(CONFIG_MVEBU_SEI)+= irq-mvebu-sei.o
 obj-$(CONFIG_LS_EXTIRQ)+= irq-ls-extirq.o
 obj-$(CONFIG_LS_SCFG_MSI)  += irq-ls-scfg-msi.o
-obj-$(CONFIG_EZNPS_GIC)+= irq-eznps.o
 obj-$(CONFIG_ARCH_ASPEED)  += irq-aspeed-vic.o irq-aspeed-i2c-ic.o 
irq-aspeed-scu-ic.o
 obj-$(CONFIG_STM32_EXTI)   += irq-stm32-exti.o
 obj-$(CONFIG_QCOM_IRQ_COMBINER)+= qcom-irq-combiner.o
diff --git a/drivers/irqchip/irq-eznps.c b/drivers/irqchip/irq-eznps.c
deleted file mode 100644
index 2a7a388..000
--- a/drivers/irqchip/irq-eznps.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *  - Redistributions of source code must retain the above
- *copyright notice, this list of conditions and the following
- *disclaimer.
- *
- *  - Redistributions in binary form must reproduce the above
- *copyright notice, this list of conditions and the following
- *disclaimer in the documentation and/or other materials
- *provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define NPS_NR_CPU_IRQS 8  /* number of interrupt lines of NPS400 CPU */
-#define NPS_TIMER0_IRQ  3
-
-/*
- * NPS400 core includes an Interrupt Controller (IC) support.
- * All cores can deactivate level irqs at first level control
- * at cores mesh layer called MTM.
- * For devices out side chip e.g. uart, network there is another
- * level called Global Interrupt Manager (GIM).
- * This second level can control level and edge interrupt.
- *
- * NOTE: AUX_IENABLE and CTOP_AUX_IACK are auxiliary registers
- * with private HW copy per CPU.
- */
-
-static void nps400_irq_mask(struct irq_data *irqd)
-{
-   unsigned int ienb;
-   unsigned int irq = irqd_to_hwirq(irqd);
-
-   ienb = read_aux_reg(AUX_IENABLE);
-   ienb &= ~(1 << irq);
-   write_aux_reg(AUX_IENABLE, ienb);
-}
-
-static void nps400_irq_unmask(struct irq_data *irqd)
-{
-   unsigned int ienb;
-   unsigned int irq = irqd_to_hwirq(irqd);
-
-   ienb = r

Re: [PATCH 2/3] drivers/irqchip: Remove EZChip NPS interrupt controller

2020-12-03 Thread Vineet Gupta
On 11/5/20 1:22 PM, Vineet Gupta wrote:
> NPS platform has been removed from ARC port and there are no in-tree
> users of it now. So RIP !
> 
> Cc: Thomas Gleixner 
> Cc: Jason Cooper 
> Cc: Marc Zyngier 
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Vineet Gupta 

Ping !

> ---
>   drivers/irqchip/Kconfig |   7 --
>   drivers/irqchip/Makefile|   1 -
>   drivers/irqchip/irq-eznps.c | 165 
>   3 files changed, 173 deletions(-)
>   delete mode 100644 drivers/irqchip/irq-eznps.c
> 
> diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
> index c6098eee0c7c..7920c3a3017d 100644
> --- a/drivers/irqchip/Kconfig
> +++ b/drivers/irqchip/Kconfig
> @@ -389,13 +389,6 @@ config LS_SCFG_MSI
>   config PARTITION_PERCPU
>   bool
>   
> -config EZNPS_GIC
> - bool "NPS400 Global Interrupt Manager (GIM)"
> - depends on ARC || (COMPILE_TEST && !64BIT)
> - select IRQ_DOMAIN
> - help
> -   Support the EZchip NPS400 global interrupt controller
> -
>   config STM32_EXTI
>   bool
>   select IRQ_DOMAIN
> diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
> index 94c2885882ee..0ac93bfaec61 100644
> --- a/drivers/irqchip/Makefile
> +++ b/drivers/irqchip/Makefile
> @@ -86,7 +86,6 @@ obj-$(CONFIG_MVEBU_PIC) += 
> irq-mvebu-pic.o
>   obj-$(CONFIG_MVEBU_SEI) += irq-mvebu-sei.o
>   obj-$(CONFIG_LS_EXTIRQ) += irq-ls-extirq.o
>   obj-$(CONFIG_LS_SCFG_MSI)   += irq-ls-scfg-msi.o
> -obj-$(CONFIG_EZNPS_GIC)  += irq-eznps.o
>   obj-$(CONFIG_ARCH_ASPEED)   += irq-aspeed-vic.o irq-aspeed-i2c-ic.o 
> irq-aspeed-scu-ic.o
>   obj-$(CONFIG_STM32_EXTI)+= irq-stm32-exti.o
>   obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o
> diff --git a/drivers/irqchip/irq-eznps.c b/drivers/irqchip/irq-eznps.c
> deleted file mode 100644
> index 2a7a38830a8d..
> --- a/drivers/irqchip/irq-eznps.c
> +++ /dev/null
> @@ -1,165 +0,0 @@
> -/*
> - * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
> - *
> - * This software is available to you under a choice of one of two
> - * licenses.  You may choose to be licensed under the terms of the GNU
> - * General Public License (GPL) Version 2, available from the file
> - * COPYING in the main directory of this source tree, or the
> - * OpenIB.org BSD license below:
> - *
> - * Redistribution and use in source and binary forms, with or
> - * without modification, are permitted provided that the following
> - * conditions are met:
> - *
> - *  - Redistributions of source code must retain the above
> - *copyright notice, this list of conditions and the following
> - *disclaimer.
> - *
> - *  - Redistributions in binary form must reproduce the above
> - *copyright notice, this list of conditions and the following
> - *disclaimer in the documentation and/or other materials
> - *provided with the distribution.
> - *
> - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
> - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> - * SOFTWARE.
> - */
> -
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#define NPS_NR_CPU_IRQS 8  /* number of interrupt lines of NPS400 CPU */
> -#define NPS_TIMER0_IRQ  3
> -
> -/*
> - * NPS400 core includes an Interrupt Controller (IC) support.
> - * All cores can deactivate level irqs at first level control
> - * at cores mesh layer called MTM.
> - * For devices out side chip e.g. uart, network there is another
> - * level called Global Interrupt Manager (GIM).
> - * This second level can control level and edge interrupt.
> - *
> - * NOTE: AUX_IENABLE and CTOP_AUX_IACK are auxiliary registers
> - * with private HW copy per CPU.
> - */
> -
> -static void nps400_irq_mask(struct irq_data *irqd)
> -{
> - unsigned int ienb;
> - unsigned int irq = irqd_to_hwirq(irqd);
> -
> - ienb = read_aux_reg(AUX_IENABLE);
> - ienb &= ~(1 << irq);
> - write_aux_reg(AUX_IENABLE, ienb);
> -}
> -
> -static void nps400_irq_unmask(struct irq_data *irqd)
> -{
> - unsigned i

[tip: timers/core] clocksource/drivers/nps: Remove EZChip NPS clocksource driver

2020-12-03 Thread tip-bot2 for Vineet Gupta
The following commit has been merged into the timers/core branch of tip:

Commit-ID: b6ea209ef124dad4045772a759e2aecd191534c0
Gitweb:
https://git.kernel.org/tip/b6ea209ef124dad4045772a759e2aecd191534c0
Author:Vineet Gupta 
AuthorDate:Thu, 05 Nov 2020 13:22:08 -08:00
Committer: Daniel Lezcano 
CommitterDate: Thu, 03 Dec 2020 19:16:18 +01:00

clocksource/drivers/nps: Remove EZChip NPS clocksource driver

NPS platform has been removed from ARC port and there are no in-tree
users of it now. So RIP !

Cc: Daniel Lezcano 
Cc: Thomas Gleixner 
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Vineet Gupta 
Signed-off-by: Daniel Lezcano 
Link: https://lore.kernel.org/r/20201105212210.1891598-2-vgu...@synopsys.com
---
 drivers/clocksource/Kconfig |  10 +-
 drivers/clocksource/Makefile|   1 +-
 drivers/clocksource/timer-nps.c | 284 +---
 3 files changed, 295 deletions(-)
 delete mode 100644 drivers/clocksource/timer-nps.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 68b087b..390c27c 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -275,16 +275,6 @@ config CLKSRC_TI_32K
  This option enables support for Texas Instruments 32.768 Hz 
clocksource
  available on many OMAP-like platforms.
 
-config CLKSRC_NPS
-   bool "NPS400 clocksource driver" if COMPILE_TEST
-   depends on !PHYS_ADDR_T_64BIT
-   select CLKSRC_MMIO
-   select TIMER_OF if OF
-   help
- NPS400 clocksource support.
- It has a 64-bit counter with update rate up to 1000MHz.
- This counter is accessed via couple of 32-bit memory-mapped registers.
-
 config CLKSRC_STM32
bool "Clocksource for STM32 SoCs" if !ARCH_STM32
depends on OF && ARM && (ARCH_STM32 || COMPILE_TEST)
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 1c444cc..3c75cbb 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -56,7 +56,6 @@ obj-$(CONFIG_CLKSRC_QCOM) += timer-qcom.o
 obj-$(CONFIG_MTK_TIMER)+= timer-mediatek.o
 obj-$(CONFIG_CLKSRC_PISTACHIO) += timer-pistachio.o
 obj-$(CONFIG_CLKSRC_TI_32K)+= timer-ti-32k.o
-obj-$(CONFIG_CLKSRC_NPS)   += timer-nps.o
 obj-$(CONFIG_OXNAS_RPS_TIMER)  += timer-oxnas-rps.o
 obj-$(CONFIG_OWL_TIMER)+= timer-owl.o
 obj-$(CONFIG_MILBEAUT_TIMER)   += timer-milbeaut.o
diff --git a/drivers/clocksource/timer-nps.c b/drivers/clocksource/timer-nps.c
deleted file mode 100644
index 7b6bb0d..000
--- a/drivers/clocksource/timer-nps.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *  - Redistributions of source code must retain the above
- *copyright notice, this list of conditions and the following
- *disclaimer.
- *
- *  - Redistributions in binary form must reproduce the above
- *copyright notice, this list of conditions and the following
- *disclaimer in the documentation and/or other materials
- *provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define NPS_MSU_TICK_LOW   0xC8
-#define NPS_CLUSTER_OFFSET 8
-#define NPS_CLUSTER_NUM16
-
-/* This array is per cluster of CPUs (Each NPS400 cluster got 256 CPUs) */
-static void *nps_msu_reg_low_addr[NPS_CLUSTER_NUM] __read_mostly;
-
-static int __init nps_get_timer_clk(struct device_node *node,
-unsigned long *timer_freq,
-struct clk **clk)
-{
-   int ret;
-
-   *clk = of_clk_get(node, 0);
-   ret = PTR_ERR_OR_ZERO(*clk);
-   if (ret) {
-   pr_err("timer missing clk\n");
-   return ret;
-   }
-
-   ret = clk_prepare_enable(*clk);
-   if (ret) {
-   pr_err("

Re: [PATCH 0/6] ARC: build: fix various issues in arc boot Makefile

2020-11-24 Thread Vineet Gupta
Hi Masahiro San,

On 11/21/20 11:36 AM, Masahiro Yamada wrote:
>
>
> Masahiro Yamada (6):
>ARC: build: remove non-existing bootpImage from KBUILD_IMAGE
>ARC: build: add uImage.lzma to the top-level target
>ARC: build: add boot_targets to PHONY
>ARC: build: move symlink creation to arch/arc/Makefile to avoid race
>ARC: build: remove unneeded extra-y
>ARC: build: use $(READELF) instead of hard-coded readelf
>
>   arch/arc/Makefile  | 20 +---
>   arch/arc/boot/Makefile | 18 --
>   2 files changed, 17 insertions(+), 21 deletions(-)

This LGTM. Do you want me to pick up these via ARC tree ?

Thx,
-Vineet


[GIT PULL] ARC fixes for 5.10-rc6

2020-11-23 Thread Vineet Gupta
Hi Linus,

A couple more stack unwinder related fixes. Please pull !

Thx,
-Vineet
--->
The following changes since commit 3b57533b460c8dc22a432684b7e8d22571f34d2e:

   ARC: [plat-hsdk] Remap CCMs super early in asm boot trampoline 
(2020-11-02 11:45:09 -0800)

are available in the Git repository at:

   git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git/ 
tags/arc-5.10-rc6

for you to fetch changes up to f737561c709667013d832316dd3198a7fe3d1260:

   ARC: stack unwinding: reorganize how initial register state setup 
(2020-11-17 20:12:01 -0800)


ARC fixes for 5.10-rc6

  - More stack unwinding updates

  - Miscll minor fixes


Flavio Suligoi (1):
   ARC: mm: fix spelling mistakes

Gustavo Pimentel (1):
   ARC: bitops: Remove unecessary operation and value

Vineet Gupta (2):
   ARC: stack unwinding: don't assume non-current task is sleeping
   ARC: stack unwinding: reorganize how initial register state setup

  arch/arc/include/asm/bitops.h |  4 +---
  arch/arc/kernel/stacktrace.c  | 56 
---
  arch/arc/mm/tlb.c | 24 +--
  3 files changed, 44 insertions(+), 40 deletions(-)


Re: [PATCH v2 10/13] arc: use FLATMEM with freeing of unused memory map instead of DISCONTIGMEM

2020-11-16 Thread Vineet Gupta
Hi Mike,

On 11/1/20 9:04 AM, Mike Rapoport wrote:
> From: Mike Rapoport 
>
> Currently ARC uses DISCONTIGMEM to cope with sparse physical memory address
> space on systems with 2 memory banks. While DISCONTIGMEM avoids wasting
> memory on unpopulated memory map, it adds both memory and CPU overhead
> relatively to FLATMEM. Moreover, DISCONTINGMEM is generally considered
> deprecated.
>
> The obvious replacement for DISCONTIGMEM would be SPARSEMEM, but it is also
> less efficient than FLATMEM in pfn_to_page() and page_to_pfn() conversions.
> Besides it requires tuning of SECTION_SIZE which is not trivial for
> possible ARC memory configuration.
>
> Since the memory map for both banks is always allocated from the "lowmem"
> bank, it is possible to use FLATMEM for two-bank configuration and simply
> free the unused hole in the memory map. All is required for that is to
> provide ARC-specific pfn_valid() that will take into account actual
> physical memory configuration and define HAVE_ARCH_PFN_VALID.
>
> The resulting kernel image configured with defconfig + HIGHMEM=y is
> smaller:
>
> $ size a/vmlinux b/vmlinux
> textdata bss dec hex filename
> 4673503 1245456  279756 6198715  5e95bb a/vmlinux
> 4658706 1246864  279756 6185326  5e616e b/vmlinux
>
> $ ./scripts/bloat-o-meter a/vmlinux b/vmlinux
> add/remove: 28/30 grow/shrink: 42/399 up/down: 10986/-29025 (-18039)
> ...
> Total: Before=4709315, After=4691276, chg -0.38%
>
> Booting nSIM with haps_ns.dts results in the following memory usage
> reports:
>
> a:
> Memory: 1559104K/1572864K available (3531K kernel code, 595K rwdata, 752K 
> rodata, 136K init, 275K bss, 13760K reserved, 0K cma-reserved, 1048576K 
> highmem)
>
> b:
> Memory: 1559112K/1572864K available (3519K kernel code, 594K rwdata, 752K 
> rodata, 136K init, 280K bss, 13752K reserved, 0K cma-reserved, 1048576K 
> highmem)
>
> Signed-off-by: Mike Rapoport 

Sorry this fell through the cracks. Do you have a branch I can checkout 
and do a quick test.

Thx,
-Vineet

> ---
>   arch/arc/Kconfig|  3 ++-
>   arch/arc/include/asm/page.h | 20 +---
>   arch/arc/mm/init.c  | 29 ++---
>   3 files changed, 41 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 0a89cc9def65..c874f8ab0341 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -67,6 +67,7 @@ config GENERIC_CSUM
>   
>   config ARCH_DISCONTIGMEM_ENABLE
>   def_bool n
> + depends on BROKEN
>   
>   config ARCH_FLATMEM_ENABLE
>   def_bool y
> @@ -506,7 +507,7 @@ config LINUX_RAM_BASE
>   
>   config HIGHMEM
>   bool "High Memory Support"
> - select ARCH_DISCONTIGMEM_ENABLE
> + select HAVE_ARCH_PFN_VALID
>   help
> With ARC 2G:2G address split, only upper 2G is directly addressable by
> kernel. Enable this to potentially allow access to rest of 2G and PAE
> diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
> index b0dfed0f12be..23e41e890eda 100644
> --- a/arch/arc/include/asm/page.h
> +++ b/arch/arc/include/asm/page.h
> @@ -82,11 +82,25 @@ typedef pte_t * pgtable_t;
>*/
>   #define virt_to_pfn(kaddr)  (__pa(kaddr) >> PAGE_SHIFT)
>   
> -#define ARCH_PFN_OFFSET  virt_to_pfn(CONFIG_LINUX_RAM_BASE)
> +/*
> + * When HIGHMEM is enabled we have holes in the memory map so we need
> + * pfn_valid() that takes into account the actual extents of the physical
> + * memory
> + */
> +#ifdef CONFIG_HIGHMEM
> +
> +extern unsigned long arch_pfn_offset;
> +#define ARCH_PFN_OFFSET  arch_pfn_offset
> +
> +extern int pfn_valid(unsigned long pfn);
> +#define pfn_validpfn_valid
>   
> -#ifdef CONFIG_FLATMEM
> +#else /* CONFIG_HIGHMEM */
> +
> +#define ARCH_PFN_OFFSET  virt_to_pfn(CONFIG_LINUX_RAM_BASE)
>   #define pfn_valid(pfn)  (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
> -#endif
> +
> +#endif /* CONFIG_HIGHMEM */
>   
>   /*
>* __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
> diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
> index 3a35b82a718e..ce07e697916c 100644
> --- a/arch/arc/mm/init.c
> +++ b/arch/arc/mm/init.c
> @@ -28,6 +28,8 @@ static unsigned long low_mem_sz;
>   static unsigned long min_high_pfn, max_high_pfn;
>   static phys_addr_t high_mem_start;
>   static phys_addr_t high_mem_sz;
> +unsigned long arch_pfn_offset;
> +EXPORT_SYMBOL(arch_pfn_offset);
>   #endif
>   
>   #ifdef CONFIG_DISCONTIGMEM
> @@ -98,16 +100,11 @@ void __init setup_arch_memory(void)
>   init_mm.brk = (unsigned long)_end;
>   
>   /* first page of system - kernel .vector starts here */
> - min_low_pfn = ARCH_PFN_OFFSET;
> + min_low_pfn = virt_to_pfn(CONFIG_LINUX_RAM_BASE);
>   
>   /* Last usable page of low mem */
>   max_low_pfn = max_pfn = PFN_DOWN(low_mem_start + low_mem_sz);
>   
> -#ifdef CONFIG_FLATMEM
> - /* pfn_valid() uses this */
> - max_mapnr = max_low_pfn - 

Re: [PATCH] ARC: mm: fix spelling mistakes

2020-11-10 Thread Vineet Gupta
On 11/9/20 5:21 AM, Flavio Suligoi wrote:
> Signed-off-by: Flavio Suligoi 

Thx, applied to for-curr !

-Vineet

> ---
>   arch/arc/mm/tlb.c | 24 
>   1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/arch/arc/mm/tlb.c b/arch/arc/mm/tlb.c
> index c340acd989a0..9bb3c24f3677 100644
> --- a/arch/arc/mm/tlb.c
> +++ b/arch/arc/mm/tlb.c
> @@ -30,14 +30,14 @@
>*  -Changes related to MMU v2 (Rel 4.8)
>*
>* Vineetg: Aug 29th 2008
> - *  -In TLB Flush operations (Metal Fix MMU) there is a explict command to
> + *  -In TLB Flush operations (Metal Fix MMU) there is a explicit command to
>*flush Micro-TLBS. If TLB Index Reg is invalid prior to TLBIVUTLB cmd,
>*it fails. Thus need to load it with ANY valid value before invoking
>*TLBIVUTLB cmd
>*
>* Vineetg: Aug 21th 2008:
>*  -Reduced the duration of IRQ lockouts in TLB Flush routines
> - *  -Multiple copies of TLB erase code seperated into a "single" function
> + *  -Multiple copies of TLB erase code separated into a "single" function
>*  -In TLB Flush routines, interrupt disabling moved UP to retrieve ASID
>*   in interrupt-safe region.
>*
> @@ -66,7 +66,7 @@
>*
>* Although J-TLB is 2 way set assoc, ARC700 caches J-TLB into uTLBS which 
> has
>* much higher associativity. u-D-TLB is 8 ways, u-I-TLB is 4 ways.
> - * Given this, the thrasing problem should never happen because once the 3
> + * Given this, the thrashing problem should never happen because once the 3
>* J-TLB entries are created (even though 3rd will knock out one of the prev
>* two), the u-D-TLB and u-I-TLB will have what is required to accomplish 
> memcpy
>*
> @@ -127,7 +127,7 @@ static void utlb_invalidate(void)
>* There was however an obscure hardware bug, where uTLB flush would
>* fail when a prior probe for J-TLB (both totally unrelated) would
>* return lkup err - because the entry didn't exist in MMU.
> -  * The Workround was to set Index reg with some valid value, prior to
> +  * The Workaround was to set Index reg with some valid value, prior to
>* flush. This was fixed in MMU v3
>*/
>   unsigned int idx;
> @@ -272,7 +272,7 @@ noinline void local_flush_tlb_all(void)
>   }
>   
>   /*
> - * Flush the entrie MM for userland. The fastest way is to move to Next ASID
> + * Flush the entire MM for userland. The fastest way is to move to Next ASID
>*/
>   noinline void local_flush_tlb_mm(struct mm_struct *mm)
>   {
> @@ -303,7 +303,7 @@ noinline void local_flush_tlb_mm(struct mm_struct *mm)
>* Difference between this and Kernel Range Flush is
>*  -Here the fastest way (if range is too large) is to move to next ASID
>*  without doing any explicit Shootdown
> - *  -In case of kernel Flush, entry has to be shot down explictly
> + *  -In case of kernel Flush, entry has to be shot down explicitly
>*/
>   void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
>  unsigned long end)
> @@ -620,7 +620,7 @@ void update_mmu_cache(struct vm_area_struct *vma, 
> unsigned long vaddr_unaligned,
>* Super Page size is configurable in hardware (4K to 16M), but fixed once
>* RTL builds.
>*
> - * The exact THP size a Linx configuration will support is a function of:
> + * The exact THP size a Linux configuration will support is a function of:
>*  - MMU page size (typical 8K, RTL fixed)
>*  - software page walker address split between PGD:PTE:PFN (typical
>*11:8:13, but can be changed with 1 line)
> @@ -698,7 +698,7 @@ void local_flush_pmd_tlb_range(struct vm_area_struct 
> *vma, unsigned long start,
>   
>   #endif
>   
> -/* Read the Cache Build Confuration Registers, Decode them and save into
> +/* Read the Cache Build Configuration Registers, Decode them and save into
>* the cpuinfo structure for later use.
>* No Validation is done here, simply read/convert the BCRs
>*/
> @@ -803,13 +803,13 @@ void arc_mmu_init(void)
>   pr_info("%s", arc_mmu_mumbojumbo(0, str, sizeof(str)));
>   
>   /*
> -  * Can't be done in processor.h due to header include depenedencies
> +  * Can't be done in processor.h due to header include dependencies
>*/
>   BUILD_BUG_ON(!IS_ALIGNED((CONFIG_ARC_KVADDR_SIZE << 20), PMD_SIZE));
>   
>   /*
>* stack top size sanity check,
> -  * Can't be done in processor.h due to header include depenedencies
> +  * Can't be done in processor.h due to header include dependencies
>*/
>   BUILD_BUG_ON(!IS_ALIGNED(STACK_TOP, PMD_SIZE));
>   
> @@ -881,7 +881,7 @@ void arc_mmu_init(void)
>*  the duplicate one.
>* -Knob to be verbose abt it.(TODO: hook them up to debugfs)
>*/
> -volatile int dup_pd_silent; /* Be slient abt it or complain (default) */
> +volatile int dup_pd_silent; /* Be silent abt it or complain (default) */
>   
>   void 

Re: [PATCH] Revert "ARC: entry: fix potential EFA clobber when TIF_SYSCALL_TRACE"

2020-11-10 Thread Vineet Gupta
On 11/9/20 2:29 AM, Greg Kroah-Hartman wrote:
> On Sat, Nov 07, 2020 at 03:10:06PM +0100, Greg Kroah-Hartman wrote:
>> On Fri, Nov 06, 2020 at 08:27:44PM +0000, Vineet Gupta wrote:
>>> Hi Stable Team,
>>>
>>> On 10/19/20 7:19 PM, Vineet Gupta wrote:
>>>> This reverts commit 00fdec98d9881bf5173af09aebd353ab3b9ac729.
>>>> (but only from 5.2 and prior kernels)
>>>>
>>>> The original commit was a preventive fix based on code-review and was
>>>> auto-picked for stable back-port (for better or worse).
>>>> It was OK for v5.3+ kernels, but turned up needing an implicit change
>>>> 68e5c6f073bcf70 "(ARC: entry: EV_Trap expects r10 (vs. r9) to have
>>>>   exception cause)" merged in v5.3 which itself was not backported.
>>>> So to summarize the stable backport of this patch for v5.2 and prior
>>>> kernels is busted and it won't boot.
>>>>
>>>> The obvious solution is backport 68e5c6f073bcf70 but that is a pain as
>>>> it doesn't revert cleanly and each of affected kernels (so far v4.19,
>>>> v4.14, v4.9, v4.4) needs a slightly different massaged varaint.
>>>> So the easier fix is to simply revert the backport from 5.2 and prior.
>>>> The issue was not a big deal as it would cause strace to sporadically
>>>> not work correctly.
>>>>
>>>> Waldemar Brodkorb first reported this when running ARC uClibc regressions
>>>> on latest stable kernels (with offending backport). Once he bisected it,
>>>> the analysis was trivial, so thx to him for this.
>>>>
>>>> Reported-by: Waldemar Brodkorb 
>>>> Bisected-by: Waldemar Brodkorb 
>>>> Cc: stable  # 5.2 and prior
>>>> Signed-off-by: Vineet Gupta 
>>> Can this revert be please applied to 4.19 and older kernels for the next 
>>> cycle.
>>>
>>> Or is there is a procedural issue given this revert is not in mainline. I've
>>> described the issue in detail above so if there's a better/desirable way of
>>> reverting it from backports, please let me know.
>> THis is fine, sorry, it's just in a backlog of lots of stable patches...
>>
>> We will get to it soon.
> Now queued up, thanks.

Thx a bunch Greg.

-Vineet


Re: [PATCH] Revert "ARC: entry: fix potential EFA clobber when TIF_SYSCALL_TRACE"

2020-11-06 Thread Vineet Gupta
Hi Stable Team,

On 10/19/20 7:19 PM, Vineet Gupta wrote:
> This reverts commit 00fdec98d9881bf5173af09aebd353ab3b9ac729.
> (but only from 5.2 and prior kernels)
> 
> The original commit was a preventive fix based on code-review and was
> auto-picked for stable back-port (for better or worse).
> It was OK for v5.3+ kernels, but turned up needing an implicit change
> 68e5c6f073bcf70 "(ARC: entry: EV_Trap expects r10 (vs. r9) to have
>  exception cause)" merged in v5.3 which itself was not backported.
> So to summarize the stable backport of this patch for v5.2 and prior
> kernels is busted and it won't boot.
> 
> The obvious solution is backport 68e5c6f073bcf70 but that is a pain as
> it doesn't revert cleanly and each of affected kernels (so far v4.19,
> v4.14, v4.9, v4.4) needs a slightly different massaged varaint.
> So the easier fix is to simply revert the backport from 5.2 and prior.
> The issue was not a big deal as it would cause strace to sporadically
> not work correctly.
> 
> Waldemar Brodkorb first reported this when running ARC uClibc regressions
> on latest stable kernels (with offending backport). Once he bisected it,
> the analysis was trivial, so thx to him for this.
> 
> Reported-by: Waldemar Brodkorb 
> Bisected-by: Waldemar Brodkorb 
> Cc: stable  # 5.2 and prior
> Signed-off-by: Vineet Gupta 

Can this revert be please applied to 4.19 and older kernels for the next cycle.

Or is there is a procedural issue given this revert is not in mainline. I've
described the issue in detail above so if there's a better/desirable way of
reverting it from backports, please let me know.

Thx,

> ---
>  arch/arc/kernel/entry.S | 16 +++-
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
> index ea00c8a17f07..60406ec62eb8 100644
> --- a/arch/arc/kernel/entry.S
> +++ b/arch/arc/kernel/entry.S
> @@ -165,6 +165,7 @@ END(EV_Extension)
>  tracesys:
>   ; save EFA in case tracer wants the PC of traced task
>   ; using ERET won't work since next-PC has already committed
> + lr  r12, [efa]
>   GET_CURR_TASK_FIELD_PTR   TASK_THREAD, r11
>   st  r12, [r11, THREAD_FAULT_ADDR]   ; thread.fault_address
>  
> @@ -207,9 +208,15 @@ tracesys_exit:
>  ; Breakpoint TRAP
>  ; -
>  trap_with_param:
> - mov r0, r12 ; EFA in case ptracer/gdb wants stop_pc
> +
> + ; stop_pc info by gdb needs this info
> + lr  r0, [efa]
>   mov r1, sp
>  
> + ; Now that we have read EFA, it is safe to do "fake" rtie
> + ;   and get out of CPU exception mode
> + FAKE_RET_FROM_EXCPN
> +
>   ; Save callee regs in case gdb wants to have a look
>   ; SP will grow up by size of CALLEE Reg-File
>   ; NOTE: clobbers r12
> @@ -236,10 +243,6 @@ ENTRY(EV_Trap)
>  
>   EXCEPTION_PROLOGUE
>  
> - lr  r12, [efa]
> -
> - FAKE_RET_FROM_EXCPN
> -
>   ; TRAP 1   :breakpoints
>   ; Check ECR for trap with arg (PROLOGUE ensures r10 has ECR)
>   bmsk.f 0, r10, 7
> @@ -247,6 +250,9 @@ ENTRY(EV_Trap)
>  
>   ; TRAP  (no param): syscall top level
>  
> + ; First return from Exception to pure K mode (Exception/IRQs renabled)
> + FAKE_RET_FROM_EXCPN
> +
>   ; If syscall tracing ongoing, invoke pre-post-hooks
>   GET_CURR_THR_INFO_FLAGS   r10
>   btst r10, TIF_SYSCALL_TRACE
> 



Re: [PATCH] ARC: bitops: Remove unecessary operation and value

2020-11-05 Thread Vineet Gupta
On 10/21/20 2:12 PM, Gustavo Pimentel wrote:
> The 1-bit shift rotation to the left on x variable located on
> 4   last if statement can be removed because the computed value is will
> not be used afront.

All of constant_fls() is anyhow optimized away at compile time, so this 
won't affect any code-gen at all, still this patch is legit.

> Signed-off-by: Gustavo Pimentel 

Added to for-curr !

Thx,
-Vineet

> ---
>   arch/arc/include/asm/bitops.h | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h
> index 50eb3f6..8cc 100644
> --- a/arch/arc/include/asm/bitops.h
> +++ b/arch/arc/include/asm/bitops.h
> @@ -297,10 +297,8 @@ static inline int constant_fls(unsigned int x)
>   x <<= 2;
>   r -= 2;
>   }
> - if (!(x & 0x8000u)) {
> - x <<= 1;
> + if (!(x & 0x8000u))
>   r -= 1;
> - }
>   return r;
>   }
>   



[RFC] proc: get_wchan() stack unwind only makes sense for sleeping/non-self tasks

2020-11-05 Thread Vineet Gupta
Most architectures currently check this in their get_wchan() implementation
(ARC doesn't hence this patch). However doing this in core code shows
the semantics better so move the check one level up (eventually remove
the boiler-plate code from arches)

Signed-off-by: Vineet Gupta 

 #  tools/perf/arch/arc/util/
---
 fs/proc/array.c | 4 +++-
 fs/proc/base.c  | 6 --
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 65ec2029fa80..081fade5a361 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -519,8 +519,10 @@ static int do_task_stat(struct seq_file *m, struct 
pid_namespace *ns,
unlock_task_sighand(task, );
}
 
-   if (permitted && (!whole || num_threads < 2))
+   if (task != current && task->state != TASK_RUNNING &&
+   permitted && (!whole || num_threads < 2))
wchan = get_wchan(task);
+
if (!whole) {
min_flt = task->min_flt;
maj_flt = task->maj_flt;
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 0f707003dda5..abd7ec6324c5 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -385,13 +385,15 @@ static const struct file_operations proc_pid_cmdline_ops 
= {
 static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
  struct pid *pid, struct task_struct *task)
 {
-   unsigned long wchan;
+   unsigned long wchan = 0;
char symname[KSYM_NAME_LEN];
 
if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS))
goto print0;
 
-   wchan = get_wchan(task);
+   if (task != current && task->state != TASK_RUNNING)
+   wchan = get_wchan(task);
+
if (wchan && !lookup_symbol_name(wchan, symname)) {
seq_puts(m, symname);
return 0;
-- 
2.25.1



[PATCH 3/3] include/soc: remove headers for EZChip NPS

2020-11-05 Thread Vineet Gupta
NPS platform has been removed from ARC port and there are no in-tree
user of it now . So RIP !

Signed-off-by: Vineet Gupta 
---
 include/soc/nps/common.h | 172 ---
 include/soc/nps/mtm.h|  59 --
 2 files changed, 231 deletions(-)
 delete mode 100644 include/soc/nps/common.h
 delete mode 100644 include/soc/nps/mtm.h

diff --git a/include/soc/nps/common.h b/include/soc/nps/common.h
deleted file mode 100644
index 8c18dc6d3fde..
--- a/include/soc/nps/common.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *  - Redistributions of source code must retain the above
- *copyright notice, this list of conditions and the following
- *disclaimer.
- *
- *  - Redistributions in binary form must reproduce the above
- *copyright notice, this list of conditions and the following
- *disclaimer in the documentation and/or other materials
- *provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef SOC_NPS_COMMON_H
-#define SOC_NPS_COMMON_H
-
-#ifdef CONFIG_SMP
-#define NPS_IPI_IRQ5
-#endif
-
-#define NPS_HOST_REG_BASE  0xF600
-
-#define NPS_MSU_BLKID  0x018
-
-#define CTOP_INST_RSPI_GIC_0_R12   0x3C56117E
-#define CTOP_INST_MOV2B_FLIP_R3_B1_B2_INST 0x5B60
-#define CTOP_INST_MOV2B_FLIP_R3_B1_B2_LIMM 0x00010422
-
-#ifndef AUX_IENABLE
-#define AUX_IENABLE0x40c
-#endif
-
-#define CTOP_AUX_IACK  (0xF800 + 0x088)
-
-#ifndef __ASSEMBLY__
-
-/* In order to increase compilation test coverage */
-#ifdef CONFIG_ARC
-static inline void nps_ack_gic(void)
-{
-   __asm__ __volatile__ (
-   "   .word %0\n"
-   :
-   : "i"(CTOP_INST_RSPI_GIC_0_R12)
-   : "memory");
-}
-#else
-static inline void nps_ack_gic(void) { }
-#define write_aux_reg(r, v)
-#define read_aux_reg(r) 0
-#endif
-
-/* CPU global ID */
-struct global_id {
-   union {
-   struct {
-#ifdef CONFIG_EZNPS_MTM_EXT
-   u32 __reserved:20, cluster:4, core:4, thread:4;
-#else
-   u32 __reserved:24, cluster:4, core:4;
-#endif
-   };
-   u32 value;
-   };
-};
-
-/*
- * Convert logical to physical CPU IDs
- *
- * The conversion swap bits 1 and 2 of cluster id (out of 4 bits)
- * Now quad of logical clusters id's are adjacent physically,
- * and not like the id's physically came with each cluster.
- * Below table is 4x4 mesh of core clusters as it layout on chip.
- * Cluster ids are in format: logical (physical)
- *
- *-   --
- * 3 |  5 (3)   7 (7)  | | 13 (11)   15 (15)|
- *
- * 2 |  4 (2)   6 (6)  | | 12 (10)   14 (14)|
- *-   --
- * 1 |  1 (1)   3 (5)  | |  9  (9)   11 (13)|
- *
- * 0 |  0 (0)   2 (4)  | |  8  (8)   10 (12)|
- *-   --
- *   0   123
- */
-static inline int nps_cluster_logic_to_phys(int cluster)
-{
-#ifdef __arc__
-__asm__ __volatile__(
-   "   mov r3,%0\n"
-   "   .short %1\n"
-   "   .word %2\n"
-   "   mov %0,r3\n"
-   : "+r"(cluster)
-   : "i"(CTOP_INST_MOV2B_FLIP_R3_B1_B2_INST),
- "i"(CTOP_INST_MOV2B_FLIP_R3_B1_B2_LIMM)
-   : "r3");
-#endif
-
-   return cluster;
-}
-
-#define NPS_CPU_TO_CLUSTER_NUM(cpu) \
-   ({ struct global_id gid; gid.value = cpu; \
-   nps_cluster_logic_to_phys(gid.cluster); })
-
-struct nps_host_reg_address {
-   union {
-   struct {
-   u32 base:8, cl_x:4, cl_y:4,
-   blkid:6, reg:8, __reserved:2;
-   };
-   u32 value;
-   };
-};
-
-struct nps

[PATCH 2/3] drivers/irqchip: Remove EZChip NPS interrupt controller

2020-11-05 Thread Vineet Gupta
NPS platform has been removed from ARC port and there are no in-tree
users of it now. So RIP !

Cc: Thomas Gleixner 
Cc: Jason Cooper 
Cc: Marc Zyngier 
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Vineet Gupta 
---
 drivers/irqchip/Kconfig |   7 --
 drivers/irqchip/Makefile|   1 -
 drivers/irqchip/irq-eznps.c | 165 
 3 files changed, 173 deletions(-)
 delete mode 100644 drivers/irqchip/irq-eznps.c

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index c6098eee0c7c..7920c3a3017d 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -389,13 +389,6 @@ config LS_SCFG_MSI
 config PARTITION_PERCPU
bool
 
-config EZNPS_GIC
-   bool "NPS400 Global Interrupt Manager (GIM)"
-   depends on ARC || (COMPILE_TEST && !64BIT)
-   select IRQ_DOMAIN
-   help
- Support the EZchip NPS400 global interrupt controller
-
 config STM32_EXTI
bool
select IRQ_DOMAIN
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 94c2885882ee..0ac93bfaec61 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -86,7 +86,6 @@ obj-$(CONFIG_MVEBU_PIC)   += 
irq-mvebu-pic.o
 obj-$(CONFIG_MVEBU_SEI)+= irq-mvebu-sei.o
 obj-$(CONFIG_LS_EXTIRQ)+= irq-ls-extirq.o
 obj-$(CONFIG_LS_SCFG_MSI)  += irq-ls-scfg-msi.o
-obj-$(CONFIG_EZNPS_GIC)+= irq-eznps.o
 obj-$(CONFIG_ARCH_ASPEED)  += irq-aspeed-vic.o irq-aspeed-i2c-ic.o 
irq-aspeed-scu-ic.o
 obj-$(CONFIG_STM32_EXTI)   += irq-stm32-exti.o
 obj-$(CONFIG_QCOM_IRQ_COMBINER)+= qcom-irq-combiner.o
diff --git a/drivers/irqchip/irq-eznps.c b/drivers/irqchip/irq-eznps.c
deleted file mode 100644
index 2a7a38830a8d..
--- a/drivers/irqchip/irq-eznps.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *  - Redistributions of source code must retain the above
- *copyright notice, this list of conditions and the following
- *disclaimer.
- *
- *  - Redistributions in binary form must reproduce the above
- *copyright notice, this list of conditions and the following
- *disclaimer in the documentation and/or other materials
- *provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define NPS_NR_CPU_IRQS 8  /* number of interrupt lines of NPS400 CPU */
-#define NPS_TIMER0_IRQ  3
-
-/*
- * NPS400 core includes an Interrupt Controller (IC) support.
- * All cores can deactivate level irqs at first level control
- * at cores mesh layer called MTM.
- * For devices out side chip e.g. uart, network there is another
- * level called Global Interrupt Manager (GIM).
- * This second level can control level and edge interrupt.
- *
- * NOTE: AUX_IENABLE and CTOP_AUX_IACK are auxiliary registers
- * with private HW copy per CPU.
- */
-
-static void nps400_irq_mask(struct irq_data *irqd)
-{
-   unsigned int ienb;
-   unsigned int irq = irqd_to_hwirq(irqd);
-
-   ienb = read_aux_reg(AUX_IENABLE);
-   ienb &= ~(1 << irq);
-   write_aux_reg(AUX_IENABLE, ienb);
-}
-
-static void nps400_irq_unmask(struct irq_data *irqd)
-{
-   unsigned int ienb;
-   unsigned int irq = irqd_to_hwirq(irqd);
-
-   ienb = read_aux_reg(AUX_IENABLE);
-   ienb |= (1 << irq);
-   write_aux_reg(AUX_IENABLE, ienb);
-}
-
-static void nps400_irq_eoi_global(struct irq_data *irqd)
-{
-   unsigned int __maybe_unused irq = irqd_to_hwirq(irqd);
-
-   write_aux_reg(CTOP_AUX_IACK, 1 << irq);
-
-   /* Don't ack GIC before all device access attempts are done */
-   mb();
-
-   nps_ack_gic();
-}
-
-static void nps400_irq_ack(struct irq_data *irqd)
-{
-   unsigned int __maybe_unused irq = irqd_to_hwirq(irqd);
-
-   write_aux

[PATCH 1/3] drivers/clocksource: Remove EZChip NPS clocksource driver

2020-11-05 Thread Vineet Gupta
NPS platform has been removed from ARC port and there are no in-tree
users of it now. So RIP !

Cc: Daniel Lezcano 
Cc: Thomas Gleixner 
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Vineet Gupta 
---
 drivers/clocksource/Kconfig |  10 --
 drivers/clocksource/Makefile|   1 -
 drivers/clocksource/timer-nps.c | 284 
 3 files changed, 295 deletions(-)
 delete mode 100644 drivers/clocksource/timer-nps.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 68b087bff59c..390c27cd926d 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -275,16 +275,6 @@ config CLKSRC_TI_32K
  This option enables support for Texas Instruments 32.768 Hz 
clocksource
  available on many OMAP-like platforms.
 
-config CLKSRC_NPS
-   bool "NPS400 clocksource driver" if COMPILE_TEST
-   depends on !PHYS_ADDR_T_64BIT
-   select CLKSRC_MMIO
-   select TIMER_OF if OF
-   help
- NPS400 clocksource support.
- It has a 64-bit counter with update rate up to 1000MHz.
- This counter is accessed via couple of 32-bit memory-mapped registers.
-
 config CLKSRC_STM32
bool "Clocksource for STM32 SoCs" if !ARCH_STM32
depends on OF && ARM && (ARCH_STM32 || COMPILE_TEST)
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 1c444cc3bb44..3c75cbbf8533 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -56,7 +56,6 @@ obj-$(CONFIG_CLKSRC_QCOM) += timer-qcom.o
 obj-$(CONFIG_MTK_TIMER)+= timer-mediatek.o
 obj-$(CONFIG_CLKSRC_PISTACHIO) += timer-pistachio.o
 obj-$(CONFIG_CLKSRC_TI_32K)+= timer-ti-32k.o
-obj-$(CONFIG_CLKSRC_NPS)   += timer-nps.o
 obj-$(CONFIG_OXNAS_RPS_TIMER)  += timer-oxnas-rps.o
 obj-$(CONFIG_OWL_TIMER)+= timer-owl.o
 obj-$(CONFIG_MILBEAUT_TIMER)   += timer-milbeaut.o
diff --git a/drivers/clocksource/timer-nps.c b/drivers/clocksource/timer-nps.c
deleted file mode 100644
index 7b6bb0df96ae..
--- a/drivers/clocksource/timer-nps.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *  - Redistributions of source code must retain the above
- *copyright notice, this list of conditions and the following
- *disclaimer.
- *
- *  - Redistributions in binary form must reproduce the above
- *copyright notice, this list of conditions and the following
- *disclaimer in the documentation and/or other materials
- *provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define NPS_MSU_TICK_LOW   0xC8
-#define NPS_CLUSTER_OFFSET 8
-#define NPS_CLUSTER_NUM16
-
-/* This array is per cluster of CPUs (Each NPS400 cluster got 256 CPUs) */
-static void *nps_msu_reg_low_addr[NPS_CLUSTER_NUM] __read_mostly;
-
-static int __init nps_get_timer_clk(struct device_node *node,
-unsigned long *timer_freq,
-struct clk **clk)
-{
-   int ret;
-
-   *clk = of_clk_get(node, 0);
-   ret = PTR_ERR_OR_ZERO(*clk);
-   if (ret) {
-   pr_err("timer missing clk\n");
-   return ret;
-   }
-
-   ret = clk_prepare_enable(*clk);
-   if (ret) {
-   pr_err("Couldn't enable parent clk\n");
-   clk_put(*clk);
-   return ret;
-   }
-
-   *timer_freq = clk_get_rate(*clk);
-   if (!(*timer_freq)) {
-   pr_err("Couldn't get clk rate\n");
-   clk_disable_unprepare(*clk);
-   clk_put(*clk);
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
-static u64 nps_clksrc_read(struct clocksource *clksrc)
-{
-   int cluster = raw_smp_processor_id() >> NPS_CLUSTER_OFFSET;
-
-   

[PATCH 0/3] Remove drivers used by EZChip NPS platform

2020-11-05 Thread Vineet Gupta
This series removes any drivers associated with EZChip NPS platform
which was removed from ARC in 5.10-rc1.

Vineet Gupta (3):
  drivers/clocksource: Remove EZChip NPS clocksource driver
  drivers/irqchip: Remove EZChip NPS interrupt controller
  include/soc: remove headers for EZChip NPS

 drivers/clocksource/Kconfig |  10 --
 drivers/clocksource/Makefile|   1 -
 drivers/clocksource/timer-nps.c | 284 
 drivers/irqchip/Kconfig |   7 -
 drivers/irqchip/Makefile|   1 -
 drivers/irqchip/irq-eznps.c | 165 ---
 include/soc/nps/common.h| 172 ---
 include/soc/nps/mtm.h   |  59 ---
 8 files changed, 699 deletions(-)
 delete mode 100644 drivers/clocksource/timer-nps.c
 delete mode 100644 drivers/irqchip/irq-eznps.c
 delete mode 100644 include/soc/nps/common.h
 delete mode 100644 include/soc/nps/mtm.h

-- 
2.25.1



[GIT PULL] ARC fixes for 5.10-rc3

2020-11-05 Thread Vineet Gupta
Hi Linus,

A couple of urgent fixes for ARC for 5.10-rc3. Please pull.

Thx,
-Vineet
>
The following changes since commit 3cea11cd5e3b00d91caf0b4730194039b45c5891:

   Linux 5.10-rc2 (2020-11-01 14:43:51 -0800)

are available in the Git repository at:

   git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git/ 
tags/arc-5.10-rc3

for you to fetch changes up to 3b57533b460c8dc22a432684b7e8d22571f34d2e:

   ARC: [plat-hsdk] Remap CCMs super early in asm boot trampoline 
(2020-11-02 11:45:09 -0800)


ARC fixes for 5.10-rc3

  - Unbork HSDKv1 platform (won't boot) due to memory map issue

  - Prevent stack unwinder from infinite looping

----
Vineet Gupta (2):
   ARC: stack unwinding: avoid indefinite looping
   ARC: [plat-hsdk] Remap CCMs super early in asm boot trampoline

  arch/arc/kernel/head.S    | 17 -
  arch/arc/kernel/stacktrace.c  |  7 ++-
  arch/arc/plat-hsdk/platform.c | 17 -
  3 files changed, 22 insertions(+), 19 deletions(-)


Re: [PATCH] arc: add support for TIF_NOTIFY_SIGNAL

2020-10-30 Thread Vineet Gupta
On 10/30/20 11:53 AM, Jens Axboe wrote:
>
> Ah thanks, I'll make that change. Hard for me to test a lot of these, so
> I really appreciate someone knowledgable taking a look at it.

Sure, glad to help, thx to you for writing the arch patches in first 
place. It takes a bit of daring to venture in unchartered waters ;-)

These days it is super easy to get your hands on a ARC cross toolchain. 
We don't have them shipping as regular distro packages just yet, but you 
can download a prebuilt @
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2020.09-release/arc_gnu_2020.09_prebuilt_glibc_le_archs_linux_install.tar.gz

Or you can just build upstream gcc + binutils for ARC if you so prefer.


>>>
>>> ; Normal Trap/IRQ entry only saves Scratch (caller-saved) regs
>>> ; in pt_reg since the "C" ABI (kernel code) will automatically
>>> diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c
>>> index 2be55fb96d87..a78d8f745a67 100644
>>> --- a/arch/arc/kernel/signal.c
>>> +++ b/arch/arc/kernel/signal.c
>>> @@ -362,7 +362,7 @@ void do_signal(struct pt_regs *regs)
>>>
>>> restart_scall = in_syscall(regs) && syscall_restartable(regs);
>>>
>>> -   if (get_signal()) {
>>> +   if (test_thread_flag(TIF_SIGPENDING) && get_signal()) {
>>> if (restart_scall) {
>>> arc_restart_syscall(, regs);
>>> syscall_wont_restart(regs); /* No more restarts */
>>
>> I've not seen your entire patchset, but it seems we are now hitting
>> do_signal() for either of TIF_{SIGPENDING|NOTIFY_SIGNAL} but then only
>> handling signal for TIF_SIGPENDING, so why even bother to come here. Do
>> you plan to add additional arch handling later ?
> Nope, that's all that's needed for each arch. The behavior you describe
> is how it works. It makes it so that TIF_SIGPENDING will do the signal
> delivery and syscall restart as it always has done, but
> TIF_NOTIFY_SIGNAL will only do the syscall restart. The latter is the
> intent, hence TIF_NOTIFY_SIGNAL provides a way to interrupt a process
> and have it process task_work without going through signal delivery like
> task_work with TWA_SIGNAL does today.

Nice, thx for explaining that.

>
> Updated version below:
>
>
> commit 3c6239647d95d03d1436bc826a004791c3f04617
> Author: Jens Axboe 
> Date:   Mon Oct 12 07:15:37 2020 -0600
>
>  arc: add support for TIF_NOTIFY_SIGNAL
>  
>  Wire up TIF_NOTIFY_SIGNAL handling for arc.
>  
>  Cc: linux-snps-...@lists.infradead.org
>  Signed-off-by: Jens Axboe 

Acked-by: Vineet Gupta 

>
> diff --git a/arch/arc/include/asm/thread_info.h 
> b/arch/arc/include/asm/thread_info.h
> index f9eef0e8f0b7..c0942c24d401 100644
> --- a/arch/arc/include/asm/thread_info.h
> +++ b/arch/arc/include/asm/thread_info.h
> @@ -79,6 +79,7 @@ static inline __attribute_const__ struct thread_info 
> *current_thread_info(void)
>   #define TIF_SIGPENDING  2   /* signal pending */
>   #define TIF_NEED_RESCHED3   /* rescheduling necessary */
>   #define TIF_SYSCALL_AUDIT   4   /* syscall auditing active */
> +#define TIF_NOTIFY_SIGNAL5   /* signal notifications exist */
>   #define TIF_SYSCALL_TRACE   15  /* syscall trace active */
>   
>   /* true if poll_idle() is polling TIF_NEED_RESCHED */
> @@ -89,11 +90,12 @@ static inline __attribute_const__ struct thread_info 
> *current_thread_info(void)
>   #define _TIF_SIGPENDING (1<   #define _TIF_NEED_RESCHED   (1<   #define _TIF_SYSCALL_AUDIT  (1< +#define _TIF_NOTIFY_SIGNAL   (1<   #define _TIF_MEMDIE (1<   
>   /* work to do on interrupt/exception return */
>   #define _TIF_WORK_MASK  (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
> -  _TIF_NOTIFY_RESUME)
> +  _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL)
>   
>   /*
>* _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it.
> diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
> index ea00c8a17f07..1f5308abf36d 100644
> --- a/arch/arc/kernel/entry.S
> +++ b/arch/arc/kernel/entry.S
> @@ -307,7 +307,8 @@ resume_user_mode_begin:
>   mov r0, sp  ; pt_regs for arg to do_signal()/do_notify_resume()
>   
>   GET_CURR_THR_INFO_FLAGS   r9
> - bbit0  r9, TIF_SIGPENDING, .Lchk_notify_resume
> + and.f  0,  r9, TIF_SIGPENDING|TIF_NOTIFY_SIGNAL
> + bz .Lchk_notify_resume
>   
>   ; Normal Trap/IRQ entry only saves Scratch (caller-saved) regs
>   ; in pt_reg since the "C" ABI (kern

Re: arc: kernel/entry.S:310: Error: inappropriate arguments for opcode 'and'

2020-10-30 Thread Vineet Gupta
Hi Naresh,

On 10/30/20 3:29 AM, Naresh Kamboju wrote:
> arc defconfig build failed on linux next 20201030 with gcc-8 and gcc-9.
>
> make -sk KBUILD_BUILD_USER=TuxBuild -C/linux -j16 ARCH=arc
> CROSS_COMPILE=arc-elf32- HOSTCC=gcc CC="sccache arc-elf32-gcc" O=build
> uImage
> #
> ../arch/arc/kernel/entry.S: Assembler messages:
> ../arch/arc/kernel/entry.S:310: Error: inappropriate arguments for opcode 
> 'and'
> make[3]: *** [../scripts/Makefile.build:364:
> arch/arc/kernel/entry-arcv2.o] Error 1
>
> Reported-by: Naresh Kamboju 

Thx for reporting this.  This is due to the series Add support for 
TIF_NOTIFY_SIGNAL 
where
 
ARC patch is broken and I just replied to Jens about it. He will 
hopefully fix it and push updated series to -next

Thx,
-Vineet


[PATCH] ARC: [plat-hsdk] Remap CCMs super early in asm boot trampoline

2020-10-29 Thread Vineet Gupta
ARC HSDK platform stopped booting on released v5.10-rc1, getting stuck
in startup of non master SMP cores.

This was bisected to upstream commit 7fef431be9c9ac25
"(mm/page_alloc: place pages to tail in __free_pages_core())"
That commit itself is harmless, it just exposed a subtle assumption in
our platform code (hence CC'ing linux-mm just as FYI in case some other
arches / platforms trip on it).

The upstream commit is semantically disruptive as it reverses the order
of page allocations (actually it can be good test for hardware
verification to exercise different memory patterns altogether).
For ARC HSDK platform that meant a remapped memory region (pertaining to
unused Closely Coupled Memory) started getting used early for dynamice
allocations, while not effectively remapped on all the cores, triggering
memory error exception on those cores.

The fix is to move the CCM remapping from early platform code to to early core
boot code. And while it is undesirable to riddle common boot code with
platform quirks, there is no other way to do this since the faltering code
involves setting up stack itself so even function calls are not allowed at
that point.

If anyone is interested, all the gory details can be found at Link below.

Link: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/issues/32
Cc: David Hildenbrand 
Cc: linux...@kvack.org
Signed-off-by: Vineet Gupta 
---
 arch/arc/kernel/head.S| 17 -
 arch/arc/plat-hsdk/platform.c | 17 -
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S
index 17fd1ed700cc..9152782444b5 100644
--- a/arch/arc/kernel/head.S
+++ b/arch/arc/kernel/head.S
@@ -67,7 +67,22 @@
sr  r5, [ARC_REG_LPB_CTRL]
 1:
 #endif /* CONFIG_ARC_LPB_DISABLE */
-#endif
+
+   /* On HSDK, CCMs need to remapped super early */
+#ifdef CONFIG_ARC_SOC_HSDK
+   mov r6, 0x6000
+   lr  r5, [ARC_REG_ICCM_BUILD]
+   breqr5, 0, 1f
+   sr  r6, [ARC_REG_AUX_ICCM]
+1:
+   lr  r5, [ARC_REG_DCCM_BUILD]
+   breqr5, 0, 2f
+   sr  r6, [ARC_REG_AUX_DCCM]
+2:
+#endif /* CONFIG_ARC_SOC_HSDK */
+
+#endif /* CONFIG_ISA_ARCV2 */
+
; Config DSP_CTRL properly, so kernel may use integer multiply,
; multiply-accumulate, and divide operations
DSP_EARLY_INIT
diff --git a/arch/arc/plat-hsdk/platform.c b/arch/arc/plat-hsdk/platform.c
index 0b63fc095b99..b3ea1fa11f87 100644
--- a/arch/arc/plat-hsdk/platform.c
+++ b/arch/arc/plat-hsdk/platform.c
@@ -17,22 +17,6 @@ int arc_hsdk_axi_dmac_coherent __section(".data") = 0;
 
 #define ARC_CCM_UNUSED_ADDR0x6000
 
-static void __init hsdk_init_per_cpu(unsigned int cpu)
-{
-   /*
-* By default ICCM is mapped to 0x7z while this area is used for
-* kernel virtual mappings, so move it to currently unused area.
-*/
-   if (cpuinfo_arc700[cpu].iccm.sz)
-   write_aux_reg(ARC_REG_AUX_ICCM, ARC_CCM_UNUSED_ADDR);
-
-   /*
-* By default DCCM is mapped to 0x8z while this area is used by kernel,
-* so move it to currently unused area.
-*/
-   if (cpuinfo_arc700[cpu].dccm.sz)
-   write_aux_reg(ARC_REG_AUX_DCCM, ARC_CCM_UNUSED_ADDR);
-}
 
 #define ARC_PERIPHERAL_BASE0xf000
 #define CREG_BASE  (ARC_PERIPHERAL_BASE + 0x1000)
@@ -339,5 +323,4 @@ static const char *hsdk_compat[] __initconst = {
 MACHINE_START(SIMULATION, "hsdk")
.dt_compat  = hsdk_compat,
.init_early = hsdk_init_early,
-   .init_per_cpu   = hsdk_init_per_cpu,
 MACHINE_END
-- 
2.25.1



[PATCH] ARC: stack unwinding: avoid indefinite looping

2020-10-27 Thread Vineet Gupta
Currently stack unwinder is a while(1) loop which relies on the dwarf
unwinder to signal termination, which in turn relies on dwarf info to do
so. This in theory could cause an infinite loop if the dwarf info was
somehow messed up or the register contents were etc.

This fix thus detects the excessive looping and breaks the loop.

Signed-off-by: Vineet Gupta 
---
 arch/arc/kernel/stacktrace.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arc/kernel/stacktrace.c b/arch/arc/kernel/stacktrace.c
index bf40e06f3fb8..0fed32b95923 100644
--- a/arch/arc/kernel/stacktrace.c
+++ b/arch/arc/kernel/stacktrace.c
@@ -115,7 +115,7 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs 
*regs,
int (*consumer_fn) (unsigned int, void *), void *arg)
 {
 #ifdef CONFIG_ARC_DW2_UNWIND
-   int ret = 0;
+   int ret = 0, cnt = 0;
unsigned int address;
struct unwind_frame_info frame_info;
 
@@ -135,6 +135,11 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs 
*regs,
break;
 
frame_info.regs.r63 = frame_info.regs.r31;
+
+   if (cnt++ > 128) {
+   printk("unwinder looping too long, aborting !\n");
+   return 0;
+   }
}
 
return address; /* return the last address it saw */
-- 
2.25.1



Re: Build regressions/improvements in v5.10-rc1

2020-10-26 Thread Vineet Gupta
Hi Geert,

On 10/26/20 2:48 AM, Geert Uytterhoeven wrote:
> On Mon, Oct 26, 2020 at 10:46 AM Geert Uytterhoeven
>  wrote:
>> Below is the list of build error/warning regressions/improvements in
>> v5.10-rc1[1] compared to v5.9[2].
>>
>> Summarized:
>>   - build errors: +3/-7
>>   - build warnings: +26/-28
>>
>>
>>   + {standard input}: Error: inappropriate arguments for opcode 'adc':  => 
>> 170
> arc-gcc10/axs101_defconfig

Thx for bringing this to our notice. Alexey / Claudiu - are we testing gcc-10 
for
ARC700 - It seemsv5.10-rcX kerne is unearthing some sort of compiler issue

http://kisskb.ellerman.id.au/kisskb/branch/linus/head/3650b228f83adda7e5ee532e2b90429c03f7b9ec/
http://kisskb.ellerman.id.au/kisskb/target/189425/
http://kisskb.ellerman.id.au/kisskb/buildresult/14384487/log/

>

# < make -s -j 24 ARCH=arc O=/kisskb/build/linus_axs101_defconfig_arc-gcc10 
CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-10.1.0-nolibc/arc-linux/bin/arc-linux- 
 help
# make -s -j 24 ARCH=arc O=/kisskb/build/linus_axs101_defconfig_arc-gcc10 
CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-10.1.0-nolibc/arc-linux/bin/arc-linux- 
 olddefconfig
# make -s -j 24 ARCH=arc O=/kisskb/build/linus_axs101_defconfig_arc-gcc10 
CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-10.1.0-nolibc/arc-linux/bin/arc-linux- 
 
{standard input}: Assembler messages:
{standard input}:170: Error: inappropriate arguments for opcode 'adc'
make[2]: *** [/kisskb/src/scripts/Makefile.build:283: fs/remap_range.o] Error 1
make[2]: *** Waiting for unfinished jobs
make[1]: *** [/kisskb/src/Makefile:1799: fs] Error 2
make[1]: *** Waiting for unfinished jobs
make: *** [Makefile:185: __sub-make] Error 2
Command 'make -s -j 24 ARCH=arc 
O=/kisskb/build/linus_axs101_defconfig_arc-gcc10 
CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-10.1.0-nolibc/arc-linux/bin/arc-linux- 
 ' returned non-zero exit status 2
# rm -rf /kisskb/build/linus_axs101_defconfig_arc-gcc10
# Build took: 0:01:21.179119



[GIT PULL] ARC fix for 5.10-rc1

2020-10-22 Thread Vineet Gupta
Hi Linus,

This is an unusual 2nd pull request for merge window. I found a snafu in perf
driver which made it into 5.9-rc4 and thus the fix could go in now than wait for
5.10-rc2. Sorry for the trouble.

Thx,
-Vineet
->
The following changes since commit 6364d1b41cc382db3b03cf33c57b6007ee8f09cf:

  arc: include/asm: fix typos of "themselves" (2020-10-05 21:02:29 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git/
tags/arc-5.10-rc1-fixes

for you to fetch changes up to 8c42a5c02bec6c7eccf08957be3c6c8fccf9790b:

  ARC: perf: redo the pct irq missing in device-tree handling (2020-10-22 
10:57:58
-0700)


Urgent perf ARC fix

----
Vineet Gupta (1):
  ARC: perf: redo the pct irq missing in device-tree handling

 arch/arc/kernel/perf_event.c | 27 ++-
 1 file changed, 18 insertions(+), 9 deletions(-)


[PATCH] Revert "ARC: entry: fix potential EFA clobber when TIF_SYSCALL_TRACE"

2020-10-19 Thread Vineet Gupta
This reverts commit 00fdec98d9881bf5173af09aebd353ab3b9ac729.
(but only from 5.2 and prior kernels)

The original commit was a preventive fix based on code-review and was
auto-picked for stable back-port (for better or worse).
It was OK for v5.3+ kernels, but turned up needing an implicit change
68e5c6f073bcf70 "(ARC: entry: EV_Trap expects r10 (vs. r9) to have
 exception cause)" merged in v5.3 which itself was not backported.
So to summarize the stable backport of this patch for v5.2 and prior
kernels is busted and it won't boot.

The obvious solution is backport 68e5c6f073bcf70 but that is a pain as
it doesn't revert cleanly and each of affected kernels (so far v4.19,
v4.14, v4.9, v4.4) needs a slightly different massaged varaint.
So the easier fix is to simply revert the backport from 5.2 and prior.
The issue was not a big deal as it would cause strace to sporadically
not work correctly.

Waldemar Brodkorb first reported this when running ARC uClibc regressions
on latest stable kernels (with offending backport). Once he bisected it,
the analysis was trivial, so thx to him for this.

Reported-by: Waldemar Brodkorb 
Bisected-by: Waldemar Brodkorb 
Cc: stable  # 5.2 and prior
Signed-off-by: Vineet Gupta 
---
 arch/arc/kernel/entry.S | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
index ea00c8a17f07..60406ec62eb8 100644
--- a/arch/arc/kernel/entry.S
+++ b/arch/arc/kernel/entry.S
@@ -165,6 +165,7 @@ END(EV_Extension)
 tracesys:
; save EFA in case tracer wants the PC of traced task
; using ERET won't work since next-PC has already committed
+   lr  r12, [efa]
GET_CURR_TASK_FIELD_PTR   TASK_THREAD, r11
st  r12, [r11, THREAD_FAULT_ADDR]   ; thread.fault_address
 
@@ -207,9 +208,15 @@ tracesys_exit:
 ; Breakpoint TRAP
 ; -
 trap_with_param:
-   mov r0, r12 ; EFA in case ptracer/gdb wants stop_pc
+
+   ; stop_pc info by gdb needs this info
+   lr  r0, [efa]
mov r1, sp
 
+   ; Now that we have read EFA, it is safe to do "fake" rtie
+   ;   and get out of CPU exception mode
+   FAKE_RET_FROM_EXCPN
+
; Save callee regs in case gdb wants to have a look
; SP will grow up by size of CALLEE Reg-File
; NOTE: clobbers r12
@@ -236,10 +243,6 @@ ENTRY(EV_Trap)
 
EXCEPTION_PROLOGUE
 
-   lr  r12, [efa]
-
-   FAKE_RET_FROM_EXCPN
-
; TRAP 1   :breakpoints
; Check ECR for trap with arg (PROLOGUE ensures r10 has ECR)
bmsk.f 0, r10, 7
@@ -247,6 +250,9 @@ ENTRY(EV_Trap)
 
; TRAP  (no param): syscall top level
 
+   ; First return from Exception to pure K mode (Exception/IRQs renabled)
+   FAKE_RET_FROM_EXCPN
+
; If syscall tracing ongoing, invoke pre-post-hooks
GET_CURR_THR_INFO_FLAGS   r10
btst r10, TIF_SYSCALL_TRACE
-- 
2.25.1



[GIT PULL] ARC changes for 5.10-rc1

2020-10-19 Thread Vineet Gupta
Hi Linus,

The bulk of ARC pull request is removal of EZChip NPS platform which was 
suffering
from constant bitrot. In recent years EZChip has gone though multiple successive
acquisitions and I guess things and people move on. I would like to take this
opportunity to recognize and thank all those good folks (Gilad, Noam, Ofer...) 
for
contributing major bits to ARC port (SMP, Big Endian)

Please pull.

Thx,
-Vineet
->
The following changes since commit 549738f15da0e5a00275977623be199fbbf7df50:

  Linux 5.9-rc8 (2020-10-04 16:04:34 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git/ 
tags/arc-5.10-rc1

for you to fetch changes up to 6364d1b41cc382db3b03cf33c57b6007ee8f09cf:

  arc: include/asm: fix typos of "themselves" (2020-10-05 21:02:29 -0700)


ARC changes for 5.10

 - Drop support for EZChip NPS platform

 - miscll other fixes


Mike Rapoport (1):
  ARC: SMP: fix typo and use "come up" instead of "comeup"

Necip Fazil Yildiran (1):
  arc: plat-hsdk: fix kconfig dependency warning when !RESET_CONTROLLER

Randy Dunlap (1):
  arc: include/asm: fix typos of "themselves"

Vineet Gupta (1):
  ARC: [plat-eznps]: Drop support for EZChip NPS platform

Zhen Lei (1):
  ARC: [dts] fix the errors detected by dtbs_check

 MAINTAINERS |   7 --
 arch/arc/Kconfig|   2 -
 arch/arc/Makefile   |   5 -
 arch/arc/boot/dts/axc001.dtsi   |   2 +-
 arch/arc/boot/dts/axc003.dtsi   |   2 +-
 arch/arc/boot/dts/axc003_idu.dtsi   |   2 +-
 arch/arc/boot/dts/eznps.dts |  84 -
 arch/arc/boot/dts/vdk_axc003.dtsi   |   2 +-
 arch/arc/boot/dts/vdk_axc003_idu.dtsi   |   2 +-
 arch/arc/configs/nps_defconfig  |  80 
 arch/arc/include/asm/atomic.h   | 108 +
 arch/arc/include/asm/barrier.h  |   9 +-
 arch/arc/include/asm/bitops.h   |  58 +
 arch/arc/include/asm/cmpxchg.h  |  72 +--
 arch/arc/include/asm/entry-compact.h|  27 -
 arch/arc/include/asm/processor.h|  37 --
 arch/arc/include/asm/ptrace.h   |   5 -
 arch/arc/include/asm/setup.h|   4 -
 arch/arc/include/asm/spinlock.h |   6 -
 arch/arc/include/asm/switch_to.h|   9 --
 arch/arc/kernel/ctx_sw.c|  13 --
 arch/arc/kernel/devtree.c   |   2 -
 arch/arc/kernel/process.c   |  15 ---
 arch/arc/kernel/smp.c   |   2 +-
 arch/arc/mm/tlbex.S |   7 --
 arch/arc/plat-eznps/Kconfig |  58 -
 arch/arc/plat-eznps/Makefile|   8 --
 arch/arc/plat-eznps/ctop.c  |  21 
 arch/arc/plat-eznps/entry.S |  60 -
 arch/arc/plat-eznps/include/plat/ctop.h | 208 
 arch/arc/plat-eznps/include/plat/mtm.h  |  49 
 arch/arc/plat-eznps/include/plat/smp.h  |  15 ---
 arch/arc/plat-eznps/mtm.c   | 166 -
 arch/arc/plat-eznps/platform.c  |  91 --
 arch/arc/plat-eznps/smp.c   | 138 -
 arch/arc/plat-hsdk/Kconfig  |   1 +
 36 files changed, 15 insertions(+), 1362 deletions(-)
 delete mode 100644 arch/arc/boot/dts/eznps.dts
 delete mode 100644 arch/arc/configs/nps_defconfig
 delete mode 100644 arch/arc/plat-eznps/Kconfig
 delete mode 100644 arch/arc/plat-eznps/Makefile
 delete mode 100644 arch/arc/plat-eznps/ctop.c
 delete mode 100644 arch/arc/plat-eznps/entry.S
 delete mode 100644 arch/arc/plat-eznps/include/plat/ctop.h
 delete mode 100644 arch/arc/plat-eznps/include/plat/mtm.h
 delete mode 100644 arch/arc/plat-eznps/include/plat/smp.h
 delete mode 100644 arch/arc/plat-eznps/mtm.c
 delete mode 100644 arch/arc/plat-eznps/platform.c
 delete mode 100644 arch/arc/plat-eznps/smp.c


Re: [PATCH] fs: dax: fix build error on ARC

2020-10-06 Thread Vineet Gupta
On 10/6/20 7:54 PM, Randy Dunlap wrote:
> From: Randy Dunlap 
> 
> fs/dax.c uses copy_user_page() but ARC does not provide that interface,
> resulting in a build error.
> 
> Provide copy_user_page() in  (beside copy_page()) and
> add  to fs/dax.c to fix the build error.
> 
> ../fs/dax.c: In function 'copy_cow_page_dax':
> ../fs/dax.c:702:2: error: implicit declaration of function 'copy_user_page'; 
> did you mean 'copy_to_user_page'? [-Werror=implicit-function-declaration]
> 
> Fixes: cccbce671582 ("filesystem-dax: convert to dax_direct_access()")
> Reported-by: kernel test robot 
> Signed-off-by: Randy Dunlap 
> Cc: Vineet Gupta 
> Cc: linux-snps-...@lists.infradead.org
> Cc: Dan Williams 
> ---
> Vineet, This patch fixes the build error but is it correct for ARC?

Yep this looks good. Nothing special needs to be done for user pages on ARC.

Acked-by: Vineet Gupta 

Thx,
-Vineet

> 
>  arch/arc/include/asm/page.h |1 +
>  fs/dax.c|1 +
>  2 files changed, 2 insertions(+)
> 
> --- lnx-59-rc7.orig/fs/dax.c
> +++ lnx-59-rc7/fs/dax.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #define CREATE_TRACE_POINTS
> --- lnx-59-rc7.orig/arch/arc/include/asm/page.h
> +++ lnx-59-rc7/arch/arc/include/asm/page.h
> @@ -10,6 +10,7 @@
>  #ifndef __ASSEMBLY__
>  
>  #define clear_page(paddr)memset((paddr), 0, PAGE_SIZE)
> +#define copy_user_page(to, from, vaddr, pg)  copy_page(to, from)
>  #define copy_page(to, from)  memcpy((to), (from), PAGE_SIZE)
>  
>  struct vm_area_struct;
> 
> 



Re: [PATCH] arc: include/asm: fix typos of "themselves"

2020-10-05 Thread Vineet Gupta
On 10/5/20 8:30 PM, Randy Dunlap wrote:
> From: Randy Dunlap 
> 
> Fix copy/paste spello of "themselves" in 3 places.
> 
> Signed-off-by: Randy Dunlap 
> Cc: Vineet Gupta 
> Cc: linux-snps-...@lists.infradead.org

Thx for the fix Randy. Added to for-curr.
-Vineet

> ---
>  arch/arc/include/asm/atomic.h  |4 ++--
>  arch/arc/include/asm/cmpxchg.h |2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> --- lnx-59-rc7.orig/arch/arc/include/asm/atomic.h
> +++ lnx-59-rc7/arch/arc/include/asm/atomic.h
> @@ -45,7 +45,7 @@ static inline int atomic_##op##_return(i
>   \
>   /*  \
>* Explicit full memory barrier needed before/after as  \
> -  * LLOCK/SCOND thmeselves don't provide any such semantics  \
> +  * LLOCK/SCOND themselves don't provide any such semantics  \
>*/ \
>   smp_mb();   \
>   \
> @@ -71,7 +71,7 @@ static inline int atomic_fetch_##op(int
>   \
>   /*  \
>* Explicit full memory barrier needed before/after as  \
> -  * LLOCK/SCOND thmeselves don't provide any such semantics  \
> +  * LLOCK/SCOND themselves don't provide any such semantics  \
>*/ \
>   smp_mb();   \
>   \
> --- lnx-59-rc7.orig/arch/arc/include/asm/cmpxchg.h
> +++ lnx-59-rc7/arch/arc/include/asm/cmpxchg.h
> @@ -20,7 +20,7 @@ __cmpxchg(volatile void *ptr, unsigned l
>  
>   /*
>* Explicit full memory barrier needed before/after as
> -  * LLOCK/SCOND thmeselves don't provide any such semantics
> +  * LLOCK/SCOND themselves don't provide any such semantics
>*/
>   smp_mb();
>  
> 
> 



Re: [PATCH] ARC: SMP: fix typo and use "come up" instead of "comeup"

2020-10-05 Thread Vineet Gupta
On 10/5/20 9:12 AM, Mike Rapoport wrote:
> From: Mike Rapoport 
> 
> When a secondary CPU fails to come up, there is a missing space in the
> log:
> 
>   Timeout: CPU1 FAILED to comeup !!!
> 
> Fix it.
> 
> Signed-off-by: Mike Rapoport 

Thx for the fix Mike. Added to for-curr.
-Vineet

> ---
>  arch/arc/kernel/smp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
> index eca35e02ce06..52906d314537 100644
> --- a/arch/arc/kernel/smp.c
> +++ b/arch/arc/kernel/smp.c
> @@ -226,7 +226,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
>   }
>  
>   if (!cpu_online(cpu)) {
> - pr_info("Timeout: CPU%u FAILED to comeup !!!\n", cpu);
> + pr_info("Timeout: CPU%u FAILED to come up !!!\n", cpu);
>   return -1;
>   }
>  
> 



Re: ARC: allmodconfig: Error: inappropriate arguments for opcode 'mpyd'

2020-09-28 Thread Vineet Gupta
Hi Naresh,

On 9/23/20 9:20 PM, Naresh Kamboju wrote:
> arc:allmodconfig build failed with gcc-8, gcc-9 and gcc-10 on Linus's
> mainline tree.
> 
> Build log:
> 
> make -sk KBUILD_BUILD_USER=TuxBuild -C/linux ARCH=arc
> CROSS_COMPILE=arc-elf32- HOSTCC=gcc CC="sccache arc-elf32-gcc" O=build
> allmodconfig
> 
> make -sk KBUILD_BUILD_USER=TuxBuild -C/linux -j16 ARCH=arc
> CROSS_COMPILE=arc-elf32- HOSTCC=gcc CC="sccache arc-elf32-gcc" O=build
> uImage
> 

...

> {standard input}: Assembler messages:
> {standard input}:9360: Error: inappropriate arguments for opcode 'mpyd'
> make[3]: *** [../scripts/Makefile.build:283: kernel/sched/core.o] Error 1

Thx for testing this and bringing to our attention.
I've created a github issue for gcc.

https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/issues/300

We will also look at bunch of other warnings being spit out.

Thx,
-Vineet


Re: [PATCH v6 6/6] ARC: [dts] fix the errors detected by dtbs_check

2020-09-28 Thread Vineet Gupta
On 9/24/20 12:17 AM, Zhen Lei wrote:
> xxx/arc/boot/dts/axs101.dt.yaml: dw-apb-ictl@e0012000: $nodename:0: \
> 'dw-apb-ictl@e0012000' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
> From schema: xxx/interrupt-controller/snps,dw-apb-ictl.yaml
> 
> The node name of the interrupt controller must start with
> "interrupt-controller" instead of "dw-apb-ictl".
> 
> Signed-off-by: Zhen Lei 

Thx, I've queued this up to ARC for-curr.

-Vineet

> ---
>  arch/arc/boot/dts/axc001.dtsi | 2 +-
>  arch/arc/boot/dts/axc003.dtsi | 2 +-
>  arch/arc/boot/dts/axc003_idu.dtsi | 2 +-
>  arch/arc/boot/dts/vdk_axc003.dtsi | 2 +-
>  arch/arc/boot/dts/vdk_axc003_idu.dtsi | 2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arc/boot/dts/axc001.dtsi b/arch/arc/boot/dts/axc001.dtsi
> index 79ec27c043c1da7..2a151607b08057c 100644
> --- a/arch/arc/boot/dts/axc001.dtsi
> +++ b/arch/arc/boot/dts/axc001.dtsi
> @@ -91,7 +91,7 @@
>* avoid duplicating the MB dtsi file given that IRQ from
>* this intc to cpu intc are different for axs101 and axs103
>*/
> - mb_intc: dw-apb-ictl@e0012000 {
> + mb_intc: interrupt-controller@e0012000 {
>   #interrupt-cells = <1>;
>   compatible = "snps,dw-apb-ictl";
>   reg = < 0x0 0xe0012000 0x0 0x200 >;
> diff --git a/arch/arc/boot/dts/axc003.dtsi b/arch/arc/boot/dts/axc003.dtsi
> index ac8e1b463a70992..cd1edcf4f95efe6 100644
> --- a/arch/arc/boot/dts/axc003.dtsi
> +++ b/arch/arc/boot/dts/axc003.dtsi
> @@ -129,7 +129,7 @@
>* avoid duplicating the MB dtsi file given that IRQ from
>* this intc to cpu intc are different for axs101 and axs103
>*/
> - mb_intc: dw-apb-ictl@e0012000 {
> + mb_intc: interrupt-controller@e0012000 {
>   #interrupt-cells = <1>;
>   compatible = "snps,dw-apb-ictl";
>   reg = < 0x0 0xe0012000 0x0 0x200 >;
> diff --git a/arch/arc/boot/dts/axc003_idu.dtsi 
> b/arch/arc/boot/dts/axc003_idu.dtsi
> index 9da21e7fd246f9f..70779386ca7963a 100644
> --- a/arch/arc/boot/dts/axc003_idu.dtsi
> +++ b/arch/arc/boot/dts/axc003_idu.dtsi
> @@ -135,7 +135,7 @@
>* avoid duplicating the MB dtsi file given that IRQ from
>* this intc to cpu intc are different for axs101 and axs103
>*/
> - mb_intc: dw-apb-ictl@e0012000 {
> + mb_intc: interrupt-controller@e0012000 {
>   #interrupt-cells = <1>;
>   compatible = "snps,dw-apb-ictl";
>   reg = < 0x0 0xe0012000 0x0 0x200 >;
> diff --git a/arch/arc/boot/dts/vdk_axc003.dtsi 
> b/arch/arc/boot/dts/vdk_axc003.dtsi
> index f8be7ba8dad499c..c21d0eb07bf6737 100644
> --- a/arch/arc/boot/dts/vdk_axc003.dtsi
> +++ b/arch/arc/boot/dts/vdk_axc003.dtsi
> @@ -46,7 +46,7 @@
>  
>   };
>  
> - mb_intc: dw-apb-ictl@e0012000 {
> + mb_intc: interrupt-controller@e0012000 {
>   #interrupt-cells = <1>;
>   compatible = "snps,dw-apb-ictl";
>   reg = < 0xe0012000 0x200 >;
> diff --git a/arch/arc/boot/dts/vdk_axc003_idu.dtsi 
> b/arch/arc/boot/dts/vdk_axc003_idu.dtsi
> index 0afa3e53a4e3932..4d348853ac7c5dc 100644
> --- a/arch/arc/boot/dts/vdk_axc003_idu.dtsi
> +++ b/arch/arc/boot/dts/vdk_axc003_idu.dtsi
> @@ -54,7 +54,7 @@
>  
>   };
>  
> - mb_intc: dw-apb-ictl@e0012000 {
> + mb_intc: interrupt-controller@e0012000 {
>   #interrupt-cells = <1>;
>   compatible = "snps,dw-apb-ictl";
>   reg = < 0xe0012000 0x200 >;
> 



Re: [PATCH] arc: plat-hsdk: fix kconfig dependency warning when !RESET_CONTROLLER

2020-09-14 Thread Vineet Gupta
On 9/14/20 4:46 AM, Necip Fazil Yildiran wrote:
> When ARC_SOC_HSDK is enabled and RESET_CONTROLLER is disabled, it results
> in the following Kbuild warning:
>
> WARNING: unmet direct dependencies detected for RESET_HSDK
>   Depends on [n]: RESET_CONTROLLER [=n] && HAS_IOMEM [=y] && (ARC_SOC_HSDK 
> [=y] || COMPILE_TEST [=n])
>   Selected by [y]:
>   - ARC_SOC_HSDK [=y] && ISA_ARCV2 [=y]
>
> The reason is that ARC_SOC_HSDK selects RESET_HSDK without depending on or
> selecting RESET_CONTROLLER while RESET_HSDK is subordinate to
> RESET_CONTROLLER.
>
> Honor the kconfig menu hierarchy to remove kconfig dependency warnings.
>
> Fixes: a528629dfd3b ("ARC: [plat-hsdk] select CONFIG_RESET_HSDK from Kconfig")
> Signed-off-by: Necip Fazil Yildiran 


Applied to for-curr

Thx,
-Vineet

> ---
>  arch/arc/plat-hsdk/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arc/plat-hsdk/Kconfig b/arch/arc/plat-hsdk/Kconfig
> index ce8101834518..6b5c54576f54 100644
> --- a/arch/arc/plat-hsdk/Kconfig
> +++ b/arch/arc/plat-hsdk/Kconfig
> @@ -8,5 +8,6 @@ menuconfig ARC_SOC_HSDK
>   select ARC_HAS_ACCL_REGS
>   select ARC_IRQ_NO_AUTOSAVE
>   select CLK_HSDK
> + select RESET_CONTROLLER
>   select RESET_HSDK
>   select HAVE_PCI



[PATCH] ARC: [plat-eznps]: Drop support for EZChip NPS platform

2020-09-08 Thread Vineet Gupta
NPS customers are no longer doing active development, as evident from
rand config build failures reported in recent times, so drop support
for NPS platform.

Signed-off-by: Vineet Gupta 
---
 MAINTAINERS |   7 -
 arch/arc/Makefile   |   5 -
 arch/arc/configs/nps_defconfig  |  80 -
 arch/arc/include/asm/atomic.h   | 104 
 arch/arc/include/asm/barrier.h  |   9 +-
 arch/arc/include/asm/bitops.h   |  58 +--
 arch/arc/include/asm/cmpxchg.h  |  70 +---
 arch/arc/include/asm/entry-compact.h|  27 ---
 arch/arc/include/asm/processor.h|  37 -
 arch/arc/include/asm/ptrace.h   |   5 -
 arch/arc/include/asm/setup.h|   4 -
 arch/arc/include/asm/spinlock.h |   6 -
 arch/arc/include/asm/switch_to.h|   9 -
 arch/arc/kernel/ctx_sw.c|  13 --
 arch/arc/kernel/process.c   |  15 --
 arch/arc/mm/tlbex.S |   7 -
 arch/arc/plat-eznps/Kconfig |  58 ---
 arch/arc/plat-eznps/Makefile|   8 -
 arch/arc/plat-eznps/ctop.c  |  21 ---
 arch/arc/plat-eznps/entry.S |  60 ---
 arch/arc/plat-eznps/include/plat/ctop.h | 208 
 arch/arc/plat-eznps/include/plat/mtm.h  |  49 --
 arch/arc/plat-eznps/include/plat/smp.h  |  15 --
 arch/arc/plat-eznps/mtm.c   | 166 ---
 arch/arc/plat-eznps/platform.c  |  91 ---
 arch/arc/plat-eznps/smp.c   | 138 
 26 files changed, 5 insertions(+), 1265 deletions(-)
 delete mode 100644 arch/arc/configs/nps_defconfig
 delete mode 100644 arch/arc/plat-eznps/Kconfig
 delete mode 100644 arch/arc/plat-eznps/Makefile
 delete mode 100644 arch/arc/plat-eznps/ctop.c
 delete mode 100644 arch/arc/plat-eznps/entry.S
 delete mode 100644 arch/arc/plat-eznps/include/plat/ctop.h
 delete mode 100644 arch/arc/plat-eznps/include/plat/mtm.h
 delete mode 100644 arch/arc/plat-eznps/include/plat/smp.h
 delete mode 100644 arch/arc/plat-eznps/mtm.c
 delete mode 100644 arch/arc/plat-eznps/platform.c
 delete mode 100644 arch/arc/plat-eznps/smp.c

diff --git a/MAINTAINERS b/MAINTAINERS
index b5cfab015bd6..72b4c44ac37b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6614,13 +6614,6 @@ L:   io...@lists.linux-foundation.org
 S: Maintained
 F: drivers/iommu/exynos-iommu.c
 
-EZchip NPS platform support
-M: Vineet Gupta 
-M: Ofer Levi 
-S: Supported
-F: arch/arc/boot/dts/eznps.dts
-F: arch/arc/plat-eznps
-
 F2FS FILE SYSTEM
 M: Jaegeuk Kim 
 M: Chao Yu 
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index d00f8b8afd08..0c6bf0d1df7a 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -94,13 +94,8 @@ core-y   += arch/arc/boot/dts/
 core-y += arch/arc/plat-sim/
 core-$(CONFIG_ARC_PLAT_TB10X)  += arch/arc/plat-tb10x/
 core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/
-core-$(CONFIG_ARC_PLAT_EZNPS)  += arch/arc/plat-eznps/
 core-$(CONFIG_ARC_SOC_HSDK)+= arch/arc/plat-hsdk/
 
-ifdef CONFIG_ARC_PLAT_EZNPS
-KBUILD_CPPFLAGS += -I$(srctree)/arch/arc/plat-eznps/include
-endif
-
 drivers-$(CONFIG_OPROFILE) += arch/arc/oprofile/
 
 libs-y += arch/arc/lib/ $(LIBGCC)
diff --git a/arch/arc/configs/nps_defconfig b/arch/arc/configs/nps_defconfig
deleted file mode 100644
index f7a978dfdf1d..
--- a/arch/arc/configs/nps_defconfig
+++ /dev/null
@@ -1,80 +0,0 @@
-# CONFIG_LOCALVERSION_AUTO is not set
-# CONFIG_SWAP is not set
-CONFIG_SYSVIPC=y
-CONFIG_NO_HZ_IDLE=y
-CONFIG_HIGH_RES_TIMERS=y
-CONFIG_IKCONFIG=y
-CONFIG_IKCONFIG_PROC=y
-CONFIG_BLK_DEV_INITRD=y
-CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
-# CONFIG_EPOLL is not set
-# CONFIG_SIGNALFD is not set
-# CONFIG_TIMERFD is not set
-# CONFIG_EVENTFD is not set
-# CONFIG_AIO is not set
-CONFIG_EMBEDDED=y
-CONFIG_PERF_EVENTS=y
-# CONFIG_COMPAT_BRK is not set
-CONFIG_ISA_ARCOMPACT=y
-CONFIG_KPROBES=y
-CONFIG_MODULES=y
-CONFIG_MODULE_FORCE_LOAD=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_BLK_DEV_BSG is not set
-CONFIG_ARC_PLAT_EZNPS=y
-CONFIG_SMP=y
-CONFIG_NR_CPUS=4096
-CONFIG_ARC_CACHE_LINE_SHIFT=5
-# CONFIG_ARC_CACHE_PAGES is not set
-# CONFIG_ARC_HAS_LLSC is not set
-CONFIG_ARC_KVADDR_SIZE=402
-CONFIG_ARC_EMUL_UNALIGNED=y
-CONFIG_PREEMPT=y
-CONFIG_NET=y
-CONFIG_UNIX=y
-CONFIG_INET=y
-CONFIG_IP_PNP=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_INET_DIAG is not set
-# CONFIG_IPV6 is not set
-# CONFIG_WIRELESS is not set
-CONFIG_DEVTMPFS=y
-CONFIG_DEVTMPFS_MOUNT=y
-# CONFIG_PREVENT_FIRMWARE_BUILD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_COUNT=1
-CONFIG_BLK_DEV_RAM_SIZE=2048
-CONFIG_NETDEVICES=y
-CONFIG_NETCONSOLE=y
-# CONFIG_NET_VENDOR_BROADCOM is not set
-# CONFIG_NET_VENDOR_MICREL is not set
-# CONFIG_NET_VENDOR_STMICRO is not set
-# CONFIG_WLAN

[GIT PULL] ARC updates for 5.9-rc4

2020-09-04 Thread Vineet Gupta
Hi Linus,

Please pull.

Thx,
-Vineet
--->
The following changes since commit 9123e3a74ec7b934a4a099e98af6a61c2f80bbf5:

  Linux 5.9-rc1 (2020-08-16 13:04:57 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git/ tags/arc-5.9-rc4

for you to fetch changes up to 26907eb605fbc3ba9dbf888f21d9d8d04471271d:

  ARC: [plat-hsdk]: Switch ethernet phy-mode to rgmii-id (2020-09-01 11:59:04 
-0700)


ARC fixes for 5.9-rc4

 - HSDK-4xd Dev system: perf driver updates for sampling interrupt

 - HSDK* Dev System : Ethernet broken   [Evgeniy Didin]

 - HIGHMEM broken (2 memory banks)  [Mike Rapoport]

 - show_regs() rewrite once and for all

 - Other minor fixes


Evgeniy Didin (1):
  ARC: [plat-hsdk]: Switch ethernet phy-mode to rgmii-id

Mike Rapoport (1):
  arc: fix memory initialization for systems with two memory banks

Randy Dunlap (1):
  ARC: pgalloc.h: delete a duplicated word + other fixes

Vineet Gupta (4):
  ARC: perf: don't bail setup if pct irq missing in device-tree
  ARC: HSDK: wireup perf irq
  ARC: show_regs: fix r12 printing and simplify
  irqchip/eznps: Fix build error for !ARC700 builds

 arch/arc/boot/dts/hsdk.dts  |  6 ++-
 arch/arc/include/asm/pgalloc.h  |  4 +-
 arch/arc/kernel/perf_event.c| 14 ++
 arch/arc/kernel/troubleshoot.c  | 77 +
 arch/arc/mm/init.c  | 27 +++-
 arch/arc/plat-eznps/include/plat/ctop.h |  1 -
 include/soc/nps/common.h|  6 +++
 7 files changed, 62 insertions(+), 73 deletions(-)


Re: [PATCH v3 03/23] arc: use asm-generic/mmu_context.h for no-op implementations

2020-09-01 Thread Vineet Gupta
On 9/1/20 7:15 AM, Nicholas Piggin wrote:
> Cc: Vineet Gupta 
> Cc: linux-snps-...@lists.infradead.org
> Signed-off-by: Nicholas Piggin 

Acked-by: Vineet Gupta#arch/arc

Thx,
-Vineet

> ---
> 
> Please ack or nack if you object to this being mered via
> Arnd's tree.
> 
>  arch/arc/include/asm/mmu_context.h | 17 +
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arc/include/asm/mmu_context.h 
> b/arch/arc/include/asm/mmu_context.h
> index 3a5e6a5b9ed6..df164066e172 100644
> --- a/arch/arc/include/asm/mmu_context.h
> +++ b/arch/arc/include/asm/mmu_context.h
> @@ -102,6 +102,7 @@ static inline void get_new_mmu_context(struct mm_struct 
> *mm)
>   * Initialize the context related info for a new mm_struct
>   * instance.
>   */
> +#define init_new_context init_new_context
>  static inline int
>  init_new_context(struct task_struct *tsk, struct mm_struct *mm)
>  {
> @@ -113,6 +114,7 @@ init_new_context(struct task_struct *tsk, struct 
> mm_struct *mm)
>   return 0;
>  }
>  
> +#define destroy_context destroy_context
>  static inline void destroy_context(struct mm_struct *mm)
>  {
>   unsigned long flags;
> @@ -153,13 +155,13 @@ static inline void switch_mm(struct mm_struct *prev, 
> struct mm_struct *next,
>  }
>  
>  /*
> - * Called at the time of execve() to get a new ASID
> - * Note the subtlety here: get_new_mmu_context() behaves differently here
> - * vs. in switch_mm(). Here it always returns a new ASID, because mm has
> - * an unallocated "initial" value, while in latter, it moves to a new ASID,
> - * only if it was unallocated
> + * activate_mm defaults (in asm-generic) to switch_mm and is called at the
> + * time of execve() to get a new ASID Note the subtlety here:
> + * get_new_mmu_context() behaves differently here vs. in switch_mm(). Here
> + * it always returns a new ASID, because mm has an unallocated "initial"
> + * value, while in latter, it moves to a new ASID, only if it was
> + * unallocated
>   */
> -#define activate_mm(prev, next)  switch_mm(prev, next, NULL)
>  
>  /* it seemed that deactivate_mm( ) is a reasonable place to do book-keeping
>   * for retiring-mm. However destroy_context( ) still needs to do that because
> @@ -168,8 +170,7 @@ static inline void switch_mm(struct mm_struct *prev, 
> struct mm_struct *next,
>   * there is a good chance that task gets sched-out/in, making it's ASID valid
>   * again (this teased me for a whole day).
>   */
> -#define deactivate_mm(tsk, mm)   do { } while (0)
>  
> -#define enter_lazy_tlb(mm, tsk)
> +#include 
>  
>  #endif /* __ASM_ARC_MMU_CONTEXT_H */
> 



Re: linux-next: Fixes tag needs some work in the arc-current tree

2020-09-01 Thread Vineet Gupta
On 9/1/20 4:36 AM, Stephen Rothwell wrote:
> Hi Mike,
>
> On Tue, 1 Sep 2020 12:13:08 +0300 Mike Rapoport  wrote:
>> On Tue, Sep 01, 2020 at 06:49:28PM +1000, Stephen Rothwell wrote:
>>> In commit
>>>
>>>   7000c9462d1b ("arc: fix memory initialization for systems with two memory 
>>> banks")
>>>
>>> Fixes tag
>>>
>>>   Fixes: 51930df5801e ("mm: free_area_init: allow defining max_zone_pfn in 
>>> descend ing order")  
>> It's line rewrapping:
>>^
> Yeah, wrapped and then unwrapped with an extra space :-(

Its vim's doing. Now fixed and pushed !

Thx,
-Vineet


Re: [PATCH] arc: fix memory initialization for systems with two memory banks

2020-08-28 Thread Vineet Gupta
Hi Mike,

On 8/28/20 9:39 AM, Mike Rapoport wrote:
> From: Mike Rapoport 
>
> Rework if memory map initialization broke initialization of ARC systems
> with two memory banks. Before these changes, memblock was not aware of
> nodes configuration and the memory map was always allocated from the
> "lowmem" bank. After the addition of node information to memblock, the core
> mm attempts to allocate the memory map for the "highmem" bank from its
> node. The access to this memory using __va() fails because it can be only
> accessed using kmap.
>
> Anther problem that was uncovered is that {min,max}_high_pfn are calculated
> from u64 high_mem_start variable which prevents truncation to 32-bit
> physical address and the PFN values are above the node and zone boundaries.

Not sure if I quite follow this part. We should not be relying on truncation: 
the
pfn should be derived off of zone addresses ?

> Use phys_addr_t type for high_mem_start and high_mem_size to ensure
> correspondence between PFNs and highmem zone boundaries and reserve the
> entire highmem bank until mem_init() to avoid accesses to it before highmem
> is enabled.
>
> Fixes: 51930df5801e ("mm: free_area_init: allow defining max_zone_pfn in 
> descend ing order")
> Signed-off-by: Mike Rapoport 

Thx for the fix. I verified that a 2 mem bank system with HIGHMEM enabled now
works again.
And I've also added a couple of lines to changelog to describe how to test such 
a
config.

|    To test this:
|    1. Enable HIGHMEM in ARC config
|    2. Enable 2 memory banks in haps_hs.dts (uncomment the 2nd bank)


> ---
>  arch/arc/mm/init.c | 27 ---
>  1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
> index f886ac69d8ad..3a35b82a718e 100644
> --- a/arch/arc/mm/init.c
> +++ b/arch/arc/mm/init.c
> @@ -26,8 +26,8 @@ static unsigned long low_mem_sz;
>  
>  #ifdef CONFIG_HIGHMEM
>  static unsigned long min_high_pfn, max_high_pfn;
> -static u64 high_mem_start;
> -static u64 high_mem_sz;
> +static phys_addr_t high_mem_start;
> +static phys_addr_t high_mem_sz;
>  #endif
>  
>  #ifdef CONFIG_DISCONTIGMEM
> @@ -69,6 +69,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 
> size)
>   high_mem_sz = size;
>   in_use = 1;
>   memblock_add_node(base, size, 1);
> + memblock_reserve(base, size);
>  #endif
>   }
>  
> @@ -157,7 +158,7 @@ void __init setup_arch_memory(void)
>   min_high_pfn = PFN_DOWN(high_mem_start);
>   max_high_pfn = PFN_DOWN(high_mem_start + high_mem_sz);
>  
> - max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn;
> + max_zone_pfn[ZONE_HIGHMEM] = min_low_pfn;
>  
>   high_memory = (void *)(min_high_pfn << PAGE_SHIFT);
>   kmap_init();
> @@ -166,22 +167,26 @@ void __init setup_arch_memory(void)
>   free_area_init(max_zone_pfn);
>  }
>  
> -/*
> - * mem_init - initializes memory
> - *
> - * Frees up bootmem
> - * Calculates and displays memory available/used
> - */
> -void __init mem_init(void)
> +static void __init highmem_init(void)
>  {
>  #ifdef CONFIG_HIGHMEM
>   unsigned long tmp;
>  
> - reset_all_zones_managed_pages();
> + memblock_free(high_mem_start, high_mem_sz);
>   for (tmp = min_high_pfn; tmp < max_high_pfn; tmp++)
>   free_highmem_page(pfn_to_page(tmp));
>  #endif
> +}
>  
> +/*
> + * mem_init - initializes memory
> + *
> + * Frees up bootmem
> + * Calculates and displays memory available/used
> + */
> +void __init mem_init(void)
> +{
>   memblock_free_all();
> + highmem_init();
>   mem_init_print_info(NULL);
>  }



[PATCH v2] irqchip/eznps: Fix build error for !ARC700 builds

2020-08-25 Thread Vineet Gupta
eznps driver is supposed to be platform independent however it ends up
including stuff from inside arch/arc headers leading to rand config
build errors.

Fix this specific reported error as quick hacks as the correct fixes are
too much work:
 - copy AUX_IENABLE from arch/arc header
 - move CTOP_AUX_IACK from platform header

Reported-by: kernel test robot 
Reported-by: Sebastian Andrzej Siewior 
Link: https://lkml.kernel.org/r/20200824095831.5lpkmkafelnvl...@linutronix.de
Signed-off-by: Vineet Gupta 
---
 arch/arc/plat-eznps/include/plat/ctop.h | 1 -
 include/soc/nps/common.h| 6 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arc/plat-eznps/include/plat/ctop.h 
b/arch/arc/plat-eznps/include/plat/ctop.h
index a4a61531c7fb..77712c5ffe84 100644
--- a/arch/arc/plat-eznps/include/plat/ctop.h
+++ b/arch/arc/plat-eznps/include/plat/ctop.h
@@ -33,7 +33,6 @@
 #define CTOP_AUX_DPC   (CTOP_AUX_BASE + 0x02C)
 #define CTOP_AUX_LPC   (CTOP_AUX_BASE + 0x030)
 #define CTOP_AUX_EFLAGS(CTOP_AUX_BASE + 0x080)
-#define CTOP_AUX_IACK  (CTOP_AUX_BASE + 0x088)
 #define CTOP_AUX_GPA1  (CTOP_AUX_BASE + 0x08C)
 #define CTOP_AUX_UDMC  (CTOP_AUX_BASE + 0x300)
 
diff --git a/include/soc/nps/common.h b/include/soc/nps/common.h
index 9b1d43d671a3..8c18dc6d3fde 100644
--- a/include/soc/nps/common.h
+++ b/include/soc/nps/common.h
@@ -45,6 +45,12 @@
 #define CTOP_INST_MOV2B_FLIP_R3_B1_B2_INST 0x5B60
 #define CTOP_INST_MOV2B_FLIP_R3_B1_B2_LIMM 0x00010422
 
+#ifndef AUX_IENABLE
+#define AUX_IENABLE0x40c
+#endif
+
+#define CTOP_AUX_IACK  (0xF800 + 0x088)
+
 #ifndef __ASSEMBLY__
 
 /* In order to increase compilation test coverage */
-- 
2.25.1



[PATCH] irqchip/eznps: Fix build error for !ARC700 builds

2020-08-24 Thread Vineet Gupta
Reported-by: kernel test robot 
Reported-by: Sebastian Andrzej Siewior 
Link: 
http://lists.infradead.org/pipermail/linux-snps-arc/2020-August/004032.html
Signed-off-by: Vineet Gupta 
---
 arch/arc/plat-eznps/include/plat/ctop.h | 1 -
 include/soc/nps/common.h| 6 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arc/plat-eznps/include/plat/ctop.h 
b/arch/arc/plat-eznps/include/plat/ctop.h
index a4a61531c7fb..77712c5ffe84 100644
--- a/arch/arc/plat-eznps/include/plat/ctop.h
+++ b/arch/arc/plat-eznps/include/plat/ctop.h
@@ -33,7 +33,6 @@
 #define CTOP_AUX_DPC   (CTOP_AUX_BASE + 0x02C)
 #define CTOP_AUX_LPC   (CTOP_AUX_BASE + 0x030)
 #define CTOP_AUX_EFLAGS(CTOP_AUX_BASE + 0x080)
-#define CTOP_AUX_IACK  (CTOP_AUX_BASE + 0x088)
 #define CTOP_AUX_GPA1  (CTOP_AUX_BASE + 0x08C)
 #define CTOP_AUX_UDMC  (CTOP_AUX_BASE + 0x300)
 
diff --git a/include/soc/nps/common.h b/include/soc/nps/common.h
index 9b1d43d671a3..8c18dc6d3fde 100644
--- a/include/soc/nps/common.h
+++ b/include/soc/nps/common.h
@@ -45,6 +45,12 @@
 #define CTOP_INST_MOV2B_FLIP_R3_B1_B2_INST 0x5B60
 #define CTOP_INST_MOV2B_FLIP_R3_B1_B2_LIMM 0x00010422
 
+#ifndef AUX_IENABLE
+#define AUX_IENABLE0x40c
+#endif
+
+#define CTOP_AUX_IACK  (0xF800 + 0x088)
+
 #ifndef __ASSEMBLY__
 
 /* In order to increase compilation test coverage */
-- 
2.25.1



Re: {standard input}:5973: Error: operand out of range (512 is not between -512 and 511)

2020-08-24 Thread Vineet Gupta
Hi Sebastian,

On 8/24/20 12:35 PM, Sebastian Andrzej Siewior wrote:
> On 2020-08-24 18:21:21 [+], Vineet Gupta wrote:
>>>>>> {standard input}:5973: Error: operand out of range (512 is not between 
>>>>>> -512 and 511)
>>>>
>>
>> The error above was fixed back in April:
>> 799587d5731db9dc ("ARC: [plat-eznps]: Restrict to CONFIG_ISA_ARCOMPACT")
> 
> This commit is
> |git describe --contains 799587d5731db9dc
> |v5.7-rc7~32^2~2
> 
> and CI said:
> |head:   d012a7190fc1fd72ed48911e77ca97ba4521bccd
> ^^ v5.9-rc2
> |commit: de8f5e4f2dc1f032b46afda0a78cab5456974f89 lockdep: Introduce 
> wait-type checks
> ^^ v5.7-rc1
> 
> so my assumption was that it tested rc2 and bisected it down to that
> commit. Otherwise I don't see the point in testing such an old commit on
> a recent -rc2 and complaining about things not related to one another.

/me confused and a bit out of context here. I didn't see the original CI report
but anyways, we know the code issue... read below

> 
>>> I have here gcc 10 and the output is:
>>
>> I suppose this is mainline gcc 10 ? Although it doesn't seem like compiler 
>> version
>> related.
> 
> Sorry for that. It is
> |$ ~/cross-gcc/gcc-10.1.0-nolibc/arc-linux/bin/arc-linux-gcc -v
> |Using built-in specs.
> |COLLECT_GCC=/home/bigeasy/cross-gcc/gcc-10.1.0-nolibc/arc-linux/bin/arc-linux-gcc
> |COLLECT_LTO_WRAPPER=/home/bigeasy/cross-gcc/gcc-10.1.0-nolibc/arc-linux/bin/../libexec/gcc/arc-linux/10.1.0/lto-wrapper
> |Target: arc-linux
> |Configured with: /home/arnd/git/gcc/configure --target=arc-linux 
> --enable-targets=all 
> --prefix=/home/arnd/cross/x86_64/gcc-10.1.0-nolibc/arc-linux 
> --enable-languages=c --without-headers --disable-bootstrap --disable-nls 
> --disable-threads --disable-shared --disable-libmudflap --disable-libssp 
> --disable-libgomp --disable-decimal-float --disable-libquadmath 
> --disable-libatomic --disable-libcc1 --disable-libmpx 
> --enable-checking=release
> |Thread model: single
> |Supported LTO compression algorithms: zlib
> |gcc version 10.1.0 (GCC) 
> 
> This is the one built by Arnd and hosted at
>   https://www.kernel.org/pub/tools/crosstool/
> 
> Is it suitable for testing?

Yeah, as I said this is not specific to compiler version, just the combination 
of
build options which trigger it.



>>> so I removed CONFIG_EZNPS_GIC. And then I ended with:
>>> |  LD  vmlinux.o
>>> |arc-linux-ld: 
>>> gcc-10.1.0-nolibc/arc-linux/bin/../lib/gcc/arc-linux/10.1.0/arc700/libgcc.a(_muldi3.o):
>>>  compiled for a little endian system and target is big endian
>>> |arc-linux-ld: failed to merge target specific data of file 
>>> gcc-10.1.0-nolibc/arc-linux/bin/../lib/gcc/arc-linux/10.1.0/arc700/libgcc.a(_muldi3.o)
>>
>> This is unrelated since original .config with CONFIG_ARC_PLAT_EZNPS would 
>> have
>> selected Big endina build, but you need a BE toolchain to get that working 
>> (since
>> libgcc emulation code still comes from toolchain).
> 
> Is a switch missing while building the gcc, another gcc target needed or
> is this something that is not part of upstream gcc?

You need a ARC gcc toolchain configured for big endian builds (actually the
compiler driver can handle both, but support libs such as libgcc need to be 
BE/LE
built either through multilib or cleanest is to have a ARC gcc configured for
big-endian. Everything is upstream.


>>> Please update CI and ARC.
>>
>> Nothing to update in CI. I'll send the ARC patch as a follow up.
> 
> but it shouldn't complain about a commit merged in v5.7-rc1 because it
> caused an error which was then fixed in v5.7-rc7 while using HEAD
> v5.9-rc2?

Yeah this indeed is weird, the only explanation I can think of is the rand 
config
triggered the issue now.

-Vineet


Re: {standard input}:5973: Error: operand out of range (512 is not between -512 and 511)

2020-08-24 Thread Vineet Gupta
On 8/24/20 11:21 AM, Vineet Gupta wrote:
>> and the assembler does not like that.
>> After the removal CONFIG_ARC_PLAT_EZNPS I got to stage 2:
>> |drivers/irqchip/irq-eznps.c:80:16: error: 'CTOP_AUX_IACK' undeclared (first 
>> use in this function)
>> |   80 |  write_aux_reg(CTOP_AUX_IACK, 1 << irq);
>>
> Indeed this is a problem I can reproduce. Enabling CONFIG_EZNPS_GIC on a non
> ARC700 build causes the issue: the ctop header is inside platform code
> (arch/arc/plat-eznps/include/plat/ctop.h) which obviously fails if not 
> building
> for ARC.
> 
> My solution is to move ctop.h to include/soc/nps/plat/.

This is turning out to be rat's nest. That header when moved causes other 
issues.
I don't have time to clean up all the mess so I'll just fix it up by doing the
minimal change.

-Vineet


Re: {standard input}:5973: Error: operand out of range (512 is not between -512 and 511)

2020-08-24 Thread Vineet Gupta
+CC Ofer

On 8/24/20 2:58 AM, Sebastian Andrzej Siewior wrote:
> On 2020-08-24 10:17:19 [+0800], kernel test robot wrote:
>> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
>> master
>> head:   d012a7190fc1fd72ed48911e77ca97ba4521bccd
>> commit: de8f5e4f2dc1f032b46afda0a78cab5456974f89 lockdep: Introduce 
>> wait-type checks
>> date:   5 months ago
>> config: arc-randconfig-r004-20200824 (attached as .config)
>> compiler: arc-elf-gcc (GCC) 9.3.0
>> reproduce (this is a W=1 build):
>> wget 
>> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
>> ~/bin/make.cross
>> chmod +x ~/bin/make.cross
>> git checkout de8f5e4f2dc1f032b46afda0a78cab5456974f89
>> # save the attached .config to linux build tree
>> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
>> ARCH=arc 
>>
>> If you fix the issue, kindly add following tag as appropriate
>> Reported-by: kernel test robot 
>>
>> All errors (new ones prefixed by >>):
>>
>>{standard input}: Assembler messages:
 {standard input}:5973: Error: operand out of range (512 is not between 
 -512 and 511)
>>

The error above was fixed back in April:
799587d5731db9dc ("ARC: [plat-eznps]: Restrict to CONFIG_ISA_ARCOMPACT")

> I have here gcc 10 and the output is:

I suppose this is mainline gcc 10 ? Although it doesn't seem like compiler 
version
related.


> |  CC  arch/arc/kernel/signal.o
> |arch/arc/include/asm/bitops.h: Assembler messages:
> |arch/arc/include/asm/bitops.h:236: Error: junk at end of line, first 
> unrecognized character is `0'
> |arch/arc/include/asm/bitops.h:236: Error: junk at end of line, first 
> unrecognized character is `0'
> |make[3]: *** [scripts/Makefile.build:283: arch/arc/kernel/signal.o] Error 1
> |make[2]: *** [scripts/Makefile.build:500: arch/arc/kernel] Error 2
> |make[1]: *** [Makefile:1788: arch/arc] Error 2
> 
> the reason is that:
> | #ifndef CONFIG_ARC_PLAT_EZNPS
> | BIT_OPS(set, |, bset)
> | BIT_OPS(clear, & ~, bclr)
> | BIT_OPS(change, ^, bxor)
> | #else
> | BIT_OPS(set, |, CTOP_INST_AOR_DI_R2_R2_R3)
> | BIT_OPS(clear, & ~, CTOP_INST_AAND_DI_R2_R2_R3)
> | BIT_OPS(change, ^, CTOP_INST_AXOR_DI_R2_R2_R3)
> | #endif
> 
> and the config supplied does not accept CTOP_INST_AAND_DI_R2_R2_R3
> (which is
>   #define CTOP_INST_AAND_DI_R2_R2_R3  0x4A664C04
> )


> and the assembler does not like that.
> After the removal CONFIG_ARC_PLAT_EZNPS I got to stage 2:
> |drivers/irqchip/irq-eznps.c:80:16: error: 'CTOP_AUX_IACK' undeclared (first 
> use in this function)
> |   80 |  write_aux_reg(CTOP_AUX_IACK, 1 << irq);
> 

Indeed this is a problem I can reproduce. Enabling CONFIG_EZNPS_GIC on a non
ARC700 build causes the issue: the ctop header is inside platform code
(arch/arc/plat-eznps/include/plat/ctop.h) which obviously fails if not building
for ARC.

My solution is to move ctop.h to include/soc/nps/plat/.

> so I removed CONFIG_EZNPS_GIC. And then I ended with:
> |  LD  vmlinux.o
> |arc-linux-ld: 
> gcc-10.1.0-nolibc/arc-linux/bin/../lib/gcc/arc-linux/10.1.0/arc700/libgcc.a(_muldi3.o):
>  compiled for a little endian system and target is big endian
> |arc-linux-ld: failed to merge target specific data of file 
> gcc-10.1.0-nolibc/arc-linux/bin/../lib/gcc/arc-linux/10.1.0/arc700/libgcc.a(_muldi3.o)

This is unrelated since original .config with CONFIG_ARC_PLAT_EZNPS would have
selected Big endina build, but you need a BE toolchain to get that working 
(since
libgcc emulation code still comes from toolchain).

> 
> Please update CI and ARC.

Nothing to update in CI. I'll send the ARC patch as a follow up.


> 
> Sebastian
> 

Thx for reporting.
-Vineet


Re: [PATCH 0/2] locking/qspinlock: Break qspinlock_types.h header loop

2020-08-05 Thread Vineet Gupta
On 7/30/20 12:50 AM, Herbert Xu wrote:
> On Thu, Jul 30, 2020 at 10:47:16AM +0300, Andy Shevchenko wrote:
>> We may ask Synopsys folks to look at this as well.
>> Vineet, any ideas if we may unify ATOMIC64_INIT() across the architectures?
> I don't think there is any technical difficulty.  The custom
> atomic64_t simply adds an alignment requirement so the initialisor
> remains the same.

Exactly so.

FWIW the alignment requirement is because ARC ABI allows 64-bit data to be 
32-bit
aligned provided hardware deals fine with 4 byte aligned for the non-atomic
double-load/store LDD/STD instructions. The 64-bit alignement however is 
required
for atomic double load/store LLOCKD/SCONDD instructions hence the definition of
ARC atomic64_t

-Vineet


Re: [PATCH 04/24] arm: use asm-generic/mmu_context.h for no-op implementations

2020-07-27 Thread Vineet Gupta
On 7/27/20 8:33 PM, Nicholas Piggin wrote:
> Cc: Russell King 
> Cc: linux-arm-ker...@lists.infradead.org
> Signed-off-by: Nicholas Piggin 
> ---
>  arch/arm/include/asm/mmu_context.h | 26 +++---
>  1 file changed, 3 insertions(+), 23 deletions(-)
> 
> diff --git a/arch/arm/include/asm/mmu_context.h 
> b/arch/arm/include/asm/mmu_context.h
> index f99ed524fe41..84e58956fcab 100644
> --- a/arch/arm/include/asm/mmu_context.h
> +++ b/arch/arm/include/asm/mmu_context.h
> @@ -26,6 +26,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
>  #ifdef CONFIG_CPU_HAS_ASID
>  
>  void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
> +
> +#define init_new_context init_new_context
>  static inline int
>  init_new_context(struct task_struct *tsk, struct mm_struct *mm)
>  {
> @@ -92,32 +94,10 @@ static inline void finish_arch_post_lock_switch(void)
>  
>  #endif   /* CONFIG_MMU */
>  
> -static inline int
> -init_new_context(struct task_struct *tsk, struct mm_struct *mm)
> -{
> - return 0;
> -}
> -
> -
>  #endif   /* CONFIG_CPU_HAS_ASID */
>  
> -#define destroy_context(mm)  do { } while(0)
>  #define activate_mm(prev,next)   switch_mm(prev, next, NULL)

Actually this can also go away too.

ARM switch_mm(prev, next, tsk) -> check_and_switch_context(next, tsk) but latter
doesn't use @tsk at all. With patch below, you can remove above as well...

>
From 672e0f78a94892794057a5a7542d85b71c1369c4 Mon Sep 17 00:00:00 2001
From: Vineet Gupta 
Date: Mon, 27 Jul 2020 21:12:42 -0700
Subject: [PATCH] ARM: mm: check_and_switch_context() doesn't use @tsk arg

Signed-off-by: Vineet Gupta 
---
 arch/arm/include/asm/efi.h | 2 +-
 arch/arm/include/asm/mmu_context.h | 5 ++---
 arch/arm/mm/context.c  | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h
index 5dcf3c6011b7..0995b308149d 100644
--- a/arch/arm/include/asm/efi.h
+++ b/arch/arm/include/asm/efi.h
@@ -37,7 +37,7 @@ int efi_set_mapping_permissions(struct mm_struct *mm,
efi_memory_desc_t *md);

 static inline void efi_set_pgd(struct mm_struct *mm)
 {
-   check_and_switch_context(mm, NULL);
+   check_and_switch_context(mm);
 }

 void efi_virtmap_load(void);
diff --git a/arch/arm/include/asm/mmu_context.h 
b/arch/arm/include/asm/mmu_context.h
index f99ed524fe41..c96360fa3466 100644
--- a/arch/arm/include/asm/mmu_context.h
+++ b/arch/arm/include/asm/mmu_context.h
@@ -25,7 +25,7 @@ void __check_vmalloc_seq(struct mm_struct *mm);

 #ifdef CONFIG_CPU_HAS_ASID

-void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
+void check_and_switch_context(struct mm_struct *mm);
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
@@ -47,8 +47,7 @@ static inline void a15_erratum_get_cpumask(int this_cpu, 
struct
mm_struct *mm,

 #ifdef CONFIG_MMU

-static inline void check_and_switch_context(struct mm_struct *mm,
-   struct task_struct *tsk)
+static inline void check_and_switch_context(struct mm_struct *mm)
 {
if (unlikely(mm->context.vmalloc_seq != init_mm.context.vmalloc_seq))
__check_vmalloc_seq(mm);
diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
index b7525b433f3e..86c411e1d7cb 100644
--- a/arch/arm/mm/context.c
+++ b/arch/arm/mm/context.c
@@ -234,7 +234,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int 
cpu)
return asid | generation;
 }

-void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
+void check_and_switch_context(struct mm_struct *mm)
 {
unsigned long flags;
unsigned int cpu = smp_processor_id();
-- 
2.20.1



Re: [PATCH 01/24] asm-generic: add generic versions of mmu context functions

2020-07-27 Thread Vineet Gupta
On 7/27/20 8:33 PM, Nicholas Piggin wrote:
> Many of these are no-ops on many architectures, so extend mmu_context.h
> to cover MMU and NOMMU, and split the NOMMU bits out to nommu_context.h
> 

> -static inline void switch_mm(struct mm_struct *prev,
> - struct mm_struct *next,
> - struct task_struct *tsk)
> +/**
> + * activate_mm - called after exec switches the current task to a new mm, to 
> switch to it
> + * @prev_mm: previous mm of this task
> + * @next_mm: new mm
> + */
> +#ifndef activate_mm
> +static inline void activate_mm(struct mm_struct *prev_mm,
> +struct mm_struct *next_mm)
>  {
> + switch_mm(prev_mm, next_mm, current);
>  }
> +#endif

Is activate_mm() really needed now. It seems most arches have
   activate_mm(p, n) -> switch_mm(p, n, NULL)

And if we are passing current, that can be pushed inside switch_mm()

>  
> -static inline void activate_mm(struct mm_struct *prev_mm,
> -struct mm_struct *next_mm)


Re: [PATCH 03/24] arc: use asm-generic/mmu_context.h for no-op implementations

2020-07-27 Thread Vineet Gupta
On 7/27/20 8:33 PM, Nicholas Piggin wrote:

>  /*
> - * Called at the time of execve() to get a new ASID
> - * Note the subtlety here: get_new_mmu_context() behaves differently here
> - * vs. in switch_mm(). Here it always returns a new ASID, because mm has
> - * an unallocated "initial" value, while in latter, it moves to a new ASID,
> - * only if it was unallocated
> + * activate_mm defaults to switch_mm and is called at the time of execve() to

With activate_mm() definition actually gone, perhaps add "activate_mm() comes 
from
generic code..." to provide next reader about the "spurious looking comment"

> + * get a new ASID Note the subtlety here: get_new_mmu_context() behaves
> + * differently here vs. in switch_mm(). Here it always returns a new ASID,
> + * because mm has an unallocated "initial" value, while in latter, it moves 
> to
> + * a new ASID, only if it was unallocated
>   */
> -#define activate_mm(prev, next)  switch_mm(prev, next, NULL)
>  
>  /* it seemed that deactivate_mm( ) is a reasonable place to do book-keeping
>   * for retiring-mm. However destroy_context( ) still needs to do that because
> @@ -168,8 +169,7 @@ static inline void switch_mm(struct mm_struct *prev, 
> struct mm_struct *next,
>   * there is a good chance that task gets sched-out/in, making it's ASID valid
>   * again (this teased me for a whole day).
>   */
> -#define deactivate_mm(tsk, mm)   do { } while (0)

same for deactivate_mm()


[PATCH] ARC: perf: don't bail setup if pct irq missing in device-tree

2020-07-26 Thread Vineet Gupta
Current code inadventely bails if hardware supports sampling/overflow
interrupts, but the irq is missing from device tree. This need not be as
we can still do simple counting based perf stat.

This unborks perf on HSDK-4xD

Signed-off-by: Vineet Gupta 
---
 arch/arc/kernel/perf_event.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
index 661fd842ea97..79849f37e782 100644
--- a/arch/arc/kernel/perf_event.c
+++ b/arch/arc/kernel/perf_event.c
@@ -562,7 +562,7 @@ static int arc_pmu_device_probe(struct platform_device 
*pdev)
 {
struct arc_reg_pct_build pct_bcr;
struct arc_reg_cc_build cc_bcr;
-   int i, has_interrupts;
+   int i, has_interrupts, irq;
int counter_size;   /* in bits */
 
union cc_name {
@@ -637,13 +637,7 @@ static int arc_pmu_device_probe(struct platform_device 
*pdev)
.attr_groups= arc_pmu->attr_groups,
};
 
-   if (has_interrupts) {
-   int irq = platform_get_irq(pdev, 0);
-
-   if (irq < 0) {
-   pr_err("Cannot get IRQ number for the platform\n");
-   return -ENODEV;
-   }
+   if (has_interrupts && (irq = platform_get_irq(pdev, 0) >= 0)) {
 
arc_pmu->irq = irq;
 
@@ -652,9 +646,9 @@ static int arc_pmu_device_probe(struct platform_device 
*pdev)
   this_cpu_ptr(_pmu_cpu));
 
on_each_cpu(arc_cpu_pmu_irq_init, , 1);
-
-   } else
+   } else {
arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
+   }
 
/*
 * perf parser doesn't really like '-' symbol in events name, so let's
-- 
2.20.1



Re: [PATCH] ARC: pgalloc.h: delete a duplicated word + other fixes

2020-07-21 Thread Vineet Gupta
On 7/21/20 1:59 PM, Randy Dunlap wrote:
> Drop the repeated word "to".
> Change "Thay" to "That".
> Add a closing right parenthesis.
> 
> Signed-off-by: Randy Dunlap 
> Cc: Vineet Gupta 
> Cc: linux-snps-...@lists.infradead.org

Thx Randy. Added to for-curr !

-Vineet

> ---
>  arch/arc/include/asm/pgalloc.h |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- linux-next-20200720.orig/arch/arc/include/asm/pgalloc.h
> +++ linux-next-20200720/arch/arc/include/asm/pgalloc.h
> @@ -18,10 +18,10 @@
>   * vineetg: April 2010
>   *  -Switched pgtable_t from being struct page * to unsigned long
>   *  =Needed so that Page Table allocator (pte_alloc_one) is not forced to
> - *   to deal with struct page. Thay way in future we can make it allocate
> + *   deal with struct page. That way in future we can make it allocate
>   *   multiple PG Tbls in one Page Frame
>   *  =sweet side effect is avoiding calls to ugly page_address( ) from the
> - *   pg-tlb allocator sub-sys (pte_alloc_one, ptr_free, pmd_populate
> + *   pg-tlb allocator sub-sys (pte_alloc_one, ptr_free, pmd_populate)
>   *
>   *  Amit Bhor, Sameer Dhavale: Codito Technologies 2004
>   */
> 



[GIT PULL] ARC updates for 5.8-rc5

2020-07-07 Thread Vineet Gupta
Hi Linus,

Please pull ARC fixes/ for 5.8-rc5.

Thx,
-Vineet

>
The following changes since commit b3a9e3b9622ae10064826dccb4f7a52bd88c7407:

  Linux 5.8-rc1 (2020-06-14 12:45:04 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git/ tags/arc-5.8-rc5

for you to fetch changes up to 10011f7d95dea311c0f2a3ea6725b5a2e97015a8:

  ARCv2: support loop buffer (LPB) disabling (2020-06-18 13:07:24 -0700)


ARC updates for 5.8-rc5

 - User build systems to pass -mcpu

 - Fix potential EFA clobber in syscall handler

 - Fix ARCompact 2 levels of interrupts build

 - Detect newer HS CPU releases

 - miscll other fixes


Eugeniy Paltsev (2):
  ARC: build: allow users to specify -mcpu
  ARCv2: support loop buffer (LPB) disabling

Vineet Gupta (5):
  ARC: entry: fix potential EFA clobber when TIF_SYSCALL_TRACE
  ARC: [arcompact] fix bitrot with 2 levels of interrupt
  ARC: elf: use right ELF_ARCH
  ARCv2: boot log: detect newer/upconing HS3x/HS4x releases
  ARC: build: remove deprecated toggle for arc700 builds

 arch/arc/Kconfig| 15 +++
 arch/arc/Makefile   | 21 +++--
 arch/arc/include/asm/elf.h  |  2 +-
 arch/arc/include/asm/irqflags-compact.h |  5 -
 arch/arc/kernel/entry.S | 16 +---
 arch/arc/kernel/head.S  |  8 
 arch/arc/kernel/setup.c | 19 +++
 7 files changed, 59 insertions(+), 27 deletions(-)


Re: [PATCH v2 2/4] ARC: ARCv2: support loop buffer (LPB) disabling

2020-06-18 Thread Vineet Gupta
On 6/18/20 12:50 PM, Eugeniy Paltsev wrote:
> Hi Vineet,
>
> could you also peek this patch to for-curr as we don't have any disagreement 
> about it?
>
> I'll respin the rest of the patches later. Thanks.
> ---
>  Eugeniy Paltsev

Added !

-Vineet



Re: [PATCH v2 1/4] ARC: allow to override default mcpu compiler flag

2020-06-16 Thread Vineet Gupta
On 6/5/20 3:47 AM, Alexey Brodkin wrote:
> Hi Eugeniy,
> 
> A couple of minor notes below.
> 
>> -Original Message-
>> From: Eugeniy Paltsev 
>> Sent: Thursday, June 4, 2020 8:39 PM
>> To: linux-snps-...@lists.infradead.org; Vineet Gupta 
>> Cc: linux-kernel@vger.kernel.org; Alexey Brodkin ; 
>> Eugeniy Paltsev
>> 
>> Subject: [PATCH v2 1/4] ARC: allow to override default mcpu compiler flag
>>
>> Kernel builds set their own default -mcpu for a given ISA build.
> 
> We used to use a default "-mcpu" per ARC ISA version (one for ARCompact
> and one for ARCv2).
> 
>> But that gets in the way of "custom" -mcpu flags from propagating
>> into kernel build.
> 
> But with more versions of CPUs & SoCs becoming available we want to
> be able to fine-tune generated code more precise.
> 
>> This will also be used in next patches for HSDK-4xD board support which
>> uses a different -mcpu to effect dual issue scheduling.
> 
> "...for utilization of the new CPU's dual-issue capabilities"?
> 
>> +++ b/arch/arc/Makefile
>> @@ -10,8 +10,25 @@ CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- 
>> arceb-linux-)
>>  endif
>>
>>  cflags-y+= -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
>> -cflags-$(CONFIG_ISA_ARCOMPACT)  += -mA7
>> -cflags-$(CONFIG_ISA_ARCV2)  += -mcpu=hs38
>> +
>> +tune-mcpu-def-$(CONFIG_ISA_ARCOMPACT)   := -mA7
> 
> I'd suggest to either swap "-mA7" which is being obsoleted with "-mcpu=arc700"
> right here or as a separate change, otherwise we may soon get ATC700 builds
> broken with newer compilers.

FWIW I've added a modified variant of this patch to for-curr as we need it for
ongoing ARC64 port as well.

-Vineet


Re: [PATCH v2 0/4] ARC: [plat-hsdk-4xd] initial port for HSDK-4xD board

2020-06-04 Thread Vineet Gupta
On 6/4/20 10:39 AM, Eugeniy Paltsev wrote:
> Changes v1->v2:
>  * Fallback to ISA default mcpu flag if custom one isn't supported by
>compiler.
>  * Drop HSDK custom Kconfig options (choose between HSDK and HSDK-4xD) as
>we don't need it (at least for now). Instead we select ARC_LPB_DISABLE
>for both boards but it's totally OK as HSDK doesn't have LPB so
>disabling will be skipped by BCR check in runtime.
>  * Add missing HSDK-4xD device tree bindings. Convert HSDK device tree
>bindings to json-schema.
> 
> Eugeniy Paltsev (4):
>   ARC: allow to override default mcpu compiler flag
>   ARC: ARCv2: support loop buffer (LPB) disabling
>   ARC: [plat-hsdk-4xd] initial port for HSDK-4xD board
>   ARC: [plat-hsdk*] document HSDK-4xD board/SoC bindings

LTGM overall. Dropping of new Kconfig items is nice too.

-Vineet


Re: [PATCH v2 1/4] ARC: allow to override default mcpu compiler flag

2020-06-04 Thread Vineet Gupta
On 6/4/20 10:39 AM, Eugeniy Paltsev wrote:
> Kernel builds set their own default -mcpu for a given ISA build.
> But that gets in the way of "custom" -mcpu flags from propagating
> into kernel build.
> 
> This will also be used in next patches for HSDK-4xD board support which
> uses a different -mcpu to effect dual issue scheduling.
> 
> Signed-off-by: Eugeniy Paltsev 

Much better. Ack with nit below.

> ---
>  arch/arc/Kconfig  |  9 +
>  arch/arc/Makefile | 21 +++--
>  2 files changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index ff306246d0f8..7034c217708f 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -377,6 +377,15 @@ config ARC_HAS_SWAPE
>   bool "Insn: SWAPE (endian-swap)"
>   default y
>  
> +config ARC_TUNE_MCPU
> + string "Override default -mcpu compiler flag"
> + default ""
> + help
> +   Override default -mcpu=xxx compiler flag (which is set depending on
> +   the ISA version) with the specified value.
> +   NOTE: If specified flag isn't supported by current compiler the
> +   ISA default value will be used as a fallback.
> +
>  if ISA_ARCV2
>  
>  config ARC_USE_UNALIGNED_MEM_ACCESS
> diff --git a/arch/arc/Makefile b/arch/arc/Makefile
> index 20e9ab6cc521..2b66e8264174 100644
> --- a/arch/arc/Makefile
> +++ b/arch/arc/Makefile
> @@ -10,8 +10,25 @@ CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- 
> arceb-linux-)
>  endif
>  
>  cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
> -cflags-$(CONFIG_ISA_ARCOMPACT)   += -mA7
> -cflags-$(CONFIG_ISA_ARCV2)   += -mcpu=hs38
> +
> +tune-mcpu-def-$(CONFIG_ISA_ARCOMPACT):= -mA7
> +tune-mcpu-def-$(CONFIG_ISA_ARCV2):= -mcpu=hs38
> +
> +ifeq ($(CONFIG_ARC_TUNE_MCPU),"")
> +cflags-y += $(tune-mcpu-def-y)
> +else
> +tune-mcpu:= $(shell echo $(CONFIG_ARC_TUNE_MCPU))
> +tune-mcpu-ok := $(call cc-option-yn, 
> $(tune-mcpu))
> +ifeq ($(tune-mcpu-ok),y)
> +cflags-y += $(tune-mcpu)
> +else
> +# The flag provided by 'CONFIG_ARC_TUNE_MCPU' option isn't known by this 
> compiler
> +# (probably the compiler is too old). Use ISA default mcpu flag instead as a 
> safe option.

It is obvious what is done here and the comments can be skipped (no need to 
repost).

> +$(warning ** WARNING ** CONFIG_ARC_TUNE_MCPU flag '$(tune-mcpu)' is unknown, 
> fallback to '$(tune-mcpu-def-y)')
> +cflags-y += $(tune-mcpu-def-y)
> +endif
> +endif

-Vineet


Re: [PATCH 3/3] ARC: [plat-hsdk-4xd] initial port for HSDK-4xD board

2020-05-29 Thread Vineet Gupta
+CC Rob H (it seems the CC in patch didn't go thru)

On 5/29/20 4:55 AM, Eugeniy Paltsev wrote:
> This initial port adds support of ARC HS4x/HS4xD Development Kit board with 
> some
> basic features such serial port, USB, SD/MMC, SPI flash, Ethernet and others.
> 
> The HSDK-4xD board has much in common with its predecessor - HSDK board.
> However HSDK-4xD has some differences in comparison with its predecessor:
>  * based on quad core ARC HS48/HS47D processor (instead of quad core ARC HS38)
>  * has ThinkSilicon GPU (instead of Vivante GPU)
>  * has ARC PGU and HDMI output
>  * has separate SDIO controller for WiFi module
>  * has additional timers with clocksource independent from CPU clocksource
>(required for DVFS)
>  * has performance counters interrupt
>  * other minor stuff
> 
> NOTE:
> HSDK-4xD and HSDK may share significant part of DTS so we can move this common
> part to one .dtsi file (as we have done it in U-boot). However we have quite
> enough out of the tree patches for tweaking HSDK DTS (patches in out
> verification flow, patches for run in simulation, etc...), so I'd prefer to
> keep HSDK DTS untouched. That's why HSDK-4xD DTS is created as an separate 
> file.

I agree we need a different version of DTB for wiring up perf interrupt and gpu
(whether full copy or common parts in a dtsi I don't care). But just curious if
the "other" mods to DTS were temporary "hacks" for various testing things or do
you intend to actually productize/upstream them at some point. I mean you can
alsoways create a local copy for those and point your .config to it, do that is
not a reason to create a new dtb !  I know this is bike shedding...


> Cc: Rob Herring 
> Signed-off-by: Eugeniy Paltsev 
> ---
>  arch/arc/boot/dts/hsdk-4xd.dts  | 322 
>  arch/arc/configs/hsdk_4xd_defconfig |  99 +
>  arch/arc/kernel/devtree.c   |   1 +
>  arch/arc/plat-hsdk/Kconfig  |  24 ++-
>  arch/arc/plat-hsdk/platform.c   |   6 +
>  5 files changed, 451 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arc/boot/dts/hsdk-4xd.dts
>  create mode 100644 arch/arc/configs/hsdk_4xd_defconfig
> 
> diff --git a/arch/arc/boot/dts/hsdk-4xd.dts b/arch/arc/boot/dts/hsdk-4xd.dts
> new file mode 100644
> index ..2b7f76a01e3e
> --- /dev/null
> +++ b/arch/arc/boot/dts/hsdk-4xd.dts
> @@ -0,0 +1,322 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2020 Synopsys, Inc. (www.synopsys.com)
> + */
> +
> +/*
> + * Device Tree for ARC HS4x/HS4xD Development Kit
> + */
> +/dts-v1/;
> +
> +#include 
> +#include 
> +
> +/ {
> + model = "snps,hsdk-4xd";
> + compatible = "snps,hsdk-4xd";
> +
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + chosen {
> + bootargs = "earlycon=uart8250,mmio32,0xf0005000,115200n8 
> console=ttyS0,115200n8 debug print-fatal-signals=1";
> + };
> +
> + aliases {
> + ethernet = 
> + };
> +
> + cpus {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + cpu@0 {
> + device_type = "cpu";
> + compatible = "snps,archs48";
> + reg = <0>;
> + clocks = <_clk>;
> + };
> +
> + cpu@1 {
> + device_type = "cpu";
> + compatible = "snps,archs48";
> + reg = <1>;
> + clocks = <_clk>;
> + };
> +
> + cpu@2 {
> + device_type = "cpu";
> + compatible = "snps,archs48";
> + reg = <2>;
> + clocks = <_clk>;
> + };
> +
> + cpu@3 {
> + device_type = "cpu";
> + compatible = "snps,archs48";
> + reg = <3>;
> + clocks = <_clk>;
> + };
> + };
> +
> + input_clk: input-clk {
> + #clock-cells = <0>;
> + compatible = "fixed-clock";
> + clock-frequency = <>;
> + };
> +
> + reg_5v0: regulator-5v0 {
> + compatible = "regulator-fixed";
> +
> + regulator-name = "5v0-supply";
> + regulator-min-microvolt = <500>;
> + regulator-max-microvolt = <500>;
> + };
> +
> + cpu_intc: cpu-interrupt-controller {
> + compatible = "snps,archs-intc";
> + interrupt-controller;
> + #interrupt-cells = <1>;
> + };
> +
> + idu_intc: idu-interrupt-controller {
> + compatible = "snps,archs-idu-intc";
> + interrupt-controller;
> + #interrupt-cells = <1>;
> + interrupt-parent = <_intc>;
> + };
> +
> + arcpct: pct {
> + compatible = "snps,archs-pct";
> + interrupt-parent = <_intc>;
> + interrupts = <20>;
> + };
> +
> + /* TIMER0 with 

Re: [PATCH 2/3] ARC: ARCv2: support loop buffer (LPB) disabling

2020-05-29 Thread Vineet Gupta
On 5/29/20 4:55 AM, Eugeniy Paltsev wrote:
> On HS cores, loop buffer (LPB) is programmable in runtime and can
> be optionally disabled.
> 
> Signed-off-by: Eugeniy Paltsev 

LGTM.

-Vineet


Re: [PATCH 1/3] ARC: allow to overide default mcpu compiler flag

2020-05-29 Thread Vineet Gupta
On 5/29/20 4:55 AM, Eugeniy Paltsev wrote:
> By default we set -mcpu=xxx compiler flag depending on the CPU ISA
> version. It's good starting point, however that may be not enough
> as for some platforms we may want to use some specific 'mcpu'
> options for better optimization or to workaround HW issues.
> 
> We are going to use this option for HSDK-4xD board support.
> In addition it also allows to awoid patching 'mcpu' in ARC Makefile
> when we building Linux for some non-standard simulation or FPGA-based
> platforms.
> 
> Signed-off-by: Eugeniy Paltsev 

Question: So now if I build in buildroot with -mhs38_linux, it will use hard 
float
(kernel should not use floating point) but the libgcc linked will be different 
too
and that should be OK ?

I've rewritten the changelog.

  kernel builds set their own default -mcpu for a given ISA build.
  But that gets in the way of "custom" -mcpu flags from propagating
  into kernel build.

  This will also be used in next patches for HSDK-4xD board support which
  uses a different -mcpu to effect dual issue scheduling.





[GIT PULL] ARC fixes for 5.7

2020-05-19 Thread Vineet Gupta
Hi Linus,

Please pull the assorted ARC fixes for 5.7.

Thx,
-Vineet
->
The following changes since commit 8f3d9f354286745c751374f5f1fcafee6b3f3136:

  Linux 5.7-rc1 (2020-04-12 12:35:55 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git/ tags/arc-5.7-rc7

for you to fetch changes up to 7915502377c54c9f58f6ac537bde0c2c342a6742:

  ARC: show_regs: avoid extra line of output (2020-05-14 15:05:00 -0700)


ARC fixes for 5.7

 - Recent DSP code regressing ARC700 platforms

 - Thinkos in ICCM/DCCM size checks

 - USB regression

 - other small fixes here and there


Eugeniy Paltsev (3):
  ARC: Fix ICCM & DCCM runtime size checks
  ARC: [plat-hsdk]: fix USB regression
  ARC: guard dsp early init against non ARCv2

Masahiro Yamada (2):
  arc: ptrace: hard-code "arc" instead of UTS_MACHINE
  arc: remove #ifndef CONFIG_AS_CFI_SIGNAL_FRAME

Vineet Gupta (3):
  ARC: entry: comment
  ARC: [plat-eznps]: Restrict to CONFIG_ISA_ARCOMPACT
  ARC: show_regs: avoid extra line of output

 arch/arc/configs/hsdk_defconfig|  1 +
 arch/arc/include/asm/dsp-impl.h|  2 ++
 arch/arc/include/asm/entry-arcv2.h |  2 ++
 arch/arc/kernel/Makefile   |  3 ---
 arch/arc/kernel/ptrace.c   |  2 +-
 arch/arc/kernel/setup.c|  5 +++--
 arch/arc/kernel/troubleshoot.c | 14 ++
 arch/arc/kernel/unwind.c   |  2 --
 arch/arc/plat-eznps/Kconfig|  1 +
 9 files changed, 16 insertions(+), 16 deletions(-)


Re: [PATCH v2 3/6] dmaengine: dw: Set DMA device max segment size parameter

2020-05-08 Thread Vineet Gupta
On 5/8/20 4:21 AM, Andy Shevchenko wrote:
> Yeah, I have locally something like this and I didn't dare to upstream because
> there is an issue. We have this information per DMA controller, while we
> actually need this on per DMA channel basis.
>
> Above will work only for synthesized DMA with all channels having same block
> size. That's why above conditional is not needed anyway.
>
> OTOH, I never saw the DesignWare DMA to be synthesized differently (I remember
> that Intel Medfield has interesting settings, but I don't remember if DMA
> channels are different inside the same controller).
>
> Vineet, do you have any information that Synopsys customers synthesized DMA
> controllers with different channel characteristics inside one DMA IP?

The IP drivers are done by different teams, but I can try and ask around.


Re: [PATCH] ARC: guard dsp early init against non ARCv2

2020-04-29 Thread Vineet Gupta
On 4/29/20 10:12 AM, Eugeniy Paltsev wrote:
> Hi Vineet, 
>
>> From: Vineet Gupta 
>> Sent: Tuesday, April 28, 2020 22:46
>> To: Eugeniy Paltsev; linux-snps-...@lists.infradead.org
>> Cc: Alexey Brodkin; linux-kernel@vger.kernel.org
>> Subject: Re: [PATCH] ARC: guard dsp early init against non ARCv2
>>
>> On 4/28/20 11:50 AM, Eugeniy Paltsev wrote:
>>> As of today we guard early DSP init code with
>>> ARC_AUX_DSP_BUILD (0x7A) BCR check to verify that we have
>>> CPU with DSP configured. However that's not enough as in
>>> ARCv1 CPU the same BCR (0x7A) is used for checking MUL/MAC
>>> instructions presence.
>>>
>>> So, let's guard DSP early init against non ARCv2.
>>>
>>> Signed-off-by: Eugeniy Paltsev 
>>> ---
>>>  arch/arc/include/asm/dsp-impl.h | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/arch/arc/include/asm/dsp-impl.h 
>>> b/arch/arc/include/asm/dsp-impl.h
>>> index e1aa212ca6eb..e64d945ae7df 100644
>>> --- a/arch/arc/include/asm/dsp-impl.h
>>> +++ b/arch/arc/include/asm/dsp-impl.h
>>> @@ -15,12 +15,14 @@
>>>
>>>  /* clobbers r5 register */
>>>  .macro DSP_EARLY_INIT
>>> +#if defined(CONFIG_ISA_ARCV2)
>> ifdef is the canonical way for a single macro to check.
>>
>> Also, this needs to be finer grained, i.e. CONFIG_ARC_DSP_KERNEL which is 
>> already
>> tied to ARCV2 only configs.
> We shouldn't limit the scope of this code part [dsp early init] to the cases
> were DSP support is enabled in kconfig - and that is the reason why this code
> initially was guarded with BCR check only.
>
> So, I change the check to
>
> #if defined(CONFIG_ARC_DSP_HANDLED) || defined(CONFIG_ARC_DSP_NONE)

You are right. It needs to be disabled if the hardware exists independent of 
Kconfig.

> which is actually the equivalent to
>
> #if defined(CONFIG_ISA_ARCV2)
>
> but I don't think it's worth thing to do.

Agree.

-Vineet


Re: [PATCH] ARC: guard dsp early init against non ARCv2

2020-04-28 Thread Vineet Gupta
On 4/28/20 11:50 AM, Eugeniy Paltsev wrote:
> As of today we guard early DSP init code with
> ARC_AUX_DSP_BUILD (0x7A) BCR check to verify that we have
> CPU with DSP configured. However that's not enough as in
> ARCv1 CPU the same BCR (0x7A) is used for checking MUL/MAC
> instructions presence.
>
> So, let's guard DSP early init against non ARCv2.
>
> Signed-off-by: Eugeniy Paltsev 
> ---
>  arch/arc/include/asm/dsp-impl.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/arc/include/asm/dsp-impl.h b/arch/arc/include/asm/dsp-impl.h
> index e1aa212ca6eb..e64d945ae7df 100644
> --- a/arch/arc/include/asm/dsp-impl.h
> +++ b/arch/arc/include/asm/dsp-impl.h
> @@ -15,12 +15,14 @@
>  
>  /* clobbers r5 register */
>  .macro DSP_EARLY_INIT
> +#if defined(CONFIG_ISA_ARCV2)

ifdef is the canonical way for a single macro to check.

Also, this needs to be finer grained, i.e. CONFIG_ARC_DSP_KERNEL which is 
already
tied to ARCV2 only configs.

>   lr  r5, [ARC_AUX_DSP_BUILD]
>   bmskr5, r5, 7
>   breqr5, 0, 1f
>   mov r5, DSP_CTRL_DISABLED_ALL
>   sr  r5, [ARC_AUX_DSP_CTRL]
>  1:
> +#endif
>  .endm
>  
>  /* clobbers r10, r11 registers pair */



Re: [RFC 0/6] ARC: merge HAPS-HS with nSIM-HS configs

2019-10-22 Thread Vineet Gupta
Ok but this if off topic and not directly related to patches - or am I missing 
something.

Indeed if we run UP only for nsim we should add pseudo SMP and also a true SMP.

For uClibc-ng regression, it doesn't matter what they use and not for us to 
decide anyways - we just need to tell them (or point to wiki etc) that starting 
with 5.x kernel,any nsim uart config needs to change of they are using the 
defconfigs.

-Vineet


From: Eugeniy Paltsev 
Sent: Tuesday, October 22, 2019 11:18 AM
To: Vineet Gupta; Eugeniy Paltsev; linux-snps-...@lists.infradead.org; Vineet 
Gupta
Cc: Alexey Brodkin; linux-kernel@vger.kernel.org
Subject: Re: [RFC 0/6] ARC: merge HAPS-HS with nSIM-HS configs

Btw, about nSIM regression runs:
We are using UP configuration for all nSIM runs and I propose to use pseudo-SMP 
 configuration (SMP configuration with only one CPU online) instead as our main 
target are SMP systems.

So -
run our verification jobs on both UP and pseudo-SMP nSIM
run uClibc-ng regression on pseudo-SMP only

 Any objections / thoughts?
---
 Eugeniy Paltsev



From: Vineet Gupta 
Sent: Friday, October 18, 2019 21:48
To: Eugeniy Paltsev; linux-snps-...@lists.infradead.org; Vineet Gupta
Cc: Alexey Brodkin; linux-kernel@vger.kernel.org
Subject: Re: [RFC 0/6] ARC: merge HAPS-HS with nSIM-HS configs

On 10/18/19 5:15 AM, Eugeniy Paltsev wrote:
> Starting from nSIM 2019.06 is possible to use DW UART
> instead of ARC UART. That allows us to merge
> "nsim_hs" with "haps_hs" and "nsim_hs_smp" with "haps_hs_smp"
> mith some minor changes.
>
> We eliminate nsim_hs_defconfig and nsim_hs_smp_defconfig
> and leave haps_hs_defconfig and haps_hs_smp_defconfig
> which can be used on HAPS / nSIM / ZEBU / QEMU platforms
> without additionall changes in Linux kernel.

Thx for doing this, I was planning to do this myself.

But remember that doing this will disturb existing nsim setups
- Our internal linux/gnu regression jobs one of which tracks my for-curr and 
will
  fail immediately
- uClibc-ng maintainer who also seems to use nsim AFAIK for regression runs

So we need to notify parties involves (and it would be best that we align this 
to
a kernel release which anyways will be next one.

Also go thru the github wiki pages and wherever applicable please add the config
info for nsim (keep the old settings there for reference as well)

Thx,
-Vineet


Re: [RFC 6/6] ARC: merge HAPS-HS with nSIM-HS configs

2019-10-18 Thread Vineet Gupta
On 10/18/19 5:15 AM, Eugeniy Paltsev wrote:
> Starting from nSIM 2019.06 is possible to use DW UART
> instead of ARC UART. That allows us to merge
> "nsim_hs" with "haps_hs" and "nsim_hs_smp" with "haps_hs_smp"
> mith minor changes which were done in previous commits.
> 
> We eliminate nsim_hs_defconfig and nsim_hs_smp_defconfig
> and leave haps_hs_defconfig and haps_hs_smp_defconfig
> which can be used on HAPS / nSIM / ZEBU / QEMU platforms
> without additionall changes in Linux kernel.
> 
> For nSIM we should now use UART property values
> "-prop=nsim_mem-dev=uart0,kind=dwuart,base=0xf000"
> instead of previously used
> "-prop=nsim_mem-dev=uart0,base=0xc0fc1000"
> "use_connect" and "irq" values of UART property remains untouched.
> 
> Signed-off-by: Eugeniy Paltsev 
> ---
>  arch/arc/boot/dts/nsim_hs.dts  | 67 --
>  arch/arc/boot/dts/nsim_hs_idu.dts  | 65 -
>  arch/arc/configs/nsim_hs_defconfig | 56 -
>  arch/arc/configs/nsim_hs_smp_defconfig | 54 -
>  arch/arc/plat-sim/platform.c   |  1 -

You also need to update KBUILD_DEFCONFIG to use the haps defconfig now.

Also perhaps as an addon change switch nsim_700_defconfig to dwuart too for
consistent uart settings for all processor builds in kernel/nsim (otherwise you
need to document this disparity in various github wiki pages)

-Vineet


Re: [RFC 0/6] ARC: merge HAPS-HS with nSIM-HS configs

2019-10-18 Thread Vineet Gupta
On 10/18/19 5:15 AM, Eugeniy Paltsev wrote:
> Starting from nSIM 2019.06 is possible to use DW UART
> instead of ARC UART. That allows us to merge
> "nsim_hs" with "haps_hs" and "nsim_hs_smp" with "haps_hs_smp"
> mith some minor changes.
> 
> We eliminate nsim_hs_defconfig and nsim_hs_smp_defconfig
> and leave haps_hs_defconfig and haps_hs_smp_defconfig
> which can be used on HAPS / nSIM / ZEBU / QEMU platforms
> without additionall changes in Linux kernel.

Thx for doing this, I was planning to do this myself.

But remember that doing this will disturb existing nsim setups
- Our internal linux/gnu regression jobs one of which tracks my for-curr and 
will
  fail immediately
- uClibc-ng maintainer who also seems to use nsim AFAIK for regression runs

So we need to notify parties involves (and it would be best that we align this 
to
a kernel release which anyways will be next one.

Also go thru the github wiki pages and wherever applicable please add the config
info for nsim (keep the old settings there for reference as well)

Thx,
-Vineet


[PATCH v3 0/5] elide extraneous generated code for folded p4d/pud/pmd

2019-10-16 Thread Vineet Gupta
Hi,

This series came out of seemingly benign excursion into understanding/removing
__ARCH_USE_5LEVEL_HACK from ARC port showing some extraneous code being
generated despite folded p4d/pud/pmd

| bloat-o-meter2 vmlinux-[AB]*
| add/remove: 0/0 grow/shrink: 3/0 up/down: 130/0 (130)
| function old new   delta
| free_pgd_range   548 660+112
| p4d_clear_bad  2  20 +18

The patches here address that

| bloat-o-meter2 vmlinux-[BF]*
| add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-386 (-386)
| function old new   delta
| pud_clear_bad 20   - -20
| p4d_clear_bad 20   - -20
| free_pgd_range   660 314-346

The code savings are not a whole lot, but still worthwhile IMHO.

Please review, test and apply. It seems to survive my usual battery of
multibench, hakcbench etc.

Thx,
-Vineet

---
Changes since v2 [3]
 - No code changes: Fixed the silly typos and collected ACKs

Changes since v1 [1]
 - Per Linus Sugestion remvoed the extra ifdey'ery (hence not
   accumulating Kirill's ACks)
 - Added the RFC patch for pmd_free_tlb() after discussions [2]
 - Also throwing in the ARC patch which started this all (so we get the
   full context of patchset) - I'm ok if this goes via mm tree, should
   be non contentious and can drop this too if Andrew thinks otherwise

[1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006263.html
[2] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006277.html
[3] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006307.html
---

Vineet Gupta (5):
  ARC: mm: remove __ARCH_USE_5LEVEL_HACK
  asm-generic/tlb: stub out pud_free_tlb() if nopud ...
  asm-generic/tlb: stub out p4d_free_tlb() if nop4d ...
  asm-generic/tlb: stub out pmd_free_tlb() if nopmd
  asm-generic/mm: stub out p{4,u}d_clear_bad() if
__PAGETABLE_P{4,u}D_FOLDED

 arch/arc/include/asm/pgtable.h  |  1 -
 arch/arc/mm/fault.c | 10 --
 arch/arc/mm/highmem.c   |  4 +++-
 include/asm-generic/4level-fixup.h  |  1 -
 include/asm-generic/5level-fixup.h  |  1 -
 include/asm-generic/pgtable-nop4d.h |  2 +-
 include/asm-generic/pgtable-nopmd.h |  2 +-
 include/asm-generic/pgtable-nopud.h |  2 +-
 include/asm-generic/pgtable.h   | 11 +++
 include/asm-generic/tlb.h   |  4 
 mm/pgtable-generic.c|  9 +
 11 files changed, 34 insertions(+), 13 deletions(-)

-- 
2.20.1



[PATCH v3 2/5] asm-generic/tlb: stub out pud_free_tlb() if nopud ...

2019-10-16 Thread Vineet Gupta
... independent of __ARCH_HAS_4LEVEL_HACK

This came up when removing __ARCH_HAS_5LEVEL_HACK for ARC as code bloat.
With this patch we see the following code reduction

| bloat-o-meter2 vmlinux-B-elide-ARCH_USE_5LEVEL_HACK 
vmlinux-C-elide-pud_free_tlb
| add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-104 (-104)
| function old new   delta
| free_pgd_range   656 552-104
| Total: Before=4137276, After=4137172, chg -1.00%

Note: The primary change is alternate defintion for pud_free_tlb() but
while there also removed empty stubs for __pud_free_tlb, which is anyhow
called only from pud_free_tlb()

Acked-by: Kirill A. Shutemov 
Acked-by: Linus Torvalds 
Signed-off-by: Vineet Gupta 
---
 include/asm-generic/4level-fixup.h  | 1 -
 include/asm-generic/pgtable-nopud.h | 2 +-
 include/asm-generic/tlb.h   | 2 --
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/asm-generic/4level-fixup.h 
b/include/asm-generic/4level-fixup.h
index e3667c9a33a5..c86cf7cb4bba 100644
--- a/include/asm-generic/4level-fixup.h
+++ b/include/asm-generic/4level-fixup.h
@@ -30,7 +30,6 @@
 #undef pud_free_tlb
 #define pud_free_tlb(tlb, x, addr) do { } while (0)
 #define pud_free(mm, x)do { } while (0)
-#define __pud_free_tlb(tlb, x, addr)   do { } while (0)
 
 #undef  pud_addr_end
 #define pud_addr_end(addr, end)(end)
diff --git a/include/asm-generic/pgtable-nopud.h 
b/include/asm-generic/pgtable-nopud.h
index c77a1d301155..d3776cb494c0 100644
--- a/include/asm-generic/pgtable-nopud.h
+++ b/include/asm-generic/pgtable-nopud.h
@@ -59,7 +59,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long 
address)
  */
 #define pud_alloc_one(mm, address) NULL
 #define pud_free(mm, x)do { } while (0)
-#define __pud_free_tlb(tlb, x, a)  do { } while (0)
+#define pud_free_tlb(tlb, x, a)do { } while (0)
 
 #undef  pud_addr_end
 #define pud_addr_end(addr, end)(end)
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 04c0644006fd..5e0c2d01e656 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -584,7 +584,6 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
} while (0)
 #endif
 
-#ifndef __ARCH_HAS_4LEVEL_HACK
 #ifndef pud_free_tlb
 #define pud_free_tlb(tlb, pudp, address)   \
do {\
@@ -594,7 +593,6 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
__pud_free_tlb(tlb, pudp, address); \
} while (0)
 #endif
-#endif
 
 #ifndef __ARCH_HAS_5LEVEL_HACK
 #ifndef p4d_free_tlb
-- 
2.20.1



[PATCH v3 5/5] asm-generic/mm: stub out p{4,u}d_clear_bad() if __PAGETABLE_P{4,U}D_FOLDED

2019-10-16 Thread Vineet Gupta
This came up when removing __ARCH_HAS_5LEVEL_HACK for ARC as code bloat.
With this patch we see the following code reduction.

| bloat-o-meter2 vmlinux-D-elide-p4d_free_tlb vmlinux-E-elide-p?d_clear_bad
| add/remove: 0/2 grow/shrink: 0/0 up/down: 0/-40 (-40)
| function old new   delta
| pud_clear_bad 20   - -20
| p4d_clear_bad 20   - -20
| Total: Before=4136930, After=4136890, chg -1.00%

Acked-by: Kirill A. Shutemov 
Signed-off-by: Vineet Gupta 
---
 include/asm-generic/pgtable.h | 11 +++
 mm/pgtable-generic.c  |  9 +
 2 files changed, 20 insertions(+)

diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 818691846c90..9cdcbc7c0b7b 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -558,8 +558,19 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, 
pgprot_t newprot)
  * Do the tests inline, but report and clear the bad entry in mm/memory.c.
  */
 void pgd_clear_bad(pgd_t *);
+
+#ifndef __PAGETABLE_P4D_FOLDED
 void p4d_clear_bad(p4d_t *);
+#else
+#define p4d_clear_bad(p4d)do { } while (0)
+#endif
+
+#ifndef __PAGETABLE_PUD_FOLDED
 void pud_clear_bad(pud_t *);
+#else
+#define pud_clear_bad(p4d)do { } while (0)
+#endif
+
 void pmd_clear_bad(pmd_t *);
 
 static inline int pgd_none_or_clear_bad(pgd_t *pgd)
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index 532c29276fce..3d7c01e76efc 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -24,18 +24,27 @@ void pgd_clear_bad(pgd_t *pgd)
pgd_clear(pgd);
 }
 
+#ifndef __PAGETABLE_P4D_FOLDED
 void p4d_clear_bad(p4d_t *p4d)
 {
p4d_ERROR(*p4d);
p4d_clear(p4d);
 }
+#endif
 
+#ifndef __PAGETABLE_PUD_FOLDED
 void pud_clear_bad(pud_t *pud)
 {
pud_ERROR(*pud);
pud_clear(pud);
 }
+#endif
 
+/*
+ * Note that the pmd variant below can't be stub'ed out just as for p4d/pud
+ * above. pmd folding is special and typically pmd_* macros refer to upper
+ * level even when folded
+ */
 void pmd_clear_bad(pmd_t *pmd)
 {
pmd_ERROR(*pmd);
-- 
2.20.1



[PATCH v3 3/5] asm-generic/tlb: stub out p4d_free_tlb() if nop4d ...

2019-10-16 Thread Vineet Gupta
... independent of __ARCH_HAS_5LEVEL_HACK

This came up when removing __ARCH_HAS_5LEVEL_HACK for ARC as code bloat.
With this patch we see the following code reduction

| bloat-o-meter2 vmlinux-C-elide-pud_free_tlb vmlinux-D-elide-p4d_free_tlb
| add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-104 (-104)
| function old new   delta
| free_pgd_range   552 422-130
| Total: Before=4137172, After=4137042, chg -1.00%

Acked-by: Kirill A. Shutemov 
Acked-by: Linus Torvalds 
Signed-off-by: Vineet Gupta 
---
 include/asm-generic/5level-fixup.h  | 1 -
 include/asm-generic/pgtable-nop4d.h | 2 +-
 include/asm-generic/tlb.h   | 2 --
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/asm-generic/5level-fixup.h 
b/include/asm-generic/5level-fixup.h
index f6947da70d71..4c74b1c1d13b 100644
--- a/include/asm-generic/5level-fixup.h
+++ b/include/asm-generic/5level-fixup.h
@@ -51,7 +51,6 @@ static inline int p4d_present(p4d_t p4d)
 #undef p4d_free_tlb
 #define p4d_free_tlb(tlb, x, addr) do { } while (0)
 #define p4d_free(mm, x)do { } while (0)
-#define __p4d_free_tlb(tlb, x, addr)   do { } while (0)
 
 #undef  p4d_addr_end
 #define p4d_addr_end(addr, end)(end)
diff --git a/include/asm-generic/pgtable-nop4d.h 
b/include/asm-generic/pgtable-nop4d.h
index aebab905e6cd..ce2cbb3c380f 100644
--- a/include/asm-generic/pgtable-nop4d.h
+++ b/include/asm-generic/pgtable-nop4d.h
@@ -50,7 +50,7 @@ static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long 
address)
  */
 #define p4d_alloc_one(mm, address) NULL
 #define p4d_free(mm, x)do { } while (0)
-#define __p4d_free_tlb(tlb, x, a)  do { } while (0)
+#define p4d_free_tlb(tlb, x, a)do { } while (0)
 
 #undef  p4d_addr_end
 #define p4d_addr_end(addr, end)(end)
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 5e0c2d01e656..05dddc17522b 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -594,7 +594,6 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
} while (0)
 #endif
 
-#ifndef __ARCH_HAS_5LEVEL_HACK
 #ifndef p4d_free_tlb
 #define p4d_free_tlb(tlb, pudp, address)   \
do {\
@@ -603,7 +602,6 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
__p4d_free_tlb(tlb, pudp, address); \
} while (0)
 #endif
-#endif
 
 #endif /* CONFIG_MMU */
 
-- 
2.20.1



[PATCH v3 1/5] ARC: mm: remove __ARCH_USE_5LEVEL_HACK

2019-10-16 Thread Vineet Gupta
With paging code made 5-level compliant, this is no longer needed.
ARC has software page walker with 2 lookup levels (pgd -> pte)

This was expected to be non functional change but ended with slight
code bloat due to needless inclusions of p*d_free_tlb() macros which
will be addressed in further patches.

| bloat-o-meter2 vmlinux-[AB]*
| add/remove: 0/0 grow/shrink: 2/0 up/down: 128/0 (128)
| function old new   delta
| free_pgd_range   546 656+110
| p4d_clear_bad  2  20 +18
| Total: Before=4137148, After=4137276, chg 0.00%

Acked-by: Kirill A. Shutemov 
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/pgtable.h |  1 -
 arch/arc/mm/fault.c| 10 --
 arch/arc/mm/highmem.c  |  4 +++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
index 7addd0301c51..b917b596f7fb 100644
--- a/arch/arc/include/asm/pgtable.h
+++ b/arch/arc/include/asm/pgtable.h
@@ -33,7 +33,6 @@
 #define _ASM_ARC_PGTABLE_H
 
 #include 
-#define __ARCH_USE_5LEVEL_HACK
 #include 
 #include 
 #include/* to propagate CONFIG_ARC_MMU_VER  */
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index 3861543b66a0..fb86bc3e9b35 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -30,6 +30,7 @@ noinline static int handle_kernel_vaddr_fault(unsigned long 
address)
 * with the 'reference' page table.
 */
pgd_t *pgd, *pgd_k;
+   p4d_t *p4d, *p4d_k;
pud_t *pud, *pud_k;
pmd_t *pmd, *pmd_k;
 
@@ -39,8 +40,13 @@ noinline static int handle_kernel_vaddr_fault(unsigned long 
address)
if (!pgd_present(*pgd_k))
goto bad_area;
 
-   pud = pud_offset(pgd, address);
-   pud_k = pud_offset(pgd_k, address);
+   p4d = p4d_offset(pgd, address);
+   p4d_k = p4d_offset(pgd_k, address);
+   if (!p4d_present(*p4d_k))
+   goto bad_area;
+
+   pud = pud_offset(p4d, address);
+   pud_k = pud_offset(p4d_k, address);
if (!pud_present(*pud_k))
goto bad_area;
 
diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c
index a4856bfaedf3..fc8849e4f72e 100644
--- a/arch/arc/mm/highmem.c
+++ b/arch/arc/mm/highmem.c
@@ -111,12 +111,14 @@ EXPORT_SYMBOL(__kunmap_atomic);
 static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr)
 {
pgd_t *pgd_k;
+   p4d_t *p4d_k;
pud_t *pud_k;
pmd_t *pmd_k;
pte_t *pte_k;
 
pgd_k = pgd_offset_k(kvaddr);
-   pud_k = pud_offset(pgd_k, kvaddr);
+   p4d_k = p4d_offset(pgd_k, kvaddr);
+   pud_k = pud_offset(p4d_k, kvaddr);
pmd_k = pmd_offset(pud_k, kvaddr);
 
pte_k = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
-- 
2.20.1



[PATCH v3 4/5] asm-generic/tlb: stub out pmd_free_tlb() if nopmd

2019-10-16 Thread Vineet Gupta
This came up when removing __ARCH_HAS_5LEVEL_HACK for ARC as code bloat.
With this patch we see the following code reduction.

| bloat-o-meter2 vmlinux-E-elide-p?d_clear_bad vmlinux-F-elide-pmd_free_tlb
| add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-112 (-112)
| function old new   delta
| free_pgd_range   422 310-112
| Total: Before=4137042, After=4136930, chg -1.00%

Note that pmd folding can be tricky: In 2-level setup (where pmd is
conceptually folded) most pmd routines are valid and refer to upper levels.
In this patch we can, but see next patch for example where we can't

Acked-by: Kirill A. Shutemov 
Signed-off-by: Vineet Gupta 
---
 include/asm-generic/pgtable-nopmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/pgtable-nopmd.h 
b/include/asm-generic/pgtable-nopmd.h
index b85b8271a73d..0d9b28cba16d 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -60,7 +60,7 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long 
address)
 static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
 {
 }
-#define __pmd_free_tlb(tlb, x, a)  do { } while (0)
+#define pmd_free_tlb(tlb, x, a)do { } while (0)
 
 #undef  pmd_addr_end
 #define pmd_addr_end(addr, end)(end)
-- 
2.20.1



Re: [PATCH v2 1/5] ARC: mm: remove __ARCH_USE_5LEVEL_HACK

2019-10-15 Thread Vineet Gupta
On 10/15/19 2:48 PM, Linus Torvalds wrote:
> On Tue, Oct 15, 2019 at 12:19 PM Vineet Gupta
>  wrote:
>> This is a non-functional change anyways since ARC has software page walker
>> with 2 lookup levels (pgd -> pte)
>
> Could we encourage other architectures to do the same, and get rid of
> all uses of __ARCH_USE_5LEVEL_HACK?

IMHO this should have been done at the onset. The actual changes don't seem that
difficult, just need to add the missing p4d calls although I can sympathize with
hassles of coordinating/building/testing/yadi yada cross arch.

OTOH, the [45]LEVEL_HACK seem like a nice way to "fold" the levels: the
skipped/folded level vanishes completely. Among others it does things like

 #define p4d_t  pgd_t   

On ARC 2-level code:

   free_pte_range
pmd_pgtable(*pmd);

((*pmd).pud).pgd))) & PAGE_MASK));   <-- 5LEVEL_HACK
vs.
*pmd).pud).p4d).pgd & PAGE_MASK ));  <-- w/o 5LEVEL_HACK

pmd_clear(pmd);

*(pmd)).pud).pgd = 0
vs.
*(pmd)).pud).p4d).pgd = 0


So we may not be able to fix all he historical misgivigs, but this might 
alleviate
the pain a bit. I'll try to dabble a bit.

Thx for taking a look and te ACKs.
-Vineet


[PATCH v2 0/5] eldie generated code for folded p4d/pud

2019-10-15 Thread Vineet Gupta
Hi,

This series came out of seemingly naive exceursion into understanding/removing
__ARCH_USE_5LEVEL_HACK from ARC port. With removal of 5LEVEL_HACK some
extraneous code was bein generated

| bloat-o-meter2 vmlinux-[AB]*
| add/remove: 0/0 grow/shrink: 3/0 up/down: 130/0 (130)
| function old new   delta
| free_pgd_range   548 660+112
| p4d_clear_bad  2  20 +18

Which the patches here elides (for folded p4d/pud/pmd)

| bloat-o-meter2 vmlinux-[BF]*
| add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-386 (-386)
| function old new   delta
| pud_clear_bad 20   - -20
| p4d_clear_bad 20   - -20
| free_pgd_range   660 314-346

The code savings are not a whole lot, but still worthwhile IMHO.

Please review, test and apply. It seems to survive my usual battery of
multibench, hakcbench etc.

Thx,
-Vineet

---
Changes since v1 [1]
 - Per Linus Sugestion remvoed the extra ifdey'ery (hence not
   accumulating Kirill's ACks)
 - Added the RFC patch for pmd_free_tlb() after discussions [2]
 - Also throwing in the ARC patch which started this all (so we get the
   full context of patchset) - I'm ok if this goes via mm tree, should
   be non contentious and can drop this too if Andrew thinks otherwise

[1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006263.html
[2] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006277.html

---

Vineet Gupta (5):
  ARC: mm: remove __ARCH_USE_5LEVEL_HACK
  asm-generic/tlb: stub out pud_free_tlb() if nopud ...
  asm-generic/tlb: stub out p4d_free_tlb() if nop4d ...
  asm-generic/tlb: stub out pmd_free_tlb() if nopmd
  asm-generic/mm: stub out p{4,d}d_clear_bad() if
__PAGETABLE_P{4,u}D_FOLDED

 arch/arc/include/asm/pgtable.h  |  1 -
 arch/arc/mm/fault.c | 10 --
 arch/arc/mm/highmem.c   |  4 +++-
 include/asm-generic/4level-fixup.h  |  1 -
 include/asm-generic/5level-fixup.h  |  1 -
 include/asm-generic/pgtable-nop4d.h |  2 +-
 include/asm-generic/pgtable-nopmd.h |  2 +-
 include/asm-generic/pgtable-nopud.h |  2 +-
 include/asm-generic/pgtable.h   | 11 +++
 include/asm-generic/tlb.h   |  4 
 mm/pgtable-generic.c|  8 
 11 files changed, 33 insertions(+), 13 deletions(-)

-- 
2.20.1



[PATCH v2 2/5] asm-generic/tlb: stub out pud_free_tlb() if nopud ...

2019-10-15 Thread Vineet Gupta
... independent of __ARCH_HAS_4LEVEL_HACK

This came up when removing __ARCH_HAS_5LEVEL_HACK for ARC as code bloat
from this routine which is not required in a 2-level paging setup

Note: The primary change is alternate defines for pud_free_tlb() but
while here removed empty stubs for __pud_free_tlb as, which is only called
from pud_free_tlb(), being conditionalized already

| bloat-o-meter2 vmlinux-B-elide-ARCH_USE_5LEVEL_HACK 
vmlinux-C-elide-pud_free_tlb
| add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-104 (-104)
| function old new   delta
| free_pgd_range   656 552-104
| Total: Before=4137276, After=4137172, chg -1.00%

Signed-off-by: Vineet Gupta 
---
 include/asm-generic/4level-fixup.h  | 1 -
 include/asm-generic/pgtable-nopud.h | 2 +-
 include/asm-generic/tlb.h   | 2 --
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/asm-generic/4level-fixup.h 
b/include/asm-generic/4level-fixup.h
index e3667c9a33a5..c86cf7cb4bba 100644
--- a/include/asm-generic/4level-fixup.h
+++ b/include/asm-generic/4level-fixup.h
@@ -30,7 +30,6 @@
 #undef pud_free_tlb
 #define pud_free_tlb(tlb, x, addr) do { } while (0)
 #define pud_free(mm, x)do { } while (0)
-#define __pud_free_tlb(tlb, x, addr)   do { } while (0)
 
 #undef  pud_addr_end
 #define pud_addr_end(addr, end)(end)
diff --git a/include/asm-generic/pgtable-nopud.h 
b/include/asm-generic/pgtable-nopud.h
index c77a1d301155..d3776cb494c0 100644
--- a/include/asm-generic/pgtable-nopud.h
+++ b/include/asm-generic/pgtable-nopud.h
@@ -59,7 +59,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long 
address)
  */
 #define pud_alloc_one(mm, address) NULL
 #define pud_free(mm, x)do { } while (0)
-#define __pud_free_tlb(tlb, x, a)  do { } while (0)
+#define pud_free_tlb(tlb, x, a)do { } while (0)
 
 #undef  pud_addr_end
 #define pud_addr_end(addr, end)(end)
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 04c0644006fd..5e0c2d01e656 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -584,7 +584,6 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
} while (0)
 #endif
 
-#ifndef __ARCH_HAS_4LEVEL_HACK
 #ifndef pud_free_tlb
 #define pud_free_tlb(tlb, pudp, address)   \
do {\
@@ -594,7 +593,6 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
__pud_free_tlb(tlb, pudp, address); \
} while (0)
 #endif
-#endif
 
 #ifndef __ARCH_HAS_5LEVEL_HACK
 #ifndef p4d_free_tlb
-- 
2.20.1



[PATCH v2 4/5] asm-generic/tlb: stub out pmd_free_tlb() if nopmd

2019-10-15 Thread Vineet Gupta
Note that pmd routine folding can be tricky as even in 2-level setup
(where pmd is folded) most pmd routines refer to upper levels.
This one can surely be elided however.

| bloat-o-meter2 vmlinux-E-elide-p?d_clear_bad vmlinux-F-elide-pmd_free_tlb
| add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-112 (-112)
| function old new   delta
| free_pgd_range   422 310-112
| Total: Before=4137042, After=4136930, chg -1.00%

Signed-off-by: Vineet Gupta 
---
 include/asm-generic/pgtable-nopmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/pgtable-nopmd.h 
b/include/asm-generic/pgtable-nopmd.h
index b85b8271a73d..0d9b28cba16d 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -60,7 +60,7 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long 
address)
 static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
 {
 }
-#define __pmd_free_tlb(tlb, x, a)  do { } while (0)
+#define pmd_free_tlb(tlb, x, a)do { } while (0)
 
 #undef  pmd_addr_end
 #define pmd_addr_end(addr, end)(end)
-- 
2.20.1



[PATCH v2 3/5] asm-generic/tlb: stub out p4d_free_tlb() if nop4d ...

2019-10-15 Thread Vineet Gupta
... independent of __ARCH_HAS_5LEVEL_HACK

This came up when removing __ARCH_HAS_5LEVEL_HACK for ARC as code bloat
from this routine not required in a 2-level paging setup

| bloat-o-meter2 vmlinux-C-elide-pud_free_tlb vmlinux-D-elide-p4d_free_tlb
| add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-104 (-104)
| function old new   delta
| free_pgd_range   552 422-130
| Total: Before=4137172, After=4137042, chg -1.00%

Signed-off-by: Vineet Gupta 
---
 include/asm-generic/5level-fixup.h  | 1 -
 include/asm-generic/pgtable-nop4d.h | 2 +-
 include/asm-generic/tlb.h   | 2 --
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/asm-generic/5level-fixup.h 
b/include/asm-generic/5level-fixup.h
index f6947da70d71..4c74b1c1d13b 100644
--- a/include/asm-generic/5level-fixup.h
+++ b/include/asm-generic/5level-fixup.h
@@ -51,7 +51,6 @@ static inline int p4d_present(p4d_t p4d)
 #undef p4d_free_tlb
 #define p4d_free_tlb(tlb, x, addr) do { } while (0)
 #define p4d_free(mm, x)do { } while (0)
-#define __p4d_free_tlb(tlb, x, addr)   do { } while (0)
 
 #undef  p4d_addr_end
 #define p4d_addr_end(addr, end)(end)
diff --git a/include/asm-generic/pgtable-nop4d.h 
b/include/asm-generic/pgtable-nop4d.h
index aebab905e6cd..ce2cbb3c380f 100644
--- a/include/asm-generic/pgtable-nop4d.h
+++ b/include/asm-generic/pgtable-nop4d.h
@@ -50,7 +50,7 @@ static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long 
address)
  */
 #define p4d_alloc_one(mm, address) NULL
 #define p4d_free(mm, x)do { } while (0)
-#define __p4d_free_tlb(tlb, x, a)  do { } while (0)
+#define p4d_free_tlb(tlb, x, a)do { } while (0)
 
 #undef  p4d_addr_end
 #define p4d_addr_end(addr, end)(end)
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 5e0c2d01e656..05dddc17522b 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -594,7 +594,6 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
} while (0)
 #endif
 
-#ifndef __ARCH_HAS_5LEVEL_HACK
 #ifndef p4d_free_tlb
 #define p4d_free_tlb(tlb, pudp, address)   \
do {\
@@ -603,7 +602,6 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
__p4d_free_tlb(tlb, pudp, address); \
} while (0)
 #endif
-#endif
 
 #endif /* CONFIG_MMU */
 
-- 
2.20.1



[PATCH v2 5/5] asm-generic/mm: stub out p{4,d}d_clear_bad() if __PAGETABLE_P{4,u}D_FOLDED

2019-10-15 Thread Vineet Gupta
This removes the code for 2 level paging as seen on ARC

| bloat-o-meter2 vmlinux-D-elide-p4d_free_tlb vmlinux-E-elide-p?d_clear_bad
| add/remove: 0/2 grow/shrink: 0/0 up/down: 0/-40 (-40)
| function old new   delta
| pud_clear_bad 20   - -20
| p4d_clear_bad 20   - -20
| Total: Before=4136930, After=4136890, chg -1.00%

Signed-off-by: Vineet Gupta 
---
 include/asm-generic/pgtable.h | 11 +++
 mm/pgtable-generic.c  |  8 
 2 files changed, 19 insertions(+)

diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 818691846c90..9cdcbc7c0b7b 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -558,8 +558,19 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, 
pgprot_t newprot)
  * Do the tests inline, but report and clear the bad entry in mm/memory.c.
  */
 void pgd_clear_bad(pgd_t *);
+
+#ifndef __PAGETABLE_P4D_FOLDED
 void p4d_clear_bad(p4d_t *);
+#else
+#define p4d_clear_bad(p4d)do { } while (0)
+#endif
+
+#ifndef __PAGETABLE_PUD_FOLDED
 void pud_clear_bad(pud_t *);
+#else
+#define pud_clear_bad(p4d)do { } while (0)
+#endif
+
 void pmd_clear_bad(pmd_t *);
 
 static inline int pgd_none_or_clear_bad(pgd_t *pgd)
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index 532c29276fce..a5edddc3846a 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -24,18 +24,26 @@ void pgd_clear_bad(pgd_t *pgd)
pgd_clear(pgd);
 }
 
+#ifndef __PAGETABLE_P4D_FOLDED
 void p4d_clear_bad(p4d_t *p4d)
 {
p4d_ERROR(*p4d);
p4d_clear(p4d);
 }
+#endif
 
+#ifndef __PAGETABLE_PUD_FOLDED
 void pud_clear_bad(pud_t *pud)
 {
pud_ERROR(*pud);
pud_clear(pud);
 }
+#endif
 
+/*
+ * Note that below can't be stubed out for nopmd case:
+ * pmd folding is special and typically pmd_* macros refet to upper level
+ */
 void pmd_clear_bad(pmd_t *pmd)
 {
pmd_ERROR(*pmd);
-- 
2.20.1



[PATCH v2 1/5] ARC: mm: remove __ARCH_USE_5LEVEL_HACK

2019-10-15 Thread Vineet Gupta
Add the intermedivmlinux-A-baseline vmlinux-B-elide-ARCH_USE_5LEVEL_HACK

This is a non-functional change anyways since ARC has software page walker
with 2 lookup levels (pgd -> pte)

There is slight code bloat due to pulling in needless p*d_free_tlb()
macros which needs to be addressed seperately.

| bloat-o-meter2 vmlinux-with-5LEVEL_HACK vmlinux-patched
| add/remove: 0/0 grow/shrink: 2/0 up/down: 128/0 (128)
| function old new   delta
| free_pgd_range   546 656+110
| p4d_clear_bad  2  20 +18
| Total: Before=4137148, After=4137276, chg 0.00%

Cc: Kirill A. Shutemov 
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/pgtable.h |  1 -
 arch/arc/mm/fault.c| 10 --
 arch/arc/mm/highmem.c  |  4 +++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
index 7addd0301c51..b917b596f7fb 100644
--- a/arch/arc/include/asm/pgtable.h
+++ b/arch/arc/include/asm/pgtable.h
@@ -33,7 +33,6 @@
 #define _ASM_ARC_PGTABLE_H
 
 #include 
-#define __ARCH_USE_5LEVEL_HACK
 #include 
 #include 
 #include/* to propagate CONFIG_ARC_MMU_VER  */
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index 3861543b66a0..fb86bc3e9b35 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -30,6 +30,7 @@ noinline static int handle_kernel_vaddr_fault(unsigned long 
address)
 * with the 'reference' page table.
 */
pgd_t *pgd, *pgd_k;
+   p4d_t *p4d, *p4d_k;
pud_t *pud, *pud_k;
pmd_t *pmd, *pmd_k;
 
@@ -39,8 +40,13 @@ noinline static int handle_kernel_vaddr_fault(unsigned long 
address)
if (!pgd_present(*pgd_k))
goto bad_area;
 
-   pud = pud_offset(pgd, address);
-   pud_k = pud_offset(pgd_k, address);
+   p4d = p4d_offset(pgd, address);
+   p4d_k = p4d_offset(pgd_k, address);
+   if (!p4d_present(*p4d_k))
+   goto bad_area;
+
+   pud = pud_offset(p4d, address);
+   pud_k = pud_offset(p4d_k, address);
if (!pud_present(*pud_k))
goto bad_area;
 
diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c
index a4856bfaedf3..fc8849e4f72e 100644
--- a/arch/arc/mm/highmem.c
+++ b/arch/arc/mm/highmem.c
@@ -111,12 +111,14 @@ EXPORT_SYMBOL(__kunmap_atomic);
 static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr)
 {
pgd_t *pgd_k;
+   p4d_t *p4d_k;
pud_t *pud_k;
pmd_t *pmd_k;
pte_t *pte_k;
 
pgd_k = pgd_offset_k(kvaddr);
-   pud_k = pud_offset(pgd_k, kvaddr);
+   p4d_k = p4d_offset(pgd_k, kvaddr);
+   pud_k = pud_offset(p4d_k, kvaddr);
pmd_k = pmd_offset(pud_k, kvaddr);
 
pte_k = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
-- 
2.20.1



Re: [RFC] asm-generic/tlb: stub out pmd_free_tlb() if __PAGETABLE_PMD_FOLDED

2019-10-14 Thread Vineet Gupta
On 10/14/19 11:25 AM, Linus Torvalds wrote:
> On Mon, Oct 14, 2019 at 11:02 AM Vineet Gupta  wrote:
>>
>> I suppose we could but
>>
>> (a) It would be asymmetric with the __p{u,4}d_free_tlb() changes in [1] and 
>> [2].
> 
> Your patch is already assymmetric wrt those anyway - you had to add that
> 
>   +#else
>   +#define pmd_free_tlb(tlb, pmdp, address)do { } while (0)
>   +#endif
> 
> that the other cases don't currently have, so then you point to
> another patch that makes the code uglier instead.
> 
>> Do you  prefer [1] and [2] be repun along the same lines as you propose 
>> above ?
> 
> In general, I absolutely detest how we have random
> 
>#ifndef ARCH_HAS_ONE_DEFINE
>#define another_define_entirely()
>...
> 
> which makes no sense and is ugly, and also wreaks havoc on simple
> things like "git grep another_define_entirely"
> 
> I've long tried to convince people to just do
> 
>   #ifndef special_define
>   #define special_define(xyz) ..
>   #endif
> 
> instead, which doesn't mix up two completely unrelated names, and when
> you grep for that function name, you _see_ all the context.

Ok fair enough, I'd just add extra comments to non stubbed p?d_free_tlb that 
they
are stubbed out for corresponding case.

> 
>> Also would you care to shed light on my other question about not being able 
>> to
>> fold away pmd_clear_bad() despite PMD_FOLDED given the pmd macros actually
>> checking for pgd. Of all the people you are likely to have most insight on 
>> how the
>> pmd folding actually evolved and works :-)
> 
> I think some of it is just ugly and historical, and confused.
> 
> In general, it should always be the "higher" level that folds away. So
> I think the best example of this is
> 
>   include/asm-generic/pgtable-nop4d.h
> 
> where basically all the "pgd" functions become no-ops, and can never
> not exist or be bad, because they are always just containers for the
> lower level and don't have any data in them themselves:
> 
>   static inline int pgd_none(pgd_t pgd)   { return 0; }
>   static inline int pgd_bad(pgd_t pgd){ return 0; }
>   static inline int pgd_present(pgd_t pgd){ return 1; }
>   static inline void pgd_clear(pgd_t *pgd){ }
> 
> and walking from pgd to p4d is that nice folded op:
> 
>   static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)
>   { return (p4d_t *)pgd; }
> 
> and this is how it should always work.See "nopud" and "nopmd"(which
> are 3rd/2nd level respectively) doing the same thing exactly.

Right, my naive mental model was assuming nopmd would somehow stub out pmd_*
macros (or call into upper level function somehow etc), wheres here
(1) we stub out the prior level and
(2) the function of stubbed level operate on the data type of higher level.


> And yes, pmd_clear_bad() should just go away. We have
> 
>   static inline int pmd_none_or_clear_bad(pmd_t *pmd)
>   {
> if (pmd_none(*pmd))
> return 1;
> if (unlikely(pmd_bad(*pmd))) {
> pmd_clear_bad(pmd);
> return 1;
> }
> return 0;
>   }
> 
> and if the pmd doesn't exist, then both pmd_none() and pmd_bad()
> should just be zero (see above), and the pmd_none_or_clear_bad()
> should just become "return 0";
> 
> Exactly what part isn't working for you?

I haven't tested that patch but I suspect even if it was broken, it would not
necessarily show right away with a trivial test.

Anyhow my worry/confusions starts at free_pgd_range() where
pgd_none_or_clear_bad(pgd) is no-op given pgd_none()/pgd_bad() are stubs for 
nopmd
case.

  free_pgd_range
pgd = pgd_offset(tlb->mm, addr);
do {
next = pgd_addr_end(addr, end);
if (pgd_none_or_clear_bad(pgd))
continue;
free_p4e_range(tlb, pgd, addr);
} while (pgd++, addr = next, addr != end);
   ...

And the validation of pgd entry actually happens in pmd_none_or_clear_bad(pmd)
since there pmd actually ends up referencing pgd entry. Hence the ensuing
pmd_clear_bad() doesn't seem like if it could be stubbed out.

  free_pmd_range
pmd = pmd_offset(pud, addr);
do {
next = pmd_addr_end(addr, end);
if (pmd_none_or_clear_bad(pmd)) <--- pmd_bad()/pmd_clear_bad()
continue;
free_pte_range(tlb, pmd, addr);
} while (pmd++, addr = next, addr != end);

I'm sure I'm missing something, but don't understand what !


Re: [RFC] asm-generic/tlb: stub out pmd_free_tlb() if __PAGETABLE_PMD_FOLDED

2019-10-14 Thread Vineet Gupta
On 10/14/19 10:41 AM, Linus Torvalds wrote:
> On Fri, Oct 11, 2019 at 3:38 PM Vineet Gupta  
> wrote:
>>
>> This is inine with similar patches for nopud [1] and nop4d [2] cases.
> 
> I don't think your patch is wrong, but wouldn't it be easier and
> cleaner to just do this instead
> 
> --- a/include/asm-generic/pgtable-nopmd.h
> +++ b/include/asm-generic/pgtable-nopmd.h
> @@ -60,7 +60,7 @@ static inline pmd_t * pmd_offset(pud_t * pud,
> unsigned long address)
>  static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
>  {
>  }
> -#define __pmd_free_tlb(tlb, x, a)  do { } while (0)
> +#define pmd_free_tlb(tlb, x, a)do { } while (0)
> 
>  #undef  pmd_addr_end
>  #define pmd_addr_end(addr, end)(end)

I suppose we could but

(a) It would be asymmetric with the __p{u,4}d_free_tlb() changes in [1] and [2].
Do you  prefer [1] and [2] be repun along the same lines as you propose above ?

(b) IMHO p?d_free_tlb() under corresponding #ifndef *P?D_FOLDED is much clearer 
to
read as being stubbed out. But this is minor point.

Also would you care to shed light on my other question about not being able to
fold away pmd_clear_bad() despite PMD_FOLDED given the pmd macros actually
checking for pgd. Of all the people you are likely to have most insight on how 
the
pmd folding actually evolved and works :-)

Thx,
-Vineet

[1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006266.html
[2] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006265.html


[RFC] asm-generic/tlb: stub out pmd_free_tlb() if __PAGETABLE_PMD_FOLDED

2019-10-11 Thread Vineet Gupta
This is inine with similar patches for nopud [1] and nop4d [2] cases.

  However I'm not really sure I understand clearly how the nopmd code is
  supposed to work (for a 2 tier paging system) - hence the RFC.
  Consider free_pmd_range() simplified/annotated below

  free_pmd_range
  ...
pmd = pmd_offset(pud, addr);
do {
next = pmd_addr_end(addr, end);
if (pmd_none_or_clear_bad(pmd)) => *pmd_bad()/pmd_clear_bad() 
[a]*
continue;
free_pte_range(tlb, pmd, addr);
} while (pmd++, addr = next, addr != end);
   ...
*pmd_free_tlb(tlb, pmd, start); => [b]*

   For ARC/nopmd case [a] is actually checking pgd and consequently
   pmd_clear_bad() can't be stubbed out for PMD_FOLDED case. However it seems
   case [b] can be stubbed out (hence this patch) along same lines as [1] and 
[2]

| bloat-o-meter2 vmlinux-E-elide-p?d_clear_bad vmlinux-F-elide-pmd_free_tlb
| add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-112 (-112)
| function old new   delta
| free_pgd_range   422 310-112
| Total: Before=4137002, After=4136890, chg -1.00%

[1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006266.html
[2] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006265.html

Signed-off-by: Vineet Gupta 
---
 include/asm-generic/tlb.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index f3dad87f4ecc..a1edad7d4170 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -574,6 +574,7 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
} while (0)
 #endif
 
+#ifndef __PAGETABLE_PMD_FOLDED
 #ifndef pmd_free_tlb
 #define pmd_free_tlb(tlb, pmdp, address)   \
do {\
@@ -583,6 +584,9 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
__pmd_free_tlb(tlb, pmdp, address); \
} while (0)
 #endif
+#else
+#define pmd_free_tlb(tlb, pmdp, address)do { } while (0)
+#endif
 
 #ifndef __PAGETABLE_PUD_FOLDED
 #ifndef pud_free_tlb
-- 
2.20.1



Re: [PATCH 0/3] eldie generated code for folded p4d/pud

2019-10-10 Thread Vineet Gupta


Hi Kirill,

On 10/10/19 1:56 AM, Kirill A. Shutemov wrote:
> On Wed, Oct 09, 2019 at 10:26:55PM +0000, Vineet Gupta wrote:
>>
>> This series elides extraneous generate code for folded p4d/pud.
>> This came up when trying to remove __ARCH_USE_5LEVEL_HACK from ARC port.
>> The code saving are not a while lot, but still worthwhile IMHO.
> 
> Agreed.

Thx.

So given we are folding pmd too, it seemed we could do the following as well.

+#ifndef __PAGETABLE_PMD_FOLDED
 void pmd_clear_bad(pmd_t *);
+#else
+#define pmd_clear_bad(pmd)do { } while (0)
+#endif

+#ifndef __PAGETABLE_PMD_FOLDED
 void pmd_clear_bad(pmd_t *pmd)
 {
pmd_ERROR(*pmd);
pmd_clear(pmd);
 }
+#endif

I stared at generated code and it seems a bit wrong.
free_pgd_range() -> pgd_none_or_clear_bad() is no longer checking for unmapped 
pgd
entries as pgd_none/pgd_bad are all stubs returning 0.

This whole pmd folding is a bit confusing considering I only revisit it every 
few
years :-) Abstraction wise, __PAGETABLE_PMD_FOLDED only has pgd, pte but even in
this regime bunch of pmd macros are still valid

pmd_set(pmdp, ptep) {
*pmdp.pud.p4d.pgd = (unsigned long)ptep
}

Is there a better way to make a mental model of this code folding.

In an ideal world pmd folded would have meant pmd_* routines just vanish - poof.
So in that sense I like your implementation under #[45]LEVEL_HACK where the 
level
simply vanishes by code like #define p4d_t pgd_t. Perhaps there is lot of 
historic
baggage, proliferated into arch code so hard to untangle.

Thx,
-Vineet


[PATCH 1/3] asm-generic/tlb: stub out pud_free_tlb() if __PAGETABLE_PUD_FOLDED ...

2019-10-09 Thread Vineet Gupta
... independent of __ARCH_HAS_4LEVEL_HACK

This came up when removing __ARCH_HAS_5LEVEL_HACK for ARC as code bloat
from pud_free_tlb() despite pud being folded (with 2 levels on ARC)

| bloat-o-meter2 vmlinux-B-elide-ARCH_USE_5LEVEL_HACK 
vmlinux-C-elide-pud_free_tlb
| add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-104 (-104)
| function old new   delta
| free_pgd_range   656 552-104
| Total: Before=4137276, After=4137172, chg -1.00%

Signed-off-by: Vineet Gupta 
---
 include/asm-generic/4level-fixup.h | 2 --
 include/asm-generic/tlb.h  | 4 +++-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/4level-fixup.h 
b/include/asm-generic/4level-fixup.h
index e3667c9a33a5..d7c5ba1968d3 100644
--- a/include/asm-generic/4level-fixup.h
+++ b/include/asm-generic/4level-fixup.h
@@ -27,8 +27,6 @@
 #define pud_page(pud)  pgd_page(pud)
 #define pud_page_vaddr(pud)pgd_page_vaddr(pud)
 
-#undef pud_free_tlb
-#define pud_free_tlb(tlb, x, addr) do { } while (0)
 #define pud_free(mm, x)do { } while (0)
 #define __pud_free_tlb(tlb, x, addr)   do { } while (0)
 
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 04c0644006fd..1f83188cb331 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -584,7 +584,7 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
} while (0)
 #endif
 
-#ifndef __ARCH_HAS_4LEVEL_HACK
+#ifndef __PAGETABLE_PUD_FOLDED
 #ifndef pud_free_tlb
 #define pud_free_tlb(tlb, pudp, address)   \
do {\
@@ -594,6 +594,8 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, 
struct vm_area_struct *vm
__pud_free_tlb(tlb, pudp, address); \
} while (0)
 #endif
+#else
+#define pud_free_tlb(tlb, pudp, address)   do { } while (0)
 #endif
 
 #ifndef __ARCH_HAS_5LEVEL_HACK
-- 
2.20.1



[PATCH 3/3] asm-generic/mm: stub out p{4,d}d_clear_bad() if __PAGETABLE_P{4,u}D_FOLDED

2019-10-09 Thread Vineet Gupta
This removes the code for 2 level paging as seen on ARC

| bloat-o-meter2 vmlinux-D-elide-p4d_free_tlb vmlinux-E-elide-p?d_clear_bad
| add/remove: 0/2 grow/shrink: 0/0 up/down: 0/-22 (-22)
| function old new   delta
| pud_clear_bad 20   - -20
| p4d_clear_bad 20   - -20
| Total: Before=4137104, After=4137082, chg -1.00%

Signed-off-by: Vineet Gupta 
---
 include/asm-generic/pgtable.h | 11 +++
 mm/pgtable-generic.c  |  4 
 2 files changed, 15 insertions(+)

diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 818691846c90..9cdcbc7c0b7b 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -558,8 +558,19 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, 
pgprot_t newprot)
  * Do the tests inline, but report and clear the bad entry in mm/memory.c.
  */
 void pgd_clear_bad(pgd_t *);
+
+#ifndef __PAGETABLE_P4D_FOLDED
 void p4d_clear_bad(p4d_t *);
+#else
+#define p4d_clear_bad(p4d)do { } while (0)
+#endif
+
+#ifndef __PAGETABLE_PUD_FOLDED
 void pud_clear_bad(pud_t *);
+#else
+#define pud_clear_bad(p4d)do { } while (0)
+#endif
+
 void pmd_clear_bad(pmd_t *);
 
 static inline int pgd_none_or_clear_bad(pgd_t *pgd)
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index 532c29276fce..856dc3bb77e6 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -24,17 +24,21 @@ void pgd_clear_bad(pgd_t *pgd)
pgd_clear(pgd);
 }
 
+#ifndef __PAGETABLE_P4D_FOLDED
 void p4d_clear_bad(p4d_t *p4d)
 {
p4d_ERROR(*p4d);
p4d_clear(p4d);
 }
+#endif
 
+#ifndef __PAGETABLE_PUD_FOLDED
 void pud_clear_bad(pud_t *pud)
 {
pud_ERROR(*pud);
pud_clear(pud);
 }
+#endif
 
 void pmd_clear_bad(pmd_t *pmd)
 {
-- 
2.20.1



  1   2   3   4   5   6   7   8   9   10   >