diff mbox series

[U-Boot,v2,5/7] bootcount: spl: Extend SPL to support bootcount incrementation

Message ID 20180314172450.8385-6-lukma@denx.de
State Changes Requested
Delegated to: Stefan Roese
Headers show
Series Provide SPL support for bootcount (in the case of using falcon boot mode) | expand

Commit Message

Lukasz Majewski March 14, 2018, 5:24 p.m. UTC
This patch adds support for incrementation of the bootcount in SPL.
Such feature is necessary when we do want to use this feature with
'falcon' boot mode (which loads OS directly in SPL).

Signed-off-by: Lukasz Majewski <lukma@denx.de>

---

Changes in v2:
- New patch - as suggested by Stefan Roese - bootcount_inc() is called
  in common SPL code (./common/spl/spl.c), so other boards can also
  reuse it without modification

 common/spl/spl.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Stefan Roese March 21, 2018, 10:20 a.m. UTC | #1
> Lukasz Majewski <lukma@denx.de> hat am 14. März 2018 um 18:24 geschrieben:
> 
> 
> This patch adds support for incrementation of the bootcount in SPL.
> Such feature is necessary when we do want to use this feature with
> 'falcon' boot mode (which loads OS directly in SPL).
> 
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> 
> ---
> 
> Changes in v2:
> - New patch - as suggested by Stefan Roese - bootcount_inc() is called
>   in common SPL code (./common/spl/spl.c), so other boards can also
>   reuse it without modification
> 
>  common/spl/spl.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index b1ce56d0d0..01e7989869 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -20,6 +20,9 @@
>  #include <dm/root.h>
>  #include <linux/compiler.h>
>  #include <fdt_support.h>
> +#ifdef CONFIG_SPL_BOOTCOUNT_LIMIT
> +#include <bootcount.h>
> +#endif

Is this #ifdef necessary? If not, please remove it. 

>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -411,6 +414,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>  	spl_board_init();
>  #endif
>  
> +#ifdef CONFIG_SPL_BOOTCOUNT_LIMIT
> +	bootcount_inc();
> +#endif
> +

I think you can remove this #ifdef as well here. You have the
#ifdef in the header already.

Thanks,
Stefan
Lukasz Majewski March 21, 2018, 11:31 a.m. UTC | #2
Hi Stefan,

> > Lukasz Majewski <lukma@denx.de> hat am 14. März 2018 um 18:24
> > geschrieben:
> > 
> > 
> > This patch adds support for incrementation of the bootcount in SPL.
> > Such feature is necessary when we do want to use this feature with
> > 'falcon' boot mode (which loads OS directly in SPL).
> > 
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > 
> > ---
> > 
> > Changes in v2:
> > - New patch - as suggested by Stefan Roese - bootcount_inc() is
> > called in common SPL code (./common/spl/spl.c), so other boards can
> > also reuse it without modification
> > 
> >  common/spl/spl.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/common/spl/spl.c b/common/spl/spl.c
> > index b1ce56d0d0..01e7989869 100644
> > --- a/common/spl/spl.c
> > +++ b/common/spl/spl.c
> > @@ -20,6 +20,9 @@
> >  #include <dm/root.h>
> >  #include <linux/compiler.h>
> >  #include <fdt_support.h>
> > +#ifdef CONFIG_SPL_BOOTCOUNT_LIMIT
> > +#include <bootcount.h>
> > +#endif  
> 
> Is this #ifdef necessary? If not, please remove it. 

The problem is that after removing those #ifdefs I do have SPL build
breaks on .... x86 arch.

It seems like some kind of non-trival dependency introduced in generic
bootcount.h u-boot file.

I even thought about introducing new file - like bootcount_spl.h

> 
> >  
> >  DECLARE_GLOBAL_DATA_PTR;
> >  
> > @@ -411,6 +414,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
> >  	spl_board_init();
> >  #endif
> >  
> > +#ifdef CONFIG_SPL_BOOTCOUNT_LIMIT
> > +	bootcount_inc();
> > +#endif
> > +  
> 
> I think you can remove this #ifdef as well here. You have the
> #ifdef in the header already.

Yes, it can be removed.

> 
> Thanks,
> Stefan




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
diff mbox series

Patch

diff --git a/common/spl/spl.c b/common/spl/spl.c
index b1ce56d0d0..01e7989869 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -20,6 +20,9 @@ 
 #include <dm/root.h>
 #include <linux/compiler.h>
 #include <fdt_support.h>
+#ifdef CONFIG_SPL_BOOTCOUNT_LIMIT
+#include <bootcount.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -411,6 +414,10 @@  void board_init_r(gd_t *dummy1, ulong dummy2)
 	spl_board_init();
 #endif
 
+#ifdef CONFIG_SPL_BOOTCOUNT_LIMIT
+	bootcount_inc();
+#endif
+
 	memset(&spl_image, '\0', sizeof(spl_image));
 #ifdef CONFIG_SYS_SPL_ARGS_ADDR
 	spl_image.arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR;