diff mbox series

[08/11] include: sbi: Add domains_init() platform operation

Message ID 20201121094756.4154728-9-anup.patel@wdc.com
State Superseded
Headers show
Series OpenSBI domain configuration using device tree | expand

Commit Message

Anup Patel Nov. 21, 2020, 9:47 a.m. UTC
We introduce domains_init() platform operation which can be used by
platform support to initialize/populate domains in the coldboot path.

The domains_init() is called late in the coldboot sequence from the
sbi_domain_finalize() so sbi_printf() can be used by platform support
to print errors/warings at time of populating domains.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
---
 include/sbi/sbi_platform.h | 16 ++++++++++++++++
 lib/sbi/sbi_domain.c       |  8 ++++++++
 2 files changed, 24 insertions(+)

Comments

Alistair Francis Dec. 3, 2020, 11:38 p.m. UTC | #1
On Sat, 2020-11-21 at 15:17 +0530, Anup Patel wrote:
> We introduce domains_init() platform operation which can be used by
> platform support to initialize/populate domains in the coldboot path.
> 
> The domains_init() is called late in the coldboot sequence from the
> sbi_domain_finalize() so sbi_printf() can be used by platform support
> to print errors/warings at time of populating domains.
> 
> Signed-off-by: Anup Patel <anup.patel@wdc.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  include/sbi/sbi_platform.h | 16 ++++++++++++++++
>  lib/sbi/sbi_domain.c       |  8 ++++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
> index e1355d8..7a8c113 100644
> --- a/include/sbi/sbi_platform.h
> +++ b/include/sbi/sbi_platform.h
> @@ -90,6 +90,8 @@ struct sbi_platform_operations {
>          */
>         int (*misa_get_xlen)(void);
>  
> +       /** Initialize (or populate) domains for the platform */
> +       int (*domains_init)(void);
>         /** Get domain pointer for given HART id */
>         struct sbi_domain *(*domain_get)(u32 hartid);
>  
> @@ -451,6 +453,20 @@ static inline int sbi_platform_misa_xlen(const
> struct sbi_platform *plat)
>         return -1;
>  }
>  
> +/**
> + * Initialize (or populate) domains for the platform
> + *
> + * @param plat pointer to struct sbi_platform
> + *
> + * @return 0 on success and negative error code on failure
> + */
> +static inline int sbi_platform_domains_init(const struct
> sbi_platform *plat)
> +{
> +       if (plat && sbi_platform_ops(plat)->domains_init)
> +               return sbi_platform_ops(plat)->domains_init();
> +       return 0;
> +}
> +
>  /**
>   * Get domain pointer for given HART
>   *
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> index 639e016..1a3651b 100644
> --- a/lib/sbi/sbi_domain.c
> +++ b/lib/sbi/sbi_domain.c
> @@ -375,6 +375,14 @@ int sbi_domain_finalize(struct sbi_scratch
> *scratch, u32 cold_hartid)
>         struct sbi_domain *dom, *tdom;
>         const struct sbi_platform *plat = sbi_platform_ptr(scratch);
>  
> +       /* Initialize domains for the platform */
> +       rc = sbi_platform_domains_init(plat);
> +       if (rc) {
> +               sbi_printf("%s: platform domains_init() failed (error
> %d)\n",
> +                          __func__, rc);
> +               return rc;
> +       }
> +
>         /* Discover domains */
>         for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
>                 /* Ignore invalid HART */
Atish Patra Dec. 4, 2020, 6:27 a.m. UTC | #2
On Sat, Nov 21, 2020 at 2:53 PM Anup Patel <anup.patel@wdc.com> wrote:
>
> We introduce domains_init() platform operation which can be used by
> platform support to initialize/populate domains in the coldboot path.
>
> The domains_init() is called late in the coldboot sequence from the
> sbi_domain_finalize() so sbi_printf() can be used by platform support
> to print errors/warings at time of populating domains.
>

/s/warings/warnings

> Signed-off-by: Anup Patel <anup.patel@wdc.com>
> ---
>  include/sbi/sbi_platform.h | 16 ++++++++++++++++
>  lib/sbi/sbi_domain.c       |  8 ++++++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
> index e1355d8..7a8c113 100644
> --- a/include/sbi/sbi_platform.h
> +++ b/include/sbi/sbi_platform.h
> @@ -90,6 +90,8 @@ struct sbi_platform_operations {
>          */
>         int (*misa_get_xlen)(void);
>
> +       /** Initialize (or populate) domains for the platform */
> +       int (*domains_init)(void);
>         /** Get domain pointer for given HART id */
>         struct sbi_domain *(*domain_get)(u32 hartid);
>
> @@ -451,6 +453,20 @@ static inline int sbi_platform_misa_xlen(const struct sbi_platform *plat)
>         return -1;
>  }
>
> +/**
> + * Initialize (or populate) domains for the platform
> + *
> + * @param plat pointer to struct sbi_platform
> + *
> + * @return 0 on success and negative error code on failure
> + */
> +static inline int sbi_platform_domains_init(const struct sbi_platform *plat)
> +{
> +       if (plat && sbi_platform_ops(plat)->domains_init)
> +               return sbi_platform_ops(plat)->domains_init();
> +       return 0;
> +}
> +
>  /**
>   * Get domain pointer for given HART
>   *
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> index 639e016..1a3651b 100644
> --- a/lib/sbi/sbi_domain.c
> +++ b/lib/sbi/sbi_domain.c
> @@ -375,6 +375,14 @@ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid)
>         struct sbi_domain *dom, *tdom;
>         const struct sbi_platform *plat = sbi_platform_ptr(scratch);
>
> +       /* Initialize domains for the platform */
> +       rc = sbi_platform_domains_init(plat);
> +       if (rc) {
> +               sbi_printf("%s: platform domains_init() failed (error %d)\n",
> +                          __func__, rc);
> +               return rc;
> +       }
> +
>         /* Discover domains */
>         for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
>                 /* Ignore invalid HART */
> --
> 2.25.1
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi

Reviewed-by: Atish Patra <atish.patra@wdc.com>

--
Regards,
Atish
Anup Patel Dec. 4, 2020, 12:35 p.m. UTC | #3
On Fri, Dec 4, 2020 at 11:57 AM Atish Patra <atishp@atishpatra.org> wrote:
>
> On Sat, Nov 21, 2020 at 2:53 PM Anup Patel <anup.patel@wdc.com> wrote:
> >
> > We introduce domains_init() platform operation which can be used by
> > platform support to initialize/populate domains in the coldboot path.
> >
> > The domains_init() is called late in the coldboot sequence from the
> > sbi_domain_finalize() so sbi_printf() can be used by platform support
> > to print errors/warings at time of populating domains.
> >
>
> /s/warings/warnings

Okay, will update.

>
> > Signed-off-by: Anup Patel <anup.patel@wdc.com>
> > ---
> >  include/sbi/sbi_platform.h | 16 ++++++++++++++++
> >  lib/sbi/sbi_domain.c       |  8 ++++++++
> >  2 files changed, 24 insertions(+)
> >
> > diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
> > index e1355d8..7a8c113 100644
> > --- a/include/sbi/sbi_platform.h
> > +++ b/include/sbi/sbi_platform.h
> > @@ -90,6 +90,8 @@ struct sbi_platform_operations {
> >          */
> >         int (*misa_get_xlen)(void);
> >
> > +       /** Initialize (or populate) domains for the platform */
> > +       int (*domains_init)(void);
> >         /** Get domain pointer for given HART id */
> >         struct sbi_domain *(*domain_get)(u32 hartid);
> >
> > @@ -451,6 +453,20 @@ static inline int sbi_platform_misa_xlen(const struct sbi_platform *plat)
> >         return -1;
> >  }
> >
> > +/**
> > + * Initialize (or populate) domains for the platform
> > + *
> > + * @param plat pointer to struct sbi_platform
> > + *
> > + * @return 0 on success and negative error code on failure
> > + */
> > +static inline int sbi_platform_domains_init(const struct sbi_platform *plat)
> > +{
> > +       if (plat && sbi_platform_ops(plat)->domains_init)
> > +               return sbi_platform_ops(plat)->domains_init();
> > +       return 0;
> > +}
> > +
> >  /**
> >   * Get domain pointer for given HART
> >   *
> > diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> > index 639e016..1a3651b 100644
> > --- a/lib/sbi/sbi_domain.c
> > +++ b/lib/sbi/sbi_domain.c
> > @@ -375,6 +375,14 @@ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid)
> >         struct sbi_domain *dom, *tdom;
> >         const struct sbi_platform *plat = sbi_platform_ptr(scratch);
> >
> > +       /* Initialize domains for the platform */
> > +       rc = sbi_platform_domains_init(plat);
> > +       if (rc) {
> > +               sbi_printf("%s: platform domains_init() failed (error %d)\n",
> > +                          __func__, rc);
> > +               return rc;
> > +       }
> > +
> >         /* Discover domains */
> >         for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
> >                 /* Ignore invalid HART */
> > --
> > 2.25.1
> >
> >
> > --
> > opensbi mailing list
> > opensbi@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/opensbi
>
> Reviewed-by: Atish Patra <atish.patra@wdc.com>
>
> --
> Regards,
> Atish

Regards,
Anup
diff mbox series

Patch

diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index e1355d8..7a8c113 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -90,6 +90,8 @@  struct sbi_platform_operations {
 	 */
 	int (*misa_get_xlen)(void);
 
+	/** Initialize (or populate) domains for the platform */
+	int (*domains_init)(void);
 	/** Get domain pointer for given HART id */
 	struct sbi_domain *(*domain_get)(u32 hartid);
 
@@ -451,6 +453,20 @@  static inline int sbi_platform_misa_xlen(const struct sbi_platform *plat)
 	return -1;
 }
 
+/**
+ * Initialize (or populate) domains for the platform
+ *
+ * @param plat pointer to struct sbi_platform
+ *
+ * @return 0 on success and negative error code on failure
+ */
+static inline int sbi_platform_domains_init(const struct sbi_platform *plat)
+{
+	if (plat && sbi_platform_ops(plat)->domains_init)
+		return sbi_platform_ops(plat)->domains_init();
+	return 0;
+}
+
 /**
  * Get domain pointer for given HART
  *
diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
index 639e016..1a3651b 100644
--- a/lib/sbi/sbi_domain.c
+++ b/lib/sbi/sbi_domain.c
@@ -375,6 +375,14 @@  int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid)
 	struct sbi_domain *dom, *tdom;
 	const struct sbi_platform *plat = sbi_platform_ptr(scratch);
 
+	/* Initialize domains for the platform */
+	rc = sbi_platform_domains_init(plat);
+	if (rc) {
+		sbi_printf("%s: platform domains_init() failed (error %d)\n",
+			   __func__, rc);
+		return rc;
+	}
+
 	/* Discover domains */
 	for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {
 		/* Ignore invalid HART */