aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorDexuan Cui <dexuan.cui@intel.com>2009-12-07 00:03:21 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-12-16 16:37:50 -0500
commitb9c3b266411d27f1a6466c19d146d08db576bfea (patch)
treec310b37e7dff6607e22eca0b690c2a3f290c85a9 /drivers/pci
parent2820f333e3b4ad96590093efbed7b3400bcf492b (diff)
PCI: support device-specific reset methods
Add a new type of quirk for resetting devices at pci_dev_reset time. This is necessary to handle device with nonstandard reset procedures, especially useful for guest drivers. Signed-off-by: Yu Zhao <yu.zhao@intel.com> Signed-off-by: Dexuan Cui <dexuan.cui@intel.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci.c19
-rw-r--r--drivers/pci/pci.h8
-rw-r--r--drivers/pci/quirks.c9
3 files changed, 36 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0bc27e059019..6011d064e89d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2284,6 +2284,21 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe)
2284 return 0; 2284 return 0;
2285} 2285}
2286 2286
2287static int pci_dev_specific_reset(struct pci_dev *dev, int probe)
2288{
2289 struct pci_dev_reset_methods *i;
2290
2291 for (i = pci_dev_reset_methods; i->reset; i++) {
2292 if ((i->vendor == dev->vendor ||
2293 i->vendor == (u16)PCI_ANY_ID) &&
2294 (i->device == dev->device ||
2295 i->device == (u16)PCI_ANY_ID))
2296 return i->reset(dev, probe);
2297 }
2298
2299 return -ENOTTY;
2300}
2301
2287static int pci_dev_reset(struct pci_dev *dev, int probe) 2302static int pci_dev_reset(struct pci_dev *dev, int probe)
2288{ 2303{
2289 int rc; 2304 int rc;
@@ -2296,6 +2311,10 @@ static int pci_dev_reset(struct pci_dev *dev, int probe)
2296 down(&dev->dev.sem); 2311 down(&dev->dev.sem);
2297 } 2312 }
2298 2313
2314 rc = pci_dev_specific_reset(dev, probe);
2315 if (rc != -ENOTTY)
2316 goto done;
2317
2299 rc = pcie_flr(dev, probe); 2318 rc = pcie_flr(dev, probe);
2300 if (rc != -ENOTTY) 2319 if (rc != -ENOTTY)
2301 goto done; 2320 goto done;
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 33ed8e0aba1e..709eaa4fee51 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -313,4 +313,12 @@ static inline int pci_resource_alignment(struct pci_dev *dev,
313 313
314extern void pci_enable_acs(struct pci_dev *dev); 314extern void pci_enable_acs(struct pci_dev *dev);
315 315
316struct pci_dev_reset_methods {
317 u16 vendor;
318 u16 device;
319 int (*reset)(struct pci_dev *dev, int probe);
320};
321
322extern struct pci_dev_reset_methods pci_dev_reset_methods[];
323
316#endif /* DRIVERS_PCI_H */ 324#endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index f70f4e23225c..86c9177a6c6c 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2636,6 +2636,15 @@ static int __init pci_apply_final_quirks(void)
2636} 2636}
2637 2637
2638fs_initcall_sync(pci_apply_final_quirks); 2638fs_initcall_sync(pci_apply_final_quirks);
2639
2640/*
2641 * Followings are device-specific reset methods which can be used to
2642 * reset a single function if other methods (e.g. FLR, PM D0->D3) are
2643 * not available.
2644 */
2645struct pci_dev_reset_methods pci_dev_reset_methods[] = {
2646 { 0 }
2647};
2639#else 2648#else
2640void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) {} 2649void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) {}
2641#endif 2650#endif