Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Bolarinwa Olayemi Saheed and committed by
Bjorn Helgaas
d20df83b b3a9e3b9

+23 -8
+2 -2
drivers/dma/ioat/init.c
··· 1195 1195 /* disable relaxed ordering */ 1196 1196 err = pcie_capability_read_word(pdev, IOAT_DEVCTRL_OFFSET, &val16); 1197 1197 if (err) 1198 - return err; 1198 + return pcibios_err_to_errno(err); 1199 1199 1200 1200 /* clear relaxed ordering enable */ 1201 1201 val16 &= ~IOAT_DEVCTRL_ROE; 1202 1202 err = pcie_capability_write_word(pdev, IOAT_DEVCTRL_OFFSET, val16); 1203 1203 if (err) 1204 - return err; 1204 + return pcibios_err_to_errno(err); 1205 1205 1206 1206 if (ioat_dma->cap & IOAT_CAP_DPS) 1207 1207 writeb(ioat_pending_level + 1,
+8 -2
drivers/pci/pci.c
··· 5688 5688 int pcie_set_readrq(struct pci_dev *dev, int rq) 5689 5689 { 5690 5690 u16 v; 5691 + int ret; 5691 5692 5692 5693 if (rq < 128 || rq > 4096 || !is_power_of_2(rq)) 5693 5694 return -EINVAL; ··· 5707 5706 5708 5707 v = (ffs(rq) - 8) << 12; 5709 5708 5710 - return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, 5709 + ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, 5711 5710 PCI_EXP_DEVCTL_READRQ, v); 5711 + 5712 + return pcibios_err_to_errno(ret); 5712 5713 } 5713 5714 EXPORT_SYMBOL(pcie_set_readrq); 5714 5715 ··· 5741 5738 int pcie_set_mps(struct pci_dev *dev, int mps) 5742 5739 { 5743 5740 u16 v; 5741 + int ret; 5744 5742 5745 5743 if (mps < 128 || mps > 4096 || !is_power_of_2(mps)) 5746 5744 return -EINVAL; ··· 5751 5747 return -EINVAL; 5752 5748 v <<= 5; 5753 5749 5754 - return pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, 5750 + ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, 5755 5751 PCI_EXP_DEVCTL_PAYLOAD, v); 5752 + 5753 + return pcibios_err_to_errno(ret); 5756 5754 } 5757 5755 EXPORT_SYMBOL(pcie_set_mps); 5758 5756
+8 -3
drivers/pci/pcie/aer.c
··· 224 224 225 225 int pci_enable_pcie_error_reporting(struct pci_dev *dev) 226 226 { 227 + int rc; 228 + 227 229 if (!pcie_aer_is_native(dev)) 228 230 return -EIO; 229 231 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); 231 234 } 232 235 EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting); 233 236 234 237 int pci_disable_pcie_error_reporting(struct pci_dev *dev) 235 238 { 239 + int rc; 240 + 236 241 if (!pcie_aer_is_native(dev)) 237 242 return -EIO; 238 243 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); 241 246 } 242 247 EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting); 243 248
+5 -1
drivers/scsi/smartpqi/smartpqi_init.c
··· 7423 7423 static inline int pqi_set_pcie_completion_timeout(struct pci_dev *pci_dev, 7424 7424 u16 timeout) 7425 7425 { 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, 7427 7429 PCI_EXP_DEVCTL2_COMP_TIMEOUT, timeout); 7430 + 7431 + return pcibios_err_to_errno(rc); 7428 7432 } 7429 7433 7430 7434 static int pqi_pci_init(struct pqi_ctrl_info *ctrl_info)