All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhiqiang Hou <zhiqiang.hou@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] ARMv8/layerscape: Add mmu_init API
Date: Wed, 20 Jan 2016 12:05:34 +0000	[thread overview]
Message-ID: <HE1PR04MB090605F675D57DC8BB8B04EB84C20@HE1PR04MB0906.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <VI1PR04MB11366D546C5C13B2E480485897C10@VI1PR04MB1136.eurprd04.prod.outlook.com>

Hi Prabhakar,

Thanks for your feedback!

> -----Original Message-----
> From: Prabhakar Kushwaha
> Sent: 2016?1?19? 21:54
> To: Zhiqiang Hou <Zhiqiang.Hou@freescale.com>; u-boot at lists.denx.de;
> albert.u.boot at aribaud.net; Mingkai.hu at freescale.com; yorksun at freescale.com
> Cc: leoli at freescale.com; prabhakar at freescale.com;
> bhupesh.sharma at freescale.com; sjg at chromium.org; bmeng.cn at gmail.com;
> hs at denx.de; joe.hershberger at ni.com; marex at denx.de; Zhiqiang Hou
> <zhiqiang.hou@nxp.com>; Hou Zhiqiang <B48286@freescale.com>
> Subject: RE: [PATCH 1/3] ARMv8/layerscape: Add mmu_init API
> 
> > -----Original Message-----
> > From: Zhiqiang Hou [mailto:Zhiqiang.Hou at freescale.com]
> > Sent: Tuesday, January 19, 2016 6:10 PM
> > To: u-boot at lists.denx.de; albert.u.boot at aribaud.net;
> > Mingkai.hu at freescale.com; yorksun at freescale.com
> > Cc: leoli at freescale.com; prabhakar at freescale.com;
> > bhupesh.sharma at freescale.com; sjg at chromium.org; bmeng.cn at gmail.com;
> > hs at denx.de; joe.hershberger at ni.com; marex at denx.de; Zhiqiang Hou
> > <zhiqiang.hou@nxp.com>; Hou Zhiqiang <B48286@freescale.com>
> > Subject: [PATCH 1/3] ARMv8/layerscape: Add mmu_init API
> >
> > From: Hou Zhiqiang <B48286@freescale.com>
> >
> > Expose this API to make it reuseable when u-boot turn into other EL
> > from EL3.
> >
> > Signed-off-by: Hou Zhiqiang <B48286@freescale.com>
> > ---
> >  arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 24
> > ++++++++++++++++++++++++
> >  include/common.h                        |  1 +
> >  2 files changed, 25 insertions(+)
> >
> > diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> > b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> > index 6ea28ed..df5670f 100644
> > --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> > +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> > @@ -403,6 +403,30 @@ void enable_caches(void)
> >  	final_mmu_setup();
> >  	__asm_invalidate_tlb_all();
> >  }
> > +
> > +static void mmu_disable(void)
> > +{
> > +	if (get_sctlr() & CR_M)
> > +		set_sctlr(get_sctlr() & ~CR_M);
> > +}
> > +
> > +static void mmu_enable(void)
> > +{
> > +	if (!(get_sctlr() & CR_M))
> > +		set_sctlr(get_sctlr() | CR_M);
> > +}
> > +
> > +void mmu_init(void)
> 
> Name of function is not mapping about what it is doing.
> This function assume MMU is already enabled with early_table and it will setup
> final_mmu_setup.
> 

This function map basically with what it is doing except some I-cache operations
that will be remove from this func, and not assume the early_mmu_setup.
It assumes the relocation has been done. 

> > +{
> > +	mmu_disable();
> > +	dcache_disable();
> > +	icache_disable();
> > +	final_mmu_setup();
> > +	__asm_invalidate_tlb_all();
> > +	mmu_enable();
> > +	icache_enable();
> > +	set_sctlr(get_sctlr() | CR_C);
> > +}
> >  #endif
> 
> If I am correct board_init_r deploy final_mmu_setup via enable_caches().
> Why cannot existing framework be used.
> 

This patch aims to make final_mmu_setup() can be called flexibly in case as
When it return from PPA and execute at EL2, the MMU must be initialized
for the current EL.
Yes, the enable_caches() will call the __weak__ mmu_setup() if MMU wasn't
enabled. But for fsl layerscape platforms, the MMU has been enabled by early
mmu setup, so the __weak__ mmu_setup won't be called.

I am not know cache and mmu so much, and have some question:
For ARM:
Why there isn't a isolate API for mmu_setup, but invoke it from dcache_enable()?
If data cache won't be used, the MMU also cannot be used?

> >
> >  static inline u32 initiator_type(u32 cluster, int init_id) diff --git
> > a/include/common.h b/include/common.h index 75c78d5..57a9b30 100644
> > --- a/include/common.h
> > +++ b/include/common.h
> > @@ -757,6 +757,7 @@ void	flush_dcache_range(unsigned long start,
> > unsigned long stop);
> >  void	invalidate_dcache_range(unsigned long start, unsigned long stop);
> >  void	invalidate_dcache_all(void);
> >  void	invalidate_icache_all(void);
> > +void	mmu_init(void);
> >
> >  enum {
> >  	/* Disable caches (else flush caches but leave them active) */
> > --
> > 2.1.0.27.g96db324

Thanks,
Zhiqiang

  reply	other threads:[~2016-01-20 12:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 12:39 [U-Boot] [PATCH 1/3] ARMv8/layerscape: Add mmu_init API Zhiqiang Hou
2016-01-19 12:39 ` [U-Boot] [PATCH 2/3] ARMv8/layerscape: Add FSL PPA support Zhiqiang Hou
2016-01-19 14:07   ` Prabhakar Kushwaha
2016-01-20  8:41     ` Zhiqiang Hou
2016-01-19 12:39 ` [U-Boot] [PATCH 3/3] ARMv8/ls1043ardb: Integrate FSL PPA Zhiqiang Hou
2016-01-19 13:54 ` [U-Boot] [PATCH 1/3] ARMv8/layerscape: Add mmu_init API Prabhakar Kushwaha
2016-01-20 12:05   ` Zhiqiang Hou [this message]
2016-01-20 15:54     ` york sun
2016-01-21  1:10       ` Zhiqiang Hou

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=HE1PR04MB090605F675D57DC8BB8B04EB84C20@HE1PR04MB0906.eurprd04.prod.outlook.com \
    --to=zhiqiang.hou@nxp.com \
    --cc=u-boot@lists.denx.de \
    /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.