commit b43aadf786480e2bfc6effc9c755d57bee68acbb Author: Alexandru Gagniuc Date: Tue Dec 18 17:27:58 2018 -0600 [HACK] PCI: pciehp: debug pciehp_isr and pciehp_ist diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 3f3df4c29f6e..f23ca91b5a4c 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -222,6 +222,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events) * Even if it's occupied again, we cannot assume the card is the same. */ mutex_lock(&ctrl->state_lock); + ctrl_err(ctrl, "ZOPA: %s: locked &ctrl->state_lock", __func__); switch (ctrl->state) { case BLINKINGOFF_STATE: cancel_delayed_work(&ctrl->button_work); @@ -229,6 +230,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events) case ON_STATE: ctrl->state = POWEROFF_STATE; mutex_unlock(&ctrl->state_lock); + ctrl_err(ctrl, "ZOPA: %s unlocked (POWEROFF)", __func__); if (events & PCI_EXP_SLTSTA_DLLSC) ctrl_info(ctrl, "Slot(%s): Link Down\n", slot_name(ctrl)); @@ -239,6 +241,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events) break; default: mutex_unlock(&ctrl->state_lock); + ctrl_err(ctrl, "ZOPA: %s unlocked (no action)", __func__); break; } @@ -248,6 +251,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events) link_active = pciehp_check_link_active(ctrl); if (!present && !link_active) { mutex_unlock(&ctrl->state_lock); + ctrl_err(ctrl, "ZOPA: %s unlocked (!present && !link_active)", __func__); return; } @@ -258,6 +262,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events) case OFF_STATE: ctrl->state = POWERON_STATE; mutex_unlock(&ctrl->state_lock); + ctrl_err(ctrl, "ZOPA: %s unlocked (POWERON)", __func__); if (present) ctrl_info(ctrl, "Slot(%s): Card present\n", slot_name(ctrl)); @@ -268,6 +273,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events) break; default: mutex_unlock(&ctrl->state_lock); + ctrl_err(ctrl, "ZOPA: %s unlocked (nothing to do)", __func__); break; } } diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 7dd443aea5a5..44e83e13c4bb 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -510,6 +510,22 @@ void pciehp_power_off_slot(struct controller *ctrl) PCI_EXP_SLTCTL_PWR_OFF); } +void print_slot_status(struct pci_dev *pdev, uint32_t slot_status, const char *msg) { + pci_err(pdev, "ZOPA: %s(0x%08x):%s%s%s%s%s%s%s%s%s", + msg, slot_status, + (slot_status & PCI_EXP_SLTSTA_DLLSC) ? " DLL-changed" : "", + (slot_status & 0x80) ? " interlock-status" : "", + (slot_status & 0x40) ? " presence-detected" : "", + (slot_status & 0x20) ? " mrl-state" : "", + (slot_status & PCI_EXP_SLTSTA_CC) ? " command-completed" : "", + (slot_status & PCI_EXP_SLTSTA_PDC) ? " presence-detect-changed" : "", + (slot_status & 0x04) ? " MRL-sensor" : "", + (slot_status & PCI_EXP_SLTSTA_PFD) ? " power-fault" : "", + (slot_status & PCI_EXP_SLTSTA_ABP) ? " attention-button-pressed" : "" + ); + +} + static irqreturn_t pciehp_isr(int irq, void *dev_id) { struct controller *ctrl = (struct controller *)dev_id; @@ -522,8 +538,10 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) * in the Slot Control register (PCIe r4.0, sec 6.7.3.4). */ if (pdev->current_state == PCI_D3cold || - (!(ctrl->slot_ctrl & PCI_EXP_SLTCTL_HPIE) && !pciehp_poll_mode)) + (!(ctrl->slot_ctrl & PCI_EXP_SLTCTL_HPIE) && !pciehp_poll_mode)) { + pci_err(pdev, "ZOPA: %s hit: D3cold. Exiting", __func__); return IRQ_NONE; + } /* * Keep the port accessible by holding a runtime PM ref on its parent. @@ -536,6 +554,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) pm_runtime_put(parent); disable_irq_nosync(irq); atomic_or(RERUN_ISR, &ctrl->pending_events); + pci_err(pdev, "ZOPA: %s: parent rerun. Wake thread", __func__); return IRQ_WAKE_THREAD; } } @@ -556,6 +575,11 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC); + if (status) + print_slot_status(pdev, status & ~events, "Status"); + + print_slot_status(pdev, events, "Events"); + /* * If we've already reported a power fault, don't report it again * until we've done something to handle it. @@ -566,6 +590,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) if (!events) { if (parent) pm_runtime_put(parent); + pci_err(pdev, "ZOPA: %s No events detected.", __func__); return IRQ_NONE; } @@ -584,6 +609,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) wake_up(&ctrl->queue); if (events == PCI_EXP_SLTSTA_CC) + pci_err(pdev, "ZOPA: %s command completed. Done.", __func__); return IRQ_HANDLED; events &= ~PCI_EXP_SLTSTA_CC; @@ -594,8 +620,12 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) return IRQ_HANDLED; } + if (events) + print_slot_status(pdev, events, "Queued up"); + /* Save pending events for consumption by IRQ thread. */ atomic_or(events, &ctrl->pending_events); + pci_err(pdev, "ZOPA: %s: exiting", __func__); return IRQ_WAKE_THREAD; } @@ -614,6 +644,7 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) enable_irq(irq); if (ret != IRQ_WAKE_THREAD) { pci_config_pm_runtime_put(pdev); + pci_err(pdev, "ZOPA: %s ZAFUQ %d", __func__, ret); return ret; } } @@ -622,9 +653,12 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) events = atomic_xchg(&ctrl->pending_events, 0); if (!events) { pci_config_pm_runtime_put(pdev); + pci_err(pdev, "ZOPA: %s No events to handle", __func__); return IRQ_NONE; } + print_slot_status(pdev, events, "pciehp_ist: Entered with events"); + /* Check Attention Button Pressed */ if (events & PCI_EXP_SLTSTA_ABP) { ctrl_info(ctrl, "Slot(%s): Attention button pressed\n", @@ -653,6 +687,7 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) pci_config_pm_runtime_put(pdev); wake_up(&ctrl->requester); + pci_err(pdev, "ZOPA: %s handled", __func__); return IRQ_HANDLED; }