This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new a65b517ff0a pci: Skip already-initialized devices in
pci_register_device.
a65b517ff0a is described below
commit a65b517ff0ad0a92ea47afe0853d4d3f96f15633
Author: ganjing <[email protected]>
AuthorDate: Tue Apr 21 23:15:57 2026 +0800
pci: Skip already-initialized devices in pci_register_device.
When multiple CPUs scan the same PCI bus, check PCI_COMMAND IO
and MEMORY bits before registering a device. If either is already
enabled, the device was probed by a prior CPU's driver (via
pci_enable_device) and should be skipped to avoid duplicate probe.
Signed-off-by: ganjing <[email protected]>
---
drivers/pci/pci.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b8c38559cee..482044fdd47 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2244,8 +2244,22 @@ int pci_register_device(FAR struct pci_device_s *dev)
{
FAR const struct pci_device_id_s *id;
FAR struct pci_driver_s *drv;
+ uint16_t cmd;
int ret;
+ /* Skip devices already initialized by another CPU. In BMP
+ * environments where multiple CPUs scan the same PCI bus,
+ * a device with IO or MEMORY enabled was probed by a prior
+ * CPU's driver (via pci_enable_device) - skip to avoid
+ * duplicate probe.
+ */
+
+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
+ if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY))
+ {
+ return -EBUSY;
+ }
+
ret = nxmutex_lock(&g_pci_lock);
if (ret < 0)
{