diff mbox series

[v8,02/24] PCI: Ensure a bridge has I/O and MEM access for hot-added devices

Message ID 20200427182358.2067702-3-s.miroshnichenko@yadro.com
State New, archived
Delegated to: Bjorn Helgaas
Headers show
Series PCI: Allow BAR movement during boot and hotplug | expand

Commit Message

Sergei Miroshnichenko April 27, 2020, 6:23 p.m. UTC
During hot-adding a device, its bridge may be already pci_is_enabled(), but
without the I/O and/or MEM access bits, which may be required by this new
device: these bits are set during first enabling the bridge, and they must
be checked again.

When hot-adding to the following bridge:

  +-[0020:00]---00.0-[01-0d]----00.0-[02-0d]----04.0-[03-0d]--   <-   00.0

this patch sets up the MEM bit in the downstream port 0020:02:04.0, needed
for 0020:08:00.0:

  [ 1037.698206] pci 0020:00:00.0: PCI bridge to [bus 01-0d]
  [ 1037.698785] pci 0020:00:00.0:   bridge window [mem 0x3fe800000000-0x3fe8017fffff]
  [ 1037.698874] pci 0020:00:00.0:   bridge window [mem 0x240000000000-0x2400ffffffff 64bit pref]
  [ 1037.699002] pcieport 0020:02:04.0: enabling device (0545 -> 0547)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [ 1037.699114] pcieport 0020:03:00.0: enabling device (0540 -> 0542)
  [ 1037.699198] pciehp 0020:04:09.0:pcie204: Slot #41 AttnBtn+ PwrCtrl+ MRL- AttnInd+ PwrInd+ HotPlug+ Surprise- Interlock- NoCompl- LLActRep+
  [ 1037.699285] pciehp 0020:04:09.0:pcie204: Slot(41): Card present
  [ 1037.699346] pciehp 0020:04:09.0:pcie204: Slot(41): Already enabled

Signed-off-by: Sergei Miroshnichenko <s.miroshnichenko@yadro.com>
---
 drivers/pci/pci.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

kernel test robot April 29, 2020, 6:30 a.m. UTC | #1
Hi Sergei,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on pci/next]
[also build test WARNING on powerpc/next linus/master v5.7-rc3 next-20200428]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Sergei-Miroshnichenko/PCI-Allow-BAR-movement-during-boot-and-hotplug/20200428-105625
base:   https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: powerpc-defconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project f30416fdde922eaa655934e050026930fefbd260)
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install powerpc cross compiling tool for clang build
        # apt-get install binutils-powerpc-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/pci/pci.c:1745:3: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
                   pci_reenable_device(dev);
                   ^~~~~~~~~~~~~~~~~~~ ~~~
   1 warning generated.

vim +/warn_unused_result +1745 drivers/pci/pci.c

  1732	
  1733	static void pci_enable_bridge(struct pci_dev *dev)
  1734	{
  1735		struct pci_dev *bridge;
  1736		int retval;
  1737	
  1738		mutex_lock(&dev->enable_mutex);
  1739	
  1740		bridge = pci_upstream_bridge(dev);
  1741		if (bridge)
  1742			pci_enable_bridge(bridge);
  1743	
  1744		if (pci_is_enabled(dev)) {
> 1745			pci_reenable_device(dev);
  1746	
  1747			if (!dev->is_busmaster)
  1748				pci_set_master(dev);
  1749			mutex_unlock(&dev->enable_mutex);
  1750			return;
  1751		}
  1752	
  1753		retval = pci_enable_device(dev);
  1754		if (retval)
  1755			pci_err(dev, "Error enabling bridge (%d), continuing\n",
  1756				retval);
  1757		pci_set_master(dev);
  1758		mutex_unlock(&dev->enable_mutex);
  1759	}
  1760	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d7819be809a3..2c0ae81d260d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1740,6 +1740,8 @@  static void pci_enable_bridge(struct pci_dev *dev)
 		pci_enable_bridge(bridge);
 
 	if (pci_is_enabled(dev)) {
+		pci_reenable_device(dev);
+
 		if (!dev->is_busmaster)
 			pci_set_master(dev);
 		mutex_unlock(&dev->enable_mutex);