From patchwork Tue Oct 7 07:00:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkat Duvvuru X-Patchwork-Id: 5043671 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 88A67C11AB for ; Tue, 7 Oct 2014 07:02:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC3D420172 for ; Tue, 7 Oct 2014 07:02:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A367E20120 for ; Tue, 7 Oct 2014 07:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752497AbaJGHCd (ORCPT ); Tue, 7 Oct 2014 03:02:33 -0400 Received: from cmexedge1.emulex.com ([138.239.224.99]:32506 "EHLO CMEXEDGE1.ext.emulex.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751214AbaJGHCd (ORCPT ); Tue, 7 Oct 2014 03:02:33 -0400 Received: from CMEXHTCAS1.ad.emulex.com (138.239.115.217) by CMEXEDGE1.ext.emulex.com (138.239.224.99) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 7 Oct 2014 00:02:07 -0700 Received: from Hp-G7-54.localdomain (10.192.238.54) by smtp.emulex.com (138.239.115.207) with Microsoft SMTP Server id 14.3.174.1; Tue, 7 Oct 2014 00:01:59 -0700 From: Venkat Duvvuru To: CC: Venkat Duvvuru Subject: [PATCH] pci: Limit VPD length of Emulex adapters to the actual length supported. Date: Tue, 7 Oct 2014 12:30:06 +0530 X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 Message-ID: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 By default pci utilities/subsystem tries to read 32k bytes of vpd data no matter what the device supports. This can lead to unexpected behavior depending on how each of the devices handle this condition. This patch fixes the problem for Emulex adapter family. Signed-off-by: Venkat Duvvuru --- drivers/pci/quirks.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 17 +++++++++++++++++ 2 files changed, 52 insertions(+), 0 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 80c2d01..21b439f 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -3832,3 +3832,38 @@ void pci_dev_specific_enable_acs(struct pci_dev *dev) } } } + +#define SLI_INTF_REG_OFFSET 0x58 +#define SLI_INTF_FT_MASK 0x00000001 +static void quirk_elx_limit_vpd(struct pci_dev *dev) +{ + int virtfn; + u32 sli_intf; + + pci_read_config_dword(dev, SLI_INTF_REG_OFFSET, &sli_intf); + virtfn = (sli_intf & SLI_INTF_FT_MASK) ? 1 : 0; + + if (dev->vpd) { + if (virtfn) + dev->vpd->len = 0x200; + else + dev->vpd->len = 0x400; + } +} + +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BE, PCI_DEVICE_ID_BE_ID1, + quirk_elx_limit_vpd); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BE, PCI_DEVICE_ID_BE_ID2, + quirk_elx_limit_vpd); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BE, PCI_DEVICE_ID_OC_BE2, + quirk_elx_limit_vpd); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BE, PCI_DEVICE_ID_OC_BE3, + quirk_elx_limit_vpd); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_OC_LANCER, + quirk_elx_limit_vpd); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_OC_VF_LANCER, + quirk_elx_limit_vpd); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_OC_SKYHAWK, + quirk_elx_limit_vpd); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_OC_VF_SKYHAWK, + quirk_elx_limit_vpd); diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 6ed0bb7..888041d 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2971,4 +2971,21 @@ #define PCI_VENDOR_ID_OCZ 0x1b85 +#define PCI_VENDOR_ID_BE 0x19a2 +#define PCI_VENDOR_ID_EMULEX 0x10df +#define PCI_DEVICE_ID_BE_ID1 0x211 +#define PCI_DEVICE_ID_BE_ID2 0x221 +/* Device Id for BE2 cards */ +#define PCI_DEVICE_ID_OC_BE2 0x700 +/* Device Id for BE3 cards */ +#define PCI_DEVICE_ID_OC_BE3 0x710 +/* Device id for Lancer cards */ +#define PCI_DEVICE_ID_OC_LANCER 0xe220 +/* Device id for VF in Lancer */ +#define PCI_DEVICE_ID_OC_VF_LANCER 0xe228 +/* Device id for SkyHawk cards */ +#define PCI_DEVICE_ID_OC_SKYHAWK 0x720 +/* Device id for VF in SkyHawk */ +#define PCI_DEVICE_ID_OC_VF_SKYHAWK 0x728 + #endif /* _LINUX_PCI_IDS_H */