From d37d5b408c7016c53c613a13da0cb4aa62dd1bf0 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Apr 16 2024 08:58:23 +0000 Subject: PCI: pciehp: Cancel bringup sequence if card is not present (git-fixes). --- diff --git a/patches.suse/PCI-pciehp-Cancel-bringup-sequence-if-card-is-not-pr.patch b/patches.suse/PCI-pciehp-Cancel-bringup-sequence-if-card-is-not-pr.patch new file mode 100644 index 0000000..e8cf96f --- /dev/null +++ b/patches.suse/PCI-pciehp-Cancel-bringup-sequence-if-card-is-not-pr.patch @@ -0,0 +1,67 @@ +From: Rongguang Wei +Date: Fri, 12 May 2023 10:15:18 +0800 +Subject: PCI: pciehp: Cancel bringup sequence if card is not present +Git-commit: e8afd0d9fccc27c8ad263db5cf5952cfcf72d6fe +Patch-mainline: 6.5-rc1 +References: git-fixes + +If a PCIe hotplug slot has an Attention Button, the normal hot-add flow is: + + - Slot is empty and slot power is off + - User inserts card in slot and presses Attention Button + - OS blinks Power Indicator for 5 seconds + - After 5 seconds, OS turns on Power Indicator, turns on slot power, and + enumerates the device + +Previously, if a user pressed the Attention Button on an *empty* slot, +pciehp logged the following messages and blinked the Power Indicator +until a second button press: + + [0.000] pciehp: Button press: will power on in 5 sec + [0.001] # Power Indicator starts blinking + [5.001] # 5 second timeout; slot is empty, so we should cancel the + request to power on and turn off Power Indicator + + [7.000] # Power Indicator still blinking + [8.000] # possible card insertion + [9.000] pciehp: Button press: canceling request to power on + +The first button press incorrectly left the slot in BLINKINGON_STATE, so +the second was interpreted as a "cancel power on" event regardless of +whether a card was present. + +If the slot is empty, turn off the Power Indicator and return from +BLINKINGON_STATE to OFF_STATE after 5 seconds, effectively canceling the +request to power on. Putting the slot in OFF_STATE also means the second +button press will correctly request a slot power on if the slot is +occupied. + +[bhelgaas: commit log] +Link: https://lore.kernel.org/r/20230512021518.336460-1-clementwei90@163.com +Fixes: d331710ea78f ("PCI: pciehp: Become resilient to missed events") +Suggested-by: Lukas Wunner +Signed-off-by: Rongguang Wei +Signed-off-by: Bjorn Helgaas +Reviewed-by: Lukas Wunner +Signed-off-by: Jiri Slaby +--- + drivers/pci/hotplug/pciehp_ctrl.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/drivers/pci/hotplug/pciehp_ctrl.c ++++ b/drivers/pci/hotplug/pciehp_ctrl.c +@@ -270,6 +270,14 @@ void pciehp_handle_presence_or_link_chan + present = pciehp_card_present(ctrl); + link_active = pciehp_check_link_active(ctrl); + if (!present && !link_active) { ++ if (ctrl->state == BLINKINGON_STATE) { ++ ctrl->state = OFF_STATE; ++ cancel_delayed_work(&ctrl->work); ++ pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, ++ INDICATOR_NOOP); ++ ctrl_info(ctrl, "Slot(%s): Card not present\n", ++ slot_name(ctrl)); ++ } + mutex_unlock(&ctrl->lock); + return; + } diff --git a/series.conf b/series.conf index 88ec443..43b6d99 100644 --- a/series.conf +++ b/series.conf @@ -64700,6 +64700,7 @@ patches.suse/PCI-ASPM-Return-0-or-ETIMEDOUT-from-pcie_retrain_lin.patch patches.suse/PCI-ASPM-Factor-out-pcie_wait_for_retrain.patch patches.suse/PCI-ASPM-Avoid-link-retraining-race.patch + patches.suse/PCI-pciehp-Cancel-bringup-sequence-if-card-is-not-pr.patch patches.suse/USB-serial-option-add-LARA-R6-01B-PIDs.patch patches.suse/KVM-s390-vsie-fix-the-length-of-APCB-bitmap.patch patches.suse/md-raid0-add-discard-support-for-the-original-layout-e836.patch