[flashrom] [Patch] + RFC: Use shutdown callback mechanism to shutdown programmers

David Hendricks dhendrix at google.com
Fri Apr 22 06:28:15 CEST 2011


Hi everyone,
Lately we've been looking into reverse
PCI<http://flashrom.org/trac/flashrom/changeset/1232>and
MMIO <http://patchwork.coreboot.org/patch/2331/> writes, along with the
shutdown callback mechanism.

The main usage case for Flashrom makes this a pretty simple matter, since
most users only worry about a single programmer being used. However, when
external devices are used which depend on internal programmer settings,
things can get messy.

Consider the case of a laptop with an x86 southbridge and an EC -- To
communicate with the EC thru the LPC/FWH interface, some register settings
in the southbridge might need to be changed. The code flow should be:
1. Set up SB, use rpci_* and rmmio_* to register reverse PCI and MMIO
callbacks wherever necessary.
2. Set up EC.
3. Run code.
4. Call EC shutdown routine.
5. Reverse SB PCI/MMIO writes.

However, the current code calls the programmer shutdown routine in step 4 *
after* doing all shutdown callbacks in step 5. This causes southbridge
registers to be reverted before the EC's shutdown routine is called,
potentially making the EC unreachable.

The attached patch addresses this by using programmer shutdown functions the
same as any other shutdown callback. The internal_shutdown function is
registered early in the internal_init() function so that newly discovered
external programmers (ie SuperIO/EC LPC -> SPI bridges) can be discovered
and have their shutdown callbacks added in the correct order.

If this seems useful, we should make necessary changes to other programmers
as well before committing this patch.

Signed-off-by: David Hendricks <dhendrix at google.com>

-- 
David Hendricks (dhendrix)
Systems Software Engineer, Google Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.flashrom.org/pipermail/flashrom/attachments/20110421/9b987a13/attachment.html>


More information about the flashrom mailing list