From patchwork Fri Feb 5 19:59:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sostalle X-Patchwork-Id: 8239191 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8FABB9F3CD for ; Fri, 5 Feb 2016 20:03:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B07B120384 for ; Fri, 5 Feb 2016 20:03:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 526A620390 for ; Fri, 5 Feb 2016 20:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755538AbcBEUC7 (ORCPT ); Fri, 5 Feb 2016 15:02:59 -0500 Received: from mga01.intel.com ([192.55.52.88]:44073 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754331AbcBEUC6 (ORCPT ); Fri, 5 Feb 2016 15:02:58 -0500 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 05 Feb 2016 12:02:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,401,1449561600"; d="scan'208";a="647867267" Received: from dev.jf.intel.com ([134.134.147.16]) by FMSMGA003.fm.intel.com with ESMTP; 05 Feb 2016 12:02:58 -0800 From: "Sean O. Stalley" To: linux-pci@vger.kernel.org, mj@ucw.cz, bhelgaas@google.com, alex.williamson@redhat.com Cc: sean.stalley@intel.com, david.daney@cavium.com Subject: [PATCH v3 2/2] Add support for enhanced allocation regions Date: Fri, 5 Feb 2016 11:59:05 -0800 Message-Id: <1454702345-4014-3-git-send-email-sean.stalley@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454702345-4014-1-git-send-email-sean.stalley@intel.com> References: <1454702345-4014-1-git-send-email-sean.stalley@intel.com> 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.2 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 Append [enhanced] to Regions that contain the BEI flag in sysfs. Don't tuncate least significant bits of the region size. ex: a 2000 byte region should display [size=2000] instead of [size=1K] Signed-off-by: Sean O. Stalley --- lib/header.h | 4 ++++ lib/pci.h | 2 ++ lib/sysfs.c | 5 ++++- lspci.c | 17 ++++++++++++++--- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/header.h b/lib/header.h index b8f7dc1..7b9a803 100644 --- a/lib/header.h +++ b/lib/header.h @@ -1235,3 +1235,7 @@ #define PCI_VENDOR_ID_INTEL 0x8086 #define PCI_VENDOR_ID_COMPAQ 0x0e11 + +/* taken from */ + +#define IORESOURCE_PCI_EA_BEI (1<<5) diff --git a/lib/pci.h b/lib/pci.h index 9c1e281..a88e156 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -129,8 +129,10 @@ struct pci_dev { int irq; /* IRQ number */ pciaddr_t base_addr[6]; /* Base addresses including flags in lower bits */ pciaddr_t size[6]; /* Region sizes */ + pciaddr_t flags[6]; /* Region flags */ pciaddr_t rom_base_addr; /* Expansion ROM base address */ pciaddr_t rom_size; /* Expansion ROM size */ + pciaddr_t rom_flags; /* Expansion ROM flags */ struct pci_cap *first_cap; /* List of capabilities */ char *phy_slot; /* Physical slot */ char *module_alias; /* Linux kernel module alias */ diff --git a/lib/sysfs.c b/lib/sysfs.c index 986ecc9..e900e3a 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -153,14 +153,17 @@ sysfs_get_resources(struct pci_dev *d) size = end - start + 1; else size = 0; - flags &= PCI_ADDR_FLAG_MASK; if (i < 6) { + d->flags[i] = flags; + flags &= PCI_ADDR_FLAG_MASK; d->base_addr[i] = start | flags; d->size[i] = size; } else { + d->rom_flags = flags; + flags &= PCI_ADDR_FLAG_MASK; d->rom_base_addr = start | flags; d->rom_size = size; } diff --git a/lspci.c b/lspci.c index fe7b7fe..358bb34 100644 --- a/lspci.c +++ b/lspci.c @@ -336,7 +336,7 @@ show_size(pciaddr_t x) if (!x) return; for (i = 0; i < (sizeof(suffix) / sizeof(*suffix) - 1); i++) { - if (x < 1024) + if (x % 1024) break; x /= 1024; } @@ -364,7 +364,12 @@ show_bases(struct device *d, int cnt) printf("\tRegion %d: ", i); else putchar('\t'); - if (pos && !flg) /* Reported by the OS, but not by the device */ + + if (p->flags[i] & IORESOURCE_PCI_EA_BEI) + { + printf("[enhanced] "); + } + else if (pos && !flg) /* Reported by the OS, but not by the device */ { printf("[virtual] "); flg = pos; @@ -437,7 +442,13 @@ show_rom(struct device *d, int reg) if (!rom && !flg && !len) return; putchar('\t'); - if ((rom & PCI_ROM_ADDRESS_MASK) && !(flg & PCI_ROM_ADDRESS_MASK)) + + + if (p->rom_flags & IORESOURCE_PCI_EA_BEI) + { + printf("[enhanced] "); + } + else if ((rom & PCI_ROM_ADDRESS_MASK) && !(flg & PCI_ROM_ADDRESS_MASK)) { printf("[virtual] "); flg = rom;