mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-08 14:13:53 +00:00
PCI/AER: Factor out interrupt toggling into helpers
There are many places that enable and disable AER interrupt, so move them into helpers. Link: https://lore.kernel.org/r/20230512000014.118942-1-kai.heng.feng@canonical.com Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
0bb80ecc33
commit
13cf36c648
@ -1213,6 +1213,28 @@ static irqreturn_t aer_irq(int irq, void *context)
|
|||||||
return IRQ_WAKE_THREAD;
|
return IRQ_WAKE_THREAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void aer_enable_irq(struct pci_dev *pdev)
|
||||||
|
{
|
||||||
|
int aer = pdev->aer_cap;
|
||||||
|
u32 reg32;
|
||||||
|
|
||||||
|
/* Enable Root Port's interrupt in response to error messages */
|
||||||
|
pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, ®32);
|
||||||
|
reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
|
||||||
|
pci_write_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, reg32);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void aer_disable_irq(struct pci_dev *pdev)
|
||||||
|
{
|
||||||
|
int aer = pdev->aer_cap;
|
||||||
|
u32 reg32;
|
||||||
|
|
||||||
|
/* Disable Root's interrupt in response to error messages */
|
||||||
|
pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, ®32);
|
||||||
|
reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
|
||||||
|
pci_write_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, reg32);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* aer_enable_rootport - enable Root Port's interrupts when receiving messages
|
* aer_enable_rootport - enable Root Port's interrupts when receiving messages
|
||||||
* @rpc: pointer to a Root Port data structure
|
* @rpc: pointer to a Root Port data structure
|
||||||
@ -1242,10 +1264,7 @@ static void aer_enable_rootport(struct aer_rpc *rpc)
|
|||||||
pci_read_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS, ®32);
|
pci_read_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS, ®32);
|
||||||
pci_write_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS, reg32);
|
pci_write_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS, reg32);
|
||||||
|
|
||||||
/* Enable Root Port's interrupt in response to error messages */
|
aer_enable_irq(pdev);
|
||||||
pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, ®32);
|
|
||||||
reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
|
|
||||||
pci_write_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, reg32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1260,10 +1279,7 @@ static void aer_disable_rootport(struct aer_rpc *rpc)
|
|||||||
int aer = pdev->aer_cap;
|
int aer = pdev->aer_cap;
|
||||||
u32 reg32;
|
u32 reg32;
|
||||||
|
|
||||||
/* Disable Root's interrupt in response to error messages */
|
aer_disable_irq(pdev);
|
||||||
pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, ®32);
|
|
||||||
reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
|
|
||||||
pci_write_config_dword(pdev, aer + PCI_ERR_ROOT_COMMAND, reg32);
|
|
||||||
|
|
||||||
/* Clear Root's error status reg */
|
/* Clear Root's error status reg */
|
||||||
pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_STATUS, ®32);
|
pci_read_config_dword(pdev, aer + PCI_ERR_ROOT_STATUS, ®32);
|
||||||
@ -1358,12 +1374,8 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
|
|||||||
*/
|
*/
|
||||||
aer = root ? root->aer_cap : 0;
|
aer = root ? root->aer_cap : 0;
|
||||||
|
|
||||||
if ((host->native_aer || pcie_ports_native) && aer) {
|
if ((host->native_aer || pcie_ports_native) && aer)
|
||||||
/* Disable Root's interrupt in response to error messages */
|
aer_disable_irq(root);
|
||||||
pci_read_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, ®32);
|
|
||||||
reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
|
|
||||||
pci_write_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, reg32);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == PCI_EXP_TYPE_RC_EC || type == PCI_EXP_TYPE_RC_END) {
|
if (type == PCI_EXP_TYPE_RC_EC || type == PCI_EXP_TYPE_RC_END) {
|
||||||
rc = pcie_reset_flr(dev, PCI_RESET_DO_RESET);
|
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)
|
|||||||
pci_read_config_dword(root, aer + PCI_ERR_ROOT_STATUS, ®32);
|
pci_read_config_dword(root, aer + PCI_ERR_ROOT_STATUS, ®32);
|
||||||
pci_write_config_dword(root, aer + PCI_ERR_ROOT_STATUS, reg32);
|
pci_write_config_dword(root, aer + PCI_ERR_ROOT_STATUS, reg32);
|
||||||
|
|
||||||
/* Enable Root Port's interrupt in response to error messages */
|
aer_enable_irq(root);
|
||||||
pci_read_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, ®32);
|
|
||||||
reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
|
|
||||||
pci_write_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, reg32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
|
return rc ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
|
||||||
|
Loading…
Reference in New Issue
Block a user