linux_dsm_epyc7002/drivers/platform/chrome
Brian Norris 11799564fc mfd: cros_ec: Retry commands when EC is known to be busy
Commit 001dde9400 ("mfd: cros ec: spi: Fix "in progress" error
signaling") pointed out some bad code, but its analysis and conclusion
was not 100% correct.

It *is* correct that we should not propagate result==EC_RES_IN_PROGRESS
for transport errors, because this has a special meaning -- that we
should follow up with EC_CMD_GET_COMMS_STATUS until the EC is no longer
busy. This is definitely the wrong thing for many commands, because
among other problems, EC_CMD_GET_COMMS_STATUS doesn't actually retrieve
any RX data from the EC, so commands that expected some data back will
instead start processing junk.

For such commands, the right answer is to either propagate the error
(and return that error to the caller) or resend the original command
(*not* EC_CMD_GET_COMMS_STATUS).

Unfortunately, commit 001dde9400 forgets a crucial point: that for
some long-running operations, the EC physically cannot respond to
commands any more. For example, with EC_CMD_FLASH_ERASE, the EC may be
re-flashing its own code regions, so it can't respond to SPI interrupts.
Instead, the EC prepares us ahead of time for being busy for a "long"
time, and fills its hardware buffer with EC_SPI_PAST_END. Thus, we
expect to see several "transport" errors (or, messages filled with
EC_SPI_PAST_END). So we should really translate that to a retryable
error (-EAGAIN) and continue sending EC_CMD_GET_COMMS_STATUS until we
get a ready status.

IOW, it is actually important to treat some of these "junk" values as
retryable errors.

Together with commit 001dde9400, this resolves bugs like the
following:

1. EC_CMD_FLASH_ERASE now works again (with commit 001dde9400, we
   would abort the first time we saw EC_SPI_PAST_END)
2. Before commit 001dde9400, transport errors (e.g.,
   EC_SPI_RX_BAD_DATA) seen in other commands (e.g.,
   EC_CMD_RTC_GET_VALUE) used to yield junk data in the RX buffer; they
   will now yield -EAGAIN return values, and tools like 'hwclock' will
   simply fail instead of retrieving and re-programming undefined time
   values

Fixes: 001dde9400 ("mfd: cros ec: spi: Fix "in progress" error signaling")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2018-05-23 06:59:00 +01:00
..
chromeos_laptop.c platform/chrome: chromeos_laptop - discard data for unneeded boards 2018-04-09 22:52:17 -07:00
chromeos_pstore.c dmi: Mark all struct dmi_system_id instances const 2017-09-14 11:59:30 +02:00
cros_ec_debugfs.c platform/chrome: cros_ec_debugfs: Add PD port info to debugfs 2018-04-10 22:24:51 -07:00
cros_ec_lightbar.c cros_ec: Move cros_ec_dev module to drivers/mfd 2017-12-15 10:46:06 +00:00
cros_ec_lpc_mec.c platform/chrome: cros_ec_lpc: Add support for mec1322 EC 2017-06-23 16:12:01 -07:00
cros_ec_lpc_reg.c platform/chrome: cros_ec_lpc: Add support for mec1322 EC 2017-06-23 16:12:01 -07:00
cros_ec_lpc.c platform/chrome: cros_ec_lpc: Add support for Google devices using custom coreboot firmware 2018-04-09 22:57:46 -07:00
cros_ec_proto.c mfd: cros_ec: Retry commands when EC is known to be busy 2018-05-23 06:59:00 +01:00
cros_ec_sysfs.c platform/chrome: mfd/cros_ec_dev: Add sysfs entry to set keyboard wake lid angle 2018-04-10 22:25:07 -07:00
cros_ec_vbc.c cros_ec: Split cros_ec_devs module 2017-12-15 10:45:11 +00:00
cros_kbd_led_backlight.c platform/chrome: Add Chrome OS keyboard backlight LEDs support 2016-05-11 11:55:47 -07:00
Kconfig cros_ec: Move cros_ec_dev module to drivers/mfd 2017-12-15 10:46:06 +00:00
Makefile cros_ec: Move cros_ec_dev module to drivers/mfd 2017-12-15 10:46:06 +00:00