@@ -1213,6 +1213,28 @@ static irqreturn_t aer_irq(int irq, void *context)
12131213 return IRQ_WAKE_THREAD ;
12141214}
12151215
1216+ static void aer_enable_irq (struct pci_dev * pdev )
1217+ {
1218+ int aer = pdev -> aer_cap ;
1219+ u32 reg32 ;
1220+
1221+ /* Enable Root Port's interrupt in response to error messages */
1222+ pci_read_config_dword (pdev , aer + PCI_ERR_ROOT_COMMAND , & reg32 );
1223+ reg32 |= ROOT_PORT_INTR_ON_MESG_MASK ;
1224+ pci_write_config_dword (pdev , aer + PCI_ERR_ROOT_COMMAND , reg32 );
1225+ }
1226+
1227+ static void aer_disable_irq (struct pci_dev * pdev )
1228+ {
1229+ int aer = pdev -> aer_cap ;
1230+ u32 reg32 ;
1231+
1232+ /* Disable Root's interrupt in response to error messages */
1233+ pci_read_config_dword (pdev , aer + PCI_ERR_ROOT_COMMAND , & reg32 );
1234+ reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK ;
1235+ pci_write_config_dword (pdev , aer + PCI_ERR_ROOT_COMMAND , reg32 );
1236+ }
1237+
12161238/**
12171239 * aer_enable_rootport - enable Root Port's interrupts when receiving messages
12181240 * @rpc: pointer to a Root Port data structure
@@ -1242,10 +1264,7 @@ static void aer_enable_rootport(struct aer_rpc *rpc)
12421264 pci_read_config_dword (pdev , aer + PCI_ERR_UNCOR_STATUS , & reg32 );
12431265 pci_write_config_dword (pdev , aer + PCI_ERR_UNCOR_STATUS , reg32 );
12441266
1245- /* Enable Root Port's interrupt in response to error messages */
1246- pci_read_config_dword (pdev , aer + PCI_ERR_ROOT_COMMAND , & reg32 );
1247- reg32 |= ROOT_PORT_INTR_ON_MESG_MASK ;
1248- pci_write_config_dword (pdev , aer + PCI_ERR_ROOT_COMMAND , reg32 );
1267+ aer_enable_irq (pdev );
12491268}
12501269
12511270/**
@@ -1260,10 +1279,7 @@ static void aer_disable_rootport(struct aer_rpc *rpc)
12601279 int aer = pdev -> aer_cap ;
12611280 u32 reg32 ;
12621281
1263- /* Disable Root's interrupt in response to error messages */
1264- pci_read_config_dword (pdev , aer + PCI_ERR_ROOT_COMMAND , & reg32 );
1265- reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK ;
1266- pci_write_config_dword (pdev , aer + PCI_ERR_ROOT_COMMAND , reg32 );
1282+ aer_disable_irq (pdev );
12671283
12681284 /* Clear Root's error status reg */
12691285 pci_read_config_dword (pdev , aer + PCI_ERR_ROOT_STATUS , & reg32 );
@@ -1358,12 +1374,8 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
13581374 */
13591375 aer = root ? root -> aer_cap : 0 ;
13601376
1361- if ((host -> native_aer || pcie_ports_native ) && aer ) {
1362- /* Disable Root's interrupt in response to error messages */
1363- pci_read_config_dword (root , aer + PCI_ERR_ROOT_COMMAND , & reg32 );
1364- reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK ;
1365- pci_write_config_dword (root , aer + PCI_ERR_ROOT_COMMAND , reg32 );
1366- }
1377+ if ((host -> native_aer || pcie_ports_native ) && aer )
1378+ aer_disable_irq (root );
13671379
13681380 if (type == PCI_EXP_TYPE_RC_EC || type == PCI_EXP_TYPE_RC_END ) {
13691381 rc = pcie_reset_flr (dev , PCI_RESET_DO_RESET );
@@ -1382,10 +1394,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
13821394 pci_read_config_dword (root , aer + PCI_ERR_ROOT_STATUS , & reg32 );
13831395 pci_write_config_dword (root , aer + PCI_ERR_ROOT_STATUS , reg32 );
13841396
1385- /* Enable Root Port's interrupt in response to error messages */
1386- pci_read_config_dword (root , aer + PCI_ERR_ROOT_COMMAND , & reg32 );
1387- reg32 |= ROOT_PORT_INTR_ON_MESG_MASK ;
1388- pci_write_config_dword (root , aer + PCI_ERR_ROOT_COMMAND , reg32 );
1397+ aer_enable_irq (root );
13891398 }
13901399
13911400 return rc ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED ;
0 commit comments