All of lore.kernel.org
 help / color / mirror / Atom feed
From: Itaru Kitayama <itaru.kitayama@linux.dev>
To: Mark Rutland <mark.rutland@arm.com>
Cc: skseofh@gmail.com, catalin.marinas@arm.com, will@kernel.org,
	ryan.roberts@arm.com, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64: add early fixmap initialization flag
Date: Tue, 20 Feb 2024 09:29:14 +0900	[thread overview]
Message-ID: <ZdPyWkOlUan5AI9r@vm3> (raw)
In-Reply-To: <ZdMx-svsHgrfguxX@FVFF77S0Q05N>

On Mon, Feb 19, 2024 at 10:48:26AM +0000, Mark Rutland wrote:
> On Sat, Feb 17, 2024 at 11:03:26PM +0900, skseofh@gmail.com wrote:
> > From: Daero Lee <skseofh@gmail.com>
> > 
> > early_fixmap_init may be called multiple times. Since there is no
> > change in the page table after early fixmap initialization, an
> > initialization flag was added.
> 
> Why is that better?
> 
> We call early_fixmap_init() in two places:
> 
> * early_fdt_map()
> * setup_arch()
> 
> ... and to get to setup_arch() we *must* have gone through early_fdt_map(),
> since __primary_switched() calls that before going to setup_arch().
> 
> So AFAICT we can remove the second call to early_fixmap_init() in setup_arch(),
> and rely on the earlier one in early_fdt_map().

Removing the second call makes the code base a bit harder to understand
as the functions related to DT and ACPI setup are not separated cleanly.
I prefer calling the early_fixmap_init() in setup_arch() as well.

Itaru.

> 
> Mark.
> 
> > 
> > Signed-off-by: Daero Lee <skseofh@gmail.com>
> > ---
> >  arch/arm64/mm/fixmap.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c
> > index c0a3301203bd..fbdd5f30f3a1 100644
> > --- a/arch/arm64/mm/fixmap.c
> > +++ b/arch/arm64/mm/fixmap.c
> > @@ -32,6 +32,8 @@ static pte_t bm_pte[NR_BM_PTE_TABLES][PTRS_PER_PTE] __page_aligned_bss;
> >  static pmd_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss __maybe_unused;
> >  static pud_t bm_pud[PTRS_PER_PUD] __page_aligned_bss __maybe_unused;
> >  
> > +static int early_fixmap_initialized __initdata;
> > +
> >  static inline pte_t *fixmap_pte(unsigned long addr)
> >  {
> >  	return &bm_pte[BM_PTE_TABLE_IDX(addr)][pte_index(addr)];
> > @@ -100,10 +102,15 @@ void __init early_fixmap_init(void)
> >  	unsigned long addr = FIXADDR_TOT_START;
> >  	unsigned long end = FIXADDR_TOP;
> >  
> > +	if (early_fixmap_initialized)
> > +		return;
> > +
> >  	pgd_t *pgdp = pgd_offset_k(addr);
> >  	p4d_t *p4dp = p4d_offset(pgdp, addr);
> >  
> >  	early_fixmap_init_pud(p4dp, addr, end);
> > +
> > +	early_fixmap_initialized = 1;
> >  }
> >  
> >  /*
> > -- 
> > 2.25.1
> > 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Itaru Kitayama <itaru.kitayama@linux.dev>
To: Mark Rutland <mark.rutland@arm.com>
Cc: skseofh@gmail.com, catalin.marinas@arm.com, will@kernel.org,
	ryan.roberts@arm.com, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64: add early fixmap initialization flag
Date: Tue, 20 Feb 2024 09:29:14 +0900	[thread overview]
Message-ID: <ZdPyWkOlUan5AI9r@vm3> (raw)
In-Reply-To: <ZdMx-svsHgrfguxX@FVFF77S0Q05N>

On Mon, Feb 19, 2024 at 10:48:26AM +0000, Mark Rutland wrote:
> On Sat, Feb 17, 2024 at 11:03:26PM +0900, skseofh@gmail.com wrote:
> > From: Daero Lee <skseofh@gmail.com>
> > 
> > early_fixmap_init may be called multiple times. Since there is no
> > change in the page table after early fixmap initialization, an
> > initialization flag was added.
> 
> Why is that better?
> 
> We call early_fixmap_init() in two places:
> 
> * early_fdt_map()
> * setup_arch()
> 
> ... and to get to setup_arch() we *must* have gone through early_fdt_map(),
> since __primary_switched() calls that before going to setup_arch().
> 
> So AFAICT we can remove the second call to early_fixmap_init() in setup_arch(),
> and rely on the earlier one in early_fdt_map().

Removing the second call makes the code base a bit harder to understand
as the functions related to DT and ACPI setup are not separated cleanly.
I prefer calling the early_fixmap_init() in setup_arch() as well.

Itaru.

> 
> Mark.
> 
> > 
> > Signed-off-by: Daero Lee <skseofh@gmail.com>
> > ---
> >  arch/arm64/mm/fixmap.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c
> > index c0a3301203bd..fbdd5f30f3a1 100644
> > --- a/arch/arm64/mm/fixmap.c
> > +++ b/arch/arm64/mm/fixmap.c
> > @@ -32,6 +32,8 @@ static pte_t bm_pte[NR_BM_PTE_TABLES][PTRS_PER_PTE] __page_aligned_bss;
> >  static pmd_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss __maybe_unused;
> >  static pud_t bm_pud[PTRS_PER_PUD] __page_aligned_bss __maybe_unused;
> >  
> > +static int early_fixmap_initialized __initdata;
> > +
> >  static inline pte_t *fixmap_pte(unsigned long addr)
> >  {
> >  	return &bm_pte[BM_PTE_TABLE_IDX(addr)][pte_index(addr)];
> > @@ -100,10 +102,15 @@ void __init early_fixmap_init(void)
> >  	unsigned long addr = FIXADDR_TOT_START;
> >  	unsigned long end = FIXADDR_TOP;
> >  
> > +	if (early_fixmap_initialized)
> > +		return;
> > +
> >  	pgd_t *pgdp = pgd_offset_k(addr);
> >  	p4d_t *p4dp = p4d_offset(pgdp, addr);
> >  
> >  	early_fixmap_init_pud(p4dp, addr, end);
> > +
> > +	early_fixmap_initialized = 1;
> >  }
> >  
> >  /*
> > -- 
> > 2.25.1
> > 

  reply	other threads:[~2024-02-20  0:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-17 14:03 [PATCH] arm64: add early fixmap initialization flag skseofh
2024-02-17 14:03 ` skseofh
2024-02-19 10:48 ` Mark Rutland
2024-02-19 10:48   ` Mark Rutland
2024-02-20  0:29   ` Itaru Kitayama [this message]
2024-02-20  0:29     ` Itaru Kitayama
2024-02-20 11:55     ` Mark Rutland
2024-02-20 11:55       ` Mark Rutland
2024-02-20 23:14       ` Itaru Kitayama
2024-02-20 23:14         ` Itaru Kitayama
2024-02-22 10:59         ` Mark Rutland
2024-02-22 10:59           ` Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZdPyWkOlUan5AI9r@vm3 \
    --to=itaru.kitayama@linux.dev \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ryan.roberts@arm.com \
    --cc=skseofh@gmail.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.