From: Yu Zhao <yu.zhao@intel.com>
To: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Cc: "achiang@hp.com" <achiang@hp.com>,
"bjorn.helgaas@hp.com" <bjorn.helgaas@hp.com>,
"grundler@parisc-linux.org" <grundler@parisc-linux.org>,
"greg@kroah.com" <greg@kroah.com>,
"mingo@elte.hu" <mingo@elte.hu>,
"jbarnes@virtuousgeek.org" <jbarnes@virtuousgeek.org>,
"matthew@wil.cx" <matthew@wil.cx>,
"randy.dunlap@oracle.com" <randy.dunlap@oracle.com>,
"rdreier@cisco.com" <rdreier@cisco.com>,
"horms@verge.net.au" <horms@verge.net.au>,
"yinghai@kernel.org" <yinghai@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>
Subject: [PATCH 3/13 v7] PCI: define PCI resource names in an 'enum'
Date: Sat, 22 Nov 2008 02:39:32 +0800 [thread overview]
Message-ID: <20081121183932.GD7810@yzhao12-linux.sh.intel.com> (raw)
In-Reply-To: <20081121183605.GA7810@yzhao12-linux.sh.intel.com>
This patch moves all definitions of the PCI resource names to an 'enum',
and also replaces some hard-coded resource variables with symbol
names. This change eases introduction of device specific resources.
Signed-off-by: Yu Zhao <yu.zhao@intel.com>
---
drivers/pci/pci-sysfs.c | 4 +++-
drivers/pci/probe.c | 2 +-
drivers/pci/proc.c | 7 ++++---
include/linux/pci.h | 37 ++++++++++++++++++++++++-------------
4 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 5d72866..0d74851 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -101,11 +101,13 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
struct pci_dev * pci_dev = to_pci_dev(dev);
char * str = buf;
int i;
- int max = 7;
+ int max;
resource_size_t start, end;
if (pci_dev->subordinate)
max = DEVICE_COUNT_RESOURCE;
+ else
+ max = PCI_BRIDGE_RESOURCES;
for (i = 0; i < max; i++) {
struct resource *res = &pci_dev->resource[i];
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 003a9b3..4c5429f 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -423,7 +423,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
child->subordinate = 0xff;
/* Set up default resource pointers and names.. */
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) {
child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i];
child->resource[i]->name = child->name;
}
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index e1098c3..f6f2a59 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -352,15 +352,16 @@ static int show_device(struct seq_file *m, void *v)
dev->vendor,
dev->device,
dev->irq);
- /* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */
- for (i=0; i<7; i++) {
+
+ /* only print standard and ROM resources to preserve compatibility */
+ for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
resource_size_t start, end;
pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
seq_printf(m, "\t%16llx",
(unsigned long long)(start |
(dev->resource[i].flags & PCI_REGION_FLAG_MASK)));
}
- for (i=0; i<7; i++) {
+ for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
resource_size_t start, end;
pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
seq_printf(m, "\t%16llx",
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 7e7ff03..d455ec8 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -82,7 +82,30 @@ enum pci_mmap_state {
#define PCI_DMA_FROMDEVICE 2
#define PCI_DMA_NONE 3
-#define DEVICE_COUNT_RESOURCE 12
+/*
+ * For PCI devices, the region numbers are assigned this way:
+ */
+enum {
+ /* #0-5: standard PCI resources */
+ PCI_STD_RESOURCES,
+ PCI_STD_RESOURCE_END = 5,
+
+ /* #6: expansion ROM resource */
+ PCI_ROM_RESOURCE,
+
+ /* resources assigned to buses behind the bridge */
+#define PCI_BRIDGE_RESOURCE_NUM 4
+
+ PCI_BRIDGE_RESOURCES,
+ PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES +
+ PCI_BRIDGE_RESOURCE_NUM - 1,
+
+ /* total resources associated with a PCI device */
+ PCI_NUM_RESOURCES,
+
+ /* preserve this for compatibility */
+ DEVICE_COUNT_RESOURCE
+};
typedef int __bitwise pci_power_t;
@@ -268,18 +291,6 @@ static inline void pci_add_saved_cap(struct pci_dev *pci_dev,
hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space);
}
-/*
- * For PCI devices, the region numbers are assigned this way:
- *
- * 0-5 standard PCI regions
- * 6 expansion ROM
- * 7-10 bridges: address space assigned to buses behind the bridge
- */
-
-#define PCI_ROM_RESOURCE 6
-#define PCI_BRIDGE_RESOURCES 7
-#define PCI_NUM_RESOURCES 11
-
#ifndef PCI_BUS_NUM_RESOURCES
#define PCI_BUS_NUM_RESOURCES 16
#endif
--
1.5.6.4
next prev parent reply other threads:[~2008-11-21 19:36 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-21 18:36 [PATCH 0/13 v7] PCI: Linux kernel SR-IOV support Yu Zhao
2008-11-21 18:38 ` [PATCH 1/13 v7] PCI: enhance pci_ari_enabled() Yu Zhao
2008-11-21 18:38 ` [PATCH 2/13 v7] PCI: remove unnecessary arg of pci_update_resource() Yu Zhao
2008-11-21 18:39 ` Yu Zhao [this message]
2008-11-21 18:40 ` [PATCH 4/13 v7] PCI: remove unnecessary condition check in pci_restore_bars() Yu Zhao
2008-11-21 18:40 ` [PATCH 5/13 v7] PCI: export __pci_read_base() Yu Zhao
2008-11-21 18:41 ` [PATCH 6/13 v7] PCI: make pci_alloc_child_bus() be able to handle NULL bridge Yu Zhao
2008-11-21 18:41 ` [PATCH 7/13 v7] PCI: add a new function to map BAR offset Yu Zhao
2008-11-21 18:41 ` [PATCH 8/13 v7] PCI: cleanup pci_bus_add_devices() Yu Zhao
2008-11-21 18:42 ` [PATCH 9/13 v7] PCI: split a new function from pci_bus_add_devices() Yu Zhao
2008-11-21 18:42 ` [PATCH 10/13 v7] PCI: support the SR-IOV capability Yu Zhao
2008-11-21 18:43 ` [PATCH 11/13 v7] PCI: reserve bus range for SR-IOV device Yu Zhao
2008-11-21 18:43 ` [PATCH 12/13 v7] PCI: document the SR-IOV sysfs entries Yu Zhao
2008-11-21 18:44 ` [PATCH 13/13 v7] PCI: document for SR-IOV user and developer Yu Zhao
2008-11-21 20:57 ` [PATCH 0/13 v7] PCI: Linux kernel SR-IOV support Greg KH
2008-11-22 7:03 ` Zhao, Yu
2008-11-26 14:03 ` [SR-IOV driver example 0/3] introduction Yu Zhao
2008-11-26 14:11 ` [SR-IOV driver example 1/3] PF driver: allocate hardware specific resource Yu Zhao
2008-11-26 14:21 ` [SR-IOV driver example 2/3] PF driver: integrate with SR-IOV core Yu Zhao
2008-11-26 16:58 ` Greg KH
2008-11-26 17:54 ` Chris Wright
2008-12-01 16:46 ` Yu Zhao
2008-11-26 19:27 ` Nakajima, Jun
2008-11-26 19:55 ` Greg KH
2008-12-01 16:44 ` Yu Zhao
2008-11-26 14:40 ` [SR-IOV driver example 3/3] VF driver tar ball Yu Zhao
2008-11-26 17:00 ` Greg KH
2008-11-26 16:59 ` [SR-IOV driver example 0/3] introduction Greg KH
2008-12-01 16:54 ` Yu Zhao
2008-11-26 20:14 ` Jeff Garzik
2008-12-01 16:39 ` Yu Zhao
2008-12-02 9:27 ` [SR-IOV driver example 0/3 resend] introduction Yu Zhao
2008-12-02 9:40 ` [SR-IOV driver example 1/3 resend] PF driver: hardware specific operations Yu Zhao
2008-12-02 9:42 ` [SR-IOV driver example 2/3 resend] PF driver: integrate with SR-IOV core Yu Zhao
2008-12-03 3:12 ` [SR-IOV driver example 0/3 resend] introduction Jeff Kirsher
2008-12-16 23:23 ` [PATCH 0/13 v7] PCI: Linux kernel SR-IOV support Jesse Barnes
2008-12-17 2:37 ` Jike Song
2008-12-17 6:06 ` Greg KH
2008-12-17 7:07 ` Zhao, Yu
2008-12-17 7:21 ` Greg KH
2008-12-17 16:44 ` Rose, Gregory V
2008-12-17 17:51 ` Greg KH
2008-12-17 18:51 ` Jesse Barnes
2008-12-17 19:05 ` Rose, Gregory V
2008-12-17 19:34 ` Jeremy Fitzhardinge
2008-12-17 19:42 ` Rose, Gregory V
2008-12-17 19:42 ` Jesse Barnes
2008-12-17 19:51 ` Greg KH
2008-12-17 20:07 ` Jesse Barnes
2008-12-18 2:39 ` Zhao, Yu
2008-12-18 22:42 ` Rose, Gregory V
2008-12-17 11:42 ` Fischer, Anna
2008-12-17 18:59 ` Jesse Barnes
2008-12-18 2:13 ` Zhao, Yu
2008-12-18 6:37 ` Fischer, Anna
2008-12-17 14:15 ` Matthew Wilcox
2008-12-17 17:27 ` Jesse Barnes
2008-12-18 2:26 ` Zhao, Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081121183932.GD7810@yzhao12-linux.sh.intel.com \
--to=yu.zhao@intel.com \
--cc=achiang@hp.com \
--cc=bjorn.helgaas@hp.com \
--cc=greg@kroah.com \
--cc=grundler@parisc-linux.org \
--cc=horms@verge.net.au \
--cc=jbarnes@virtuousgeek.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=mingo@elte.hu \
--cc=randy.dunlap@oracle.com \
--cc=rdreier@cisco.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox