summaryrefslogtreecommitdiffstats
path: root/libflash/mbox-flash.c
Commit message (Collapse)AuthorAgeFilesLines
* astbmc: Prefer ipmi-hiomap for PNOR accessAndrew Jeffery2018-10-111-0/+6
| | | | | | | | | If the IPMI command is not available, fall back to the mailbox interface. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> [stewart: fix up mbox test] Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* libflash: quieten our loggingStewart Smith2018-06-181-2/+0
| | | | | Suggested-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* mbox/flash: Remove dead codeBalbir singh2018-05-241-3/+0
| | | | | | | | Caught by scan-build, attn is passed in by value and modified but not read after that. Signed-off-by: Balbir singh <bsingharora@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* mbox: Reduce default BMC timeoutsCyril Bur2018-03-271-4/+3
| | | | | | | | | | | | | | | | | | | Rebooting a BMC can take 70 seconds. Skiboot cannot possibly spin for 70 seconds waiting for a BMC to come back. This also makes the current default of 30 seconds a bit pointless, is it far too short to be a worse case wait time but too long to avoid hitting hardlockup detectors and wrecking havoc inside host linux. Just change it to three seconds so that host linux will survive and that, reads and writes will fail but at least the host stays up. Also refactored the waiting loop just a bit so that it's easier to read. Reported-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> Tested-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* mbox: Harden against BMC daemon errorsCyril Bur2018-03-271-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bugs present in the BMC daemon mean that skiboot gets presented with mbox windows of size zero. These windows cannot be valid and skiboot already detects these conditions. Currently skiboot warns quite strongly about the occurrence of these problems. The problem for skiboot is that it doesn't take any action. Initially I wanting to avoid putting policy like this into skiboot but since these bugs aren't going away and skiboot barfing is leading to lockups and ultimately the host going down something needs to be done. I propose that when we detect the problem we fail the mbox call and punt the problem back up to Linux. I don't like it but at least it will cause errors to cascade and won't bring the host down. I'm not sure how Linux is supposed to detect this or what it can even do but this is better than a crash. Diagnosing a failure to boot if skiboot its self fails to read flash may be marginally more difficult with this patch. This is because skiboot will now only print one warning about the zero sized window rather than continuously spitting it out. Reported-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> Tested-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: fallback to requesting lower MBOX versions from BMCStewart Smith2017-12-201-0/+7
| | | | | | | | | | | | Some BMC mbox implementations seem to sometimes mysteriously fail when trying to negotiate v3 when they only support v2. To work around this, we can fall back to requesting lower mbox protocol versions until we find one that works. In theory, this should already "just work", but we have a counter example, which this patch fixes. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: only wait for MBOX_DEFAULT_POLL_MS if busyStewart Smith2017-12-181-1/+2
| | | | | | | This makes the mbox unit test run 300x quicker and seems to shave about 6 seconds from boot time on Witherspoon. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/test: Add tests for mbox-flashCyril Bur2017-12-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | A first basic set of tests for mbox-flash. These tests do their testing by stubbing out or otherwise replacing functions not in libflash/mbox-flash.c. The stubbed out version of the function can then be used to emulate a BMC mbox daemon talking to back to the code in mbox-flash and it can ensure that there is some adherence to the protocol and that from a blocklevel api point of view the world appears sane. This makes these tests simple to run and they have been integrated into `make check`. The down side is that these tests rely on duplicated feature incomplete BMC daemon behaviour. Therefore these tests are a strong indicator of broken behaviour but a very unreliable indicator of correctness. Full integration tests with a 'real' BMC daemon are probably beyond the scope of this repository. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> [stewart: fix TESTS_LOOPS printf] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Add the ability to lock flashCyril Bur2017-12-141-5/+65
| | | | | Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Understand v3Cyril Bur2017-12-141-32/+75
| | | | | Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Use static arrays of function pointersCyril Bur2017-12-141-32/+81
| | | | | Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Use BMC suggested timeout valueCyril Bur2017-12-141-11/+26
| | | | | Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Simplify message sendingCyril Bur2017-12-141-92/+31
| | | | | | | | | | | | | hw/lpc-mbox no longer requires that the memory associated with messages exist for the lifetime of the message. Once it has been sent to the BMC, that is bmc_mbox_enqueue() returns, lpc-mbox does not need the message to continue to exist. On the reciving side, lpc-mbox will ensure that a message exists for the receving callback function. Remove all code to deal with allocating messages. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Allow mbox-flash to tell the driver msg timeoutsCyril Bur2017-12-141-8/+9
| | | | | | | | | | | | | | | Currently when mbox-flash decides that a message times out the driver has no way of knowing to drop the message and will continue waiting for a response indefinitely preventing more messages from ever being sent. This is a problem if the BMC crashes or has some other issue where it won't ever respond to our outstanding message. This patch provides a method for mbox-flash to tell the driver how long it should wait before it no longer needs to care about the response. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Move sequence handling to driver levelCyril Bur2017-12-141-10/+0
| | | | | Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Always close windows before opening a new windowCyril Bur2017-12-141-0/+3
| | | | | | | | | | | | | | The MBOX protocol states that if an open window command fails then all open windows are closed. Currently, if an open window command fails mbox-flash will erroneously assume that the previously open window is still open. The solution to this is to mark all windows as closed before issuing an open window command and then on success we'll mark the new window as open. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Fix unintentional integer overflow (CID 142226)Cyril Bur2017-08-151-2/+2
| | | | | | | | | | | | Fixes: CID 142226 (#1 of 1): overflow_before_widen: Potentially overflowing expression `1 << mbox_flash->shift` with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64_t (64 bits, unsigned). Fixes: CID 142226 Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Implement MARK_WRITE_ERASED mbox callSuraj Jitindar Singh2017-05-261-4/+59
| | | | | | | | | | | | | | | | | Version two of the mbox-flash protocol defines a new command: MARK_WRITE_ERASED. This command provides a simple way to mark a region of flash as all 0xff without the need to go and write all 0xff. This is an optimisation as there is no need for an erase before a write, it is the responsibility of the BMC to deal with the flash correctly, however in v1 it was ambiguous what a client should do if the flash should be erased but not actually written to. This allows of a optimal path to resolve this problem. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Acked-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Update to V2 of the protocolCyril Bur2017-05-261-135/+557
| | | | | | | | | | | | | | | | | | | Updated version 2 of the protocol can be found at: https://github.com/openbmc/mboxbridge/blob/master/Documentation/mbox_protocol.md This commit changes mbox-flash such that it will preferentially talk version 2 to any capable daemon but still remain capable of talking to v1 daemons. Version two changes some of the command definitions for increased consistency and usability. Version two includes more attention bits - these are now dealt with at a simple level. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Acked-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/mbox-flash: Minor fixups before V2Cyril Bur2017-05-261-1/+7
| | | | | | | | | | | | | | | | - Warn if flushing with closed write window. - Call msg_free_memory() in mbox_flash_init() before a successful return. No leak is present as the current allocation theme is from static memory. However as this is likely to change in the future, best to ensure that msg_free_memory() is called after every allocation. - Fix bug where len argument may be incorrect in mark dirty command. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Acked-by: Cyril Bur <cyri.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash: blocklevel backend for MBOX flash accessCyril Bur2017-02-231-0/+576
The use MBOX protocol to request flash access from the BMC. Then read/write to the 'flash' through windows it creates on LPC FW space. Reference implementation of the mbox flash daemon for BMC userspace: https://github.com/cyrilbur-ibm/mboxbridge Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
OpenPOWER on IntegriCloud