From patchwork Tue Oct 20 09:11:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 7444201 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0A96ABEEA4 for ; Tue, 20 Oct 2015 09:13:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DC442081A for ; Tue, 20 Oct 2015 09:13:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C1B32080D for ; Tue, 20 Oct 2015 09:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752476AbbJTJNA (ORCPT ); Tue, 20 Oct 2015 05:13:00 -0400 Received: from mga09.intel.com ([134.134.136.24]:38659 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751729AbbJTJLq (ORCPT ); Tue, 20 Oct 2015 05:11:46 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 20 Oct 2015 02:11:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,706,1437462000"; d="scan'208";a="831065168" Received: from black.fi.intel.com ([10.237.72.93]) by fmsmga002.fm.intel.com with ESMTP; 20 Oct 2015 02:11:44 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 820477F; Tue, 20 Oct 2015 12:11:42 +0300 (EEST) From: Andy Shevchenko To: linux-spi@vger.kernel.org, Mark Brown Cc: Andy Shevchenko , stable@vger.kernel.org Subject: [PATCH v3 1/2] spi: dw: explicitly free IRQ handler in dw_spi_remove_host() Date: Tue, 20 Oct 2015 12:11:40 +0300 Message-Id: <1445332301-15126-2-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1445332301-15126-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1445332301-15126-1-git-send-email-andriy.shevchenko@linux.intel.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The following warning occurs when DW SPI is compiled as a module and it's a PCI device. On the removal stage pcibios_free_irq() is called earlier than free_irq() due to the latter is called at managed resources free strage. ------------[ cut here ]------------ WARNING: CPU: 1 PID: 1003 at /home/andy/prj/linux/fs/proc/generic.c:575 remove_proc_entry+0x118/0x150() remove_proc_entry: removing non-empty directory 'irq/38', leaking at least 'dw_spi1' Modules linked in: spi_dw_midpci(-) spi_dw [last unloaded: dw_dmac_core] CPU: 1 PID: 1003 Comm: modprobe Not tainted 4.3.0-rc5-next-20151013+ #32 00000000 00000000 f5535d70 c12dc220 f5535db0 f5535da0 c104e912 c198a6bc f5535dcc 000003eb c198a638 0000023f c11b4098 c11b4098 f54f1ec8 f54f1ea0 f642ba20 f5535db8 c104e96e 00000009 f5535db0 c198a6bc f5535dcc f5535df0 Call Trace: [] dump_stack+0x41/0x61 [] warn_slowpath_common+0x82/0xb0 [] ? remove_proc_entry+0x118/0x150 [] ? remove_proc_entry+0x118/0x150 [] warn_slowpath_fmt+0x2e/0x30 [] remove_proc_entry+0x118/0x150 [] unregister_irq_proc+0xaa/0xc0 [] free_desc+0x1e/0x60 [] irq_free_descs+0x32/0x70 [] irq_domain_free_irqs+0x120/0x150 [] mp_unmap_irq+0x5c/0x60 [] intel_mid_pci_irq_disable+0x20/0x40 [] pcibios_free_irq+0xf/0x20 [] pci_device_remove+0x52/0xb0 [] __device_release_driver+0x77/0x100 [] driver_detach+0x87/0x90 [] bus_remove_driver+0x4a/0xc0 [] ? selinux_capable+0xd/0x10 [] driver_unregister+0x23/0x60 [] ? find_module_all+0x5a/0x80 [] pci_unregister_driver+0x13/0x60 [] dw_spi_driver_exit+0xd/0xf [spi_dw_midpci] [] SyS_delete_module+0x17a/0x210 Explicitly call free_irq() at removal stage of the DW SPI driver. Fixes: 04f421e7b0b1 (spi: dw: use managed resources) Cc: stable@vger.kernel.org Signed-off-by: Andy Shevchenko --- drivers/spi/spi-dw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index a730c35..221ff97 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -486,8 +486,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60); snprintf(dws->name, sizeof(dws->name), "dw_spi%d", dws->bus_num); - ret = devm_request_irq(dev, dws->irq, dw_spi_irq, IRQF_SHARED, - dws->name, master); + ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, dws->name, master); if (ret < 0) { dev_err(dev, "can not get IRQ\n"); goto err_free_master; @@ -532,6 +531,7 @@ err_dma_exit: if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit(dws); spi_enable_chip(dws, 0); + free_irq(dws->irq, master); err_free_master: spi_master_put(master); return ret; @@ -548,6 +548,8 @@ void dw_spi_remove_host(struct dw_spi *dws) dws->dma_ops->dma_exit(dws); spi_shutdown_chip(dws); + + free_irq(dws->irq, dws->master); } EXPORT_SYMBOL_GPL(dw_spi_remove_host);