diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2007-01-25 03:34:08 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-07 18:50:07 -0500 |
commit | 8fed4b65236c44d090bd62f2d14938ae791e0260 (patch) | |
tree | 53b0609ff8e53d9b1410f707f59cd14a555f8c04 /drivers | |
parent | 0fcfdabbdbedb3bdc63f29209aeeac805df78a92 (diff) |
MSI: Combine pci_(save|restore)_msi/msix_state
The PCI save/restore code doesn't need to care about MSI vs MSI-X, all
it really wants is to say "save/restore all MSI(-X) info for this device".
This is borne out in the code, we call the MSI and MSI-X save routines
side by side, and similarly with the restore routines.
So combine the MSI/MSI-X routines into pci_save_msi_state() and
pci_restore_msi_state(). It is up to those routines to decide what state
needs to be saved.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/msi.c | 27 | ||||
-rw-r--r-- | drivers/pci/pci.c | 4 | ||||
-rw-r--r-- | drivers/pci/pci.h | 6 |
3 files changed, 26 insertions, 11 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 6cfa6be9a6d5..067ae9917fd6 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -295,7 +295,7 @@ static int msi_lookup_irq(struct pci_dev *dev, int type) | |||
295 | } | 295 | } |
296 | 296 | ||
297 | #ifdef CONFIG_PM | 297 | #ifdef CONFIG_PM |
298 | int pci_save_msi_state(struct pci_dev *dev) | 298 | static int __pci_save_msi_state(struct pci_dev *dev) |
299 | { | 299 | { |
300 | int pos, i = 0; | 300 | int pos, i = 0; |
301 | u16 control; | 301 | u16 control; |
@@ -333,7 +333,7 @@ int pci_save_msi_state(struct pci_dev *dev) | |||
333 | return 0; | 333 | return 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | void pci_restore_msi_state(struct pci_dev *dev) | 336 | static void __pci_restore_msi_state(struct pci_dev *dev) |
337 | { | 337 | { |
338 | int i = 0, pos; | 338 | int i = 0, pos; |
339 | u16 control; | 339 | u16 control; |
@@ -361,7 +361,7 @@ void pci_restore_msi_state(struct pci_dev *dev) | |||
361 | kfree(save_state); | 361 | kfree(save_state); |
362 | } | 362 | } |
363 | 363 | ||
364 | int pci_save_msix_state(struct pci_dev *dev) | 364 | static int __pci_save_msix_state(struct pci_dev *dev) |
365 | { | 365 | { |
366 | int pos; | 366 | int pos; |
367 | int temp; | 367 | int temp; |
@@ -409,7 +409,20 @@ int pci_save_msix_state(struct pci_dev *dev) | |||
409 | return 0; | 409 | return 0; |
410 | } | 410 | } |
411 | 411 | ||
412 | void pci_restore_msix_state(struct pci_dev *dev) | 412 | int pci_save_msi_state(struct pci_dev *dev) |
413 | { | ||
414 | int rc; | ||
415 | |||
416 | rc = __pci_save_msi_state(dev); | ||
417 | if (rc) | ||
418 | return rc; | ||
419 | |||
420 | rc = __pci_save_msix_state(dev); | ||
421 | |||
422 | return rc; | ||
423 | } | ||
424 | |||
425 | static void __pci_restore_msix_state(struct pci_dev *dev) | ||
413 | { | 426 | { |
414 | u16 save; | 427 | u16 save; |
415 | int pos; | 428 | int pos; |
@@ -446,6 +459,12 @@ void pci_restore_msix_state(struct pci_dev *dev) | |||
446 | pci_write_config_word(dev, msi_control_reg(pos), save); | 459 | pci_write_config_word(dev, msi_control_reg(pos), save); |
447 | enable_msi_mode(dev, pos, PCI_CAP_ID_MSIX); | 460 | enable_msi_mode(dev, pos, PCI_CAP_ID_MSIX); |
448 | } | 461 | } |
462 | |||
463 | void pci_restore_msi_state(struct pci_dev *dev) | ||
464 | { | ||
465 | __pci_restore_msi_state(dev); | ||
466 | __pci_restore_msix_state(dev); | ||
467 | } | ||
449 | #endif /* CONFIG_PM */ | 468 | #endif /* CONFIG_PM */ |
450 | 469 | ||
451 | /** | 470 | /** |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7ae709024456..84c757ba0664 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -634,8 +634,6 @@ pci_save_state(struct pci_dev *dev) | |||
634 | pci_read_config_dword(dev, i * 4,&dev->saved_config_space[i]); | 634 | pci_read_config_dword(dev, i * 4,&dev->saved_config_space[i]); |
635 | if ((i = pci_save_msi_state(dev)) != 0) | 635 | if ((i = pci_save_msi_state(dev)) != 0) |
636 | return i; | 636 | return i; |
637 | if ((i = pci_save_msix_state(dev)) != 0) | ||
638 | return i; | ||
639 | if ((i = pci_save_pcie_state(dev)) != 0) | 637 | if ((i = pci_save_pcie_state(dev)) != 0) |
640 | return i; | 638 | return i; |
641 | if ((i = pci_save_pcix_state(dev)) != 0) | 639 | if ((i = pci_save_pcix_state(dev)) != 0) |
@@ -673,7 +671,7 @@ pci_restore_state(struct pci_dev *dev) | |||
673 | } | 671 | } |
674 | pci_restore_pcix_state(dev); | 672 | pci_restore_pcix_state(dev); |
675 | pci_restore_msi_state(dev); | 673 | pci_restore_msi_state(dev); |
676 | pci_restore_msix_state(dev); | 674 | |
677 | return 0; | 675 | return 0; |
678 | } | 676 | } |
679 | 677 | ||
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 4948db0f8100..a4f2d580625e 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -52,17 +52,15 @@ void pci_no_msi(void); | |||
52 | static inline void disable_msi_mode(struct pci_dev *dev, int pos, int type) { } | 52 | static inline void disable_msi_mode(struct pci_dev *dev, int pos, int type) { } |
53 | static inline void pci_no_msi(void) { } | 53 | static inline void pci_no_msi(void) { } |
54 | #endif | 54 | #endif |
55 | |||
55 | #if defined(CONFIG_PCI_MSI) && defined(CONFIG_PM) | 56 | #if defined(CONFIG_PCI_MSI) && defined(CONFIG_PM) |
56 | int pci_save_msi_state(struct pci_dev *dev); | 57 | int pci_save_msi_state(struct pci_dev *dev); |
57 | int pci_save_msix_state(struct pci_dev *dev); | ||
58 | void pci_restore_msi_state(struct pci_dev *dev); | 58 | void pci_restore_msi_state(struct pci_dev *dev); |
59 | void pci_restore_msix_state(struct pci_dev *dev); | ||
60 | #else | 59 | #else |
61 | static inline int pci_save_msi_state(struct pci_dev *dev) { return 0; } | 60 | static inline int pci_save_msi_state(struct pci_dev *dev) { return 0; } |
62 | static inline int pci_save_msix_state(struct pci_dev *dev) { return 0; } | ||
63 | static inline void pci_restore_msi_state(struct pci_dev *dev) {} | 61 | static inline void pci_restore_msi_state(struct pci_dev *dev) {} |
64 | static inline void pci_restore_msix_state(struct pci_dev *dev) {} | ||
65 | #endif | 62 | #endif |
63 | |||
66 | static inline int pci_no_d1d2(struct pci_dev *dev) | 64 | static inline int pci_no_d1d2(struct pci_dev *dev) |
67 | { | 65 | { |
68 | unsigned int parent_dstates = 0; | 66 | unsigned int parent_dstates = 0; |