From 914119ad8746a2a61c4b04b58bef12a86f83e9a2 Mon Sep 17 00:00:00 2001 From: Xiongfeng Wang Date: Wed, 17 Jul 2019 18:44:40 +0800 Subject: [PATCH] Revert "pciehp: use completion to wait irq_thread 'pciehp_ist'" hulk inclusion category: bugfix bugzilla: NA CVE: NA ------------------- This reverts commit cdda3bbfd0cab7dea3cfb37e9a8648f945c0241d. If 'slot_being_removed_rescanned' is set, when we power off the slot through sysfs, the irq_thread 'pciehp_ist' will be woken up. But it will return immediately and schedule this thread 3 seconds later. However, sysfs write should wait until the actual operation is finished. We will power off the slot in 'power_write_file' instread of waking up a irq_thread. So this patch has no use. Let's revert it. A following patch will fix the issue. Signed-off-by: Xiongfeng Wang Reviewed-by: Yao Hongbo Signed-off-by: Yang Yingliang --- drivers/pci/hotplug/pciehp.h | 2 +- drivers/pci/hotplug/pciehp_ctrl.c | 8 ++++---- drivers/pci/hotplug/pciehp_hpc.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index c4d3b035f619..a4b294fddc93 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -126,7 +126,7 @@ struct controller { unsigned int power_fault_detected; atomic_t pending_events; int request_result; - struct completion requester; + wait_queue_head_t requester; }; /** diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index e12f62b234d4..b6274e58f95d 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -403,9 +403,9 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot) * card before the thread wakes up, so initialize to -ENODEV. */ ctrl->request_result = -ENODEV; - reinit_completion(&ctrl->requester); pciehp_request(ctrl, PCI_EXP_SLTSTA_PDC); - wait_for_completion(&ctrl->requester); + wait_event(ctrl->requester, + !atomic_read(&ctrl->pending_events)); return ctrl->request_result; case POWERON_STATE: ctrl_info(ctrl, "Slot(%s): Already in powering on state\n", @@ -436,9 +436,9 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot) case BLINKINGOFF_STATE: case ON_STATE: mutex_unlock(&p_slot->lock); - reinit_completion(&ctrl->requester); pciehp_request(ctrl, DISABLE_SLOT); - wait_for_completion(&ctrl->requester); + wait_event(ctrl->requester, + !atomic_read(&ctrl->pending_events)); return ctrl->request_result; case POWEROFF_STATE: ctrl_info(ctrl, "Slot(%s): Already in powering off state\n", diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 50d856f9534d..43bb78122795 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -739,7 +739,7 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) up_read(&ctrl->reset_lock); pci_config_pm_runtime_put(pdev); - complete(&ctrl->requester); + wake_up(&ctrl->requester); return IRQ_HANDLED; } @@ -953,7 +953,7 @@ struct controller *pcie_init(struct pcie_device *dev) ctrl->slot_cap = slot_cap; mutex_init(&ctrl->ctrl_lock); init_rwsem(&ctrl->reset_lock); - init_completion(&ctrl->requester); + init_waitqueue_head(&ctrl->requester); init_waitqueue_head(&ctrl->queue); dbg_ctrl(ctrl); -- GitLab