Re: [PATCH 2/2] rtc/alpha: remove legacy rtc driver

2019-10-23 Thread Paul Gortmaker
[[PATCH 2/2] rtc/alpha: remove legacy rtc driver] On 23/10/2019 (Wed 17:01) 
Arnd Bergmann wrote:

> The old drivers/char/rtc.c driver was originally the implementation
> for x86 PCs but got subsequently replaced by the rtc class driver
> on all architectures except alpha.
> 
> Move alpha over to the portable driver and remove the old one
> for good.

Git history will show I'm in favour of showing old code and old drivers
to the curb - even if it is stuff that I wrote myself 20+ years ago!  So
if all users are now on the formalized rtc framework, then this relic
should go away, and you can add my ack'd for the commit.

Thanks,
Paul.
--

> 
> The CONFIG_JS_RTC option was only ever used on SPARC32 but
> has not been available for many years, this was used to build
> the same rtc driver with a different module name.
> 
> Cc: Richard Henderson 
> Cc: Ivan Kokshaysky 
> Cc: Matt Turner 
> Cc: linux-alpha@vger.kernel.org
> Cc: Paul Gortmaker 
> Signed-off-by: Arnd Bergmann 
> ---
> This was last discussed in early 2018 in
> https://lore.kernel.org/lkml/CAK8P3a0QZNY+K+V1HG056xCerz=_l2jh5ufz+2lwkdqkw5z...@mail.gmail.com/
> 
> Nobody ever replied there, so let's try this instead.
> If there is any reason to keep the driver after all,
> please let us know.
> ---
>  arch/alpha/configs/defconfig |3 +-
>  drivers/char/Kconfig |   56 --
>  drivers/char/Makefile|4 -
>  drivers/char/rtc.c   | 1311 --
>  4 files changed, 2 insertions(+), 1372 deletions(-)
>  delete mode 100644 drivers/char/rtc.c
> 
> diff --git a/arch/alpha/configs/defconfig b/arch/alpha/configs/defconfig
> index f4ec420d7f2d..e10c1be3c0d1 100644
> --- a/arch/alpha/configs/defconfig
> +++ b/arch/alpha/configs/defconfig
> @@ -53,7 +53,8 @@ CONFIG_NET_PCI=y
>  CONFIG_YELLOWFIN=y
>  CONFIG_SERIAL_8250=y
>  CONFIG_SERIAL_8250_CONSOLE=y
> -CONFIG_RTC=y
> +CONFIG_RTC_CLASS=y
> +CONFIG_RTC_DRV_CMOS=y
>  CONFIG_EXT2_FS=y
>  CONFIG_REISERFS_FS=m
>  CONFIG_ISO9660_FS=y
> diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
> index dabbf3f519c6..c2ac4f257c82 100644
> --- a/drivers/char/Kconfig
> +++ b/drivers/char/Kconfig
> @@ -243,62 +243,6 @@ config NVRAM
> To compile this driver as a module, choose M here: the
> module will be called nvram.
>  
> -#
> -# These legacy RTC drivers just cause too many conflicts with the generic
> -# RTC framework ... let's not even try to coexist any more.
> -#
> -if RTC_LIB=n
> -
> -config RTC
> - tristate "Enhanced Real Time Clock Support (legacy PC RTC driver)"
> - depends on ALPHA
> - ---help---
> -   If you say Y here and create a character special file /dev/rtc with
> -   major number 10 and minor number 135 using mknod ("man mknod"), you
> -   will get access to the real time clock (or hardware clock) built
> -   into your computer.
> -
> -   Every PC has such a clock built in. It can be used to generate
> -   signals from as low as 1Hz up to 8192Hz, and can also be used
> -   as a 24 hour alarm. It reports status information via the file
> -   /proc/driver/rtc and its behaviour is set by various ioctls on
> -   /dev/rtc.
> -
> -   If you run Linux on a multiprocessor machine and said Y to
> -   "Symmetric Multi Processing" above, you should say Y here to read
> -   and set the RTC in an SMP compatible fashion.
> -
> -   If you think you have a use for such a device (such as periodic data
> -   sampling), then say Y here, and read 
> 
> -   for details.
> -
> -   To compile this driver as a module, choose M here: the
> -   module will be called rtc.
> -
> -config JS_RTC
> - tristate "Enhanced Real Time Clock Support"
> - depends on SPARC32 && PCI
> - ---help---
> -   If you say Y here and create a character special file /dev/rtc with
> -   major number 10 and minor number 135 using mknod ("man mknod"), you
> -   will get access to the real time clock (or hardware clock) built
> -   into your computer.
> -
> -   Every PC has such a clock built in. It can be used to generate
> -   signals from as low as 1Hz up to 8192Hz, and can also be used
> -   as a 24 hour alarm. It reports status information via the file
> -   /proc/driver/rtc and its behaviour is set by various ioctls on
> -   /dev/rtc.
> -
> -   If you think you have a use for such a device (such as periodic data
> -   sampling), then say Y here, and read 
> 
> -   for details.
> -
> -   To compile this driver as a module, choose M here: the
> -   module will be called js-rtc.
> -
> -endif # RTC_LIB
> -
>  config DTLK
>   tristate "Double Talk PC internal speech card support"
>   depends on ISA
> diff --git a/drivers/char/Makefile b/drivers/char/Makefile
> index abe3138b1f5a..ffce287ef415 100644
> --- a/drivers/char/Makefile
> +++ b/drivers/char/Makefile
> @@ -20,7 +20,6 @@ obj-$(CONFIG_APM_EMULATION) += apm-emulation.o
>  

Re: [PATCH 2/2] rtc/alpha: remove legacy rtc driver

2019-10-23 Thread Alexandre Belloni
On 23/10/2019 17:01:59+0200, Arnd Bergmann wrote:
> The old drivers/char/rtc.c driver was originally the implementation
> for x86 PCs but got subsequently replaced by the rtc class driver
> on all architectures except alpha.
> 
> Move alpha over to the portable driver and remove the old one
> for good.
> 
> The CONFIG_JS_RTC option was only ever used on SPARC32 but
> has not been available for many years, this was used to build
> the same rtc driver with a different module name.
> 
> Cc: Richard Henderson 
> Cc: Ivan Kokshaysky 
> Cc: Matt Turner 
> Cc: linux-alpha@vger.kernel.org
> Cc: Paul Gortmaker 
> Signed-off-by: Arnd Bergmann 
Acked-by: Alexandre Belloni 

> ---
> This was last discussed in early 2018 in
> https://lore.kernel.org/lkml/CAK8P3a0QZNY+K+V1HG056xCerz=_l2jh5ufz+2lwkdqkw5z...@mail.gmail.com/
> 
> Nobody ever replied there, so let's try this instead.
> If there is any reason to keep the driver after all,
> please let us know.
> ---
>  arch/alpha/configs/defconfig |3 +-
>  drivers/char/Kconfig |   56 --
>  drivers/char/Makefile|4 -
>  drivers/char/rtc.c   | 1311 --
>  4 files changed, 2 insertions(+), 1372 deletions(-)
>  delete mode 100644 drivers/char/rtc.c
> 
> diff --git a/arch/alpha/configs/defconfig b/arch/alpha/configs/defconfig
> index f4ec420d7f2d..e10c1be3c0d1 100644
> --- a/arch/alpha/configs/defconfig
> +++ b/arch/alpha/configs/defconfig
> @@ -53,7 +53,8 @@ CONFIG_NET_PCI=y
>  CONFIG_YELLOWFIN=y
>  CONFIG_SERIAL_8250=y
>  CONFIG_SERIAL_8250_CONSOLE=y
> -CONFIG_RTC=y
> +CONFIG_RTC_CLASS=y
> +CONFIG_RTC_DRV_CMOS=y
>  CONFIG_EXT2_FS=y
>  CONFIG_REISERFS_FS=m
>  CONFIG_ISO9660_FS=y
> diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
> index dabbf3f519c6..c2ac4f257c82 100644
> --- a/drivers/char/Kconfig
> +++ b/drivers/char/Kconfig
> @@ -243,62 +243,6 @@ config NVRAM
> To compile this driver as a module, choose M here: the
> module will be called nvram.
>  
> -#
> -# These legacy RTC drivers just cause too many conflicts with the generic
> -# RTC framework ... let's not even try to coexist any more.
> -#
> -if RTC_LIB=n
> -
> -config RTC
> - tristate "Enhanced Real Time Clock Support (legacy PC RTC driver)"
> - depends on ALPHA
> - ---help---
> -   If you say Y here and create a character special file /dev/rtc with
> -   major number 10 and minor number 135 using mknod ("man mknod"), you
> -   will get access to the real time clock (or hardware clock) built
> -   into your computer.
> -
> -   Every PC has such a clock built in. It can be used to generate
> -   signals from as low as 1Hz up to 8192Hz, and can also be used
> -   as a 24 hour alarm. It reports status information via the file
> -   /proc/driver/rtc and its behaviour is set by various ioctls on
> -   /dev/rtc.
> -
> -   If you run Linux on a multiprocessor machine and said Y to
> -   "Symmetric Multi Processing" above, you should say Y here to read
> -   and set the RTC in an SMP compatible fashion.
> -
> -   If you think you have a use for such a device (such as periodic data
> -   sampling), then say Y here, and read 
> 
> -   for details.
> -
> -   To compile this driver as a module, choose M here: the
> -   module will be called rtc.
> -
> -config JS_RTC
> - tristate "Enhanced Real Time Clock Support"
> - depends on SPARC32 && PCI
> - ---help---
> -   If you say Y here and create a character special file /dev/rtc with
> -   major number 10 and minor number 135 using mknod ("man mknod"), you
> -   will get access to the real time clock (or hardware clock) built
> -   into your computer.
> -
> -   Every PC has such a clock built in. It can be used to generate
> -   signals from as low as 1Hz up to 8192Hz, and can also be used
> -   as a 24 hour alarm. It reports status information via the file
> -   /proc/driver/rtc and its behaviour is set by various ioctls on
> -   /dev/rtc.
> -
> -   If you think you have a use for such a device (such as periodic data
> -   sampling), then say Y here, and read 
> 
> -   for details.
> -
> -   To compile this driver as a module, choose M here: the
> -   module will be called js-rtc.
> -
> -endif # RTC_LIB
> -
>  config DTLK
>   tristate "Double Talk PC internal speech card support"
>   depends on ISA
> diff --git a/drivers/char/Makefile b/drivers/char/Makefile
> index abe3138b1f5a..ffce287ef415 100644
> --- a/drivers/char/Makefile
> +++ b/drivers/char/Makefile
> @@ -20,7 +20,6 @@ obj-$(CONFIG_APM_EMULATION) += apm-emulation.o
>  obj-$(CONFIG_DTLK)   += dtlk.o
>  obj-$(CONFIG_APPLICOM)   += applicom.o
>  obj-$(CONFIG_SONYPI) += sonypi.o
> -obj-$(CONFIG_RTC)+= rtc.o
>  obj-$(CONFIG_HPET)   += hpet.o
>  obj-$(CONFIG_XILINX_HWICAP)  += xilinx_hwicap/
>  obj-$(CONFIG_NVRAM)  += nvram.o
> @@ -45,9 

[PATCH 2/2] rtc/alpha: remove legacy rtc driver

2019-10-23 Thread Arnd Bergmann
The old drivers/char/rtc.c driver was originally the implementation
for x86 PCs but got subsequently replaced by the rtc class driver
on all architectures except alpha.

Move alpha over to the portable driver and remove the old one
for good.

The CONFIG_JS_RTC option was only ever used on SPARC32 but
has not been available for many years, this was used to build
the same rtc driver with a different module name.

Cc: Richard Henderson 
Cc: Ivan Kokshaysky 
Cc: Matt Turner 
Cc: linux-alpha@vger.kernel.org
Cc: Paul Gortmaker 
Signed-off-by: Arnd Bergmann 
---
This was last discussed in early 2018 in
https://lore.kernel.org/lkml/CAK8P3a0QZNY+K+V1HG056xCerz=_l2jh5ufz+2lwkdqkw5z...@mail.gmail.com/

Nobody ever replied there, so let's try this instead.
If there is any reason to keep the driver after all,
please let us know.
---
 arch/alpha/configs/defconfig |3 +-
 drivers/char/Kconfig |   56 --
 drivers/char/Makefile|4 -
 drivers/char/rtc.c   | 1311 --
 4 files changed, 2 insertions(+), 1372 deletions(-)
 delete mode 100644 drivers/char/rtc.c

diff --git a/arch/alpha/configs/defconfig b/arch/alpha/configs/defconfig
index f4ec420d7f2d..e10c1be3c0d1 100644
--- a/arch/alpha/configs/defconfig
+++ b/arch/alpha/configs/defconfig
@@ -53,7 +53,8 @@ CONFIG_NET_PCI=y
 CONFIG_YELLOWFIN=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_RTC=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_CMOS=y
 CONFIG_EXT2_FS=y
 CONFIG_REISERFS_FS=m
 CONFIG_ISO9660_FS=y
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index dabbf3f519c6..c2ac4f257c82 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -243,62 +243,6 @@ config NVRAM
  To compile this driver as a module, choose M here: the
  module will be called nvram.
 
-#
-# These legacy RTC drivers just cause too many conflicts with the generic
-# RTC framework ... let's not even try to coexist any more.
-#
-if RTC_LIB=n
-
-config RTC
-   tristate "Enhanced Real Time Clock Support (legacy PC RTC driver)"
-   depends on ALPHA
-   ---help---
- If you say Y here and create a character special file /dev/rtc with
- major number 10 and minor number 135 using mknod ("man mknod"), you
- will get access to the real time clock (or hardware clock) built
- into your computer.
-
- Every PC has such a clock built in. It can be used to generate
- signals from as low as 1Hz up to 8192Hz, and can also be used
- as a 24 hour alarm. It reports status information via the file
- /proc/driver/rtc and its behaviour is set by various ioctls on
- /dev/rtc.
-
- If you run Linux on a multiprocessor machine and said Y to
- "Symmetric Multi Processing" above, you should say Y here to read
- and set the RTC in an SMP compatible fashion.
-
- If you think you have a use for such a device (such as periodic data
- sampling), then say Y here, and read 

- for details.
-
- To compile this driver as a module, choose M here: the
- module will be called rtc.
-
-config JS_RTC
-   tristate "Enhanced Real Time Clock Support"
-   depends on SPARC32 && PCI
-   ---help---
- If you say Y here and create a character special file /dev/rtc with
- major number 10 and minor number 135 using mknod ("man mknod"), you
- will get access to the real time clock (or hardware clock) built
- into your computer.
-
- Every PC has such a clock built in. It can be used to generate
- signals from as low as 1Hz up to 8192Hz, and can also be used
- as a 24 hour alarm. It reports status information via the file
- /proc/driver/rtc and its behaviour is set by various ioctls on
- /dev/rtc.
-
- If you think you have a use for such a device (such as periodic data
- sampling), then say Y here, and read 

- for details.
-
- To compile this driver as a module, choose M here: the
- module will be called js-rtc.
-
-endif # RTC_LIB
-
 config DTLK
tristate "Double Talk PC internal speech card support"
depends on ISA
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index abe3138b1f5a..ffce287ef415 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -20,7 +20,6 @@ obj-$(CONFIG_APM_EMULATION)   += apm-emulation.o
 obj-$(CONFIG_DTLK) += dtlk.o
 obj-$(CONFIG_APPLICOM) += applicom.o
 obj-$(CONFIG_SONYPI)   += sonypi.o
-obj-$(CONFIG_RTC)  += rtc.o
 obj-$(CONFIG_HPET) += hpet.o
 obj-$(CONFIG_XILINX_HWICAP)+= xilinx_hwicap/
 obj-$(CONFIG_NVRAM)+= nvram.o
@@ -45,9 +44,6 @@ obj-$(CONFIG_TCG_TPM) += tpm/
 
 obj-$(CONFIG_PS3_FLASH)+= ps3flash.o
 
-obj-$(CONFIG_JS_RTC)   += js-rtc.o
-js-rtc-y = rtc.o
-
 obj-$(CONFIG_XILLYBUS) += xillybus/
 obj-$(CONFIG_POWERNV_OP_PANEL) 

Re: [PATCH 00/12] mm: remove __ARCH_HAS_4LEVEL_HACK

2019-10-23 Thread Linus Torvalds
On Wed, Oct 23, 2019 at 5:29 AM Mike Rapoport  wrote:
>
> These patches convert several architectures to use page table folding and
> remove __ARCH_HAS_4LEVEL_HACK along with include/asm-generic/4level-fixup.h.

Thanks for doing this.

The patches look sane from a quick scan, and it's definitely the right
thing to do. So ack on my part, but obviously testing the different
architectures would be a really good thing...

Linus


Re: [PATCH 08/12] parisc: use pgtable-nopXd instead of 4level-fixup

2019-10-23 Thread Rolf Eike Beer
diff --git a/arch/parisc/include/asm/page.h 
b/arch/parisc/include/asm/page.h

index 93caf17..1d339ee 100644
--- a/arch/parisc/include/asm/page.h
+++ b/arch/parisc/include/asm/page.h
@@ -42,48 +42,54 @@ typedef struct { unsigned long pte; } pte_t; /*
either 32 or 64bit */

 /* NOTE: even on 64 bits, these entries are __u32 because we allocate
  * the pmd and pgd in ZONE_DMA (i.e. under 4GB) */
-typedef struct { __u32 pmd; } pmd_t;
 typedef struct { __u32 pgd; } pgd_t;
 typedef struct { unsigned long pgprot; } pgprot_t;

-#define pte_val(x) ((x).pte)
-/* These do not work lvalues, so make sure we don't use them as such. 
*/

+#if CONFIG_PGTABLE_LEVELS == 3
+typedef struct { __u32 pmd; } pmd_t;
+#define __pmd(x)   ((pmd_t) { (x) } )
+/* pXd_val() do not work lvalues, so make sure we don't use them as 
such. */


For me it sounds like there is something missing, maybe an "as" before 
lvalues?

And it was "These", so plural, and now it is singular, so do -> does?

Eike


Re: [PATCH 02/12] arm: nommu: use pgtable-nopud instead of 4level-fixup

2019-10-23 Thread Russell King - ARM Linux admin
On Wed, Oct 23, 2019 at 12:28:51PM +0300, Mike Rapoport wrote:
> From: Mike Rapoport 
> 
> The generic nommu implementation of page table manipulation takes care of
> folding of the upper levels and does not require fixups.
> 
> Simply replace of include/asm-generic/4level-fixup.h with
> include/asm-generic/pgtable-nopud.h.
> 
> Signed-off-by: Mike Rapoport 

Acked-by: Russell King 

Thanks.

> ---
>  arch/arm/include/asm/pgtable.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
> index 3ae120c..eabcb48 100644
> --- a/arch/arm/include/asm/pgtable.h
> +++ b/arch/arm/include/asm/pgtable.h
> @@ -12,7 +12,7 @@
>  
>  #ifndef CONFIG_MMU
>  
> -#include 
> +#include 
>  #include 
>  
>  #else
> -- 
> 2.7.4
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up


[PATCH 08/12] parisc: use pgtable-nopXd instead of 4level-fixup

2019-10-23 Thread Mike Rapoport
From: Mike Rapoport 

parisc has two or three levels of page tables and can use appropriate
pgtable-nopXd and folding of the upper layers.

Replace usage of include/asm-generic/4level-fixup.h and explicit
definitions of __PAGETABLE_PxD_FOLDED in parisc with
include/asm-generic/pgtable-nopmd.h for two-level configurations and with
include/asm-generic/pgtable-nopmd.h for three-lelve configurations and
adjust page table manipulation macros and functions accordingly.

Signed-off-by: Mike Rapoport 
---
 arch/parisc/include/asm/page.h| 30 +-
 arch/parisc/include/asm/pgalloc.h | 41 +++---
 arch/parisc/include/asm/pgtable.h | 52 +++
 arch/parisc/include/asm/tlb.h |  2 ++
 arch/parisc/kernel/cache.c| 13 ++
 arch/parisc/kernel/pci-dma.c  |  9 +--
 arch/parisc/mm/fixmap.c   | 10 +---
 7 files changed, 81 insertions(+), 76 deletions(-)

diff --git a/arch/parisc/include/asm/page.h b/arch/parisc/include/asm/page.h
index 93caf17..1d339ee 100644
--- a/arch/parisc/include/asm/page.h
+++ b/arch/parisc/include/asm/page.h
@@ -42,48 +42,54 @@ typedef struct { unsigned long pte; } pte_t; /* either 32 
or 64bit */
 
 /* NOTE: even on 64 bits, these entries are __u32 because we allocate
  * the pmd and pgd in ZONE_DMA (i.e. under 4GB) */
-typedef struct { __u32 pmd; } pmd_t;
 typedef struct { __u32 pgd; } pgd_t;
 typedef struct { unsigned long pgprot; } pgprot_t;
 
-#define pte_val(x) ((x).pte)
-/* These do not work lvalues, so make sure we don't use them as such. */
+#if CONFIG_PGTABLE_LEVELS == 3
+typedef struct { __u32 pmd; } pmd_t;
+#define __pmd(x)   ((pmd_t) { (x) } )
+/* pXd_val() do not work lvalues, so make sure we don't use them as such. */
 #define pmd_val(x) ((x).pmd + 0)
+#endif
+
+#define pte_val(x) ((x).pte)
 #define pgd_val(x) ((x).pgd + 0)
 #define pgprot_val(x)  ((x).pgprot)
 
 #define __pte(x)   ((pte_t) { (x) } )
-#define __pmd(x)   ((pmd_t) { (x) } )
 #define __pgd(x)   ((pgd_t) { (x) } )
 #define __pgprot(x)((pgprot_t) { (x) } )
 
-#define __pmd_val_set(x,n) (x).pmd = (n)
-#define __pgd_val_set(x,n) (x).pgd = (n)
-
 #else
 /*
  * .. while these make it easier on the compiler
  */
 typedef unsigned long pte_t;
+
+#if CONFIG_PGTABLE_LEVELS == 3
 typedef __u32 pmd_t;
+#define pmd_val(x)  (x)
+#define __pmd(x)   (x)
+#endif
+
 typedef __u32 pgd_t;
 typedef unsigned long pgprot_t;
 
 #define pte_val(x)  (x)
-#define pmd_val(x)  (x)
 #define pgd_val(x)  (x)
 #define pgprot_val(x)   (x)
 
 #define __pte(x)(x)
-#define __pmd(x)   (x)
 #define __pgd(x)(x)
 #define __pgprot(x) (x)
 
-#define __pmd_val_set(x,n) (x) = (n)
-#define __pgd_val_set(x,n) (x) = (n)
-
 #endif /* STRICT_MM_TYPECHECKS */
 
+#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
+#if CONFIG_PGTABLE_LEVELS == 3
+#define set_pud(pudptr, pudval) (*(pudptr) = (pudval))
+#endif
+
 typedef struct page *pgtable_t;
 
 typedef struct __physmem_range {
diff --git a/arch/parisc/include/asm/pgalloc.h 
b/arch/parisc/include/asm/pgalloc.h
index d98647c..9ac74da 100644
--- a/arch/parisc/include/asm/pgalloc.h
+++ b/arch/parisc/include/asm/pgalloc.h
@@ -34,13 +34,13 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
/* Populate first pmd with allocated memory.  We mark it
 * with PxD_FLAG_ATTACHED as a signal to the system that this
 * pmd entry may not be cleared. */
-   __pgd_val_set(*actual_pgd, (PxD_FLAG_PRESENT | 
-   PxD_FLAG_VALID | 
-   PxD_FLAG_ATTACHED) 
-   + (__u32)(__pa((unsigned long)pgd) >> PxD_VALUE_SHIFT));
+   set_pgd(actual_pgd, __pgd((PxD_FLAG_PRESENT |
+   PxD_FLAG_VALID |
+   PxD_FLAG_ATTACHED)
+   + (__u32)(__pa((unsigned long)pgd) >> 
PxD_VALUE_SHIFT)));
/* The first pmd entry also is marked with PxD_FLAG_ATTACHED as
 * a signal that this pmd may not be freed */
-   __pgd_val_set(*pgd, PxD_FLAG_ATTACHED);
+   set_pgd(pgd, __pgd(PxD_FLAG_ATTACHED));
 #endif
}
spin_lock_init(pgd_spinlock(actual_pgd));
@@ -59,10 +59,10 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t 
*pgd)
 
 /* Three Level Page Table Support for pmd's */
 
-static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
+static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
 {
-   __pgd_val_set(*pgd, (PxD_FLAG_PRESENT | PxD_FLAG_VALID) +
-   (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
+   set_pud(pud, __pud((PxD_FLAG_PRESENT | PxD_FLAG_VALID) +
+   (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT)));
 }
 
 static inline 

[PATCH 09/12] sparc32: use pgtable-nopud instead of 4level-fixup

2019-10-23 Thread Mike Rapoport
From: Mike Rapoport 

32-bit version of sparc has three-level page tables and can use
pgtable-nopud and folding of the upper layers.

Replace usage of include/asm-generic/4level-fixup.h with
include/asm-generic/pgtable-nopud.h and adjust page table manipulation
macros and functions accordingly.

Signed-off-by: Mike Rapoport 
---
 arch/sparc/include/asm/pgalloc_32.h |  6 ++---
 arch/sparc/include/asm/pgtable_32.h | 28 ++--
 arch/sparc/mm/fault_32.c| 11 ++--
 arch/sparc/mm/highmem.c |  6 -
 arch/sparc/mm/io-unit.c |  6 -
 arch/sparc/mm/iommu.c   |  6 -
 arch/sparc/mm/srmmu.c   | 51 +
 7 files changed, 81 insertions(+), 33 deletions(-)

diff --git a/arch/sparc/include/asm/pgalloc_32.h 
b/arch/sparc/include/asm/pgalloc_32.h
index 10538a4..eae0c92 100644
--- a/arch/sparc/include/asm/pgalloc_32.h
+++ b/arch/sparc/include/asm/pgalloc_32.h
@@ -26,14 +26,14 @@ static inline void free_pgd_fast(pgd_t *pgd)
 #define pgd_free(mm, pgd)  free_pgd_fast(pgd)
 #define pgd_alloc(mm)  get_pgd_fast()
 
-static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
+static inline void pud_set(pud_t * pudp, pmd_t * pmdp)
 {
unsigned long pa = __nocache_pa(pmdp);
 
-   set_pte((pte_t *)pgdp, __pte((SRMMU_ET_PTD | (pa >> 4;
+   set_pte((pte_t *)pudp, __pte((SRMMU_ET_PTD | (pa >> 4;
 }
 
-#define pgd_populate(MM, PGD, PMD)  pgd_set(PGD, PMD)
+#define pud_populate(MM, PGD, PMD)  pud_set(PGD, PMD)
 
 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
   unsigned long address)
diff --git a/arch/sparc/include/asm/pgtable_32.h 
b/arch/sparc/include/asm/pgtable_32.h
index 31da448..6d6f44c 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -12,7 +12,7 @@
 #include 
 
 #ifndef __ASSEMBLY__
-#include 
+#include 
 
 #include 
 #include 
@@ -132,12 +132,12 @@ static inline struct page *pmd_page(pmd_t pmd)
return pfn_to_page((pmd_val(pmd) & SRMMU_PTD_PMASK) >> (PAGE_SHIFT-4));
 }
 
-static inline unsigned long pgd_page_vaddr(pgd_t pgd)
+static inline unsigned long pud_page_vaddr(pud_t pud)
 {
-   if (srmmu_device_memory(pgd_val(pgd))) {
+   if (srmmu_device_memory(pud_val(pud))) {
return ~0;
} else {
-   unsigned long v = pgd_val(pgd) & SRMMU_PTD_PMASK;
+   unsigned long v = pud_val(pud) & SRMMU_PTD_PMASK;
return (unsigned long)__nocache_va(v << 4);
}
 }
@@ -184,24 +184,24 @@ static inline void pmd_clear(pmd_t *pmdp)
set_pte((pte_t *)>pmdv[i], __pte(0));
 }
 
-static inline int pgd_none(pgd_t pgd)  
+static inline int pud_none(pud_t pud)
 {
-   return !(pgd_val(pgd) & 0xFFF);
+   return !(pud_val(pud) & 0xFFF);
 }
 
-static inline int pgd_bad(pgd_t pgd)
+static inline int pud_bad(pud_t pud)
 {
-   return (pgd_val(pgd) & SRMMU_ET_MASK) != SRMMU_ET_PTD;
+   return (pud_val(pud) & SRMMU_ET_MASK) != SRMMU_ET_PTD;
 }
 
-static inline int pgd_present(pgd_t pgd)
+static inline int pud_present(pud_t pud)
 {
-   return ((pgd_val(pgd) & SRMMU_ET_MASK) == SRMMU_ET_PTD);
+   return ((pud_val(pud) & SRMMU_ET_MASK) == SRMMU_ET_PTD);
 }
 
-static inline void pgd_clear(pgd_t *pgdp)
+static inline void pud_clear(pud_t *pudp)
 {
-   set_pte((pte_t *)pgdp, __pte(0));
+   set_pte((pte_t *)pudp, __pte(0));
 }
 
 /*
@@ -319,9 +319,9 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 #define pgd_offset_k(address) pgd_offset(_mm, address)
 
 /* Find an entry in the second-level page table.. */
-static inline pmd_t *pmd_offset(pgd_t * dir, unsigned long address)
+static inline pmd_t *pmd_offset(pud_t * dir, unsigned long address)
 {
-   return (pmd_t *) pgd_page_vaddr(*dir) +
+   return (pmd_t *) pud_page_vaddr(*dir) +
((address >> PMD_SHIFT) & (PTRS_PER_PMD - 1));
 }
 
diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
index 8d69de1..89976c9 100644
--- a/arch/sparc/mm/fault_32.c
+++ b/arch/sparc/mm/fault_32.c
@@ -351,6 +351,8 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int 
text_fault, int write,
 */
int offset = pgd_index(address);
pgd_t *pgd, *pgd_k;
+   p4d_t *p4d, *p4d_k;
+   pud_t *pud, *pud_k;
pmd_t *pmd, *pmd_k;
 
pgd = tsk->active_mm->pgd + offset;
@@ -363,8 +365,13 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int 
text_fault, int write,
return;
}
 
-   pmd = pmd_offset(pgd, address);
-   pmd_k = pmd_offset(pgd_k, address);
+   p4d = p4d_offset(pgd, address);
+   pud = pud_offset(p4d, address);
+   pmd = pmd_offset(pud, address);
+
+   p4d_k = p4d_offset(pgd_k, address);
+   

[PATCH 03/12] c6x: use pgtable-nopud instead of 4level-fixup

2019-10-23 Thread Mike Rapoport
From: Mike Rapoport 

c6x is a nommu architecture and does not require fixup for upper layers of
the page tables because it is already handled by the generic nommu
implementation.

Replace usage of include/asm-generic/4level-fixup.h with
include/asm-generic/pgtable-nopud.h

Signed-off-by: Mike Rapoport 
---
 arch/c6x/include/asm/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/c6x/include/asm/pgtable.h b/arch/c6x/include/asm/pgtable.h
index 0b6919c..197c473 100644
--- a/arch/c6x/include/asm/pgtable.h
+++ b/arch/c6x/include/asm/pgtable.h
@@ -8,7 +8,7 @@
 #ifndef _ASM_C6X_PGTABLE_H
 #define _ASM_C6X_PGTABLE_H
 
-#include 
+#include 
 
 #include 
 #include 
-- 
2.7.4