[PATCH 3/4] ASoC: fsl: Let imx-audio-rpmsg register platform device for card

2024-03-05 Thread Chancel Liu
Let imx-audio-rpmsg register platform device for card. So that card
register and unregister can be controlled by rpmsg driver's register
and unregister.

Signed-off-by: Chancel Liu 
---
 sound/soc/fsl/fsl_rpmsg.c   | 11 ---
 sound/soc/fsl/imx-audio-rpmsg.c | 18 +-
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/sound/soc/fsl/fsl_rpmsg.c b/sound/soc/fsl/fsl_rpmsg.c
index 00852f174a69..53bd517e59d6 100644
--- a/sound/soc/fsl/fsl_rpmsg.c
+++ b/sound/soc/fsl/fsl_rpmsg.c
@@ -240,17 +240,6 @@ static int fsl_rpmsg_probe(struct platform_device *pdev)
if (ret)
goto err_pm_disable;
 
-   rpmsg->card_pdev = platform_device_register_data(>dev,
-"imx-audio-rpmsg",
-PLATFORM_DEVID_AUTO,
-NULL,
-0);
-   if (IS_ERR(rpmsg->card_pdev)) {
-   dev_err(>dev, "failed to register rpmsg card\n");
-   ret = PTR_ERR(rpmsg->card_pdev);
-   goto err_pm_disable;
-   }
-
return 0;
 
 err_pm_disable:
diff --git a/sound/soc/fsl/imx-audio-rpmsg.c b/sound/soc/fsl/imx-audio-rpmsg.c
index 40820d5ad92d..a6817ce1e92a 100644
--- a/sound/soc/fsl/imx-audio-rpmsg.c
+++ b/sound/soc/fsl/imx-audio-rpmsg.c
@@ -12,6 +12,7 @@
  */
 struct imx_audio_rpmsg {
struct platform_device *rpmsg_pdev;
+   struct platform_device *card_pdev;
 };
 
 static int imx_audio_rpmsg_cb(struct rpmsg_device *rpdev, void *data, int len,
@@ -95,6 +96,17 @@ static int imx_audio_rpmsg_probe(struct rpmsg_device *rpdev)
ret = PTR_ERR(data->rpmsg_pdev);
}
 
+   data->card_pdev = platform_device_register_data(>dev,
+   "imx-audio-rpmsg",
+   PLATFORM_DEVID_AUTO,
+   rpdev->id.name,
+   strlen(rpdev->id.name));
+   if (IS_ERR(data->card_pdev)) {
+   dev_err(>dev, "failed to register rpmsg card.\n");
+   ret = PTR_ERR(data->card_pdev);
+   goto fail;
+   }
+
return ret;
 }
 
@@ -105,6 +117,9 @@ static void imx_audio_rpmsg_remove(struct rpmsg_device 
*rpdev)
if (data->rpmsg_pdev)
platform_device_unregister(data->rpmsg_pdev);
 
+   if (data->card_pdev)
+   platform_device_unregister(data->card_pdev);
+
dev_info(>dev, "audio rpmsg driver is removed\n");
 }
 
@@ -113,6 +128,7 @@ static struct rpmsg_device_id imx_audio_rpmsg_id_table[] = {
{ .name = "rpmsg-micfil-channel" },
{ },
 };
+MODULE_DEVICE_TABLE(rpmsg, imx_audio_rpmsg_id_table);
 
 static struct rpmsg_driver imx_audio_rpmsg_driver = {
.drv.name   = "imx_audio_rpmsg",
@@ -126,5 +142,5 @@ module_rpmsg_driver(imx_audio_rpmsg_driver);
 
 MODULE_DESCRIPTION("Freescale SoC Audio RPMSG interface");
 MODULE_AUTHOR("Shengjiu Wang ");
-MODULE_ALIAS("platform:imx_audio_rpmsg");
+MODULE_ALIAS("rpmsg:imx_audio_rpmsg");
 MODULE_LICENSE("GPL v2");
-- 
2.43.0



[PATCH 2/4] ASoC: fsl: imx-audio-rpmsg: Register device with rpmsg channel name

2024-03-05 Thread Chancel Liu
This rpmsg driver registers device for ASoC platform driver. To align
with platform driver use rpmsg channel name to create device.

Signed-off-by: Chancel Liu 
---
 sound/soc/fsl/imx-audio-rpmsg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/fsl/imx-audio-rpmsg.c b/sound/soc/fsl/imx-audio-rpmsg.c
index 289e47c03d40..40820d5ad92d 100644
--- a/sound/soc/fsl/imx-audio-rpmsg.c
+++ b/sound/soc/fsl/imx-audio-rpmsg.c
@@ -87,8 +87,8 @@ static int imx_audio_rpmsg_probe(struct rpmsg_device *rpdev)
 
/* Register platform driver for rpmsg routine */
data->rpmsg_pdev = platform_device_register_data(>dev,
-IMX_PCM_DRV_NAME,
-PLATFORM_DEVID_AUTO,
+rpdev->id.name,
+PLATFORM_DEVID_NONE,
 NULL, 0);
if (IS_ERR(data->rpmsg_pdev)) {
dev_err(>dev, "failed to register rpmsg platform.\n");
-- 
2.43.0



[PATCH 1/4] ASoC: fsl: imx_pcm_rpmsg: Register component with rpmsg channel name

2024-03-05 Thread Chancel Liu
Machine driver uses rpmsg channel name to link this platform component.
However if the component is re-registerd card will not find this new
created component in snd_soc_try_rebind_card().

Explicitly register this component with rpmsg channel name so that
card can always find this component.

Signed-off-by: Chancel Liu 
---
 sound/soc/fsl/imx-pcm-rpmsg.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c
index fb9244c1e9c5..2b9e4bb5e0f7 100644
--- a/sound/soc/fsl/imx-pcm-rpmsg.c
+++ b/sound/soc/fsl/imx-pcm-rpmsg.c
@@ -732,9 +732,6 @@ static int imx_rpmsg_pcm_probe(struct platform_device *pdev)
goto fail;
}
 
-   /* platform component name is used by machine driver to link with */
-   component->name = info->rpdev->id.name;
-
 #ifdef CONFIG_DEBUG_FS
component->debugfs_prefix = "rpmsg";
 #endif
@@ -822,9 +819,17 @@ static const struct dev_pm_ops imx_rpmsg_pcm_pm_ops = {
imx_rpmsg_pcm_resume)
 };
 
+static const struct platform_device_id imx_rpmsg_pcm_id_table[] = {
+   { .name = "rpmsg-audio-channel" },
+   { .name = "rpmsg-micfil-channel" },
+   { }
+};
+MODULE_DEVICE_TABLE(platform, imx_rpmsg_pcm_id_table);
+
 static struct platform_driver imx_pcm_rpmsg_driver = {
.probe  = imx_rpmsg_pcm_probe,
.remove_new = imx_rpmsg_pcm_remove,
+   .id_table = imx_rpmsg_pcm_id_table,
.driver = {
.name = IMX_PCM_DRV_NAME,
.pm = _rpmsg_pcm_pm_ops,
-- 
2.43.0



[PATCH 4/4] ASoC: fsl: imx-rpmsg: Update to correct DT node

2024-03-05 Thread Chancel Liu
Platform device for card to probe is registered in imx-audio-rpmsg.
According to this change DT node of ASoC CPU DAI device is updated.

Signed-off-by: Chancel Liu 
---
 sound/soc/fsl/imx-rpmsg.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index e5bd63dab10c..2686125b3043 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -108,10 +108,9 @@ static int imx_rpmsg_late_probe(struct snd_soc_card *card)
 static int imx_rpmsg_probe(struct platform_device *pdev)
 {
struct snd_soc_dai_link_component *dlc;
-   struct device *dev = pdev->dev.parent;
/* rpmsg_pdev is the platform device for the rpmsg node that probed us 
*/
-   struct platform_device *rpmsg_pdev = to_platform_device(dev);
-   struct device_node *np = rpmsg_pdev->dev.of_node;
+   struct platform_device *rpmsg_pdev = NULL;
+   struct device_node *np = NULL;
struct of_phandle_args args;
const char *platform_name;
struct imx_rpmsg *data;
@@ -127,6 +126,22 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
goto fail;
}
 
+   if (!strcmp(pdev->dev.platform_data, "rpmsg-micfil-channel"))
+   np = of_find_node_by_name(NULL, "rpmsg_micfil");
+   else
+   np = of_find_node_by_name(NULL, "rpmsg_audio");
+   if (!np) {
+   dev_err(>dev, "failed to parse node\n");
+   ret = -EINVAL;
+   goto fail;
+   }
+   rpmsg_pdev = of_find_device_by_node(np);
+   if (!rpmsg_pdev) {
+   dev_err(>dev, "failed to parse platform device\n");
+   ret = -EINVAL;
+   goto fail;
+   }
+
ret = of_reserved_mem_device_init_by_idx(>dev, np, 0);
if (ret)
dev_warn(>dev, "no reserved DMA memory\n");
-- 
2.43.0



[PATCH 0/4] ASoC: fsl: Support register and unregister rpmsg sound card through remoteproc

2024-03-05 Thread Chancel Liu
echo /lib/firmware/fw.elf > /sys/class/remoteproc/remoteproc0/firmware
(A) echo start > /sys/class/remoteproc/remoteproc0/state
(B) echo stop > /sys/class/remoteproc/remoteproc0/state

The rpmsg sound card is registered in (A) and unregistered in (B).
After "start", imx-audio-rpmsg registers devices for ASoC platform driver
and machine driver. Then sound card is registered. After "stop",
imx-audio-rpmsg unregisters devices for ASoC platform driver and machine
driver. Then sound card is unregistered.

Chancel Liu (4):
  ASoC: fsl: imx_pcm_rpmsg: Register component with rpmsg channel name
  ASoC: fsl: imx-audio-rpmsg: Register device with rpmsg channel name
  ASoC: fsl: Let imx-audio-rpmsg register platform device for card
  ASoC: fsl: imx-rpmsg: Update to correct DT node

 sound/soc/fsl/fsl_rpmsg.c   | 11 ---
 sound/soc/fsl/imx-audio-rpmsg.c | 22 +++---
 sound/soc/fsl/imx-pcm-rpmsg.c   | 11 ---
 sound/soc/fsl/imx-rpmsg.c   | 21 ++---
 4 files changed, 45 insertions(+), 20 deletions(-)

--
2.43.0



Re: [PATCH v3 10/10] mm/treewide: Align up pXd_leaf() retval across archs

2024-03-05 Thread Mike Rapoport
On Tue, Mar 05, 2024 at 12:37:50PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> Even if pXd_leaf() API is defined globally, it's not clear on the retval,
> and there are three types used (bool, int, unsigned log).
> 
> Always return a boolean for pXd_leaf() APIs.
> 
> Suggested-by: Jason Gunthorpe 
> Signed-off-by: Peter Xu 

Reviewed-by: Mike Rapoport (IBM) 

> ---
>  arch/riscv/include/asm/pgtable-64.h | 2 +-
>  arch/riscv/include/asm/pgtable.h| 2 +-
>  arch/s390/include/asm/pgtable.h | 4 ++--
>  arch/sparc/include/asm/pgtable_64.h | 4 ++--
>  arch/x86/include/asm/pgtable.h  | 8 
>  include/linux/pgtable.h | 8 
>  6 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/riscv/include/asm/pgtable-64.h 
> b/arch/riscv/include/asm/pgtable-64.h
> index b42017d76924..2c7e1661db01 100644
> --- a/arch/riscv/include/asm/pgtable-64.h
> +++ b/arch/riscv/include/asm/pgtable-64.h
> @@ -190,7 +190,7 @@ static inline int pud_bad(pud_t pud)
>  }
>  
>  #define pud_leaf pud_leaf
> -static inline int pud_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
>  {
>   return pud_present(pud) && (pud_val(pud) & _PAGE_LEAF);
>  }
> diff --git a/arch/riscv/include/asm/pgtable.h 
> b/arch/riscv/include/asm/pgtable.h
> index add5cd30ab34..6839520dbcb1 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -241,7 +241,7 @@ static inline int pmd_bad(pmd_t pmd)
>  }
>  
>  #define pmd_leaf pmd_leaf
> -static inline int pmd_leaf(pmd_t pmd)
> +static inline bool pmd_leaf(pmd_t pmd)
>  {
>   return pmd_present(pmd) && (pmd_val(pmd) & _PAGE_LEAF);
>  }
> diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
> index 9e08af5b9247..60950e7a25f5 100644
> --- a/arch/s390/include/asm/pgtable.h
> +++ b/arch/s390/include/asm/pgtable.h
> @@ -706,7 +706,7 @@ static inline int pud_none(pud_t pud)
>  }
>  
>  #define pud_leaf pud_leaf
> -static inline int pud_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
>  {
>   if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) != _REGION_ENTRY_TYPE_R3)
>   return 0;
> @@ -714,7 +714,7 @@ static inline int pud_leaf(pud_t pud)
>  }
>  
>  #define pmd_leaf pmd_leaf
> -static inline int pmd_leaf(pmd_t pmd)
> +static inline bool pmd_leaf(pmd_t pmd)
>  {
>   return (pmd_val(pmd) & _SEGMENT_ENTRY_LARGE) != 0;
>  }
> diff --git a/arch/sparc/include/asm/pgtable_64.h 
> b/arch/sparc/include/asm/pgtable_64.h
> index 6ff0a28d5fd1..4d1bafaba942 100644
> --- a/arch/sparc/include/asm/pgtable_64.h
> +++ b/arch/sparc/include/asm/pgtable_64.h
> @@ -681,7 +681,7 @@ static inline unsigned long pte_special(pte_t pte)
>  }
>  
>  #define pmd_leaf pmd_leaf
> -static inline unsigned long pmd_leaf(pmd_t pmd)
> +static inline bool pmd_leaf(pmd_t pmd)
>  {
>   pte_t pte = __pte(pmd_val(pmd));
>  
> @@ -868,7 +868,7 @@ static inline pmd_t *pud_pgtable(pud_t pud)
>  #define p4d_page(p4d)NULL
>  
>  #define pud_leaf pud_leaf
> -static inline unsigned long pud_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
>  {
>   pte_t pte = __pte(pud_val(pud));
>  
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index cfc84c55d0e6..7621a5acb13e 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -252,7 +252,7 @@ static inline unsigned long pgd_pfn(pgd_t pgd)
>  }
>  
>  #define p4d_leaf p4d_leaf
> -static inline int p4d_leaf(p4d_t p4d)
> +static inline bool p4d_leaf(p4d_t p4d)
>  {
>   /* No 512 GiB pages yet */
>   return 0;
> @@ -261,7 +261,7 @@ static inline int p4d_leaf(p4d_t p4d)
>  #define pte_page(pte)pfn_to_page(pte_pfn(pte))
>  
>  #define pmd_leaf pmd_leaf
> -static inline int pmd_leaf(pmd_t pte)
> +static inline bool pmd_leaf(pmd_t pte)
>  {
>   return pmd_flags(pte) & _PAGE_PSE;
>  }
> @@ -1086,7 +1086,7 @@ static inline pmd_t *pud_pgtable(pud_t pud)
>  #define pud_page(pud)pfn_to_page(pud_pfn(pud))
>  
>  #define pud_leaf pud_leaf
> -static inline int pud_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
>  {
>   return (pud_val(pud) & (_PAGE_PSE | _PAGE_PRESENT)) ==
>   (_PAGE_PSE | _PAGE_PRESENT);
> @@ -1413,7 +1413,7 @@ static inline bool pgdp_maps_userspace(void *__ptr)
>  }
>  
>  #define pgd_leaf pgd_leaf
> -static inline int pgd_leaf(pgd_t pgd) { return 0; }
> +static inline bool pgd_leaf(pgd_t pgd) { return false; }
>  
>  #ifdef CONFIG_PAGE_TABLE_ISOLATION
>  /*
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index a36cf4e124b0..85fc7554cd52 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -1777,16 +1777,16 @@ typedef unsigned int pgtbl_mod_mask;
>   * Only meaningful when called on a valid entry.
>   */
>  #ifndef pgd_leaf
> -#define pgd_leaf(x)  0
> +#define pgd_leaf(x)  false
>  #endif
>  #ifndef p4d_leaf
> -#define p4d_leaf(x)  0
> +#define 

Re: [PATCH v3 09/10] mm/treewide: Drop pXd_large()

2024-03-05 Thread Mike Rapoport
On Tue, Mar 05, 2024 at 12:37:49PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> They're not used anymore, drop all of them.
> 
> Reviewed-by: Jason Gunthorpe 
> Signed-off-by: Peter Xu 

Reviewed-by: Mike Rapoport (IBM) 

> ---
>  arch/arm/include/asm/pgtable-2level.h|  1 -
>  arch/arm/include/asm/pgtable-3level.h|  1 -
>  arch/loongarch/kvm/mmu.c |  2 +-
>  arch/powerpc/include/asm/book3s/64/pgtable.h |  4 +---
>  arch/powerpc/include/asm/pgtable.h   |  4 
>  arch/s390/include/asm/pgtable.h  |  8 
>  arch/sparc/include/asm/pgtable_64.h  |  8 
>  arch/x86/include/asm/pgtable.h   | 19 +++
>  arch/x86/kvm/mmu/mmu.c   |  2 +-
>  9 files changed, 18 insertions(+), 31 deletions(-)
> 
> diff --git a/arch/arm/include/asm/pgtable-2level.h 
> b/arch/arm/include/asm/pgtable-2level.h
> index ce543cd9380c..b0a262566eb9 100644
> --- a/arch/arm/include/asm/pgtable-2level.h
> +++ b/arch/arm/include/asm/pgtable-2level.h
> @@ -213,7 +213,6 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long 
> addr)
>  
>  #define pmd_pfn(pmd) (__phys_to_pfn(pmd_val(pmd) & PHYS_MASK))
>  
> -#define pmd_large(pmd)   (pmd_val(pmd) & 2)
>  #define pmd_leaf(pmd)(pmd_val(pmd) & 2)
>  #define pmd_bad(pmd) (pmd_val(pmd) & 2)
>  #define pmd_present(pmd) (pmd_val(pmd))
> diff --git a/arch/arm/include/asm/pgtable-3level.h 
> b/arch/arm/include/asm/pgtable-3level.h
> index 71c3add6417f..4b1d9eb3908a 100644
> --- a/arch/arm/include/asm/pgtable-3level.h
> +++ b/arch/arm/include/asm/pgtable-3level.h
> @@ -118,7 +118,6 @@
>PMD_TYPE_TABLE)
>  #define pmd_sect(pmd)((pmd_val(pmd) & PMD_TYPE_MASK) == \
>PMD_TYPE_SECT)
> -#define pmd_large(pmd)   pmd_sect(pmd)
>  #define pmd_leaf(pmd)pmd_sect(pmd)
>  
>  #define pud_clear(pudp)  \
> diff --git a/arch/loongarch/kvm/mmu.c b/arch/loongarch/kvm/mmu.c
> index 50a6acd7ffe4..a556cff35740 100644
> --- a/arch/loongarch/kvm/mmu.c
> +++ b/arch/loongarch/kvm/mmu.c
> @@ -723,7 +723,7 @@ static int host_pfn_mapping_level(struct kvm *kvm, gfn_t 
> gfn,
>   /*
>* Read each entry once.  As above, a non-leaf entry can be promoted to
>* a huge page _during_ this walk.  Re-reading the entry could send the
> -  * walk into the weeks, e.g. p*d_large() returns false (sees the old
> +  * walk into the weeks, e.g. p*d_leaf() returns false (sees the old
>* value) and then p*d_offset() walks into the target huge page instead
>* of the old page table (sees the new value).
>*/
> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
> b/arch/powerpc/include/asm/book3s/64/pgtable.h
> index 3e99e409774a..df66dce8306f 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
> @@ -1437,17 +1437,15 @@ static inline bool is_pte_rw_upgrade(unsigned long 
> old_val, unsigned long new_va
>  }
>  
>  /*
> - * Like pmd_huge() and pmd_large(), but works regardless of config options
> + * Like pmd_huge(), but works regardless of config options
>   */
>  #define pmd_leaf pmd_leaf
> -#define pmd_large pmd_leaf
>  static inline bool pmd_leaf(pmd_t pmd)
>  {
>   return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
>  }
>  
>  #define pud_leaf pud_leaf
> -#define pud_large pud_leaf
>  static inline bool pud_leaf(pud_t pud)
>  {
>   return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
> diff --git a/arch/powerpc/include/asm/pgtable.h 
> b/arch/powerpc/include/asm/pgtable.h
> index e6edf1cdbc5b..239709a2f68e 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -101,10 +101,6 @@ void poking_init(void);
>  extern unsigned long ioremap_bot;
>  extern const pgprot_t protection_map[16];
>  
> -#ifndef pmd_large
> -#define pmd_large(pmd)   0
> -#endif
> -
>  /* can we use this in kvm */
>  unsigned long vmalloc_to_phys(void *vmalloc_addr);
>  
> diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
> index a5f16a244a64..9e08af5b9247 100644
> --- a/arch/s390/include/asm/pgtable.h
> +++ b/arch/s390/include/asm/pgtable.h
> @@ -705,16 +705,16 @@ static inline int pud_none(pud_t pud)
>   return pud_val(pud) == _REGION3_ENTRY_EMPTY;
>  }
>  
> -#define pud_leaf pud_large
> -static inline int pud_large(pud_t pud)
> +#define pud_leaf pud_leaf
> +static inline int pud_leaf(pud_t pud)
>  {
>   if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) != _REGION_ENTRY_TYPE_R3)
>   return 0;
>   return !!(pud_val(pud) & _REGION3_ENTRY_LARGE);
>  }
>  
> -#define pmd_leaf pmd_large
> -static inline int pmd_large(pmd_t pmd)
> +#define pmd_leaf pmd_leaf
> +static inline int pmd_leaf(pmd_t pmd)
>  {
>   return 

Re: [PATCH v3 07/10] mm/treewide: Replace pmd_large() with pmd_leaf()

2024-03-05 Thread Mike Rapoport
On Tue, Mar 05, 2024 at 12:37:47PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> pmd_large() is always defined as pmd_leaf().  Merge their usages.  Chose
> pmd_leaf() because pmd_leaf() is a global API, while pmd_large() is not.
> 
> Reviewed-by: Jason Gunthorpe 
> Signed-off-by: Peter Xu 
> ---
>  arch/arm/mm/dump.c   |  4 ++--
>  arch/powerpc/mm/book3s64/pgtable.c   |  2 +-
>  arch/powerpc/mm/book3s64/radix_pgtable.c |  2 +-
>  arch/powerpc/mm/pgtable_64.c |  2 +-
>  arch/s390/boot/vmem.c|  2 +-
>  arch/s390/include/asm/pgtable.h  |  8 
>  arch/s390/mm/gmap.c  | 12 ++--
>  arch/s390/mm/hugetlbpage.c   |  2 +-
>  arch/s390/mm/pageattr.c  |  2 +-
>  arch/s390/mm/pgtable.c   |  6 +++---
>  arch/s390/mm/vmem.c  |  6 +++---
>  arch/sparc/mm/init_64.c  |  4 ++--
>  arch/x86/boot/compressed/ident_map_64.c  |  2 +-
>  arch/x86/kvm/mmu/mmu.c   |  2 +-
>  arch/x86/mm/fault.c  |  8 
>  arch/x86/mm/init_32.c|  2 +-
>  arch/x86/mm/init_64.c|  8 
>  arch/x86/mm/kasan_init_64.c  |  2 +-
>  arch/x86/mm/mem_encrypt_identity.c   |  4 ++--
>  arch/x86/mm/pat/set_memory.c |  4 ++--
>  arch/x86/mm/pgtable.c|  2 +-
>  arch/x86/mm/pti.c|  4 ++--
>  arch/x86/power/hibernate.c   |  2 +-
>  arch/x86/xen/mmu_pv.c|  4 ++--
>  drivers/misc/sgi-gru/grufault.c  |  2 +-
>  25 files changed, 49 insertions(+), 49 deletions(-)

Reviewed-by: Mike Rapoport (IBM) 

> 
> diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
> index a9381095ab36..cd032522d902 100644
> --- a/arch/arm/mm/dump.c
> +++ b/arch/arm/mm/dump.c
> @@ -349,12 +349,12 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, 
> unsigned long start)
>   for (i = 0; i < PTRS_PER_PMD; i++, pmd++) {
>   addr = start + i * PMD_SIZE;
>   domain = get_domain_name(pmd);
> - if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
> + if (pmd_none(*pmd) || pmd_leaf(*pmd) || !pmd_present(*pmd))
>   note_page(st, addr, 4, pmd_val(*pmd), domain);
>   else
>   walk_pte(st, pmd, addr, domain);
>  
> - if (SECTION_SIZE < PMD_SIZE && pmd_large(pmd[1])) {
> + if (SECTION_SIZE < PMD_SIZE && pmd_leaf(pmd[1])) {
>   addr += SECTION_SIZE;
>   pmd++;
>   domain = get_domain_name(pmd);
> diff --git a/arch/powerpc/mm/book3s64/pgtable.c 
> b/arch/powerpc/mm/book3s64/pgtable.c
> index 3438ab72c346..45f526547b27 100644
> --- a/arch/powerpc/mm/book3s64/pgtable.c
> +++ b/arch/powerpc/mm/book3s64/pgtable.c
> @@ -113,7 +113,7 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,
>  
>   WARN_ON(pte_hw_valid(pmd_pte(*pmdp)) && !pte_protnone(pmd_pte(*pmdp)));
>   assert_spin_locked(pmd_lockptr(mm, pmdp));
> - WARN_ON(!(pmd_large(pmd)));
> + WARN_ON(!(pmd_leaf(pmd)));
>  #endif
>   trace_hugepage_set_pmd(addr, pmd_val(pmd));
>   return set_pte_at(mm, addr, pmdp_ptep(pmdp), pmd_pte(pmd));
> diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c 
> b/arch/powerpc/mm/book3s64/radix_pgtable.c
> index 1f8db10693e3..5cc4008329be 100644
> --- a/arch/powerpc/mm/book3s64/radix_pgtable.c
> +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
> @@ -924,7 +924,7 @@ bool vmemmap_can_optimize(struct vmem_altmap *altmap, 
> struct dev_pagemap *pgmap)
>  int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node,
>   unsigned long addr, unsigned long next)
>  {
> - int large = pmd_large(*pmdp);
> + int large = pmd_leaf(*pmdp);
>  
>   if (large)
>   vmemmap_verify(pmdp_ptep(pmdp), node, addr, next);
> diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
> index 386c6b06eab7..9b99113cb51a 100644
> --- a/arch/powerpc/mm/pgtable_64.c
> +++ b/arch/powerpc/mm/pgtable_64.c
> @@ -132,7 +132,7 @@ struct page *pmd_page(pmd_t pmd)
>* enabled so these checks can't be used.
>*/
>   if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP))
> - VM_WARN_ON(!(pmd_large(pmd) || pmd_huge(pmd)));
> + VM_WARN_ON(!(pmd_leaf(pmd) || pmd_huge(pmd)));
>   return pte_page(pmd_pte(pmd));
>   }
>   return virt_to_page(pmd_page_vaddr(pmd));
> diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c
> index e3a4500a5a75..348ab02b1028 100644
> --- a/arch/s390/boot/vmem.c
> +++ b/arch/s390/boot/vmem.c
> @@ -333,7 +333,7 @@ static void pgtable_pmd_populate(pud_t *pud, unsigned 
> long addr, unsigned long e
>   }
>   pte = boot_pte_alloc();
>

Re: [PATCH v3 06/10] mm/kasan: Use pXd_leaf() in shadow_mapped()

2024-03-05 Thread Mike Rapoport
On Tue, Mar 05, 2024 at 12:37:46PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> There is an old trick in shadow_mapped() to use pXd_bad() to detect huge
> pages.  After commit 93fab1b22ef7 ("mm: add generic p?d_leaf() macros") we
> have a global API for huge mappings.  Use that to replace the trick.
> 
> Cc: Andrey Ryabinin 
> Cc: Alexander Potapenko 
> Cc: Andrey Konovalov 
> Cc: Dmitry Vyukov 
> Cc: Vincenzo Frascino 
> Cc: kasan-...@googlegroups.com
> Signed-off-by: Peter Xu 

Reviewed-by: Mike Rapoport (IBM) 

> ---
>  mm/kasan/shadow.c | 11 ++-
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c
> index 9ef84f31833f..d6210ca48dda 100644
> --- a/mm/kasan/shadow.c
> +++ b/mm/kasan/shadow.c
> @@ -199,19 +199,12 @@ static bool shadow_mapped(unsigned long addr)
>   pud = pud_offset(p4d, addr);
>   if (pud_none(*pud))
>   return false;
> -
> - /*
> -  * We can't use pud_large() or pud_huge(), the first one is
> -  * arch-specific, the last one depends on HUGETLB_PAGE.  So let's abuse
> -  * pud_bad(), if pud is bad then it's bad because it's huge.
> -  */
> - if (pud_bad(*pud))
> + if (pud_leaf(*pud))
>   return true;
>   pmd = pmd_offset(pud, addr);
>   if (pmd_none(*pmd))
>   return false;
> -
> - if (pmd_bad(*pmd))
> + if (pmd_leaf(*pmd))
>   return true;
>   pte = pte_offset_kernel(pmd, addr);
>   return !pte_none(ptep_get(pte));
> -- 
> 2.44.0
> 
> 

-- 
Sincerely yours,
Mike.


Re: [PATCH v3 05/10] mm/x86: Drop two unnecessary pud_leaf() definitions

2024-03-05 Thread Mike Rapoport
On Tue, Mar 05, 2024 at 12:37:45PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> pud_leaf() has a fallback macro defined in include/linux/pgtable.h already.
> Drop the extra two for x86.
> 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: Borislav Petkov 
> Cc: Dave Hansen 
> Cc: x...@kernel.org
> Reviewed-by: Jason Gunthorpe 
> Acked-by: Thomas Gleixner 
> Signed-off-by: Peter Xu 

Reviewed-by: Mike Rapoport (IBM) 

> ---
>  arch/x86/include/asm/pgtable.h  | 1 -
>  include/asm-generic/pgtable-nopmd.h | 1 -
>  2 files changed, 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index d6e993a5659f..9db7a38a0e9f 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -1097,7 +1097,6 @@ static inline int pud_bad(pud_t pud)
>   return (pud_flags(pud) & ~(_KERNPG_TABLE | _PAGE_USER)) != 0;
>  }
>  #else
> -#define pud_leaf pud_large
>  static inline int pud_large(pud_t pud)
>  {
>   return 0;
> diff --git a/include/asm-generic/pgtable-nopmd.h 
> b/include/asm-generic/pgtable-nopmd.h
> index 8ffd64e7a24c..fa27e16bbe1b 100644
> --- a/include/asm-generic/pgtable-nopmd.h
> +++ b/include/asm-generic/pgtable-nopmd.h
> @@ -31,7 +31,6 @@ static inline int pud_none(pud_t pud)   { 
> return 0; }
>  static inline int pud_bad(pud_t pud) { return 0; }
>  static inline int pud_present(pud_t pud) { return 1; }
>  static inline int pud_user(pud_t pud){ return 0; }
> -static inline int pud_leaf(pud_t pud){ return 0; }
>  static inline void pud_clear(pud_t *pud) { }
>  #define pmd_ERROR(pmd)   (pud_ERROR((pmd).pud))
>  
> -- 
> 2.44.0
> 
> 

-- 
Sincerely yours,
Mike.


Re: [PATCH v3 04/10] mm/x86: Replace pgd_large() with pgd_leaf()

2024-03-05 Thread Mike Rapoport
On Tue, Mar 05, 2024 at 12:37:44PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> pgd_leaf() is a global API while pgd_large() is not.  Always use
> the global pgd_leaf(), then drop pgd_large().
> 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: Borislav Petkov 
> Cc: Dave Hansen 
> Cc: x...@kernel.org
> Signed-off-by: Peter Xu 

Reviewed-by: Mike Rapoport (IBM) 

> ---
>  arch/x86/include/asm/pgtable.h | 4 ++--
>  arch/x86/mm/pti.c  | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index 69ed0ea0641b..d6e993a5659f 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -1418,8 +1418,8 @@ static inline bool pgdp_maps_userspace(void *__ptr)
>   return (((ptr & ~PAGE_MASK) / sizeof(pgd_t)) < PGD_KERNEL_START);
>  }
>  
> -#define pgd_leaf pgd_large
> -static inline int pgd_large(pgd_t pgd) { return 0; }
> +#define pgd_leaf pgd_leaf
> +static inline int pgd_leaf(pgd_t pgd) { return 0; }
>  
>  #ifdef CONFIG_PAGE_TABLE_ISOLATION
>  /*
> diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
> index dc0a81f5f60e..c17aab24c1b3 100644
> --- a/arch/x86/mm/pti.c
> +++ b/arch/x86/mm/pti.c
> @@ -185,7 +185,7 @@ static p4d_t *pti_user_pagetable_walk_p4d(unsigned long 
> address)
>  
>   set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(new_p4d_page)));
>   }
> - BUILD_BUG_ON(pgd_large(*pgd) != 0);
> + BUILD_BUG_ON(pgd_leaf(*pgd) != 0);
>  
>   return p4d_offset(pgd, address);
>  }
> -- 
> 2.44.0
> 
> 

-- 
Sincerely yours,
Mike.


Re: [PATCH v3 03/10] mm/x86: Replace p4d_large() with p4d_leaf()

2024-03-05 Thread Mike Rapoport
On Tue, Mar 05, 2024 at 12:37:43PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> p4d_large() is always defined as p4d_leaf().  Merge their usages.  Chose
> p4d_leaf() because p4d_leaf() is a global API, while p4d_large() is not.
> 
> Only x86 has p4d_leaf() defined as of now.  So it also means after this
> patch we removed all p4d_large() usages.
> 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: Borislav Petkov 
> Cc: Dave Hansen 
> Cc: x...@kernel.org
> Reviewed-by: Jason Gunthorpe 
> Signed-off-by: Peter Xu 

Reviewed-by: Mike Rapoport (IBM) 

> ---
>  arch/x86/mm/fault.c  | 4 ++--
>  arch/x86/mm/init_64.c| 2 +-
>  arch/x86/mm/pat/set_memory.c | 4 ++--
>  arch/x86/mm/pti.c| 2 +-
>  arch/x86/power/hibernate.c   | 2 +-
>  arch/x86/xen/mmu_pv.c| 2 +-
>  6 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index 679b09cfe241..8b69ce3f4115 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -368,7 +368,7 @@ static void dump_pagetable(unsigned long address)
>   goto bad;
>  
>   pr_cont("P4D %lx ", p4d_val(*p4d));
> - if (!p4d_present(*p4d) || p4d_large(*p4d))
> + if (!p4d_present(*p4d) || p4d_leaf(*p4d))
>   goto out;
>  
>   pud = pud_offset(p4d, address);
> @@ -1039,7 +1039,7 @@ spurious_kernel_fault(unsigned long error_code, 
> unsigned long address)
>   if (!p4d_present(*p4d))
>   return 0;
>  
> - if (p4d_large(*p4d))
> + if (p4d_leaf(*p4d))
>   return spurious_kernel_fault_check(error_code, (pte_t *) p4d);
>  
>   pud = pud_offset(p4d, address);
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index ebdbcae48011..d691e7992a9a 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1197,7 +1197,7 @@ remove_p4d_table(p4d_t *p4d_start, unsigned long addr, 
> unsigned long end,
>   if (!p4d_present(*p4d))
>   continue;
>  
> - BUILD_BUG_ON(p4d_large(*p4d));
> + BUILD_BUG_ON(p4d_leaf(*p4d));
>  
>   pud_base = pud_offset(p4d, 0);
>   remove_pud_table(pud_base, addr, next, altmap, direct);
> diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
> index e9b448d1b1b7..5359a9c88099 100644
> --- a/arch/x86/mm/pat/set_memory.c
> +++ b/arch/x86/mm/pat/set_memory.c
> @@ -676,7 +676,7 @@ pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long 
> address,
>   return NULL;
>  
>   *level = PG_LEVEL_512G;
> - if (p4d_large(*p4d) || !p4d_present(*p4d))
> + if (p4d_leaf(*p4d) || !p4d_present(*p4d))
>   return (pte_t *)p4d;
>  
>   pud = pud_offset(p4d, address);
> @@ -739,7 +739,7 @@ pmd_t *lookup_pmd_address(unsigned long address)
>   return NULL;
>  
>   p4d = p4d_offset(pgd, address);
> - if (p4d_none(*p4d) || p4d_large(*p4d) || !p4d_present(*p4d))
> + if (p4d_none(*p4d) || p4d_leaf(*p4d) || !p4d_present(*p4d))
>   return NULL;
>  
>   pud = pud_offset(p4d, address);
> diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
> index 669ba1c345b3..dc0a81f5f60e 100644
> --- a/arch/x86/mm/pti.c
> +++ b/arch/x86/mm/pti.c
> @@ -206,7 +206,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long 
> address)
>   if (!p4d)
>   return NULL;
>  
> - BUILD_BUG_ON(p4d_large(*p4d) != 0);
> + BUILD_BUG_ON(p4d_leaf(*p4d) != 0);
>   if (p4d_none(*p4d)) {
>   unsigned long new_pud_page = __get_free_page(gfp);
>   if (WARN_ON_ONCE(!new_pud_page))
> diff --git a/arch/x86/power/hibernate.c b/arch/x86/power/hibernate.c
> index 6f955eb1e163..28153789f873 100644
> --- a/arch/x86/power/hibernate.c
> +++ b/arch/x86/power/hibernate.c
> @@ -165,7 +165,7 @@ int relocate_restore_code(void)
>   pgd = (pgd_t *)__va(read_cr3_pa()) +
>   pgd_index(relocated_restore_code);
>   p4d = p4d_offset(pgd, relocated_restore_code);
> - if (p4d_large(*p4d)) {
> + if (p4d_leaf(*p4d)) {
>   set_p4d(p4d, __p4d(p4d_val(*p4d) & ~_PAGE_NX));
>   goto out;
>   }
> diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
> index e21974f2cf2d..12a43a4abebf 100644
> --- a/arch/x86/xen/mmu_pv.c
> +++ b/arch/x86/xen/mmu_pv.c
> @@ -1104,7 +1104,7 @@ static void __init xen_cleanmfnmap_p4d(p4d_t *p4d, bool 
> unpin)
>   pud_t *pud_tbl;
>   int i;
>  
> - if (p4d_large(*p4d)) {
> + if (p4d_leaf(*p4d)) {
>   pa = p4d_val(*p4d) & PHYSICAL_PAGE_MASK;
>   xen_free_ro_pages(pa, P4D_SIZE);
>   return;
> -- 
> 2.44.0
> 
> 

-- 
Sincerely yours,
Mike.


Re: [PATCH v3 02/10] mm/ppc: Replace pXd_is_leaf() with pXd_leaf()

2024-03-05 Thread Mike Rapoport
On Tue, Mar 05, 2024 at 12:37:42PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> They're the same macros underneath.  Drop pXd_is_leaf(), instead always use
> pXd_leaf().
> 
> At the meantime, instead of renames, drop the pXd_is_leaf() fallback
> definitions directly in arch/powerpc/include/asm/pgtable.h. because similar
> fallback macros for pXd_leaf() are already defined in
> include/linux/pgtable.h.
> 
> Cc: Michael Ellerman 
> Cc: Nicholas Piggin 
> Cc: "Aneesh Kumar K.V" 
> Cc: "Naveen N. Rao" 
> Cc: linuxppc-dev@lists.ozlabs.org
> Suggested-by: Christophe Leroy 
> Reviewed-by: Jason Gunthorpe 
> Signed-off-by: Peter Xu 

Reviewed-by: Mike Rapoport (IBM) 

> ---
>  arch/powerpc/include/asm/book3s/64/pgtable.h | 10 
>  arch/powerpc/include/asm/pgtable.h   | 24 
>  arch/powerpc/kvm/book3s_64_mmu_radix.c   | 12 +-
>  arch/powerpc/mm/book3s64/radix_pgtable.c | 14 ++--
>  arch/powerpc/mm/pgtable.c|  6 ++---
>  arch/powerpc/mm/pgtable_64.c |  6 ++---
>  arch/powerpc/xmon/xmon.c |  6 ++---
>  7 files changed, 26 insertions(+), 52 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
> b/arch/powerpc/include/asm/book3s/64/pgtable.h
> index d1318e8582ac..3e99e409774a 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
> @@ -1439,18 +1439,16 @@ static inline bool is_pte_rw_upgrade(unsigned long 
> old_val, unsigned long new_va
>  /*
>   * Like pmd_huge() and pmd_large(), but works regardless of config options
>   */
> -#define pmd_is_leaf pmd_is_leaf
> -#define pmd_leaf pmd_is_leaf
> +#define pmd_leaf pmd_leaf
>  #define pmd_large pmd_leaf
> -static inline bool pmd_is_leaf(pmd_t pmd)
> +static inline bool pmd_leaf(pmd_t pmd)
>  {
>   return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
>  }
>  
> -#define pud_is_leaf pud_is_leaf
> -#define pud_leaf pud_is_leaf
> +#define pud_leaf pud_leaf
>  #define pud_large pud_leaf
> -static inline bool pud_is_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
>  {
>   return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
>  }
> diff --git a/arch/powerpc/include/asm/pgtable.h 
> b/arch/powerpc/include/asm/pgtable.h
> index 5928b3c1458d..e6edf1cdbc5b 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -182,30 +182,6 @@ static inline void pte_frag_set(mm_context_t *ctx, void 
> *p)
>  }
>  #endif
>  
> -#ifndef pmd_is_leaf
> -#define pmd_is_leaf pmd_is_leaf
> -static inline bool pmd_is_leaf(pmd_t pmd)
> -{
> - return false;
> -}
> -#endif
> -
> -#ifndef pud_is_leaf
> -#define pud_is_leaf pud_is_leaf
> -static inline bool pud_is_leaf(pud_t pud)
> -{
> - return false;
> -}
> -#endif
> -
> -#ifndef p4d_is_leaf
> -#define p4d_is_leaf p4d_is_leaf
> -static inline bool p4d_is_leaf(p4d_t p4d)
> -{
> - return false;
> -}
> -#endif
> -
>  #define pmd_pgtable pmd_pgtable
>  static inline pgtable_t pmd_pgtable(pmd_t pmd)
>  {
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c 
> b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> index 4a1abb9f7c05..408d98f8a514 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> @@ -503,7 +503,7 @@ static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t 
> *pmd, bool full,
>   for (im = 0; im < PTRS_PER_PMD; ++im, ++p) {
>   if (!pmd_present(*p))
>   continue;
> - if (pmd_is_leaf(*p)) {
> + if (pmd_leaf(*p)) {
>   if (full) {
>   pmd_clear(p);
>   } else {
> @@ -532,7 +532,7 @@ static void kvmppc_unmap_free_pud(struct kvm *kvm, pud_t 
> *pud,
>   for (iu = 0; iu < PTRS_PER_PUD; ++iu, ++p) {
>   if (!pud_present(*p))
>   continue;
> - if (pud_is_leaf(*p)) {
> + if (pud_leaf(*p)) {
>   pud_clear(p);
>   } else {
>   pmd_t *pmd;
> @@ -635,12 +635,12 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, 
> pte_t pte,
>   new_pud = pud_alloc_one(kvm->mm, gpa);
>  
>   pmd = NULL;
> - if (pud && pud_present(*pud) && !pud_is_leaf(*pud))
> + if (pud && pud_present(*pud) && !pud_leaf(*pud))
>   pmd = pmd_offset(pud, gpa);
>   else if (level <= 1)
>   new_pmd = kvmppc_pmd_alloc();
>  
> - if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_is_leaf(*pmd)))
> + if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_leaf(*pmd)))
>   new_ptep = kvmppc_pte_alloc();
>  
>   /* Check if we might have been invalidated; let the guest retry if so */
> @@ -658,7 +658,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, 
> pte_t pte,
>   new_pud = NULL;
>   }
>   pud = pud_offset(p4d, gpa);
> - if 

Re: [PATCH v3 01/10] mm/ppc: Define pXd_large() with pXd_leaf()

2024-03-05 Thread Mike Rapoport
On Tue, Mar 05, 2024 at 12:37:41PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> The two definitions are the same.  The only difference is that pXd_large()
> is only defined with THP selected, and only on book3s 64bits.
> 
> Instead of implementing it twice, make pXd_large() a macro to pXd_leaf().
> Define it unconditionally just like pXd_leaf().  This helps to prepare
> merging the two APIs.
> 
> Cc: Michael Ellerman 
> Cc: Nicholas Piggin 
> Cc: Christophe Leroy 
> Cc: "Aneesh Kumar K.V" 
> Cc: "Naveen N. Rao" 
> Cc: linuxppc-dev@lists.ozlabs.org
> Reviewed-by: Jason Gunthorpe 
> Signed-off-by: Peter Xu 

Reviewed-by: Mike Rapoport (IBM) 

> ---
>  arch/powerpc/include/asm/book3s/64/pgtable.h | 16 ++--
>  arch/powerpc/include/asm/pgtable.h   |  2 +-
>  2 files changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
> b/arch/powerpc/include/asm/book3s/64/pgtable.h
> index 927d585652bc..d1318e8582ac 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
> @@ -1157,20 +1157,6 @@ pud_hugepage_update(struct mm_struct *mm, unsigned 
> long addr, pud_t *pudp,
>   return pud_val(*pudp);
>  }
>  
> -/*
> - * returns true for pmd migration entries, THP, devmap, hugetlb
> - * But compile time dependent on THP config
> - */
> -static inline int pmd_large(pmd_t pmd)
> -{
> - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
> -}
> -
> -static inline int pud_large(pud_t pud)
> -{
> - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
> -}
> -
>  /*
>   * For radix we should always find H_PAGE_HASHPTE zero. Hence
>   * the below will work for radix too
> @@ -1455,6 +1441,7 @@ static inline bool is_pte_rw_upgrade(unsigned long 
> old_val, unsigned long new_va
>   */
>  #define pmd_is_leaf pmd_is_leaf
>  #define pmd_leaf pmd_is_leaf
> +#define pmd_large pmd_leaf
>  static inline bool pmd_is_leaf(pmd_t pmd)
>  {
>   return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
> @@ -1462,6 +1449,7 @@ static inline bool pmd_is_leaf(pmd_t pmd)
>  
>  #define pud_is_leaf pud_is_leaf
>  #define pud_leaf pud_is_leaf
> +#define pud_large pud_leaf
>  static inline bool pud_is_leaf(pud_t pud)
>  {
>   return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
> diff --git a/arch/powerpc/include/asm/pgtable.h 
> b/arch/powerpc/include/asm/pgtable.h
> index 7a1ba8889aea..5928b3c1458d 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -101,7 +101,7 @@ void poking_init(void);
>  extern unsigned long ioremap_bot;
>  extern const pgprot_t protection_map[16];
>  
> -#ifndef CONFIG_TRANSPARENT_HUGEPAGE
> +#ifndef pmd_large
>  #define pmd_large(pmd)   0
>  #endif
>  
> -- 
> 2.44.0
> 
> 

-- 
Sincerely yours,
Mike.


Re: [PATCH] selftests/powerpc: Fix load_unaligned_zeropad build failure

2024-03-05 Thread Michael Ellerman
Kees Cook  writes:
> On Tue, 05 Mar 2024 23:56:44 +1100, Michael Ellerman wrote:
>> This test is userspace code, but uses some kernel headers via symlinks,
>> and mocks other headers, in order to test load_unaligned_zeropad().
>> 
>> Currently the test fails to build with:
>> 
>>   In file included from load_unaligned_zeropad.c:26:
>>   word-at-a-time.h:7:10: fatal error: linux/bitops.h: No such file or 
>> directory
>>   7 | #include 
>> 
>> [...]
>
> Applied to for-next/hardening, thanks!
>
> [1/1] selftests/powerpc: Fix load_unaligned_zeropad build failure
>   https://git.kernel.org/kees/c/3fe1eb4dd2e4
>
> Take care,

Thanks.

cheers


Re: Boot failure with ppc64 port on iMacs G5

2024-03-05 Thread Michael Ellerman
John Paul Adrian Glaubitz  writes:
> On Fri, 2024-03-01 at 12:56 +1100, Michael Ellerman wrote:
>> That second iso boots OK for me in qemu. It boots grub and then the
>> kernel loads and shows:
>> 
>>   Loading ...
>>   OF stdout device is: /pci@f000/mac-io@c/escc@13000/ch-a@13020
>>   Preparing to boot Linux version 6.3.0-1-powerpc64 
>> (debian-ker...@lists.debian.org) (gcc-12 (Debian 12.3.0-2) 12.3.0, GNU ld 
>> (GNU Binutils for Debian) 2.40) #1 SMP Debian 6.3.7-1 (2023-06-12)
>>   Detected machine type: 0400
>>   command line: BOOT_IMAGE=/install/vmlinux --- quiet
>>   memory layout at init:
>> memory_limit :  (16 MB aligned)
>> alloc_bottom : 05e7
>> alloc_top: 3000
>> alloc_top_hi : 8000
>> rmo_top  : 3000
>> ram_top  : 8000
>>   copying OF device tree...
>>   Building dt strings...
>>   Building dt structure...
>>   Device tree strings 0x05e8 -> 0x05e80560
>>   Device tree struct  0x05e9 -> 0x05ea
>>   Quiescing Open Firmware ...
>>   Booting Linux via __start() @ 0x0200 ...
>>   Hello World !
>>   smp_core99_probe
>>   smp_core99_bringup_done
>>   Starting system log daemon: syslogd, klogd.
>> 
>> And eventually starts the installer.
>
> Yep, the second, older image works as expected. However, the recent one does 
> not
> and I have absolutely no clue why.

I actually tested both, and both work, but then I cited the wrong one in
my email >_<

So at least on qemu that newer kernel is OK:

  Preparing to boot Linux version 6.6.15-powerpc64 
(debian-ker...@lists.debian.org) (gcc-13 (Debian 13.2.0-13) 13.2.0, GNU ld (GNU 
Binutils for Debian) 2.42) #1 SMP Debian 6.6.15-2 (2024-02-04)
  ...
  Booting Linux via __start() @ 0x0480 ...
  Hello World !
  smp_core99_probe
  smp_core99_bringup_done
  Starting system log daemon: syslogd, klogd.


cheers


Re: [PATCH] powerpc: xor_vmx: Add '-mhard-float' to CFLAGS

2024-03-05 Thread Michael Ellerman
Nathan Chancellor  writes:
> Ping? We have been applying this in our CI since it was sent, it would
> be nice to have this upstream soon so it can start filtering through the
> stable trees.

Sorry, I was away in January and missed this. Will pick it up.

cheers

> On Sat, Jan 27, 2024 at 11:07:43AM -0700, Nathan Chancellor wrote:
>> arch/powerpc/lib/xor_vmx.o is built with '-msoft-float' (from the main
>> powerpc Makefile) and '-maltivec' (from its CFLAGS), which causes an
>> error when building with clang after a recent change in main:
>> 
>>   error: option '-msoft-float' cannot be specified with '-maltivec'
>>   make[6]: *** [scripts/Makefile.build:243: arch/powerpc/lib/xor_vmx.o] 
>> Error 1
>> 
>> Explicitly add '-mhard-float' before '-maltivec' in xor_vmx.o's CFLAGS
>> to override the previous inclusion of '-msoft-float' (as the last option
>> wins), which matches how other areas of the kernel use '-maltivec', such
>> as AMDGPU.
>> 
>> Cc: sta...@vger.kernel.org
>> Closes: https://github.com/ClangBuiltLinux/linux/issues/1986
>> Link: 
>> https://github.com/llvm/llvm-project/commit/4792f912b232141ecba4cbae538873be3c28556c
>> Signed-off-by: Nathan Chancellor 
>> ---
>>  arch/powerpc/lib/Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
>> index 6eac63e79a89..0ab65eeb93ee 100644
>> --- a/arch/powerpc/lib/Makefile
>> +++ b/arch/powerpc/lib/Makefile
>> @@ -76,7 +76,7 @@ obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o
>>  obj-$(CONFIG_FTR_FIXUP_SELFTEST) += feature-fixups-test.o
>>  
>>  obj-$(CONFIG_ALTIVEC)   += xor_vmx.o xor_vmx_glue.o
>> -CFLAGS_xor_vmx.o += -maltivec $(call cc-option,-mabi=altivec)
>> +CFLAGS_xor_vmx.o += -mhard-float -maltivec $(call cc-option,-mabi=altivec)
>>  # Enable 
>>  CFLAGS_xor_vmx.o += -isystem $(shell $(CC) -print-file-name=include)
>>  
>> 
>> ---
>> base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
>> change-id: 20240127-ppc-xor_vmx-drop-msoft-float-ad68b437f86c
>> 
>> Best regards,
>> -- 
>> Nathan Chancellor 
>> 


Re: [PATCH] powerpc: xor_vmx: Add '-mhard-float' to CFLAGS

2024-03-05 Thread Nathan Chancellor
Ping? We have been applying this in our CI since it was sent, it would
be nice to have this upstream soon so it can start filtering through the
stable trees.

On Sat, Jan 27, 2024 at 11:07:43AM -0700, Nathan Chancellor wrote:
> arch/powerpc/lib/xor_vmx.o is built with '-msoft-float' (from the main
> powerpc Makefile) and '-maltivec' (from its CFLAGS), which causes an
> error when building with clang after a recent change in main:
> 
>   error: option '-msoft-float' cannot be specified with '-maltivec'
>   make[6]: *** [scripts/Makefile.build:243: arch/powerpc/lib/xor_vmx.o] Error 
> 1
> 
> Explicitly add '-mhard-float' before '-maltivec' in xor_vmx.o's CFLAGS
> to override the previous inclusion of '-msoft-float' (as the last option
> wins), which matches how other areas of the kernel use '-maltivec', such
> as AMDGPU.
> 
> Cc: sta...@vger.kernel.org
> Closes: https://github.com/ClangBuiltLinux/linux/issues/1986
> Link: 
> https://github.com/llvm/llvm-project/commit/4792f912b232141ecba4cbae538873be3c28556c
> Signed-off-by: Nathan Chancellor 
> ---
>  arch/powerpc/lib/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
> index 6eac63e79a89..0ab65eeb93ee 100644
> --- a/arch/powerpc/lib/Makefile
> +++ b/arch/powerpc/lib/Makefile
> @@ -76,7 +76,7 @@ obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o
>  obj-$(CONFIG_FTR_FIXUP_SELFTEST) += feature-fixups-test.o
>  
>  obj-$(CONFIG_ALTIVEC)+= xor_vmx.o xor_vmx_glue.o
> -CFLAGS_xor_vmx.o += -maltivec $(call cc-option,-mabi=altivec)
> +CFLAGS_xor_vmx.o += -mhard-float -maltivec $(call cc-option,-mabi=altivec)
>  # Enable 
>  CFLAGS_xor_vmx.o += -isystem $(shell $(CC) -print-file-name=include)
>  
> 
> ---
> base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
> change-id: 20240127-ppc-xor_vmx-drop-msoft-float-ad68b437f86c
> 
> Best regards,
> -- 
> Nathan Chancellor 
> 


Re: [RESEND2 PATCH net v4 2/2] soc: fsl: qbman: Use raw spinlock for cgr_lock

2024-03-05 Thread Christophe Leroy


Le 05/03/2024 à 19:14, Sean Anderson a écrit :
> [Vous ne recevez pas souvent de courriers de sean.ander...@linux.dev. 
> Découvrez pourquoi ceci est important à 
> https://aka.ms/LearnAboutSenderIdentification ]
> 
> Hi,
> 
> On 2/23/24 11:02, Sean Anderson wrote:
>> On 2/23/24 00:38, Christophe Leroy wrote:
>>> Le 22/02/2024 à 18:07, Sean Anderson a écrit :
 [Vous ne recevez pas souvent de courriers de sean.ander...@linux.dev. 
 Découvrez pourquoi ceci est important à 
 https://aka.ms/LearnAboutSenderIdentification ]

 cgr_lock may be locked with interrupts already disabled by
 smp_call_function_single. As such, we must use a raw spinlock to avoid
 problems on PREEMPT_RT kernels. Although this bug has existed for a
 while, it was not apparent until commit ef2a8d5478b9 ("net: dpaa: Adjust
 queue depth on rate change") which invokes smp_call_function_single via
 qman_update_cgr_safe every time a link goes up or down.
>>>
>>> Why a raw spinlock to avoid problems on PREEMPT_RT, can you elaborate ?
>>
>> smp_call_function always runs its callback in hard IRQ context, even on
>> PREEMPT_RT, where spinlocks can sleep. So we need to use raw spinlocks
>> to ensure we aren't waiting on a sleeping task. See the first bug report
>> for more discussion.
>>
>> In the longer term it would be better to switch to some other
>> abstraction.
> 
> Does this make sense to you?

Yes that fine, thanks for the clarification. Maybe you can explain that 
in the patch description in case you send a v5.

Christophe


[PATCH] macintosh: adb: make adb_dev_class constant

2024-03-05 Thread Ricardo B. Marliere
Since commit 43a7206b0963 ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the adb_dev_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Cc: Greg Kroah-Hartman 
Suggested-by: Greg Kroah-Hartman 
Signed-off-by: Ricardo B. Marliere 
---
 drivers/macintosh/adb.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 057b0221f695..b0407c5fadb2 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -74,7 +74,9 @@ static struct adb_driver *adb_driver_list[] = {
NULL
 };
 
-static struct class *adb_dev_class;
+static const struct class adb_dev_class = {
+   .name = "adb",
+};
 
 static struct adb_driver *adb_controller;
 BLOCKING_NOTIFIER_HEAD(adb_client_list);
@@ -888,10 +890,10 @@ adbdev_init(void)
return;
}
 
-   adb_dev_class = class_create("adb");
-   if (IS_ERR(adb_dev_class))
+   if (class_register(_dev_class))
return;
-   device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
+
+   device_create(_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
 
platform_device_register(_pfdev);
platform_driver_probe(_pfdrv, adb_dummy_probe);

---
base-commit: 90d35da658da8cff0d4ecbb5113f5fac9d00eb72
change-id: 20240305-macintosh-9b027d413a05

Best regards,
-- 
Ricardo B. Marliere 



[PATCH][next] crypto/nx: Avoid -Wflex-array-member-not-at-end warning

2024-03-05 Thread Gustavo A. R. Silva
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally. So, we are deprecating flexible-array
members in the middle of another structure.

There is currently an object (`header`) in `struct nx842_crypto_ctx`
that contains a flexible structure (`struct nx842_crypto_header`):

struct nx842_crypto_ctx {
...
struct nx842_crypto_header header;
struct nx842_crypto_header_group group[NX842_CRYPTO_GROUP_MAX];
...
};

So, in order to avoid ending up with a flexible-array member in the
middle of another struct, we use the `struct_group_tagged()` helper to
separate the flexible array from the rest of the members in the flexible
structure:

struct nx842_crypto_header {
struct_group_tagged(nx842_crypto_header_hdr, hdr,

... the rest of the members

);
struct nx842_crypto_header_group group[];
} __packed;

With the change described above, we can now declare an object of the
type of the tagged struct, without embedding the flexible array in the
middle of another struct:

struct nx842_crypto_ctx {
...
struct nx842_crypto_header_hdr header;
struct nx842_crypto_header_group group[NX842_CRYPTO_GROUP_MAX];
...
 } __packed;

We also use `container_of()` whenever we need to retrieve a pointer to
the flexible structure, through which we can access the flexible
array if needed.

So, with these changes, fix the following warning:

In file included from drivers/crypto/nx/nx-842.c:55:
drivers/crypto/nx/nx-842.h:174:36: warning: structure containing a flexible 
array member is not at the end of another structure 
[-Wflex-array-member-not-at-end]
  174 | struct nx842_crypto_header header;
  |^~

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/crypto/nx/nx-842.c |  6 --
 drivers/crypto/nx/nx-842.h | 10 ++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c
index 2ab90ec10e61..82214cde2bcd 100644
--- a/drivers/crypto/nx/nx-842.c
+++ b/drivers/crypto/nx/nx-842.c
@@ -251,7 +251,9 @@ int nx842_crypto_compress(struct crypto_tfm *tfm,
  u8 *dst, unsigned int *dlen)
 {
struct nx842_crypto_ctx *ctx = crypto_tfm_ctx(tfm);
-   struct nx842_crypto_header *hdr = >header;
+   struct nx842_crypto_header *hdr =
+   container_of(>header,
+struct nx842_crypto_header, hdr);
struct nx842_crypto_param p;
struct nx842_constraints c = *ctx->driver->constraints;
unsigned int groups, hdrsize, h;
@@ -490,7 +492,7 @@ int nx842_crypto_decompress(struct crypto_tfm *tfm,
}
 
memcpy(>header, src, hdr_len);
-   hdr = >header;
+   hdr = container_of(>header, struct nx842_crypto_header, hdr);
 
for (n = 0; n < hdr->groups; n++) {
/* ignore applies to last group */
diff --git a/drivers/crypto/nx/nx-842.h b/drivers/crypto/nx/nx-842.h
index 7590bfb24d79..25fa70b2112c 100644
--- a/drivers/crypto/nx/nx-842.h
+++ b/drivers/crypto/nx/nx-842.h
@@ -157,9 +157,11 @@ struct nx842_crypto_header_group {
 } __packed;
 
 struct nx842_crypto_header {
-   __be16 magic;   /* NX842_CRYPTO_MAGIC */
-   __be16 ignore;  /* decompressed end bytes to ignore */
-   u8 groups;  /* total groups in this header */
+   struct_group_tagged(nx842_crypto_header_hdr, hdr,
+   __be16 magic;   /* NX842_CRYPTO_MAGIC */
+   __be16 ignore;  /* decompressed end bytes to ignore */
+   u8 groups;  /* total groups in this header */
+   );
struct nx842_crypto_header_group group[];
 } __packed;
 
@@ -171,7 +173,7 @@ struct nx842_crypto_ctx {
u8 *wmem;
u8 *sbounce, *dbounce;
 
-   struct nx842_crypto_header header;
+   struct nx842_crypto_header_hdr header;
struct nx842_crypto_header_group group[NX842_CRYPTO_GROUP_MAX];
 
struct nx842_driver *driver;
-- 
2.34.1



Re: [PATCH] selftests/powerpc: Fix load_unaligned_zeropad build failure

2024-03-05 Thread Kees Cook
On Tue, 05 Mar 2024 23:56:44 +1100, Michael Ellerman wrote:
> This test is userspace code, but uses some kernel headers via symlinks,
> and mocks other headers, in order to test load_unaligned_zeropad().
> 
> Currently the test fails to build with:
> 
>   In file included from load_unaligned_zeropad.c:26:
>   word-at-a-time.h:7:10: fatal error: linux/bitops.h: No such file or 
> directory
>   7 | #include 
> 
> [...]

Applied to for-next/hardening, thanks!

[1/1] selftests/powerpc: Fix load_unaligned_zeropad build failure
  https://git.kernel.org/kees/c/3fe1eb4dd2e4

Take care,

-- 
Kees Cook



[linux-next:master] BUILD REGRESSION 11afac187274a6177a7ac82997f8691c0f469e41

2024-03-05 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
branch HEAD: 11afac187274a6177a7ac82997f8691c0f469e41  Add linux-next specific 
files for 20240305

Error/Warning reports:

https://lore.kernel.org/oe-kbuild-all/202403051732.lucjfzah-...@intel.com
https://lore.kernel.org/oe-kbuild-all/202403051807.vgb2ht4i-...@intel.com
https://lore.kernel.org/oe-kbuild-all/202403051835.iqlgz996-...@intel.com
https://lore.kernel.org/oe-kbuild-all/202403052102.hlg8i44z-...@intel.com

Error/Warning: (recently discovered and may have been fixed)

ERROR: modpost: "acpi_device_notify_remove" [drivers/i2c/i2c-core.ko] undefined!
arch/powerpc/include/asm/reg_fsl_emb.h:18:9: error: impossible constraint in 
'asm'
arch/powerpc/include/asm/reg_fsl_emb.h:18:9: warning: 'asm' operand 1 probably 
does not match constraints
drivers/perf/starfive_starlink_pmu.c:169:3: error: call to undeclared function 
'writeq'; ISO C99 and later do not support implicit function declarations 
[-Wimplicit-function-declaration]
drivers/perf/starfive_starlink_pmu.c:191:8: error: call to undeclared function 
'readq'; ISO C99 and later do not support implicit function declarations 
[-Wimplicit-function-declaration]
pinctrl-aw9523.c:(.init.text+0x14): relocation truncated to fit: R_NIOS2_CALL26 
against `i2c_register_driver'
pinctrl-aw9523.c:(.text+0x13a8): relocation truncated to fit: R_NIOS2_CALL26 
against `__devm_regmap_init_i2c'

Error/Warning ids grouped by kconfigs:

gcc_recent_errors
|-- alpha-allyesconfig
|   |-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue()-instead
|-- alpha-randconfig-r133-20240305
|   `-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|-- arc-allmodconfig
|   |-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue()-instead
|-- arc-allyesconfig
|   |-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue()-instead
|-- arm-allmodconfig
|   |-- 
arch-arm-mach-omap2-prm33xx.c:warning:expecting-prototype-for-am33xx_prm_global_warm_sw_reset().-Prototype-was-for-am33xx_prm_global_sw_reset()-instead
|   |-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue()-instead
|-- arm-allyesconfig
|   |-- 
arch-arm-mach-omap2-prm33xx.c:warning:expecting-prototype-for-am33xx_prm_global_warm_sw_reset().-Prototype-was-for-am33xx_prm_global_sw_reset()-instead
|   |-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue()-instead
|-- arm-keystone_defconfig
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue()-instead
|-- arm64-defconfig
|   |-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue()-instead
|-- arm64-randconfig-001-20240305
|   `-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|-- csky-allmodconfig
|   |-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue()-instead
|-- csky-allyesconfig
|   |-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue()-instead
|-- csky-randconfig-001-20240305
|   `-- 
drivers-gpu-drm-nouveau-nvkm-subdev-gsp-r535.c:warning:Function-parameter-or-struct-member-gsp-not-described-in-nvkm_gsp_radix3_sg
|-- csky-randconfig-002-20240305
|   `-- 
fs-ubifs-journal.c:warning:expecting-prototype-for-wake_up_reservation().-Prototype-was-for-add_or_start_queue

Re: [RESEND2 PATCH net v4 2/2] soc: fsl: qbman: Use raw spinlock for cgr_lock

2024-03-05 Thread Sean Anderson
Hi,

On 2/23/24 11:02, Sean Anderson wrote:
> On 2/23/24 00:38, Christophe Leroy wrote:
>> Le 22/02/2024 à 18:07, Sean Anderson a écrit :
>>> [Vous ne recevez pas souvent de courriers de sean.ander...@linux.dev. 
>>> Découvrez pourquoi ceci est important à 
>>> https://aka.ms/LearnAboutSenderIdentification ]
>>> 
>>> cgr_lock may be locked with interrupts already disabled by
>>> smp_call_function_single. As such, we must use a raw spinlock to avoid
>>> problems on PREEMPT_RT kernels. Although this bug has existed for a
>>> while, it was not apparent until commit ef2a8d5478b9 ("net: dpaa: Adjust
>>> queue depth on rate change") which invokes smp_call_function_single via
>>> qman_update_cgr_safe every time a link goes up or down.
>> 
>> Why a raw spinlock to avoid problems on PREEMPT_RT, can you elaborate ?
> 
> smp_call_function always runs its callback in hard IRQ context, even on
> PREEMPT_RT, where spinlocks can sleep. So we need to use raw spinlocks
> to ensure we aren't waiting on a sleeping task. See the first bug report
> for more discussion.
> 
> In the longer term it would be better to switch to some other
> abstraction.

Does this make sense to you?

--Sean



Re: [PATCH] soc: fsl: qbman: Remove RESERVEDMEM_OF_DECLARE usage

2024-03-05 Thread Sean Anderson
On 3/5/24 13:02, Rob Herring wrote:
>
> On Thu, 01 Feb 2024 13:29:30 -0600, Rob Herring wrote:
>> There is no reason to use RESERVEDMEM_OF_DECLARE() as the initialization
>> hook just saves off the base address and size. Use of
>> RESERVEDMEM_OF_DECLARE() is reserved for non-driver code and
>> initialization which must be done early. For qbman, retrieving the
>> address and size can be done in probe just as easily.
>>
>> Signed-off-by: Rob Herring 
>> ---
>>  drivers/soc/fsl/qbman/bman_ccsr.c | 27 +++-
>>  drivers/soc/fsl/qbman/dpaa_sys.c  | 12 +++--
>>  drivers/soc/fsl/qbman/dpaa_sys.h  |  4 +-
>>  drivers/soc/fsl/qbman/qman_ccsr.c | 73 ++-
>>  4 files changed, 38 insertions(+), 78 deletions(-)
>>
>
> No one is going to pick this up? I applied to the DT tree.

As discussed in [1], this driver is currently orphaned.

--Sean

[1] https://lore.kernel.org/all/20240219153016.ntltc76bphwrv6hn@skbuf/


[Embedded World 2024, SECO 
SpA]


Re: [PATCH] soc: fsl: qbman: Remove RESERVEDMEM_OF_DECLARE usage

2024-03-05 Thread Rob Herring


On Thu, 01 Feb 2024 13:29:30 -0600, Rob Herring wrote:
> There is no reason to use RESERVEDMEM_OF_DECLARE() as the initialization
> hook just saves off the base address and size. Use of
> RESERVEDMEM_OF_DECLARE() is reserved for non-driver code and
> initialization which must be done early. For qbman, retrieving the
> address and size can be done in probe just as easily.
> 
> Signed-off-by: Rob Herring 
> ---
>  drivers/soc/fsl/qbman/bman_ccsr.c | 27 +++-
>  drivers/soc/fsl/qbman/dpaa_sys.c  | 12 +++--
>  drivers/soc/fsl/qbman/dpaa_sys.h  |  4 +-
>  drivers/soc/fsl/qbman/qman_ccsr.c | 73 ++-
>  4 files changed, 38 insertions(+), 78 deletions(-)
> 

No one is going to pick this up? I applied to the DT tree.

Rob


Re: [PATCH v3 02/10] mm/ppc: Replace pXd_is_leaf() with pXd_leaf()

2024-03-05 Thread Christophe Leroy


Le 05/03/2024 à 05:37, pet...@redhat.com a écrit :
> From: Peter Xu 
> 
> They're the same macros underneath.  Drop pXd_is_leaf(), instead always use
> pXd_leaf().
> 
> At the meantime, instead of renames, drop the pXd_is_leaf() fallback
> definitions directly in arch/powerpc/include/asm/pgtable.h. because similar
> fallback macros for pXd_leaf() are already defined in
> include/linux/pgtable.h.
> 
> Cc: Michael Ellerman 
> Cc: Nicholas Piggin 
> Cc: "Aneesh Kumar K.V" 
> Cc: "Naveen N. Rao" 
> Cc: linuxppc-dev@lists.ozlabs.org
> Suggested-by: Christophe Leroy 
> Reviewed-by: Jason Gunthorpe 
> Signed-off-by: Peter Xu 

Reviewed-by: Christophe Leroy 

In case you post a new version, in the subject, usually with use powerpc 
not ppc

> ---
>   arch/powerpc/include/asm/book3s/64/pgtable.h | 10 
>   arch/powerpc/include/asm/pgtable.h   | 24 
>   arch/powerpc/kvm/book3s_64_mmu_radix.c   | 12 +-
>   arch/powerpc/mm/book3s64/radix_pgtable.c | 14 ++--
>   arch/powerpc/mm/pgtable.c|  6 ++---
>   arch/powerpc/mm/pgtable_64.c |  6 ++---
>   arch/powerpc/xmon/xmon.c |  6 ++---
>   7 files changed, 26 insertions(+), 52 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
> b/arch/powerpc/include/asm/book3s/64/pgtable.h
> index d1318e8582ac..3e99e409774a 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
> @@ -1439,18 +1439,16 @@ static inline bool is_pte_rw_upgrade(unsigned long 
> old_val, unsigned long new_va
>   /*
>* Like pmd_huge() and pmd_large(), but works regardless of config options
>*/
> -#define pmd_is_leaf pmd_is_leaf
> -#define pmd_leaf pmd_is_leaf
> +#define pmd_leaf pmd_leaf
>   #define pmd_large pmd_leaf
> -static inline bool pmd_is_leaf(pmd_t pmd)
> +static inline bool pmd_leaf(pmd_t pmd)
>   {
>   return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
>   }
>   
> -#define pud_is_leaf pud_is_leaf
> -#define pud_leaf pud_is_leaf
> +#define pud_leaf pud_leaf
>   #define pud_large pud_leaf
> -static inline bool pud_is_leaf(pud_t pud)
> +static inline bool pud_leaf(pud_t pud)
>   {
>   return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
>   }
> diff --git a/arch/powerpc/include/asm/pgtable.h 
> b/arch/powerpc/include/asm/pgtable.h
> index 5928b3c1458d..e6edf1cdbc5b 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -182,30 +182,6 @@ static inline void pte_frag_set(mm_context_t *ctx, void 
> *p)
>   }
>   #endif
>   
> -#ifndef pmd_is_leaf
> -#define pmd_is_leaf pmd_is_leaf
> -static inline bool pmd_is_leaf(pmd_t pmd)
> -{
> - return false;
> -}
> -#endif
> -
> -#ifndef pud_is_leaf
> -#define pud_is_leaf pud_is_leaf
> -static inline bool pud_is_leaf(pud_t pud)
> -{
> - return false;
> -}
> -#endif
> -
> -#ifndef p4d_is_leaf
> -#define p4d_is_leaf p4d_is_leaf
> -static inline bool p4d_is_leaf(p4d_t p4d)
> -{
> - return false;
> -}
> -#endif
> -
>   #define pmd_pgtable pmd_pgtable
>   static inline pgtable_t pmd_pgtable(pmd_t pmd)
>   {
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c 
> b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> index 4a1abb9f7c05..408d98f8a514 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> @@ -503,7 +503,7 @@ static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t 
> *pmd, bool full,
>   for (im = 0; im < PTRS_PER_PMD; ++im, ++p) {
>   if (!pmd_present(*p))
>   continue;
> - if (pmd_is_leaf(*p)) {
> + if (pmd_leaf(*p)) {
>   if (full) {
>   pmd_clear(p);
>   } else {
> @@ -532,7 +532,7 @@ static void kvmppc_unmap_free_pud(struct kvm *kvm, pud_t 
> *pud,
>   for (iu = 0; iu < PTRS_PER_PUD; ++iu, ++p) {
>   if (!pud_present(*p))
>   continue;
> - if (pud_is_leaf(*p)) {
> + if (pud_leaf(*p)) {
>   pud_clear(p);
>   } else {
>   pmd_t *pmd;
> @@ -635,12 +635,12 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, 
> pte_t pte,
>   new_pud = pud_alloc_one(kvm->mm, gpa);
>   
>   pmd = NULL;
> - if (pud && pud_present(*pud) && !pud_is_leaf(*pud))
> + if (pud && pud_present(*pud) && !pud_leaf(*pud))
>   pmd = pmd_offset(pud, gpa);
>   else if (level <= 1)
>   new_pmd = kvmppc_pmd_alloc();
>   
> - if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_is_leaf(*pmd)))
> + if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_leaf(*pmd)))
>   new_ptep = kvmppc_pte_alloc();
>   
>   /* Check if we might have been invalidated; let the guest retry if so */
> @@ -658,7 +658,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, 
> pte_t pte,
>  

Re: [PATCH v3 01/10] mm/ppc: Define pXd_large() with pXd_leaf()

2024-03-05 Thread Christophe Leroy


Le 05/03/2024 à 05:37, pet...@redhat.com a écrit :
> From: Peter Xu 
> 
> The two definitions are the same.  The only difference is that pXd_large()
> is only defined with THP selected, and only on book3s 64bits.
> 
> Instead of implementing it twice, make pXd_large() a macro to pXd_leaf().
> Define it unconditionally just like pXd_leaf().  This helps to prepare
> merging the two APIs.
> 
> Cc: Michael Ellerman 
> Cc: Nicholas Piggin 
> Cc: Christophe Leroy 
> Cc: "Aneesh Kumar K.V" 
> Cc: "Naveen N. Rao" 
> Cc: linuxppc-dev@lists.ozlabs.org
> Reviewed-by: Jason Gunthorpe 
> Signed-off-by: Peter Xu 

Reviewed-by: Christophe Leroy 

> ---
>   arch/powerpc/include/asm/book3s/64/pgtable.h | 16 ++--
>   arch/powerpc/include/asm/pgtable.h   |  2 +-
>   2 files changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
> b/arch/powerpc/include/asm/book3s/64/pgtable.h
> index 927d585652bc..d1318e8582ac 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
> @@ -1157,20 +1157,6 @@ pud_hugepage_update(struct mm_struct *mm, unsigned 
> long addr, pud_t *pudp,
>   return pud_val(*pudp);
>   }
>   
> -/*
> - * returns true for pmd migration entries, THP, devmap, hugetlb
> - * But compile time dependent on THP config
> - */
> -static inline int pmd_large(pmd_t pmd)
> -{
> - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
> -}
> -
> -static inline int pud_large(pud_t pud)
> -{
> - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
> -}
> -
>   /*
>* For radix we should always find H_PAGE_HASHPTE zero. Hence
>* the below will work for radix too
> @@ -1455,6 +1441,7 @@ static inline bool is_pte_rw_upgrade(unsigned long 
> old_val, unsigned long new_va
>*/
>   #define pmd_is_leaf pmd_is_leaf
>   #define pmd_leaf pmd_is_leaf
> +#define pmd_large pmd_leaf
>   static inline bool pmd_is_leaf(pmd_t pmd)
>   {
>   return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
> @@ -1462,6 +1449,7 @@ static inline bool pmd_is_leaf(pmd_t pmd)
>   
>   #define pud_is_leaf pud_is_leaf
>   #define pud_leaf pud_is_leaf
> +#define pud_large pud_leaf
>   static inline bool pud_is_leaf(pud_t pud)
>   {
>   return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
> diff --git a/arch/powerpc/include/asm/pgtable.h 
> b/arch/powerpc/include/asm/pgtable.h
> index 7a1ba8889aea..5928b3c1458d 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -101,7 +101,7 @@ void poking_init(void);
>   extern unsigned long ioremap_bot;
>   extern const pgprot_t protection_map[16];
>   
> -#ifndef CONFIG_TRANSPARENT_HUGEPAGE
> +#ifndef pmd_large
>   #define pmd_large(pmd)  0
>   #endif
>   


[kvm-unit-tests PATCH v2 04/13] treewide: lib/stack: Make base_address arch specific

2024-03-05 Thread Andrew Jones
Calculating the offset of an address is image specific, which is
architecture specific. Until now, all architectures and architecture
configurations which select CONFIG_RELOC were able to subtract
_etext, but the EFI configuration of riscv cannot (it must subtract
ImageBase). Make this function weak, such that an architecture may
override it when necessary, to accommodate the image layout. Then,
immediately supply the riscv override.

Signed-off-by: Andrew Jones 
---
 lib/riscv/stack.c | 18 ++
 lib/stack.c   |  8 
 lib/stack.h   |  2 ++
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/lib/riscv/stack.c b/lib/riscv/stack.c
index d865594b9671..2cd7f012738b 100644
--- a/lib/riscv/stack.c
+++ b/lib/riscv/stack.c
@@ -2,6 +2,24 @@
 #include 
 #include 
 
+#ifdef CONFIG_RELOC
+extern char ImageBase, _text, _etext;
+
+bool arch_base_address(const void *rebased_addr, unsigned long *addr)
+{
+   unsigned long ra = (unsigned long)rebased_addr;
+   unsigned long base = (unsigned long)
+   unsigned long start = (unsigned long)&_text;
+   unsigned long end = (unsigned long)&_etext;
+
+   if (ra < start || ra >= end)
+   return false;
+
+   *addr = ra - base;
+   return true;
+}
+#endif
+
 int arch_backtrace_frame(const void *frame, const void **return_addrs,
 int max_depth, bool current_frame)
 {
diff --git a/lib/stack.c b/lib/stack.c
index dd6bfa8dac6e..086fec544a81 100644
--- a/lib/stack.c
+++ b/lib/stack.c
@@ -14,7 +14,7 @@
 #ifdef CONFIG_RELOC
 extern char _text, _etext;
 
-static bool base_address(const void *rebased_addr, unsigned long *addr)
+bool __attribute__((weak)) arch_base_address(const void *rebased_addr, 
unsigned long *addr)
 {
unsigned long ra = (unsigned long)rebased_addr;
unsigned long start = (unsigned long)&_text;
@@ -27,7 +27,7 @@ static bool base_address(const void *rebased_addr, unsigned 
long *addr)
return true;
 }
 #else
-static bool base_address(const void *rebased_addr, unsigned long *addr)
+bool __attribute__((weak)) arch_base_address(const void *rebased_addr, 
unsigned long *addr)
 {
*addr = (unsigned long)rebased_addr;
return true;
@@ -45,13 +45,13 @@ static void print_stack(const void **return_addrs, int 
depth,
/* @addr indicates a non-return address, as expected by the stack
 * pretty printer script. */
if (depth > 0 && !top_is_return_address) {
-   if (base_address(return_addrs[0], ))
+   if (arch_base_address(return_addrs[0], ))
printf(" @%lx", addr);
i++;
}
 
for (; i < depth; i++) {
-   if (base_address(return_addrs[i], ))
+   if (arch_base_address(return_addrs[i], ))
printf(" %lx", addr);
}
printf("\n");
diff --git a/lib/stack.h b/lib/stack.h
index 6edc84344b51..df076d94bf8f 100644
--- a/lib/stack.h
+++ b/lib/stack.h
@@ -34,4 +34,6 @@ static inline int backtrace_frame(const void *frame, const 
void **return_addrs,
 }
 #endif
 
+bool __attribute__((weak)) arch_base_address(const void *rebased_addr, 
unsigned long *addr);
+
 #endif
-- 
2.44.0



[kvm-unit-tests PATCH v2 03/13] treewide: lib/stack: Fix backtrace

2024-03-05 Thread Andrew Jones
We should never pass the result of __builtin_frame_address(0) to
another function since the compiler is within its rights to pop the
frame to which it points before making the function call, as may be
done for tail calls. Nobody has complained about backtrace(), so
likely all compilations have been inlining backtrace_frame(), not
dropping the frame on the tail call, or nobody is looking at traces.
However, for riscv, when built for EFI, it does drop the frame on the
tail call, and it was noticed. Preemptively fix backtrace() for all
architectures.

Fixes: 52266791750d ("lib: backtrace printing")
Acked-by: Claudio Imbrenda 
Reviewed-by: Nicholas Piggin 
Signed-off-by: Andrew Jones 
---
 lib/arm/stack.c   | 13 +
 lib/arm64/stack.c | 12 +---
 lib/riscv/stack.c | 12 +---
 lib/s390x/stack.c | 12 +---
 lib/stack.h   | 24 +---
 lib/x86/stack.c   | 12 +---
 6 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/lib/arm/stack.c b/lib/arm/stack.c
index 7d081be7c6d0..66d18b47ea53 100644
--- a/lib/arm/stack.c
+++ b/lib/arm/stack.c
@@ -8,13 +8,16 @@
 #include 
 #include 
 
-int backtrace_frame(const void *frame, const void **return_addrs,
-   int max_depth)
+int arch_backtrace_frame(const void *frame, const void **return_addrs,
+int max_depth, bool current_frame)
 {
static int walking;
int depth;
const unsigned long *fp = (unsigned long *)frame;
 
+   if (current_frame)
+   fp = __builtin_frame_address(0);
+
if (walking) {
printf("RECURSIVE STACK WALK!!!\n");
return 0;
@@ -33,9 +36,3 @@ int backtrace_frame(const void *frame, const void 
**return_addrs,
walking = 0;
return depth;
 }
-
-int backtrace(const void **return_addrs, int max_depth)
-{
-   return backtrace_frame(__builtin_frame_address(0),
-  return_addrs, max_depth);
-}
diff --git a/lib/arm64/stack.c b/lib/arm64/stack.c
index 82611f4b1815..f5eb57fd8892 100644
--- a/lib/arm64/stack.c
+++ b/lib/arm64/stack.c
@@ -8,7 +8,8 @@
 
 extern char vector_stub_start, vector_stub_end;
 
-int backtrace_frame(const void *frame, const void **return_addrs, int 
max_depth)
+int arch_backtrace_frame(const void *frame, const void **return_addrs,
+int max_depth, bool current_frame)
 {
const void *fp = frame;
static bool walking;
@@ -17,6 +18,9 @@ int backtrace_frame(const void *frame, const void 
**return_addrs, int max_depth)
bool is_exception = false;
unsigned long addr;
 
+   if (current_frame)
+   fp = __builtin_frame_address(0);
+
if (walking) {
printf("RECURSIVE STACK WALK!!!\n");
return 0;
@@ -54,9 +58,3 @@ int backtrace_frame(const void *frame, const void 
**return_addrs, int max_depth)
walking = false;
return depth;
 }
-
-int backtrace(const void **return_addrs, int max_depth)
-{
-   return backtrace_frame(__builtin_frame_address(0),
-  return_addrs, max_depth);
-}
diff --git a/lib/riscv/stack.c b/lib/riscv/stack.c
index 712a5478d547..d865594b9671 100644
--- a/lib/riscv/stack.c
+++ b/lib/riscv/stack.c
@@ -2,12 +2,16 @@
 #include 
 #include 
 
-int backtrace_frame(const void *frame, const void **return_addrs, int 
max_depth)
+int arch_backtrace_frame(const void *frame, const void **return_addrs,
+int max_depth, bool current_frame)
 {
static bool walking;
const unsigned long *fp = (unsigned long *)frame;
int depth;
 
+   if (current_frame)
+   fp = __builtin_frame_address(0);
+
if (walking) {
printf("RECURSIVE STACK WALK!!!\n");
return 0;
@@ -24,9 +28,3 @@ int backtrace_frame(const void *frame, const void 
**return_addrs, int max_depth)
walking = false;
return depth;
 }
-
-int backtrace(const void **return_addrs, int max_depth)
-{
-   return backtrace_frame(__builtin_frame_address(0),
-  return_addrs, max_depth);
-}
diff --git a/lib/s390x/stack.c b/lib/s390x/stack.c
index 9f234a12adf6..d194f654e94d 100644
--- a/lib/s390x/stack.c
+++ b/lib/s390x/stack.c
@@ -14,11 +14,15 @@
 #include 
 #include 
 
-int backtrace_frame(const void *frame, const void **return_addrs, int 
max_depth)
+int arch_backtrace_frame(const void *frame, const void **return_addrs,
+int max_depth, bool current_frame)
 {
int depth = 0;
struct stack_frame *stack = (struct stack_frame *)frame;
 
+   if (current_frame)
+   stack = __builtin_frame_address(0);
+
for (depth = 0; stack && depth < max_depth; depth++) {
return_addrs[depth] = (void *)stack->grs[8];
stack = stack->back_chain;
@@ -28,9 +32,3 @@ int backtrace_frame(const void *frame, const void 
**return_addrs, 

Re: [PATCHv11 2/4] genirq: Provide a snapshot mechanism for interrupt statistics

2024-03-05 Thread Thomas Gleixner
On Tue, Mar 05 2024 at 18:57, Bitao Hu wrote:
> On 2024/3/4 22:24, Thomas Gleixner wrote:
> "GENERIC_IRQ_STAT_SNAPSHOT" visible to the user. However, after
> analyzing the previous emails, it seems that what you were actually
> proposing was to directly disable "GENERIC_IRQ_STAT_SNAPSHOT" when
> "SOFTLOCKUP_DETECTOR_INTR_STORM" is not enabled, as a way to save
> memory. If my current understanding is correct, then the code for that
> part would look something like the following.

Correct.

> diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
> index 2531f3496ab6..a28e5ac5fc79 100644
> --- a/kernel/irq/Kconfig
> +++ b/kernel/irq/Kconfig
> @@ -108,6 +108,10 @@ config GENERIC_IRQ_MATRIX_ALLOCATOR
>   config GENERIC_IRQ_RESERVATION_MODE
>  bool
>
> +# Snapshot for interrupt statistics
> +config GENERIC_IRQ_STAT_SNAPSHOT
> +   bool
> +
>   # Support forced irq threading
>   config IRQ_FORCED_THREADING
>  bool
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 49f652674bd8..899b69fcb598 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -1032,6 +1032,7 @@ config SOFTLOCKUP_DETECTOR
>   config SOFTLOCKUP_DETECTOR_INTR_STORM
>  bool "Detect Interrupt Storm in Soft Lockups"
>  depends on SOFTLOCKUP_DETECTOR && IRQ_TIME_ACCOUNTING
> +   select GENERIC_IRQ_STAT_SNAPSHOT

This goes into the patch which adds the lockup detector parts.

Thanks,

tglx


[PATCH 0/6] ipmi: Convert to platform remove callback returning void

2024-03-05 Thread Uwe Kleine-König
Hello,

this series converts all drivers below drivers/char/ipmi to struct
platform_driver::remove_new(). See commit 5c5a7680e67b ("platform: Provide a
remove callback that returns no value") for an extended explanation and the
eventual goal.

All conversations are trivial, because their .remove() callbacks
returned zero unconditionally.

There are no interdependencies between these patches, so they could be
picked up individually. But I'd hope that they get picked up all
together by Corey.

Best regards
Uwe

Uwe Kleine-König (6):
  ipmi: bt-bmc: Convert to platform remove callback returning void
  ipmi: ipmi_powernv: Convert to platform remove callback returning void
  ipmi: ipmi_si_platform: Convert to platform remove callback returning void
  ipmi: ipmi_ssif: Convert to platform remove callback returning void
  ipmi: kcs_bmc_aspeed: Convert to platform remove callback returning void
  ipmi: kcs_bmc_npcm7xx: Convert to platform remove callback returning void

 drivers/char/ipmi/bt-bmc.c   | 5 ++---
 drivers/char/ipmi/ipmi_powernv.c | 6 ++
 drivers/char/ipmi/ipmi_si_platform.c | 6 ++
 drivers/char/ipmi/ipmi_ssif.c| 5 ++---
 drivers/char/ipmi/kcs_bmc_aspeed.c   | 6 ++
 drivers/char/ipmi/kcs_bmc_npcm7xx.c  | 6 ++
 6 files changed, 12 insertions(+), 22 deletions(-)

base-commit: 11afac187274a6177a7ac82997f8691c0f469e41
-- 
2.43.0



[PATCH 2/6] ipmi: ipmi_powernv: Convert to platform remove callback returning void

2024-03-05 Thread Uwe Kleine-König
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König 
---
 drivers/char/ipmi/ipmi_powernv.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_powernv.c b/drivers/char/ipmi/ipmi_powernv.c
index da22a8cbe68e..c59a86eb58c7 100644
--- a/drivers/char/ipmi/ipmi_powernv.c
+++ b/drivers/char/ipmi/ipmi_powernv.c
@@ -281,15 +281,13 @@ static int ipmi_powernv_probe(struct platform_device 
*pdev)
return rc;
 }
 
-static int ipmi_powernv_remove(struct platform_device *pdev)
+static void ipmi_powernv_remove(struct platform_device *pdev)
 {
struct ipmi_smi_powernv *smi = dev_get_drvdata(>dev);
 
ipmi_unregister_smi(smi->intf);
free_irq(smi->irq, smi);
irq_dispose_mapping(smi->irq);
-
-   return 0;
 }
 
 static const struct of_device_id ipmi_powernv_match[] = {
@@ -304,7 +302,7 @@ static struct platform_driver powernv_ipmi_driver = {
.of_match_table = ipmi_powernv_match,
},
.probe  = ipmi_powernv_probe,
-   .remove = ipmi_powernv_remove,
+   .remove_new = ipmi_powernv_remove,
 };
 
 
-- 
2.43.0



Re: [PATCH v3 04/10] mm/x86: Replace pgd_large() with pgd_leaf()

2024-03-05 Thread Jason Gunthorpe
On Tue, Mar 05, 2024 at 12:37:44PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> pgd_leaf() is a global API while pgd_large() is not.  Always use
> the global pgd_leaf(), then drop pgd_large().
> 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: Borislav Petkov 
> Cc: Dave Hansen 
> Cc: x...@kernel.org
> Signed-off-by: Peter Xu 
> ---
>  arch/x86/include/asm/pgtable.h | 4 ++--
>  arch/x86/mm/pti.c  | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Jason Gunthorpe 

Jason


[PATCH] powerpc/bpf/32: Fix failing test_bpf tests

2024-03-05 Thread Christophe Leroy
Recent additions in BPF like cpu v4 instructions, test_bpf module
exhibits the following failures:

test_bpf: #82 ALU_MOVSX | BPF_B jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 
times)
test_bpf: #83 ALU_MOVSX | BPF_H jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 
times)
test_bpf: #84 ALU64_MOVSX | BPF_B jited:1 ret 2 != 1 (0x2 != 0x1)FAIL 
(1 times)
test_bpf: #85 ALU64_MOVSX | BPF_H jited:1 ret 2 != 1 (0x2 != 0x1)FAIL 
(1 times)
test_bpf: #86 ALU64_MOVSX | BPF_W jited:1 ret 2 != 1 (0x2 != 0x1)FAIL 
(1 times)

test_bpf: #165 ALU_SDIV_X: -6 / 2 = -3 jited:1 ret 2147483645 != -3 
(0x7ffd != 0xfffd)FAIL (1 times)
test_bpf: #166 ALU_SDIV_K: -6 / 2 = -3 jited:1 ret 2147483645 != -3 
(0x7ffd != 0xfffd)FAIL (1 times)

test_bpf: #169 ALU_SMOD_X: -7 % 2 = -1 jited:1 ret 1 != -1 (0x1 != 
0x)FAIL (1 times)
test_bpf: #170 ALU_SMOD_K: -7 % 2 = -1 jited:1 ret 1 != -1 (0x1 != 
0x)FAIL (1 times)

test_bpf: #172 ALU64_SMOD_K: -7 % 2 = -1 jited:1 ret 1 != -1 (0x1 != 
0x)FAIL (1 times)

test_bpf: #313 BSWAP 16: 0x0123456789abcdef -> 0xefcd
eBPF filter opcode 00d7 (@2) unsupported
jited:0 301 PASS
test_bpf: #314 BSWAP 32: 0x0123456789abcdef -> 0xefcdab89
eBPF filter opcode 00d7 (@2) unsupported
jited:0 555 PASS
test_bpf: #315 BSWAP 64: 0x0123456789abcdef -> 0x67452301
eBPF filter opcode 00d7 (@2) unsupported
jited:0 268 PASS
test_bpf: #316 BSWAP 64: 0x0123456789abcdef >> 32 -> 0xefcdab89
eBPF filter opcode 00d7 (@2) unsupported
jited:0 269 PASS
test_bpf: #317 BSWAP 16: 0xfedcba9876543210 -> 0x1032
eBPF filter opcode 00d7 (@2) unsupported
jited:0 460 PASS
test_bpf: #318 BSWAP 32: 0xfedcba9876543210 -> 0x10325476
eBPF filter opcode 00d7 (@2) unsupported
jited:0 320 PASS
test_bpf: #319 BSWAP 64: 0xfedcba9876543210 -> 0x98badcfe
eBPF filter opcode 00d7 (@2) unsupported
jited:0 222 PASS
test_bpf: #320 BSWAP 64: 0xfedcba9876543210 >> 32 -> 0x10325476
eBPF filter opcode 00d7 (@2) unsupported
jited:0 273 PASS

test_bpf: #344 BPF_LDX_MEMSX | BPF_B
eBPF filter opcode 0091 (@5) unsupported
jited:0 432 PASS
test_bpf: #345 BPF_LDX_MEMSX | BPF_H
eBPF filter opcode 0089 (@5) unsupported
jited:0 381 PASS
test_bpf: #346 BPF_LDX_MEMSX | BPF_W
eBPF filter opcode 0081 (@5) unsupported
jited:0 505 PASS

test_bpf: #490 JMP32_JA: Unconditional jump: if (true) return 1
eBPF filter opcode 0006 (@1) unsupported
jited:0 261 PASS

test_bpf: Summary: 1040 PASSED, 10 FAILED, [924/1038 JIT'ed]

Fix them by adding missing processing.

Fixes: daabb2b098e0 ("bpf/tests: add tests for cpuv4 instructions")
Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/ppc-opcode.h |   4 +
 arch/powerpc/net/bpf_jit_comp32.c | 137 --
 2 files changed, 110 insertions(+), 31 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
b/arch/powerpc/include/asm/ppc-opcode.h
index 005601243dda..076ae60b4a55 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -510,6 +510,7 @@
 #define PPC_RAW_STB(r, base, i)(0x9800 | ___PPC_RS(r) | 
___PPC_RA(base) | IMM_L(i))
 #define PPC_RAW_LBZ(r, base, i)(0x8800 | ___PPC_RT(r) | 
___PPC_RA(base) | IMM_L(i))
 #define PPC_RAW_LDX(r, base, b)(0x7c2a | ___PPC_RT(r) | 
___PPC_RA(base) | ___PPC_RB(b))
+#define PPC_RAW_LHA(r, base, i)(0xa800 | ___PPC_RT(r) | 
___PPC_RA(base) | IMM_L(i))
 #define PPC_RAW_LHZ(r, base, i)(0xa000 | ___PPC_RT(r) | 
___PPC_RA(base) | IMM_L(i))
 #define PPC_RAW_LHBRX(r, base, b)  (0x7c00062c | ___PPC_RT(r) | 
___PPC_RA(base) | ___PPC_RB(b))
 #define PPC_RAW_LWBRX(r, base, b)  (0x7c00042c | ___PPC_RT(r) | 
___PPC_RA(base) | ___PPC_RB(b))
@@ -532,6 +533,7 @@
 #define PPC_RAW_MULW(d, a, b)  (0x7c0001d6 | ___PPC_RT(d) | 
___PPC_RA(a) | ___PPC_RB(b))
 #define PPC_RAW_MULHWU(d, a, b)(0x7c16 | ___PPC_RT(d) | 
___PPC_RA(a) | ___PPC_RB(b))
 #define PPC_RAW_MULI(d, a, i)  (0x1c00 | ___PPC_RT(d) | 
___PPC_RA(a) | IMM_L(i))
+#define PPC_RAW_DIVW(d, a, b)  (0x7c0003d6 | ___PPC_RT(d) | 
___PPC_RA(a) | ___PPC_RB(b))
 #define PPC_RAW_DIVWU(d, a, b) (0x7c000396 | ___PPC_RT(d) | 
___PPC_RA(a) | ___PPC_RB(b))
 #define PPC_RAW_DIVDU(d, a, b) (0x7c000392 | ___PPC_RT(d) | 
___PPC_RA(a) | ___PPC_RB(b))
 #define PPC_RAW_DIVDE(t, a, b) (0x7c000352 | ___PPC_RT(t) | 
___PPC_RA(a) | ___PPC_RB(b))
@@ -550,6 +552,8 @@
 #define PPC_RAW_XOR(d, a, b)   (0x7c000278 | ___PPC_RA(d) | 
___PPC_RS(a) | ___PPC_RB(b))
 #define PPC_RAW_XORI(d, a, i)  (0x6800 | ___PPC_RA(d) | 

Re: [PATCH v5 0/5] Add support for QMC HDLC

2024-03-05 Thread Andy Shevchenko
On Tue, Mar 05, 2024 at 12:02:26PM +0100, Herve Codina wrote:
> On Thu, 29 Feb 2024 17:23:32 +0200
> Andy Shevchenko  wrote:

...

> > I think it's a good series and next version will be final. The only 
> > question is
> > possible use of the returned values from bitmap_scatter()/bitmap_gather(), 
> > the
> > rest are minors.
> 
> I replied about the reason why I didn't return any values from
> bitmap_{scatter,gather}() in that patch 4 discussion.
> 
> Are you ok to keep them returning void in this series ?

Sure. We can amend that later if needed.

-- 
With Best Regards,
Andy Shevchenko




Re: [RFC v2.1 07/12] powerpc: Use initializer for struct vm_unmapped_area_info

2024-03-05 Thread Edgecombe, Rick P
On Tue, 2024-03-05 at 11:51 +1100, Michael Ellerman wrote:
> I gave it a quick boot test, all good.
> 
> Acked-by: Michael Ellerman  (powerpc)

Thanks! Christophe was advocating for slight spin on this (not doing
the member initializing in the declaration, but dropping the
assignments that set 0):
https://lore.kernel.org/lkml/ec3e377a-c0a0-4dd3-9cb9-96517e54d...@csgroup.eu/

I'll leave it as tested here, unless I hear otherwise.


Re: [PATCH v3 10/10] mm/treewide: Align up pXd_leaf() retval across archs

2024-03-05 Thread Jason Gunthorpe
On Tue, Mar 05, 2024 at 12:37:50PM +0800, pet...@redhat.com wrote:
> From: Peter Xu 
> 
> Even if pXd_leaf() API is defined globally, it's not clear on the retval,
> and there are three types used (bool, int, unsigned log).
> 
> Always return a boolean for pXd_leaf() APIs.
> 
> Suggested-by: Jason Gunthorpe 
> Signed-off-by: Peter Xu 
> ---
>  arch/riscv/include/asm/pgtable-64.h | 2 +-
>  arch/riscv/include/asm/pgtable.h| 2 +-
>  arch/s390/include/asm/pgtable.h | 4 ++--
>  arch/sparc/include/asm/pgtable_64.h | 4 ++--
>  arch/x86/include/asm/pgtable.h  | 8 
>  include/linux/pgtable.h | 8 
>  6 files changed, 14 insertions(+), 14 deletions(-)

Reviewed-by: Jason Gunthorpe 

Jason


[PATCH] selftests/powerpc: Fix load_unaligned_zeropad build failure

2024-03-05 Thread Michael Ellerman
This test is userspace code, but uses some kernel headers via symlinks,
and mocks other headers, in order to test load_unaligned_zeropad().

Currently the test fails to build with:

  In file included from load_unaligned_zeropad.c:26:
  word-at-a-time.h:7:10: fatal error: linux/bitops.h: No such file or directory
  7 | #include 

This is due to the recent changes to the kernel headers.

Fix it by symlinking the new wordpart.h, and creating an empty stub for
bitops.h which is all that's needed.

Reported-by: Sachin Sant 
Tested-by: Sachin Sant 
Fixes: 66a5c40f60f5 ("kernel.h: removed REPEAT_BYTE from kernel.h")
Signed-off-by: Michael Ellerman 
---
 tools/testing/selftests/powerpc/primitives/linux/bitops.h   | 0
 tools/testing/selftests/powerpc/primitives/linux/wordpart.h | 1 +
 2 files changed, 1 insertion(+)
 create mode 100644 tools/testing/selftests/powerpc/primitives/linux/bitops.h
 create mode 12 tools/testing/selftests/powerpc/primitives/linux/wordpart.h

Kees, do you mind taking this one via your tree because that's where the commit
that changes the headers is?

diff --git a/tools/testing/selftests/powerpc/primitives/linux/bitops.h 
b/tools/testing/selftests/powerpc/primitives/linux/bitops.h
new file mode 100644
index ..e69de29bb2d1
diff --git a/tools/testing/selftests/powerpc/primitives/linux/wordpart.h 
b/tools/testing/selftests/powerpc/primitives/linux/wordpart.h
new file mode 12
index ..4a74d2cbbc9b
--- /dev/null
+++ b/tools/testing/selftests/powerpc/primitives/linux/wordpart.h
@@ -0,0 +1 @@
+../../../../../../include/linux/wordpart.h
\ No newline at end of file
-- 
2.43.2



[PATCH 3/3] powerpc/4xx: Fix warp_gpio_leds build failure

2024-03-05 Thread Michael Ellerman
The 44x/warp_defconfig build fails with:

  arch/powerpc/platforms/44x/warp.c:109:15: error: variable ‘warp_gpio_leds’ 
has initializer but incomplete type
109 | static struct platform_device warp_gpio_leds = {
|   ^~~

Fix it by including platform_device.h.

Fixes: ef175b29a242 ("of: Stop circularly including of_device.h and 
of_platform.h")
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/platforms/44x/warp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/platforms/44x/warp.c 
b/arch/powerpc/platforms/44x/warp.c
index bf0188dcb918..a5001d32f978 100644
--- a/arch/powerpc/platforms/44x/warp.c
+++ b/arch/powerpc/platforms/44x/warp.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.43.2



[PATCH 1/3] powerpc/embedded6xx: Fix no previous prototype for avr_uart_send() etc.

2024-03-05 Thread Michael Ellerman
Move the prototypes into mpc10x.h which is included by all the relevant
C files, fixes:

  arch/powerpc/platforms/embedded6xx/ls_uart.c:59:6: error: no previous 
prototype for 'avr_uart_configure'
  arch/powerpc/platforms/embedded6xx/ls_uart.c:82:6: error: no previous 
prototype for 'avr_uart_send'

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/platforms/embedded6xx/linkstation.c | 3 ---
 arch/powerpc/platforms/embedded6xx/mpc10x.h  | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c 
b/arch/powerpc/platforms/embedded6xx/linkstation.c
index 9c10aac40c7b..e265f026eee2 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -99,9 +99,6 @@ static void __init linkstation_init_IRQ(void)
mpic_init(mpic);
 }
 
-extern void avr_uart_configure(void);
-extern void avr_uart_send(const char);
-
 static void __noreturn linkstation_restart(char *cmd)
 {
local_irq_disable();
diff --git a/arch/powerpc/platforms/embedded6xx/mpc10x.h 
b/arch/powerpc/platforms/embedded6xx/mpc10x.h
index 5ad12023e562..ebc258fa4858 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc10x.h
+++ b/arch/powerpc/platforms/embedded6xx/mpc10x.h
@@ -156,4 +156,7 @@ int mpc10x_disable_store_gathering(struct pci_controller 
*hose);
 /* For MPC107 boards that use the built-in openpic */
 void mpc10x_set_openpic(void);
 
+void avr_uart_configure(void);
+void avr_uart_send(const char c);
+
 #endif /* __PPC_KERNEL_MPC10X_H */
-- 
2.43.2



[PATCH 2/3] powerpc/amigaone: Make several functions static

2024-03-05 Thread Michael Ellerman
These functions can all be static. Make them so. That also fixes no
previous prototype warnings:

  arch/powerpc/platforms/amigaone/setup.c:28:6: error: no previous prototype 
for 'amigaone_show_cpuinfo'
  arch/powerpc/platforms/amigaone/setup.c:68:13: error: no previous prototype 
for 'amigaone_setup_arch'
  arch/powerpc/platforms/amigaone/setup.c:86:13: error: no previous prototype 
for 'amigaone_init_IRQ'
  arch/powerpc/platforms/amigaone/setup.c:126:17: error: no previous prototype 
for 'amigaone_restart'

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/platforms/amigaone/setup.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/amigaone/setup.c 
b/arch/powerpc/platforms/amigaone/setup.c
index 6c6e714a7521..2c8dc0886912 100644
--- a/arch/powerpc/platforms/amigaone/setup.c
+++ b/arch/powerpc/platforms/amigaone/setup.c
@@ -25,7 +25,7 @@
 
 extern void __flush_disable_L1(void);
 
-void amigaone_show_cpuinfo(struct seq_file *m)
+static void amigaone_show_cpuinfo(struct seq_file *m)
 {
seq_printf(m, "vendor\t\t: Eyetech Ltd.\n");
 }
@@ -65,7 +65,7 @@ static int __init amigaone_add_bridge(struct device_node *dev)
return 0;
 }
 
-void __init amigaone_setup_arch(void)
+static void __init amigaone_setup_arch(void)
 {
if (ppc_md.progress)
ppc_md.progress("Linux/PPC "UTS_RELEASE"\n", 0);
@@ -83,7 +83,7 @@ static void __init amigaone_discover_phbs(void)
BUG_ON(phb != 0);
 }
 
-void __init amigaone_init_IRQ(void)
+static void __init amigaone_init_IRQ(void)
 {
struct device_node *pic, *np = NULL;
const unsigned long *prop = NULL;
@@ -123,7 +123,7 @@ static int __init request_isa_regions(void)
 }
 machine_device_initcall(amigaone, request_isa_regions);
 
-void __noreturn amigaone_restart(char *cmd)
+static void __noreturn amigaone_restart(char *cmd)
 {
local_irq_disable();
 
-- 
2.43.2



Re: [kvm-unit-tests PATCH 14/32] powerpc: general interrupt tests

2024-03-05 Thread Andrew Jones
On Tue, Mar 05, 2024 at 07:26:18AM +0100, Thomas Huth wrote:
> On 05/03/2024 03.19, Nicholas Piggin wrote:
> > On Fri Mar 1, 2024 at 10:41 PM AEST, Thomas Huth wrote:
> > > On 26/02/2024 11.12, Nicholas Piggin wrote:
> > > > Add basic testing of various kinds of interrupts, machine check,
> > > > page fault, illegal, decrementer, trace, syscall, etc.
> > > > 
> > > > This has a known failure on QEMU TCG pseries machines where MSR[ME]
> > > > can be incorrectly set to 0.
> > > 
> > > Two questions out of curiosity:
> > > 
> > > Any chance that this could be fixed easily in QEMU?
> > 
> > Yes I have a fix on the mailing list. It should get into 9.0 and
> > probably stable.
> 
> Ok, then it's IMHO not worth the effort to make the k-u-t work around this
> bug in older QEMU versions.
> 
> > > Or is there a way to detect TCG from within the test? (for example, we 
> > > have
> > > a host_is_tcg() function for s390x so we can e.g. use report_xfail() for
> > > tests that are known to fail on TCG there)
> > 
> > I do have a half-done patch which adds exactly this.
> > 
> > One (minor) annoyance is that it doesn't seem possible to detect QEMU
> > version to add workarounds. E.g., we would like to test the fixed
> > functionality, but older qemu should not. Maybe that's going too much
> > into a rabbit hole. We *could* put a QEMU version into device tree
> > to deal with this though...
> 
> No, let's better not do this - hardwired version checks are often a bad
> idea, e.g. when a bug is in QEMU 8.0.0 and 8.1.0, it could be fixed in 8.0.1
> and then it could get really messy with the version checks...
>

We've tried to address this type of issue (but for KVM, so kernel versions
instead of QEMU versions) in the past by inventing the errata framework,
which is based on environment variables. Instead of checking for versions,
we check for a hash (which is just the commit hash of the fix). While we
do guess that the fix is present by version number, it can always be
manually set as present as well. In any case, the test is simply skipped
when the errata environment variable isn't present, so in the worst case
we lose some coverage we could have had, but the rest of the tests still
complete and we don't get the same failures over and over. An example of
its use is in arm/psci.c. Look for the ERRATA() calls.

We could extend the errata framework for QEMU/TCG. We just need to add
another bit of data to the errata.txt file for it to know it should
check QEMU versions instead of kernel versions for those errata. We can
also ignore the errata framework and just create the errata environment
variable which would by 'n' by default now and later, after distros have
fixes, it could be changed to 'y'.

Thanks,
drew


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

2024-03-05 Thread Johannes Berg
On Mon, 2024-02-26 at 17:14 +0100, Arnd Bergmann wrote:
> 
>  arch/um/Kconfig| 1 +
>  arch/um/include/asm/page.h | 2 +-


LGTM, thanks.

Acked-by: Johannes Berg 

johannes


Re: [PATCH v5 0/5] Add support for QMC HDLC

2024-03-05 Thread Herve Codina
Hi Andy,

On Thu, 29 Feb 2024 17:23:32 +0200
Andy Shevchenko  wrote:

...

> 
> I think it's a good series and next version will be final. The only question 
> is
> possible use of the returned values from bitmap_scatter()/bitmap_gather(), the
> rest are minors.

I replied about the reason why I didn't return any values from
bitmap_{scatter,gather}() in that patch 4 discussion.

Are you ok to keep them returning void in this series ?

Best regards,
Hervé

-- 
Hervé Codina, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


Re: [PATCHv11 2/4] genirq: Provide a snapshot mechanism for interrupt statistics

2024-03-05 Thread Bitao Hu

Hi,

On 2024/3/4 22:24, Thomas Gleixner wrote:

The above is not even configurable by the user. It's only selectable by
some other config option.


+# Snapshot for interrupt statistics
+config GENERIC_IRQ_STAT_SNAPSHOT
+   bool
+   help
+
+ Say Y here to enable the kernel to provide a snapshot mechanism
+ for interrupt statistics.


That makes is visible which is pointless because it's only relevant when
there is an actual user.

I guess I may have misunderstood your intentions earlier. Initially, I
thought you were suggesting that when "SOFTLOCKUP_DETECTOR_INTR_STORM"
is not enabled, people should be able to choose
"GENERIC_IRQ_STAT_SNAPSHOT" through menuconfig, so I attempted to make
"GENERIC_IRQ_STAT_SNAPSHOT" visible to the user. However, after
analyzing the previous emails, it seems that what you were actually
proposing was to directly disable "GENERIC_IRQ_STAT_SNAPSHOT" when
"SOFTLOCKUP_DETECTOR_INTR_STORM" is not enabled, as a way to save
memory. If my current understanding is correct, then the code for that
part would look something like the following.

Does this align with your expectations?

Best Regards,
Bitao Hu

diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 2531f3496ab6..a28e5ac5fc79 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -108,6 +108,10 @@ config GENERIC_IRQ_MATRIX_ALLOCATOR
 config GENERIC_IRQ_RESERVATION_MODE
bool

+# Snapshot for interrupt statistics
+config GENERIC_IRQ_STAT_SNAPSHOT
+   bool
+
 # Support forced irq threading
 config IRQ_FORCED_THREADING
bool
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 49f652674bd8..899b69fcb598 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1032,6 +1032,7 @@ config SOFTLOCKUP_DETECTOR
 config SOFTLOCKUP_DETECTOR_INTR_STORM
bool "Detect Interrupt Storm in Soft Lockups"
depends on SOFTLOCKUP_DETECTOR && IRQ_TIME_ACCOUNTING
+   select GENERIC_IRQ_STAT_SNAPSHOT
default y if NR_CPUS <= 128
help
  Say Y here to enable the kernel to detect interrupt storm








Re: [PATCH v2 3/3] arch/powerpc: Remove from backlight code

2024-03-05 Thread Christophe Leroy


Le 05/03/2024 à 11:04, Thomas Zimmermann a écrit :
> Hi
> 
> Am 05.03.24 um 10:25 schrieb Christophe Leroy:
>>
>> Le 05/03/2024 à 10:01, Thomas Zimmermann a écrit :
>>> Replace  with a forward declaration in  to
>>> resolves an unnecessary dependency. Remove pmac_backlight_curve_lookup()
>>> and struct fb_info from source and header files. The function and the
>>> framebuffer struct is unused. No functional changes.
>> When you remove pmac_backlight_curve_lookup() prototype you'll then get
>> a warning/error about missing prototype when building
>> arch/powerpc/platforms/powermac/backlight.c
>>
>> The fonction is not used outside of that file so it should be static.
>> And then it is not used in that file either so it should be removed
>> completely. Indeed last use of that function was removed by commit
>> d565dd3b0824 ("[PATCH] powerpc: More via-pmu backlight fixes") so the
>> function can safely be removed.
> 
> Isn't that what my patch is doing? I have no callers of the function in 
> my tree (drm-tip), so I removed it entirely. Should I add a Fixes tag 
> against commit d565dd3b0824? Best regards Thomas

Sorry I overlooked your patch and focussed on the removal of the 
prototype and missed the removal of the function.

Christophe

>>
>> Christophe
>>
>>> Signed-off-by: Thomas Zimmermann 
>>> ---
>>>    arch/powerpc/include/asm/backlight.h    |  5 ++--
>>>    arch/powerpc/platforms/powermac/backlight.c | 26 
>>> -
>>>    2 files changed, 2 insertions(+), 29 deletions(-)
>>>
>>> diff --git a/arch/powerpc/include/asm/backlight.h 
>>> b/arch/powerpc/include/asm/backlight.h
>>> index 1b5eab62ed047..061a910d74929 100644
>>> --- a/arch/powerpc/include/asm/backlight.h
>>> +++ b/arch/powerpc/include/asm/backlight.h
>>> @@ -10,15 +10,14 @@
>>>    #define __ASM_POWERPC_BACKLIGHT_H
>>>    #ifdef __KERNEL__
>>> -#include 
>>>    #include 
>>> +struct backlight_device;
>>> +
>>>    /* For locking instructions, see the implementation file */
>>>    extern struct backlight_device *pmac_backlight;
>>>    extern struct mutex pmac_backlight_mutex;
>>> -extern int pmac_backlight_curve_lookup(struct fb_info *info, int 
>>> value);
>>> -
>>>    extern int pmac_has_backlight_type(const char *type);
>>>    extern void pmac_backlight_key(int direction);
>>> diff --git a/arch/powerpc/platforms/powermac/backlight.c 
>>> b/arch/powerpc/platforms/powermac/backlight.c
>>> index aeb79a8b3e109..12bc01353bd3c 100644
>>> --- a/arch/powerpc/platforms/powermac/backlight.c
>>> +++ b/arch/powerpc/platforms/powermac/backlight.c
>>> @@ -9,7 +9,6 @@
>>>     */
>>>    #include 
>>> -#include 
>>>    #include 
>>>    #include 
>>>    #include 
>>> @@ -72,31 +71,6 @@ int pmac_has_backlight_type(const char *type)
>>>    return 0;
>>>    }
>>> -int pmac_backlight_curve_lookup(struct fb_info *info, int value)
>>> -{
>>> -    int level = (FB_BACKLIGHT_LEVELS - 1);
>>> -
>>> -    if (info && info->bl_dev) {
>>> -    int i, max = 0;
>>> -
>>> -    /* Look for biggest value */
>>> -    for (i = 0; i < FB_BACKLIGHT_LEVELS; i++)
>>> -    max = max((int)info->bl_curve[i], max);
>>> -
>>> -    /* Look for nearest value */
>>> -    for (i = 0; i < FB_BACKLIGHT_LEVELS; i++) {
>>> -    int diff = abs(info->bl_curve[i] - value);
>>> -    if (diff < max) {
>>> -    max = diff;
>>> -    level = i;
>>> -    }
>>> -    }
>>> -
>>> -    }
>>> -
>>> -    return level;
>>> -}
>>> -
>>>    static void pmac_backlight_key_worker(struct work_struct *work)
>>>    {
>>>    if (atomic_read(_backlight_disabled))
> 


Re: [PATCH v2 3/3] arch/powerpc: Remove from backlight code

2024-03-05 Thread Thomas Zimmermann

Hi

Am 05.03.24 um 10:25 schrieb Christophe Leroy:


Le 05/03/2024 à 10:01, Thomas Zimmermann a écrit :

Replace  with a forward declaration in  to
resolves an unnecessary dependency. Remove pmac_backlight_curve_lookup()
and struct fb_info from source and header files. The function and the
framebuffer struct is unused. No functional changes.

When you remove pmac_backlight_curve_lookup() prototype you'll then get
a warning/error about missing prototype when building
arch/powerpc/platforms/powermac/backlight.c

The fonction is not used outside of that file so it should be static.
And then it is not used in that file either so it should be removed
completely. Indeed last use of that function was removed by commit
d565dd3b0824 ("[PATCH] powerpc: More via-pmu backlight fixes") so the
function can safely be removed.


Isn't that what my patch is doing? I have no callers of the function in 
my tree (drm-tip), so I removed it entirely. Should I add a Fixes tag 
against commit d565dd3b0824? Best regards Thomas


Christophe


Signed-off-by: Thomas Zimmermann 
---
   arch/powerpc/include/asm/backlight.h|  5 ++--
   arch/powerpc/platforms/powermac/backlight.c | 26 -
   2 files changed, 2 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/include/asm/backlight.h 
b/arch/powerpc/include/asm/backlight.h
index 1b5eab62ed047..061a910d74929 100644
--- a/arch/powerpc/include/asm/backlight.h
+++ b/arch/powerpc/include/asm/backlight.h
@@ -10,15 +10,14 @@
   #define __ASM_POWERPC_BACKLIGHT_H
   #ifdef __KERNEL__
   
-#include 

   #include 
   
+struct backlight_device;

+
   /* For locking instructions, see the implementation file */
   extern struct backlight_device *pmac_backlight;
   extern struct mutex pmac_backlight_mutex;
   
-extern int pmac_backlight_curve_lookup(struct fb_info *info, int value);

-
   extern int pmac_has_backlight_type(const char *type);
   
   extern void pmac_backlight_key(int direction);

diff --git a/arch/powerpc/platforms/powermac/backlight.c 
b/arch/powerpc/platforms/powermac/backlight.c
index aeb79a8b3e109..12bc01353bd3c 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -9,7 +9,6 @@
*/
   
   #include 

-#include 
   #include 
   #include 
   #include 
@@ -72,31 +71,6 @@ int pmac_has_backlight_type(const char *type)
return 0;
   }
   
-int pmac_backlight_curve_lookup(struct fb_info *info, int value)

-{
-   int level = (FB_BACKLIGHT_LEVELS - 1);
-
-   if (info && info->bl_dev) {
-   int i, max = 0;
-
-   /* Look for biggest value */
-   for (i = 0; i < FB_BACKLIGHT_LEVELS; i++)
-   max = max((int)info->bl_curve[i], max);
-
-   /* Look for nearest value */
-   for (i = 0; i < FB_BACKLIGHT_LEVELS; i++) {
-   int diff = abs(info->bl_curve[i] - value);
-   if (diff < max) {
-   max = diff;
-   level = i;
-   }
-   }
-
-   }
-
-   return level;
-}
-
   static void pmac_backlight_key_worker(struct work_struct *work)
   {
if (atomic_read(_backlight_disabled))


--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)



Re: [PATCH v2 3/3] arch/powerpc: Remove from backlight code

2024-03-05 Thread Christophe Leroy


Le 05/03/2024 à 10:01, Thomas Zimmermann a écrit :
> Replace  with a forward declaration in  to
> resolves an unnecessary dependency. Remove pmac_backlight_curve_lookup()
> and struct fb_info from source and header files. The function and the
> framebuffer struct is unused. No functional changes.

When you remove pmac_backlight_curve_lookup() prototype you'll then get 
a warning/error about missing prototype when building 
arch/powerpc/platforms/powermac/backlight.c

The fonction is not used outside of that file so it should be static. 
And then it is not used in that file either so it should be removed 
completely. Indeed last use of that function was removed by commit 
d565dd3b0824 ("[PATCH] powerpc: More via-pmu backlight fixes") so the 
function can safely be removed.

Christophe

> 
> Signed-off-by: Thomas Zimmermann 
> ---
>   arch/powerpc/include/asm/backlight.h|  5 ++--
>   arch/powerpc/platforms/powermac/backlight.c | 26 -
>   2 files changed, 2 insertions(+), 29 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/backlight.h 
> b/arch/powerpc/include/asm/backlight.h
> index 1b5eab62ed047..061a910d74929 100644
> --- a/arch/powerpc/include/asm/backlight.h
> +++ b/arch/powerpc/include/asm/backlight.h
> @@ -10,15 +10,14 @@
>   #define __ASM_POWERPC_BACKLIGHT_H
>   #ifdef __KERNEL__
>   
> -#include 
>   #include 
>   
> +struct backlight_device;
> +
>   /* For locking instructions, see the implementation file */
>   extern struct backlight_device *pmac_backlight;
>   extern struct mutex pmac_backlight_mutex;
>   
> -extern int pmac_backlight_curve_lookup(struct fb_info *info, int value);
> -
>   extern int pmac_has_backlight_type(const char *type);
>   
>   extern void pmac_backlight_key(int direction);
> diff --git a/arch/powerpc/platforms/powermac/backlight.c 
> b/arch/powerpc/platforms/powermac/backlight.c
> index aeb79a8b3e109..12bc01353bd3c 100644
> --- a/arch/powerpc/platforms/powermac/backlight.c
> +++ b/arch/powerpc/platforms/powermac/backlight.c
> @@ -9,7 +9,6 @@
>*/
>   
>   #include 
> -#include 
>   #include 
>   #include 
>   #include 
> @@ -72,31 +71,6 @@ int pmac_has_backlight_type(const char *type)
>   return 0;
>   }
>   
> -int pmac_backlight_curve_lookup(struct fb_info *info, int value)
> -{
> - int level = (FB_BACKLIGHT_LEVELS - 1);
> -
> - if (info && info->bl_dev) {
> - int i, max = 0;
> -
> - /* Look for biggest value */
> - for (i = 0; i < FB_BACKLIGHT_LEVELS; i++)
> - max = max((int)info->bl_curve[i], max);
> -
> - /* Look for nearest value */
> - for (i = 0; i < FB_BACKLIGHT_LEVELS; i++) {
> - int diff = abs(info->bl_curve[i] - value);
> - if (diff < max) {
> - max = diff;
> - level = i;
> - }
> - }
> -
> - }
> -
> - return level;
> -}
> -
>   static void pmac_backlight_key_worker(struct work_struct *work)
>   {
>   if (atomic_read(_backlight_disabled))


Re: [PATCH v2 3/3] arch/powerpc: Remove from backlight code

2024-03-05 Thread Jani Nikula
On Tue, 05 Mar 2024, Thomas Zimmermann  wrote:
> Replace  with a forward declaration in  to
> resolves an unnecessary dependency. Remove pmac_backlight_curve_lookup()

*resolve

> and struct fb_info from source and header files. The function and the
> framebuffer struct is unused. No functional changes.

*are

Reviewed-by: Jani Nikula 

>
> Signed-off-by: Thomas Zimmermann 
> ---
>  arch/powerpc/include/asm/backlight.h|  5 ++--
>  arch/powerpc/platforms/powermac/backlight.c | 26 -
>  2 files changed, 2 insertions(+), 29 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/backlight.h 
> b/arch/powerpc/include/asm/backlight.h
> index 1b5eab62ed047..061a910d74929 100644
> --- a/arch/powerpc/include/asm/backlight.h
> +++ b/arch/powerpc/include/asm/backlight.h
> @@ -10,15 +10,14 @@
>  #define __ASM_POWERPC_BACKLIGHT_H
>  #ifdef __KERNEL__
>  
> -#include 
>  #include 
>  
> +struct backlight_device;
> +
>  /* For locking instructions, see the implementation file */
>  extern struct backlight_device *pmac_backlight;
>  extern struct mutex pmac_backlight_mutex;
>  
> -extern int pmac_backlight_curve_lookup(struct fb_info *info, int value);
> -
>  extern int pmac_has_backlight_type(const char *type);
>  
>  extern void pmac_backlight_key(int direction);
> diff --git a/arch/powerpc/platforms/powermac/backlight.c 
> b/arch/powerpc/platforms/powermac/backlight.c
> index aeb79a8b3e109..12bc01353bd3c 100644
> --- a/arch/powerpc/platforms/powermac/backlight.c
> +++ b/arch/powerpc/platforms/powermac/backlight.c
> @@ -9,7 +9,6 @@
>   */
>  
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -72,31 +71,6 @@ int pmac_has_backlight_type(const char *type)
>   return 0;
>  }
>  
> -int pmac_backlight_curve_lookup(struct fb_info *info, int value)
> -{
> - int level = (FB_BACKLIGHT_LEVELS - 1);
> -
> - if (info && info->bl_dev) {
> - int i, max = 0;
> -
> - /* Look for biggest value */
> - for (i = 0; i < FB_BACKLIGHT_LEVELS; i++)
> - max = max((int)info->bl_curve[i], max);
> -
> - /* Look for nearest value */
> - for (i = 0; i < FB_BACKLIGHT_LEVELS; i++) {
> - int diff = abs(info->bl_curve[i] - value);
> - if (diff < max) {
> - max = diff;
> - level = i;
> - }
> - }
> -
> - }
> -
> - return level;
> -}
> -
>  static void pmac_backlight_key_worker(struct work_struct *work)
>  {
>   if (atomic_read(_backlight_disabled))

-- 
Jani Nikula, Intel


Re: [PATCH v2 2/3] macintosh/via-pmu-backlight: Include

2024-03-05 Thread Jani Nikula
On Tue, 05 Mar 2024, Thomas Zimmermann  wrote:
> Fix builds with CONFIG_PMAC_BACKLIGHT=y. The include statement for the
> backlight header has recently been removed from . Add it to
> via-pmu-backlight.c to get the necessary symbols.
>
> Reported-by: Naresh Kamboju 
> Closes: 
> https://lore.kernel.org/dri-devel/ca+g9fysak5tbqqxfc2w4ohlga0cbthmxbeq8qayfxtu75yi...@mail.gmail.com/
> Signed-off-by: Thomas Zimmermann 
> Fixes: 11b4eedfc87d ("fbdev: Do not include  in header")
> Cc: Thomas Zimmermann 
> Cc: Jani Nikula 
> Cc: Helge Deller 
> Cc: linux-fb...@vger.kernel.org
> Cc: dri-de...@lists.freedesktop.org

Reviewed-by: Jani Nikula 

> ---
>  drivers/macintosh/via-pmu-backlight.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/macintosh/via-pmu-backlight.c 
> b/drivers/macintosh/via-pmu-backlight.c
> index c2d87e7fa85be..89450645c2305 100644
> --- a/drivers/macintosh/via-pmu-backlight.c
> +++ b/drivers/macintosh/via-pmu-backlight.c
> @@ -10,6 +10,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 

-- 
Jani Nikula, Intel


[PATCH v2 2/3] macintosh/via-pmu-backlight: Include

2024-03-05 Thread Thomas Zimmermann
Fix builds with CONFIG_PMAC_BACKLIGHT=y. The include statement for the
backlight header has recently been removed from . Add it to
via-pmu-backlight.c to get the necessary symbols.

Reported-by: Naresh Kamboju 
Closes: 
https://lore.kernel.org/dri-devel/ca+g9fysak5tbqqxfc2w4ohlga0cbthmxbeq8qayfxtu75yi...@mail.gmail.com/
Signed-off-by: Thomas Zimmermann 
Fixes: 11b4eedfc87d ("fbdev: Do not include  in header")
Cc: Thomas Zimmermann 
Cc: Jani Nikula 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-de...@lists.freedesktop.org
---
 drivers/macintosh/via-pmu-backlight.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/macintosh/via-pmu-backlight.c 
b/drivers/macintosh/via-pmu-backlight.c
index c2d87e7fa85be..89450645c2305 100644
--- a/drivers/macintosh/via-pmu-backlight.c
+++ b/drivers/macintosh/via-pmu-backlight.c
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-- 
2.44.0



[PATCH v2 3/3] arch/powerpc: Remove from backlight code

2024-03-05 Thread Thomas Zimmermann
Replace  with a forward declaration in  to
resolves an unnecessary dependency. Remove pmac_backlight_curve_lookup()
and struct fb_info from source and header files. The function and the
framebuffer struct is unused. No functional changes.

Signed-off-by: Thomas Zimmermann 
---
 arch/powerpc/include/asm/backlight.h|  5 ++--
 arch/powerpc/platforms/powermac/backlight.c | 26 -
 2 files changed, 2 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/include/asm/backlight.h 
b/arch/powerpc/include/asm/backlight.h
index 1b5eab62ed047..061a910d74929 100644
--- a/arch/powerpc/include/asm/backlight.h
+++ b/arch/powerpc/include/asm/backlight.h
@@ -10,15 +10,14 @@
 #define __ASM_POWERPC_BACKLIGHT_H
 #ifdef __KERNEL__
 
-#include 
 #include 
 
+struct backlight_device;
+
 /* For locking instructions, see the implementation file */
 extern struct backlight_device *pmac_backlight;
 extern struct mutex pmac_backlight_mutex;
 
-extern int pmac_backlight_curve_lookup(struct fb_info *info, int value);
-
 extern int pmac_has_backlight_type(const char *type);
 
 extern void pmac_backlight_key(int direction);
diff --git a/arch/powerpc/platforms/powermac/backlight.c 
b/arch/powerpc/platforms/powermac/backlight.c
index aeb79a8b3e109..12bc01353bd3c 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -9,7 +9,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -72,31 +71,6 @@ int pmac_has_backlight_type(const char *type)
return 0;
 }
 
-int pmac_backlight_curve_lookup(struct fb_info *info, int value)
-{
-   int level = (FB_BACKLIGHT_LEVELS - 1);
-
-   if (info && info->bl_dev) {
-   int i, max = 0;
-
-   /* Look for biggest value */
-   for (i = 0; i < FB_BACKLIGHT_LEVELS; i++)
-   max = max((int)info->bl_curve[i], max);
-
-   /* Look for nearest value */
-   for (i = 0; i < FB_BACKLIGHT_LEVELS; i++) {
-   int diff = abs(info->bl_curve[i] - value);
-   if (diff < max) {
-   max = diff;
-   level = i;
-   }
-   }
-
-   }
-
-   return level;
-}
-
 static void pmac_backlight_key_worker(struct work_struct *work)
 {
if (atomic_read(_backlight_disabled))
-- 
2.44.0



[PATCH v2 1/3] fbdev/chipsfb: Include

2024-03-05 Thread Thomas Zimmermann
Fix builds with CONFIG_PMAC_BACKLIGHT=y. The include statement for
the backlight header has recently been removed from .

Reported-by: Naresh Kamboju 
Closes: 
https://lore.kernel.org/dri-devel/ca+g9fysak5tbqqxfc2w4ohlga0cbthmxbeq8qayfxtu75yi...@mail.gmail.com/
Signed-off-by: Thomas Zimmermann 
Fixes: 11b4eedfc87d ("fbdev: Do not include  in header")
Reviewed-by: Jani Nikula 
Cc: Thomas Zimmermann 
Cc: Jani Nikula 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-de...@lists.freedesktop.org
---
 drivers/video/fbdev/chipsfb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c
index b80711f13df8a..b16a905588fed 100644
--- a/drivers/video/fbdev/chipsfb.c
+++ b/drivers/video/fbdev/chipsfb.c
@@ -15,6 +15,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.44.0



[PATCH v2 0/3] arch/powerpc: Resolve backlight include dependencies

2024-03-05 Thread Thomas Zimmermann
After cleaning up  in commit 11b4eedfc87d ("fbdev: Do
not include  in header"), building with
CONFIG_PMAC_BACKLIGHT=y returns errors about missing declarations.
Patches 1 and 2 resolve the errors. Patch 1 has been reviewed at [1].
Patch 3 removes another dependency between backlight and fbdev code.

Compile tested with ppc6xx_defconfig.

v2:
* via-pmu-backlight: fix build errors
* powerpc: resolve dependency between fbdev and backlight

[1] https://patchwork.freedesktop.org/series/130661/

Thomas Zimmermann (3):
  fbdev/chipsfb: Include 
  macintosh/via-pmu-backlight: Include 
  arch/powerpc: Remove  from backlight code

 arch/powerpc/include/asm/backlight.h|  5 ++--
 arch/powerpc/platforms/powermac/backlight.c | 26 -
 drivers/macintosh/via-pmu-backlight.c   |  1 +
 drivers/video/fbdev/chipsfb.c   |  1 +
 4 files changed, 4 insertions(+), 29 deletions(-)

-- 
2.44.0



Re: [PATCH] powerpc: include linux/backlight.h from asm/backlight.h

2024-03-05 Thread Jani Nikula
On Tue, 05 Mar 2024, Michael Ellerman  wrote:
> I prefer Thomas' patch, but I'm fine with either to go in via drm.

Thanks!


-- 
Jani Nikula, Intel


Re: [PATCH] powerpc: include linux/backlight.h from asm/backlight.h

2024-03-05 Thread Thomas Zimmermann

Hi

Am 05.03.24 um 01:36 schrieb Michael Ellerman:

Christophe Leroy  writes:

Le 04/03/2024 à 11:32, Thomas Zimmermann a écrit :

Hi

Am 04.03.24 um 10:55 schrieb Jani Nikula:

Removal of the backlight include from fb.h uncovered an implicit
dependency in powerpc asm/backlight.h. Add the explicit include.

Reported-by: Naresh Kamboju 
Closes:
https://lore.kernel.org/r/ca+g9fysak5tbqqxfc2w4ohlga0cbthmxbeq8qayfxtu75yi...@mail.gmail.com
Fixes: 11b4eedfc87d ("fbdev: Do not include  in
header")
Cc: Thomas Zimmermann 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Signed-off-by: Jani Nikula 

---

Not even compile tested!

That's one of the cases that's hard to catch unless you get the config
right.


---
   arch/powerpc/include/asm/backlight.h | 1 +
   1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/include/asm/backlight.h
b/arch/powerpc/include/asm/backlight.h
index 1b5eab62ed04..275d5bb9aa04 100644
--- a/arch/powerpc/include/asm/backlight.h
+++ b/arch/powerpc/include/asm/backlight.h
@@ -10,6 +10,7 @@
   #define __ASM_POWERPC_BACKLIGHT_H
   #ifdef __KERNEL__
+#include 

Thanks, but I think this should go directly into chipsfb.c. I would have
provided a patch already, if our mail server didn't have issues this
morning. Let me try again.

asm/backlight.h needs it for struct backlight_device

At least if you don't want to include linux/backlight.h in
asm/backlight.h, then you need a forward declaration of struct
backlight_device;

It's preferable for asm headers not to include linux headers (to avoid
loops), so a forward declaration would be better IMHO.


The asm header shouldn't include  either. I'll send an 
update to my patch to clean up everything.


Best regards
Thomas



cheers


--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)