From patchwork Thu Apr 4 11:39:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 233735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0B7C52C00A6 for ; Thu, 4 Apr 2013 22:39:46 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759344Ab3DDLjn (ORCPT ); Thu, 4 Apr 2013 07:39:43 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:58966 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758672Ab3DDLjm (ORCPT ); Thu, 4 Apr 2013 07:39:42 -0400 Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 4 Apr 2013 05:39:41 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 4 Apr 2013 05:39:40 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 8BECC3E40040 for ; Thu, 4 Apr 2013 05:39:26 -0600 (MDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r34Bdc7a331286 for ; Thu, 4 Apr 2013 05:39:38 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r34Bdbnc017989 for ; Thu, 4 Apr 2013 05:39:38 -0600 Received: from shangw ([9.125.30.207]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r34BdaPb017920; Thu, 4 Apr 2013 05:39:37 -0600 Received: by shangw (Postfix, from userid 1000) id 56E143019C0; Thu, 4 Apr 2013 19:39:35 +0800 (CST) From: Gavin Shan To: linux-pci@vger.kernel.org Cc: bhelgaas@google.com, Gavin Shan Subject: [PATCH 2/5] PCI: Use MSI/MSI-X cap cache in pci_msi_check_device() Date: Thu, 4 Apr 2013 19:39:29 +0800 Message-Id: <1365075572-20763-3-git-send-email-shangw@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1365075572-20763-1-git-send-email-shangw@linux.vnet.ibm.com> References: <1365075572-20763-1-git-send-email-shangw@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13040411-4834-0000-0000-000005729513 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The function pci_msi_check_device() is called while enabling MSI or MSI-X interrupts to make sure the PCI device can support MSI or MSI-X capability. The patch changes the function for a bit to use the cached MSI or MSI-X capability in pci_dev instead of polling them from config space. Signed-off-by: Gavin Shan --- drivers/pci/msi.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 3459bdf..5f51e10 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -772,6 +772,11 @@ static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type) if (!pci_msi_enable || !dev || dev->no_msi) return -EINVAL; + /* Check if the PCI device has MSI or MSI-X capability */ + if ((type == PCI_CAP_ID_MSI && !dev->msi_cap) || + (type == PCI_CAP_ID_MSIX && !dev->msix_cap)) + return -EINVAL; + /* * You can't ask to have 0 or less MSIs configured. * a) it's stupid .. @@ -795,9 +800,6 @@ static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type) if (ret) return ret; - if (!pci_find_capability(dev, type)) - return -EINVAL; - return 0; }