From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Yinghai Lu To: Bjorn Helgaas Cc: "Rafael J. Wysocki" , Paul Gortmaker , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu , stable@vger.kernel.org Subject: [PATCH] PCI/PME: Restore pcie_pme_driver.remove Date: Tue, 14 Feb 2017 21:17:48 -0800 Message-Id: <20170215051748.3346-1-yinghai@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: Found 4.9 and later, removing pci device for pcie port via /sys failed: ------------[ cut here ]------------ kernel BUG at drivers/pci/msi.c:370! invalid opcode: 0000 [#1] SMP Modules linked in: CPU: 1 PID: 14509 Comm: sh Tainted: G W 4.8.0-rc1-yh-00012-gd29438d RIP: 0010:[] free_msi_irqs+0x65/0x190 ... Call Trace: [] pci_disable_msi+0x34/0x40 [] cleanup_service_irqs+0x27/0x30 [] pcie_port_device_remove+0x2a/0x40 [] pcie_portdrv_remove+0x40/0x50 [] pci_device_remove+0x4b/0xc0 [] __device_release_driver+0xb6/0x150 [] device_release_driver+0x25/0x40 [] pci_stop_bus_device+0x74/0xa0 [] pci_stop_and_remove_bus_device_locked+0x1a/0x30 [] remove_store+0x50/0x70 [] dev_attr_store+0x18/0x30 [] sysfs_kf_write+0x44/0x60 [] kernfs_fop_write+0x10e/0x190 [] __vfs_write+0x28/0x110 [] ? percpu_down_read+0x44/0x80 [] ? __sb_start_write+0xa7/0xe0 [] ? __sb_start_write+0xa7/0xe0 [] vfs_write+0xc4/0x180 [] SyS_write+0x49/0xa0 [] do_syscall_64+0xa6/0x1b0 [] entry_SYSCALL64_slow_path+0x25/0x25 ... RIP [] free_msi_irqs+0x65/0x190 RSP ---[ end trace f4505e1dac5b95d3 ]--- Segmentation fault Bisect to commit d7def2040077 ("PCI/PME: Make explicitly non-modular"). That commit did extra thing like remove the .remove for pcie_pme_driver. Put back pcie_pme_remove and restore to pcie_pme_driver fix the problem. Fixes: d7def2040077 ("PCI/PME: Make explicitly non-modular") Cc: Signed-off-by: Yinghai Lu diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index 7175293..2dd1c68 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c @@ -433,6 +433,17 @@ static int pcie_pme_resume(struct pcie_device *srv) return 0; } +/** + * pcie_pme_remove - Prepare PCIe PME service device for removal. + * @srv - PCIe service device to remove. + */ +static void pcie_pme_remove(struct pcie_device *srv) +{ + pcie_pme_suspend(srv); + free_irq(srv->irq, srv); + kfree(get_service_data(srv)); +} + static struct pcie_port_service_driver pcie_pme_driver = { .name = "pcie_pme", .port_type = PCI_EXP_TYPE_ROOT_PORT, @@ -441,6 +452,7 @@ static struct pcie_port_service_driver pcie_pme_driver = { .probe = pcie_pme_probe, .suspend = pcie_pme_suspend, .resume = pcie_pme_resume, + .remove = pcie_pme_remove, }; /**