We're defining CONFIG_FLASH_DEFERRED_ERASE for stm32f76x / stm32f446, probably due to large flash size and long sector erase time on those parts.
My main problem with CONFIG_FLASH_DEFERRED_ERASE is that it implements a second method of asynchronous flash erase (CONFIG_HOST_COMMAND_STATUS / EC_RES_IN_PROGRESS is method #1, it uses the hostcmd task rather than a deferred function). Ideally the host should be able to specify the erase method as one of the following:
- Synchronous / wait for completion (even though it may take a while).
- Asynchronous / return EC_RES_IN_PROGRESS, check status with STATUS command.
- Don't care / let the EC decide (this is how FLASH_ERASE_SECTOR works today).
I realize that kicking off flash erase after 100ms may solve some problems with instruction fetch being down during erase, but eventually we will have to pay that cost, kicking it 100ms later is not necessarily safe either. The host needs to be aware that EC_CMD_FLASH_ERASE in async. mode may lead to increased interrupt latency, and increase its timeouts accordingly, until the erase completes.
Comment 1 by gwendal@chromium.org
, Dec 8 2017