diff mbox

[PATCHv2,2/4] pci: No config access for removed devices

Message ID 1473199219-3369-3-git-send-email-keith.busch@intel.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Keith Busch Sept. 6, 2016, 10 p.m. UTC
If we've  detected that the PCI device is removed, do not attempt to
access the device's config space.

On a config read, if the device is not present, the value returned will be
set to all 1's. This is the same as what hardware would normally return
when accessing a removed device, but we do not need to repeatedly test
hardware's completion capabilities if software can take a short-cut.

Signed-off-by: Keith Busch <keith.busch@intel.com>
---
 include/linux/pci.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

kernel test robot Sept. 7, 2016, 12:03 p.m. UTC | #1
Hi Keith,

[auto build test ERROR on pci/next]
[also build test ERROR on v4.8-rc5 next-20160907]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Keith-Busch/Limiting-pci-access-requsets/20160907-170240
base:   https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: mips-jmr3927_defconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   arch/mips/txx9/generic/pci.c: In function 'early_read_config_word':
>> arch/mips/txx9/generic/pci.c:49:1: error: the frame size of 1528 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
    }
    ^
   cc1: all warnings being treated as errors

vim +49 arch/mips/txx9/generic/pci.c

89d63fe1 Atsushi Nemoto 2008-07-11  33  	struct pci_bus fake_bus;
89d63fe1 Atsushi Nemoto 2008-07-11  34  
89d63fe1 Atsushi Nemoto 2008-07-11  35  	fake_dev.bus = &fake_bus;
89d63fe1 Atsushi Nemoto 2008-07-11  36  	fake_dev.sysdata = hose;
89d63fe1 Atsushi Nemoto 2008-07-11  37  	fake_dev.devfn = devfn;
89d63fe1 Atsushi Nemoto 2008-07-11  38  	fake_bus.number = bus;
89d63fe1 Atsushi Nemoto 2008-07-11  39  	fake_bus.sysdata = hose;
89d63fe1 Atsushi Nemoto 2008-07-11  40  	fake_bus.ops = hose->pci_ops;
89d63fe1 Atsushi Nemoto 2008-07-11  41  
89d63fe1 Atsushi Nemoto 2008-07-11  42  	if (bus != top_bus)
89d63fe1 Atsushi Nemoto 2008-07-11  43  		/* Fake a parent bus structure. */
89d63fe1 Atsushi Nemoto 2008-07-11  44  		fake_bus.parent = &fake_bus;
89d63fe1 Atsushi Nemoto 2008-07-11  45  	else
89d63fe1 Atsushi Nemoto 2008-07-11  46  		fake_bus.parent = NULL;
89d63fe1 Atsushi Nemoto 2008-07-11  47  
89d63fe1 Atsushi Nemoto 2008-07-11  48  	return pci_read_config_word(&fake_dev, offset, value);
89d63fe1 Atsushi Nemoto 2008-07-11 @49  }
89d63fe1 Atsushi Nemoto 2008-07-11  50  
89d63fe1 Atsushi Nemoto 2008-07-11  51  int __init txx9_pci66_check(struct pci_controller *hose, int top_bus,
89d63fe1 Atsushi Nemoto 2008-07-11  52  			    int current_bus)
89d63fe1 Atsushi Nemoto 2008-07-11  53  {
89d63fe1 Atsushi Nemoto 2008-07-11  54  	u32 pci_devfn;
89d63fe1 Atsushi Nemoto 2008-07-11  55  	unsigned short vid;
89d63fe1 Atsushi Nemoto 2008-07-11  56  	int cap66 = -1;
89d63fe1 Atsushi Nemoto 2008-07-11  57  	u16 stat;

:::::: The code at line 49 was first introduced by commit
:::::: 89d63fe179520b11f54de1f26755b7444c79e73a [MIPS] TXx9: Reorganize PCI code

:::::: TO: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
:::::: CC: Ralf Baechle <ralf@linux-mips.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/include/linux/pci.h b/include/linux/pci.h
index 865d3ec..1b62f7a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -932,28 +932,46 @@  struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops);
 
 static inline int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val)
 {
+	if (unlikely(dev->is_removed)) {
+		*val = ~0;
+		return -ENODEV;
+	}
 	return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
 }
 static inline int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val)
 {
+	if (unlikely(dev->is_removed)) {
+		*val = ~0;
+		return -ENODEV;
+	}
 	return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
 }
 static inline int pci_read_config_dword(const struct pci_dev *dev, int where,
 					u32 *val)
 {
+	if (unlikely(dev->is_removed)) {
+		*val = ~0;
+		return -ENODEV;
+	}
 	return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
 }
 static inline int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val)
 {
+	if (unlikely(dev->is_removed))
+		return -ENODEV;
 	return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
 }
 static inline int pci_write_config_word(const struct pci_dev *dev, int where, u16 val)
 {
+	if (unlikely(dev->is_removed))
+		return -ENODEV;
 	return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
 }
 static inline int pci_write_config_dword(const struct pci_dev *dev, int where,
 					 u32 val)
 {
+	if (unlikely(dev->is_removed))
+		return -ENODEV;
 	return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
 }