From: Thomas Chou <thomas@wytron.com.tw>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/5] altera_qspi: skip erase if the sector is blank
Date: Thu, 24 Dec 2015 10:23:05 +0800 [thread overview]
Message-ID: <567B5709.9010709@wytron.com.tw> (raw)
In-Reply-To: <201512240228.39571.marex@denx.de>
Hi Marek,
On 2015?12?24? 09:28, Marek Vasut wrote:
> On Thursday, December 24, 2015 at 01:51:22 AM, Thomas Chou wrote:
>> Skip erase if the sector is blank. The sector erase is slow, and
>> may take 0.7 sec typically or up to 3 sec worst-case.
>>
>> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
>> ---
>> drivers/mtd/altera_qspi.c | 39 +++++++++++++++++++++++++--------------
>> 1 file changed, 25 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/mtd/altera_qspi.c b/drivers/mtd/altera_qspi.c
>> index b0d4f2c..8a630a6 100644
>> --- a/drivers/mtd/altera_qspi.c
>> +++ b/drivers/mtd/altera_qspi.c
>> @@ -131,24 +131,35 @@ static int altera_qspi_erase(struct mtd_info *mtd,
>> struct erase_info *instr) size_t end = addr + len;
>> u32 sect;
>> u32 stat;
>> + u32 *flash, *last;
>>
>> instr->state = MTD_ERASING;
>> addr &= ~(mtd->erasesize - 1); /* get lower aligned address */
>> while (addr < end) {
>> - sect = addr / mtd->erasesize;
>> - sect <<= 8;
>> - sect |= QUADSPI_MEM_OP_SECTOR_ERASE;
>> - debug("erase %08x\n", sect);
>> - writel(sect, ®s->mem_op);
>> - stat = readl(®s->isr);
>> - if (stat & QUADSPI_ISR_ILLEGAL_ERASE) {
>> - /* erase failed, sector might be protected */
>> - debug("erase %08x fail %x\n", sect, stat);
>> - writel(stat, ®s->isr); /* clear isr */
>> - instr->fail_addr = addr;
>> - instr->state = MTD_ERASE_FAILED;
>> - mtd_erase_callback(instr);
>> - return -EIO;
>> + flash = pdata->base + addr;
>> + last = pdata->base + addr + mtd->erasesize;
>> + /* skip erase if sector is blank */
>> + while (flash < last) {
>> + if (readl(flash) != 0xffffffff)
>> + break;
>> + flash++;
>
> Shouldn't $last be divided by 4 ? $flash is u32 * afterall .
No. Both flash and last are assigned with byte addressing from
pdata->base, which is void *.
Best regards,
Thomas
next prev parent reply other threads:[~2015-12-24 2:23 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-24 0:51 [U-Boot] [PATCH 1/5] altera_qspi: call callback even if the erase failed Thomas Chou
2015-12-24 0:51 ` [U-Boot] [PATCH 2/5] altera_qspi: set fail_addr for erase ops Thomas Chou
2015-12-28 1:34 ` Thomas Chou
2015-12-24 0:51 ` [U-Boot] [PATCH 3/5] altera_qspi: skip erase if the sector is blank Thomas Chou
2015-12-24 1:28 ` Marek Vasut
2015-12-24 2:23 ` Thomas Chou [this message]
2015-12-24 3:01 ` Marek Vasut
2015-12-24 3:08 ` Thomas Chou
2015-12-24 3:43 ` Marek Vasut
2015-12-28 1:34 ` Thomas Chou
2015-12-24 0:51 ` [U-Boot] [PATCH 4/5] altera_qspi: show erase progress Thomas Chou
2015-12-24 1:29 ` Marek Vasut
2015-12-24 2:50 ` Thomas Chou
2015-12-24 3:02 ` Marek Vasut
2015-12-24 3:26 ` Thomas Chou
2015-12-24 3:42 ` Marek Vasut
2015-12-24 5:24 ` Thomas Chou
2015-12-24 5:37 ` Marek Vasut
2015-12-25 0:12 ` Thomas Chou
2015-12-25 4:08 ` Marek Vasut
2015-12-25 8:33 ` Thomas Chou
2015-12-25 9:58 ` Marek Vasut
2015-12-28 1:17 ` Thomas Chou
2015-12-28 5:35 ` Marek Vasut
2015-12-28 8:04 ` Thomas Chou
2015-12-28 12:40 ` Marek Vasut
2015-12-28 1:35 ` Thomas Chou
2015-12-24 0:51 ` [U-Boot] [PATCH 5/5] altera_qspi: allow ctrl-c to abort the erase ops Thomas Chou
2015-12-28 1:35 ` Thomas Chou
2015-12-28 1:34 ` [U-Boot] [PATCH 1/5] altera_qspi: call callback even if the erase failed Thomas Chou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=567B5709.9010709@wytron.com.tw \
--to=thomas@wytron.com.tw \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox