Skip to content

Commit d20df83

Browse files
refactormyselfbjorn-helgaas
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bolarinwa Olayemi Saheed <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent b3a9e3b commit d20df83

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

drivers/dma/ioat/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,13 +1195,13 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca)
11951195
/* disable relaxed ordering */
11961196
err = pcie_capability_read_word(pdev, IOAT_DEVCTRL_OFFSET, &val16);
11971197
if (err)
1198-
return err;
1198+
return pcibios_err_to_errno(err);
11991199

12001200
/* clear relaxed ordering enable */
12011201
val16 &= ~IOAT_DEVCTRL_ROE;
12021202
err = pcie_capability_write_word(pdev, IOAT_DEVCTRL_OFFSET, val16);
12031203
if (err)
1204-
return err;
1204+
return pcibios_err_to_errno(err);
12051205

12061206
if (ioat_dma->cap & IOAT_CAP_DPS)
12071207
writeb(ioat_pending_level + 1,

drivers/pci/pci.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5688,6 +5688,7 @@ EXPORT_SYMBOL(pcie_get_readrq);
56885688
int pcie_set_readrq(struct pci_dev *dev, int rq)
56895689
{
56905690
u16 v;
5691+
int ret;
56915692

56925693
if (rq < 128 || rq > 4096 || !is_power_of_2(rq))
56935694
return -EINVAL;
@@ -5706,8 +5707,10 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
57065707

57075708
v = (ffs(rq) - 8) << 12;
57085709

5709-
return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
5710+
ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
57105711
PCI_EXP_DEVCTL_READRQ, v);
5712+
5713+
return pcibios_err_to_errno(ret);
57115714
}
57125715
EXPORT_SYMBOL(pcie_set_readrq);
57135716

@@ -5738,6 +5741,7 @@ EXPORT_SYMBOL(pcie_get_mps);
57385741
int pcie_set_mps(struct pci_dev *dev, int mps)
57395742
{
57405743
u16 v;
5744+
int ret;
57415745

57425746
if (mps < 128 || mps > 4096 || !is_power_of_2(mps))
57435747
return -EINVAL;
@@ -5747,8 +5751,10 @@ int pcie_set_mps(struct pci_dev *dev, int mps)
57475751
return -EINVAL;
57485752
v <<= 5;
57495753

5750-
return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
5754+
ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
57515755
PCI_EXP_DEVCTL_PAYLOAD, v);
5756+
5757+
return pcibios_err_to_errno(ret);
57525758
}
57535759
EXPORT_SYMBOL(pcie_set_mps);
57545760

drivers/pci/pcie/aer.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,25 @@ int pcie_aer_is_native(struct pci_dev *dev)
224224

225225
int pci_enable_pcie_error_reporting(struct pci_dev *dev)
226226
{
227+
int rc;
228+
227229
if (!pcie_aer_is_native(dev))
228230
return -EIO;
229231

230-
return pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS);
232+
rc = pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS);
233+
return pcibios_err_to_errno(rc);
231234
}
232235
EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting);
233236

234237
int pci_disable_pcie_error_reporting(struct pci_dev *dev)
235238
{
239+
int rc;
240+
236241
if (!pcie_aer_is_native(dev))
237242
return -EIO;
238243

239-
return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL,
240-
PCI_EXP_AER_FLAGS);
244+
rc = pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS);
245+
return pcibios_err_to_errno(rc);
241246
}
242247
EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting);
243248

drivers/scsi/smartpqi/smartpqi_init.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7423,8 +7423,12 @@ static int pqi_ctrl_init_resume(struct pqi_ctrl_info *ctrl_info)
74237423
static inline int pqi_set_pcie_completion_timeout(struct pci_dev *pci_dev,
74247424
u16 timeout)
74257425
{
7426-
return pcie_capability_clear_and_set_word(pci_dev, PCI_EXP_DEVCTL2,
7426+
int rc;
7427+
7428+
rc = pcie_capability_clear_and_set_word(pci_dev, PCI_EXP_DEVCTL2,
74277429
PCI_EXP_DEVCTL2_COMP_TIMEOUT, timeout);
7430+
7431+
return pcibios_err_to_errno(rc);
74287432
}
74297433

74307434
static int pqi_pci_init(struct pqi_ctrl_info *ctrl_info)

0 commit comments

Comments
 (0)