Re: [PATCH 2/6 v3] PCI: add new general functions

Previous thread: [PATCH 1/6 v3] PCI: export some functions and macros by Zhao, Yu on Saturday, September 27, 2008 - 1:27 am. (4 messages)

Next thread: [PATCH 3/6 v3] PCI: support ARI capability by Zhao, Yu on Saturday, September 27, 2008 - 1:28 am. (5 messages)
From: Zhao, Yu
Date: Saturday, September 27, 2008 - 1:27 am

Centralize capability related functions into several new functions and put PCI resource definitions into an enum.

Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Alex Chiang <achiang@hp.com>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Yu Zhao <yu.zhao@intel.com>

---
 drivers/pci/pci-sysfs.c |  119 +++++++++++++++++++++++++++--------------------
 drivers/pci/pci.c       |   68 ++++++++++++++++++++-------
 drivers/pci/pci.h       |    3 +
 drivers/pci/probe.c     |   29 ++++++++---
 drivers/pci/proc.c      |    7 ++-
 drivers/pci/setup-bus.c |    4 +-
 drivers/pci/setup-res.c |   27 +++++------
 include/linux/pci.h     |   39 ++++++++++------
 8 files changed, 186 insertions(+), 110 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index f99160d..f2feebc 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -100,11 +100,11 @@ 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;
+       max = pci_dev->subordinate ? DEVICE_COUNT_RESOURCE :
+                               PCI_BRIDGE_RESOURCES;

        for (i = 0; i < max; i++) {
                struct resource *res =  &pci_dev->resource[i];
@@ -716,10 +716,40 @@ int __attribute__ ((weak)) pcibios_add_platform_entries(struct pci_dev *dev)
        return 0;
 }

+static int pci_create_capabilities_sysfs(struct pci_dev *dev)
+{
+       int retval;
+       struct bin_attribute *attr;
+
+       /* If the device has VPD, try to expose it in sysfs. */
+       if (dev->vpd) {
+               attr = kzalloc(sizeof(*attr), GFP_ATOMIC);
+              ...
From: Jesse Barnes
Date: Thursday, October 2, 2008 - 9:21 am

This confused me for a minute until I saw that the new pci_update_resource 
ignores invalid BAR numbers.  Not sure if that's clearer than the current 

It looks like this will spew an error even under normal circumstances since 
pci_restore_bars gets called at resume time, right?  You could make this into 
a debug message or just get rid of it.  Also now that I look at this, I don't 
think it'll provide equivalent functionality to the old restore_bars code, 
won't a cardbus bridge end up getting pci_update_resource called on invalid 

These capabilities changes look good, care to separate them out?

Let's see if we can whittle down this patchset by extracting and applying all 
the various cleanups; that should make the core bits easier to review.

Thanks,
-- 
Jesse Barnes, Intel Open Source Technology Center
--

From: Zhao, Yu
Date: Tuesday, October 7, 2008 - 8:25 pm

Previous thread: [PATCH 1/6 v3] PCI: export some functions and macros by Zhao, Yu on Saturday, September 27, 2008 - 1:27 am. (4 messages)

Next thread: [PATCH 3/6 v3] PCI: support ARI capability by Zhao, Yu on Saturday, September 27, 2008 - 1:28 am. (5 messages)