diff mbox series

[U-Boot,please,test] fs/fat: reduce stack usage for SPL

Message ID 20170917133807.16819-1-robdclark@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series [U-Boot,please,test] fs/fat: reduce stack usage for SPL | expand

Commit Message

Rob Clark Sept. 17, 2017, 1:38 p.m. UTC
It seems like stack usage is a problem for SPL builds.  So move itrblock
off the stack.

Please test this and see if it helps w/ current issues with SPL builds.
Long term, I'm not sure if it is better to do this conditional on SPL
builds, or move to malloc()?  At any rate, if this fixes SPL builds it
should be a perfectly ok short term solution.

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
 fs/fat/fat.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Tom Rini Sept. 17, 2017, 1:42 p.m. UTC | #1
On Sun, Sep 17, 2017 at 09:38:04AM -0400, Rob Clark wrote:

> It seems like stack usage is a problem for SPL builds.  So move itrblock
> off the stack.
> 
> Please test this and see if it helps w/ current issues with SPL builds.
> Long term, I'm not sure if it is better to do this conditional on SPL
> builds, or move to malloc()?  At any rate, if this fixes SPL builds it
> should be a perfectly ok short term solution.
> 
> Signed-off-by: Rob Clark <robdclark@gmail.com>

Tested-by: Tom Rini <trini@konsulko.com>

Note that malloc would also be fine as we already have a dependency on
malloc, that's just not (but should be!) expressed in Kconfig, for FAT
support already.  Thanks!
Adam Ford Sept. 17, 2017, 1:50 p.m. UTC | #2
On Sun, Sep 17, 2017 at 8:42 AM, Tom Rini <trini@konsulko.com> wrote:
> On Sun, Sep 17, 2017 at 09:38:04AM -0400, Rob Clark wrote:
>
>> It seems like stack usage is a problem for SPL builds.  So move itrblock
>> off the stack.
>>
>> Please test this and see if it helps w/ current issues with SPL builds.
>> Long term, I'm not sure if it is better to do this conditional on SPL
>> builds, or move to malloc()?  At any rate, if this fixes SPL builds it
>> should be a perfectly ok short term solution.
>>
>> Signed-off-by: Rob Clark <robdclark@gmail.com>
>
> Tested-by: Tom Rini <trini@konsulko.com>
>

This fixed the problem on the am3517-evm.  Thank you,

Tested-by: Adam Ford <aford173@gmail.com>

> Note that malloc would also be fine as we already have a dependency on
> malloc, that's just not (but should be!) expressed in Kconfig, for FAT
> support already.  Thanks!
>
> --
> Tom
diff mbox series

Patch

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index f0284398b4..93140c9bcb 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1031,10 +1031,12 @@  int file_fat_detectfs(void)
 	return 0;
 }
 
+static fat_itr itrblock;
+
 int fat_exists(const char *filename)
 {
 	fsdata fsdata;
-	fat_itr itrblock, *itr = &itrblock;
+	fat_itr *itr = &itrblock;
 	int ret;
 
 	ret = fat_itr_root(itr, &fsdata);
@@ -1049,7 +1051,7 @@  int fat_exists(const char *filename)
 int fat_size(const char *filename, loff_t *size)
 {
 	fsdata fsdata;
-	fat_itr itrblock, *itr = &itrblock;
+	fat_itr *itr = &itrblock;
 	int ret;
 
 	ret = fat_itr_root(itr, &fsdata);
@@ -1081,7 +1083,7 @@  int file_fat_read_at(const char *filename, loff_t pos, void *buffer,
 		     loff_t maxsize, loff_t *actread)
 {
 	fsdata fsdata;
-	fat_itr itrblock, *itr = &itrblock;
+	fat_itr *itr = &itrblock;
 	int ret;
 
 	ret = fat_itr_root(itr, &fsdata);