From patchwork Wed Feb 19 08:58:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Gordeev X-Patchwork-Id: 3679331 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AB736BF13A for ; Wed, 19 Feb 2014 08:57:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BDE49201BA for ; Wed, 19 Feb 2014 08:57:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8E7920035 for ; Wed, 19 Feb 2014 08:57:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753219AbaBSI4p (ORCPT ); Wed, 19 Feb 2014 03:56:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48402 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753138AbaBSI4o (ORCPT ); Wed, 19 Feb 2014 03:56:44 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1J8ueix016313 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Feb 2014 03:56:40 -0500 Received: from dhcp-26-207.brq.redhat.com (vpn-55-192.rdu2.redhat.com [10.10.55.192]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1J8uOYv003605; Wed, 19 Feb 2014 03:56:39 -0500 From: Alexander Gordeev To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Jens Axboe , Bartlomiej Zolnierkiewicz , Kyungmin Park , linux-pci@vger.kernel.org Subject: [PATCH 7/9] skd: Fix incomplete cleanup of MSI-X interrupt Date: Wed, 19 Feb 2014 09:58:19 +0100 Message-Id: <554eac1b5dc4852f4a8c92f07d6c06d12f1c3f13.1392799752.git.agordeev@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.5 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 When enabling MSI-X interrupts fails due to lack of memory the call to pci_disable_msix() is missed and the device is left with MSI-X interrupts enabled while the driver assumes otherwise. This update fixes the described misbehaviour and cleans up the code of skd_release_msix() function. Signed-off-by: Alexander Gordeev Cc: Jens Axboe Cc: Bartlomiej Zolnierkiewicz Cc: Kyungmin Park Cc: linux-pci@vger.kernel.org --- drivers/block/skd_main.c | 50 +++++++++++++++++++++++---------------------- 1 files changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index 3fa0918..d0550ba 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -3910,43 +3910,44 @@ static void skd_release_msix(struct skd_device *skdev) struct skd_msix_entry *qentry; int i; - if (skdev->msix_entries == NULL) - return; - for (i = 0; i < skdev->msix_count; i++) { - qentry = &skdev->msix_entries[i]; - skdev = qentry->rsp; + if (skdev->msix_entries) { + for (i = 0; i < skdev->msix_count; i++) { + qentry = &skdev->msix_entries[i]; + skdev = qentry->rsp; + + if (qentry->have_irq) + devm_free_irq(&skdev->pdev->dev, + qentry->vector, qentry->rsp); + } - if (qentry->have_irq) - devm_free_irq(&skdev->pdev->dev, - qentry->vector, qentry->rsp); + kfree(skdev->msix_entries); } - pci_disable_msix(skdev->pdev); - kfree(skdev->msix_entries); + + if (skdev->msix_count) + pci_disable_msix(skdev->pdev); + skdev->msix_count = 0; skdev->msix_entries = NULL; } static int skd_acquire_msix(struct skd_device *skdev) { - int i, rc; - struct pci_dev *pdev; - struct msix_entry *entries = NULL; + int i, rc, msix_count = SKD_MAX_MSIX_COUNT; + struct pci_dev *pdev = skdev->pdev; + struct msix_entry *entries; struct skd_msix_entry *qentry; - pdev = skdev->pdev; - skdev->msix_count = SKD_MAX_MSIX_COUNT; - entries = kzalloc(sizeof(struct msix_entry) * SKD_MAX_MSIX_COUNT, - GFP_KERNEL); + entries = kzalloc(sizeof(struct msix_entry) * msix_count, GFP_KERNEL); if (!entries) return -ENOMEM; - for (i = 0; i < SKD_MAX_MSIX_COUNT; i++) + for (i = 0; i < msix_count; i++) entries[i].entry = i; - rc = pci_enable_msix(pdev, entries, SKD_MAX_MSIX_COUNT); + rc = pci_enable_msix(pdev, entries, msix_count); if (rc < 0) goto msix_out; - if (rc) { + else if (rc) { if (rc < SKD_MIN_MSIX_COUNT) { pr_err("(%s): failed to enable MSI-X %d\n", skd_name(skdev), rc); @@ -3956,20 +3957,21 @@ static int skd_acquire_msix(struct skd_device *skdev) skdev->name, __func__, __LINE__, pci_name(pdev), skdev->name, rc); - skdev->msix_count = rc; - rc = pci_enable_msix(pdev, entries, skdev->msix_count); + msix_count = rc; + rc = pci_enable_msix(pdev, entries, msix_count); if (rc) { pr_err("(%s): failed to enable MSI-X " "support (%d) %d\n", - skd_name(skdev), skdev->msix_count, rc); + skd_name(skdev), msix_count, rc); goto msix_out; } } + + skdev->msix_count = msix_count; skdev->msix_entries = kzalloc(sizeof(struct skd_msix_entry) * skdev->msix_count, GFP_KERNEL); if (!skdev->msix_entries) { rc = -ENOMEM; - skdev->msix_count = 0; pr_err("(%s): msix table allocation error\n", skd_name(skdev)); goto msix_out;