diff mbox

[U-Boot,v2] ubi: enable error reporting in initialization

Message ID 1415215917-9149-1-git-send-email-andrew.ruder@elecsyscorp.com
State Awaiting Upstream
Delegated to: Heiko Schocher
Headers show

Commit Message

Andrew Ruder Nov. 5, 2014, 7:31 p.m. UTC
The UBI layer will disable much of its error reporting when it is
compiled into the linux kernel to avoid stopping boot.  We want this
error reporting in U-Boot since we don't initialize the UBI layer until
it is used and want the error reporting.

We force this by telling the UBI layer we are building as a module.

Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Kyungmin Park <kmpark@infradead.org>
---
 include/ubi_uboot.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Hector Palacios Dec. 17, 2014, 5:48 p.m. UTC | #1
Hi Andrew,

On 11/05/2014 08:31 PM, Andrew Ruder wrote:
> The UBI layer will disable much of its error reporting when it is
> compiled into the linux kernel to avoid stopping boot.  We want this
> error reporting in U-Boot since we don't initialize the UBI layer until
> it is used and want the error reporting.
> 
> We force this by telling the UBI layer we are building as a module.
> 
> Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Kyungmin Park <kmpark@infradead.org>
> ---
>  include/ubi_uboot.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
> index 1fd15f4..324fe72 100644
> --- a/include/ubi_uboot.h
> +++ b/include/ubi_uboot.h
> @@ -51,6 +51,14 @@
>  
>  #undef CONFIG_MTD_UBI_BLOCK
>  
> +/* ubi_init() disables returning error codes when built into the Linux
> + * kernel so that it doesn't hang the Linux kernel boot process.  Since
> + * the U-Boot driver code depends on getting valid error codes from this
> + * function we just tell the UBI layer that we are building as a module
> + * (which only enables the additional error reporting).
> + */
> +#define CONFIG_MTD_UBI_MODULE
> +
>  #if !defined(CONFIG_MTD_UBI_BEB_LIMIT)
>  #define CONFIG_MTD_UBI_BEB_LIMIT	20
>  #endif
> 

I applied this patch but apparently I'm suffering a memory leak in a certain
condition. I wonder if you can reproduce it:

1. Assume you have an empty partition called "MyPart".
2. Write it with some dummy data:
	=> mw.l $loadaddr deadbeed 1000
	=> nand write $loadaddr MyPart 1000
3. Set it as the UBI part:
	=> ubi part MyPart
This (which returned 0 before, despite failing during the attach procedure now should
return an error).
4. Run the command again several times:
	=> ubi part MyPart
	=> ubi part MyPart

In my case, after calling this three times, the target hangs. I think the exit path in
ubi_init() does not properly free every allocated memory. I was not able to find the
root cause, though.

Regards
--
Hector Palacios
Hector Palacios Dec. 18, 2014, 9:19 a.m. UTC | #2
Hi Andrew,

On 11/05/2014 08:31 PM, Andrew Ruder wrote:
> The UBI layer will disable much of its error reporting when it is
> compiled into the linux kernel to avoid stopping boot.  We want this
> error reporting in U-Boot since we don't initialize the UBI layer until
> it is used and want the error reporting.
> 
> We force this by telling the UBI layer we are building as a module.
> 
> Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Kyungmin Park <kmpark@infradead.org>
> ---
>  include/ubi_uboot.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
> index 1fd15f4..324fe72 100644
> --- a/include/ubi_uboot.h
> +++ b/include/ubi_uboot.h
> @@ -51,6 +51,14 @@
>  
>  #undef CONFIG_MTD_UBI_BLOCK
>  
> +/* ubi_init() disables returning error codes when built into the Linux
> + * kernel so that it doesn't hang the Linux kernel boot process.  Since
> + * the U-Boot driver code depends on getting valid error codes from this
> + * function we just tell the UBI layer that we are building as a module
> + * (which only enables the additional error reporting).
> + */
> +#define CONFIG_MTD_UBI_MODULE
> +
>  #if !defined(CONFIG_MTD_UBI_BEB_LIMIT)
>  #define CONFIG_MTD_UBI_BEB_LIMIT	20
>  #endif
> 

I applied this patch but apparently I'm suffering a memory leak in a certain
condition. I wonder if you can reproduce it:

1. Assume you have an empty partition called "MyPart".
2. Write it with some dummy data:
	=> mw.l $loadaddr deadbeed 1000
	=> nand write $loadaddr MyPart 1000
3. Set it as the UBI part:
	=> ubi part MyPart
This (which returned 0 before, despite failing during the attach procedure now should
return an error).
4. Run the command again several times:
	=> ubi part MyPart
	=> ubi part MyPart

In my case, after calling this three times, the target hangs. I think the exit path in
ubi_init() does not properly free every allocated memory. I was not able to find the
root cause, though.

Regards
--
Hector Palacios
diff mbox

Patch

diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
index 1fd15f4..324fe72 100644
--- a/include/ubi_uboot.h
+++ b/include/ubi_uboot.h
@@ -51,6 +51,14 @@ 
 
 #undef CONFIG_MTD_UBI_BLOCK
 
+/* ubi_init() disables returning error codes when built into the Linux
+ * kernel so that it doesn't hang the Linux kernel boot process.  Since
+ * the U-Boot driver code depends on getting valid error codes from this
+ * function we just tell the UBI layer that we are building as a module
+ * (which only enables the additional error reporting).
+ */
+#define CONFIG_MTD_UBI_MODULE
+
 #if !defined(CONFIG_MTD_UBI_BEB_LIMIT)
 #define CONFIG_MTD_UBI_BEB_LIMIT	20
 #endif