From c5946f9d286ad368329c79107fdf4d825d2091bd Mon Sep 17 00:00:00 2001 From: Jiang Liu Date: Mon, 21 Jul 2014 10:17:44 +0800 Subject: [PATCH] USB: core: hcd-pci: free IRQ before disabling PCI device when shutting down The assigned IRQ should be freed before calling pci_disable_device() when shutting down system, otherwise it will cause following warning. [ 568.879482] ------------[ cut here ]------------ [ 568.884236] WARNING: CPU: 1 PID: 3300 at /home/konrad/ssd/konrad/xtt-i386/bootstrap/linux-usb/fs/proc/generic.c:521 remove_proc_entry+0x165/0x170() [ 568.897846] remove_proc_entry: removing non-empty directory 'irq/16', leaking at least 'ohci_hcd:usb4' [ 568.907430] Modules linked in: dm_multipath dm_mod iscsi_boot_sysfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi libcrc32c crc32c_generic sg sd_mod crct10dif_generic crc_t10dif crct10dif_common radeon fbcon tileblit ttm font bitblit softcursor ata_generic ahci libahci drm_kms_helper skge r8169 libata mii scsi_mod wmi acpi_cpufreq [ 568.938539] CPU: 1 PID: 3300 Comm: init Tainted: G W 3.16.0-rc5upstream-01651-g03b9189 #1 [ 568.947946] Hardware name: ECS A780GM-A Ultra/A780GM-A Ultra, BIOS 080015 04/01/2010 [ 568.956008] 00000209 ed0f1cd0 c1617946 c175403c ed0f1d00 c1090c3f c1754084 ed0f1d2c [ 568.964068] 00000ce4 c175403c 00000209 c11f22a5 c11f22a5 f755e8c0 ed0f1d78 f755e90d [ 568.972128] ed0f1d18 c1090cde 00000009 ed0f1d10 c1754084 ed0f1d2c ed0f1d60 c11f22a5 [ 568.980194] Call Trace: [ 568.982715] [] dump_stack+0x48/0x60 [ 568.987294] [] warn_slowpath_common+0x7f/0xa0 [ 569.003887] [] warn_slowpath_fmt+0x2e/0x30 [ 569.009092] [] remove_proc_entry+0x165/0x170 [ 569.014476] [] unregister_irq_proc+0xaa/0xc0 [ 569.019858] [] free_desc+0x1f/0x60 [ 569.024346] [] irq_free_descs+0x3a/0x80 [ 569.029283] [] irq_dispose_mapping+0x2d/0x50 [ 569.034666] [] mp_unmap_irq+0x73/0xa0 [ 569.039423] [] acpi_unregister_gsi_ioapic+0x2b/0x40 [ 569.045431] [] acpi_unregister_gsi+0xf/0x20 [ 569.050725] [] acpi_pci_irq_disable+0x4b/0x50 [ 569.056196] [] pcibios_disable_device+0x18/0x20 [ 569.061848] [] do_pci_disable_device+0x4d/0x60 [ 569.067410] [] pci_disable_device+0x47/0xb0 [ 569.077814] [] usb_hcd_pci_shutdown+0x31/0x40 [ 569.083285] [] pci_device_shutdown+0x19/0x50 [ 569.088667] [] device_shutdown+0x14/0x120 [ 569.093777] [] kernel_restart_prepare+0x2d/0x30 [ 569.099429] [] kernel_restart+0xe/0x60 [ 569.109028] [] SYSC_reboot+0x191/0x220 [ 569.159269] [] SyS_reboot+0x1a/0x20 [ 569.163843] [] sysenter_do_call+0x12/0x16 [ 569.168951] ---[ end trace ccc1ec4471c289c9 ]--- Tested-by: Aaron Lu Signed-off-by: Jiang Liu Reviewed-by: Huang Rui Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd-pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 82044b5d6113..efc953119ce2 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -380,6 +380,8 @@ void usb_hcd_pci_shutdown(struct pci_dev *dev) if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && hcd->driver->shutdown) { hcd->driver->shutdown(hcd); + if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0) + free_irq(hcd->irq, hcd); pci_disable_device(dev); } } -- 2.20.1