瀏覽代碼

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>
Michael Ellerman 18 年之前
父節點
當前提交
8fed4b6523
共有 3 個文件被更改,包括 26 次插入11 次删除
  1. 23 4
      drivers/pci/msi.c
  2. 1 3
      drivers/pci/pci.c
  3. 2 4
      drivers/pci/pci.h

+ 23 - 4
drivers/pci/msi.c

@@ -295,7 +295,7 @@ static int msi_lookup_irq(struct pci_dev *dev, int type)
 }
 }
 
 
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM
-int pci_save_msi_state(struct pci_dev *dev)
+static int __pci_save_msi_state(struct pci_dev *dev)
 {
 {
 	int pos, i = 0;
 	int pos, i = 0;
 	u16 control;
 	u16 control;
@@ -333,7 +333,7 @@ int pci_save_msi_state(struct pci_dev *dev)
 	return 0;
 	return 0;
 }
 }
 
 
-void pci_restore_msi_state(struct pci_dev *dev)
+static void __pci_restore_msi_state(struct pci_dev *dev)
 {
 {
 	int i = 0, pos;
 	int i = 0, pos;
 	u16 control;
 	u16 control;
@@ -361,7 +361,7 @@ void pci_restore_msi_state(struct pci_dev *dev)
 	kfree(save_state);
 	kfree(save_state);
 }
 }
 
 
-int pci_save_msix_state(struct pci_dev *dev)
+static int __pci_save_msix_state(struct pci_dev *dev)
 {
 {
 	int pos;
 	int pos;
 	int temp;
 	int temp;
@@ -409,7 +409,20 @@ int pci_save_msix_state(struct pci_dev *dev)
 	return 0;
 	return 0;
 }
 }
 
 
-void pci_restore_msix_state(struct pci_dev *dev)
+int pci_save_msi_state(struct pci_dev *dev)
+{
+	int rc;
+
+	rc = __pci_save_msi_state(dev);
+	if (rc)
+		return rc;
+
+	rc = __pci_save_msix_state(dev);
+
+	return rc;
+}
+
+static void __pci_restore_msix_state(struct pci_dev *dev)
 {
 {
 	u16 save;
 	u16 save;
 	int pos;
 	int pos;
@@ -446,6 +459,12 @@ void pci_restore_msix_state(struct pci_dev *dev)
 	pci_write_config_word(dev, msi_control_reg(pos), save);
 	pci_write_config_word(dev, msi_control_reg(pos), save);
 	enable_msi_mode(dev, pos, PCI_CAP_ID_MSIX);
 	enable_msi_mode(dev, pos, PCI_CAP_ID_MSIX);
 }
 }
+
+void pci_restore_msi_state(struct pci_dev *dev)
+{
+	__pci_restore_msi_state(dev);
+	__pci_restore_msix_state(dev);
+}
 #endif	/* CONFIG_PM */
 #endif	/* CONFIG_PM */
 
 
 /**
 /**

+ 1 - 3
drivers/pci/pci.c

@@ -634,8 +634,6 @@ pci_save_state(struct pci_dev *dev)
 		pci_read_config_dword(dev, i * 4,&dev->saved_config_space[i]);
 		pci_read_config_dword(dev, i * 4,&dev->saved_config_space[i]);
 	if ((i = pci_save_msi_state(dev)) != 0)
 	if ((i = pci_save_msi_state(dev)) != 0)
 		return i;
 		return i;
-	if ((i = pci_save_msix_state(dev)) != 0)
-		return i;
 	if ((i = pci_save_pcie_state(dev)) != 0)
 	if ((i = pci_save_pcie_state(dev)) != 0)
 		return i;
 		return i;
 	if ((i = pci_save_pcix_state(dev)) != 0)
 	if ((i = pci_save_pcix_state(dev)) != 0)
@@ -673,7 +671,7 @@ pci_restore_state(struct pci_dev *dev)
 	}
 	}
 	pci_restore_pcix_state(dev);
 	pci_restore_pcix_state(dev);
 	pci_restore_msi_state(dev);
 	pci_restore_msi_state(dev);
-	pci_restore_msix_state(dev);
+
 	return 0;
 	return 0;
 }
 }
 
 

+ 2 - 4
drivers/pci/pci.h

@@ -52,17 +52,15 @@ void pci_no_msi(void);
 static inline void disable_msi_mode(struct pci_dev *dev, int pos, int type) { }
 static inline void disable_msi_mode(struct pci_dev *dev, int pos, int type) { }
 static inline void pci_no_msi(void) { }
 static inline void pci_no_msi(void) { }
 #endif
 #endif
+
 #if defined(CONFIG_PCI_MSI) && defined(CONFIG_PM)
 #if defined(CONFIG_PCI_MSI) && defined(CONFIG_PM)
 int pci_save_msi_state(struct pci_dev *dev);
 int pci_save_msi_state(struct pci_dev *dev);
-int pci_save_msix_state(struct pci_dev *dev);
 void pci_restore_msi_state(struct pci_dev *dev);
 void pci_restore_msi_state(struct pci_dev *dev);
-void pci_restore_msix_state(struct pci_dev *dev);
 #else
 #else
 static inline int pci_save_msi_state(struct pci_dev *dev) { return 0; }
 static inline int pci_save_msi_state(struct pci_dev *dev) { return 0; }
-static inline int pci_save_msix_state(struct pci_dev *dev) { return 0; }
 static inline void pci_restore_msi_state(struct pci_dev *dev) {}
 static inline void pci_restore_msi_state(struct pci_dev *dev) {}
-static inline void pci_restore_msix_state(struct pci_dev *dev) {}
 #endif
 #endif
+
 static inline int pci_no_d1d2(struct pci_dev *dev)
 static inline int pci_no_d1d2(struct pci_dev *dev)
 {
 {
 	unsigned int parent_dstates = 0;
 	unsigned int parent_dstates = 0;