From 9648407ed0b9f142b1416d8488fa3177f40cff89 Mon Sep 17 00:00:00 2001 From: Craig Hesling Date: Thu, 15 Jul 2021 02:20:41 -0400 Subject: flash_fp_mcu: Fix interrupt to unbind race caused by pwr_en Taking control of the pwr_en line causes the FPMCU to power cycle. This causes an interrupt to the cros-ec driver. The interrupt handler then races with the subsequent cros-ec unbind attempt. This can manifest in multiple ways, but one common way is for the later binding of spidev to fail, since the interrupt handler reinitialized the cros-ec driver (due to crrev.com/c/1903814). The spidev attempt then errors out because there are still resources associated with the device (the reallocated cros-ec objects). The need to take control of the power enable line to simply keep FPMCU power enabled is no longer needed on any device. * The need for this arose during nocturne development, when the pwr_en line was associated with the SPI interface in ACPI. This can be seen in https://crrev.com/c/1084686. This pwr_en control was then added to flash_fp_mcu in https://crrev.com/c/1114743. * The pwr_line was then quickly disassociated with the SPI interface a few days later in https://crrev.com/c/1155565, but wasn't removed from flash_fp_mcu. To this day, the FP pwr_en line is controlled in coreboot manually. It remains powered on when the Chromebook is powered on, irrespective of drivers. BRANCH=none BUG=b:190744837 TEST=Run the following on nocturne, nami, kohaku, dratini, and volteer. scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello ssh ${DUT_HOSTNAME} flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello Signed-off-by: Craig Hesling Change-Id: Icc64f7056e21180efd19b2f650b9fe5804cd2906 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3027129 Tested-by: Patryk Duda Reviewed-by: Patryk Duda Reviewed-by: Josie Nordrum (cherry picked from commit 6e4ed0664ef649b0170894cc2ac1a738d3673ce1) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3041185 Commit-Queue: Jora Jacobi Reviewed-by: Jora Jacobi --- util/flash_fp_mcu | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu index 827aa398de..85ab64dfc5 100644 --- a/util/flash_fp_mcu +++ b/util/flash_fp_mcu @@ -299,13 +299,6 @@ flash_fp_mcu_stm32() { echo "Flashing ${transport} device ID: ${deviceid}" - # Ensure the ACPI is not cutting power when unloading cros-ec-spi - if [[ "${gpio_pwren}" -gt 0 ]]; then - gpio export "${gpio_pwren}" - gpio out "${gpio_pwren}" - gpio 1 "${gpio_pwren}" - fi - # Remove cros_fp if present klog "Unbinding cros-ec driver" if [[ "${transport}" == "UART" ]]; then @@ -409,11 +402,6 @@ flash_fp_mcu_stm32() { klog "Binding cros-ec driver" echo "" > "/sys/bus/spi/devices/${deviceid}/driver_override" echo "${deviceid}" > /sys/bus/spi/drivers/cros-ec-spi/bind - - # Kernel driver is back, we are no longer controlling power - if [[ "${gpio_pwren}" -gt 0 ]]; then - gpio unexport "${gpio_pwren}" - fi fi if [[ "${cmd_exit_status}" -ne 0 ]]; then -- cgit v1.2.1