Re: [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures

2024-02-26 Thread Guo Ren
On Tue, Feb 27, 2024 at 12:15 AM Arnd Bergmann  wrote:
>
> From: Arnd Bergmann 
>
> Most architectures only support a single hardcoded page size. In order
> to ensure that each one of these sets the corresponding Kconfig symbols,
> change over the PAGE_SHIFT definition to the common one and allow
> only the hardware page size to be selected.
>
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/alpha/Kconfig | 1 +
>  arch/alpha/include/asm/page.h  | 2 +-
>  arch/arm/Kconfig   | 1 +
>  arch/arm/include/asm/page.h| 2 +-
>  arch/csky/Kconfig  | 1 +
>  arch/csky/include/asm/page.h   | 2 +-
>  arch/m68k/Kconfig  | 3 +++
>  arch/m68k/Kconfig.cpu  | 2 ++
>  arch/m68k/include/asm/page.h   | 6 +-
>  arch/microblaze/Kconfig| 1 +
>  arch/microblaze/include/asm/page.h | 2 +-
>  arch/nios2/Kconfig | 1 +
>  arch/nios2/include/asm/page.h  | 2 +-
>  arch/openrisc/Kconfig  | 1 +
>  arch/openrisc/include/asm/page.h   | 2 +-
>  arch/riscv/Kconfig | 1 +
>  arch/riscv/include/asm/page.h  | 2 +-
>  arch/s390/Kconfig  | 1 +
>  arch/s390/include/asm/page.h   | 2 +-
>  arch/sparc/Kconfig | 2 ++
>  arch/sparc/include/asm/page_32.h   | 2 +-
>  arch/sparc/include/asm/page_64.h   | 3 +--
>  arch/um/Kconfig| 1 +
>  arch/um/include/asm/page.h | 2 +-
>  arch/x86/Kconfig   | 1 +
>  arch/x86/include/asm/page_types.h  | 2 +-
>  arch/xtensa/Kconfig| 1 +
>  arch/xtensa/include/asm/page.h | 2 +-
>  28 files changed, 32 insertions(+), 19 deletions(-)
>
> diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
> index d6968d090d49..4f490250d323 100644
> --- a/arch/alpha/Kconfig
> +++ b/arch/alpha/Kconfig
> @@ -14,6 +14,7 @@ config ALPHA
> select PCI_DOMAINS if PCI
> select PCI_SYSCALL if PCI
> select HAVE_ASM_MODVERSIONS
> +   select HAVE_PAGE_SIZE_8KB
> select HAVE_PCSPKR_PLATFORM
> select HAVE_PERF_EVENTS
> select NEED_DMA_MAP_STATE
> diff --git a/arch/alpha/include/asm/page.h b/arch/alpha/include/asm/page.h
> index 4db1ebc0ed99..70419e6be1a3 100644
> --- a/arch/alpha/include/asm/page.h
> +++ b/arch/alpha/include/asm/page.h
> @@ -6,7 +6,7 @@
>  #include 
>
>  /* PAGE_SHIFT determines the page size */
> -#define PAGE_SHIFT 13
> +#define PAGE_SHIFT CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE  (_AC(1,UL) << PAGE_SHIFT)
>  #define PAGE_MASK  (~(PAGE_SIZE-1))
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 0af6709570d1..9d52ba3a8ad1 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -116,6 +116,7 @@ config ARM
> select HAVE_MOD_ARCH_SPECIFIC
> select HAVE_NMI
> select HAVE_OPTPROBES if !THUMB2_KERNEL
> +   select HAVE_PAGE_SIZE_4KB
> select HAVE_PCI if MMU
> select HAVE_PERF_EVENTS
> select HAVE_PERF_REGS
> diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
> index 119aa85d1feb..62af9f7f9e96 100644
> --- a/arch/arm/include/asm/page.h
> +++ b/arch/arm/include/asm/page.h
> @@ -8,7 +8,7 @@
>  #define _ASMARM_PAGE_H
>
>  /* PAGE_SHIFT determines the page size */
> -#define PAGE_SHIFT 12
> +#define PAGE_SHIFT CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE  (_AC(1,UL) << PAGE_SHIFT)
>  #define PAGE_MASK  (~((1 << PAGE_SHIFT) - 1))
>
> diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
> index cf2a6fd7dff8..9c2723ab1c94 100644
> --- a/arch/csky/Kconfig
> +++ b/arch/csky/Kconfig
> @@ -89,6 +89,7 @@ config CSKY
> select HAVE_KPROBES if !CPU_CK610
> select HAVE_KPROBES_ON_FTRACE if !CPU_CK610
> select HAVE_KRETPROBES if !CPU_CK610
> +   select HAVE_PAGE_SIZE_4KB
> select HAVE_PERF_EVENTS
> select HAVE_PERF_REGS
> select HAVE_PERF_USER_STACK_DUMP
> diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h
> index 4a0502e324a6..f70f37402d75 100644
> --- a/arch/csky/include/asm/page.h
> +++ b/arch/csky/include/asm/page.h
> @@ -10,7 +10,7 @@
>  /*
>   * PAGE_SHIFT determines the page size: 4KB
>   */
> -#define PAGE_SHIFT 12
> +#define PAGE_SHIFT CONFIG_PAGE_SHIFT
LGTM, thx.
Acked-by: Guo Ren 

>  #define PAGE_SIZE  (_AC(1, UL) << PAGE_SHIFT)
>  #define PAGE_MASK  (~(PAGE_SIZE - 1))
>  #define THREAD_SIZE(PAGE_SIZE * 2)
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index 4b3e93cac723..7b709453d5e7 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k

Re: [PATCH 20/21] csky: remove ioremap_cache

2019-10-21 Thread Guo Ren
Acked-by: Guo Ren 

On Fri, Oct 18, 2019 at 1:47 AM Christoph Hellwig  wrote:
>
> No driver that can be used on csky uses ioremap_cache, and this
> interface has been deprecated in favor of memremap.
>
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/csky/include/asm/io.h | 2 --
>  arch/csky/mm/ioremap.c | 7 ---
>  2 files changed, 9 deletions(-)
>
> diff --git a/arch/csky/include/asm/io.h b/arch/csky/include/asm/io.h
> index a4b9fb616faa..f572605d5ad5 100644
> --- a/arch/csky/include/asm/io.h
> +++ b/arch/csky/include/asm/io.h
> @@ -36,13 +36,11 @@
>  /*
>   * I/O memory mapping functions.
>   */
> -extern void __iomem *ioremap_cache(phys_addr_t addr, size_t size);
>  extern void __iomem *__ioremap(phys_addr_t addr, size_t size, pgprot_t prot);
>  extern void iounmap(void *addr);
>
>  #define ioremap(addr, size)__ioremap((addr), (size), 
> pgprot_noncached(PAGE_KERNEL))
>  #define ioremap_wc(addr, size) __ioremap((addr), (size), 
> pgprot_writecombine(PAGE_KERNEL))
> -#define ioremap_cache  ioremap_cache
>
>  #include 
>
> diff --git a/arch/csky/mm/ioremap.c b/arch/csky/mm/ioremap.c
> index e13cd3497628..ae78256a56fd 100644
> --- a/arch/csky/mm/ioremap.c
> +++ b/arch/csky/mm/ioremap.c
> @@ -44,13 +44,6 @@ void __iomem *__ioremap(phys_addr_t phys_addr, size_t 
> size, pgprot_t prot)
>  }
>  EXPORT_SYMBOL(__ioremap);
>
> -void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size)
> -{
> -   return __ioremap_caller(phys_addr, size, PAGE_KERNEL,
> -   __builtin_return_address(0));
> -}
> -EXPORT_SYMBOL(ioremap_cache);
> -
>  void iounmap(void __iomem *addr)
>  {
> vunmap((void *)((unsigned long)addr & PAGE_MASK));
> --
> 2.20.1
>


-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/


Re: [PATCH 05/15] csky: switch to generic version of pte allocation

2019-05-03 Thread Guo Ren
On Sat, May 04, 2019 at 12:03:48AM +0800, Guo Ren wrote:
> Hi Mike,
> 
> Acked-by: Guo Ren 
> 
> On Thu, May 02, 2019 at 06:28:32PM +0300, Mike Rapoport wrote:
> > The csky implementation pte_alloc_one(), pte_free_kernel() and pte_free()
> > is identical to the generic except of lack of __GFP_ACCOUNT for the user
> > PTEs allocation.
> > 
> > Switch csky to use generic version of these functions.
> Ok.
> 
> > 
> > The csky implementation of pte_alloc_one_kernel() is not replaced because
> > it does not clear the allocated page but rather sets each PTE in it to a
> > non-zero value.
> Yes, we must set each PTE to _PAGE_GLOBAL because hardware refill the
> MMU TLB entry with two PTEs and it use the result of pte0.global | 
> pte1.global.
   ^
  correct: pte0.global & pte1.global
> If pte0 is valid and pte1 is invalid, we must set _PAGE_GLOBAL in
> invalid pte entry. Fortunately, there is no performance issue.
> 
> > 
> > The pte_free_kernel() and pte_free() versions on csky are identical to the
> > generic ones and can be simply dropped.
> Ok.
> 
> Best Regards
>  Guo Ren
> 
> > 
> > Signed-off-by: Mike Rapoport 
> > ---
> >  arch/csky/include/asm/pgalloc.h | 30 +++---
> >  1 file changed, 3 insertions(+), 27 deletions(-)
> > 
> > diff --git a/arch/csky/include/asm/pgalloc.h 
> > b/arch/csky/include/asm/pgalloc.h
> > index d213bb4..98c571670 100644
> > --- a/arch/csky/include/asm/pgalloc.h
> > +++ b/arch/csky/include/asm/pgalloc.h
> > @@ -8,6 +8,9 @@
> >  #include 
> >  #include 
> >  
> > +#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
> > +#include/* for pte_{alloc,free}_one */
> > +
> >  static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
> > pte_t *pte)
> >  {
> > @@ -39,33 +42,6 @@ static inline pte_t *pte_alloc_one_kernel(struct 
> > mm_struct *mm)
> > return pte;
> >  }
> >  
> > -static inline struct page *pte_alloc_one(struct mm_struct *mm)
> > -{
> > -   struct page *pte;
> > -
> > -   pte = alloc_pages(GFP_KERNEL | __GFP_ZERO, 0);
> > -   if (!pte)
> > -   return NULL;
> > -
> > -   if (!pgtable_page_ctor(pte)) {
> > -   __free_page(pte);
> > -   return NULL;
> > -   }
> > -
> > -   return pte;
> > -}
> > -
> > -static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
> > -{
> > -   free_pages((unsigned long)pte, PTE_ORDER);
> > -}
> > -
> > -static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
> > -{
> > -   pgtable_page_dtor(pte);
> > -   __free_pages(pte, PTE_ORDER);
> > -}
> > -
> >  static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
> >  {
> > free_pages((unsigned long)pgd, PGD_ORDER);
> > -- 
> > 2.7.4
> > 
> 
> ___
> linux-riscv mailing list
> linux-ri...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv


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

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

Looks good for me and panic is ok.

Reviewed-by: Guo Ren