diff mbox series

[2/2] lib: utils: Try other FDT drivers when we see SBI_ENODEV

Message ID 20210520155912.1336836-3-anup.patel@wdc.com
State Accepted
Headers show
Series Few misc fixes | expand

Commit Message

Anup Patel May 20, 2021, 3:59 p.m. UTC
We should try other FDT drivers when we see SBI_ENODEV returned
by cold_init() of FDT driver.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
---
 lib/utils/ipi/fdt_ipi.c         | 3 +++
 lib/utils/irqchip/fdt_irqchip.c | 3 +++
 lib/utils/reset/fdt_reset.c     | 3 +++
 lib/utils/serial/fdt_serial.c   | 5 +++++
 lib/utils/timer/fdt_timer.c     | 3 +++
 5 files changed, 17 insertions(+)

Comments

Atish Patra May 21, 2021, 5:33 a.m. UTC | #1
On Thu, May 20, 2021 at 9:01 AM Anup Patel <anup.patel@wdc.com> wrote:
>
> We should try other FDT drivers when we see SBI_ENODEV returned
> by cold_init() of FDT driver.
>
> Signed-off-by: Anup Patel <anup.patel@wdc.com>
> ---
>  lib/utils/ipi/fdt_ipi.c         | 3 +++
>  lib/utils/irqchip/fdt_irqchip.c | 3 +++
>  lib/utils/reset/fdt_reset.c     | 3 +++
>  lib/utils/serial/fdt_serial.c   | 5 +++++
>  lib/utils/timer/fdt_timer.c     | 3 +++
>  5 files changed, 17 insertions(+)
>
> diff --git a/lib/utils/ipi/fdt_ipi.c b/lib/utils/ipi/fdt_ipi.c
> index efca37e..3932f50 100644
> --- a/lib/utils/ipi/fdt_ipi.c
> +++ b/lib/utils/ipi/fdt_ipi.c
> @@ -7,6 +7,7 @@
>   *   Anup Patel <anup.patel@wdc.com>
>   */
>
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/ipi/fdt_ipi.h>
> @@ -54,6 +55,8 @@ static int fdt_ipi_cold_init(void)
>                                         drv->match_table, &match)) >= 0) {
>                         if (drv->cold_init) {
>                                 rc = drv->cold_init(fdt, noff, match);
> +                               if (rc == SBI_ENODEV)
> +                                       continue;
>                                 if (rc)
>                                         return rc;
>                         }
> diff --git a/lib/utils/irqchip/fdt_irqchip.c b/lib/utils/irqchip/fdt_irqchip.c
> index 3630be6..1306d50 100644
> --- a/lib/utils/irqchip/fdt_irqchip.c
> +++ b/lib/utils/irqchip/fdt_irqchip.c
> @@ -7,6 +7,7 @@
>   *   Anup Patel <anup.patel@wdc.com>
>   */
>
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/irqchip/fdt_irqchip.h>
> @@ -47,6 +48,8 @@ static int fdt_irqchip_cold_init(void)
>                                         drv->match_table, &match)) >= 0) {
>                         if (drv->cold_init) {
>                                 rc = drv->cold_init(fdt, noff, match);
> +                               if (rc == SBI_ENODEV)
> +                                       continue;
>                                 if (rc)
>                                         return rc;
>                         }
> diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c
> index b01b0d1..1d687dc 100644
> --- a/lib/utils/reset/fdt_reset.c
> +++ b/lib/utils/reset/fdt_reset.c
> @@ -7,6 +7,7 @@
>   *   Anup Patel <anup.patel@wdc.com>
>   */
>
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/reset/fdt_reset.h>
> @@ -39,6 +40,8 @@ int fdt_reset_init(void)
>
>                 if (drv->init) {
>                         rc = drv->init(fdt, noff, match);
> +                       if (rc == SBI_ENODEV)
> +                               continue;
>                         if (rc)
>                                 return rc;
>                 }
> diff --git a/lib/utils/serial/fdt_serial.c b/lib/utils/serial/fdt_serial.c
> index bad3387..25982ec 100644
> --- a/lib/utils/serial/fdt_serial.c
> +++ b/lib/utils/serial/fdt_serial.c
> @@ -8,6 +8,7 @@
>   */
>
>  #include <libfdt.h>
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/serial/fdt_serial.h>
> @@ -59,6 +60,8 @@ int fdt_serial_init(void)
>
>                 if (drv->init) {
>                         rc = drv->init(fdt, noff, match);
> +                       if (rc == SBI_ENODEV)
> +                               continue;
>                         if (rc)
>                                 return rc;
>                 }
> @@ -80,6 +83,8 @@ int fdt_serial_init(void)
>
>                 if (drv->init) {
>                         rc = drv->init(fdt, noff, match);
> +                       if (rc == SBI_ENODEV)
> +                               continue;
>                         if (rc)
>                                 return rc;
>                 }
> diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c
> index 92198cd..1fad42c 100644
> --- a/lib/utils/timer/fdt_timer.c
> +++ b/lib/utils/timer/fdt_timer.c
> @@ -7,6 +7,7 @@
>   *   Anup Patel <anup.patel@wdc.com>
>   */
>
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/timer/fdt_timer.h>
> @@ -54,6 +55,8 @@ static int fdt_timer_cold_init(void)
>                                         drv->match_table, &match)) >= 0) {
>                         if (drv->cold_init) {
>                                 rc = drv->cold_init(fdt, noff, match);
> +                               if (rc == SBI_ENODEV)
> +                                       continue;
>                                 if (rc)
>                                         return rc;
>                         }
> --
> 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>
Xiang W May 21, 2021, 6:39 a.m. UTC | #2
在 2021-05-20四的 21:29 +0530,Anup Patel写道:
> We should try other FDT drivers when we see SBI_ENODEV returned
> by cold_init() of FDT driver.
> 
> Signed-off-by: Anup Patel <anup.patel@wdc.com>

Reviewed-by: Xiang W <wxjstz@126.com>

> ---
>  lib/utils/ipi/fdt_ipi.c         | 3 +++
>  lib/utils/irqchip/fdt_irqchip.c | 3 +++
>  lib/utils/reset/fdt_reset.c     | 3 +++
>  lib/utils/serial/fdt_serial.c   | 5 +++++
>  lib/utils/timer/fdt_timer.c     | 3 +++
>  5 files changed, 17 insertions(+)
> 
> diff --git a/lib/utils/ipi/fdt_ipi.c b/lib/utils/ipi/fdt_ipi.c
> index efca37e..3932f50 100644
> --- a/lib/utils/ipi/fdt_ipi.c
> +++ b/lib/utils/ipi/fdt_ipi.c
> @@ -7,6 +7,7 @@
>   *   Anup Patel <anup.patel@wdc.com>
>   */
>  
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/ipi/fdt_ipi.h>
> @@ -54,6 +55,8 @@ static int fdt_ipi_cold_init(void)
>  					drv->match_table, &match)) >=
> 0) {
>  			if (drv->cold_init) {
>  				rc = drv->cold_init(fdt, noff, match);
> +				if (rc == SBI_ENODEV)
> +					continue;
>  				if (rc)
>  					return rc;
>  			}
> diff --git a/lib/utils/irqchip/fdt_irqchip.c
> b/lib/utils/irqchip/fdt_irqchip.c
> index 3630be6..1306d50 100644
> --- a/lib/utils/irqchip/fdt_irqchip.c
> +++ b/lib/utils/irqchip/fdt_irqchip.c
> @@ -7,6 +7,7 @@
>   *   Anup Patel <anup.patel@wdc.com>
>   */
>  
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/irqchip/fdt_irqchip.h>
> @@ -47,6 +48,8 @@ static int fdt_irqchip_cold_init(void)
>  					drv->match_table, &match)) >=
> 0) {
>  			if (drv->cold_init) {
>  				rc = drv->cold_init(fdt, noff, match);
> +				if (rc == SBI_ENODEV)
> +					continue;
>  				if (rc)
>  					return rc;
>  			}
> diff --git a/lib/utils/reset/fdt_reset.c
> b/lib/utils/reset/fdt_reset.c
> index b01b0d1..1d687dc 100644
> --- a/lib/utils/reset/fdt_reset.c
> +++ b/lib/utils/reset/fdt_reset.c
> @@ -7,6 +7,7 @@
>   *   Anup Patel <anup.patel@wdc.com>
>   */
>  
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/reset/fdt_reset.h>
> @@ -39,6 +40,8 @@ int fdt_reset_init(void)
>  
>  		if (drv->init) {
>  			rc = drv->init(fdt, noff, match);
> +			if (rc == SBI_ENODEV)
> +				continue;
>  			if (rc)
>  				return rc;
>  		}
> diff --git a/lib/utils/serial/fdt_serial.c
> b/lib/utils/serial/fdt_serial.c
> index bad3387..25982ec 100644
> --- a/lib/utils/serial/fdt_serial.c
> +++ b/lib/utils/serial/fdt_serial.c
> @@ -8,6 +8,7 @@
>   */
>  
>  #include <libfdt.h>
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/serial/fdt_serial.h>
> @@ -59,6 +60,8 @@ int fdt_serial_init(void)
>  
>  		if (drv->init) {
>  			rc = drv->init(fdt, noff, match);
> +			if (rc == SBI_ENODEV)
> +				continue;
>  			if (rc)
>  				return rc;
>  		}
> @@ -80,6 +83,8 @@ int fdt_serial_init(void)
>  
>  		if (drv->init) {
>  			rc = drv->init(fdt, noff, match);
> +			if (rc == SBI_ENODEV)
> +				continue;
>  			if (rc)
>  				return rc;
>  		}
> diff --git a/lib/utils/timer/fdt_timer.c
> b/lib/utils/timer/fdt_timer.c
> index 92198cd..1fad42c 100644
> --- a/lib/utils/timer/fdt_timer.c
> +++ b/lib/utils/timer/fdt_timer.c
> @@ -7,6 +7,7 @@
>   *   Anup Patel <anup.patel@wdc.com>
>   */
>  
> +#include <sbi/sbi_error.h>
>  #include <sbi/sbi_scratch.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/timer/fdt_timer.h>
> @@ -54,6 +55,8 @@ static int fdt_timer_cold_init(void)
>  					drv->match_table, &match)) >=
> 0) {
>  			if (drv->cold_init) {
>  				rc = drv->cold_init(fdt, noff, match);
> +				if (rc == SBI_ENODEV)
> +					continue;
>  				if (rc)
>  					return rc;
>  			}
> -- 
> 2.25.1
> 
>
Anup Patel May 24, 2021, 11:26 a.m. UTC | #3
> -----Original Message-----
> From: Xiang W <wxjstz@126.com>
> Sent: 21 May 2021 12:09
> To: Anup Patel <Anup.Patel@wdc.com>; Atish Patra <Atish.Patra@wdc.com>;
> Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Anup Patel <anup@brainfault.org>; opensbi@lists.infradead.org
> Subject: Re: [PATCH 2/2] lib: utils: Try other FDT drivers when we see
> SBI_ENODEV
> 
> 在 2021-05-20四的 21:29 +0530,Anup Patel写道:
> > We should try other FDT drivers when we see SBI_ENODEV returned by
> > cold_init() of FDT driver.
> >
> > Signed-off-by: Anup Patel <anup.patel@wdc.com>
> 
> Reviewed-by: Xiang W <wxjstz@126.com>

Applied this patch to the riscv/opensbi repo

Regards,
Anup

> 
> > ---
> >  lib/utils/ipi/fdt_ipi.c         | 3 +++
> >  lib/utils/irqchip/fdt_irqchip.c | 3 +++
> >  lib/utils/reset/fdt_reset.c     | 3 +++
> >  lib/utils/serial/fdt_serial.c   | 5 +++++
> >  lib/utils/timer/fdt_timer.c     | 3 +++
> >  5 files changed, 17 insertions(+)
> >
> > diff --git a/lib/utils/ipi/fdt_ipi.c b/lib/utils/ipi/fdt_ipi.c index
> > efca37e..3932f50 100644
> > --- a/lib/utils/ipi/fdt_ipi.c
> > +++ b/lib/utils/ipi/fdt_ipi.c
> > @@ -7,6 +7,7 @@
> >   *   Anup Patel <anup.patel@wdc.com>
> >   */
> >
> > +#include <sbi/sbi_error.h>
> >  #include <sbi/sbi_scratch.h>
> >  #include <sbi_utils/fdt/fdt_helper.h>  #include
> > <sbi_utils/ipi/fdt_ipi.h> @@ -54,6 +55,8 @@ static int
> > fdt_ipi_cold_init(void)
> >  					drv->match_table, &match)) >=
> > 0) {
> >  			if (drv->cold_init) {
> >  				rc = drv->cold_init(fdt, noff, match);
> > +				if (rc == SBI_ENODEV)
> > +					continue;
> >  				if (rc)
> >  					return rc;
> >  			}
> > diff --git a/lib/utils/irqchip/fdt_irqchip.c
> > b/lib/utils/irqchip/fdt_irqchip.c index 3630be6..1306d50 100644
> > --- a/lib/utils/irqchip/fdt_irqchip.c
> > +++ b/lib/utils/irqchip/fdt_irqchip.c
> > @@ -7,6 +7,7 @@
> >   *   Anup Patel <anup.patel@wdc.com>
> >   */
> >
> > +#include <sbi/sbi_error.h>
> >  #include <sbi/sbi_scratch.h>
> >  #include <sbi_utils/fdt/fdt_helper.h>  #include
> > <sbi_utils/irqchip/fdt_irqchip.h> @@ -47,6 +48,8 @@ static int
> > fdt_irqchip_cold_init(void)
> >  					drv->match_table, &match)) >=
> > 0) {
> >  			if (drv->cold_init) {
> >  				rc = drv->cold_init(fdt, noff, match);
> > +				if (rc == SBI_ENODEV)
> > +					continue;
> >  				if (rc)
> >  					return rc;
> >  			}
> > diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c
> > index b01b0d1..1d687dc 100644
> > --- a/lib/utils/reset/fdt_reset.c
> > +++ b/lib/utils/reset/fdt_reset.c
> > @@ -7,6 +7,7 @@
> >   *   Anup Patel <anup.patel@wdc.com>
> >   */
> >
> > +#include <sbi/sbi_error.h>
> >  #include <sbi/sbi_scratch.h>
> >  #include <sbi_utils/fdt/fdt_helper.h>  #include
> > <sbi_utils/reset/fdt_reset.h> @@ -39,6 +40,8 @@ int
> > fdt_reset_init(void)
> >
> >  		if (drv->init) {
> >  			rc = drv->init(fdt, noff, match);
> > +			if (rc == SBI_ENODEV)
> > +				continue;
> >  			if (rc)
> >  				return rc;
> >  		}
> > diff --git a/lib/utils/serial/fdt_serial.c
> > b/lib/utils/serial/fdt_serial.c index bad3387..25982ec 100644
> > --- a/lib/utils/serial/fdt_serial.c
> > +++ b/lib/utils/serial/fdt_serial.c
> > @@ -8,6 +8,7 @@
> >   */
> >
> >  #include <libfdt.h>
> > +#include <sbi/sbi_error.h>
> >  #include <sbi/sbi_scratch.h>
> >  #include <sbi_utils/fdt/fdt_helper.h>  #include
> > <sbi_utils/serial/fdt_serial.h> @@ -59,6 +60,8 @@ int
> > fdt_serial_init(void)
> >
> >  		if (drv->init) {
> >  			rc = drv->init(fdt, noff, match);
> > +			if (rc == SBI_ENODEV)
> > +				continue;
> >  			if (rc)
> >  				return rc;
> >  		}
> > @@ -80,6 +83,8 @@ int fdt_serial_init(void)
> >
> >  		if (drv->init) {
> >  			rc = drv->init(fdt, noff, match);
> > +			if (rc == SBI_ENODEV)
> > +				continue;
> >  			if (rc)
> >  				return rc;
> >  		}
> > diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c
> > index 92198cd..1fad42c 100644
> > --- a/lib/utils/timer/fdt_timer.c
> > +++ b/lib/utils/timer/fdt_timer.c
> > @@ -7,6 +7,7 @@
> >   *   Anup Patel <anup.patel@wdc.com>
> >   */
> >
> > +#include <sbi/sbi_error.h>
> >  #include <sbi/sbi_scratch.h>
> >  #include <sbi_utils/fdt/fdt_helper.h>  #include
> > <sbi_utils/timer/fdt_timer.h> @@ -54,6 +55,8 @@ static int
> > fdt_timer_cold_init(void)
> >  					drv->match_table, &match)) >=
> > 0) {
> >  			if (drv->cold_init) {
> >  				rc = drv->cold_init(fdt, noff, match);
> > +				if (rc == SBI_ENODEV)
> > +					continue;
> >  				if (rc)
> >  					return rc;
> >  			}
> > --
> > 2.25.1
> >
> >
diff mbox series

Patch

diff --git a/lib/utils/ipi/fdt_ipi.c b/lib/utils/ipi/fdt_ipi.c
index efca37e..3932f50 100644
--- a/lib/utils/ipi/fdt_ipi.c
+++ b/lib/utils/ipi/fdt_ipi.c
@@ -7,6 +7,7 @@ 
  *   Anup Patel <anup.patel@wdc.com>
  */
 
+#include <sbi/sbi_error.h>
 #include <sbi/sbi_scratch.h>
 #include <sbi_utils/fdt/fdt_helper.h>
 #include <sbi_utils/ipi/fdt_ipi.h>
@@ -54,6 +55,8 @@  static int fdt_ipi_cold_init(void)
 					drv->match_table, &match)) >= 0) {
 			if (drv->cold_init) {
 				rc = drv->cold_init(fdt, noff, match);
+				if (rc == SBI_ENODEV)
+					continue;
 				if (rc)
 					return rc;
 			}
diff --git a/lib/utils/irqchip/fdt_irqchip.c b/lib/utils/irqchip/fdt_irqchip.c
index 3630be6..1306d50 100644
--- a/lib/utils/irqchip/fdt_irqchip.c
+++ b/lib/utils/irqchip/fdt_irqchip.c
@@ -7,6 +7,7 @@ 
  *   Anup Patel <anup.patel@wdc.com>
  */
 
+#include <sbi/sbi_error.h>
 #include <sbi/sbi_scratch.h>
 #include <sbi_utils/fdt/fdt_helper.h>
 #include <sbi_utils/irqchip/fdt_irqchip.h>
@@ -47,6 +48,8 @@  static int fdt_irqchip_cold_init(void)
 					drv->match_table, &match)) >= 0) {
 			if (drv->cold_init) {
 				rc = drv->cold_init(fdt, noff, match);
+				if (rc == SBI_ENODEV)
+					continue;
 				if (rc)
 					return rc;
 			}
diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c
index b01b0d1..1d687dc 100644
--- a/lib/utils/reset/fdt_reset.c
+++ b/lib/utils/reset/fdt_reset.c
@@ -7,6 +7,7 @@ 
  *   Anup Patel <anup.patel@wdc.com>
  */
 
+#include <sbi/sbi_error.h>
 #include <sbi/sbi_scratch.h>
 #include <sbi_utils/fdt/fdt_helper.h>
 #include <sbi_utils/reset/fdt_reset.h>
@@ -39,6 +40,8 @@  int fdt_reset_init(void)
 
 		if (drv->init) {
 			rc = drv->init(fdt, noff, match);
+			if (rc == SBI_ENODEV)
+				continue;
 			if (rc)
 				return rc;
 		}
diff --git a/lib/utils/serial/fdt_serial.c b/lib/utils/serial/fdt_serial.c
index bad3387..25982ec 100644
--- a/lib/utils/serial/fdt_serial.c
+++ b/lib/utils/serial/fdt_serial.c
@@ -8,6 +8,7 @@ 
  */
 
 #include <libfdt.h>
+#include <sbi/sbi_error.h>
 #include <sbi/sbi_scratch.h>
 #include <sbi_utils/fdt/fdt_helper.h>
 #include <sbi_utils/serial/fdt_serial.h>
@@ -59,6 +60,8 @@  int fdt_serial_init(void)
 
 		if (drv->init) {
 			rc = drv->init(fdt, noff, match);
+			if (rc == SBI_ENODEV)
+				continue;
 			if (rc)
 				return rc;
 		}
@@ -80,6 +83,8 @@  int fdt_serial_init(void)
 
 		if (drv->init) {
 			rc = drv->init(fdt, noff, match);
+			if (rc == SBI_ENODEV)
+				continue;
 			if (rc)
 				return rc;
 		}
diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c
index 92198cd..1fad42c 100644
--- a/lib/utils/timer/fdt_timer.c
+++ b/lib/utils/timer/fdt_timer.c
@@ -7,6 +7,7 @@ 
  *   Anup Patel <anup.patel@wdc.com>
  */
 
+#include <sbi/sbi_error.h>
 #include <sbi/sbi_scratch.h>
 #include <sbi_utils/fdt/fdt_helper.h>
 #include <sbi_utils/timer/fdt_timer.h>
@@ -54,6 +55,8 @@  static int fdt_timer_cold_init(void)
 					drv->match_table, &match)) >= 0) {
 			if (drv->cold_init) {
 				rc = drv->cold_init(fdt, noff, match);
+				if (rc == SBI_ENODEV)
+					continue;
 				if (rc)
 					return rc;
 			}