diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2015-08-27 18:52:36 +0900 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2015-08-30 22:18:00 +0900 |
commit | 2bc1f2b5929d03fddd38f169621a0fa7670d85eb (patch) | |
tree | 2e7d2ccbed35da9e0112d8a64a623c7767cf199b | |
parent | a679cc0118f6bec16c82d2c44f8a980f6f319bde (diff) | |
download | u-boot-imx-2bc1f2b5929d03fddd38f169621a0fa7670d85eb.zip u-boot-imx-2bc1f2b5929d03fddd38f169621a0fa7670d85eb.tar.gz u-boot-imx-2bc1f2b5929d03fddd38f169621a0fa7670d85eb.tar.bz2 |
mtd: denali_spl: do not allocate page_buffer in .bss section
Since commit 2580a2a7e719 ("mtd: nand: Increase max sizes of OOB and
Page size"), three boards (ph1_ld4, ph1_pro4, ph1_sld8) fail to build
with the following error message:
arm-linux-gnueabi-ld.bfd: SPL image plus BSS too big
They compile drivers/mtd/nand/denali_spl.c and it has a page_buffer
as static data:
static uint8_t page_buffer[NAND_MAX_PAGESIZE];
This buffer required 8KB in .bss section before that commit and now
it has been increased to 16KB. Given limited code/memory size for SPL,
it is not a good idea to allocate a page buffer statically. In the
first place, the load address 'dst' can be used as a page buffer.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r-- | drivers/mtd/nand/denali_spl.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/mtd/nand/denali_spl.c b/drivers/mtd/nand/denali_spl.c index e98f537..1587413 100644 --- a/drivers/mtd/nand/denali_spl.c +++ b/drivers/mtd/nand/denali_spl.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2014 Panasonic Corporation + * Copyright (C) 2014-2015 Masahiro Yamada <yamada.masahiro@socionext.com> * * SPDX-License-Identifier: GPL-2.0+ */ @@ -22,7 +23,6 @@ static void __iomem *denali_flash_reg = (void __iomem *)CONFIG_SYS_NAND_REGS_BASE; static const int flash_bank; -static uint8_t page_buffer[NAND_MAX_PAGESIZE]; static int page_size, oob_size, pages_per_block; static void index_addr(uint32_t address, uint32_t data) @@ -144,15 +144,15 @@ static int nand_read_page(void *buf, int page) return 0; } -static int nand_block_isbad(int block) +static int nand_block_isbad(void *buf, int block) { int ret; - ret = nand_read_oob(page_buffer, block * pages_per_block); + ret = nand_read_oob(buf, block * pages_per_block); if (ret < 0) return ret; - return page_buffer[CONFIG_SYS_NAND_BAD_BLOCK_POS] != 0xff; + return *((uint8_t *)buf + CONFIG_SYS_NAND_BAD_BLOCK_POS) != 0xff; } /* nand_init() - initialize data to make nand usable by SPL */ @@ -184,7 +184,7 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) while (size) { if (force_bad_block_check || page == 0) { - ret = nand_block_isbad(block); + ret = nand_block_isbad(dst, block); if (ret < 0) return ret; @@ -196,24 +196,16 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) force_bad_block_check = 0; - if (unlikely(column || size < page_size)) { - /* Partial page read */ - ret = nand_read_page(page_buffer, - block * pages_per_block + page); - if (ret < 0) - return ret; + ret = nand_read_page(dst, block * pages_per_block + page); + if (ret < 0) + return ret; - readlen = min(page_size - column, (int)size); - memcpy(dst, page_buffer, readlen); + readlen = min(page_size - column, (int)size); + if (unlikely(column)) { + /* Partial page read */ + memmove(dst, dst + column, readlen); column = 0; - } else { - ret = nand_read_page(dst, - block * pages_per_block + page); - if (ret < 0) - return ret; - - readlen = page_size; } size -= readlen; |