PCI: Convert PCIe capability PCIBIOS errors to errno
The PCI config accessors (pci_read_config_word(), et al) return PCIBIOS_SUCCESSFUL (zero) or positive error values like PCIBIOS_FUNC_NOT_SUPPORTED. The PCIe capability accessors (pcie_capability_read_word(), et al) similarly return PCIBIOS errors, but some callers assume they return generic errno values like -EINVAL. For example, the Myri-10G probe function returns a positive PCIBIOS error if the pcie_capability_clear_and_set_word() in pcie_set_readrq() fails: myri10ge_probe status = pcie_set_readrq return pcie_capability_clear_and_set_word if (status) return status A positive return from a PCI driver probe function would cause a "Driver probe function unexpectedly returned" warning from local_pci_probe() instead of the desired probe failure. Convert PCIBIOS errors to generic errno for all callers of: pcie_capability_read_word pcie_capability_read_dword pcie_capability_write_word pcie_capability_write_dword pcie_capability_set_word pcie_capability_set_dword pcie_capability_clear_word pcie_capability_clear_dword pcie_capability_clear_and_set_word pcie_capability_clear_and_set_dword that check the return code for anything other than zero. [bhelgaas: commit log, squash together] Suggested-by: Bjorn Helgaas <bjorn@helgaas.com> Link: https://lore.kernel.org/r/20200615073225.24061-1-refactormyself@gmail.com Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
Родитель
b3a9e3b962
Коммит
d20df83b66
|
@ -1195,13 +1195,13 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca)
|
|||
/* disable relaxed ordering */
|
||||
err = pcie_capability_read_word(pdev, IOAT_DEVCTRL_OFFSET, &val16);
|
||||
if (err)
|
||||
return err;
|
||||
return pcibios_err_to_errno(err);
|
||||
|
||||
/* clear relaxed ordering enable */
|
||||
val16 &= ~IOAT_DEVCTRL_ROE;
|
||||
err = pcie_capability_write_word(pdev, IOAT_DEVCTRL_OFFSET, val16);
|
||||
if (err)
|
||||
return err;
|
||||
return pcibios_err_to_errno(err);
|
||||
|
||||
if (ioat_dma->cap & IOAT_CAP_DPS)
|
||||
writeb(ioat_pending_level + 1,
|
||||
|
|
|
@ -5688,6 +5688,7 @@ EXPORT_SYMBOL(pcie_get_readrq);
|
|||
int pcie_set_readrq(struct pci_dev *dev, int rq)
|
||||
{
|
||||
u16 v;
|
||||
int ret;
|
||||
|
||||
if (rq < 128 || rq > 4096 || !is_power_of_2(rq))
|
||||
return -EINVAL;
|
||||
|
@ -5706,8 +5707,10 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
|
|||
|
||||
v = (ffs(rq) - 8) << 12;
|
||||
|
||||
return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
|
||||
ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
|
||||
PCI_EXP_DEVCTL_READRQ, v);
|
||||
|
||||
return pcibios_err_to_errno(ret);
|
||||
}
|
||||
EXPORT_SYMBOL(pcie_set_readrq);
|
||||
|
||||
|
@ -5738,6 +5741,7 @@ EXPORT_SYMBOL(pcie_get_mps);
|
|||
int pcie_set_mps(struct pci_dev *dev, int mps)
|
||||
{
|
||||
u16 v;
|
||||
int ret;
|
||||
|
||||
if (mps < 128 || mps > 4096 || !is_power_of_2(mps))
|
||||
return -EINVAL;
|
||||
|
@ -5747,8 +5751,10 @@ int pcie_set_mps(struct pci_dev *dev, int mps)
|
|||
return -EINVAL;
|
||||
v <<= 5;
|
||||
|
||||
return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
|
||||
ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
|
||||
PCI_EXP_DEVCTL_PAYLOAD, v);
|
||||
|
||||
return pcibios_err_to_errno(ret);
|
||||
}
|
||||
EXPORT_SYMBOL(pcie_set_mps);
|
||||
|
||||
|
|
|
@ -224,20 +224,25 @@ int pcie_aer_is_native(struct pci_dev *dev)
|
|||
|
||||
int pci_enable_pcie_error_reporting(struct pci_dev *dev)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (!pcie_aer_is_native(dev))
|
||||
return -EIO;
|
||||
|
||||
return pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS);
|
||||
rc = pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS);
|
||||
return pcibios_err_to_errno(rc);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting);
|
||||
|
||||
int pci_disable_pcie_error_reporting(struct pci_dev *dev)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (!pcie_aer_is_native(dev))
|
||||
return -EIO;
|
||||
|
||||
return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL,
|
||||
PCI_EXP_AER_FLAGS);
|
||||
rc = pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS);
|
||||
return pcibios_err_to_errno(rc);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting);
|
||||
|
||||
|
|
|
@ -7423,8 +7423,12 @@ static int pqi_ctrl_init_resume(struct pqi_ctrl_info *ctrl_info)
|
|||
static inline int pqi_set_pcie_completion_timeout(struct pci_dev *pci_dev,
|
||||
u16 timeout)
|
||||
{
|
||||
return pcie_capability_clear_and_set_word(pci_dev, PCI_EXP_DEVCTL2,
|
||||
int rc;
|
||||
|
||||
rc = pcie_capability_clear_and_set_word(pci_dev, PCI_EXP_DEVCTL2,
|
||||
PCI_EXP_DEVCTL2_COMP_TIMEOUT, timeout);
|
||||
|
||||
return pcibios_err_to_errno(rc);
|
||||
}
|
||||
|
||||
static int pqi_pci_init(struct pqi_ctrl_info *ctrl_info)
|
||||
|
|
Загрузка…
Ссылка в новой задаче