summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan Crowell <dcrowell@us.ibm.com>2013-09-20 09:32:58 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-09-20 10:39:54 -0500
commita8b5295cafa2d27651744785850ba5fcf96f90df (patch)
tree8bce57df57bb90352d3cf4221c467a1949a1a66c /src
parent935e80f06d7de42b158a49102162d54e600b8565 (diff)
downloadtalos-hostboot-a8b5295cafa2d27651744785850ba5fcf96f90df.tar.gz
talos-hostboot-a8b5295cafa2d27651744785850ba5fcf96f90df.zip
Fix PNOR write bug
There was a problem that at least broke some situations where the write crossed erase blocks. I also suspect it could affect other scenarios as well. Fix was verified with testcase changes in another commit. Change-Id: I6550a6fe9efe90a8336f24ba4551822c0c97071e Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/6276 Tested-by: Jenkins Server Reviewed-by: ADAM R. MUHLE <armuhle@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/usr/pnor/pnordd.C33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/usr/pnor/pnordd.C b/src/usr/pnor/pnordd.C
index 6c65f2dd2..ef4bdf68a 100644
--- a/src/usr/pnor/pnordd.C
+++ b/src/usr/pnor/pnordd.C
@@ -283,20 +283,33 @@ errlHndl_t PnorDD::writeFlash(void* i_buffer,
block < num_blocks;
++block )
{
- write_bytes = iv_erasesize_bytes;
- if(bytes_left < iv_erasesize_bytes )
+ TRACDCOMP(g_trac_pnor,"cur_writeStart_addr=%X, cur_blkStart_addr=%X, cur_blkEnd_addr=%X, bytes_left=%X", cur_writeStart_addr, cur_blkStart_addr, cur_blkEnd_addr, bytes_left );
+ // writing at a block boundary, just write the whole thing
+ if( cur_writeStart_addr == cur_blkStart_addr )
{
- uint32_t end_waste = 0;
- //deduct any unused space at the end of the erase block
- if( cur_blkEnd_addr > (cur_writeStart_addr + bytes_left))
+ if( bytes_left > iv_erasesize_bytes )
{
- end_waste = cur_blkEnd_addr - (cur_writeStart_addr + bytes_left);
- write_bytes -= end_waste;
+ write_bytes = iv_erasesize_bytes;
+ }
+ else
+ {
+ write_bytes = bytes_left;
+ }
+ }
+ // writing the end of a block
+ else //cur_writeStart_addr > cur_blkStart_addr
+ {
+ uint32_t bytes_tail = cur_blkEnd_addr - cur_writeStart_addr;
+ if( bytes_left < bytes_tail )
+ {
+ write_bytes = bytes_left;
+ }
+ else
+ {
+ write_bytes = bytes_tail;
}
-
- //deduct any unused space at the beginning of the erase block
- write_bytes = write_bytes - (cur_writeStart_addr - cur_blkStart_addr);
}
+ //note that writestart < blkstart can never happen
// write a single block of data out to flash efficiently
mutex_lock(&cv_mutex);
OpenPOWER on IntegriCloud