Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3699625imm; Mon, 18 Jun 2018 02:32:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK+itDdAB8+mDjeqOZPZaFd5GcNh2Nam+PVT4W99w3/RJbET5OGJVHX0KUBurZ+jB6hFY9d X-Received: by 2002:a17:902:1025:: with SMTP id b34-v6mr13385348pla.207.1529314370883; Mon, 18 Jun 2018 02:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529314370; cv=none; d=google.com; s=arc-20160816; b=dUxpA1RBOGIXCzmirgjdztGJW2qIzZOOTNxCzFeDnH8vm3Lg2OSlry4KSSmfbQpbiK 2kAU13NoO1D4KZIINDiDwq20XIzC4Gyqj0TWxzCun6/OoDD3VAhNVeThHGDaeRBGKMS0 PXXLwL5z1suHay3HlB5UDg/AQozAQCWplh4UPcPFYzz6SW9ueaaT8DkMWVIUzMrUiQ4R tIfhv85fCES4Nm08DOlQETEpYzSpEfx5wzCvZqJWV5WTXAdhZdMu7HUklGj6dSZrtZsp 0Pq0gyx7nqv1HkrBcYhVOJ8ztzhLXD/sgw1LBvMuIYHJXFUEnSKIHYIMFkKz0GJYjJb6 uEQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+4XJqRIF57z8Hl5PIKINg5ObKL6VVwWmoHLB+lIUaNI=; b=cZAXip/cmsyH/XY4h5r6x5LKpGLzaDpto4PbEKZ3NcW9pFbuw0jesNFsuBMGApG7XQ 1YLFHydeHzBMoqNQB/oT2QrC4iPsoMQdb4oa1SkNEk3m7oRC37Wu4ouXTpcvUvvbjRHZ UtqRVHnstZV+S1coDVIQBC95aVFlTgR4qNuVp2Ps5L34lwuPRA6sq0uAmvhmxIWyR8Ma VSKD7Y4UbBeec/lM9ZzqVrFXju5Re7t5BFqNf0jfweINO8kFocAIrSXJE30xkYGeRbv0 G9S7AIqhX1evt6adai1HMmrZDQe/ETBCzDx3sR6x5mB09Sjp4I3nRxt800KKjTUTvFum H8aA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d31-v6si15066316pld.23.2018.06.18.02.32.37; Mon, 18 Jun 2018 02:32:50 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936274AbeFRIYw (ORCPT + 99 others); Mon, 18 Jun 2018 04:24:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56112 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936091AbeFRIYs (ORCPT ); Mon, 18 Jun 2018 04:24:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CDDAEBAD; Mon, 18 Jun 2018 08:24:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Long, Nicholas" , Igor Russkikh , "David S. Miller" , Sasha Levin Subject: [PATCH 4.16 203/279] net: aquantia: Limit number of vectors to actually allocated irqs Date: Mon, 18 Jun 2018 10:13:08 +0200 Message-Id: <20180618080617.297253514@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Igor Russkikh [ Upstream commit a09bd81b5413d1b4d705c6c5303b5d311069da22 ] Driver should use pci_alloc_irq_vectors return value to correct number of allocated vectors and napi instances. Otherwise it'll panic later in pci_irq_vector. Driver also should allow more than one MSI vectors to be allocated. Error return path from pci_alloc_irq_vectors is also fixed to revert resources in a correct sequence when error happens. Reported-by: Long, Nicholas Fixes: 23ee07a ("net: aquantia: Cleanup pci functions module") Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 1 drivers/net/ethernet/aquantia/atlantic/aq_nic.h | 1 drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 20 +++++++++---------- 3 files changed, 12 insertions(+), 10 deletions(-) --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c @@ -95,6 +95,7 @@ void aq_nic_cfg_start(struct aq_nic_s *s /*rss rings */ cfg->vecs = min(cfg->aq_hw_caps->vecs, AQ_CFG_VECS_DEF); cfg->vecs = min(cfg->vecs, num_online_cpus()); + cfg->vecs = min(cfg->vecs, self->irqvecs); /* cfg->vecs should be power of 2 for RSS */ if (cfg->vecs >= 8U) cfg->vecs = 8U; --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h @@ -80,6 +80,7 @@ struct aq_nic_s { struct pci_dev *pdev; unsigned int msix_entry_mask; + u32 irqvecs; }; static inline struct device *aq_nic_get_dev(struct aq_nic_s *self) --- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c @@ -267,16 +267,16 @@ static int aq_pci_probe(struct pci_dev * numvecs = min(numvecs, num_online_cpus()); /*enable interrupts */ #if !AQ_CFG_FORCE_LEGACY_INT - err = pci_alloc_irq_vectors(self->pdev, numvecs, numvecs, - PCI_IRQ_MSIX); - - if (err < 0) { - err = pci_alloc_irq_vectors(self->pdev, 1, 1, - PCI_IRQ_MSI | PCI_IRQ_LEGACY); - if (err < 0) - goto err_hwinit; + numvecs = pci_alloc_irq_vectors(self->pdev, 1, numvecs, + PCI_IRQ_MSIX | PCI_IRQ_MSI | + PCI_IRQ_LEGACY); + + if (numvecs < 0) { + err = numvecs; + goto err_hwinit; } #endif + self->irqvecs = numvecs; /* net device init */ aq_nic_cfg_start(self); @@ -298,9 +298,9 @@ err_free_aq_hw: kfree(self->aq_hw); err_ioremap: free_netdev(ndev); -err_pci_func: - pci_release_regions(pdev); err_ndev: + pci_release_regions(pdev); +err_pci_func: pci_disable_device(pdev); return err; }