diff mbox series

[v3,10/15] lib: utils: fdt_fixup: Allow preserving PMU properties

Message ID 20231122073617.379441-11-peterlin@andestech.com
State Changes Requested
Headers show
Series Add Andes PMU extension support | expand

Commit Message

Yu-Chien Peter Lin Nov. 22, 2023, 7:36 a.m. UTC
Add a scratch option to control PMU fixup, so the next
stage software can dump the PMU node including event
mapping information for debugging purposes.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
---
Changes v1 -> v2:
  - New patch
Changes v2 -> v3:
  - Rename to SBI_SCRATCH_PRESERVE_PMU_NODE (suggested by Anup)
  - Include Anup's RB tag
---
 include/sbi/sbi_scratch.h | 2 ++
 lib/utils/fdt/fdt_fixup.c | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Atish Patra Nov. 22, 2023, 11:41 p.m. UTC | #1
On Tue, Nov 21, 2023 at 11:40 PM Yu Chien Peter Lin
<peterlin@andestech.com> wrote:
>
> Add a scratch option to control PMU fixup, so the next
> stage software can dump the PMU node including event
> mapping information for debugging purposes.
>
> Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
> Reviewed-by: Anup Patel <anup@brainfault.org>
> ---
> Changes v1 -> v2:
>   - New patch
> Changes v2 -> v3:
>   - Rename to SBI_SCRATCH_PRESERVE_PMU_NODE (suggested by Anup)
>   - Include Anup's RB tag
> ---
>  include/sbi/sbi_scratch.h | 2 ++
>  lib/utils/fdt/fdt_fixup.c | 6 +++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h
> index e6a33ba..0f67cde 100644
> --- a/include/sbi/sbi_scratch.h
> +++ b/include/sbi/sbi_scratch.h
> @@ -151,6 +151,8 @@ enum sbi_scratch_options {
>         SBI_SCRATCH_NO_BOOT_PRINTS = (1 << 0),
>         /** Enable runtime debug prints */
>         SBI_SCRATCH_DEBUG_PRINTS = (1 << 1),
> +       /** Preserve PMU node properties */
> +       SBI_SCRATCH_PRESERVE_PMU_NODE = (1 << 2),
>  };
>
>  /** Get pointer to sbi_scratch for current HART */
> diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
> index e213ded..cf20edf 100644
> --- a/lib/utils/fdt/fdt_fixup.c
> +++ b/lib/utils/fdt/fdt_fixup.c
> @@ -387,6 +387,8 @@ int fdt_reserved_memory_fixup(void *fdt)
>
>  void fdt_fixups(void *fdt)
>  {
> +       struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
> +
>         fdt_aplic_fixup(fdt);
>
>         fdt_imsic_fixup(fdt);
> @@ -394,5 +396,7 @@ void fdt_fixups(void *fdt)
>         fdt_plic_fixup(fdt);
>
>         fdt_reserved_memory_fixup(fdt);
> -       fdt_pmu_fixup(fdt);
> +
> +       if (!(scratch->options & SBI_SCRATCH_PRESERVE_PMU_NODE))
> +               fdt_pmu_fixup(fdt);
>  }
> --
> 2.34.1
>


Reviewed-by: Atish Patra <atishp@rivosinc.com>
Lad, Prabhakar Nov. 24, 2023, 2:54 p.m. UTC | #2
On Wed, Nov 22, 2023 at 7:41 AM Yu Chien Peter Lin
<peterlin@andestech.com> wrote:
>
> Add a scratch option to control PMU fixup, so the next
> stage software can dump the PMU node including event
> mapping information for debugging purposes.
>
> Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
> Reviewed-by: Anup Patel <anup@brainfault.org>
> ---
> Changes v1 -> v2:
>   - New patch
> Changes v2 -> v3:
>   - Rename to SBI_SCRATCH_PRESERVE_PMU_NODE (suggested by Anup)
>   - Include Anup's RB tag
> ---
>  include/sbi/sbi_scratch.h | 2 ++
>  lib/utils/fdt/fdt_fixup.c | 6 +++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Cheers,
Prabhakar

> diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h
> index e6a33ba..0f67cde 100644
> --- a/include/sbi/sbi_scratch.h
> +++ b/include/sbi/sbi_scratch.h
> @@ -151,6 +151,8 @@ enum sbi_scratch_options {
>         SBI_SCRATCH_NO_BOOT_PRINTS = (1 << 0),
>         /** Enable runtime debug prints */
>         SBI_SCRATCH_DEBUG_PRINTS = (1 << 1),
> +       /** Preserve PMU node properties */
> +       SBI_SCRATCH_PRESERVE_PMU_NODE = (1 << 2),
>  };
>
>  /** Get pointer to sbi_scratch for current HART */
> diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
> index e213ded..cf20edf 100644
> --- a/lib/utils/fdt/fdt_fixup.c
> +++ b/lib/utils/fdt/fdt_fixup.c
> @@ -387,6 +387,8 @@ int fdt_reserved_memory_fixup(void *fdt)
>
>  void fdt_fixups(void *fdt)
>  {
> +       struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
> +
>         fdt_aplic_fixup(fdt);
>
>         fdt_imsic_fixup(fdt);
> @@ -394,5 +396,7 @@ void fdt_fixups(void *fdt)
>         fdt_plic_fixup(fdt);
>
>         fdt_reserved_memory_fixup(fdt);
> -       fdt_pmu_fixup(fdt);
> +
> +       if (!(scratch->options & SBI_SCRATCH_PRESERVE_PMU_NODE))
> +               fdt_pmu_fixup(fdt);
>  }
> --
> 2.34.1
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
Anup Patel Nov. 25, 2023, 4:42 a.m. UTC | #3
On Wed, Nov 22, 2023 at 1:10 PM Yu Chien Peter Lin
<peterlin@andestech.com> wrote:
>
> Add a scratch option to control PMU fixup, so the next
> stage software can dump the PMU node including event
> mapping information for debugging purposes.
>
> Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
> Reviewed-by: Anup Patel <anup@brainfault.org>
> ---
> Changes v1 -> v2:
>   - New patch
> Changes v2 -> v3:
>   - Rename to SBI_SCRATCH_PRESERVE_PMU_NODE (suggested by Anup)
>   - Include Anup's RB tag
> ---
>  include/sbi/sbi_scratch.h | 2 ++
>  lib/utils/fdt/fdt_fixup.c | 6 +++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h
> index e6a33ba..0f67cde 100644
> --- a/include/sbi/sbi_scratch.h
> +++ b/include/sbi/sbi_scratch.h
> @@ -151,6 +151,8 @@ enum sbi_scratch_options {
>         SBI_SCRATCH_NO_BOOT_PRINTS = (1 << 0),
>         /** Enable runtime debug prints */
>         SBI_SCRATCH_DEBUG_PRINTS = (1 << 1),
> +       /** Preserve PMU node properties */
> +       SBI_SCRATCH_PRESERVE_PMU_NODE = (1 << 2),

I have second thoughts about using the scratch option for this.

Let's not waste a bit in the scratch option just for debugging the PMU node.

I suggest adding the kconfig option FDT_FIXUPS_PRESERVE_PMU_NODE
in <opensbi>lib/utils/fdt/Kconfig and use it in fdt_fixups() function.

Regards,
Anup

>  };
>
>  /** Get pointer to sbi_scratch for current HART */
> diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
> index e213ded..cf20edf 100644
> --- a/lib/utils/fdt/fdt_fixup.c
> +++ b/lib/utils/fdt/fdt_fixup.c
> @@ -387,6 +387,8 @@ int fdt_reserved_memory_fixup(void *fdt)
>
>  void fdt_fixups(void *fdt)
>  {
> +       struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
> +
>         fdt_aplic_fixup(fdt);
>
>         fdt_imsic_fixup(fdt);
> @@ -394,5 +396,7 @@ void fdt_fixups(void *fdt)
>         fdt_plic_fixup(fdt);
>
>         fdt_reserved_memory_fixup(fdt);
> -       fdt_pmu_fixup(fdt);
> +
> +       if (!(scratch->options & SBI_SCRATCH_PRESERVE_PMU_NODE))
> +               fdt_pmu_fixup(fdt);
>  }
> --
> 2.34.1
>
Yu-Chien Peter Lin Nov. 28, 2023, 9:57 a.m. UTC | #4
Hi Anup,

On Sat, Nov 25, 2023 at 10:12:06AM +0530, Anup Patel wrote:
> On Wed, Nov 22, 2023 at 1:10 PM Yu Chien Peter Lin
> <peterlin@andestech.com> wrote:
> >
> > Add a scratch option to control PMU fixup, so the next
> > stage software can dump the PMU node including event
> > mapping information for debugging purposes.
> >
> > Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
> > Reviewed-by: Anup Patel <anup@brainfault.org>
> > ---
> > Changes v1 -> v2:
> >   - New patch
> > Changes v2 -> v3:
> >   - Rename to SBI_SCRATCH_PRESERVE_PMU_NODE (suggested by Anup)
> >   - Include Anup's RB tag
> > ---
> >  include/sbi/sbi_scratch.h | 2 ++
> >  lib/utils/fdt/fdt_fixup.c | 6 +++++-
> >  2 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h
> > index e6a33ba..0f67cde 100644
> > --- a/include/sbi/sbi_scratch.h
> > +++ b/include/sbi/sbi_scratch.h
> > @@ -151,6 +151,8 @@ enum sbi_scratch_options {
> >         SBI_SCRATCH_NO_BOOT_PRINTS = (1 << 0),
> >         /** Enable runtime debug prints */
> >         SBI_SCRATCH_DEBUG_PRINTS = (1 << 1),
> > +       /** Preserve PMU node properties */
> > +       SBI_SCRATCH_PRESERVE_PMU_NODE = (1 << 2),
> 
> I have second thoughts about using the scratch option for this.
> 
> Let's not waste a bit in the scratch option just for debugging the PMU node.
> 
> I suggest adding the kconfig option FDT_FIXUPS_PRESERVE_PMU_NODE
> in <opensbi>lib/utils/fdt/Kconfig and use it in fdt_fixups() function.

OK, will do.

Best regards,
Peter Lin

> Regards,
> Anup
> 
> >  };
> >
> >  /** Get pointer to sbi_scratch for current HART */
> > diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
> > index e213ded..cf20edf 100644
> > --- a/lib/utils/fdt/fdt_fixup.c
> > +++ b/lib/utils/fdt/fdt_fixup.c
> > @@ -387,6 +387,8 @@ int fdt_reserved_memory_fixup(void *fdt)
> >
> >  void fdt_fixups(void *fdt)
> >  {
> > +       struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
> > +
> >         fdt_aplic_fixup(fdt);
> >
> >         fdt_imsic_fixup(fdt);
> > @@ -394,5 +396,7 @@ void fdt_fixups(void *fdt)
> >         fdt_plic_fixup(fdt);
> >
> >         fdt_reserved_memory_fixup(fdt);
> > -       fdt_pmu_fixup(fdt);
> > +
> > +       if (!(scratch->options & SBI_SCRATCH_PRESERVE_PMU_NODE))
> > +               fdt_pmu_fixup(fdt);
> >  }
> > --
> > 2.34.1
> >
diff mbox series

Patch

diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h
index e6a33ba..0f67cde 100644
--- a/include/sbi/sbi_scratch.h
+++ b/include/sbi/sbi_scratch.h
@@ -151,6 +151,8 @@  enum sbi_scratch_options {
 	SBI_SCRATCH_NO_BOOT_PRINTS = (1 << 0),
 	/** Enable runtime debug prints */
 	SBI_SCRATCH_DEBUG_PRINTS = (1 << 1),
+	/** Preserve PMU node properties */
+	SBI_SCRATCH_PRESERVE_PMU_NODE = (1 << 2),
 };
 
 /** Get pointer to sbi_scratch for current HART */
diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
index e213ded..cf20edf 100644
--- a/lib/utils/fdt/fdt_fixup.c
+++ b/lib/utils/fdt/fdt_fixup.c
@@ -387,6 +387,8 @@  int fdt_reserved_memory_fixup(void *fdt)
 
 void fdt_fixups(void *fdt)
 {
+	struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
+
 	fdt_aplic_fixup(fdt);
 
 	fdt_imsic_fixup(fdt);
@@ -394,5 +396,7 @@  void fdt_fixups(void *fdt)
 	fdt_plic_fixup(fdt);
 
 	fdt_reserved_memory_fixup(fdt);
-	fdt_pmu_fixup(fdt);
+
+	if (!(scratch->options & SBI_SCRATCH_PRESERVE_PMU_NODE))
+		fdt_pmu_fixup(fdt);
 }