From patchwork Wed Oct 11 08:44:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 115525 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp390415edb; Wed, 11 Oct 2017 01:45:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCWRWSrjGLnzRlZtLDZY+M3kAfF3s5XvLczwenVuk0ahjJGlHHZlTHpTCjrzvzP2FhOrtA0 X-Received: by 10.84.137.129 with SMTP id 1mr14980023pln.376.1507711558563; Wed, 11 Oct 2017 01:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507711558; cv=none; d=google.com; s=arc-20160816; b=QPQiKp21AE08p06vJikZnUxUV1sPjVwTe4Vcc1Q1TCQ9JgdPAAGesalaSrrTZUuSBe PM426FD4ohioUlqWJCN+yugO30N3sfce99c1PmKrNTJfeOhJl4lmRjpIuge/y1uNgtLx H5mXu3Uz2aWP5MbEWr8ynEMDJxlOTXRR2yPC1nIJCyS+h2pe4y3umIJsO6S4STSmdtSr PFNAzayRLsr2n+5NiVDhS+8BdCSAFeV+PSga0lNc3mnRSpgbsNXC7rcFGLIrudWbcayn DeTlGIKEgRxFFSVSCE0LMe7iYdQdPaYg5wS3aPytXbjYHkwTB2FQX79ujmfMebINZQ03 ZPMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=77TKev0JrNx+UbnS8SBBEK6Vug8DcQv957RLKZUSy2M=; b=PqgkdG5FVHW5ThXb5EkCLKRXC0axiU1rBUEm8E1ty70ygCHsAB3cd8ZiLDEJH4uxri kMlQzHeRNpFBJ1+fVw48hj07uOFJ7DFG+jfNaIjSM4yXk3CESpUO3zuYjSynG6EKA5uR 5MM6l/Cah7KeThTCaw9XeXFhHdM1hwF6K8YCX4RUcfIrLhL7K/X+H8KlwgS8tUq44t40 eVN9mje9qppwIUW0KojDdWybSK6yuU3uwldrpqggvVrY6XdGtjmIVyXdrxqwnnaUJxIA U4oAdJDSnBtOw/lsw4H96PytCzf2FESrFEcK0wErkg1d2/MHe8QZCzq2egRNCCdwwNWl Fr0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hOJsMI3T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si10315528plp.471.2017.10.11.01.45.58; Wed, 11 Oct 2017 01:45:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=hOJsMI3T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757345AbdJKIpz (ORCPT + 26 others); Wed, 11 Oct 2017 04:45:55 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:18521 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757317AbdJKIpb (ORCPT ); Wed, 11 Oct 2017 04:45:31 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v9B8iwLI008509; Wed, 11 Oct 2017 03:44:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1507711498; bh=sYkmQ3U2A+2hYFLaaV4nmHBFP+WPQz70s0Ek/fhDES8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hOJsMI3T2J7KElo0SIhwtt0v7+PKZt+P3s+xdNFFWmRdvFAS38TcbqvEKc2CtSv6E T555Q8krw6bqNJpoJ2TzUAmQ2uV4wDBw26nPE+1V03PACJsBzPGJhDsdwSOILnaYmL R4S5GM81hUXAkbgDcqZi44ceL0ukinDZ2tezTmhA= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9B8irCJ018024; Wed, 11 Oct 2017 03:44:53 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Wed, 11 Oct 2017 03:44:53 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Wed, 11 Oct 2017 03:44:53 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9B8ih2s019232; Wed, 11 Oct 2017 03:44:51 -0500 From: Kishon Vijay Abraham I To: Arnd Bergmann , Greg Kroah-Hartman , Kishon Vijay Abraham I CC: , , , Subject: [PATCH 3/3] misc: pci_endpoint_test: Fix BUG_ON error during pci_disable_msi Date: Wed, 11 Oct 2017 14:14:38 +0530 Message-ID: <20171011084438.8296-4-kishon@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171011084438.8296-1-kishon@ti.com> References: <20171011084438.8296-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pci_disable_msi throws a Kernel BUG if the driver has successfully requested an irq and not released it. Fix it here by freeing irqs before invoking pci_disable_msi. Signed-off-by: Kishon Vijay Abraham I --- drivers/misc/pci_endpoint_test.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.11.0 diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 5cb624b6fa0a..086a7f85c2c0 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -92,6 +92,7 @@ struct pci_endpoint_test { void __iomem *bar[6]; struct completion irq_raised; int last_irq; + int num_irqs; /* mutex to protect the ioctls */ struct mutex mutex; struct miscdevice miscdev; @@ -504,6 +505,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, irq = pci_alloc_irq_vectors(pdev, 1, 32, PCI_IRQ_MSI); if (irq < 0) dev_err(dev, "failed to get MSI interrupts\n"); + test->num_irqs = irq; } err = devm_request_irq(dev, pdev->irq, pci_endpoint_test_irqhandler, @@ -578,6 +580,9 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, pci_iounmap(pdev, test->bar[bar]); } + for (i = 0; i < irq; i++) + devm_free_irq(dev, pdev->irq + i, test); + err_disable_msi: pci_disable_msi(pdev); pci_release_regions(pdev); @@ -591,6 +596,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, static void pci_endpoint_test_remove(struct pci_dev *pdev) { int id; + int i; enum pci_barno bar; struct pci_endpoint_test *test = pci_get_drvdata(pdev); struct miscdevice *misc_device = &test->miscdev; @@ -605,6 +611,8 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev) if (test->bar[bar]) pci_iounmap(pdev, test->bar[bar]); } + for (i = 0; i < test->num_irqs; i++) + devm_free_irq(&pdev->dev, pdev->irq + i, test); pci_disable_msi(pdev); pci_release_regions(pdev); pci_disable_device(pdev);