Re: [PATCH v2 05/14] mm/sparc: Change pXd_huge() behavior to exclude swap entries

2024-03-18 Thread Muchun Song



> On Mar 19, 2024, at 04:03, pet...@redhat.com wrote:
> 
> From: Peter Xu 
> 
> Please refer to the previous patch on the reasoning for x86.  Now sparc is
> the only architecture that will allow swap entries to be reported as
> pXd_huge().  After this patch, all architectures should forbid swap entries
> in pXd_huge().
> 
> Cc: David S. Miller 
> Cc: Andreas Larsson 
> Cc: sparcli...@vger.kernel.org
> Signed-off-by: Peter Xu 
> ---
> arch/sparc/mm/hugetlbpage.c | 6 ++
> 1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
> index b432500c13a5..d31c2cec35c9 100644
> --- a/arch/sparc/mm/hugetlbpage.c
> +++ b/arch/sparc/mm/hugetlbpage.c
> @@ -409,14 +409,12 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, 
> unsigned long addr,
> 
> int pmd_huge(pmd_t pmd)
> {
> - return !pmd_none(pmd) &&
> - (pmd_val(pmd) & (_PAGE_VALID|_PAGE_PMD_HUGE)) != _PAGE_VALID;
> + return pmd_leaf(pmd);;

There is a redundant semicolon in the end.

Thanks.

> }
> 
> int pud_huge(pud_t pud)
> {
> - return !pud_none(pud) &&
> - (pud_val(pud) & (_PAGE_VALID|_PAGE_PUD_HUGE)) != _PAGE_VALID;
> + return pud_leaf(pud);
> }
> 
> static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd,
> -- 
> 2.44.0
> 



Re: [PATCH v14 00/16] Add audio support in v4l2 framework

2024-03-18 Thread Shengjiu Wang
On Tue, Mar 19, 2024 at 10:24 AM Shengjiu Wang  wrote:
>
> On Mon, Mar 18, 2024 at 11:56 PM Hans Verkuil  wrote:
> >
> > Hi Shengjiu,
> >
> > I was about to prepare a pull request for this when I realized that
> > entries for the new drivers need to be added to the MAINTAINERS file.
> >
> > Can you post patches 'v14 17/16' and 'v14/18/16' adding entries for each
> > new driver?
>
> Ok,  How about the change below?
>
> VIRTUAL MEM2MEM DRIVER FOR AUDIO
> M:  Hans Verkuil 
> M:  Shengjiu Wang 
> L:  linux-me...@vger.kernel.org
> S:  Maintained
> W:  https://linuxtv.org
> T:  git git://linuxtv.org/media_tree.git
> F:  drivers/media/test-drivers/vim2m-audio.c
>
> NXP ASRC V4L2 MEM2MEM DRIVERS
> M:  Shengjiu Wang 
> L:  linux-me...@vger.kernel.org
> S:  Maintained
> W:  https://linuxtv.org
> T:  git git://linuxtv.org/media_tree.git
> F:  drivers/media/platform/nxp/imx-asrc.c
>

BTW, should I merge this change to PATCH 15/16  and PATCH 16/16?
That I will resend the whole patch series.  Seems this is a better way.

Best regrads
Shengjiu Wang

> best regards
> wang shengjiu
>
> >
> > Thank you,
> >
> > Hans
> >
> > On 11/03/2024 10:53 am, Shengjiu Wang wrote:
> > > Audio signal processing also has the requirement for memory to
> > > memory similar as Video.
> > >
> > > This asrc memory to memory (memory ->asrc->memory) case is a non
> > > real time use case.
> > >
> > > User fills the input buffer to the asrc module, after conversion, then 
> > > asrc
> > > sends back the output buffer to user. So it is not a traditional ALSA 
> > > playback
> > > and capture case.
> > >
> > > It is a specific use case,  there is no reference in current kernel.
> > > v4l2 memory to memory is the closed implementation,  v4l2 current
> > > support video, image, radio, tuner, touch devices, so it is not
> > > complicated to add support for this specific audio case.
> > >
> > > Because we had implemented the "memory -> asrc ->i2s device-> codec"
> > > use case in ALSA.  Now the "memory->asrc->memory" needs
> > > to reuse the code in asrc driver, so the first 3 patches is for refining
> > > the code to make it can be shared by the "memory->asrc->memory"
> > > driver.
> > >
> > > The main change is in the v4l2 side, A /dev/vl4-audioX will be created,
> > > user applications only use the ioctl of v4l2 framework.
> > >
> > > Other change is to add memory to memory support for two kinds of i.MX ASRC
> > > module.
> > >
> > > changes in v14:
> > > - document the reservation of 'AUXX' fourcc format.
> > > - add v4l2_audfmt_to_fourcc() definition.
> > >
> > > changes in v13
> > > - change 'pixelformat' to 'audioformat' in dev-audio-mem2mem.rst
> > > - add more description for clock drift in ext-ctrls-audio-m2m.rst
> > > - Add "media: v4l2-ctrls: add support for fraction_bits" from Hans
> > >   to avoid build issue for kernel test robot
> > >
> > > changes in v12
> > > - minor changes according to comments
> > > - drop min_buffers_needed = 1 and V4L2_CTRL_FLAG_UPDATE flag
> > > - drop bus_info
> > >
> > > changes in v11
> > > - add add-fixed-point-test-controls in vivid.
> > > - add v4l2_ctrl_fp_compose() helper function for min and max
> > >
> > > changes in v10
> > > - remove FIXED_POINT type
> > > - change code base on media: v4l2-ctrls: add support for fraction_bits
> > > - fix issue reported by kernel test robot
> > > - remove module_alias
> > >
> > > changes in v9:
> > > - add MEDIA_ENT_F_PROC_AUDIO_RESAMPLER.
> > > - add MEDIA_INTF_T_V4L_AUDIO
> > > - add media controller support
> > > - refine the vim2m-audio to support 8k<->16k conversion.
> > >
> > > changes in v8:
> > > - refine V4L2_CAP_AUDIO_M2M to be 0x0008
> > > - update doc for FIXED_POINT
> > > - address comments for imx-asrc
> > >
> > > changes in v7:
> > > - add acked-by from Mark
> > > - separate commit for fixed point, m2m audio class, audio rate controls
> > > - use INTEGER_MENU for rate,  FIXED_POINT for rate offset
> > > - remove used fmts
> > > - address other comments for Hans
> > >
> > > changes in v6:
> > > - use m2m_prepare/m2m_unprepare/m2m_start/m2m_stop to replace
> > >   m2m_start_part_one/m2m_stop_part_one, 
> > > m2m_start_part_two/m2m_stop_part_two.
> > > - change V4L2_CTRL_TYPE_ASRC_RATE to V4L2_CTRL_TYPE_FIXED_POINT
> > > - fix warning by kernel test rebot
> > > - remove some unused format V4L2_AUDIO_FMT_XX
> > > - Get SNDRV_PCM_FORMAT from V4L2_AUDIO_FMT in driver.
> > > - rename audm2m to viaudm2m.
> > >
> > > changes in v5:
> > > - remove V4L2_AUDIO_FMT_LPCM
> > > - define audio pixel format like V4L2_AUDIO_FMT_S8...
> > > - remove rate and format in struct v4l2_audio_format.
> > > - Add V4L2_CID_ASRC_SOURCE_RATE and V4L2_CID_ASRC_DEST_RATE controls
> > > - updata document accordingly.
> > >
> > > changes in v4:
> > > - update document style
> > > - separate V4L2_AUDIO_FMT_LPCM and V4L2_CAP_AUDIO_M2M in separate commit
> > >
> > > changes in v3:
> > > - Modify documents for adding audio m2m 

Re: [PATCH v14 00/16] Add audio support in v4l2 framework

2024-03-18 Thread Shengjiu Wang
On Mon, Mar 18, 2024 at 11:56 PM Hans Verkuil  wrote:
>
> Hi Shengjiu,
>
> I was about to prepare a pull request for this when I realized that
> entries for the new drivers need to be added to the MAINTAINERS file.
>
> Can you post patches 'v14 17/16' and 'v14/18/16' adding entries for each
> new driver?

Ok,  How about the change below?

VIRTUAL MEM2MEM DRIVER FOR AUDIO
M:  Hans Verkuil 
M:  Shengjiu Wang 
L:  linux-me...@vger.kernel.org
S:  Maintained
W:  https://linuxtv.org
T:  git git://linuxtv.org/media_tree.git
F:  drivers/media/test-drivers/vim2m-audio.c

NXP ASRC V4L2 MEM2MEM DRIVERS
M:  Shengjiu Wang 
L:  linux-me...@vger.kernel.org
S:  Maintained
W:  https://linuxtv.org
T:  git git://linuxtv.org/media_tree.git
F:  drivers/media/platform/nxp/imx-asrc.c

best regards
wang shengjiu

>
> Thank you,
>
> Hans
>
> On 11/03/2024 10:53 am, Shengjiu Wang wrote:
> > Audio signal processing also has the requirement for memory to
> > memory similar as Video.
> >
> > This asrc memory to memory (memory ->asrc->memory) case is a non
> > real time use case.
> >
> > User fills the input buffer to the asrc module, after conversion, then asrc
> > sends back the output buffer to user. So it is not a traditional ALSA 
> > playback
> > and capture case.
> >
> > It is a specific use case,  there is no reference in current kernel.
> > v4l2 memory to memory is the closed implementation,  v4l2 current
> > support video, image, radio, tuner, touch devices, so it is not
> > complicated to add support for this specific audio case.
> >
> > Because we had implemented the "memory -> asrc ->i2s device-> codec"
> > use case in ALSA.  Now the "memory->asrc->memory" needs
> > to reuse the code in asrc driver, so the first 3 patches is for refining
> > the code to make it can be shared by the "memory->asrc->memory"
> > driver.
> >
> > The main change is in the v4l2 side, A /dev/vl4-audioX will be created,
> > user applications only use the ioctl of v4l2 framework.
> >
> > Other change is to add memory to memory support for two kinds of i.MX ASRC
> > module.
> >
> > changes in v14:
> > - document the reservation of 'AUXX' fourcc format.
> > - add v4l2_audfmt_to_fourcc() definition.
> >
> > changes in v13
> > - change 'pixelformat' to 'audioformat' in dev-audio-mem2mem.rst
> > - add more description for clock drift in ext-ctrls-audio-m2m.rst
> > - Add "media: v4l2-ctrls: add support for fraction_bits" from Hans
> >   to avoid build issue for kernel test robot
> >
> > changes in v12
> > - minor changes according to comments
> > - drop min_buffers_needed = 1 and V4L2_CTRL_FLAG_UPDATE flag
> > - drop bus_info
> >
> > changes in v11
> > - add add-fixed-point-test-controls in vivid.
> > - add v4l2_ctrl_fp_compose() helper function for min and max
> >
> > changes in v10
> > - remove FIXED_POINT type
> > - change code base on media: v4l2-ctrls: add support for fraction_bits
> > - fix issue reported by kernel test robot
> > - remove module_alias
> >
> > changes in v9:
> > - add MEDIA_ENT_F_PROC_AUDIO_RESAMPLER.
> > - add MEDIA_INTF_T_V4L_AUDIO
> > - add media controller support
> > - refine the vim2m-audio to support 8k<->16k conversion.
> >
> > changes in v8:
> > - refine V4L2_CAP_AUDIO_M2M to be 0x0008
> > - update doc for FIXED_POINT
> > - address comments for imx-asrc
> >
> > changes in v7:
> > - add acked-by from Mark
> > - separate commit for fixed point, m2m audio class, audio rate controls
> > - use INTEGER_MENU for rate,  FIXED_POINT for rate offset
> > - remove used fmts
> > - address other comments for Hans
> >
> > changes in v6:
> > - use m2m_prepare/m2m_unprepare/m2m_start/m2m_stop to replace
> >   m2m_start_part_one/m2m_stop_part_one, 
> > m2m_start_part_two/m2m_stop_part_two.
> > - change V4L2_CTRL_TYPE_ASRC_RATE to V4L2_CTRL_TYPE_FIXED_POINT
> > - fix warning by kernel test rebot
> > - remove some unused format V4L2_AUDIO_FMT_XX
> > - Get SNDRV_PCM_FORMAT from V4L2_AUDIO_FMT in driver.
> > - rename audm2m to viaudm2m.
> >
> > changes in v5:
> > - remove V4L2_AUDIO_FMT_LPCM
> > - define audio pixel format like V4L2_AUDIO_FMT_S8...
> > - remove rate and format in struct v4l2_audio_format.
> > - Add V4L2_CID_ASRC_SOURCE_RATE and V4L2_CID_ASRC_DEST_RATE controls
> > - updata document accordingly.
> >
> > changes in v4:
> > - update document style
> > - separate V4L2_AUDIO_FMT_LPCM and V4L2_CAP_AUDIO_M2M in separate commit
> >
> > changes in v3:
> > - Modify documents for adding audio m2m support
> > - Add audio virtual m2m driver
> > - Defined V4L2_AUDIO_FMT_LPCM format type for audio.
> > - Defined V4L2_CAP_AUDIO_M2M capability type for audio m2m case.
> > - with modification in v4l-utils, pass v4l2-compliance test.
> >
> > changes in v2:
> > - decouple the implementation in v4l2 and ALSA
> > - implement the memory to memory driver as a platfrom driver
> >   and move it to driver/media
> > - move fsl_asrc_common.h to include/sound folder
> >
> > Hans Verkuil (1):
> > 

[PATCH v2 1/1] ASoC: fsl: imx-es8328: Switch to using gpiod API

2024-03-18 Thread Andy Shevchenko
This updates the driver to gpiod API, and removes yet another use of
of_get_named_gpio().

Signed-off-by: Andy Shevchenko 
---
v2: fixed compilation error
 sound/soc/fsl/imx-es8328.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c
index 6f0d031c1d5f..d67b8a149bff 100644
--- a/sound/soc/fsl/imx-es8328.c
+++ b/sound/soc/fsl/imx-es8328.c
@@ -3,7 +3,7 @@
 // Copyright 2012 Freescale Semiconductor, Inc.
 // Copyright 2012 Linaro Ltd.
 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -23,7 +23,7 @@ struct imx_es8328_data {
struct snd_soc_card card;
char codec_dai_name[DAI_NAME_SIZE];
char platform_name[DAI_NAME_SIZE];
-   int jack_gpio;
+   struct gpio_desc *jack_gpiod;
 };
 
 static struct snd_soc_jack_gpio headset_jack_gpios[] = {
@@ -54,8 +54,8 @@ static int imx_es8328_dai_init(struct snd_soc_pcm_runtime 
*rtd)
struct imx_es8328_data, card);
int ret = 0;
 
-   /* Headphone jack detection */
-   if (gpio_is_valid(data->jack_gpio)) {
+   if (data->jack_gpiod) {
+   /* Headphone jack detection */
ret = snd_soc_card_jack_new_pins(rtd->card, "Headphone",
 SND_JACK_HEADSET | 
SND_JACK_BTN_0,
 _jack,
@@ -64,7 +64,7 @@ static int imx_es8328_dai_init(struct snd_soc_pcm_runtime 
*rtd)
if (ret)
return ret;
 
-   headset_jack_gpios[0].gpio = data->jack_gpio;
+   headset_jack_gpios[0].desc = data->jack_gpiod;
ret = snd_soc_jack_add_gpios(_jack,
 ARRAY_SIZE(headset_jack_gpios),
 headset_jack_gpios);
@@ -174,7 +174,11 @@ static int imx_es8328_probe(struct platform_device *pdev)
 
data->dev = dev;
 
-   data->jack_gpio = of_get_named_gpio(pdev->dev.of_node, "jack-gpio", 0);
+   data->jack_gpiod = devm_gpiod_get_optional(dev, "jack", GPIOD_IN);
+   if (IS_ERR(data->jack_gpiod)) {
+   ret = PTR_ERR(data->jack_gpiod);
+   goto put_device;
+   }
 
/*
 * CPU == Platform
-- 
2.43.0.rc1.1.gbec44491f096



[PATCH v2 14/14] mm: Document pXd_leaf() API

2024-03-18 Thread peterx
From: Peter Xu 

There's one small section already, but since we're going to remove
pXd_huge(), that comment may start to obsolete.

Rewrite that section with more information, hopefully with that the API is
crystal clear on what it implies.

Reviewed-by: Jason Gunthorpe 
Signed-off-by: Peter Xu 
---
 include/linux/pgtable.h | 24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 85fc7554cd52..6b0d222a7fad 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -1770,11 +1770,25 @@ typedef unsigned int pgtbl_mod_mask;
 #endif
 
 /*
- * p?d_leaf() - true if this entry is a final mapping to a physical address.
- * This differs from p?d_huge() by the fact that they are always available (if
- * the architecture supports large pages at the appropriate level) even
- * if CONFIG_HUGETLB_PAGE is not defined.
- * Only meaningful when called on a valid entry.
+ * pXd_leaf() is the API to check whether a pgtable entry is a huge page
+ * mapping.  It should work globally across all archs, without any
+ * dependency on CONFIG_* options.  For architectures that do not support
+ * huge mappings on specific levels, below fallbacks will be used.
+ *
+ * A leaf pgtable entry should always imply the following:
+ *
+ * - It is a "present" entry.  IOW, before using this API, please check it
+ *   with pXd_present() first. NOTE: it may not always mean the "present
+ *   bit" is set.  For example, PROT_NONE entries are always "present".
+ *
+ * - It should _never_ be a swap entry of any type.  Above "present" check
+ *   should have guarded this, but let's be crystal clear on this.
+ *
+ * - It should contain a huge PFN, which points to a huge page larger than
+ *   PAGE_SIZE of the platform.  The PFN format isn't important here.
+ *
+ * - It should cover all kinds of huge mappings (e.g., pXd_trans_huge(),
+ *   pXd_devmap(), or hugetlb mappings).
  */
 #ifndef pgd_leaf
 #define pgd_leaf(x)false
-- 
2.44.0



[PATCH v2 13/14] mm/arm: Remove pmd_thp_or_huge()

2024-03-18 Thread peterx
From: Peter Xu 

ARM/ARM64 used to define pmd_thp_or_huge().  Now this macro is completely
redundant.  Remove it and use pmd_leaf().

Cc: Mark Salter 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Russell King 
Cc: Shawn Guo 
Cc: Krzysztof Kozlowski 
Cc: Bjorn Andersson 
Cc: Arnd Bergmann 
Cc: Konrad Dybcio 
Cc: Fabio Estevam 
Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Peter Xu 
---
 arch/arm/include/asm/pgtable-2level.h | 1 -
 arch/arm/include/asm/pgtable-3level.h | 1 -
 arch/arm/lib/uaccess_with_memcpy.c| 4 ++--
 arch/arm64/include/asm/pgtable.h  | 2 --
 4 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/pgtable-2level.h 
b/arch/arm/include/asm/pgtable-2level.h
index 4245c2e74720..6b5392e20f41 100644
--- a/arch/arm/include/asm/pgtable-2level.h
+++ b/arch/arm/include/asm/pgtable-2level.h
@@ -241,7 +241,6 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long 
addr)
  * define empty stubs for use by pin_page_for_write.
  */
 #define pmd_hugewillfault(pmd) (0)
-#define pmd_thp_or_huge(pmd)   (0)
 
 #endif /* __ASSEMBLY__ */
 
diff --git a/arch/arm/include/asm/pgtable-3level.h 
b/arch/arm/include/asm/pgtable-3level.h
index 9e3c44f0aea2..fa5939eb9864 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -190,7 +190,6 @@ static inline pte_t pte_mkspecial(pte_t pte)
 #define pmd_dirty(pmd) (pmd_isset((pmd), L_PMD_SECT_DIRTY))
 
 #define pmd_hugewillfault(pmd) (!pmd_young(pmd) || !pmd_write(pmd))
-#define pmd_thp_or_huge(pmd)   (pmd_leaf(pmd) || pmd_trans_huge(pmd))
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 #define pmd_trans_huge(pmd)(pmd_val(pmd) && !pmd_table(pmd))
diff --git a/arch/arm/lib/uaccess_with_memcpy.c 
b/arch/arm/lib/uaccess_with_memcpy.c
index 2f6163f05e93..c0ac7796d775 100644
--- a/arch/arm/lib/uaccess_with_memcpy.c
+++ b/arch/arm/lib/uaccess_with_memcpy.c
@@ -56,10 +56,10 @@ pin_page_for_write(const void __user *_addr, pte_t **ptep, 
spinlock_t **ptlp)
 * to see that it's still huge and whether or not we will
 * need to fault on write.
 */
-   if (unlikely(pmd_thp_or_huge(*pmd))) {
+   if (unlikely(pmd_leaf(*pmd))) {
ptl = >mm->page_table_lock;
spin_lock(ptl);
-   if (unlikely(!pmd_thp_or_huge(*pmd)
+   if (unlikely(!pmd_leaf(*pmd)
|| pmd_hugewillfault(*pmd))) {
spin_unlock(ptl);
return 0;
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index c4efa47fed5f..a580068a6564 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -512,8 +512,6 @@ static inline pmd_t pmd_mkinvalid(pmd_t pmd)
return pmd;
 }
 
-#define pmd_thp_or_huge(pmd)   (pmd_leaf(pmd) || pmd_trans_huge(pmd))
-
 #define pmd_write(pmd) pte_write(pmd_pte(pmd))
 
 #define pmd_mkhuge(pmd)(__pmd(pmd_val(pmd) & ~PMD_TABLE_BIT))
-- 
2.44.0



[PATCH v2 12/14] mm/treewide: Remove pXd_huge()

2024-03-18 Thread peterx
From: Peter Xu 

This API is not used anymore, drop it for the whole tree.

Signed-off-by: Peter Xu 
---
 arch/arm/mm/Makefile  |  1 -
 arch/arm/mm/hugetlbpage.c | 29 ---
 arch/arm64/mm/hugetlbpage.c   | 10 ---
 arch/loongarch/mm/hugetlbpage.c   | 10 ---
 arch/mips/include/asm/pgtable-32.h|  2 +-
 arch/mips/include/asm/pgtable-64.h|  2 +-
 arch/mips/mm/hugetlbpage.c| 10 ---
 arch/parisc/mm/hugetlbpage.c  | 11 ---
 .../include/asm/book3s/64/pgtable-4k.h| 10 ---
 .../include/asm/book3s/64/pgtable-64k.h   | 25 
 arch/powerpc/include/asm/nohash/pgtable.h | 10 ---
 arch/riscv/mm/hugetlbpage.c   | 10 ---
 arch/s390/mm/hugetlbpage.c| 10 ---
 arch/sh/mm/hugetlbpage.c  | 10 ---
 arch/sparc/mm/hugetlbpage.c   | 10 ---
 arch/x86/mm/hugetlbpage.c | 16 --
 include/linux/hugetlb.h   | 24 ---
 17 files changed, 2 insertions(+), 198 deletions(-)
 delete mode 100644 arch/arm/mm/hugetlbpage.c

diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
index 71b858c9b10c..1779e12db085 100644
--- a/arch/arm/mm/Makefile
+++ b/arch/arm/mm/Makefile
@@ -21,7 +21,6 @@ KASAN_SANITIZE_physaddr.o := n
 obj-$(CONFIG_DEBUG_VIRTUAL)+= physaddr.o
 
 obj-$(CONFIG_ALIGNMENT_TRAP)   += alignment.o
-obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
 obj-$(CONFIG_ARM_PV_FIXUP) += pv-fixup-asm.o
 
 obj-$(CONFIG_CPU_ABRT_NOMMU)   += abort-nommu.o
diff --git a/arch/arm/mm/hugetlbpage.c b/arch/arm/mm/hugetlbpage.c
deleted file mode 100644
index c2fa643f6bb5..
--- a/arch/arm/mm/hugetlbpage.c
+++ /dev/null
@@ -1,29 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * arch/arm/mm/hugetlbpage.c
- *
- * Copyright (C) 2012 ARM Ltd.
- *
- * Based on arch/x86/include/asm/hugetlb.h and Bill Carson's patches
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-int pud_huge(pud_t pud)
-{
-   return 0;
-}
-
-int pmd_huge(pmd_t pmd)
-{
-   return pmd_leaf(pmd);
-}
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index f494fc31201f..ca58210d6c07 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -79,16 +79,6 @@ bool arch_hugetlb_migration_supported(struct hstate *h)
 }
 #endif
 
-int pmd_huge(pmd_t pmd)
-{
-   return pmd_leaf(pmd);
-}
-
-int pud_huge(pud_t pud)
-{
-   return pud_leaf(pud);
-}
-
 static int find_num_contig(struct mm_struct *mm, unsigned long addr,
   pte_t *ptep, size_t *pgsize)
 {
diff --git a/arch/loongarch/mm/hugetlbpage.c b/arch/loongarch/mm/hugetlbpage.c
index a4e78e74aa21..1c56cb59 100644
--- a/arch/loongarch/mm/hugetlbpage.c
+++ b/arch/loongarch/mm/hugetlbpage.c
@@ -50,16 +50,6 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long 
addr,
return (pte_t *) pmd;
 }
 
-int pmd_huge(pmd_t pmd)
-{
-   return (pmd_val(pmd) & _PAGE_HUGE) != 0;
-}
-
-int pud_huge(pud_t pud)
-{
-   return (pud_val(pud) & _PAGE_HUGE) != 0;
-}
-
 uint64_t pmd_to_entrylo(unsigned long pmd_val)
 {
uint64_t val;
diff --git a/arch/mips/include/asm/pgtable-32.h 
b/arch/mips/include/asm/pgtable-32.h
index 0e196650f4f4..92b7591aac2a 100644
--- a/arch/mips/include/asm/pgtable-32.h
+++ b/arch/mips/include/asm/pgtable-32.h
@@ -129,7 +129,7 @@ static inline int pmd_none(pmd_t pmd)
 static inline int pmd_bad(pmd_t pmd)
 {
 #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
-   /* pmd_huge(pmd) but inline */
+   /* pmd_leaf(pmd) but inline */
if (unlikely(pmd_val(pmd) & _PAGE_HUGE))
return 0;
 #endif
diff --git a/arch/mips/include/asm/pgtable-64.h 
b/arch/mips/include/asm/pgtable-64.h
index 20ca48c1b606..7c28510b3768 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -245,7 +245,7 @@ static inline int pmd_none(pmd_t pmd)
 static inline int pmd_bad(pmd_t pmd)
 {
 #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
-   /* pmd_huge(pmd) but inline */
+   /* pmd_leaf(pmd) but inline */
if (unlikely(pmd_val(pmd) & _PAGE_HUGE))
return 0;
 #endif
diff --git a/arch/mips/mm/hugetlbpage.c b/arch/mips/mm/hugetlbpage.c
index 7eaff5b07873..0b9e1b59 100644
--- a/arch/mips/mm/hugetlbpage.c
+++ b/arch/mips/mm/hugetlbpage.c
@@ -57,13 +57,3 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long 
addr,
}
return (pte_t *) pmd;
 }
-
-int pmd_huge(pmd_t pmd)
-{
-   return (pmd_val(pmd) & _PAGE_HUGE) != 0;
-}
-
-int pud_huge(pud_t pud)
-{
-   return (pud_val(pud) & _PAGE_HUGE) != 0;
-}
diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c
index a9f7e21f6656..0356199bd9e7 100644
--- a/arch/parisc/mm/hugetlbpage.c
+++ 

[PATCH v2 11/14] mm/treewide: Replace pXd_huge() with pXd_leaf()

2024-03-18 Thread peterx
From: Peter Xu 

Now after we're sure all pXd_huge() definitions are the same as pXd_leaf(),
reuse it.  Luckily, pXd_huge() isn't widely used.

Signed-off-by: Peter Xu 
---
 arch/arm/include/asm/pgtable-3level.h | 2 +-
 arch/arm64/include/asm/pgtable.h  | 2 +-
 arch/arm64/mm/hugetlbpage.c   | 4 ++--
 arch/loongarch/mm/hugetlbpage.c   | 2 +-
 arch/mips/mm/tlb-r4k.c| 2 +-
 arch/powerpc/mm/pgtable_64.c  | 6 +++---
 arch/x86/mm/pgtable.c | 4 ++--
 mm/gup.c  | 4 ++--
 mm/hmm.c  | 2 +-
 mm/memory.c   | 2 +-
 10 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/arm/include/asm/pgtable-3level.h 
b/arch/arm/include/asm/pgtable-3level.h
index e7aecbef75c9..9e3c44f0aea2 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -190,7 +190,7 @@ static inline pte_t pte_mkspecial(pte_t pte)
 #define pmd_dirty(pmd) (pmd_isset((pmd), L_PMD_SECT_DIRTY))
 
 #define pmd_hugewillfault(pmd) (!pmd_young(pmd) || !pmd_write(pmd))
-#define pmd_thp_or_huge(pmd)   (pmd_huge(pmd) || pmd_trans_huge(pmd))
+#define pmd_thp_or_huge(pmd)   (pmd_leaf(pmd) || pmd_trans_huge(pmd))
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 #define pmd_trans_huge(pmd)(pmd_val(pmd) && !pmd_table(pmd))
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 14d24c357c7a..c4efa47fed5f 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -512,7 +512,7 @@ static inline pmd_t pmd_mkinvalid(pmd_t pmd)
return pmd;
 }
 
-#define pmd_thp_or_huge(pmd)   (pmd_huge(pmd) || pmd_trans_huge(pmd))
+#define pmd_thp_or_huge(pmd)   (pmd_leaf(pmd) || pmd_trans_huge(pmd))
 
 #define pmd_write(pmd) pte_write(pmd_pte(pmd))
 
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 1234bbaef5bf..f494fc31201f 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -321,7 +321,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
if (sz != PUD_SIZE && pud_none(pud))
return NULL;
/* hugepage or swap? */
-   if (pud_huge(pud) || !pud_present(pud))
+   if (pud_leaf(pud) || !pud_present(pud))
return (pte_t *)pudp;
/* table; check the next level */
 
@@ -333,7 +333,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
if (!(sz == PMD_SIZE || sz == CONT_PMD_SIZE) &&
pmd_none(pmd))
return NULL;
-   if (pmd_huge(pmd) || !pmd_present(pmd))
+   if (pmd_leaf(pmd) || !pmd_present(pmd))
return (pte_t *)pmdp;
 
if (sz == CONT_PTE_SIZE)
diff --git a/arch/loongarch/mm/hugetlbpage.c b/arch/loongarch/mm/hugetlbpage.c
index 1e76fcb83093..a4e78e74aa21 100644
--- a/arch/loongarch/mm/hugetlbpage.c
+++ b/arch/loongarch/mm/hugetlbpage.c
@@ -64,7 +64,7 @@ uint64_t pmd_to_entrylo(unsigned long pmd_val)
 {
uint64_t val;
/* PMD as PTE. Must be huge page */
-   if (!pmd_huge(__pmd(pmd_val)))
+   if (!pmd_leaf(__pmd(pmd_val)))
panic("%s", __func__);
 
val = pmd_val ^ _PAGE_HUGE;
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index 4106084e57d7..76f3b9c0a9f0 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -326,7 +326,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned 
long address, pte_t pte)
idx = read_c0_index();
 #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
/* this could be a huge page  */
-   if (pmd_huge(*pmdp)) {
+   if (pmd_leaf(*pmdp)) {
unsigned long lo;
write_c0_pagemask(PM_HUGE_MASK);
ptep = (pte_t *)pmdp;
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index 9b99113cb51a..6621cfc3baf8 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -102,7 +102,7 @@ struct page *p4d_page(p4d_t p4d)
 {
if (p4d_leaf(p4d)) {
if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP))
-   VM_WARN_ON(!p4d_huge(p4d));
+   VM_WARN_ON(!p4d_leaf(p4d));
return pte_page(p4d_pte(p4d));
}
return virt_to_page(p4d_pgtable(p4d));
@@ -113,7 +113,7 @@ struct page *pud_page(pud_t pud)
 {
if (pud_leaf(pud)) {
if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP))
-   VM_WARN_ON(!pud_huge(pud));
+   VM_WARN_ON(!pud_leaf(pud));
return pte_page(pud_pte(pud));
}
return virt_to_page(pud_pgtable(pud));
@@ -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_leaf(pmd) || pmd_huge(pmd)));
+   VM_WARN_ON(!pmd_leaf(pmd));
return 

[PATCH v2 08/14] mm/arm64: Merge pXd_huge() and pXd_leaf() definitions

2024-03-18 Thread peterx
From: Peter Xu 

Unlike most archs, aarch64 defines pXd_huge() and pXd_leaf() slightly
differently.  Redefine the pXd_huge() with pXd_leaf().

There used to be two traps for old aarch64 definitions over these APIs that
I found when reading the code around, they're:

 (1) 4797ec2dc83a ("arm64: fix pud_huge() for 2-level pagetables")
 (2) 23bc8f69f0ec ("arm64: mm: fix p?d_leaf()")

Define pXd_huge() with the current pXd_leaf() will make sure (2) isn't a
problem (on PROT_NONE checks). To make sure it also works for (1), we move
over the __PAGETABLE_PMD_FOLDED check to pud_leaf(), allowing it to
constantly returning "false" for 2-level pgtables, which looks even safer
to cover both now.

Cc: Muchun Song 
Cc: Mark Salter 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Peter Xu 
---
 arch/arm64/include/asm/pgtable.h | 4 
 arch/arm64/mm/hugetlbpage.c  | 8 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 401087e8a43d..14d24c357c7a 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -704,7 +704,11 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
 #define pud_none(pud)  (!pud_val(pud))
 #define pud_bad(pud)   (!pud_table(pud))
 #define pud_present(pud)   pte_present(pud_pte(pud))
+#ifndef __PAGETABLE_PMD_FOLDED
 #define pud_leaf(pud)  (pud_present(pud) && !pud_table(pud))
+#else
+#define pud_leaf(pud)  false
+#endif
 #define pud_valid(pud) pte_valid(pud_pte(pud))
 #define pud_user(pud)  pte_user(pud_pte(pud))
 #define pud_user_exec(pud) pte_user_exec(pud_pte(pud))
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 0f0e10bb0a95..1234bbaef5bf 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -81,16 +81,12 @@ bool arch_hugetlb_migration_supported(struct hstate *h)
 
 int pmd_huge(pmd_t pmd)
 {
-   return pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT);
+   return pmd_leaf(pmd);
 }
 
 int pud_huge(pud_t pud)
 {
-#ifndef __PAGETABLE_PMD_FOLDED
-   return pud_val(pud) && !(pud_val(pud) & PUD_TABLE_BIT);
-#else
-   return 0;
-#endif
+   return pud_leaf(pud);
 }
 
 static int find_num_contig(struct mm_struct *mm, unsigned long addr,
-- 
2.44.0



[PATCH v2 10/14] mm/gup: Merge pXd huge mapping checks

2024-03-18 Thread peterx
From: Peter Xu 

Huge mapping checks in GUP are slightly redundant and can be simplified.

pXd_huge() now is the same as pXd_leaf().  pmd_trans_huge() and
pXd_devmap() should both imply pXd_leaf(). Time to merge them into one.

Reviewed-by: Jason Gunthorpe 
Signed-off-by: Peter Xu 
---
 mm/gup.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 802987281b2f..e2415e9789bc 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -3005,8 +3005,7 @@ static int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned 
long addr, unsigned lo
if (!pmd_present(pmd))
return 0;
 
-   if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) ||
-pmd_devmap(pmd))) {
+   if (unlikely(pmd_leaf(pmd))) {
/* See gup_pte_range() */
if (pmd_protnone(pmd))
return 0;
@@ -3043,7 +3042,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned 
long addr, unsigned lo
next = pud_addr_end(addr, end);
if (unlikely(!pud_present(pud)))
return 0;
-   if (unlikely(pud_huge(pud) || pud_devmap(pud))) {
+   if (unlikely(pud_leaf(pud))) {
if (!gup_huge_pud(pud, pudp, addr, next, flags,
  pages, nr))
return 0;
@@ -3096,7 +3095,7 @@ static void gup_pgd_range(unsigned long addr, unsigned 
long end,
next = pgd_addr_end(addr, end);
if (pgd_none(pgd))
return;
-   if (unlikely(pgd_huge(pgd))) {
+   if (unlikely(pgd_leaf(pgd))) {
if (!gup_huge_pgd(pgd, pgdp, addr, next, flags,
  pages, nr))
return;
-- 
2.44.0



[PATCH v2 09/14] mm/powerpc: Redefine pXd_huge() with pXd_leaf()

2024-03-18 Thread peterx
From: Peter Xu 

PowerPC book3s 4K mostly has the same definition on both, except pXd_huge()
constantly returns 0 for hash MMUs.  As Michael Ellerman pointed out [1],
it is safe to check _PAGE_PTE on hash MMUs, as the bit will never be set so
it will keep returning false.

As a reference, __p[mu]d_mkhuge() will trigger a BUG_ON trying to create
such huge mappings for 4K hash MMUs.  Meanwhile, the major powerpc hugetlb
pgtable walker __find_linux_pte() already used pXd_leaf() to check leaf
hugetlb mappings.

The goal should be that we will have one API pXd_leaf() to detect all kinds
of huge mappings (hugepd is still special in this case, though).  AFAICT we
need to use the pXd_leaf() impl (rather than pXd_huge()'s) to make sure
ie. THPs on hash MMU will also return true.

This helps to simplify a follow up patch to drop pXd_huge() treewide.

NOTE: *_leaf() definition need to be moved before the inclusion of
asm/book3s/64/pgtable-4k.h, which defines pXd_huge() with it.

[1] https://lore.kernel.org/r/87v85zo6w7.fsf@mail.lhotse

Cc: Michael Ellerman 
Cc: Nicholas Piggin 
Cc: Christophe Leroy 
Cc: "Aneesh Kumar K.V" 
Cc: "Naveen N. Rao" 
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Peter Xu 
---
 .../include/asm/book3s/64/pgtable-4k.h| 14 ++
 arch/powerpc/include/asm/book3s/64/pgtable.h  | 27 +--
 2 files changed, 14 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h 
b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
index 48f21820afe2..92545981bb49 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
@@ -8,22 +8,12 @@
 #ifdef CONFIG_HUGETLB_PAGE
 static inline int pmd_huge(pmd_t pmd)
 {
-   /*
-* leaf pte for huge page
-*/
-   if (radix_enabled())
-   return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
-   return 0;
+   return pmd_leaf(pmd);
 }
 
 static inline int pud_huge(pud_t pud)
 {
-   /*
-* leaf pte for huge page
-*/
-   if (radix_enabled())
-   return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
-   return 0;
+   return pud_leaf(pud);
 }
 
 /*
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
b/arch/powerpc/include/asm/book3s/64/pgtable.h
index df66dce8306f..fd7180fded75 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -262,6 +262,18 @@ extern unsigned long __kernel_io_end;
 
 extern struct page *vmemmap;
 extern unsigned long pci_io_base;
+
+#define pmd_leaf pmd_leaf
+static inline bool pmd_leaf(pmd_t pmd)
+{
+   return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
+}
+
+#define pud_leaf pud_leaf
+static inline bool pud_leaf(pud_t pud)
+{
+   return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
+}
 #endif /* __ASSEMBLY__ */
 
 #include 
@@ -1436,20 +1448,5 @@ static inline bool is_pte_rw_upgrade(unsigned long 
old_val, unsigned long new_va
return false;
 }
 
-/*
- * Like pmd_huge(), but works regardless of config options
- */
-#define pmd_leaf pmd_leaf
-static inline bool pmd_leaf(pmd_t pmd)
-{
-   return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
-}
-
-#define pud_leaf pud_leaf
-static inline bool pud_leaf(pud_t pud)
-{
-   return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
-}
-
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */
-- 
2.44.0



[PATCH v2 07/14] mm/arm: Redefine pmd_huge() with pmd_leaf()

2024-03-18 Thread peterx
From: Peter Xu 

Most of the archs already define these two APIs the same way.  ARM is more
complicated in two aspects:

  - For pXd_huge() it's always checking against !PXD_TABLE_BIT, while for
pXd_leaf() it's always checking against PXD_TYPE_SECT.

  - SECT/TABLE bits are defined differently on 2-level v.s. 3-level ARM
pgtables, which makes the whole thing even harder to follow.

Luckily, the second complexity should be hidden by the pmd_leaf()
implementation against 2-level v.s. 3-level headers.  Invoke pmd_leaf()
directly for pmd_huge(), to remove the first part of complexity.  This
prepares to drop pXd_huge() API globally.

When at it, drop the obsolete comments - it's outdated.

Cc: Russell King 
Cc: Shawn Guo 
Cc: Krzysztof Kozlowski 
Cc: Bjorn Andersson 
Cc: Arnd Bergmann 
Cc: Konrad Dybcio 
Cc: Fabio Estevam 
Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Peter Xu 
---
 arch/arm/mm/hugetlbpage.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/arm/mm/hugetlbpage.c b/arch/arm/mm/hugetlbpage.c
index dd7a0277c5c0..c2fa643f6bb5 100644
--- a/arch/arm/mm/hugetlbpage.c
+++ b/arch/arm/mm/hugetlbpage.c
@@ -18,11 +18,6 @@
 #include 
 #include 
 
-/*
- * On ARM, huge pages are backed by pmd's rather than pte's, so we do a lot
- * of type casting from pmd_t * to pte_t *.
- */
-
 int pud_huge(pud_t pud)
 {
return 0;
@@ -30,5 +25,5 @@ int pud_huge(pud_t pud)
 
 int pmd_huge(pmd_t pmd)
 {
-   return pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT);
+   return pmd_leaf(pmd);
 }
-- 
2.44.0



[PATCH v2 06/14] mm/arm: Use macros to define pmd/pud helpers

2024-03-18 Thread peterx
From: Peter Xu 

It's already confusing that ARM 2-level v.s. 3-level defines SECT bit
differently on pmd/puds.  Always use a macro which is much clearer.

Cc: Russell King 
Cc: Shawn Guo 
Cc: Krzysztof Kozlowski 
Cc: Bjorn Andersson 
Cc: Arnd Bergmann 
Cc: Konrad Dybcio 
Cc: Fabio Estevam 
Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Peter Xu 
---
 arch/arm/include/asm/pgtable-2level.h   | 4 ++--
 arch/arm/include/asm/pgtable-3level-hwdef.h | 1 +
 arch/arm/include/asm/pgtable-3level.h   | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/pgtable-2level.h 
b/arch/arm/include/asm/pgtable-2level.h
index b0a262566eb9..4245c2e74720 100644
--- a/arch/arm/include/asm/pgtable-2level.h
+++ b/arch/arm/include/asm/pgtable-2level.h
@@ -213,8 +213,8 @@ 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_leaf(pmd)  (pmd_val(pmd) & 2)
-#define pmd_bad(pmd)   (pmd_val(pmd) & 2)
+#define pmd_leaf(pmd)  (pmd_val(pmd) & PMD_TYPE_SECT)
+#define pmd_bad(pmd)   pmd_leaf(pmd)
 #define pmd_present(pmd)   (pmd_val(pmd))
 
 #define copy_pmd(pmdpd,pmdps)  \
diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h 
b/arch/arm/include/asm/pgtable-3level-hwdef.h
index 2f35b4eddaa8..e7b666cf0060 100644
--- a/arch/arm/include/asm/pgtable-3level-hwdef.h
+++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
@@ -14,6 +14,7 @@
  * + Level 1/2 descriptor
  *   - common
  */
+#define PUD_TABLE_BIT  (_AT(pmdval_t, 1) << 1)
 #define PMD_TYPE_MASK  (_AT(pmdval_t, 3) << 0)
 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
 #define PMD_TYPE_TABLE (_AT(pmdval_t, 3) << 0)
diff --git a/arch/arm/include/asm/pgtable-3level.h 
b/arch/arm/include/asm/pgtable-3level.h
index 4b1d9eb3908a..e7aecbef75c9 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -112,7 +112,7 @@
 #ifndef __ASSEMBLY__
 
 #define pud_none(pud)  (!pud_val(pud))
-#define pud_bad(pud)   (!(pud_val(pud) & 2))
+#define pud_bad(pud)   (!(pud_val(pud) & PUD_TABLE_BIT))
 #define pud_present(pud)   (pud_val(pud))
 #define pmd_table(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \
 PMD_TYPE_TABLE)
@@ -137,7 +137,7 @@ static inline pmd_t *pud_pgtable(pud_t pud)
return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
 }
 
-#define pmd_bad(pmd)   (!(pmd_val(pmd) & 2))
+#define pmd_bad(pmd)   (!(pmd_val(pmd) & PMD_TABLE_BIT))
 
 #define copy_pmd(pmdpd,pmdps)  \
do {\
-- 
2.44.0



[PATCH v2 05/14] mm/sparc: Change pXd_huge() behavior to exclude swap entries

2024-03-18 Thread peterx
From: Peter Xu 

Please refer to the previous patch on the reasoning for x86.  Now sparc is
the only architecture that will allow swap entries to be reported as
pXd_huge().  After this patch, all architectures should forbid swap entries
in pXd_huge().

Cc: David S. Miller 
Cc: Andreas Larsson 
Cc: sparcli...@vger.kernel.org
Signed-off-by: Peter Xu 
---
 arch/sparc/mm/hugetlbpage.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
index b432500c13a5..d31c2cec35c9 100644
--- a/arch/sparc/mm/hugetlbpage.c
+++ b/arch/sparc/mm/hugetlbpage.c
@@ -409,14 +409,12 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, 
unsigned long addr,
 
 int pmd_huge(pmd_t pmd)
 {
-   return !pmd_none(pmd) &&
-   (pmd_val(pmd) & (_PAGE_VALID|_PAGE_PMD_HUGE)) != _PAGE_VALID;
+   return pmd_leaf(pmd);;
 }
 
 int pud_huge(pud_t pud)
 {
-   return !pud_none(pud) &&
-   (pud_val(pud) & (_PAGE_VALID|_PAGE_PUD_HUGE)) != _PAGE_VALID;
+   return pud_leaf(pud);
 }
 
 static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd,
-- 
2.44.0



[PATCH v2 04/14] mm/x86: Change pXd_huge() behavior to exclude swap entries

2024-03-18 Thread peterx
From: Peter Xu 

This patch partly reverts below commits:

3a194f3f8ad0 ("mm/hugetlb: make pud_huge() and follow_huge_pud() aware of 
non-present pud entry")
cbef8478bee5 ("mm/hugetlb: pmd_huge() returns true for non-present hugepage")

Right now, pXd_huge() definition across kernel is unclear. We have two
groups that think differently on swap entries:

  - x86/sparc: Allow pXd_huge() to accept swap entries
  - all the rest:  Doesn't allow pXd_huge() to accept swap entries

This is so confusing.  Since the sparc helpers seem to be added in 2016,
which is after x86's (2015), so sparc could have followed a trend.  x86
proposed such swap handling in 2015 to resolve hugetlb swap entries hit in
GUP, but now GUP guards swap entries with !pXd_present() in all layers so
we should be safe.

We should define this API properly, one way or another, rather than keep
them defined differently across archs.

Gut feeling tells me that pXd_huge() shouldn't include swap entries, and it
turns out that I am not the only one thinking so, the question was raised
when the current pmd_huge() for x86 was proposed by Ville Syrjälä:

https://lore.kernel.org/all/y2wq7i4lxh8iu...@intel.com/

  I might also be missing something obvious, but why is it even necessary
  to treat PRESENT==0+PSE==0 as a huge entry?

It is also questioned when Jason Gunthorpe reviewed the other patchset on
swap entry handlings:

https://lore.kernel.org/all/20240221125753.gq13...@nvidia.com/

Revert its meaning back to original.  It shouldn't have any functional
change as we should be ready with guards on !pXd_present() explicitly
everywhere.

Note that I also dropped the "#if CONFIG_PGTABLE_LEVELS > 2", it was there
probably because it was breaking things when 3a194f3f8ad0 was proposed,
according to the report here:

https://lore.kernel.org/all/y2lyxitkqyajt...@intel.com/

Now we shouldn't need that.

Instead of reverting to _PAGE_PSE raw check, leverage pXd_leaf().

Cc: Naoya Horiguchi 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: Dave Hansen 
Cc: x...@kernel.org
Signed-off-by: Peter Xu 
---
 arch/x86/mm/hugetlbpage.c | 18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
index 5804bbae4f01..8362953a24ce 100644
--- a/arch/x86/mm/hugetlbpage.c
+++ b/arch/x86/mm/hugetlbpage.c
@@ -20,29 +20,19 @@
 #include 
 
 /*
- * pmd_huge() returns 1 if @pmd is hugetlb related entry, that is normal
- * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry.
- * Otherwise, returns 0.
+ * pmd_huge() returns 1 if @pmd is hugetlb related entry.
  */
 int pmd_huge(pmd_t pmd)
 {
-   return !pmd_none(pmd) &&
-   (pmd_val(pmd) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT;
+   return pmd_leaf(pmd);
 }
 
 /*
- * pud_huge() returns 1 if @pud is hugetlb related entry, that is normal
- * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry.
- * Otherwise, returns 0.
+ * pud_huge() returns 1 if @pud is hugetlb related entry.
  */
 int pud_huge(pud_t pud)
 {
-#if CONFIG_PGTABLE_LEVELS > 2
-   return !pud_none(pud) &&
-   (pud_val(pud) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT;
-#else
-   return 0;
-#endif
+   return pud_leaf(pud);
 }
 
 #ifdef CONFIG_HUGETLB_PAGE
-- 
2.44.0



[PATCH v2 03/14] mm/gup: Check p4d presence before going on

2024-03-18 Thread peterx
From: Peter Xu 

Currently there should have no p4d swap entries so it may not matter much,
however this may help us to rule out swap entries in pXd_huge() API, which
will include p4d_huge().  The p4d_present() checks make it 100% clear that
we won't rely on p4d_huge() for swap entries.

Signed-off-by: Peter Xu 
---
 mm/gup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 69a777f4fc5c..802987281b2f 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -776,7 +776,7 @@ static struct page *follow_p4d_mask(struct vm_area_struct 
*vma,
 
p4dp = p4d_offset(pgdp, address);
p4d = READ_ONCE(*p4dp);
-   if (p4d_none(p4d))
+   if (!p4d_present(p4d))
return no_page_table(vma, flags);
BUILD_BUG_ON(p4d_huge(p4d));
if (unlikely(p4d_bad(p4d)))
@@ -3069,7 +3069,7 @@ static int gup_p4d_range(pgd_t *pgdp, pgd_t pgd, unsigned 
long addr, unsigned lo
p4d_t p4d = READ_ONCE(*p4dp);
 
next = p4d_addr_end(addr, end);
-   if (p4d_none(p4d))
+   if (!p4d_present(p4d))
return 0;
BUILD_BUG_ON(p4d_huge(p4d));
if (unlikely(is_hugepd(__hugepd(p4d_val(p4d) {
-- 
2.44.0



[PATCH v2 02/14] mm/gup: Cache p4d in follow_p4d_mask()

2024-03-18 Thread peterx
From: Peter Xu 

Add a variable to cache p4d in follow_p4d_mask().  It's a good practise to
make sure all the following checks will have a consistent view of the entry.

Signed-off-by: Peter Xu 
---
 mm/gup.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index df83182ec72d..69a777f4fc5c 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -772,16 +772,17 @@ static struct page *follow_p4d_mask(struct vm_area_struct 
*vma,
unsigned int flags,
struct follow_page_context *ctx)
 {
-   p4d_t *p4d;
+   p4d_t *p4dp, p4d;
 
-   p4d = p4d_offset(pgdp, address);
-   if (p4d_none(*p4d))
+   p4dp = p4d_offset(pgdp, address);
+   p4d = READ_ONCE(*p4dp);
+   if (p4d_none(p4d))
return no_page_table(vma, flags);
-   BUILD_BUG_ON(p4d_huge(*p4d));
-   if (unlikely(p4d_bad(*p4d)))
+   BUILD_BUG_ON(p4d_huge(p4d));
+   if (unlikely(p4d_bad(p4d)))
return no_page_table(vma, flags);
 
-   return follow_pud_mask(vma, address, p4d, flags, ctx);
+   return follow_pud_mask(vma, address, p4dp, flags, ctx);
 }
 
 /**
-- 
2.44.0



[PATCH v2 01/14] mm/hmm: Process pud swap entry without pud_huge()

2024-03-18 Thread peterx
From: Peter Xu 

Swap pud entries do not always return true for pud_huge() for all archs.
x86 and sparc (so far) allow it, but all the rest do not accept a swap
entry to be reported as pud_huge().  So it's not safe to check swap entries
within pud_huge().  Check swap entries before pud_huge(), so it should be
always safe.

This is the only place in the kernel that (IMHO, wrongly) relies on
pud_huge() to return true on pud swap entries.  The plan is to cleanup
pXd_huge() to only report non-swap mappings for all archs.

Cc: Alistair Popple 
Reviewed-by: Jason Gunthorpe 
Signed-off-by: Peter Xu 
---
 mm/hmm.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index 277ddcab4947..c95b9ec5d95f 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -424,7 +424,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long 
start, unsigned long end,
walk->action = ACTION_CONTINUE;
 
pud = READ_ONCE(*pudp);
-   if (pud_none(pud)) {
+   if (!pud_present(pud)) {
spin_unlock(ptl);
return hmm_vma_walk_hole(start, end, -1, walk);
}
@@ -435,11 +435,6 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long 
start, unsigned long end,
unsigned long *hmm_pfns;
unsigned long cpu_flags;
 
-   if (!pud_present(pud)) {
-   spin_unlock(ptl);
-   return hmm_vma_walk_hole(start, end, -1, walk);
-   }
-
i = (addr - range->start) >> PAGE_SHIFT;
npages = (end - addr) >> PAGE_SHIFT;
hmm_pfns = >hmm_pfns[i];
-- 
2.44.0



[PATCH v2 00/14] mm/treewide: Remove pXd_huge() API

2024-03-18 Thread peterx
From: Peter Xu 

[based on akpm/mm-unstable commit b66d4391d8fe, March 18th]

v2:
- Add a patch to cleanup ARM's pmd_thp_or_huge [Christophe]
- Enhance commit message for PowerPC patch on hugepd [Christophe]

v1: https://lore.kernel.org/r/20240313214719.253873-1-pet...@redhat.com

In previous work [1], we removed the pXd_large() API, which is arch
specific.  This patchset further removes the hugetlb pXd_huge() API.

Hugetlb was never special on creating huge mappings when compared with
other huge mappings.  Having a standalone API just to detect such pgtable
entries is more or less redundant, especially after the pXd_leaf() API set
is introduced with/without CONFIG_HUGETLB_PAGE.

When looking at this problem, a few issues are also exposed that we don't
have a clear definition of the *_huge() variance API.  This patchset
started by cleaning these issues first, then replace all *_huge() users to
use *_leaf(), then drop all *_huge() code.

On x86/sparc, swap entries will be reported "true" in pXd_huge(), while for
all the rest archs they're reported "false" instead.  This part is done in
patch 1-5, in which I suspect patch 1 can be seen as a bug fix, but I'll
leave that to hmm experts to decide.

Besides, there are three archs (arm, arm64, powerpc) that have slightly
different definitions between the *_huge() v.s. *_leaf() variances.  I
tackled them separately so that it'll be easier for arch experts to chim in
when necessary.  This part is done in patch 6-9.

The final patches 10-14 do the rest on the final removal, since *_leaf()
will be the ultimate API in the future, and we seem to have quite some
confusions on how *_huge() APIs can be defined, provide a rich comment for
*_leaf() API set to define them properly to avoid future misuse, and
hopefully that'll also help new archs to start support huge mappings and
avoid traps (like either swap entries, or PROT_NONE entry checks).

The whole series is lightly tested on x86 and arm64.

[1] https://lore.kernel.org/r/20240305043750.93762-1-pet...@redhat.com

Peter Xu (14):
  mm/hmm: Process pud swap entry without pud_huge()
  mm/gup: Cache p4d in follow_p4d_mask()
  mm/gup: Check p4d presence before going on
  mm/x86: Change pXd_huge() behavior to exclude swap entries
  mm/sparc: Change pXd_huge() behavior to exclude swap entries
  mm/arm: Use macros to define pmd/pud helpers
  mm/arm: Redefine pmd_huge() with pmd_leaf()
  mm/arm64: Merge pXd_huge() and pXd_leaf() definitions
  mm/powerpc: Redefine pXd_huge() with pXd_leaf()
  mm/gup: Merge pXd huge mapping checks
  mm/treewide: Replace pXd_huge() with pXd_leaf()
  mm/treewide: Remove pXd_huge()
  mm/arm: Remove pmd_thp_or_huge()
  mm: Document pXd_leaf() API

 arch/arm/include/asm/pgtable-2level.h |  5 ++-
 arch/arm/include/asm/pgtable-3level-hwdef.h   |  1 +
 arch/arm/include/asm/pgtable-3level.h |  5 ++-
 arch/arm/lib/uaccess_with_memcpy.c|  4 +--
 arch/arm/mm/Makefile  |  1 -
 arch/arm/mm/hugetlbpage.c | 34 ---
 arch/arm64/include/asm/pgtable.h  |  6 ++--
 arch/arm64/mm/hugetlbpage.c   | 18 ++
 arch/loongarch/mm/hugetlbpage.c   | 12 +--
 arch/mips/include/asm/pgtable-32.h|  2 +-
 arch/mips/include/asm/pgtable-64.h|  2 +-
 arch/mips/mm/hugetlbpage.c| 10 --
 arch/mips/mm/tlb-r4k.c|  2 +-
 arch/parisc/mm/hugetlbpage.c  | 11 --
 .../include/asm/book3s/64/pgtable-4k.h| 20 ---
 .../include/asm/book3s/64/pgtable-64k.h   | 25 --
 arch/powerpc/include/asm/book3s/64/pgtable.h  | 27 +++
 arch/powerpc/include/asm/nohash/pgtable.h | 10 --
 arch/powerpc/mm/pgtable_64.c  |  6 ++--
 arch/riscv/mm/hugetlbpage.c   | 10 --
 arch/s390/mm/hugetlbpage.c| 10 --
 arch/sh/mm/hugetlbpage.c  | 10 --
 arch/sparc/mm/hugetlbpage.c   | 12 ---
 arch/x86/mm/hugetlbpage.c | 26 --
 arch/x86/mm/pgtable.c |  4 +--
 include/linux/hugetlb.h   | 24 -
 include/linux/pgtable.h   | 24 ++---
 mm/gup.c  | 24 ++---
 mm/hmm.c  |  9 ++---
 mm/memory.c   |  2 +-
 30 files changed, 68 insertions(+), 288 deletions(-)
 delete mode 100644 arch/arm/mm/hugetlbpage.c

-- 
2.44.0



Re: [PATCH v1 1/1] ASoC: fsl: imx-es8328: Switch to using gpiod API

2024-03-18 Thread Andy Shevchenko
On Mon, Mar 18, 2024 at 09:58:37PM +0200, Andy Shevchenko wrote:
> This updates the driver to gpiod API, and removes yet another use of
> of_get_named_gpio().

This won't compile, sorry for the noise. I'll send a v2.

-- 
With Best Regards,
Andy Shevchenko




[PATCH v1 1/1] ASoC: fsl: imx-es8328: Switch to using gpiod API

2024-03-18 Thread Andy Shevchenko
This updates the driver to gpiod API, and removes yet another use of
of_get_named_gpio().

Signed-off-by: Andy Shevchenko 
---
 sound/soc/fsl/imx-es8328.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c
index 6f0d031c1d5f..ad915c55cc35 100644
--- a/sound/soc/fsl/imx-es8328.c
+++ b/sound/soc/fsl/imx-es8328.c
@@ -3,7 +3,7 @@
 // Copyright 2012 Freescale Semiconductor, Inc.
 // Copyright 2012 Linaro Ltd.
 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -23,7 +23,7 @@ struct imx_es8328_data {
struct snd_soc_card card;
char codec_dai_name[DAI_NAME_SIZE];
char platform_name[DAI_NAME_SIZE];
-   int jack_gpio;
+   struct gpio_desc *jack_gpiod;
 };
 
 static struct snd_soc_jack_gpio headset_jack_gpios[] = {
@@ -54,8 +54,8 @@ static int imx_es8328_dai_init(struct snd_soc_pcm_runtime 
*rtd)
struct imx_es8328_data, card);
int ret = 0;
 
-   /* Headphone jack detection */
-   if (gpio_is_valid(data->jack_gpio)) {
+   if (data->jack_gpiod) {
+   /* Headphone jack detection */
ret = snd_soc_card_jack_new_pins(rtd->card, "Headphone",
 SND_JACK_HEADSET | 
SND_JACK_BTN_0,
 _jack,
@@ -64,7 +64,7 @@ static int imx_es8328_dai_init(struct snd_soc_pcm_runtime 
*rtd)
if (ret)
return ret;
 
-   headset_jack_gpios[0].gpio = data->jack_gpio;
+   headset_jack_gpios[0].desc = data->jack_gpiod;
ret = snd_soc_jack_add_gpios(_jack,
 ARRAY_SIZE(headset_jack_gpios),
 headset_jack_gpios);
@@ -174,7 +174,11 @@ static int imx_es8328_probe(struct platform_device *pdev)
 
data->dev = dev;
 
-   data->jack_gpio = of_get_named_gpio(pdev->dev.of_node, "jack-gpio", 0);
+   data->jack_gpiod = devm_gpiod_get_optional(dev, "jack");
+   if (IS_ERR(data->jack_gpiod)) {
+   ret = PTR_ERR(data->jack_gpiod);
+   goto put_device;
+   }
 
/*
 * CPU == Platform
-- 
2.43.0.rc1.1.gbec44491f096



Re: Cannot load wireguard module

2024-03-18 Thread Michal Suchánek
On Mon, Mar 18, 2024 at 10:50:49PM +1100, Michael Ellerman wrote:
> Michael Ellerman  writes:
> > Michal Suchánek  writes:
> >> Hello,
> >>
> >> I cannot load the wireguard module.
> >>
> >> Loading the module provides no diagnostic other than 'No such device'.
> >>
> >> Please provide maningful diagnostics for loading software-only driver,
> >> clearly there is no particular device needed.
> >
> > Presumably it's just bubbling up an -ENODEV from somewhere.
> >
> > Can you get a trace of it?
> >
> > Something like:
> >
> >   # trace-cmd record -p function_graph -F modprobe wireguard
> >
> > That should probably show where it's bailing out.
> >
> >> jostaberry-1:~ # uname -a
> >> Linux jostaberry-1 6.8.0-lp155.8.g7e0e887-default #1 SMP Wed Mar 13 
> >> 09:02:21 UTC 2024 (7e0e887) ppc64le ppc64le ppc64le GNU/Linux
> >> jostaberry-1:~ # modprobe wireguard
> >> modprobe: ERROR: could not insert 'wireguard': No such device
> >> jostaberry-1:~ # modprobe -v wireguard
> >> insmod 
> >> /lib/modules/6.8.0-lp155.8.g7e0e887-default/kernel/arch/powerpc/crypto/chacha-p10-crypto.ko.zst
> >>  
> >> modprobe: ERROR: could not insert 'wireguard': No such device
> >  
> > What machine is this? A Power10?
> 
> I am able to load the module successfully on a P10 running v6.8.0.

Of course, it's not a Power10. Otherwise the Power10-specific chacha
implementation would load.

Thanks

Michal


Re: [PATCH 11/13] mm/treewide: Replace pXd_huge() with pXd_leaf()

2024-03-18 Thread Jason Gunthorpe
On Thu, Mar 14, 2024 at 08:59:22AM -0400, Peter Xu wrote:

> > > --- a/mm/hmm.c
> > > +++ b/mm/hmm.c
> > > @@ -429,7 +429,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned 
> > > long start, unsigned long end,
> > >   return hmm_vma_walk_hole(start, end, -1, walk);
> > >   }
> > >   
> > > - if (pud_huge(pud) && pud_devmap(pud)) {
> > > + if (pud_leaf(pud) && pud_devmap(pud)) {
> > 
> > Didn't previous patch say devmap implies leaf ? Or is it only for GUP ?
> 
> This is an extra safety check that I didn't remove.  Devmap used separate
> bits even though I'm not clear on why.  It should still imply a leaf though.

Yes, something is very wrong if devmap is true on non-leaf..

Jason


Re: [PATCH 09/13] mm/powerpc: Redefine pXd_huge() with pXd_leaf()

2024-03-18 Thread Jason Gunthorpe
On Thu, Mar 14, 2024 at 01:11:59PM +, Christophe Leroy wrote:
> 
> 
> Le 14/03/2024 à 13:53, Peter Xu a écrit :
> > On Thu, Mar 14, 2024 at 08:45:34AM +, Christophe Leroy wrote:
> >>
> >>
> >> Le 13/03/2024 à 22:47, pet...@redhat.com a écrit :
> >>> From: Peter Xu 
> >>>
> >>> PowerPC book3s 4K mostly has the same definition on both, except 
> >>> pXd_huge()
> >>> constantly returns 0 for hash MMUs.  As Michael Ellerman pointed out [1],
> >>> it is safe to check _PAGE_PTE on hash MMUs, as the bit will never be set 
> >>> so
> >>> it will keep returning false.
> >>>
> >>> As a reference, __p[mu]d_mkhuge() will trigger a BUG_ON trying to create
> >>> such huge mappings for 4K hash MMUs.  Meanwhile, the major powerpc hugetlb
> >>> pgtable walker __find_linux_pte() already used pXd_leaf() to check hugetlb
> >>> mappings.
> >>>
> >>> The goal should be that we will have one API pXd_leaf() to detect all 
> >>> kinds
> >>> of huge mappings.  AFAICT we need to use the pXd_leaf() impl (rather than
> >>> pXd_huge() ones) to make sure ie. THPs on hash MMU will also return true.
> >>
> >> All kinds of huge mappings ?
> >>
> >> pXd_leaf() will detect only leaf mappings (like pXd_huge() ). There are
> >> also huge mappings through hugepd. On powerpc 8xx we have 8M huge pages
> >> and 512k huge pages. A PGD entry covers 4M so pgd_leaf() won't report
> >> those huge pages.
> > 
> > Ah yes, I should always mention this is in the context of leaf huge pages
> > only.  Are the examples you provided all fall into hugepd category?  If so
> > I can reword the commit message, as:
> 
> On powerpc 8xx, only the 8M huge pages fall into the hugepd case.
> 
> The 512k hugepages are at PTE level, they are handled more or less like 
> CONT_PTE on ARM. see function set_huge_pte_at() for more context.
> 
> You can also look at pte_leaf_size() and pgd_leaf_size().

IMHO leaf should return false if the thing is pointing to a next level
page table, even if that next level is fully populated with contiguous
pages.

This seems more aligned with the contig page direction that hugepd
should be moved over to..

> By the way pgd_leaf_size() looks odd because it is called only when 
> pgd_leaf_size() returns true, which never happens for 8M pages.

Like this, you should reach the actual final leaf that the HW will
load and leaf_size() should say it is greater size than the current
table level. Other levels should return 0.

If necessary the core MM code should deal with this by iterating over
adjacent tables.

Jason


Re: [PATCH v14 00/16] Add audio support in v4l2 framework

2024-03-18 Thread Hans Verkuil
Hi Shengjiu,

I was about to prepare a pull request for this when I realized that
entries for the new drivers need to be added to the MAINTAINERS file.

Can you post patches 'v14 17/16' and 'v14/18/16' adding entries for each
new driver?

Thank you,

Hans

On 11/03/2024 10:53 am, Shengjiu Wang wrote:
> Audio signal processing also has the requirement for memory to
> memory similar as Video.
> 
> This asrc memory to memory (memory ->asrc->memory) case is a non
> real time use case.
> 
> User fills the input buffer to the asrc module, after conversion, then asrc
> sends back the output buffer to user. So it is not a traditional ALSA playback
> and capture case.
> 
> It is a specific use case,  there is no reference in current kernel.
> v4l2 memory to memory is the closed implementation,  v4l2 current
> support video, image, radio, tuner, touch devices, so it is not
> complicated to add support for this specific audio case.
> 
> Because we had implemented the "memory -> asrc ->i2s device-> codec"
> use case in ALSA.  Now the "memory->asrc->memory" needs
> to reuse the code in asrc driver, so the first 3 patches is for refining
> the code to make it can be shared by the "memory->asrc->memory"
> driver.
> 
> The main change is in the v4l2 side, A /dev/vl4-audioX will be created,
> user applications only use the ioctl of v4l2 framework.
> 
> Other change is to add memory to memory support for two kinds of i.MX ASRC
> module.
> 
> changes in v14:
> - document the reservation of 'AUXX' fourcc format.
> - add v4l2_audfmt_to_fourcc() definition.
> 
> changes in v13
> - change 'pixelformat' to 'audioformat' in dev-audio-mem2mem.rst
> - add more description for clock drift in ext-ctrls-audio-m2m.rst
> - Add "media: v4l2-ctrls: add support for fraction_bits" from Hans
>   to avoid build issue for kernel test robot
> 
> changes in v12
> - minor changes according to comments
> - drop min_buffers_needed = 1 and V4L2_CTRL_FLAG_UPDATE flag
> - drop bus_info
> 
> changes in v11
> - add add-fixed-point-test-controls in vivid.
> - add v4l2_ctrl_fp_compose() helper function for min and max
> 
> changes in v10
> - remove FIXED_POINT type
> - change code base on media: v4l2-ctrls: add support for fraction_bits
> - fix issue reported by kernel test robot
> - remove module_alias
> 
> changes in v9:
> - add MEDIA_ENT_F_PROC_AUDIO_RESAMPLER.
> - add MEDIA_INTF_T_V4L_AUDIO
> - add media controller support
> - refine the vim2m-audio to support 8k<->16k conversion.
> 
> changes in v8:
> - refine V4L2_CAP_AUDIO_M2M to be 0x0008
> - update doc for FIXED_POINT
> - address comments for imx-asrc
> 
> changes in v7:
> - add acked-by from Mark
> - separate commit for fixed point, m2m audio class, audio rate controls
> - use INTEGER_MENU for rate,  FIXED_POINT for rate offset
> - remove used fmts
> - address other comments for Hans
> 
> changes in v6:
> - use m2m_prepare/m2m_unprepare/m2m_start/m2m_stop to replace
>   m2m_start_part_one/m2m_stop_part_one, m2m_start_part_two/m2m_stop_part_two.
> - change V4L2_CTRL_TYPE_ASRC_RATE to V4L2_CTRL_TYPE_FIXED_POINT
> - fix warning by kernel test rebot
> - remove some unused format V4L2_AUDIO_FMT_XX
> - Get SNDRV_PCM_FORMAT from V4L2_AUDIO_FMT in driver.
> - rename audm2m to viaudm2m.
> 
> changes in v5:
> - remove V4L2_AUDIO_FMT_LPCM
> - define audio pixel format like V4L2_AUDIO_FMT_S8...
> - remove rate and format in struct v4l2_audio_format.
> - Add V4L2_CID_ASRC_SOURCE_RATE and V4L2_CID_ASRC_DEST_RATE controls
> - updata document accordingly.
> 
> changes in v4:
> - update document style
> - separate V4L2_AUDIO_FMT_LPCM and V4L2_CAP_AUDIO_M2M in separate commit
> 
> changes in v3:
> - Modify documents for adding audio m2m support
> - Add audio virtual m2m driver
> - Defined V4L2_AUDIO_FMT_LPCM format type for audio.
> - Defined V4L2_CAP_AUDIO_M2M capability type for audio m2m case.
> - with modification in v4l-utils, pass v4l2-compliance test.
> 
> changes in v2:
> - decouple the implementation in v4l2 and ALSA
> - implement the memory to memory driver as a platfrom driver
>   and move it to driver/media
> - move fsl_asrc_common.h to include/sound folder
> 
> Hans Verkuil (1):
>   media: v4l2-ctrls: add support for fraction_bits
> 
> Shengjiu Wang (15):
>   ASoC: fsl_asrc: define functions for memory to memory usage
>   ASoC: fsl_easrc: define functions for memory to memory usage
>   ASoC: fsl_asrc: move fsl_asrc_common.h to include/sound
>   ASoC: fsl_asrc: register m2m platform device
>   ASoC: fsl_easrc: register m2m platform device
>   media: uapi: Add V4L2_CAP_AUDIO_M2M capability flag
>   media: v4l2: Add audio capture and output support
>   media: uapi: Define audio sample format fourcc type
>   media: uapi: Add V4L2_CTRL_CLASS_M2M_AUDIO
>   media: uapi: Add audio rate controls support
>   media: uapi: Declare interface types for Audio
>   media: uapi: Add an entity type for audio resampler
>   media: vivid: add fixed point test controls
>   media: imx-asrc: Add memory to memory 

Re: [PATCH] powerpc/kernel: Fix potential spectre v1 in syscall

2024-03-18 Thread Nathan Lynch
Michael Ellerman  writes:

> Breno Leitao  writes:
>> On Tue, Mar 12, 2024 at 08:17:42AM +, Christophe Leroy wrote:
>>> +Nathan as this is RTAS related.

Thanks!

>>> Le 21/08/2018 à 20:42, Breno Leitao a écrit :
>>> > The rtas syscall reads a value from a user-provided structure and uses it
>>> > to index an array, being a possible area for a potential spectre v1 
>>> > attack.
>>> > This is the code that exposes this problem.
>>> > 
>>> >   args.rets = [nargs];
>>> > 
>>> > The nargs is an user provided value, and the below code is an example 
>>> > where
>>> > the 'nargs' value would be set to XX.
>>> > 
>>> >   struct rtas_args ra;
>>> >   ra.nargs = htobe32(XX);
>>> >   syscall(__NR_rtas, );
>>> 
>>> 
>>> This patch has been hanging around in patchwork since 2018 and doesn't 
>>> apply anymore. Is it still relevant ? If so, can you rebase et resubmit ?
>>
>> This seems to be important, since nargs is a user-provided value. I can
>> submit it if the maintainers are willing to accept. I do not want to
>> spend my time if no one is willing to review it.
>
> My memory is that I didn't think it was actually a problem, because all
> we do is memset args.rets to zero.

This is also my initial reaction to this. I suppose if the memset()
implementation performs some validation of the destination buffer
contents (comparing to a known poison value or something) that could
load the CPU cache then there is a more plausible issue?

> Anyway we should probably just fix it to be safe and keep the static
> checkers happy.

Here is the relevant passage in its current state:

if (copy_from_user(, uargs, 3 * sizeof(u32)) != 0)
return -EFAULT;

nargs = be32_to_cpu(args.nargs);
nret  = be32_to_cpu(args.nret);
token = be32_to_cpu(args.token);

if (nargs >= ARRAY_SIZE(args.args)
|| nret > ARRAY_SIZE(args.args)
|| nargs + nret > ARRAY_SIZE(args.args))
return -EINVAL;

/* Copy in args. */
if (copy_from_user(args.args, uargs->args,
   nargs * sizeof(rtas_arg_t)) != 0)
return -EFAULT;

/*
 * If this token doesn't correspond to a function the kernel
 * understands, you're not allowed to call it.
 */
func = rtas_token_to_function_untrusted(token);
if (!func)
return -EINVAL;

args.rets = [nargs];
memset(args.rets, 0, nret * sizeof(rtas_arg_t));

Some questions:

1. The patch sanitizes 'nargs' immediately before the call to memset(),
   but shouldn't that happen before 'nargs' is used as an input to
   copy_from_user()?

2. If 'nargs' needs this treatment, then why wouldn't the user-supplied
   'nret' and 'token' need them as well? 'nret' is used to index the
   same array as 'nargs'. And at least conceptually, 'token' is used to
   index a data structure (xarray) with array-like semantics (to be
   fair, this is a relatively recent development and was not the case
   when this change was submitted).


Re: [RFC] sched/eevdf: sched feature to dismiss lag on wakeup

2024-03-18 Thread Luis Machado
On 3/14/24 13:45, Tobias Huschle wrote:
> On Fri, Mar 08, 2024 at 03:11:38PM +, Luis Machado wrote:
>> On 2/28/24 16:10, Tobias Huschle wrote:
>>>
>>> Questions:
>>> 1. The kworker getting its negative lag occurs in the following scenario
>>>- kworker and a cgroup are supposed to execute on the same CPU
>>>- one task within the cgroup is executing and wakes up the kworker
>>>- kworker with 0 lag, gets picked immediately and finishes its
>>>  execution within ~5000ns
>>>- on dequeue, kworker gets assigned a negative lag
>>>Is this expected behavior? With this short execution time, I would
>>>expect the kworker to be fine.
>>
>> That strikes me as a bit odd as well. Have you been able to determine how a 
>> negative lag
>> is assigned to the kworker after such a short runtime?
>>
> 
> I did some more trace reading though and found something.
> 
> What I observed if everything runs regularly:
> - vhost and kworker run alternating on the same CPU
> - if the kworker is done, it leaves the runqueue
> - vhost wakes up the kworker if it needs it
> --> this means:
>   - vhost starts alone on an otherwise empty runqueue
>   - it seems like it never gets dequeued
> (unless another unrelated task joins or migration hits)
>   - if vhost wakes up the kworker, the kworker gets selected
>   - vhost runtime > kworker runtime 
> --> kworker gets positive lag and gets selected immediately next time
> 
> What happens if it does go wrong:
> From what I gather, there seem to be occasions where the vhost either
> executes suprisingly quick, or the kworker surprinsingly slow. If these
> outliers reach critical values, it can happen, that
>vhost runtime < kworker runtime
> which now causes the kworker to get the negative lag.
> 
> In this case it seems like, that the vhost is very fast in waking up
> the kworker. And coincidentally, the kworker takes, more time than usual
> to finish. We speak of 4-digit to low 5-digit nanoseconds.
> 
> So, for these outliers, the scheduler extrapolates that the kworker 
> out-consumes the vhost and should be slowed down, although in the majority
> of other cases this does not happen.

Thanks for providing the above details Tobias. It does seem like EEVDF is strict
about the eligibility checks and making tasks wait when their lags are 
negative, even
if just a little bit as in the case of the kworker.

There was a patch to disable the eligibility checks 
(https://lore.kernel.org/lkml/20231013030213.2472697-1-youssefes...@chromium.org/),
which would make EEVDF more like EVDF, though the deadline comparison would
probably still favor the vhost task instead of the kworker with the negative 
lag.

I'm not sure if you tried it, but I thought I'd mention it.


[PATCH 6/6] mm/mm_init.c: remove arch_reserved_kernel_pages()

2024-03-18 Thread Baoquan He
Since the current calculation of calc_nr_kernel_pages() has taken into
consideration of kernel reserved memory, no need to have
arch_reserved_kernel_pages() any more.

Signed-off-by: Baoquan He 
---
 arch/powerpc/include/asm/mmu.h |  4 
 arch/powerpc/kernel/fadump.c   |  5 -
 include/linux/mm.h |  3 ---
 mm/mm_init.c   | 12 
 4 files changed, 24 deletions(-)

diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 3b72c7ed24cf..aa5c0fd5edb1 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -406,9 +406,5 @@ extern void *abatron_pteptrs[2];
 #include 
 #endif
 
-#if defined(CONFIG_FA_DUMP) || defined(CONFIG_PRESERVE_FA_DUMP)
-#define __HAVE_ARCH_RESERVED_KERNEL_PAGES
-#endif
-
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_MMU_H_ */
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index d14eda1e8589..ae8c7619e597 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -1735,8 +1735,3 @@ static void __init fadump_reserve_crash_area(u64 base)
memblock_reserve(mstart, msize);
}
 }
-
-unsigned long __init arch_reserved_kernel_pages(void)
-{
-   return memblock_reserved_size() / PAGE_SIZE;
-}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 1888b1935103..8147b1302413 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3221,9 +3221,6 @@ static inline void show_mem(void)
 extern long si_mem_available(void);
 extern void si_meminfo(struct sysinfo * val);
 extern void si_meminfo_node(struct sysinfo *val, int nid);
-#ifdef __HAVE_ARCH_RESERVED_KERNEL_PAGES
-extern unsigned long arch_reserved_kernel_pages(void);
-#endif
 
 extern __printf(3, 4)
 void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...);
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 9ed4b9e77c4a..370a057dae97 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2383,17 +2383,6 @@ void __init page_alloc_init_late(void)
page_alloc_sysctl_init();
 }
 
-#ifndef __HAVE_ARCH_RESERVED_KERNEL_PAGES
-/*
- * Returns the number of pages that arch has reserved but
- * is not known to alloc_large_system_hash().
- */
-static unsigned long __init arch_reserved_kernel_pages(void)
-{
-   return 0;
-}
-#endif
-
 /*
  * Adaptive scale is meant to reduce sizes of hash tables on large memory
  * machines. As memory size is increased the scale is also increased but at
@@ -2436,7 +2425,6 @@ void *__init alloc_large_system_hash(const char 
*tablename,
if (!numentries) {
/* round applicable memory size up to nearest megabyte */
numentries = nr_kernel_pages;
-   numentries -= arch_reserved_kernel_pages();
 
/* It isn't necessary when PAGE_SIZE >= 1MB */
if (PAGE_SIZE < SZ_1M)
-- 
2.41.0



[PATCH 5/6] mm/mm_init.c: remove unneeded calc_memmap_size()

2024-03-18 Thread Baoquan He
Nobody calls calc_memmap_size() now.

Signed-off-by: Baoquan He 
---
 mm/mm_init.c | 20 
 1 file changed, 20 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 55a2b886b7a6..9ed4b9e77c4a 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1331,26 +1331,6 @@ static void __init calculate_node_totalpages(struct 
pglist_data *pgdat,
pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, 
realtotalpages);
 }
 
-static unsigned long __init calc_memmap_size(unsigned long spanned_pages,
-   unsigned long present_pages)
-{
-   unsigned long pages = spanned_pages;
-
-   /*
-* Provide a more accurate estimation if there are holes within
-* the zone and SPARSEMEM is in use. If there are holes within the
-* zone, each populated memory region may cost us one or two extra
-* memmap pages due to alignment because memmap pages for each
-* populated regions may not be naturally aligned on page boundary.
-* So the (present_pages >> 4) heuristic is a tradeoff for that.
-*/
-   if (spanned_pages > present_pages + (present_pages >> 4) &&
-   IS_ENABLED(CONFIG_SPARSEMEM))
-   pages = present_pages;
-
-   return PAGE_ALIGN(pages * sizeof(struct page)) >> PAGE_SHIFT;
-}
-
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 static void pgdat_init_split_queue(struct pglist_data *pgdat)
 {
-- 
2.41.0



[PATCH 4/6] mm/mm_init.c: remove meaningless calculation of zone->managed_pages in free_area_init_core()

2024-03-18 Thread Baoquan He
Currently, in free_area_init_core(), when initialize zone's field, a
rough value is set to zone->managed_pages. That value is calculated by
(zone->present_pages - memmap_pages).

In the meantime, add the value to nr_all_pages and nr_kernel_pages which
represent all free pages of system (only low memory or including HIGHMEM
memory separately). Both of them are gonna be used in
alloc_large_system_hash().

However, the rough calculation and setting of zone->managed_pages is
meaningless because
  a) memmap pages are allocated on units of node in sparse_init() or
 alloc_node_mem_map(pgdat); The simple (zone->present_pages -
 memmap_pages) is too rough to make sense for zone;
  b) the set zone->managed_pages will be zeroed out and reset with
 acutal value in mem_init() via memblock_free_all(). Before the
 resetting, no buddy allocation request is issued.

Here, remove the meaningless and complicated calculation of
(zone->present_pages - memmap_pages), directly set zone->present_pages to
zone->managed_pages. It will be adjusted in mem_init().

And also remove the assignment of nr_all_pages and nr_kernel_pages in
free_area_init_core(). Instead, call the newly added calc_nr_kernel_pages()
to count up all free but not reserved memory in memblock and assign to
nr_all_pages and nr_kernel_pages. The counting excludes memmap_pages,
and other kernel used data, which is more accurate than old way and
simpler, and can also cover the ppc required arch_reserved_kernel_pages()
case.

Signed-off-by: Baoquan He 
---
 mm/mm_init.c | 38 ++
 1 file changed, 6 insertions(+), 32 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index c57a7fc97a16..55a2b886b7a6 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1584,41 +1584,14 @@ static void __init free_area_init_core(struct 
pglist_data *pgdat)
 
for (j = 0; j < MAX_NR_ZONES; j++) {
struct zone *zone = pgdat->node_zones + j;
-   unsigned long size, freesize, memmap_pages;
-
-   size = zone->spanned_pages;
-   freesize = zone->present_pages;
-
-   /*
-* Adjust freesize so that it accounts for how much memory
-* is used by this zone for memmap. This affects the watermark
-* and per-cpu initialisations
-*/
-   memmap_pages = calc_memmap_size(size, freesize);
-   if (!is_highmem_idx(j)) {
-   if (freesize >= memmap_pages) {
-   freesize -= memmap_pages;
-   if (memmap_pages)
-   pr_debug("  %s zone: %lu pages used for 
memmap\n",
-zone_names[j], memmap_pages);
-   } else
-   pr_warn("  %s zone: %lu memmap pages exceeds 
freesize %lu\n",
-   zone_names[j], memmap_pages, freesize);
-   }
-
-   if (!is_highmem_idx(j))
-   nr_kernel_pages += freesize;
-   /* Charge for highmem memmap if there are enough kernel pages */
-   else if (nr_kernel_pages > memmap_pages * 2)
-   nr_kernel_pages -= memmap_pages;
-   nr_all_pages += freesize;
+   unsigned long size = zone->spanned_pages;
 
/*
-* Set an approximate value for lowmem here, it will be adjusted
-* when the bootmem allocator frees pages into the buddy system.
-* And all highmem pages will be managed by the buddy system.
+* Set the zone->managed_pages as zone->present_pages roughly, 
it
+* be zeroed out and reset when memblock allocator frees pages 
into
+* buddy system.
 */
-   zone_init_internals(zone, j, nid, freesize);
+   zone_init_internals(zone, j, nid, zone->present_pages);
 
if (!size)
continue;
@@ -1915,6 +1888,7 @@ void __init free_area_init(unsigned long *max_zone_pfn)
check_for_memory(pgdat);
}
 
+   calc_nr_kernel_pages();
memmap_init();
 
/* disable hash distribution for systems with a single node */
-- 
2.41.0



[PATCH 3/6] mm/mm_init.c: add new function calc_nr_kernel_pages()

2024-03-18 Thread Baoquan He
This is a preparation to calculate nr_kernel_pages and nr_all_pages,
both of which will be used later in alloc_large_system_hash().

nr_all_pages counts up all free but not reserved memory in memblock
allocator, including HIGHMEM memory. While nr_kernel_pages counts up
all free but not reserved low memory in memblock allocator, excluding
HIGHMEM memory.

Signed-off-by: Baoquan He 
---
 mm/mm_init.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 153fb2dc666f..c57a7fc97a16 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1264,6 +1264,30 @@ static void __init 
reset_memoryless_node_totalpages(struct pglist_data *pgdat)
pr_debug("On node %d totalpages: 0\n", pgdat->node_id);
 }
 
+static void __init calc_nr_kernel_pages(void)
+{
+   unsigned long start_pfn, end_pfn;
+   phys_addr_t start_addr, end_addr;
+   u64 u;
+#ifdef CONFIG_HIGHMEM
+   unsigned long high_zone_low = 
arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
+#endif
+
+   for_each_free_mem_range(u, NUMA_NO_NODE, MEMBLOCK_NONE, _addr, 
_addr, NULL) {
+   start_pfn = PFN_UP(start_addr);
+   end_pfn   = PFN_DOWN(end_addr);
+
+   if (start_pfn < end_pfn) {
+   nr_all_pages += end_pfn - start_pfn;
+#ifdef CONFIG_HIGHMEM
+   start_pfn = clamp(start_pfn, 0, high_zone_low);
+   end_pfn = clamp(end_pfn, 0, high_zone_low);
+#endif
+   nr_kernel_pages += end_pfn - start_pfn;
+   }
+   }
+}
+
 static void __init calculate_node_totalpages(struct pglist_data *pgdat,
unsigned long node_start_pfn,
unsigned long node_end_pfn)
-- 
2.41.0



[PATCH 2/6] x86: remove memblock_find_dma_reserve()

2024-03-18 Thread Baoquan He
This is not needed any more.

Signed-off-by: Baoquan He 
---
 arch/x86/include/asm/pgtable.h |  1 -
 arch/x86/kernel/setup.c|  2 --
 arch/x86/mm/init.c | 45 --
 3 files changed, 48 deletions(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 315535ffb258..cefc7a84f7a4 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1200,7 +1200,6 @@ static inline int pgd_none(pgd_t pgd)
 extern int direct_gbpages;
 void init_mem_mapping(void);
 void early_alloc_pgt_buf(void);
-extern void memblock_find_dma_reserve(void);
 void __init poking_init(void);
 unsigned long init_memory_mapping(unsigned long start,
  unsigned long end, pgprot_t prot);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 3e1e96efadfe..5aa00938051f 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1106,8 +1106,6 @@ void __init setup_arch(char **cmdline_p)
 */
arch_reserve_crashkernel();
 
-   memblock_find_dma_reserve();
-
if (!early_xdbc_setup_hardware())
early_xdbc_register_console();
 
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 5209549e8192..615f0bf4bda6 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -990,51 +990,6 @@ void __init free_initrd_mem(unsigned long start, unsigned 
long end)
 }
 #endif
 
-/*
- * Calculate the precise size of the DMA zone (first 16 MB of RAM),
- * and pass it to the MM layer - to help it set zone watermarks more
- * accurately.
- *
- * Done on 64-bit systems only for the time being, although 32-bit systems
- * might benefit from this as well.
- */
-void __init memblock_find_dma_reserve(void)
-{
-#ifdef CONFIG_X86_64
-   u64 nr_pages = 0, nr_free_pages = 0;
-   unsigned long start_pfn, end_pfn;
-   phys_addr_t start_addr, end_addr;
-   int i;
-   u64 u;
-
-   /*
-* Iterate over all memory ranges (free and reserved ones alike),
-* to calculate the total number of pages in the first 16 MB of RAM:
-*/
-   nr_pages = 0;
-   for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, NULL) {
-   start_pfn = min(start_pfn, MAX_DMA_PFN);
-   end_pfn   = min(end_pfn,   MAX_DMA_PFN);
-
-   nr_pages += end_pfn - start_pfn;
-   }
-
-   /*
-* Iterate over free memory ranges to calculate the number of free
-* pages in the DMA zone, while not counting potential partial
-* pages at the beginning or the end of the range:
-*/
-   nr_free_pages = 0;
-   for_each_free_mem_range(u, NUMA_NO_NODE, MEMBLOCK_NONE, _addr, 
_addr, NULL) {
-   start_pfn = min_t(unsigned long, PFN_UP(start_addr), 
MAX_DMA_PFN);
-   end_pfn   = min_t(unsigned long, PFN_DOWN(end_addr), 
MAX_DMA_PFN);
-
-   if (start_pfn < end_pfn)
-   nr_free_pages += end_pfn - start_pfn;
-   }
-#endif
-}
-
 void __init zone_sizes_init(void)
 {
unsigned long max_zone_pfns[MAX_NR_ZONES];
-- 
2.41.0



[PATCH 1/6] mm/mm_init.c: remove the useless dma_reserve

2024-03-18 Thread Baoquan He
Variable dma_reserve and its usage was introduced in commit 0e0b864e069c
("[PATCH] Account for memmap and optionally the kernel image as holes").
Its original purpose was to accounting for the reserved pages in DMA
zone to make DMA zone's watermarks calculation more accurate on x86.

However, currently there's zone->managed_pages to account for all
available pages for buddy, zone->present_pages to account for all
present physical pages in zone. What is more important, on x86,
calculating and setting the zone->managed_pages is a temporary move,
all zone's managed_pages will be zeroed out and reset to the actual
value according to how many pages are added to buddy allocator in
mem_init(). Before mem_init(), no buddy alloction is requested. And
zone's pcp and watermark setting are all done after mem_init(). So,
no need to worry about the DMA zone's setting accuracy during
free_area_init().

Hence, remove dma_reserve and its handling in free_area_init_core()
because it's useless and causes confusion.

Signed-off-by: Baoquan He 
---
 arch/x86/mm/init.c |  2 --
 include/linux/mm.h |  1 -
 mm/mm_init.c   | 23 ---
 3 files changed, 26 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 679893ea5e68..5209549e8192 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -1032,8 +1032,6 @@ void __init memblock_find_dma_reserve(void)
if (start_pfn < end_pfn)
nr_free_pages += end_pfn - start_pfn;
}
-
-   set_dma_reserve(nr_pages - nr_free_pages);
 #endif
 }
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 2c0910bc3e4a..1888b1935103 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3210,7 +3210,6 @@ static inline int early_pfn_to_nid(unsigned long pfn)
 extern int __meminit early_pfn_to_nid(unsigned long pfn);
 #endif
 
-extern void set_dma_reserve(unsigned long new_dma_reserve);
 extern void mem_init(void);
 extern void __init mmap_init(void);
 
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 549e76af8f82..153fb2dc666f 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -226,7 +226,6 @@ static unsigned long required_movablecore_percent 
__initdata;
 
 static unsigned long nr_kernel_pages __initdata;
 static unsigned long nr_all_pages __initdata;
-static unsigned long dma_reserve __initdata;
 
 static bool deferred_struct_pages __meminitdata;
 
@@ -1583,12 +1582,6 @@ static void __init free_area_init_core(struct 
pglist_data *pgdat)
zone_names[j], memmap_pages, freesize);
}
 
-   /* Account for reserved pages */
-   if (j == 0 && freesize > dma_reserve) {
-   freesize -= dma_reserve;
-   pr_debug("  %s zone: %lu pages reserved\n", 
zone_names[0], dma_reserve);
-   }
-
if (!is_highmem_idx(j))
nr_kernel_pages += freesize;
/* Charge for highmem memmap if there are enough kernel pages */
@@ -2547,22 +2540,6 @@ void *__init alloc_large_system_hash(const char 
*tablename,
return table;
 }
 
-/**
- * set_dma_reserve - set the specified number of pages reserved in the first 
zone
- * @new_dma_reserve: The number of pages to mark reserved
- *
- * The per-cpu batchsize and zone watermarks are determined by managed_pages.
- * In the DMA zone, a significant percentage may be consumed by kernel image
- * and other unfreeable allocations which can skew the watermarks badly. This
- * function may optionally be used to account for unfreeable pages in the
- * first zone (e.g., ZONE_DMA). The effect will be lower watermarks and
- * smaller per-cpu batchsize.
- */
-void __init set_dma_reserve(unsigned long new_dma_reserve)
-{
-   dma_reserve = new_dma_reserve;
-}
-
 void __init memblock_free_pages(struct page *page, unsigned long pfn,
unsigned int order)
 {
-- 
2.41.0



[PATCH 0/6] mm/mm_init.c: refactor free_area_init_core()

2024-03-18 Thread Baoquan He
In function free_area_init_core(), the code calculating
zone->managed_pages and the subtracting dma_reserve from DMA zone looks
very confusing.

>From git history, the code calculating zone->managed_pages was for
zone->present_pages originally. The early rough assignment is for
optimize zone's pcp and water mark setting. Later, managed_pages was
introduced into zone to represent the number of managed pages by buddy.
Now, zone->managed_pages is zeroed out and reset in mem_init() when
calling memblock_free_all(). zone's pcp and wmark setting relying on
actual zone->managed_pages are done later than mem_init() invocation.
So we don't need rush to early calculate and set zone->managed_pages,
just set it as zone->present_pages, will adjust it in mem_init().

And also add a new function calc_nr_kernel_pages() to count up free but
not reserved pages in memblock, then assign it to nr_all_pages and
nr_kernel_pages after memmap pages are allocated.


Baoquan He (6):
  mm/mm_init.c: remove the useless dma_reserve
  x86: remove unneeded memblock_find_dma_reserve()
  mm/mm_init.c: add new function calc_nr_all_pages()
  mm/mm_init.c: remove meaningless calculation of zone->managed_pages in
free_area_init_core()
  mm/mm_init.c: remove unneeded calc_memmap_size()
  mm/mm_init.c: remove arch_reserved_kernel_pages()

 arch/powerpc/include/asm/mmu.h |   4 --
 arch/powerpc/kernel/fadump.c   |   5 --
 arch/x86/include/asm/pgtable.h |   1 -
 arch/x86/kernel/setup.c|   2 -
 arch/x86/mm/init.c |  47 -
 include/linux/mm.h |   4 --
 mm/mm_init.c   | 117 +
 7 files changed, 30 insertions(+), 150 deletions(-)

-- 
2.41.0



Re: linux-next: manual merge of the powerpc tree with the mm-stable tree

2024-03-18 Thread Michael Ellerman
Christophe Leroy  writes:
> Le 29/02/2024 à 07:37, Michael Ellerman a écrit :
>> Stephen Rothwell  writes:
>>> Hi all,
>>>
>>> Today's linux-next merge of the powerpc tree got a conflict in:
>>>
>>>arch/powerpc/mm/pgtable_32.c
>>>
>>> between commit:
>>>
>>>a5e8131a0329 ("arm64, powerpc, riscv, s390, x86: ptdump: refactor 
>>> CONFIG_DEBUG_WX")
>>>
>>> from the mm-stable tree and commit:
>>>
>>>8f17bd2f4196 ("powerpc: Handle error in mark_rodata_ro() and 
>>> mark_initmem_nx()")
>>>
>>> from the powerpc tree.
>> 
>> Thanks. That's a fairly ugly conflict.
>> 
>> Maybe I'll drop that patch until the generic change has gone in.
>> 
>
> The change is now in linus tree.

Thanks. I have moved my next up and applied your v2 on top of the
upstream changes.

cheers


Re: Cannot load wireguard module

2024-03-18 Thread Michael Ellerman
Michael Ellerman  writes:
> Michal Suchánek  writes:
>> Hello,
>>
>> I cannot load the wireguard module.
>>
>> Loading the module provides no diagnostic other than 'No such device'.
>>
>> Please provide maningful diagnostics for loading software-only driver,
>> clearly there is no particular device needed.
>
> Presumably it's just bubbling up an -ENODEV from somewhere.
>
> Can you get a trace of it?
>
> Something like:
>
>   # trace-cmd record -p function_graph -F modprobe wireguard
>
> That should probably show where it's bailing out.
>
>> jostaberry-1:~ # uname -a
>> Linux jostaberry-1 6.8.0-lp155.8.g7e0e887-default #1 SMP Wed Mar 13 09:02:21 
>> UTC 2024 (7e0e887) ppc64le ppc64le ppc64le GNU/Linux
>> jostaberry-1:~ # modprobe wireguard
>> modprobe: ERROR: could not insert 'wireguard': No such device
>> jostaberry-1:~ # modprobe -v wireguard
>> insmod 
>> /lib/modules/6.8.0-lp155.8.g7e0e887-default/kernel/arch/powerpc/crypto/chacha-p10-crypto.ko.zst
>>  
>> modprobe: ERROR: could not insert 'wireguard': No such device
>  
> What machine is this? A Power10?

I am able to load the module successfully on a P10 running v6.8.0.

I tried running the demo (client-quick.sh) to check it actually works,
but that hangs sending the public key, I suspect because my development
machine is behind multiple firewalls.

cheers


Re: [PATCH 2/3] tools/erf/util/annotate: Set register_char and memory_ref_char for powerpc

2024-03-18 Thread Athira Rajeev



> On 09-Mar-2024, at 11:13 PM, Segher Boessenkool  
> wrote:
> 
> All instructions with a primary opcode from 32 to 63 are memory insns,
> and no others.  It's trivial to see whether it is a load or store, too
> (just bit 3 of the insn).  Trying to parse disassembled code is much
> harder, and you easily make some mistakes here.

Hi Segher

Thanks for checking the patch and sharing review comments.

Ok, I am checking on this part.

> 
> On Sat, Mar 09, 2024 at 12:55:12PM +0530, Athira Rajeev wrote:
>> To identify if the instruction has any memory reference,
>> "memory_ref_char" field needs to be set for specific architecture.
>> Example memory instruction:
>> lwz r10,0(r9)
>> 
>> Here "(" is the memory_ref_char. Set this as part of arch->objdump
> 
> What about "lwzx r10,0,r19", semantically exactly the same instruction?
> There is no paren in there.  Not all instructions using parens are
> memory insns, either, not in assembler code at least.
Yes, right Segher.

So, for the basic foundational patches, I targeted for instructions of this 
form (D form)
There are still samples, which comes as unknown and in that, X form 
instructions also needs to be checked.
Targeted to first get these basic foundational patches to add support in 
powerpc and get the remaining “unknowns” addressed in follow up.
But yes, X-form instructions also will be covered as part of the changes needed 
for powerpc.

> 
>> To get register number and access offset from the given instruction,
>> arch->objdump.register_char is used. In case of powerpc, the register
>> char is "r" (since reg names are r0 to r31). Hence set register_char
>> as "r".
> 
> cr0..cr7
> r0..r31
> f0..f31
> v0..v31
> vs0..vs63
> and many other spellings.  Plain "0..63" is also fine.
Ok 
> 
> The "0" in my lwzx example is a register field as well (and it stands
> for "no register", not for "r0").  Called "(RA|0)" usually (incidentally,
> see the parens there as well, oh joy).
> 
> Don't you have the binary code here as well, not just a disassembled
> representation of it?  It is way easier to just use that, and you'll get
> much better results that way :-)
> 

Thanks Segher for the suggestion on this. I will check on this as well.

Thanks
Athira Rajeev

> 
> Segher



Re: [PATCH 1/3] tools/perf/arch/powerpc: Add load/store in powerpc annotate instructions for data type profling

2024-03-18 Thread Athira Rajeev



> On 09-Mar-2024, at 3:18 PM, Christophe Leroy  
> wrote:
> 
> 
> 
> Le 09/03/2024 à 08:25, Athira Rajeev a écrit :
>> Add powerpc instruction nmemonic table to associate load/store
>> instructions with move_ops. mov_ops is used to identify mem_type
>> to associate instruction with data type and offset. Also initialize
>> and allocate arch specific fields for nr_instructions, instructions and
>> nr_instructions_allocate.
>> 
>> Signed-off-by: Athira Rajeev 
>> ---
>>  .../perf/arch/powerpc/annotate/instructions.c | 66 +++
>>  1 file changed, 66 insertions(+)
>> 
>> diff --git a/tools/perf/arch/powerpc/annotate/instructions.c 
>> b/tools/perf/arch/powerpc/annotate/instructions.c
>> index a3f423c27cae..07af4442be38 100644
>> --- a/tools/perf/arch/powerpc/annotate/instructions.c
>> +++ b/tools/perf/arch/powerpc/annotate/instructions.c
>> @@ -1,6 +1,65 @@
>>  // SPDX-License-Identifier: GPL-2.0
>>  #include 
>> 
>> +/*
>> + * powerpc instruction nmemonic table to associate load/store instructions 
>> with
>> + * move_ops. mov_ops is used to identify mem_type to associate instruction 
>> with
>> + * data type and offset.
>> + */
>> +static struct ins powerpc__instructions[] = {
>> + { .name = "lbz", .ops = _ops,  },
>> + { .name = "lbzx", .ops = _ops,  },
>> + { .name = "lbzu", .ops = _ops,  },
>> + { .name = "lbzux", .ops = _ops,  },
>> + { .name = "lhz", .ops = _ops,  },
>> + { .name = "lhzx", .ops = _ops,  },
>> + { .name = "lhzu", .ops = _ops,  },
>> + { .name = "lhzux", .ops = _ops,  },
>> + { .name = "lha", .ops = _ops,  },
>> + { .name = "lhax", .ops = _ops,  },
>> + { .name = "lhau", .ops = _ops,  },
>> + { .name = "lhaux", .ops = _ops,  },
>> + { .name = "lwz", .ops = _ops,  },
>> + { .name = "lwzx", .ops = _ops,  },
>> + { .name = "lwzu", .ops = _ops,  },
>> + { .name = "lwzux", .ops = _ops,  },
>> + { .name = "lwa", .ops = _ops,  },
>> + { .name = "lwax", .ops = _ops,  },
>> + { .name = "lwaux", .ops = _ops,  },
>> + { .name = "ld", .ops = _ops,  },
>> + { .name = "ldx", .ops = _ops,  },
>> + { .name = "ldu", .ops = _ops,  },
>> + { .name = "ldux", .ops = _ops,  },
>> + { .name = "stb", .ops = _ops,  },
>> + { .name = "stbx", .ops = _ops,  },
>> + { .name = "stbu", .ops = _ops,  },
>> + { .name = "stbux", .ops = _ops,  },
>> + { .name = "sth", .ops = _ops,  },
>> + { .name = "sthx", .ops = _ops,  },
>> + { .name = "sthu", .ops = _ops,  },
>> + { .name = "sthux", .ops = _ops,  },
>> + { .name = "stw", .ops = _ops,  },
>> + { .name = "stwx", .ops = _ops,  },
>> + { .name = "stwu", .ops = _ops,  },
>> + { .name = "stwux", .ops = _ops,  },
>> + { .name = "std", .ops = _ops,  },
>> + { .name = "stdx", .ops = _ops,  },
>> + { .name = "stdu", .ops = _ops,  },
>> + { .name = "stdux", .ops = _ops,  },
>> + { .name = "lhbrx", .ops = _ops,  },
>> + { .name = "sthbrx", .ops = _ops,  },
>> + { .name = "lwbrx", .ops = _ops,  },
>> + { .name = "stwbrx", .ops = _ops,  },
>> + { .name = "ldbrx", .ops = _ops,  },
>> + { .name = "stdbrx", .ops = _ops,  },
>> + { .name = "lmw", .ops = _ops,  },
>> + { .name = "stmw", .ops = _ops,  },
>> + { .name = "lswi", .ops = _ops,  },
>> + { .name = "lswx", .ops = _ops,  },
>> + { .name = "stswi", .ops = _ops,  },
>> + { .name = "stswx", .ops = _ops,  },
>> +};
> 
> What about lwarx and stwcx ?
Yes, Will add those in next version

> 
>> +
>>  static struct ins_ops *powerpc__associate_instruction_ops(struct arch 
>> *arch, const char *name)
>>  {
>>   int i;
>> @@ -52,6 +111,13 @@ static struct ins_ops 
>> *powerpc__associate_instruction_ops(struct arch *arch, con
>>  static int powerpc__annotate_init(struct arch *arch, char *cpuid 
>> __maybe_unused)
>>  {
>>   if (!arch->initialized) {
>> + arch->nr_instructions = ARRAY_SIZE(powerpc__instructions);
>> + arch->instructions = calloc(arch->nr_instructions, sizeof(struct ins));
>> + if (arch->instructions == NULL)
> 
> Prefered form is
> 
> if (!arch->instructions)
Ok , will make this change

> 
>> + return -ENOMEM;
>> +
>> + memcpy(arch->instructions, (struct ins *)powerpc__instructions, 
>> sizeof(struct ins) * arch->nr_instructions);
> 
> No need to cast powerpc__instructions, it is already a pointer.
Yes, I will correct it


Thanks
Athira Rajeev
> 
> 
>> + arch->nr_instructions_allocated = arch->nr_instructions;
>>   arch->initialized = true;
>>   arch->associate_instruction_ops = powerpc__associate_instruction_ops;
>>   arch->objdump.comment_char  = '#';




Re: [PATCH 3/3] tools/perf/arch/powerc: Add get_arch_regnum for powerpc

2024-03-18 Thread Athira Rajeev



> On 09-Mar-2024, at 3:24 PM, Christophe Leroy  
> wrote:
> 
> 
> 
> Le 09/03/2024 à 08:25, Athira Rajeev a écrit :
>> The function get_dwarf_regnum() returns a DWARF register number
>> from a register name string. This calls arch specific function
>> get_arch_regnum to return register number for corresponding arch.
>> Add mappings for register name to register number in powerpc code:
>> arch/powerpc/util/dwarf-regs.c
>> 
>> Signed-off-by: Athira Rajeev 
>> ---
>>  tools/perf/arch/powerpc/util/dwarf-regs.c | 29 +++
>>  1 file changed, 29 insertions(+)
>> 
>> diff --git a/tools/perf/arch/powerpc/util/dwarf-regs.c 
>> b/tools/perf/arch/powerpc/util/dwarf-regs.c
>> index 0c4f4caf53ac..d955e3e577ea 100644
>> --- a/tools/perf/arch/powerpc/util/dwarf-regs.c
>> +++ b/tools/perf/arch/powerpc/util/dwarf-regs.c
>> @@ -98,3 +98,32 @@ int regs_query_register_offset(const char *name)
>>   return roff->ptregs_offset;
>>   return -EINVAL;
>>  }
>> +
>> +struct dwarf_regs_idx {
>> + const char *name;
>> + int idx;
>> +};
>> +
>> +static const struct dwarf_regs_idx powerpc_regidx_table[] = {
>> + { "r0", 0 }, { "r1", 1 }, { "r2", 2 }, { "r3", 3 }, { "r4", 4 },
>> + { "r5", 5 }, { "r6", 6 }, { "r7", 7 }, { "r8", 8 }, { "r9", 9 },
>> + { "r10", 10 }, { "r11", 11 }, { "r12", 12 }, { "r13", 13 }, { "r14", 14 },
>> + { "r15", 15 }, { "r16", 16 }, { "r17", 17 }, { "r18", 18 }, { "r19", 19 },
>> + { "r20", 20 }, { "r21", 21 }, { "r22", 22 }, { "r23", 23 }, { "r24", 24 },
>> + { "r25", 25 }, { "r26", 26 }, { "r27", 27 }, { "r27", 27 }, { "r28", 28 },
>> + { "r29", 29 }, { "r30", 30 }, { "r31", 31 },
>> +};
>> +
>> +int get_arch_regnum(const char *name)
>> +{
>> + unsigned int i;
>> +
>> + if (*name != 'r')
>> + return -EINVAL;
>> +
>> + for (i = 0; i < ARRAY_SIZE(powerpc_regidx_table); i++)
>> + if (!strcmp(powerpc_regidx_table[i].name, name))
>> + return powerpc_regidx_table[i].idx;
> 
> Can you do more simple ?
> 
> Something like:
> 
> int n;
> 
> if (*name != 'r')
> return -EINVAL;
> n = atoi(name + 1);
> return n >= 0 && n < 32 ? n : -ENOENT;

Hi Christophe,

Thanks for reviewing patch and for the suggestions.

Sure, I will check this approach and address in V2

Thanks
Athira
> 
>> +
>> + return -ENOENT;
>> +}



Re: [PATCH] net: wan: fsl_qmc_hdlc: Fix module compilation

2024-03-18 Thread patchwork-bot+netdevbpf
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller :

On Thu, 14 Mar 2024 13:33:46 +0100 you wrote:
> The fsl_qmc_driver does not compile as module:
>   error: ‘qmc_hdlc_driver’ undeclared here (not in a function);
> 405 | MODULE_DEVICE_TABLE(of, qmc_hdlc_driver);
> | ^~~
> 
> Fix the typo.
> 
> [...]

Here is the summary with links:
  - net: wan: fsl_qmc_hdlc: Fix module compilation
https://git.kernel.org/netdev/net/c/badc9e33c795

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html