LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc/82xx: Delete an unnecessary of_node_put() call in pq2ads_pci_init_irq()
From: Markus Elfring @ 2019-08-27  8:26 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Herrenschmidt, Greg Kroah-Hartman,
	Enrico Weigelt, Kate Stewart, Michael Ellerman, Paul Mackerras,
	Thomas Gleixner
  Cc: kernel-janitors, LKML
In-Reply-To: <6dc7d70e-8a40-46ab-897b-d2eaf9a87d77@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Aug 2019 08:44:20 +0200

A null pointer would be passed to a call of the function “of_node_put”
immediately after a call of the function “of_find_compatible_node” failed
at one place.
Remove this superfluous function call.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/82xx/pq2ads-pci-pic.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
index 096cc0d59fd8..6cc054db7043 100644
--- a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
+++ b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
@@ -123,7 +123,6 @@ int __init pq2ads_pci_init_irq(void)
 	np = of_find_compatible_node(NULL, NULL, "fsl,pq2ads-pci-pic");
 	if (!np) {
 		printk(KERN_ERR "No pci pic node in device tree.\n");
-		of_node_put(np);
 		goto out;
 	}

--
2.23.0


^ permalink raw reply related

* [PATCH 0/2] powerpc/82xx: Adjustments for pq2ads_pci_init_irq()
From: Markus Elfring @ 2019-08-27  8:23 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Herrenschmidt, Greg Kroah-Hartman,
	Enrico Weigelt, Kate Stewart, Michael Ellerman, Paul Mackerras,
	Thomas Gleixner
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Aug 2019 10:16:32 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Delete an unnecessary of_node_put() call
  Use common error handling code

 arch/powerpc/platforms/82xx/pq2ads-pci-pic.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

--
2.23.0


^ permalink raw reply

* [PATCH 2/2] powerpc/82xx: Use common error handling code in pq2ads_pci_init_irq()
From: Markus Elfring @ 2019-08-27  8:28 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Herrenschmidt, Greg Kroah-Hartman,
	Enrico Weigelt, Kate Stewart, Michael Ellerman, Paul Mackerras,
	Thomas Gleixner
  Cc: kernel-janitors, LKML
In-Reply-To: <6dc7d70e-8a40-46ab-897b-d2eaf9a87d77@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Aug 2019 09:19:32 +0200

Adjust jump targets so that a bit of exception handling can be better
reused at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/82xx/pq2ads-pci-pic.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
index 6cc054db7043..f82f75a6085c 100644
--- a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
+++ b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
@@ -129,13 +129,11 @@ int __init pq2ads_pci_init_irq(void)
 	irq = irq_of_parse_and_map(np, 0);
 	if (!irq) {
 		printk(KERN_ERR "No interrupt in pci pic node.\n");
-		of_node_put(np);
-		goto out;
+		goto out_put_node;
 	}

 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv) {
-		of_node_put(np);
 		ret = -ENOMEM;
 		goto out_unmap_irq;
 	}
@@ -160,17 +158,17 @@ int __init pq2ads_pci_init_irq(void)
 	priv->host = host;
 	irq_set_handler_data(irq, priv);
 	irq_set_chained_handler(irq, pq2ads_pci_irq_demux);
-
-	of_node_put(np);
-	return 0;
+	ret = 0;
+	goto out_put_node;

 out_unmap_regs:
 	iounmap(priv->regs);
 out_free_kmalloc:
 	kfree(priv);
-	of_node_put(np);
 out_unmap_irq:
 	irq_dispose_mapping(irq);
+out_put_node:
+	of_node_put(np);
 out:
 	return ret;
 }
--
2.23.0


^ permalink raw reply related

* Re: [RFC 0/3] New idle device-tree format and support for versioned stop state
From: Nicholas Piggin @ 2019-08-27  9:31 UTC (permalink / raw)
  To: devicetree, Abhishek Goel, linux-kernel, linuxppc-dev, paulus
  Cc: ego, mikey, daniel.lezcano, rjw
In-Reply-To: <20190823070940.43220-1-huntbag@linux.vnet.ibm.com>

Abhishek Goel's on August 23, 2019 5:09 pm:
> Background
> ------------------
> 
> Previously if a older kernel runs on a newer firmware, it may enable
> all available states irrespective of its capability of handling it.
> Consider a case that some stop state has a bug, we end up disabling all
> the stop states. This patch introduces selective control to solve this
> problem.
> 
> Previous version of these patches can be found at:
> https://lkml.org/lkml/2018/10/11/544
> These patch however also had patches for support of opal save-restore
> which now I am decoupling and will take them seperately.
> I have posted the corresponding skiboot patches for this kernel patchset
> here : https://patchwork.ozlabs.org/cover/1144587/
> 
> What's new?
> --------------------
> 
> Add stop states under ibm,idle-states in addition to the current array
> based device tree properties.
> 
> New device tree format adds a compatible flag which has version
> corresponding to every state, so that only kernel which has the capability
> to handle the version of stop state will enable it. Drawback of the array
> based dt node is that versioning of idle states is not possible.
> 
> Older kernel will still see stop0 and stop0_lite in older format and we
> will deprecate it after some time.
> 
> Consider a case that stop4 has a bug. We take the following steps to
> mitigate the problem.
> 
> 1) Change compatible string for stop4 in OPAL to "stop4,v2" from
> "stop4,v1", i.e. basicallly bump up the previous version and ship the
> new firmware.
> 
> 2) The kernel will ignore stop4 as it won't be able to recognize this
> new version. Kernel will also ignore all the deeper states because its
> possible that a cpu have requested for a deeper state but was never able
> to enter into it. But we will still have shallower states that are there
> before stop 4. This, thus prevents from completely disabling stop states.
> 
> Linux kernel can now look at the version string and decide if it has the
> ability to handle that idle state. Henceforth, if kernel does not know
> about a version, it will skip that state and all the deeper state.
> 
> Once when the workaround are implemented into the kernel, we can bump up
> the known version in kernel for that state, so that support can be
> enabled once again in kernel.
> 
> New Device-tree :
> 
> Final output
>        power-mgt {
>             ...
>          ibm,enabled-stop-levels = <0xec000000>;
>          ibm,cpu-idle-state-psscr-mask = <0x0 0x3003ff 0x0 0x3003ff>;
>          ibm,cpu-idle-state-latencies-ns = <0x3e8 0x7d0>;
>          ibm,cpu-idle-state-psscr = <0x0 0x330 0x0 0x300330>;
>          ibm,cpu-idle-state-flags = <0x100000 0x101000>;
>          ibm,cpu-idle-state-residency-ns = <0x2710 0x4e20>;
>          ibm,idle-states {
>                      stop4 {
>                          flags = <0x207000>;
>                          compatible = "stop4,v1",
>                          psscr-mask = <0x0 0x3003ff>;
>                          latency-ns = <0x186a0>;
>                          residency-ns = <0x989680>;
>                          psscr = <0x0 0x300374>;
> 			 ...
>                   };
>                     ...
>                     stop11 {
>                          ...
>                          compatible = "stop11,v1",
>                          ...
>                   };
>              };

I'm not sure about this. I think the real problem we have is that the
OPAL stop API is not actually implementation independent. Because we
*can* selectively disable stop states in the firmware if there is a
hardware/firmware problem with them.

So we need a way to rev ISA/Book4/OPAL stuff so the kernel won't try
to use it if it's incapable.

We have that today in dt-cpu-ftrs. POWER9 advertises the "idle-stop"
feature. An incompatible implementation could advertise idle-stop-v4.

That won't allow individual states to remain back compatible, but if 
there is a new implementation which changes any behaviour it needs to be 
incopmatible, even if Linux happens to not rely on said behaviour yet.  
So I don't think we can keep any of them (except stop0 lite) compatible, 
so I don't see a real downside (we'll have to discuss this offline).

Thanks,
Nick

^ permalink raw reply

* Re: [PATCH 3/6] dma-mapping: remove arch_dma_mmap_pgprot
From: Paul Burton @ 2019-08-27 10:02 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Shawn Anastasio, linux-m68k@lists.linux-m68k.org, Will Deacon,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	Russell King, linux-mips@vger.kernel.org,
	iommu@lists.linux-foundation.org, Geert Uytterhoeven,
	Catalin Marinas, James Hogan, Guan Xuetao,
	linux-arm-kernel@lists.infradead.org, Robin Murphy
In-Reply-To: <20190826132553.4116-4-hch@lst.de>

Hi Christoph,

On Mon, Aug 26, 2019 at 03:25:50PM +0200, Christoph Hellwig wrote:
> arch_dma_mmap_pgprot is used for two things:
> 
>  1) to override the "normal" uncached page attributes for mapping
>     memory coherent to devices that can't snoop the CPU caches
>  2) to provide the special DMA_ATTR_WRITE_COMBINE semantics on older
>     arm systems and some mips platforms
> 
> Replace one with the pgprot_dmacoherent macro that is already provided
> by arm and much simpler to use, and lift the DMA_ATTR_WRITE_COMBINE
> handling to common code with an explicit arch opt-in.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

For the MIPS bits:

    Acked-by: Paul Burton <paul.burton@mips.com>

Thanks,
    Paul

> ---
>  arch/arm/Kconfig                   |  2 +-
>  arch/arm/mm/dma-mapping.c          |  6 ------
>  arch/arm64/Kconfig                 |  1 -
>  arch/arm64/include/asm/pgtable.h   |  4 ++++
>  arch/arm64/mm/dma-mapping.c        |  6 ------
>  arch/m68k/Kconfig                  |  1 -
>  arch/m68k/include/asm/pgtable_mm.h |  3 +++
>  arch/m68k/kernel/dma.c             |  3 +--
>  arch/mips/Kconfig                  |  2 +-
>  arch/mips/mm/dma-noncoherent.c     |  8 --------
>  include/linux/dma-noncoherent.h    | 13 +++++++++++--
>  kernel/dma/Kconfig                 | 12 +++++++++---
>  kernel/dma/mapping.c               |  8 +++++---
>  13 files changed, 35 insertions(+), 34 deletions(-)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 24360211534a..217083caeabd 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -8,7 +8,7 @@ config ARM
>  	select ARCH_HAS_DEBUG_VIRTUAL if MMU
>  	select ARCH_HAS_DEVMEM_IS_ALLOWED
>  	select ARCH_HAS_DMA_COHERENT_TO_PFN if SWIOTLB
> -	select ARCH_HAS_DMA_MMAP_PGPROT if SWIOTLB
> +	select ARCH_HAS_DMA_WRITE_COMBINE if !ARM_DMA_MEM_BUFFERABLE
>  	select ARCH_HAS_ELF_RANDOMIZE
>  	select ARCH_HAS_FORTIFY_SOURCE
>  	select ARCH_HAS_KEEPINITRD
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index d42557ee69c2..d27b12f61737 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -2402,12 +2402,6 @@ long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr,
>  	return dma_to_pfn(dev, dma_addr);
>  }
>  
> -pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot,
> -		unsigned long attrs)
> -{
> -	return __get_dma_pgprot(attrs, prot);
> -}
> -
>  void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
>  		gfp_t gfp, unsigned long attrs)
>  {
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 3adcec05b1f6..dab9dda34206 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -13,7 +13,6 @@ config ARM64
>  	select ARCH_HAS_DEBUG_VIRTUAL
>  	select ARCH_HAS_DEVMEM_IS_ALLOWED
>  	select ARCH_HAS_DMA_COHERENT_TO_PFN
> -	select ARCH_HAS_DMA_MMAP_PGPROT
>  	select ARCH_HAS_DMA_PREP_COHERENT
>  	select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
>  	select ARCH_HAS_ELF_RANDOMIZE
> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index e09760ece844..6700371227d1 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -435,6 +435,10 @@ static inline pmd_t pmd_mkdevmap(pmd_t pmd)
>  	__pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN)
>  #define pgprot_device(prot) \
>  	__pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_PXN | PTE_UXN)
> +#define pgprot_dmacoherent(prot) \
> +	__pgprot_modify(prot, PTE_ATTRINDX_MASK, \
> +			PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN)
> +
>  #define __HAVE_PHYS_MEM_ACCESS_PROT
>  struct file;
>  extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
> index bd2b039f43a6..676efcda51e6 100644
> --- a/arch/arm64/mm/dma-mapping.c
> +++ b/arch/arm64/mm/dma-mapping.c
> @@ -11,12 +11,6 @@
>  
>  #include <asm/cacheflush.h>
>  
> -pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot,
> -		unsigned long attrs)
> -{
> -	return pgprot_writecombine(prot);
> -}
> -
>  void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr,
>  		size_t size, enum dma_data_direction dir)
>  {
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index c518d695c376..a9e564306d3e 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -4,7 +4,6 @@ config M68K
>  	default y
>  	select ARCH_32BIT_OFF_T
>  	select ARCH_HAS_BINFMT_FLAT
> -	select ARCH_HAS_DMA_MMAP_PGPROT if MMU && !COLDFIRE
>  	select ARCH_HAS_DMA_PREP_COHERENT if HAS_DMA && MMU && !COLDFIRE
>  	select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA
>  	select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
> diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h
> index fe3ddd73a0cc..fde4534b974f 100644
> --- a/arch/m68k/include/asm/pgtable_mm.h
> +++ b/arch/m68k/include/asm/pgtable_mm.h
> @@ -169,6 +169,9 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
>  	    ? (__pgprot((pgprot_val(prot) & _CACHEMASK040) | _PAGE_NOCACHE_S))	\
>  	    : (prot)))
>  
> +pgprot_t pgprot_dmacoherent(pgprot_t prot);
> +#define pgprot_dmacoherent(prot)	pgprot_dmacoherent(prot)
> +
>  #endif /* CONFIG_COLDFIRE */
>  #include <asm-generic/pgtable.h>
>  #endif /* !__ASSEMBLY__ */
> diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c
> index 30cd59caf037..35064150e348 100644
> --- a/arch/m68k/kernel/dma.c
> +++ b/arch/m68k/kernel/dma.c
> @@ -23,8 +23,7 @@ void arch_dma_prep_coherent(struct page *page, size_t size)
>  	cache_push(page_to_phys(page), size);
>  }
>  
> -pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot,
> -		unsigned long attrs)
> +pgprot_t pgprot_dmacoherent(pgprot_t prot)
>  {
>  	if (CPU_IS_040_OR_060) {
>  		pgprot_val(prot) &= ~_PAGE_CACHE040;
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index d50fafd7bf3a..fc88f68ea1ee 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -1119,7 +1119,7 @@ config DMA_PERDEV_COHERENT
>  
>  config DMA_NONCOHERENT
>  	bool
> -	select ARCH_HAS_DMA_MMAP_PGPROT
> +	select ARCH_HAS_DMA_WRITE_COMBINE
>  	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
>  	select ARCH_HAS_UNCACHED_SEGMENT
>  	select NEED_DMA_MAP_STATE
> diff --git a/arch/mips/mm/dma-noncoherent.c b/arch/mips/mm/dma-noncoherent.c
> index ed56c6fa7be2..1d4d57dd9acf 100644
> --- a/arch/mips/mm/dma-noncoherent.c
> +++ b/arch/mips/mm/dma-noncoherent.c
> @@ -65,14 +65,6 @@ long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr,
>  	return page_to_pfn(virt_to_page(cached_kernel_address(cpu_addr)));
>  }
>  
> -pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot,
> -		unsigned long attrs)
> -{
> -	if (attrs & DMA_ATTR_WRITE_COMBINE)
> -		return pgprot_writecombine(prot);
> -	return pgprot_noncached(prot);
> -}
> -
>  static inline void dma_sync_virt(void *addr, size_t size,
>  		enum dma_data_direction dir)
>  {
> diff --git a/include/linux/dma-noncoherent.h b/include/linux/dma-noncoherent.h
> index 0bff3d7fac92..dd3de6d88fc0 100644
> --- a/include/linux/dma-noncoherent.h
> +++ b/include/linux/dma-noncoherent.h
> @@ -3,6 +3,7 @@
>  #define _LINUX_DMA_NONCOHERENT_H 1
>  
>  #include <linux/dma-mapping.h>
> +#include <asm/pgtable.h>
>  
>  #ifdef CONFIG_ARCH_HAS_DMA_COHERENCE_H
>  #include <asm/dma-coherence.h>
> @@ -42,10 +43,18 @@ void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
>  		dma_addr_t dma_addr, unsigned long attrs);
>  long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr,
>  		dma_addr_t dma_addr);
> -pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot,
> -		unsigned long attrs);
>  
>  #ifdef CONFIG_MMU
> +/*
> + * Page protection so that devices that can't snoop CPU caches can use the
> + * memory coherently.  We default to pgprot_noncached which is usually used
> + * for ioremap as a safe bet, but architectures can override this with less
> + * strict semantics if possible.
> + */
> +#ifndef pgprot_dmacoherent
> +#define pgprot_dmacoherent(prot)	pgprot_noncached(prot)
> +#endif
> +
>  pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs);
>  #else
>  static inline pgprot_t dma_pgprot(struct device *dev, pgprot_t prot,
> diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
> index 9decbba255fc..73c5c2b8e824 100644
> --- a/kernel/dma/Kconfig
> +++ b/kernel/dma/Kconfig
> @@ -20,6 +20,15 @@ config ARCH_HAS_DMA_COHERENCE_H
>  config ARCH_HAS_DMA_SET_MASK
>  	bool
>  
> +#
> +# Select this option if the architecture needs special handling for
> +# DMA_ATTR_WRITE_COMBINE.  Normally the "uncached" mapping should be what
> +# people thing of when saying write combine, so very few platforms should
> +# need to enable this.
> +#
> +config ARCH_HAS_DMA_WRITE_COMBINE
> +	bool
> +
>  config DMA_DECLARE_COHERENT
>  	bool
>  
> @@ -45,9 +54,6 @@ config ARCH_HAS_DMA_PREP_COHERENT
>  config ARCH_HAS_DMA_COHERENT_TO_PFN
>  	bool
>  
> -config ARCH_HAS_DMA_MMAP_PGPROT
> -	bool
> -
>  config ARCH_HAS_FORCE_DMA_UNENCRYPTED
>  	bool
>  
> diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
> index b0038ca3aa92..1b96616c9f20 100644
> --- a/kernel/dma/mapping.c
> +++ b/kernel/dma/mapping.c
> @@ -161,9 +161,11 @@ pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs)
>  	    (IS_ENABLED(CONFIG_DMA_NONCOHERENT_CACHE_SYNC) &&
>               (attrs & DMA_ATTR_NON_CONSISTENT)))
>  		return prot;
> -	if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_MMAP_PGPROT))
> -		return arch_dma_mmap_pgprot(dev, prot, attrs);
> -	return pgprot_noncached(prot);
> +#ifdef CONFIG_ARCH_HAS_DMA_WRITE_COMBINE
> +	if (attrs & DMA_ATTR_WRITE_COMBINE)
> +		return pgprot_writecombine(prot);
> +#endif
> +	return pgprot_dmacoherent(prot);
>  }
>  #endif /* CONFIG_MMU */
>  
> -- 
> 2.20.1
> 

^ permalink raw reply

* Re: [PATCH 6/6] MIPS: document mixing "slightly different CCAs"
From: Paul Burton @ 2019-08-27 10:03 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Shawn Anastasio, linux-m68k@lists.linux-m68k.org, Will Deacon,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	Russell King, linux-mips@vger.kernel.org,
	iommu@lists.linux-foundation.org, Geert Uytterhoeven,
	Catalin Marinas, James Hogan, Guan Xuetao,
	linux-arm-kernel@lists.infradead.org, Robin Murphy
In-Reply-To: <20190826132553.4116-7-hch@lst.de>

Hi Christoph,

On Mon, Aug 26, 2019 at 03:25:53PM +0200, Christoph Hellwig wrote:
> Based on an email from Paul Burton, quoting section 4.8 "Cacheability and
> Coherency Attributes and Access Types" of "MIPS Architecture Volume 1:
> Introduction to the MIPS32 Architecture" (MD00080, revision 6.01).
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Paul Burton <paul.burton@mips.com>

Thanks,
    Paul

> ---
>  arch/mips/Kconfig | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index fc88f68ea1ee..aff1cadeea43 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -1119,6 +1119,13 @@ config DMA_PERDEV_COHERENT
>  
>  config DMA_NONCOHERENT
>  	bool
> +	#
> +	# MIPS allows mixing "slightly different" Cacheability and Coherency
> +	# Attribute bits.  It is believed that the uncached access through
> +	# KSEG1 and the implementation specific "uncached accelerated" used
> +	# by pgprot_writcombine can be mixed, and the latter sometimes provides
> +	# significant advantages.
> +	#
>  	select ARCH_HAS_DMA_WRITE_COMBINE
>  	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
>  	select ARCH_HAS_UNCACHED_SEGMENT
> -- 
> 2.20.1
> 

^ permalink raw reply

* Re: [PATCH] powerpc: dump kernel log before carrying out fadump or kdump
From: Nicholas Piggin @ 2019-08-27 10:12 UTC (permalink / raw)
  To: Ganesh Goudar, linuxppc-dev, mpe; +Cc: mahesh
In-Reply-To: <20190822063156.4000-1-ganeshgr@linux.ibm.com>

Ganesh Goudar's on August 22, 2019 4:31 pm:
> Die or panic path in system reset handler dumps kernel log to
> nvram, since commit 4388c9b3a6ee ("powerpc: Do not send system
> reset request through the oops path") system reset request is
> not allowed to take die path if fadump or kdump is configured,
> hence we miss dumping kernel log to nvram, call kmsg_dump()
> before carrying out fadump or kdump.
> 
> Fixes: 4388c9b3a6ee ("powerpc: Do not send system reset request through the oops path")
> Reviewed-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
> Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>


^ permalink raw reply

* Re: [PATCH 1/4] powerpc: convert to copy_thread_tls
From: Nicholas Piggin @ 2019-08-27 10:13 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev
In-Reply-To: <70171357-45e3-3fde-9713-d93b95cc1beb@c-s.fr>

Christophe Leroy's on August 27, 2019 4:07 pm:
> 
> 
> Le 27/08/2019 à 05:30, Nicholas Piggin a écrit :
>> Commit 3033f14ab78c3 ("clone: support passing tls argument via C rather
>> than pt_regs magic") introduced the HAVE_COPY_THREAD_TLS option. Use it
>> to avoid a subtle assumption about the argument ordering of clone type
>> syscalls.
>> 
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>>   arch/powerpc/Kconfig          | 1 +
>>   arch/powerpc/kernel/process.c | 9 +++++----
>>   2 files changed, 6 insertions(+), 4 deletions(-)
>> 
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index d8dcd8820369..7477a3263225 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -182,6 +182,7 @@ config PPC
>>   	select HAVE_STACKPROTECTOR		if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13)
>>   	select HAVE_STACKPROTECTOR		if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2)
>>   	select HAVE_CONTEXT_TRACKING		if PPC64
>> +	select HAVE_COPY_THREAD_TLS
>>   	select HAVE_DEBUG_KMEMLEAK
>>   	select HAVE_DEBUG_STACKOVERFLOW
>>   	select HAVE_DYNAMIC_FTRACE
>> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
>> index 8fc4de0d22b4..24621e7e5033 100644
>> --- a/arch/powerpc/kernel/process.c
>> +++ b/arch/powerpc/kernel/process.c
>> @@ -1600,8 +1600,9 @@ static void setup_ksp_vsid(struct task_struct *p, unsigned long sp)
>>   /*
>>    * Copy architecture-specific thread state
>>    */
>> -int copy_thread(unsigned long clone_flags, unsigned long usp,
>> -		unsigned long kthread_arg, struct task_struct *p)
>> +int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
>> +		unsigned long kthread_arg, struct task_struct *p,
>> +		unsigned long tls)
>>   {
>>   	struct pt_regs *childregs, *kregs;
>>   	extern void ret_from_fork(void);
>> @@ -1642,10 +1643,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
>>   		if (clone_flags & CLONE_SETTLS) {
>>   #ifdef CONFIG_PPC64
> 
> is_32bit_task() exists and always returns 1 on PPC32 so this gross ifdef 
> in the middle of an if/else is pointless, it should be dropped.

I could do that as another patch in the series.

Thanks,
Nick

^ permalink raw reply

* [PATCH v3] powerpc/imc: Dont create debugfs files for cpu-less nodes
From: Madhavan Srinivasan @ 2019-08-27 10:16 UTC (permalink / raw)
  To: mpe; +Cc: Qian Cai, Madhavan Srinivasan, linuxppc-dev

Commit <684d984038aa> ('powerpc/powernv: Add debugfs interface for imc-mode
and imc') added debugfs interface for the nest imc pmu devices to support
changing of different ucode modes. Primarily adding this capability for
debug. But when doing so, the code did not consider the case of cpu-less
nodes. So when reading the _cmd_ or _mode_ file of a cpu-less node
will create this crash.

[ 1139.415461][ T5301] Faulting instruction address: 0xc0000000000d0d58
[ 1139.415492][ T5301] Oops: Kernel access of bad area, sig: 11 [#1]
[ 1139.415509][ T5301] LE PAGE_SIZE=64K MMU=Radix MMU=Hash SMP NR_CPUS=256
DEBUG_PAGEALLOC NUMA PowerNV
[ 1139.415542][ T5301] Modules linked in: i2c_opal i2c_core ip_tables x_tables
xfs sd_mod bnx2x mdio ahci libahci tg3 libphy libata firmware_class dm_mirror
dm_region_hash dm_log dm_mod
[ 1139.415595][ T5301] CPU: 67 PID: 5301 Comm: cat Not tainted 5.2.0-rc6-next-
20190627+ #19
[ 1139.415634][ T5301] NIP:  c0000000000d0d58 LR: c00000000049aa18 CTR:c0000000000d0d50
[ 1139.415675][ T5301] REGS: c00020194548f9e0 TRAP: 0300   Not tainted  (5.2.0-rc6-next-20190627+)
[ 1139.415705][ T5301] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:28022822  XER: 00000000
[ 1139.415777][ T5301] CFAR: c00000000049aa14 DAR: 000000000003fc08 DSISR:40000000 IRQMASK: 0
[ 1139.415777][ T5301] GPR00: c00000000049aa18 c00020194548fc70 c0000000016f8b00000000000003fc08
[ 1139.415777][ T5301] GPR04: c00020194548fcd0 0000000000000000 0000000014884e73ffffffff00011eaa
[ 1139.415777][ T5301] GPR08: 000000007eea5a52 c0000000000d0d50 00000000000000000000000000000000
[ 1139.415777][ T5301] GPR12: c0000000000d0d50 c000201fff7f8c00 00000000000000000000000000000000
[ 1139.415777][ T5301] GPR16: 000000000000000d 00007fffeb0c3368 ffffffffffffffff0000000000000000
[ 1139.415777][ T5301] GPR20: 0000000000000000 0000000000000000 00000000000000000000000000020000
[ 1139.415777][ T5301] GPR24: 0000000000000000 0000000000000000 0000000000020000000000010ec90000
[ 1139.415777][ T5301] GPR28: c00020194548fdf0 c00020049a584ef8 0000000000000000c00020049a584ea8
[ 1139.416116][ T5301] NIP [c0000000000d0d58] imc_mem_get+0x8/0x20
[ 1139.416143][ T5301] LR [c00000000049aa18] simple_attr_read+0x118/0x170
[ 1139.416158][ T5301] Call Trace:
[ 1139.416182][ T5301] [c00020194548fc70] [c00000000049a970]simple_attr_read+0x70/0x170 (unreliable)
[ 1139.416255][ T5301] [c00020194548fd10] [c00000000054385c]debugfs_attr_read+0x6c/0xb0
[ 1139.416305][ T5301] [c00020194548fd60] [c000000000454c1c]__vfs_read+0x3c/0x70
[ 1139.416363][ T5301] [c00020194548fd80] [c000000000454d0c] vfs_read+0xbc/0x1a0
[ 1139.416392][ T5301] [c00020194548fdd0] [c00000000045519c]ksys_read+0x7c/0x140
[ 1139.416434][ T5301] [c00020194548fe20] [c00000000000b108]system_call+0x5c/0x70
[ 1139.416473][ T5301] Instruction dump:
[ 1139.416511][ T5301] 4e800020 60000000 7c0802a6 60000000 7c801d28 38600000 4e800020 60000000
[ 1139.416572][ T5301] 60000000 60000000 7c0802a6 60000000 <7d201c28> 38600000 f9240000 4e800020
[ 1139.416636][ T5301] ---[ end trace c44d1fb4ace04784 ]---
[ 1139.520686][ T5301]
[ 1140.520820][ T5301] Kernel panic - not syncing: Fatal exception

Patch fixes the issue with a more robust check for vbase to NULL.

Before patch, ls output for the debugfs imc directory

# ls /sys/kernel/debug/powerpc/imc/
imc_cmd_0    imc_cmd_251  imc_cmd_253  imc_cmd_255  imc_mode_0    imc_mode_251  imc_mode_253  imc_mode_255
imc_cmd_250  imc_cmd_252  imc_cmd_254  imc_cmd_8    imc_mode_250  imc_mode_252  imc_mode_254  imc_mode_8

After patch, ls output for the debugfs imc directory

# ls /sys/kernel/debug/powerpc/imc/
imc_cmd_0  imc_cmd_8  imc_mode_0  imc_mode_8

Actual bug here is that, we have two loops with potentially
different loop counts. That is, in imc_get_mem_addr_nest(), loop count
is obtained from the dt entries. But incase of export_imc_mode_and_cmd(),
loop was based on for_each_nid() count. Patch fixes the loop count in
latter based on the struct mem_info. Ideally it would be better
to have array size in struct imc_pmu. 

Fixes: 684d984038aa ('powerpc/powernv: Add debugfs interface for imc-mode and imc')
Reported-by: Qian Cai <cai@lca.pw>
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
Changelog v2:
- No logic changes.
- Just added more commit message.

Changelog v1:
- Modified the cpumask check.
 arch/powerpc/platforms/powernv/opal-imc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-imc.c b/arch/powerpc/platforms/powernv/opal-imc.c
index 186109bdd41b..e04b20625cb9 100644
--- a/arch/powerpc/platforms/powernv/opal-imc.c
+++ b/arch/powerpc/platforms/powernv/opal-imc.c
@@ -53,9 +53,9 @@ static void export_imc_mode_and_cmd(struct device_node *node,
 				    struct imc_pmu *pmu_ptr)
 {
 	static u64 loc, *imc_mode_addr, *imc_cmd_addr;
-	int chip = 0, nid;
 	char mode[16], cmd[16];
 	u32 cb_offset;
+	struct imc_mem_info *ptr = pmu_ptr->mem_info;
 
 	imc_debugfs_parent = debugfs_create_dir("imc", powerpc_debugfs_root);
 
@@ -69,20 +69,20 @@ static void export_imc_mode_and_cmd(struct device_node *node,
 	if (of_property_read_u32(node, "cb_offset", &cb_offset))
 		cb_offset = IMC_CNTL_BLK_OFFSET;
 
-	for_each_node(nid) {
-		loc = (u64)(pmu_ptr->mem_info[chip].vbase) + cb_offset;
+	while (ptr->vbase != NULL) {
+		loc = (u64)(ptr->vbase) + cb_offset;
 		imc_mode_addr = (u64 *)(loc + IMC_CNTL_BLK_MODE_OFFSET);
-		sprintf(mode, "imc_mode_%d", nid);
+		sprintf(mode, "imc_mode_%d", (u32)(ptr->id));
 		if (!imc_debugfs_create_x64(mode, 0600, imc_debugfs_parent,
 					    imc_mode_addr))
 			goto err;
 
 		imc_cmd_addr = (u64 *)(loc + IMC_CNTL_BLK_CMD_OFFSET);
-		sprintf(cmd, "imc_cmd_%d", nid);
+		sprintf(cmd, "imc_cmd_%d", (u32)(ptr->id));
 		if (!imc_debugfs_create_x64(cmd, 0600, imc_debugfs_parent,
 					    imc_cmd_addr))
 			goto err;
-		chip++;
+		ptr++;
 	}
 	return;
 
-- 
2.21.0


^ permalink raw reply related

* Re: [PATCH 2/4] powerpc/64: remove support for kernel-mode syscalls
From: Nicholas Piggin @ 2019-08-27 10:20 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev
In-Reply-To: <4bcfa6ed-07f7-f162-664f-134b40124dda@c-s.fr>

Christophe Leroy's on August 27, 2019 4:13 pm:
> 
> 
> Le 27/08/2019 à 05:30, Nicholas Piggin a écrit :
>> There is support for the kernel to execute the 'sc 0' instruction and
>> make a system call to itself. This is a relic that is unused in the
>> tree, therefore untested. It's also highly questionable for modules to
>> be doing this.
> 
> I like it.
> 
> I dropped support for that in PPC32 when I added fast-path syscalls.

Good, then we'll match again.

>> -	beq	2f			/* if from kernel mode */
>>   #ifdef CONFIG_PPC_FSL_BOOK3E
>>   START_BTB_FLUSH_SECTION
>>   	BTB_FLUSH(r10)
>>   END_BTB_FLUSH_SECTION
>>   #endif
>>   	ACCOUNT_CPU_USER_ENTRY(r13, r10, r11)
>> -2:	std	r2,GPR2(r1)

Btw. there is a hunk which restores this optimisation but it leaked
into a later patch, I'll move it back here.

>> @@ -122,14 +118,13 @@ END_BTB_FLUSH_SECTION
>>   
>>   #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC_SPLPAR)
>>   BEGIN_FW_FTR_SECTION
>> -	beq	33f
>> -	/* if from user, see if there are any DTL entries to process */
>> +	/* see if there are any DTL entries to process */
>>   	ld	r10,PACALPPACAPTR(r13)	/* get ptr to VPA */
>>   	ld	r11,PACA_DTL_RIDX(r13)	/* get log read index */
>>   	addi	r10,r10,LPPACA_DTLIDX
>>   	LDX_BE	r10,0,r10		/* get log write index */
>> -	cmpd	cr1,r11,r10
>> -	beq+	cr1,33f
>> +	cmpd	r11,r10
>> +	beq+	33f
> 
> Any need to do this change ? Why not keep it as is ?

We don't need to keep cr0 alive with the MSR_PR compare, so I prefer
to keep the cr usage more compact, and I prefer to have cr0 for short
lived results and others for long running ones as a rule.

Thanks,
Nick

^ permalink raw reply

* Re: [PATCH 2/4] powerpc/64s: remove support for kernel-mode syscalls
From: Nicholas Piggin @ 2019-08-27 10:21 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev
In-Reply-To: <b6f8ab88-75ec-560d-6d35-9ee7bfdf5e65@c-s.fr>

Christophe Leroy's on August 27, 2019 4:14 pm:
> Euh ... That's a duplicate of [PATCH 2/4] "powerpc/64: remove support 
> for kernel-mode syscalls" ?

Yeah sorry I changed the title and got myself confused.

Thanks,
Nick

^ permalink raw reply

* Re: [PATCH 4/4] powerpc/64: system call implement the bulk of the logic in C
From: Nicholas Piggin @ 2019-08-27 10:30 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev
In-Reply-To: <3ebe3e11-f3d7-d714-50dc-334527dfee90@c-s.fr>

Christophe Leroy's on August 27, 2019 4:46 pm:
> 
> 
> Le 27/08/2019 à 05:30, Nicholas Piggin a écrit :
>> System call entry and particularly exit code is beyond the limit of what
>> is reasonable to implement in asm.
>> 
>> This conversion moves all conditional branches out of the asm code,
>> except a relatively simple test to see whether all GPRs should be
>> restored at exit time.
>> 
>> Null syscall test is about 5% faster after this patch, because the exit
>> work is handled under local_irq_disable, and the hard mask and pending
>> interrupt replay is handled after that, which avoids games with MSR.
> 
> Interesting optimisation.
> 
>> 
>> The asm instruction scheduling has not really been analysed and
>> optimised yet, as there are higher level features and improvements to
>> add first.
>> 
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>>   arch/powerpc/include/asm/asm-prototypes.h |  11 -
>>   arch/powerpc/include/asm/ptrace.h         |   3 +
>>   arch/powerpc/include/asm/signal.h         |   2 +
>>   arch/powerpc/include/asm/switch_to.h      |   4 +
>>   arch/powerpc/include/asm/time.h           |   3 +
>>   arch/powerpc/kernel/Makefile              |   3 +-
>>   arch/powerpc/kernel/entry_64.S            | 343 ++++------------------
>>   arch/powerpc/kernel/process.c             |   6 +-
>>   arch/powerpc/kernel/signal.h              |   2 -
>>   arch/powerpc/kernel/syscall_64.c          | 202 +++++++++++++
>>   10 files changed, 271 insertions(+), 308 deletions(-)
>>   create mode 100644 arch/powerpc/kernel/syscall_64.c
>> 
> 
> [...]
> 
>> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
>> index 24621e7e5033..f444525da9ce 100644
>> --- a/arch/powerpc/kernel/process.c
>> +++ b/arch/powerpc/kernel/process.c
>> @@ -1609,7 +1609,6 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
>>   	extern void ret_from_kernel_thread(void);
>>   	void (*f)(void);
>>   	unsigned long sp = (unsigned long)task_stack_page(p) + THREAD_SIZE;
>> -	struct thread_info *ti = task_thread_info(p);
>>   
>>   	klp_init_thread_info(p);
>>   
>> @@ -1617,6 +1616,8 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
>>   	sp -= sizeof(struct pt_regs);
>>   	childregs = (struct pt_regs *) sp;
>>   	if (unlikely(p->flags & PF_KTHREAD)) {
>> +		struct thread_info *ti = task_thread_info(p);
>> +
>>   		/* kernel thread */
>>   		memset(childregs, 0, sizeof(struct pt_regs));
>>   		childregs->gpr[1] = sp + sizeof(struct pt_regs);
>> @@ -1634,12 +1635,13 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
>>   	} else {
>>   		/* user thread */
>>   		struct pt_regs *regs = current_pt_regs();
>> +
>>   		CHECK_FULL_REGS(regs);
>>   		*childregs = *regs;
>>   		if (usp)
>>   			childregs->gpr[1] = usp;
>>   		p->thread.regs = childregs;
>> -		childregs->gpr[3] = 0;  /* Result from fork() */
>> +		/* ret_from_fork sets fork() result to 0 */
> 
> Does PPC32 ret_from_fork() do it as well ?

AFAICT it does, but I guess it should be a patch by itself
with powerpc: prefix. I will split it out.

>> +#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
>> +static inline void account_cpu_user_entry(void)
>> +{
>> +	unsigned long tb = mftb();
>> +
>> +	local_paca->accounting.utime += (tb - local_paca->accounting.starttime_user);
>> +	local_paca->accounting.starttime = tb;
>> +}
>> +static inline void account_cpu_user_exit(void)
>> +{
>> +	unsigned long tb = mftb();
>> +
>> +	local_paca->accounting.stime += (tb - local_paca->accounting.starttime);
>> +	local_paca->accounting.starttime_user = tb;
>> +}
>> +#else
>> +static inline void account_cpu_user_entry(void)
>> +{
>> +}
>> +static inline void account_cpu_user_exit(void)
>> +{
>> +}
>> +#endif
> 
> I think this block should go in arch/powerpc/include/asm/cputime.h, we 
> should limit #ifdefs as much as possible in C files.
> 
> And use get_accounting() instead of local_paca->accounting in order to 
> be usable on PPC32 as well

Sure thing. I need to move them for other interrupt return in C as
well.

>> +
>> +typedef long (*syscall_fn)(long, long, long, long, long, long);
>> +
>> +long system_call_exception(long r3, long r4, long r5, long r6, long r7, long r8, unsigned long r0, struct pt_regs *regs)
>> +{
>> +	unsigned long ti_flags;
>> +	syscall_fn f;
>> +
>> +	BUG_ON(!(regs->msr & MSR_PR));
>> +
>> +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
>> +	if (unlikely(regs->msr & MSR_TS_T))
>> +		tabort_syscall();
>> +#endif
> 
> MSR_TS_T and tabort_syscall() are declared regardless of 
> CONFIG_PPC_TRANSACTIONAL_MEM so IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM) 
> should be used instead of #ifdef

Will do.

>> +#if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC_SPLPAR)
>> +	if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
>> +		struct lppaca *lp = get_lppaca();
>> +
>> +		if (unlikely(local_paca->dtl_ridx != lp->dtl_idx))
>> +			accumulate_stolen_time();
>> +	}
>> +#endif
> 
> Same here, I think everything is available so IS_ENABLED() should be 
> used instead of #if

Will do.

>> +
>> +#ifdef CONFIG_PPC_KUAP_DEBUG
>> +	if (mmu_has_feature(MMU_FTR_RADIX_KUAP))
>> +		WARN_ON_ONCE(mfspr(SPRN_AMR) != AMR_KUAP_BLOCKED);
>> +#endif
> 
> This should go in a helper in one of the kup/kuap header files.

Will do.

>> +
>> +	/*
>> +	 * A syscall should always be called with interrupts enabled
>> +	 * so we just unconditionally hard-enable here. When some kind
>> +	 * of irq tracing is used, we additionally check that condition
>> +	 * is correct
>> +	 */
>> +#if defined(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG)
>> +	WARN_ON(irq_soft_mask_return() != IRQS_ENABLED);
>> +	WARN_ON(local_paca->irq_happened);
>> +#endif
> 
> Can we use IS_ENABLED() here as well ?

I think so.

>> +#ifdef CONFIG_ALTIVEC
>> +	if ((regs->msr & (MSR_FP|MSR_VEC)) != (MSR_FP|MSR_VEC))
>> +#else
>> +	if ((regs->msr & MSR_FP) != MSR_FP)
>> +#endif
> 
> Use 'if (IS_ENABLED(CONFIG_ALTIVEC)) / else' instead of an 
> #ifdef/#else/#endif

Yeah that'll be nicer.

>> +#ifdef CONFIG_PPC_KUAP_DEBUG
>> +	if (mmu_has_feature(MMU_FTR_RADIX_KUAP))
>> +		WARN_ON_ONCE(mfspr(SPRN_AMR) != AMR_KUAP_BLOCKED);
>> +#endif
> 
> Same, define a helper in the kuap header files to avoid the #ifdefs and 
> platform specif stuff here.

Will do. Thanks for the quick review.

Thanks,
Nick

^ permalink raw reply

* Re: [PATCH 2/4] powerpc/64: remove support for kernel-mode syscalls
From: Nicholas Piggin @ 2019-08-27 10:41 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev
In-Reply-To: <1566900842.ttf5qhpflv.astroid@bobo.none>

Nicholas Piggin's on August 27, 2019 8:20 pm:
> Christophe Leroy's on August 27, 2019 4:13 pm:
>> 
>> 
>> Le 27/08/2019 à 05:30, Nicholas Piggin a écrit :
>>> There is support for the kernel to execute the 'sc 0' instruction and
>>> make a system call to itself. This is a relic that is unused in the
>>> tree, therefore untested. It's also highly questionable for modules to
>>> be doing this.
>> 
>> I like it.
>> 
>> I dropped support for that in PPC32 when I added fast-path syscalls.
> 
> Good, then we'll match again.
> 
>>> -	beq	2f			/* if from kernel mode */
>>>   #ifdef CONFIG_PPC_FSL_BOOK3E
>>>   START_BTB_FLUSH_SECTION
>>>   	BTB_FLUSH(r10)
>>>   END_BTB_FLUSH_SECTION
>>>   #endif
>>>   	ACCOUNT_CPU_USER_ENTRY(r13, r10, r11)
>>> -2:	std	r2,GPR2(r1)
> 
> Btw. there is a hunk which restores this optimisation but it leaked
> into a later patch, I'll move it back here.

I'm wrong. Now I look at it again, the hunk should be removed
completely of course.

Thanks,
Nick

^ permalink raw reply

* Re: [PATCH v2 6/6] mm/memory_hotplug: Pass nid instead of zone to __remove_pages()
From: Robin Murphy @ 2019-08-27 10:49 UTC (permalink / raw)
  To: David Hildenbrand, linux-kernel
  Cc: Mark Rutland, linux-s390, Rich Felker, linux-ia64, Tom Lendacky,
	Peter Zijlstra, Dave Hansen, Heiko Carstens, Wei Yang, linux-mm,
	Michal Hocko, Paul Mackerras, H. Peter Anvin, Will Deacon,
	Dan Williams, Halil Pasic, Yu Zhao, Yoshinori Sato,
	Jason Gunthorpe, linux-sh, x86, Matthew Wilcox (Oracle),
	Mike Rapoport, Jun Yao, Christian Borntraeger, Ingo Molnar,
	linux-arm-kernel, Catalin Marinas, Ira Weiny, Fenghua Yu,
	Pavel Tatashin, Vasily Gorbik, Anshuman Khandual, Masahiro Yamada,
	linuxppc-dev, Borislav Petkov, Andy Lutomirski, Thomas Gleixner,
	Gerald Schaefer, Oscar Salvador, Tony Luck, Steve Capper,
	Greg Kroah-Hartman, Aneesh Kumar K.V, Qian Cai, Andrew Morton,
	Logan Gunthorpe
In-Reply-To: <20190826101012.10575-7-david@redhat.com>

On 26/08/2019 11:10, David Hildenbrand wrote:
> The zone parameter is no longer in use. Replace it with the nid, which
> we can now use the nid to limit the number of zones we have to process
> (vie for_each_zone_nid()). The function signature of __remove_pages() now
> looks much more similar to the one of __add_pages().

FWIW I recall this being trivially easy to hit when first playing with 
hotremove development for arm64 - since we only have 3 zones, the page 
flags poison would cause page_zone() to dereference past the end of 
node_zones[] and go all kinds of wrong. This looks like a definite 
improvement in API terms.

For arm64,

Acked-by: Robin Murphy <robin.murphy@arm.com>

Cheers,
Robin.

> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: Fenghua Yu <fenghua.yu@intel.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Steve Capper <steve.capper@arm.com>
> Cc: Mike Rapoport <rppt@linux.ibm.com>
> Cc: Anshuman Khandual <anshuman.khandual@arm.com>
> Cc: Yu Zhao <yuzhao@google.com>
> Cc: Jun Yao <yaojun8558363@gmail.com>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: Christophe Leroy <christophe.leroy@c-s.fr>
> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
> Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
> Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Wei Yang <richard.weiyang@gmail.com>
> Cc: Qian Cai <cai@lca.pw>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Logan Gunthorpe <logang@deltatee.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-ia64@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-s390@vger.kernel.org
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>   arch/arm64/mm/mmu.c            |  4 +---
>   arch/ia64/mm/init.c            |  4 +---
>   arch/powerpc/mm/mem.c          |  3 +--
>   arch/s390/mm/init.c            |  4 +---
>   arch/sh/mm/init.c              |  4 +---
>   arch/x86/mm/init_32.c          |  4 +---
>   arch/x86/mm/init_64.c          |  4 +---
>   include/linux/memory_hotplug.h |  2 +-
>   mm/memory_hotplug.c            | 17 +++++++++--------
>   mm/memremap.c                  |  3 +--
>   10 files changed, 18 insertions(+), 31 deletions(-)
> 
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index e67bab4d613e..9a2d388314f3 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -1080,7 +1080,6 @@ void arch_remove_memory(int nid, u64 start, u64 size,
>   {
>   	unsigned long start_pfn = start >> PAGE_SHIFT;
>   	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	struct zone *zone;
>   
>   	/*
>   	 * FIXME: Cleanup page tables (also in arch_add_memory() in case
> @@ -1089,7 +1088,6 @@ void arch_remove_memory(int nid, u64 start, u64 size,
>   	 * unplug. ARCH_ENABLE_MEMORY_HOTREMOVE must not be
>   	 * unlocked yet.
>   	 */
> -	zone = page_zone(pfn_to_page(start_pfn));
> -	__remove_pages(zone, start_pfn, nr_pages, altmap);
> +	__remove_pages(nid, start_pfn, nr_pages, altmap);
>   }
>   #endif
> diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
> index bf9df2625bc8..ae6a3e718aa0 100644
> --- a/arch/ia64/mm/init.c
> +++ b/arch/ia64/mm/init.c
> @@ -689,9 +689,7 @@ void arch_remove_memory(int nid, u64 start, u64 size,
>   {
>   	unsigned long start_pfn = start >> PAGE_SHIFT;
>   	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	struct zone *zone;
>   
> -	zone = page_zone(pfn_to_page(start_pfn));
> -	__remove_pages(zone, start_pfn, nr_pages, altmap);
> +	__remove_pages(nid, start_pfn, nr_pages, altmap);
>   }
>   #endif
> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index 9191a66b3bc5..af21e13529ce 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -130,10 +130,9 @@ void __ref arch_remove_memory(int nid, u64 start, u64 size,
>   {
>   	unsigned long start_pfn = start >> PAGE_SHIFT;
>   	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	struct page *page = pfn_to_page(start_pfn) + vmem_altmap_offset(altmap);
>   	int ret;
>   
> -	__remove_pages(page_zone(page), start_pfn, nr_pages, altmap);
> +	__remove_pages(nid, start_pfn, nr_pages, altmap);
>   
>   	/* Remove htab bolted mappings for this section of memory */
>   	start = (unsigned long)__va(start);
> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> index 20340a03ad90..2a7373ed6ded 100644
> --- a/arch/s390/mm/init.c
> +++ b/arch/s390/mm/init.c
> @@ -296,10 +296,8 @@ void arch_remove_memory(int nid, u64 start, u64 size,
>   {
>   	unsigned long start_pfn = start >> PAGE_SHIFT;
>   	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	struct zone *zone;
>   
> -	zone = page_zone(pfn_to_page(start_pfn));
> -	__remove_pages(zone, start_pfn, nr_pages, altmap);
> +	__remove_pages(nid, start_pfn, nr_pages, altmap);
>   	vmem_remove_mapping(start, size);
>   }
>   #endif /* CONFIG_MEMORY_HOTPLUG */
> diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
> index dfdbaa50946e..32441b59297d 100644
> --- a/arch/sh/mm/init.c
> +++ b/arch/sh/mm/init.c
> @@ -434,9 +434,7 @@ void arch_remove_memory(int nid, u64 start, u64 size,
>   {
>   	unsigned long start_pfn = PFN_DOWN(start);
>   	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	struct zone *zone;
>   
> -	zone = page_zone(pfn_to_page(start_pfn));
> -	__remove_pages(zone, start_pfn, nr_pages, altmap);
> +	__remove_pages(nid, start_pfn, nr_pages, altmap);
>   }
>   #endif /* CONFIG_MEMORY_HOTPLUG */
> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> index 4068abb9427f..2760e4bfbc56 100644
> --- a/arch/x86/mm/init_32.c
> +++ b/arch/x86/mm/init_32.c
> @@ -865,10 +865,8 @@ void arch_remove_memory(int nid, u64 start, u64 size,
>   {
>   	unsigned long start_pfn = start >> PAGE_SHIFT;
>   	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	struct zone *zone;
>   
> -	zone = page_zone(pfn_to_page(start_pfn));
> -	__remove_pages(zone, start_pfn, nr_pages, altmap);
> +	__remove_pages(nid, start_pfn, nr_pages, altmap);
>   }
>   #endif
>   
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index a6b5c653727b..99d92297f1cf 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1212,10 +1212,8 @@ void __ref arch_remove_memory(int nid, u64 start, u64 size,
>   {
>   	unsigned long start_pfn = start >> PAGE_SHIFT;
>   	unsigned long nr_pages = size >> PAGE_SHIFT;
> -	struct page *page = pfn_to_page(start_pfn) + vmem_altmap_offset(altmap);
> -	struct zone *zone = page_zone(page);
>   
> -	__remove_pages(zone, start_pfn, nr_pages, altmap);
> +	__remove_pages(nid, start_pfn, nr_pages, altmap);
>   	kernel_physical_mapping_remove(start, start + size);
>   }
>   #endif /* CONFIG_MEMORY_HOTPLUG */
> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> index f46ea71b4ffd..c5b38e7dc8aa 100644
> --- a/include/linux/memory_hotplug.h
> +++ b/include/linux/memory_hotplug.h
> @@ -125,7 +125,7 @@ static inline bool movable_node_is_enabled(void)
>   
>   extern void arch_remove_memory(int nid, u64 start, u64 size,
>   			       struct vmem_altmap *altmap);
> -extern void __remove_pages(struct zone *zone, unsigned long start_pfn,
> +extern void __remove_pages(int nid, unsigned long start_pfn,
>   			   unsigned long nr_pages, struct vmem_altmap *altmap);
>   
>   /* reasonably generic interface to expand the physical pages */
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index e88c96cf9d77..49ca3364eb70 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -514,7 +514,7 @@ static void __remove_zone(struct zone *zone, unsigned long start_pfn,
>   	pgdat_resize_unlock(zone->zone_pgdat, &flags);
>   }
>   
> -static void __remove_section(unsigned long pfn, unsigned long nr_pages,
> +static void __remove_section(int nid, unsigned long pfn, unsigned long nr_pages,
>   			     unsigned long map_offset,
>   			     struct vmem_altmap *altmap)
>   {
> @@ -525,14 +525,14 @@ static void __remove_section(unsigned long pfn, unsigned long nr_pages,
>   		return;
>   
>   	/* TODO: move zone handling out of memory removal path */
> -	for_each_zone(zone)
> +	for_each_zone_nid(zone, nid)
>   		__remove_zone(zone, pfn, nr_pages);
>   	sparse_remove_section(ms, pfn, nr_pages, map_offset, altmap);
>   }
>   
>   /**
>    * __remove_pages() - remove sections of pages from a zone
> - * @zone: zone from which pages need to be removed
> + * @nid: the nid all pages were added to
>    * @pfn: starting pageframe (must be aligned to start of a section)
>    * @nr_pages: number of pages to remove (must be multiple of section size)
>    * @altmap: alternative device page map or %NULL if default memmap is used
> @@ -542,12 +542,13 @@ static void __remove_section(unsigned long pfn, unsigned long nr_pages,
>    * sure that pages are marked reserved and zones are adjust properly by
>    * calling offline_pages().
>    */
> -void __remove_pages(struct zone *zone, unsigned long pfn,
> -		    unsigned long nr_pages, struct vmem_altmap *altmap)
> +void __remove_pages(int nid, unsigned long pfn, unsigned long nr_pages,
> +		    struct vmem_altmap *altmap)
>   {
>   	const unsigned long end_pfn = pfn + nr_pages;
>   	unsigned long cur_nr_pages;
>   	unsigned long map_offset = 0;
> +	struct zone *zone;
>   
>   	if (check_pfn_span(pfn, nr_pages, "remove"))
>   		return;
> @@ -555,7 +556,7 @@ void __remove_pages(struct zone *zone, unsigned long pfn,
>   	map_offset = vmem_altmap_offset(altmap);
>   
>   	/* TODO: move zone handling out of memory removal path */
> -	for_each_zone(zone)
> +	for_each_zone_nid(zone, nid)
>   		if (zone_intersects(zone, pfn, nr_pages))
>   			clear_zone_contiguous(zone);
>   
> @@ -563,12 +564,12 @@ void __remove_pages(struct zone *zone, unsigned long pfn,
>   		cond_resched();
>   		/* Select all remaining pages up to the next section boundary */
>   		cur_nr_pages = min(end_pfn - pfn, -(pfn | PAGE_SECTION_MASK));
> -		__remove_section(pfn, cur_nr_pages, map_offset, altmap);
> +		__remove_section(nid, pfn, cur_nr_pages, map_offset, altmap);
>   		map_offset = 0;
>   	}
>   
>   	/* TODO: move zone handling out of memory removal path */
> -	for_each_zone(zone)
> +	for_each_zone_nid(zone, nid)
>   		set_zone_contiguous(zone);
>   }
>   
> diff --git a/mm/memremap.c b/mm/memremap.c
> index 8a394552b5bd..292ef4c6b447 100644
> --- a/mm/memremap.c
> +++ b/mm/memremap.c
> @@ -138,8 +138,7 @@ static void devm_memremap_pages_release(void *data)
>   	mem_hotplug_begin();
>   	if (pgmap->type == MEMORY_DEVICE_PRIVATE) {
>   		pfn = PHYS_PFN(res->start);
> -		__remove_pages(page_zone(pfn_to_page(pfn)), pfn,
> -				 PHYS_PFN(resource_size(res)), NULL);
> +		__remove_pages(nid, pfn, PHYS_PFN(resource_size(res)), NULL);
>   	} else {
>   		arch_remove_memory(nid, res->start, resource_size(res),
>   				pgmap_altmap(pgmap));
> 

^ permalink raw reply

* powerpc asm-prototypes.h seems odd
From: Masahiro Yamada @ 2019-08-27 11:04 UTC (permalink / raw)
  To: Nicholas Piggin, Michael Ellerman, linuxppc-dev; +Cc: Linux Kernel Mailing List

Hi.

Lots of powerpc files include <asm/asm-prototypes.h>,
and powerpc is the only architecture that does this.

<asm/asm-prototypes.h> exists to support modversion for asm.
So, it is supposed to be parsed by genksysms, not to be
included from other files.  Right?


$  git grep  asm/asm-prototypes.h
arch/arm64/include/asm/asm-prototypes.h: * ... kbuild will
automatically pick these up from <asm/asm-prototypes.h> and
arch/powerpc/kernel/early_32.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/irq.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/machine_kexec_64.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/process.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/prom_init.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/ptrace.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/security.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/setup_32.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/signal_32.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/signal_64.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/smp.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/syscalls.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/tau_6xx.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/time.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/trace/ftrace.c:#include <asm/asm-prototypes.h>
arch/powerpc/kernel/traps.c:#include <asm/asm-prototypes.h>
arch/powerpc/kvm/book3s_emulate.c:#include <asm/asm-prototypes.h>
arch/powerpc/kvm/book3s_hv.c:#include <asm/asm-prototypes.h>
arch/powerpc/kvm/book3s_hv_builtin.c:#include <asm/asm-prototypes.h>
arch/powerpc/kvm/book3s_hv_rm_xive.c:#include <asm/asm-prototypes.h>
arch/powerpc/kvm/book3s_pr.c:#include <asm/asm-prototypes.h>
arch/powerpc/lib/vmx-helper.c:#include <asm/asm-prototypes.h>
arch/powerpc/mm/book3s64/hash_utils.c:#include <asm/asm-prototypes.h>
arch/powerpc/mm/book3s64/slb.c:#include <asm/asm-prototypes.h>
arch/powerpc/platforms/powernv/idle.c:#include <asm/asm-prototypes.h>
arch/powerpc/platforms/powernv/opal-call.c:#include <asm/asm-prototypes.h>
arch/powerpc/platforms/powernv/opal-tracepoints.c:#include
<asm/asm-prototypes.h>
arch/powerpc/platforms/pseries/lpar.c:#include <asm/asm-prototypes.h>
scripts/Makefile.build:# .S file exports must have their C prototypes
defined in asm/asm-prototypes.h
scripts/Makefile.build:     echo "\#include <asm/asm-prototypes.h>" ;
                            \
scripts/Makefile.build:ASM_PROTOTYPES := $(wildcard
$(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h)



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply

* Re: [powerpc]WARN : arch/powerpc/platforms/powernv/smp.c:160
From: Sachin Sant @ 2019-08-27 11:28 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, linux-next, ego
In-Reply-To: <B641A885-76DF-4976-81AE-73D41AD71BAF@linux.vnet.ibm.com>



> On 26-Aug-2019, at 3:42 PM, Sachin Sant <sachinp@linux.vnet.ibm.com> wrote:
> 
>> On 26-Aug-2019, at 8:59 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
>> 
>> Sachin Sant <sachinp@linux.vnet.ibm.com> writes:
>>> linux-next is currently broken on POWER8 non virtualized. Kernel
>>> fails to reach login prompt with following kernel warning
>>> repeatedly shown during boot.
>> 
>> I don't see it on my test systems.
>> 
>> The backtrace makes it look like you're doing CPU hot_un_plug during
>> boot, which seems a bit odd.
>> 
> There is no explicit hot un plug operation being done. This happens
> during boot.
> 
> For some reason cpu’s are being off lined.  

So this machine was configured as a KVM host. Hence the SMT=1
configuration at boot. Removing QEMU/libvirt packages and unloading
kvm module gets me to SMT 8 config.

Disabling kvm also allows me to boot next kernels without the warning.
The warning is only seen with kvm configured.

Thanks
-Sachin


^ permalink raw reply

* [RESEND PATCH v5 13/31] powernv/fadump: reset metadata address during clean up
From: Hari Bathini @ 2019-08-27 11:38 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Ananth N Mavinakayanahalli, Mahesh J Salgaonkar, Vasant Hegde,
	Oliver, Nicholas Piggin, Daniel Axtens

During kexec boot, metadata address needs to be reset to avoid running
into errors interpreting stale metadata address, in case the kexec'ed
kernel crashes before metadata address could be setup again.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
---

* Added check in fadump_cleanup() function for whether FADump is supported
  before proceeding with cleanup callbacks as this function can be called
  outside FADump code in shutdown and kexec paths which could crash the
  system on machines that do not support FADump.


 arch/powerpc/kernel/fadump-common.h          |    1 +
 arch/powerpc/kernel/fadump.c                 |    5 +++++
 arch/powerpc/platforms/powernv/opal-fadump.c |   10 ++++++++++
 arch/powerpc/platforms/pseries/rtas-fadump.c |    3 +++
 4 files changed, 19 insertions(+)

diff --git a/arch/powerpc/kernel/fadump-common.h b/arch/powerpc/kernel/fadump-common.h
index 0acf412..d2dd117 100644
--- a/arch/powerpc/kernel/fadump-common.h
+++ b/arch/powerpc/kernel/fadump-common.h
@@ -120,6 +120,7 @@ struct fadump_ops {
 	int	(*fadump_register)(struct fw_dump *fadump_config);
 	int	(*fadump_unregister)(struct fw_dump *fadump_config);
 	int	(*fadump_invalidate)(struct fw_dump *fadump_config);
+	void	(*fadump_cleanup)(struct fw_dump *fadump_config);
 	int	(*fadump_process)(struct fw_dump *fadump_config);
 	void	(*fadump_region_show)(struct fw_dump *fadump_config,
 				      struct seq_file *m);
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index a086a09..02ccfd4 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -821,6 +821,9 @@ static int register_fadump(void)
 
 void fadump_cleanup(void)
 {
+	if (!fw_dump.fadump_supported)
+		return;
+
 	/* Invalidate the registration only if dump is active. */
 	if (fw_dump.dump_active) {
 		pr_debug("Invalidating firmware-assisted dump registration\n");
@@ -830,6 +833,8 @@ void fadump_cleanup(void)
 		fw_dump.ops->fadump_unregister(&fw_dump);
 		free_crash_memory_ranges();
 	}
+
+	fw_dump.ops->fadump_cleanup(&fw_dump);
 }
 
 static void fadump_free_reserved_memory(unsigned long start_pfn,
diff --git a/arch/powerpc/platforms/powernv/opal-fadump.c b/arch/powerpc/platforms/powernv/opal-fadump.c
index e5c4700..e466f7e 100644
--- a/arch/powerpc/platforms/powernv/opal-fadump.c
+++ b/arch/powerpc/platforms/powernv/opal-fadump.c
@@ -110,6 +110,15 @@ static int opal_fadump_invalidate(struct fw_dump *fadump_conf)
 	return -EIO;
 }
 
+static void opal_fadump_cleanup(struct fw_dump *fadump_conf)
+{
+	s64 ret;
+
+	ret = opal_mpipl_register_tag(OPAL_MPIPL_TAG_KERNEL, 0);
+	if (ret != OPAL_SUCCESS)
+		pr_warn("Could not reset (%llu) kernel metadata tag!\n", ret);
+}
+
 static int __init opal_fadump_process(struct fw_dump *fadump_conf)
 {
 	return -EINVAL;
@@ -150,6 +159,7 @@ static struct fadump_ops opal_fadump_ops = {
 	.fadump_register		= opal_fadump_register,
 	.fadump_unregister		= opal_fadump_unregister,
 	.fadump_invalidate		= opal_fadump_invalidate,
+	.fadump_cleanup			= opal_fadump_cleanup,
 	.fadump_process			= opal_fadump_process,
 	.fadump_region_show		= opal_fadump_region_show,
 	.fadump_trigger			= opal_fadump_trigger,
diff --git a/arch/powerpc/platforms/pseries/rtas-fadump.c b/arch/powerpc/platforms/pseries/rtas-fadump.c
index 4111ee9..6164c5a 100644
--- a/arch/powerpc/platforms/pseries/rtas-fadump.c
+++ b/arch/powerpc/platforms/pseries/rtas-fadump.c
@@ -235,6 +235,8 @@ static int rtas_fadump_invalidate(struct fw_dump *fadump_conf)
 	return 0;
 }
 
+static void rtas_fadump_cleanup(struct fw_dump *fadump_conf) { }
+
 #define RTAS_FADUMP_GPR_MASK			0xffffff0000000000
 static inline int rtas_fadump_gpr_index(u64 id)
 {
@@ -508,6 +510,7 @@ static struct fadump_ops rtas_fadump_ops = {
 	.fadump_register		= rtas_fadump_register,
 	.fadump_unregister		= rtas_fadump_unregister,
 	.fadump_invalidate		= rtas_fadump_invalidate,
+	.fadump_cleanup			= rtas_fadump_cleanup,
 	.fadump_process			= rtas_fadump_process,
 	.fadump_region_show		= rtas_fadump_region_show,
 	.fadump_trigger			= rtas_fadump_trigger,


^ permalink raw reply related

* Re: [PATCH v5 13/31] powernv/fadump: reset metadata address during clean up
From: Hari Bathini @ 2019-08-27 12:00 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Ananth N Mavinakayanahalli, Mahesh J Salgaonkar, Nicholas Piggin,
	Oliver, Vasant Hegde, Daniel Axtens
In-Reply-To: <156630274313.8896.17475124195648859586.stgit@hbathini.in.ibm.com>



On 20/08/19 5:35 PM, Hari Bathini wrote:
> During kexec boot, metadata address needs to be reset to avoid running
> into errors interpreting stale metadata address, in case the kexec'ed
> kernel crashes before metadata address could be setup again.
> 
> Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
> ---
>  arch/powerpc/kernel/fadump-common.h          |    1 +
>  arch/powerpc/kernel/fadump.c                 |    2 ++
>  arch/powerpc/platforms/powernv/opal-fadump.c |   10 ++++++++++
>  arch/powerpc/platforms/pseries/rtas-fadump.c |    3 +++
>  4 files changed, 16 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/fadump-common.h b/arch/powerpc/kernel/fadump-common.h
> index 0acf412..d2dd117 100644
> --- a/arch/powerpc/kernel/fadump-common.h
> +++ b/arch/powerpc/kernel/fadump-common.h
> @@ -120,6 +120,7 @@ struct fadump_ops {
>  	int	(*fadump_register)(struct fw_dump *fadump_config);
>  	int	(*fadump_unregister)(struct fw_dump *fadump_config);
>  	int	(*fadump_invalidate)(struct fw_dump *fadump_config);
> +	void	(*fadump_cleanup)(struct fw_dump *fadump_config);
>  	int	(*fadump_process)(struct fw_dump *fadump_config);
>  	void	(*fadump_region_show)(struct fw_dump *fadump_config,
>  				      struct seq_file *m);
> diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
> index a086a09..b2d5ca6 100644
> --- a/arch/powerpc/kernel/fadump.c
> +++ b/arch/powerpc/kernel/fadump.c
> @@ -830,6 +830,8 @@ void fadump_cleanup(void)
>  		fw_dump.ops->fadump_unregister(&fw_dump);
>  		free_crash_memory_ranges();
>  	}
> +
> +	fw_dump.ops->fadump_cleanup(&fw_dump);

Actually, need to check if FADump is supported before proceeding with cleanup callbacks
as fadump_cleanup() can be called outside FADump code in shutdown and kexec paths which
could crash the system on machines that do not support FADump. Re-sent the patch adding
the check in fadump_cleanup() function:

    https://patchwork.ozlabs.org/patch/1153806/
    ("[RESEND,v5,13/31] powernv/fadump: reset metadata address during clean up")

- Hari


^ permalink raw reply

* Re: [PATCH rebased] powerpc/fadump: when fadump is supported register the fadump sysfs files.
From: Hari Bathini @ 2019-08-27 12:27 UTC (permalink / raw)
  To: Michal Suchanek, linuxppc-dev
  Cc: Yangtao Li, Mahesh Salgaonkar, linux-kernel, Paul Mackerras,
	Hari Bathini, Thomas Gleixner
In-Reply-To: <20190820181211.14694-1-msuchanek@suse.de>


Hi Michal,

Thanks for the patch. 

On 20/08/19 11:42 PM, Michal Suchanek wrote:
> Currently it is not possible to distinguish the case when fadump is
> supported by firmware and disabled in kernel and completely unsupported
> using the kernel sysfs interface. User can investigate the devicetree
> but it is more reasonable to provide sysfs files in case we get some
> fadumpv2 in the future.
> 
> With this patch sysfs files are available whenever fadump is supported
> by firmware.
> 
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
> Rebase on top of http://patchwork.ozlabs.org/patch/1150160/
> [v5,31/31] powernv/fadump: support holes in kernel boot memory area
> ---
>  arch/powerpc/kernel/fadump.c | 33 ++++++++++++++++++---------------
>  1 file changed, 18 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
> index 4b1bb3c55cf9..7ad424729e9c 100644
> --- a/arch/powerpc/kernel/fadump.c
> +++ b/arch/powerpc/kernel/fadump.c
> @@ -1319,13 +1319,9 @@ static void fadump_init_files(void)
>   */
>  int __init setup_fadump(void)
>  {
> -	if (!fw_dump.fadump_enabled)
> -		return 0;
> -
> -	if (!fw_dump.fadump_supported) {
> +	if (!fw_dump.fadump_supported && fw_dump.fadump_enabled) {
>  		printk(KERN_ERR "Firmware-assisted dump is not supported on"
>  			" this hardware\n");
> -		return 0;
>  	}
>  
>  	fadump_show_config();
> @@ -1333,19 +1329,26 @@ int __init setup_fadump(void)
>  	 * If dump data is available then see if it is valid and prepare for
>  	 * saving it to the disk.
>  	 */
> -	if (fw_dump.dump_active) {
> +	if (fw_dump.fadump_enabled) {
> +		if (fw_dump.dump_active) {
> +			/*
> +			 * if dump process fails then invalidate the
> +			 * registration and release memory before proceeding
> +			 * for re-registration.
> +			 */
> +			if (fw_dump.ops->fadump_process(&fw_dump) < 0)
> +				fadump_invalidate_release_mem();
> +		}
>  		/*
> -		 * if dump process fails then invalidate the registration
> -		 * and release memory before proceeding for re-registration.
> +		 * Initialize the kernel dump memory structure for FAD
> +		 * registration.
>  		 */
> -		if (fw_dump.ops->fadump_process(&fw_dump) < 0)
> -			fadump_invalidate_release_mem();
> -	}
> -	/* Initialize the kernel dump memory structure for FAD registration. */
> -	else if (fw_dump.reserve_dump_area_size)
> -		fw_dump.ops->fadump_init_mem_struct(&fw_dump);
> +		else if (fw_dump.reserve_dump_area_size)
> +			fw_dump.ops->fadump_init_mem_struct(&fw_dump);
>  
> -	fadump_init_files();
> +	}
> +	if (fw_dump.fadump_supported)
> +		fadump_init_files();
>  
>  	return 1;
>  }
> 


Could you please move up fadump_init_files() call and return after it instead of
nesting rest of the function. Also, get rid of the error message when fadump is
not supported as it is already taken care of in fadump_reserve_mem() function.
I mean:

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 2015b1f..0e9b028 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -1322,16 +1322,16 @@ static void fadump_init_files(void)
  */
 int __init setup_fadump(void)
 {
-       if (!fw_dump.fadump_enabled)
+       if (!fw_dump.fadump_supported)
                return 0;
 
-       if (!fw_dump.fadump_supported) {
-               printk(KERN_ERR "Firmware-assisted dump is not supported on"
-                       " this hardware\n");
-               return 0;
-       }
+       fadump_init_files();
 
        fadump_show_config();
+
+       if (!fw_dump.fadump_enabled)
+               return 0;
+
        /*
         * If dump data is available then see if it is valid and prepare for
         * saving it to the disk.
@@ -1348,8 +1348,6 @@ int __init setup_fadump(void)
        else if (fw_dump.reserve_dump_area_size)
                fw_dump.ops->fadump_init_mem_struct(&fw_dump);
 
-       fadump_init_files();
-
        return 1;
 }
 subsys_initcall(setup_fadump);


- Hari


^ permalink raw reply related

* [PATCH 0/2] PowerPC-pSeries: Adjustments for dlpar_store()
From: Markus Elfring @ 2019-08-27 12:40 UTC (permalink / raw)
  To: linuxppc-dev, Allison Randal, Benjamin Herrenschmidt,
	Frank Rowand, Gen Zhang, Greg Kroah-Hartman, Michael Ellerman,
	Nathan Fontenot, Nathan Lynch, Oliver O'Halloran,
	Paul Mackerras, Thomas Gleixner
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Aug 2019 14:33:21 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Delete an unnecessary kfree() call
  Delete an error message for a failed string duplication

 arch/powerpc/platforms/pseries/dlpar.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

--
2.23.0


^ permalink raw reply

* [PATCH 1/2] powerpc/pseries: Delete an unnecessary kfree() call in dlpar_store()
From: Markus Elfring @ 2019-08-27 12:42 UTC (permalink / raw)
  To: linuxppc-dev, Allison Randal, Benjamin Herrenschmidt,
	Frank Rowand, Gen Zhang, Greg Kroah-Hartman, Michael Ellerman,
	Nathan Fontenot, Nathan Lynch, Oliver O'Halloran,
	Paul Mackerras, Thomas Gleixner
  Cc: kernel-janitors, LKML
In-Reply-To: <db28c84d-ac07-6d9a-a371-c97ab72bf763@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Aug 2019 13:34:02 +0200

A null pointer would be passed to a call of the function “kfree”
immediately after a call of the function “kstrdup” failed at one place.
Remove this superfluous function call.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/pseries/dlpar.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 16e86ba8aa20..2a783dc0cfa7 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -523,7 +523,6 @@ static ssize_t dlpar_store(struct class *class, struct class_attribute *attr,
 	args = argbuf = kstrdup(buf, GFP_KERNEL);
 	if (!argbuf) {
 		pr_info("Could not allocate resources for DLPAR operation\n");
-		kfree(argbuf);
 		return -ENOMEM;
 	}

--
2.23.0


^ permalink raw reply related

* [PATCH 2/2] powerpc/pseries: Delete an error message for a failed string duplication in dlpar_store()
From: Markus Elfring @ 2019-08-27 12:44 UTC (permalink / raw)
  To: linuxppc-dev, Allison Randal, Benjamin Herrenschmidt,
	Frank Rowand, Gen Zhang, Greg Kroah-Hartman, Michael Ellerman,
	Nathan Fontenot, Nathan Lynch, Oliver O'Halloran,
	Paul Mackerras, Thomas Gleixner
  Cc: kernel-janitors, LKML
In-Reply-To: <db28c84d-ac07-6d9a-a371-c97ab72bf763@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Aug 2019 13:37:56 +0200

Omit an extra message for a memory allocation failure in this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/pseries/dlpar.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 2a783dc0cfa7..deb48b41d488 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -521,10 +521,8 @@ static ssize_t dlpar_store(struct class *class, struct class_attribute *attr,
 	int rc;

 	args = argbuf = kstrdup(buf, GFP_KERNEL);
-	if (!argbuf) {
-		pr_info("Could not allocate resources for DLPAR operation\n");
+	if (!argbuf)
 		return -ENOMEM;
-	}

 	/*
 	 * Parse out the request from the user, this will be in the form:
--
2.23.0


^ permalink raw reply related

* Re: [PATCH 2/2] powerpc: cleanup hw_irq.h
From: Nicholas Piggin @ 2019-08-27 12:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Christophe Leroy, Michael Ellerman,
	Paul Mackerras
  Cc: linuxppc-dev, linux-kernel
In-Reply-To: <81f39fa06ae582f4a783d26abd2b310204eba8f4.1566893505.git.christophe.leroy@c-s.fr>

Christophe Leroy's on August 27, 2019 6:13 pm:
> SET_MSR_EE() is just use in this file and doesn't provide
> any added value compared to mtmsr(). Drop it.
> 
> Add macros to use wrtee/wrteei insn.
> 
> Replace #ifdefs by IS_ENABLED()
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
>  arch/powerpc/include/asm/hw_irq.h | 57 ++++++++++++++++++---------------------
>  arch/powerpc/include/asm/reg.h    |  2 ++
>  2 files changed, 28 insertions(+), 31 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
> index 32a18f2f49bc..c25d57f25a8b 100644
> --- a/arch/powerpc/include/asm/hw_irq.h
> +++ b/arch/powerpc/include/asm/hw_irq.h
> @@ -226,8 +226,8 @@ static inline bool arch_irqs_disabled(void)
>  #endif /* CONFIG_PPC_BOOK3S */
>  
>  #ifdef CONFIG_PPC_BOOK3E
> -#define __hard_irq_enable()	asm volatile("wrteei 1" : : : "memory")
> -#define __hard_irq_disable()	asm volatile("wrteei 0" : : : "memory")
> +#define __hard_irq_enable()	wrteei(1)
> +#define __hard_irq_disable()	wrteei(0)
>  #else
>  #define __hard_irq_enable()	__mtmsrd(MSR_EE|MSR_RI, 1)
>  #define __hard_irq_disable()	__mtmsrd(MSR_RI, 1)
> @@ -280,8 +280,6 @@ extern void force_external_irq_replay(void);
>  
>  #else /* CONFIG_PPC64 */
>  
> -#define SET_MSR_EE(x)	mtmsr(x)
> -
>  static inline unsigned long arch_local_save_flags(void)
>  {
>  	return mfmsr();
> @@ -289,47 +287,44 @@ static inline unsigned long arch_local_save_flags(void)
>  
>  static inline void arch_local_irq_restore(unsigned long flags)
>  {
> -#if defined(CONFIG_BOOKE)
> -	asm volatile("wrtee %0" : : "r" (flags) : "memory");
> -#else
> -	mtmsr(flags);
> -#endif
> +	if (IS_ENABLED(CONFIG_BOOKE))
> +		wrtee(flags);
> +	else
> +		mtmsr(flags);
>  }
>  
>  static inline unsigned long arch_local_irq_save(void)
>  {
>  	unsigned long flags = arch_local_save_flags();
> -#ifdef CONFIG_BOOKE
> -	asm volatile("wrteei 0" : : : "memory");
> -#elif defined(CONFIG_PPC_8xx)
> -	wrtspr(SPRN_EID);
> -#else
> -	SET_MSR_EE(flags & ~MSR_EE);
> -#endif
> +
> +	if (IS_ENABLED(CONFIG_BOOKE))
> +		wrteei(0);
> +	else if (IS_ENABLED(CONFIG_PPC_8xx))
> +		wrtspr(SPRN_EID);
> +	else
> +		mtmsr(flags & ~MSR_EE);
> +
>  	return flags;
>  }
>  
>  static inline void arch_local_irq_disable(void)
>  {
> -#ifdef CONFIG_BOOKE
> -	asm volatile("wrteei 0" : : : "memory");
> -#elif defined(CONFIG_PPC_8xx)
> -	wrtspr(SPRN_EID);
> -#else
> -	arch_local_irq_save();
> -#endif
> +	if (IS_ENABLED(CONFIG_BOOKE))
> +		wrteei(0);
> +	else if (IS_ENABLED(CONFIG_PPC_8xx))
> +		wrtspr(SPRN_EID);
> +	else
> +		mtmsr(mfmsr() & ~MSR_EE);
>  }
>  
>  static inline void arch_local_irq_enable(void)
>  {
> -#ifdef CONFIG_BOOKE
> -	asm volatile("wrteei 1" : : : "memory");
> -#elif defined(CONFIG_PPC_8xx)
> -	wrtspr(SPRN_EIE);
> -#else
> -	unsigned long msr = mfmsr();
> -	SET_MSR_EE(msr | MSR_EE);
> -#endif
> +	if (IS_ENABLED(CONFIG_BOOKE))
> +		wrteei(1);
> +	else if (IS_ENABLED(CONFIG_PPC_8xx))
> +		wrtspr(SPRN_EIE);
> +	else
> +		mtmsr(mfmsr() | MSR_EE);
>  }
>  
>  static inline bool arch_irqs_disabled_flags(unsigned long flags)
> diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
> index b17ee25df226..04896dd09455 100644
> --- a/arch/powerpc/include/asm/reg.h
> +++ b/arch/powerpc/include/asm/reg.h
> @@ -1361,6 +1361,8 @@ static inline void mtmsr_isync(unsigned long val)
>  #endif
>  #define wrtspr(rn)	asm volatile("mtspr " __stringify(rn) ",0" : \
>  				     : : "memory")
> +#define wrtee(val)	asm volatile("wrtee %0" : : "r" (val) : "memory")
> +#define wrteei(val)	asm volatile("wrteei %0" : : "i" (val) : "memory")

Can you implement just one macro that uses __builtin_constant_p to 
select between the imm and reg versions? I forgot if there's some
corner cases that prevent that working with inline asm i constraints.

Otherwise, looks like a nice cleanup.

Thanks,
Nick

^ permalink raw reply

* Re: [PATCH v2 01/10] PCI: designware-ep: Add multiple PFs support for DWC
From: Andrew Murray @ 2019-08-27 13:10 UTC (permalink / raw)
  To: Xiaowei Bao
  Cc: mark.rutland@arm.com, Roy Zang, lorenzo.pieralisi@arm.co,
	arnd@arndb.de, devicetree@vger.kernel.org,
	gregkh@linuxfoundation.org, linuxppc-dev@lists.ozlabs.org,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	kishon@ti.com, M.h. Lian, robh+dt@kernel.org,
	gustavo.pimentel@synopsys.com, jingoohan1@gmail.com,
	bhelgaas@google.com, Leo Li, shawnguo@kernel.org, Mingkai Hu,
	linux-arm-kernel@lists.infradead.org
In-Reply-To: <AM5PR04MB32997FFCD08E2C34541D2F9BF5A40@AM5PR04MB3299.eurprd04.prod.outlook.com>

On Fri, Aug 23, 2019 at 11:50:20PM +0000, Xiaowei Bao wrote:
> 
> 
> > -----Original Message-----
> > From: Andrew Murray <andrew.murray@arm.com>
> > Sent: 2019年8月23日 21:25
> > To: Xiaowei Bao <xiaowei.bao@nxp.com>
> > Cc: bhelgaas@google.com; robh+dt@kernel.org; mark.rutland@arm.com;
> > shawnguo@kernel.org; Leo Li <leoyang.li@nxp.com>; kishon@ti.com;
> > lorenzo.pieralisi@arm.co; arnd@arndb.de; gregkh@linuxfoundation.org; M.h.
> > Lian <minghuan.lian@nxp.com>; Mingkai Hu <mingkai.hu@nxp.com>; Roy
> > Zang <roy.zang@nxp.com>; jingoohan1@gmail.com;
> > gustavo.pimentel@synopsys.com; linux-pci@vger.kernel.org;
> > devicetree@vger.kernel.org; linux-kernel@vger.kernel.org;
> > linux-arm-kernel@lists.infradead.org; linuxppc-dev@lists.ozlabs.org
> > Subject: Re: [PATCH v2 01/10] PCI: designware-ep: Add multiple PFs support
> > for DWC
> > 
> > On Thu, Aug 22, 2019 at 07:22:33PM +0800, Xiaowei Bao wrote:
> > > Add multiple PFs support for DWC, different PF have different config
> > > space we use pf-offset property which get from the DTS to access the
> > > different pF config space.
> > 
> > It looks like you're missing a --cover-letter again.
> > 
> > >
> > > Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
> > > ---
> > > v2:
> > >  - Remove duplicate redundant code.
> > >  - Reimplement the PF config space access way.
> > >
> > >  drivers/pci/controller/dwc/pcie-designware-ep.c | 122
> > ++++++++++++++++--------
> > >  drivers/pci/controller/dwc/pcie-designware.c    |  59 ++++++++----
> > >  drivers/pci/controller/dwc/pcie-designware.h    |  11 ++-
> > >  3 files changed, 134 insertions(+), 58 deletions(-)
> > >
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > index 2bf5a35..3e2b740 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > @@ -19,12 +19,17 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep)
> > >  	pci_epc_linkup(epc);
> > >  }
> > >
> > > -static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno
> > bar,
> > > -				   int flags)
> > > +static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no,
> > > +				   enum pci_barno bar, int flags)
> > >  {
> > >  	u32 reg;
> > > +	unsigned int func_offset = 0;
> > > +	struct dw_pcie_ep *ep = &pci->ep;
> > >
> > > -	reg = PCI_BASE_ADDRESS_0 + (4 * bar);
> > > +	if (ep->ops->func_conf_select)
> > > +		func_offset = ep->ops->func_conf_select(ep, func_no);
> > > +
> > > +	reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar);
> > 
> > This pattern of checking if func_conf_select exists and using it to get an offset
> > is repeated a lot throughout this file. You could move this functionality into a
> > new function (similar to dw_pcie_read_dbi etc). Or perhaps a new variant of
> > dw_pcie_writel_ should be created that writes takes a func_no argument.
> 
> Thanks for your comments, I thought about this method before, but there is a issue
> about the method of access the different func config space, due to our platform use
> this method that different func have different offset from dbi_base to access the
> different config space, but others platform maybe use the way that write a register
> to implement different func config space access, so I think reserve a callback function 

My point here was really to move out duplicated code to its own small function.
I wasn't making any comment about (removing) the callback, just that the test and
callback could be in one function.

> to different platform to implement the own method, my point is that, if use register 
> method they can implement the code in this function and return offset is 0, if use 
> offset method, they can return the offset value which can be use by dw_pcie_ep driver.

By the way, I haven't looked to see how many of the dw_pcie_write_xxx functions
would benefit from a func_no argument - if there were many calls to
dw_pcie_write_xxx that all used a reg value originated from func_conf_select
then an approach similar to the implementation of dw_pcie_write_dbi could
probably be justified (i.e. rather than change the value of reg) for writing to
functions.

>  
> > 
> > 
> > >  	dw_pcie_dbi_ro_wr_en(pci);
> > >  	dw_pcie_writel_dbi2(pci, reg, 0x0);
> > >  	dw_pcie_writel_dbi(pci, reg, 0x0);
> > 
> > 
> > > @@ -235,7 +257,7 @@ static int dw_pcie_ep_map_addr(struct pci_epc
> > *epc, u8 func_no,
> > >  	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
> > >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > >
> > > -	ret = dw_pcie_ep_outbound_atu(ep, addr, pci_addr, size);
> > > +	ret = dw_pcie_ep_outbound_atu(ep, func_no, addr, pci_addr, size);
> > >  	if (ret) {
> > >  		dev_err(pci->dev, "Failed to enable address\n");
> > >  		return ret;
> > > @@ -249,11 +271,15 @@ static int dw_pcie_ep_get_msi(struct pci_epc
> > *epc, u8 func_no)
> > >  	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
> > >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > >  	u32 val, reg;
> > > +	unsigned int func_offset = 0;
> > > +
> > > +	if (ep->ops->func_conf_select)
> > > +		func_offset = ep->ops->func_conf_select(ep, func_no);
> > >
> > >  	if (!ep->msi_cap)
> > >  		return -EINVAL;
> > >
> > > -	reg = ep->msi_cap + PCI_MSI_FLAGS;
> > > +	reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS;
> > 
> > This makes me nervous.
> > 
> > From a PCI viewpoint, each function has it's own capability structure and
> > within each function there may exist a MSI capability. Yet what we're doing
> > here is using dw_pcie_ep_find_capability to get the list of capabilities for
> > function 0, and then applying offsets from that for subsequent functions. I.e.
> > we're applying DW specific knowledge to find the correct capability, rather
> > than following the general PCI approach.
> > 
> > I think the above hunk shouldn't be required - but instead
> > dw_pcie_ep_find_capability is updated to take a func_no parameter.
> > 
> > Have I understood this correctly?
> 
> Yes, this is a issue, I think the different func maybe have different capability,
> but the dw_pcie_ep_find_capability function is called by dw_pcie_ep_init 
> function, we can't add func_no parameter to dw_pcie_ep_find_capability,

Why not?

Given that 'struct dw_pcie' represents a controller - and thus potentially
multiple functions - then the _find_capability function should be able to
provide the correct offset for the given function. Surely it needs to know
which function number? Unless there is some reason why we can assume that all
functions share the same capability offset.

Also the 'struct dw_pcie_ep' which represents an endpoint controller - this
has msi_cap and msix_cap fields - given this may be a multifunction device
what do these fields actually refer to?

Perhaps Jungoo/Gustavo can comment.


> I will try to fix it use a new patch, I think move this function to ep_init callback
> function If better, thanks. 
> 
> 
> > 
> > >  	val = dw_pcie_readw_dbi(pci, reg);
> > >  	if (!(val & PCI_MSI_FLAGS_ENABLE))
> > >  		return -EINVAL;
> > > @@ -268,11 +294,15 @@ static int dw_pcie_ep_set_msi(struct pci_epc
> > *epc, u8 func_no, u8 interrupts)
> > >  	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
> > >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > >  	u32 val, reg;
> > > +	unsigned int func_offset = 0;
> > > +
> > > +	if (ep->ops->func_conf_select)
> > > +		func_offset = ep->ops->func_conf_select(ep, func_no);
> > >
> > >  	if (!ep->msi_cap)
> > >  		return -EINVAL;
> > >
> > > -	reg = ep->msi_cap + PCI_MSI_FLAGS;
> > > +	reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS;
> > >  	val = dw_pcie_readw_dbi(pci, reg);
> > >  	val &= ~PCI_MSI_FLAGS_QMASK;
> > >  	val |= (interrupts << 1) & PCI_MSI_FLAGS_QMASK; @@ -288,11 +318,15
> > > @@ static int dw_pcie_ep_get_msix(struct pci_epc *epc, u8 func_no)
> > >  	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
> > >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > >  	u32 val, reg;
> > > +	unsigned int func_offset = 0;
> > > +
> > > +	if (ep->ops->func_conf_select)
> > > +		func_offset = ep->ops->func_conf_select(ep, func_no);
> > >
> > >  	if (!ep->msix_cap)
> > >  		return -EINVAL;
> > >
> > > -	reg = ep->msix_cap + PCI_MSIX_FLAGS;
> > > +	reg = ep->msix_cap + func_offset + PCI_MSIX_FLAGS;
> > 
> > Same for MSIX.
> 
> Yes.
> 
> > 
> > >  	val = dw_pcie_readw_dbi(pci, reg);
> > >  	if (!(val & PCI_MSIX_FLAGS_ENABLE))
> > >  		return -EINVAL;
> > > @@ -307,11 +341,15 @@ static int dw_pcie_ep_set_msix(struct pci_epc
> > *epc, u8 func_no, u16 interrupts)
> > >  	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
> > >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > >  	u32 val, reg;
> > > +	unsigned int func_offset = 0;
> > > +
> > > +	if (ep->ops->func_conf_select)
> > > +		func_offset = ep->ops->func_conf_select(ep, func_no);
> > >
> > >  	if (!ep->msix_cap)
> > >  		return -EINVAL;
> > >
> > > -	reg = ep->msix_cap + PCI_MSIX_FLAGS;
> > > +	reg = ep->msix_cap + func_offset + PCI_MSIX_FLAGS;
> > >  	val = dw_pcie_readw_dbi(pci, reg);
> > >  	val &= ~PCI_MSIX_FLAGS_QSIZE;
> > >  	val |= interrupts;
> > > @@ -398,29 +436,33 @@ int dw_pcie_ep_raise_msi_irq(struct
> > dw_pcie_ep *ep, u8 func_no,
> > >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > >  	struct pci_epc *epc = ep->epc;
> > >  	unsigned int aligned_offset;
> > > +	unsigned int func_offset = 0;
> > >  	u16 msg_ctrl, msg_data;
> > >  	u32 msg_addr_lower, msg_addr_upper, reg;
> > >  	u64 msg_addr;
> > >  	bool has_upper;
> > >  	int ret;
> > >
> > > +	if (ep->ops->func_conf_select)
> > > +		func_offset = ep->ops->func_conf_select(ep, func_no);
> > > +
> > 
> > You could probably move this hunk below the test for msi_cap to save some
> > cycles.
> 
> Sorry, I didn't understand the means, please explain it detailly, thanks a lot, ^_^

If you insert the call to func_conf_select *after* the test for
!msi_cap below - then in the case where msi_cap is NULL then you will
save some CPU cycles by not bothering to call func_conf_select.


> > 
> > >  	if (!ep->msi_cap)
> > >  		return -EINVAL;
> > >
> > >  	/* Raise MSI per the PCI Local Bus Specification Revision 3.0, 6.8.1. */
> > > -	reg = ep->msi_cap + PCI_MSI_FLAGS;
> > > +	reg = ep->msi_cap + func_offset + PCI_MSI_FLAGS;
> > >  	msg_ctrl = dw_pcie_readw_dbi(pci, reg);
> > >  	has_upper = !!(msg_ctrl & PCI_MSI_FLAGS_64BIT);
> > > -	reg = ep->msi_cap + PCI_MSI_ADDRESS_LO;
> > > +	reg = ep->msi_cap + func_offset + PCI_MSI_ADDRESS_LO;
> > >  	msg_addr_lower = dw_pcie_readl_dbi(pci, reg);
> > >  	if (has_upper) {
> > > -		reg = ep->msi_cap + PCI_MSI_ADDRESS_HI;
> > > +		reg = ep->msi_cap + func_offset + PCI_MSI_ADDRESS_HI;
> > >  		msg_addr_upper = dw_pcie_readl_dbi(pci, reg);
> > > -		reg = ep->msi_cap + PCI_MSI_DATA_64;
> > > +		reg = ep->msi_cap + func_offset + PCI_MSI_DATA_64;
> > >  		msg_data = dw_pcie_readw_dbi(pci, reg);
> > >  	} else {
> > >  		msg_addr_upper = 0;
> > > -		reg = ep->msi_cap + PCI_MSI_DATA_32;
> > > +		reg = ep->msi_cap + func_offset + PCI_MSI_DATA_32;
> > >  		msg_data = dw_pcie_readw_dbi(pci, reg);
> > >  	}
> > >  	aligned_offset = msg_addr_lower & (epc->mem->page_size - 1);
> > 
> > 
> > 
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.c
> > > b/drivers/pci/controller/dwc/pcie-designware.c
> > > index 7d25102..305e73d 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > > @@ -158,9 +158,10 @@ static void dw_pcie_writel_ob_unroll(struct
> > dw_pcie *pci, u32 index, u32 reg,
> > >  	dw_pcie_writel_atu(pci, offset + reg, val);  }
> > >
> > > -static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, int
> > index,
> > > -					     int type, u64 cpu_addr,
> > > -					     u64 pci_addr, u32 size)
> > > +static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8
> > func_no,
> > > +					     int index, int type,
> > > +					     u64 cpu_addr, u64 pci_addr,
> > > +					     u32 size)
> > >  {
> > >  	u32 retries, val;
> > >
> > > @@ -175,7 +176,7 @@ static void
> > dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, int index,
> > >  	dw_pcie_writel_ob_unroll(pci, index, PCIE_ATU_UNR_UPPER_TARGET,
> > >  				 upper_32_bits(pci_addr));
> > >  	dw_pcie_writel_ob_unroll(pci, index, PCIE_ATU_UNR_REGION_CTRL1,
> > > -				 type);
> > > +				 type | PCIE_ATU_FUNC_NUM(func_no));
> > 
> > Much better :)
> 
> Do you mean that use the expression "a? b:c"
> 
> > 
> > >  	dw_pcie_writel_ob_unroll(pci, index, PCIE_ATU_UNR_REGION_CTRL2,
> > >  				 PCIE_ATU_ENABLE);
> > >
> > > @@ -194,8 +195,9 @@ static void
> > dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, int index,
> > >  	dev_err(pci->dev, "Outbound iATU is not being enabled\n");  }
> > >
> > > -void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type,
> > > -			       u64 cpu_addr, u64 pci_addr, u32 size)
> > > +static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8
> > func_no,
> > > +					int index, int type, u64 cpu_addr,
> > > +					u64 pci_addr, u32 size)
> > >  {
> > >  	u32 retries, val;
> > >
> > > @@ -203,8 +205,8 @@ void dw_pcie_prog_outbound_atu(struct dw_pcie
> > *pci, int index, int type,
> > >  		cpu_addr = pci->ops->cpu_addr_fixup(pci, cpu_addr);
> > >
> > >  	if (pci->iatu_unroll_enabled) {
> > > -		dw_pcie_prog_outbound_atu_unroll(pci, index, type, cpu_addr,
> > > -						 pci_addr, size);
> > > +		dw_pcie_prog_outbound_atu_unroll(pci, func_no, index, type,
> > > +						 cpu_addr, pci_addr, size);
> > >  		return;
> > >  	}
> > >
> > 
> > 
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.h
> > > b/drivers/pci/controller/dwc/pcie-designware.h
> > > index ffed084..a0fdbf7 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > > @@ -71,9 +71,11 @@
> > >  #define PCIE_ATU_TYPE_IO		0x2
> > >  #define PCIE_ATU_TYPE_CFG0		0x4
> > >  #define PCIE_ATU_TYPE_CFG1		0x5
> > > +#define PCIE_ATU_FUNC_NUM(pf)           (pf << 20)
> > 
> > "Macro argument 'pf' may be better as '(pf)' to avoid precedence issues"
> > 
> > >  #define PCIE_ATU_CR2			0x908
> > >  #define PCIE_ATU_ENABLE			BIT(31)
> > >  #define PCIE_ATU_BAR_MODE_ENABLE	BIT(30)
> > > +#define PCIE_ATU_FUNC_NUM_MATCH_EN      BIT(19)
> > >  #define PCIE_ATU_LOWER_BASE		0x90C
> > >  #define PCIE_ATU_UPPER_BASE		0x910
> > >  #define PCIE_ATU_LIMIT			0x914
> > > @@ -197,6 +199,7 @@ struct dw_pcie_ep_ops {
> > >  	int	(*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
> > >  			     enum pci_epc_irq_type type, u16 interrupt_num);
> > >  	const struct pci_epc_features* (*get_features)(struct dw_pcie_ep
> > > *ep);
> > > +	unsigned int (*func_conf_select)(struct dw_pcie_ep *ep, u8 func_no);
> > 
> > Given that this function will return an offset, I'm not sure the name you have
> > is suitable. Something like get_pf_offset or similar is more descriptive.
> 
> As above explain, my initial view is that this function can return 0 or offset depends on
> the platform implement mechanism, so I named it func_conf_select, I think add a
> comment for this function, like this:
> /*
>  * provide a method to implement the method of different func config space access,
>  * if use offset method, return the offset from dbi_base, if your register method, implement
>  * the code in this callback function and return 0.
>  */
> How about it?

This means that func_conf_select can never (easily) indicate an error to the
caller as this would change the offset. Where func_conf_select doesn't change
the offset there probably isn't much else it can do instead (unless it was
responsible for doing the write as well). So I'm not sure how well this approach
works.

Thanks,

Andrew Murray

> 
> > 
> > Thanks,
> > 
> > Andrew Murray
> > 
> > >  };
> > >
> > >  struct dw_pcie_ep {
> > > @@ -265,8 +268,12 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci);
> > > void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index,
> > >  			       int type, u64 cpu_addr, u64 pci_addr,
> > >  			       u32 size);
> > > -int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int bar,
> > > -			     u64 cpu_addr, enum dw_pcie_as_type as_type);
> > > +void dw_pcie_prog_ep_outbound_atu(struct dw_pcie *pci, u8 func_no, int
> > index,
> > > +				  int type, u64 cpu_addr, u64 pci_addr,
> > > +				  u32 size);
> > > +int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, u8 func_no, int index,
> > > +			     int bar, u64 cpu_addr,
> > > +			     enum dw_pcie_as_type as_type);
> > >  void dw_pcie_disable_atu(struct dw_pcie *pci, int index,
> > >  			 enum dw_pcie_region_type type);
> > >  void dw_pcie_setup(struct dw_pcie *pci);
> > > --
> > > 2.9.5
> > >

^ permalink raw reply

* Re: [PATCH] perf arch powerpc: Sync powerpc syscall.tbl
From: Arnaldo Carvalho de Melo @ 2019-08-27 13:24 UTC (permalink / raw)
  To: Naveen N. Rao; +Cc: Ravi Bangoria, linuxppc-dev, linux-kernel, Nicholas Piggin
In-Reply-To: <20190827071458.19897-1-naveen.n.rao@linux.vnet.ibm.com>

Em Tue, Aug 27, 2019 at 12:44:58PM +0530, Naveen N. Rao escreveu:
> Copy over powerpc syscall.tbl to grab changes from the below commits:
>   commit cee3536d24a1 ("powerpc: Wire up clone3 syscall")
>   commit 1a271a68e030 ("arch: mark syscall number 435 reserved for clone3")
>   commit 7615d9e1780e ("arch: wire-up pidfd_open()")
>   commit d8076bdb56af ("uapi: Wire up the mount API syscalls on non-x86 arches [ver #2]")
>   commit 39036cd27273 ("arch: add pidfd and io_uring syscalls everywhere")
>   commit 48166e6ea47d ("y2038: add 64-bit time_t syscalls to all 32-bit architectures")
>   commit d33c577cccd0 ("y2038: rename old time and utime syscalls")
>   commit 00bf25d693e7 ("y2038: use time32 syscall names on 32-bit")
>   commit 8dabe7245bbc ("y2038: syscalls: rename y2038 compat syscalls")
>   commit 0d6040d46817 ("arch: add split IPC system calls where needed")
> 
> Reported-by: Nicholas Piggin <npiggin@gmail.com>

Thanks, applied to perf/core.

- Arnaldo

> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
>  .../arch/powerpc/entry/syscalls/syscall.tbl   | 146 ++++++++++++++----
>  1 file changed, 119 insertions(+), 27 deletions(-)
> 
> diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
> index db3bbb8744af..43f736ed47f2 100644
> --- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
> +++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
> @@ -20,7 +20,9 @@
>  10	common	unlink				sys_unlink
>  11	nospu	execve				sys_execve			compat_sys_execve
>  12	common	chdir				sys_chdir
> -13	common	time				sys_time			compat_sys_time
> +13	32	time				sys_time32
> +13	64	time				sys_time
> +13	spu	time				sys_time
>  14	common	mknod				sys_mknod
>  15	common	chmod				sys_chmod
>  16	common	lchown				sys_lchown
> @@ -36,14 +38,17 @@
>  22	spu	umount				sys_ni_syscall
>  23	common	setuid				sys_setuid
>  24	common	getuid				sys_getuid
> -25	common	stime				sys_stime			compat_sys_stime
> +25	32	stime				sys_stime32
> +25	64	stime				sys_stime
> +25	spu	stime				sys_stime
>  26	nospu	ptrace				sys_ptrace			compat_sys_ptrace
>  27	common	alarm				sys_alarm
>  28	32	oldfstat			sys_fstat			sys_ni_syscall
>  28	64	oldfstat			sys_ni_syscall
>  28	spu	oldfstat			sys_ni_syscall
>  29	nospu	pause				sys_pause
> -30	nospu	utime				sys_utime			compat_sys_utime
> +30	32	utime				sys_utime32
> +30	64	utime				sys_utime
>  31	common	stty				sys_ni_syscall
>  32	common	gtty				sys_ni_syscall
>  33	common	access				sys_access
> @@ -157,7 +162,9 @@
>  121	common	setdomainname			sys_setdomainname
>  122	common	uname				sys_newuname
>  123	common	modify_ldt			sys_ni_syscall
> -124	common	adjtimex			sys_adjtimex			compat_sys_adjtimex
> +124	32	adjtimex			sys_adjtimex_time32
> +124	64	adjtimex			sys_adjtimex
> +124	spu	adjtimex			sys_adjtimex
>  125	common	mprotect			sys_mprotect
>  126	32	sigprocmask			sys_sigprocmask			compat_sys_sigprocmask
>  126	64	sigprocmask			sys_ni_syscall
> @@ -198,8 +205,12 @@
>  158	common	sched_yield			sys_sched_yield
>  159	common	sched_get_priority_max		sys_sched_get_priority_max
>  160	common	sched_get_priority_min		sys_sched_get_priority_min
> -161	common	sched_rr_get_interval		sys_sched_rr_get_interval	compat_sys_sched_rr_get_interval
> -162	common	nanosleep			sys_nanosleep			compat_sys_nanosleep
> +161	32	sched_rr_get_interval		sys_sched_rr_get_interval_time32
> +161	64	sched_rr_get_interval		sys_sched_rr_get_interval
> +161	spu	sched_rr_get_interval		sys_sched_rr_get_interval
> +162	32	nanosleep			sys_nanosleep_time32
> +162	64	nanosleep			sys_nanosleep
> +162	spu	nanosleep			sys_nanosleep
>  163	common	mremap				sys_mremap
>  164	common	setresuid			sys_setresuid
>  165	common	getresuid			sys_getresuid
> @@ -213,7 +224,8 @@
>  173	nospu	rt_sigaction			sys_rt_sigaction		compat_sys_rt_sigaction
>  174	nospu	rt_sigprocmask			sys_rt_sigprocmask		compat_sys_rt_sigprocmask
>  175	nospu	rt_sigpending			sys_rt_sigpending		compat_sys_rt_sigpending
> -176	nospu	rt_sigtimedwait			sys_rt_sigtimedwait		compat_sys_rt_sigtimedwait
> +176	32	rt_sigtimedwait			sys_rt_sigtimedwait_time32	compat_sys_rt_sigtimedwait_time32
> +176	64	rt_sigtimedwait			sys_rt_sigtimedwait
>  177	nospu 	rt_sigqueueinfo			sys_rt_sigqueueinfo		compat_sys_rt_sigqueueinfo
>  178	nospu 	rt_sigsuspend			sys_rt_sigsuspend		compat_sys_rt_sigsuspend
>  179	common	pread64				sys_pread64			compat_sys_pread64
> @@ -260,7 +272,9 @@
>  218	common	removexattr			sys_removexattr
>  219	common	lremovexattr			sys_lremovexattr
>  220	common	fremovexattr			sys_fremovexattr
> -221	common	futex				sys_futex			compat_sys_futex
> +221	32	futex				sys_futex_time32
> +221	64	futex				sys_futex
> +221	spu	futex				sys_futex
>  222	common	sched_setaffinity		sys_sched_setaffinity		compat_sys_sched_setaffinity
>  223	common	sched_getaffinity		sys_sched_getaffinity		compat_sys_sched_getaffinity
>  # 224 unused
> @@ -268,7 +282,9 @@
>  226	32	sendfile64			sys_sendfile64			compat_sys_sendfile64
>  227	common	io_setup			sys_io_setup			compat_sys_io_setup
>  228	common	io_destroy			sys_io_destroy
> -229	common	io_getevents			sys_io_getevents		compat_sys_io_getevents
> +229	32	io_getevents			sys_io_getevents_time32
> +229	64	io_getevents			sys_io_getevents
> +229	spu	io_getevents			sys_io_getevents
>  230	common	io_submit			sys_io_submit			compat_sys_io_submit
>  231	common	io_cancel			sys_io_cancel
>  232	nospu	set_tid_address			sys_set_tid_address
> @@ -280,19 +296,33 @@
>  238	common	epoll_wait			sys_epoll_wait
>  239	common	remap_file_pages		sys_remap_file_pages
>  240	common	timer_create			sys_timer_create		compat_sys_timer_create
> -241	common	timer_settime			sys_timer_settime		compat_sys_timer_settime
> -242	common	timer_gettime			sys_timer_gettime		compat_sys_timer_gettime
> +241	32	timer_settime			sys_timer_settime32
> +241	64	timer_settime			sys_timer_settime
> +241	spu	timer_settime			sys_timer_settime
> +242	32	timer_gettime			sys_timer_gettime32
> +242	64	timer_gettime			sys_timer_gettime
> +242	spu	timer_gettime			sys_timer_gettime
>  243	common	timer_getoverrun		sys_timer_getoverrun
>  244	common	timer_delete			sys_timer_delete
> -245	common	clock_settime			sys_clock_settime		compat_sys_clock_settime
> -246	common	clock_gettime			sys_clock_gettime		compat_sys_clock_gettime
> -247	common	clock_getres			sys_clock_getres		compat_sys_clock_getres
> -248	common	clock_nanosleep			sys_clock_nanosleep		compat_sys_clock_nanosleep
> +245	32	clock_settime			sys_clock_settime32
> +245	64	clock_settime			sys_clock_settime
> +245	spu	clock_settime			sys_clock_settime
> +246	32	clock_gettime			sys_clock_gettime32
> +246	64	clock_gettime			sys_clock_gettime
> +246	spu	clock_gettime			sys_clock_gettime
> +247	32	clock_getres			sys_clock_getres_time32
> +247	64	clock_getres			sys_clock_getres
> +247	spu	clock_getres			sys_clock_getres
> +248	32	clock_nanosleep			sys_clock_nanosleep_time32
> +248	64	clock_nanosleep			sys_clock_nanosleep
> +248	spu	clock_nanosleep			sys_clock_nanosleep
>  249	32	swapcontext			ppc_swapcontext			ppc32_swapcontext
>  249	64	swapcontext			ppc64_swapcontext
>  249	spu	swapcontext			sys_ni_syscall
>  250	common	tgkill				sys_tgkill
> -251	common	utimes				sys_utimes			compat_sys_utimes
> +251	32	utimes				sys_utimes_time32
> +251	64	utimes				sys_utimes
> +251	spu	utimes				sys_utimes
>  252	common	statfs64			sys_statfs64			compat_sys_statfs64
>  253	common	fstatfs64			sys_fstatfs64			compat_sys_fstatfs64
>  254	32	fadvise64_64			ppc_fadvise64_64
> @@ -308,8 +338,10 @@
>  261	nospu	set_mempolicy			sys_set_mempolicy		compat_sys_set_mempolicy
>  262	nospu	mq_open				sys_mq_open			compat_sys_mq_open
>  263	nospu	mq_unlink			sys_mq_unlink
> -264	nospu	mq_timedsend			sys_mq_timedsend		compat_sys_mq_timedsend
> -265	nospu	mq_timedreceive			sys_mq_timedreceive		compat_sys_mq_timedreceive
> +264	32	mq_timedsend			sys_mq_timedsend_time32
> +264	64	mq_timedsend			sys_mq_timedsend
> +265	32	mq_timedreceive			sys_mq_timedreceive_time32
> +265	64	mq_timedreceive			sys_mq_timedreceive
>  266	nospu	mq_notify			sys_mq_notify			compat_sys_mq_notify
>  267	nospu	mq_getsetattr			sys_mq_getsetattr		compat_sys_mq_getsetattr
>  268	nospu	kexec_load			sys_kexec_load			compat_sys_kexec_load
> @@ -324,8 +356,10 @@
>  277	nospu	inotify_rm_watch		sys_inotify_rm_watch
>  278	nospu	spu_run				sys_spu_run
>  279	nospu	spu_create			sys_spu_create
> -280	nospu	pselect6			sys_pselect6			compat_sys_pselect6
> -281	nospu	ppoll				sys_ppoll			compat_sys_ppoll
> +280	32	pselect6			sys_pselect6_time32		compat_sys_pselect6_time32
> +280	64	pselect6			sys_pselect6
> +281	32	ppoll				sys_ppoll_time32		compat_sys_ppoll_time32
> +281	64	ppoll				sys_ppoll
>  282	common	unshare				sys_unshare
>  283	common	splice				sys_splice
>  284	common	tee				sys_tee
> @@ -334,7 +368,9 @@
>  287	common	mkdirat				sys_mkdirat
>  288	common	mknodat				sys_mknodat
>  289	common	fchownat			sys_fchownat
> -290	common	futimesat			sys_futimesat			compat_sys_futimesat
> +290	32	futimesat			sys_futimesat_time32
> +290	64	futimesat			sys_futimesat
> +290	spu	utimesat			sys_futimesat
>  291	32	fstatat64			sys_fstatat64
>  291	64	newfstatat			sys_newfstatat
>  291	spu	newfstatat			sys_newfstatat
> @@ -350,15 +386,21 @@
>  301	common	move_pages			sys_move_pages			compat_sys_move_pages
>  302	common	getcpu				sys_getcpu
>  303	nospu	epoll_pwait			sys_epoll_pwait			compat_sys_epoll_pwait
> -304	common	utimensat			sys_utimensat			compat_sys_utimensat
> +304	32	utimensat			sys_utimensat_time32
> +304	64	utimensat			sys_utimensat
> +304	spu	utimensat			sys_utimensat
>  305	common	signalfd			sys_signalfd			compat_sys_signalfd
>  306	common	timerfd_create			sys_timerfd_create
>  307	common	eventfd				sys_eventfd
>  308	common	sync_file_range2		sys_sync_file_range2		compat_sys_sync_file_range2
>  309	nospu	fallocate			sys_fallocate			compat_sys_fallocate
>  310	nospu	subpage_prot			sys_subpage_prot
> -311	common	timerfd_settime			sys_timerfd_settime		compat_sys_timerfd_settime
> -312	common	timerfd_gettime			sys_timerfd_gettime		compat_sys_timerfd_gettime
> +311	32	timerfd_settime			sys_timerfd_settime32
> +311	64	timerfd_settime			sys_timerfd_settime
> +311	spu	timerfd_settime			sys_timerfd_settime
> +312	32	timerfd_gettime			sys_timerfd_gettime32
> +312	64	timerfd_gettime			sys_timerfd_gettime
> +312	spu	timerfd_gettime			sys_timerfd_gettime
>  313	common	signalfd4			sys_signalfd4			compat_sys_signalfd4
>  314	common	eventfd2			sys_eventfd2
>  315	common	epoll_create1			sys_epoll_create1
> @@ -389,11 +431,15 @@
>  340	common	getsockopt			sys_getsockopt			compat_sys_getsockopt
>  341	common	sendmsg				sys_sendmsg			compat_sys_sendmsg
>  342	common	recvmsg				sys_recvmsg			compat_sys_recvmsg
> -343	common	recvmmsg			sys_recvmmsg			compat_sys_recvmmsg
> +343	32	recvmmsg			sys_recvmmsg_time32		compat_sys_recvmmsg_time32
> +343	64	recvmmsg			sys_recvmmsg
> +343	spu	recvmmsg			sys_recvmmsg
>  344	common	accept4				sys_accept4
>  345	common	name_to_handle_at		sys_name_to_handle_at
>  346	common	open_by_handle_at		sys_open_by_handle_at		compat_sys_open_by_handle_at
> -347	common	clock_adjtime			sys_clock_adjtime		compat_sys_clock_adjtime
> +347	32	clock_adjtime			sys_clock_adjtime32
> +347	64	clock_adjtime			sys_clock_adjtime
> +347	spu	clock_adjtime			sys_clock_adjtime
>  348	common	syncfs				sys_syncfs
>  349	common	sendmmsg			sys_sendmmsg			compat_sys_sendmmsg
>  350	common	setns				sys_setns
> @@ -414,6 +460,7 @@
>  363	spu	switch_endian			sys_ni_syscall
>  364	common	userfaultfd			sys_userfaultfd
>  365	common	membarrier			sys_membarrier
> +# 366-377 originally left for IPC, now unused
>  378	nospu	mlock2				sys_mlock2
>  379	nospu	copy_file_range			sys_copy_file_range
>  380	common	preadv2				sys_preadv2			compat_sys_preadv2
> @@ -424,4 +471,49 @@
>  385	nospu	pkey_free			sys_pkey_free
>  386	nospu	pkey_mprotect			sys_pkey_mprotect
>  387	nospu	rseq				sys_rseq
> -388	nospu	io_pgetevents			sys_io_pgetevents		compat_sys_io_pgetevents
> +388	32	io_pgetevents			sys_io_pgetevents_time32	compat_sys_io_pgetevents
> +388	64	io_pgetevents			sys_io_pgetevents
> +# room for arch specific syscalls
> +392	64	semtimedop			sys_semtimedop
> +393	common	semget				sys_semget
> +394	common	semctl				sys_semctl			compat_sys_semctl
> +395	common	shmget				sys_shmget
> +396	common	shmctl				sys_shmctl			compat_sys_shmctl
> +397	common	shmat				sys_shmat			compat_sys_shmat
> +398	common	shmdt				sys_shmdt
> +399	common	msgget				sys_msgget
> +400	common	msgsnd				sys_msgsnd			compat_sys_msgsnd
> +401	common	msgrcv				sys_msgrcv			compat_sys_msgrcv
> +402	common	msgctl				sys_msgctl			compat_sys_msgctl
> +403	32	clock_gettime64			sys_clock_gettime		sys_clock_gettime
> +404	32	clock_settime64			sys_clock_settime		sys_clock_settime
> +405	32	clock_adjtime64			sys_clock_adjtime		sys_clock_adjtime
> +406	32	clock_getres_time64		sys_clock_getres		sys_clock_getres
> +407	32	clock_nanosleep_time64		sys_clock_nanosleep		sys_clock_nanosleep
> +408	32	timer_gettime64			sys_timer_gettime		sys_timer_gettime
> +409	32	timer_settime64			sys_timer_settime		sys_timer_settime
> +410	32	timerfd_gettime64		sys_timerfd_gettime		sys_timerfd_gettime
> +411	32	timerfd_settime64		sys_timerfd_settime		sys_timerfd_settime
> +412	32	utimensat_time64		sys_utimensat			sys_utimensat
> +413	32	pselect6_time64			sys_pselect6			compat_sys_pselect6_time64
> +414	32	ppoll_time64			sys_ppoll			compat_sys_ppoll_time64
> +416	32	io_pgetevents_time64		sys_io_pgetevents		sys_io_pgetevents
> +417	32	recvmmsg_time64			sys_recvmmsg			compat_sys_recvmmsg_time64
> +418	32	mq_timedsend_time64		sys_mq_timedsend		sys_mq_timedsend
> +419	32	mq_timedreceive_time64		sys_mq_timedreceive		sys_mq_timedreceive
> +420	32	semtimedop_time64		sys_semtimedop			sys_semtimedop
> +421	32	rt_sigtimedwait_time64		sys_rt_sigtimedwait		compat_sys_rt_sigtimedwait_time64
> +422	32	futex_time64			sys_futex			sys_futex
> +423	32	sched_rr_get_interval_time64	sys_sched_rr_get_interval	sys_sched_rr_get_interval
> +424	common	pidfd_send_signal		sys_pidfd_send_signal
> +425	common	io_uring_setup			sys_io_uring_setup
> +426	common	io_uring_enter			sys_io_uring_enter
> +427	common	io_uring_register		sys_io_uring_register
> +428	common	open_tree			sys_open_tree
> +429	common	move_mount			sys_move_mount
> +430	common	fsopen				sys_fsopen
> +431	common	fsconfig			sys_fsconfig
> +432	common	fsmount				sys_fsmount
> +433	common	fspick				sys_fspick
> +434	common	pidfd_open			sys_pidfd_open
> +435	nospu	clone3				ppc_clone3
> -- 
> 2.23.0

-- 

- Arnaldo

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox