From: Christoph Hellwig Date: Thu, 26 Nov 2015 11:35:49 +0000 (+0100) Subject: nvme: remove dead controllers from a work item X-Git-Tag: v4.1.12-102.0.20170601_1400~94 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4b0cce4c460eb9338a6ae0f0a62f49f96bc09492;p=users%2Fjedix%2Flinux-maple.git nvme: remove dead controllers from a work item Compared to the kthread this gives us multiple call prevention for free. Signed-off-by: Christoph Hellwig Signed-off-by: Keith Busch Signed-off-by: Jens Axboe (cherry picked from commit 5c8809e650772be87ba04595a8ccf278bab7b543) Orabug: 25130845 Signed-off-by: Ashok Vairavan Reviewed-by: Martin K. Petersen --- diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 781d8ec2cd1b1..21c1c460c46fa 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1922,19 +1922,26 @@ static void nvme_reset_work(struct work_struct *work) return; out: - nvme_remove_dead_ctrl(dev, result); + nvme_remove_dead_ctrl(dev); } -static int nvme_remove_dead_ctrl(void *arg) +static void nvme_remove_dead_ctrl_work(struct work_struct *work) { - struct nvme_dev *dev = (struct nvme_dev *)arg; + struct nvme_dev *dev = container_of(work, struct nvme_dev, remove_work); struct pci_dev *pdev = to_pci_dev(dev->dev); nvme_kill_queues(&dev->ctrl); if (pci_get_drvdata(pdev)) pci_stop_and_remove_bus_device_locked(pdev); nvme_put_ctrl(&dev->ctrl); - return 0; +} + +static void nvme_remove_dead_ctrl(struct nvme_dev *dev) +{ + dev_warn(dev->dev, "Removing after probe failure\n"); + kref_get(&dev->ctrl.kref); + if (!schedule_work(&dev->remove_work)) + nvme_put_ctrl(&dev->ctrl); } static int nvme_reset(struct nvme_dev *dev)