aboutsummaryrefslogtreecommitdiff
path: root/core/flash.c
AgeCommit message (Collapse)AuthorFilesLines
2016-07-28core/flash: Fix passing pointer instead of valueCyril Bur1-1/+1
flash_find_subpartition() accepts a pointer to a boolean variable indicating ecc for a region of flash and passes the pointer directly to flash_read_corrected() which actually only wants the value. This has always worked probably because there has always been ECC on sub partitions. How there aren't any warnings triggered by this condition escapes me. Fixes: 6c26bc7 ("libflash: move ffs_flash_read into libflash") Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-20flash: Allocate flashes dynamicallyMichael Neuling1-34/+35
Convert flashes from a static array which wastes memory and limits us. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-06Revert "flash: Use blocklevel to do ECC reads"Stewart Smith1-2/+2
Was causing boot failures on Garrison and Firestone (likely other OpenPower platforms) This reverts commit 74ba83462c64d6a987ed4785aee55309daf9ffb6. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-05flash: Use blocklevel to do ECC readsAlistair Popple1-2/+2
flash_read_corrected() assumes the passed blocklevel device is an actual flash device. However the blocklevel flash abstraction supports automatically reading ECC protected data so use that instead. Signed-off-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Michael Neuling <mikey@neuling.org> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-05flash: Increase the maximum number of flash devicesMichael Neuling1-1/+1
Increase the max number of flash devices from 1 to 8. With mambo bogusdisk, we can have many flash devices. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-20ccore/fflash.c: Ffix ttypo iin fflash eerror mmessageJeremy Kerr1-1/+1
wwhich -> which. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-20fwts: add annotations for core flash/nvram functionalityStewart Smith1-0/+12
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-04-28core/flash: Add fwts olog annotationsJeremy Kerr1-0/+20
This change adds a few fwts patterns to the flash code, mostly as an example of the annotations we have. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-02flash: Add ecc.h full pathVasant Hegde1-1/+1
...to make it consistent with rest of the includes from libflash. Suggested-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-23libffs: init with ecc protection at blocklevel levelCyril Bur1-2/+2
Passing a flag on libffs init will register all regions of the flash with ecc (as per the libffs partition information) as being ecc protected (or not). This saves the consumer needing to know or care about the presence of ecc. Reviewed-By: Alistair Popple <alistair@popple.id.au> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-23libflash/ecc: Simplify and cleanup ecc code.Cyril Bur1-5/+5
The ecc 'memcpy' style functions return success or fail in terms of the ECC enum. This doesn't really make sense, use true or false. As the result the ecc enum doesn't need to be exposed anymore, which makes more sense, not clear why it was exposed in the first place. Convert some of the ecc #defines to static inlines, shouldn't make any difference but feels safer. Fix minor stylistic and typo issues. Reviewed-By: Alistair Popple <alistair@popple.id.au> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-16flash: fix offset and size parameters checkCédric Le Goater1-1/+1
Copying the flash from the host fails : # cat /dev/mtd0 > pnor cat: /dev/mtd0: Input/output error and the kernel logs : [ 1357.866996] mtd mtd0: opal_flash_async_op(op=0) failed (rc -1) It seems that the check on the parameters in the opal_flash_op() routine are bit excessive and we fail to write or read the last block. Here is a fix below which should be enough to catch an out of bounds operation. Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-09libflash: start using the blocklevel interface.Cyril Bur1-15/+20
Converted all the libflash calls to use the blocklevel interface, modified all callers to libflash to use the blocklevel interface. This patch should introduce next to no functional change. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-05-20flash: don't report nvram partitions through the device treeCyril Bur1-30/+2
Skiboot parses the ffs header in the nvram and writes a devicetree entry for each partition that ffs returns. Skiboot doesn't need to do this as it exposes access to the entirety of the nvram to linux so any user of the nvram within linux can just read the ffs partition data themselves. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-05-13flash: Fix uninitialised variable warningJoel Stanley1-1/+1
core/flash.c:271:14: error: variable 'flash' is used uninitialized whenever 'for' loop exits because its condition is false [-Werror,-Wsometimes-uninitialized] for (i = 0; i < ARRAY_SIZE(flashes); i++) { ^~~~~~~~~~~~~~~~~~~~~~~ core/flash.c:284:7: note: uninitialized use occurs here if (!flash) { ^~~~~ core/flash.c:271:14: note: remove the condition if it is always true for (i = 0; i < ARRAY_SIZE(flashes); i++) { ^~~~~~~~~~~~~~~~~~~~~~~ core/flash.c:257:21: note: initialize the variable 'flash' to silence this warning struct flash *flash; ^ = NULL Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-05-12Fix race in flash resource preloadingStewart Smith1-4/+5
(13:31:46) benh: stewart: flash_load_resources() (13:31:53) benh: stewart: you hit the unlock at the bottom of the loop (13:31:59) benh: stewart: at that point the list may be empty (13:32:09) benh: stewart: and so another concurrent load can restart the thread (13:32:15) benh: stewart: you end up with duplicate threads (13:32:26) benh: stewart: in which case you can hit the assert <patch goes here> (13:34:27) benh: ie, never drop the lock with the queue empty (13:34:29) benh: unless you know you will exit the job (13:34:32) benh: otherwise you can have a duplicate job (13:34:41) benh: -> kaboom (13:36:29) benh: yeah the decision to exit the loop must be atomic with the popping of the last element in the list (13:36:43) benh: to match the decision to start the thread which is atomic with the queuing of the first element Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-05-07astbmc: asynchronous preloading of resourcesStewart Smith1-2/+117
Implement start_preload_resource and resource_loaded platform functions for astbmc machines (palmetto, habanero, firestone). This means we start loading kernel and initramfs from flash much earlier in boot, doing things like PCI init concurrently so that by the time we go to boot the payload, it's already loaded. Implementation is a simple queue with a job running on another CPU doing the libflash calls. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-04-01Remove redundant includes of opal-api.hMichael Ellerman1-1/+0
Now that opal.h includes opal-api.h, there are a bunch of files that include both but don't need to. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-25Fix start_preload_resource for OpenPower BMC machinesCédric Le Goater1-2/+3
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-24Asynchronous LID/Resource loading for FSP systemsStewart Smith1-1/+1
This moves away from using fsp_sync_msg in fsp_fetch_data and instead using the platform hooks for start_preload_resource() to actually queue up a load and having the plumbing for checking if a resource is loaded yet. This gets rid of the "pollers called with locks held" warning we got heaps of previously. You can now boot some FSP systems without getting this warning at all. This also sets the stage for starting load of LIDs much earlier to when they're needed, improving boot time. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-23Change load_resource() API to be all about preloading.Stewart Smith1-2/+2
No functional changes in what happens, just have two calls, one for queueing preload the other for waiting until it has loaded. future patches will introduce platform specific queueing. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-06Merge branch 'openpower'Stewart Smith1-4/+54
2015-03-05flash: fix return value of flash_find_subpartition()Cédric Le Goater1-1/+1
sparse spotted the problem : core/flash.c:379:22: warning: odd constant _Bool cast (fffffffffffffff6 becomes 1) Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-05core/flash: Fix invalid try_lock check in flash_nvram_writeJeremy Kerr1-1/+1
We have the logic inverted here. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
2015-03-04hw/ipmi: Disable flash access when requestedJoel Stanley1-4/+54
BMC based systems contain a PNOR to provide flash storage. The host normally has exclusive access to the PNOR, however the BMC may use IPMI to request access to perform functions such as update the firmware. Indicate to users of the flash that the device is busy by taking the lock, and setting a per-flash busy flag, which causes flash operations to return OPAL_BUSY. Minor changes from Jeremy Kerr Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
2015-03-04core/flash: Rename KERNEL to BOOTKERNELJoel Stanley1-1/+1
BOOTKERNEL is now the name for the PNOR petition that will contain the separate kernel, so that users do not confuse the bootloader kernel with the final OS kernel. Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-04core/flash: Don't clobber rc in error pathJoel Stanley1-1/+1
When checking paramters for errors we set rc, but then simply return OPAL_HARDWARE in the error path. Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-04core/flash: Remove alignment and size restrictionsJoel Stanley1-8/+5
libflash is able to perform reads and writes across page boundaries, so this restriction is not required. Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-04core/flash: add /chosen/ibm, system-flash property to indicate system PNORJeremy Kerr1-8/+33
This change adds a property in /chosen: /chosen/ibm,system-flash Containing the path to the system flash device. We move the system-flash-specific setup to a new function to contain it in the one place. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-26libflash: move ffs_flash_read into libflashJeremy Kerr1-3/+3
We have ffs_flash_read to do optionally-ecc-ed reads of flash data. However, this isn't really related to the ffs partitioning. This change moves ffs_flash_read into libflash.c, named flash_read_corrected. The function itself isn't changed. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-23capi: Add CAPI microcode read to load_resource()Michael Neuling1-0/+1
Add ability to read CAPI microcode to load_resource() implementations. We use the cfam chipid as the subid. FSP load_resource() contains a map of cfam chipid to lid numbers. PNOR load_resource() doesn't change, but requires a properly formatted partition with EC values in the TOC matching the appropriate cfam chipid. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-23flash: Add ECC to load_resource()Michael Neuling1-15/+52
Add decoding, checking and correction of ECC enabled partitions in pnor_load_resource(). Signed-off-by: Michael Neuling <mikey@neuling.org> Reviewed-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-23libffs: Add ecc parameter on ffs_part_info()Michael Neuling1-3/+3
Add ecc parmenter to ffs_part_info() to indicate if the partition is ECC protected or not. Fix all call sites. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-23flash: Fix bugs for sub-partitions in flash_load_resource()Michael Neuling1-8/+16
In the recent change: commit 73b262e768529f152ec64b4418b0c31691bc15c3 Author: Jeremy Kerr <jk@ozlabs.org> core/flash: port pnor_load_resource to flash code Some code was moved around, but it was modified introducing a number of bugs. Firstly the size check was moved to before the sub-partition determination. This is incorrect as the size check is against the sub-partition not the full partition. Secondly, it introduced a return in the error path for sub-partitions. This should be a goto to ensure the correct cleanup code is run. Thirdly, subid is now set in the name lookup loop where it shouldn't be. Fourthly, a check on the subid was removed unnecessarily. Signed-off-by: Michael Neuling <mikey@neuling.org> Brown-paper-bag-acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-23flash: Add newlines on printsMichael Neuling1-6/+6
These were added in a8513d3f3e but I forgot the \n. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-19core/flash: Move flash NVRAM handling to new flash moduleJeremy Kerr1-3/+104
Since we want to prevent conflicts between PNOR and NVRAM, this change moves the flash-nvram handling out of flash-nvram.c and into the generic flash module. This way, the OPAL_FLASH_{READ,WRITE,ERASE} API won't conflict with the OPAL_*_NVRAM api. To do this, we use the flash_register function to look for an "NVRAM" partition. If one is found, it is automatically registered as the system NVRAM backend. We also change the rhesus and astmbc platforms to use the common flash code. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-19core/flash: port pnor_load_resource to flash codeJeremy Kerr1-0/+186
Since we have a flash device registered as the system flash, use this as a generic load_resource backend. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-19core/flash: Add flash APIJeremy Kerr1-0/+225
We'd like to enable access to the system PNOR, on platforms where its present. This change introduces an API for global flash operations: opal_flash_read opal_flash_erase opal_flash_write - plus device-tree bindings to expose the flash details. Since there are other components of the system that use the PNOR (NVRAM and pnor_load_resource), upcoming changes will port this these over to use the new interface. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>