From patchwork Mon Aug 29 17:19:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Derrick X-Patchwork-Id: 9304179 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BEB196077C for ; Mon, 29 Aug 2016 17:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADCE728803 for ; Mon, 29 Aug 2016 17:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A245A2885B; Mon, 29 Aug 2016 17:20:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32D3F28803 for ; Mon, 29 Aug 2016 17:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751950AbcH2RUv (ORCPT ); Mon, 29 Aug 2016 13:20:51 -0400 Received: from mga11.intel.com ([192.55.52.93]:31786 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751223AbcH2RUu (ORCPT ); Mon, 29 Aug 2016 13:20:50 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP; 29 Aug 2016 10:20:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,597,1470726000"; d="scan'208";a="2359164" Received: from nsgse-neoncity01.lm.intel.com (HELO nsgse-neoncity01.localdomain) ([10.232.118.5]) by fmsmga006.fm.intel.com with ESMTP; 29 Aug 2016 10:20:49 -0700 From: Jon Derrick To: helgaas@kernel.org Cc: Jon Derrick , keith.busch@intel.com, linux-pci@vger.kernel.org Subject: [PATCH 1/2] vmd: allocate irq lists with correct msix count Date: Mon, 29 Aug 2016 11:19:01 -0600 Message-Id: <1472491142-13783-1-git-send-email-jonathan.derrick@intel.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To reduce the amount of memory required for irq lists, only allocate their space after calling pci_msix_enable_range which may reduce the number of msix vectors allocated. Signed-off-by: Jon Derrick Reviewed-by: Keith Busch --- arch/x86/pci/vmd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/pci/vmd.c b/arch/x86/pci/vmd.c index 8d6bb8a..514b446 100644 --- a/arch/x86/pci/vmd.c +++ b/arch/x86/pci/vmd.c @@ -679,11 +679,6 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id) if (vmd->msix_count < 0) return -ENODEV; - vmd->irqs = devm_kcalloc(&dev->dev, vmd->msix_count, sizeof(*vmd->irqs), - GFP_KERNEL); - if (!vmd->irqs) - return -ENOMEM; - vmd->msix_entries = devm_kcalloc(&dev->dev, vmd->msix_count, sizeof(*vmd->msix_entries), GFP_KERNEL); @@ -697,6 +692,11 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id) if (vmd->msix_count < 0) return vmd->msix_count; + vmd->irqs = devm_kcalloc(&dev->dev, vmd->msix_count, sizeof(*vmd->irqs), + GFP_KERNEL); + if (!vmd->irqs) + return -ENOMEM; + for (i = 0; i < vmd->msix_count; i++) { INIT_LIST_HEAD(&vmd->irqs[i].irq_list); vmd->irqs[i].vmd_vector = vmd->msix_entries[i].vector;