Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: pciehp: Remove a non-existent card, regardless of "surprise" capability

In case a card is physically yanked out, it should immediately be removed,
regardless of the "surprise" capability bit. Thus:

- Always handle the physical removal - regardless of the "surprise" bit.
- Don't use "surprise" capability when making decisions about enabling
presence detect notifications.
- Reword the comments to indicate the intent.

Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Rajat Jain and committed by
Bjorn Helgaas
2b3940b6 50277c8b

+13 -5
+8 -1
drivers/pci/hotplug/pciehp_ctrl.c
··· 535 535 pciehp_green_led_off(p_slot); 536 536 break; 537 537 case INT_PRESENCE_ON: 538 - case INT_PRESENCE_OFF: 539 538 if (!HP_SUPR_RM(ctrl)) 540 539 break; 540 + ctrl_dbg(ctrl, "Surprise Insertion\n"); 541 + handle_surprise_event(p_slot); 542 + break; 543 + case INT_PRESENCE_OFF: 544 + /* 545 + * Regardless of surprise capability, we need to 546 + * definitely remove a card that has been pulled out! 547 + */ 541 548 ctrl_dbg(ctrl, "Surprise Removal\n"); 542 549 handle_surprise_event(p_slot); 543 550 break;
+5 -4
drivers/pci/hotplug/pciehp_hpc.c
··· 619 619 620 620 /* 621 621 * pciehp has a 1:1 bus:slot relationship so we ultimately want a secondary 622 - * bus reset of the bridge, but if the slot supports surprise removal (or 623 - * link state change based hotplug), we need to disable presence detection 624 - * (or link state notifications) around the bus reset and clear any spurious 622 + * bus reset of the bridge, but at the same time we want to ensure that it is 623 + * not seen as a hot-unplug, followed by the hot-plug of the device. Thus, 624 + * disable link state notification and presence detection change notification 625 + * momentarily, if we see that they could interfere. Also, clear any spurious 625 626 * events after. 626 627 */ 627 628 int pciehp_reset_slot(struct slot *slot, int probe) ··· 634 633 if (probe) 635 634 return 0; 636 635 637 - if (HP_SUPR_RM(ctrl) && !ATTN_BUTTN(ctrl)) { 636 + if (!ATTN_BUTTN(ctrl)) { 638 637 ctrl_mask |= PCI_EXP_SLTCTL_PDCE; 639 638 stat_mask |= PCI_EXP_SLTSTA_PDC; 640 639 }