]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[pci] Allow probing permission to vary by range
authorMichael Brown <mcb30@ipxe.org>
Mon, 24 Nov 2025 23:09:53 +0000 (23:09 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 24 Nov 2025 23:16:32 +0000 (23:16 +0000)
Make pci_can_probe() part of the runtime selectable PCI I/O API, and
defer this check to the per-range API.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/include/ipxe/pcibios.h
src/arch/x86/include/ipxe/pcidirect.h
src/drivers/bus/pci.c
src/drivers/bus/pcicloud.c
src/include/ipxe/ecam_io.h
src/include/ipxe/efi/efi_pci_api.h
src/include/ipxe/linux/linux_pci.h
src/include/ipxe/null_pci.h
src/include/ipxe/pci_io.h
src/include/ipxe/pcicloud.h

index 87b4035559ece43f94cf5ffb9d31a29c68137932..b62b470f0c93b6172e97c16468128bbf2f98afb8 100644 (file)
@@ -35,10 +35,11 @@ extern int pcibios_write ( struct pci_device *pci, uint32_t command,
 /**
  * Check if PCI bus probing is allowed
  *
+ * @v pci              PCI device
  * @ret ok             Bus probing is allowed
  */
 static inline __always_inline int
-PCIAPI_INLINE ( pcbios, pci_can_probe ) ( void ) {
+PCIAPI_INLINE ( pcbios, pci_can_probe ) ( struct pci_device *pci __unused ) {
        return 1;
 }
 
index 50157658269ceef19b0253d0347897e28fb413c3..1515b20d401e14c010e8bea2b7c41b444d43baf6 100644 (file)
@@ -28,10 +28,11 @@ extern void pcidirect_prepare ( struct pci_device *pci, int where );
 /**
  * Check if PCI bus probing is allowed
  *
+ * @v pci              PCI device
  * @ret ok             Bus probing is allowed
  */
 static inline __always_inline int
-PCIAPI_INLINE ( direct, pci_can_probe ) ( void ) {
+PCIAPI_INLINE ( direct, pci_can_probe ) ( struct pci_device *pci __unused ) {
        return 1;
 }
 
index 43ccb751dd282a0ad7b6ea722f4606d61970223e..3908871b8d70e7713444f2a4f7a9a14cd5c995c6 100644 (file)
@@ -447,10 +447,6 @@ static int pcibus_probe ( struct root_device *rootdev ) {
        uint32_t busdevfn = 0;
        int rc;
 
-       /* Skip automatic probing if prohibited */
-       if ( ! pci_can_probe() )
-               return 0;
-
        do {
                /* Allocate struct pci_device */
                if ( ! pci )
@@ -464,6 +460,10 @@ static int pcibus_probe ( struct root_device *rootdev ) {
                if ( ( rc = pci_find_next ( pci, &busdevfn ) ) != 0 )
                        break;
 
+               /* Skip automatic probing if prohibited */
+               if ( ! pci_can_probe ( pci ) )
+                       continue;
+
                /* Look for a driver */
                if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
                        DBGC ( pci, PCI_FMT " (%04x:%04x class %06x) has no "
index 9e1fd32b2b09e4ce0e8c29fed12478924b813a50..0173c3158876fdd4e3f97aaffbc628fa199bad5b 100644 (file)
@@ -142,6 +142,18 @@ static struct pci_api * pcicloud_api ( struct pci_device *pci ) {
        return api;
 }
 
+/**
+ * Check if PCI bus probing is allowed
+ *
+ * @v pci              PCI device
+ * @ret ok             Bus probing is allowed
+ */
+static int pcicloud_can_probe ( struct pci_device *pci ) {
+       struct pci_api *api = pcicloud_api ( pci );
+
+       return api->pci_can_probe ( pci );
+}
+
 /**
  * Read byte from PCI configuration space
  *
@@ -246,7 +258,7 @@ static void * pcicloud_ioremap ( struct pci_device *pci,
        return api->pci_ioremap ( pci, bus_addr, len );
 }
 
-PROVIDE_PCIAPI_INLINE ( cloud, pci_can_probe );
+PROVIDE_PCIAPI ( cloud, pci_can_probe, pcicloud_can_probe );
 PROVIDE_PCIAPI ( cloud, pci_discover, pcicloud_discover );
 PROVIDE_PCIAPI ( cloud, pci_read_config_byte, pcicloud_read_config_byte );
 PROVIDE_PCIAPI ( cloud, pci_read_config_word, pcicloud_read_config_word );
index 788ba9b9aff712702b1616b9e922ced6a635fe8d..b2c232013e688fdc9c6c3dfd84b6544a8964d471 100644 (file)
@@ -139,10 +139,11 @@ PCIAPI_INLINE ( ecam, pci_ioremap ) ( struct pci_device *pci __unused,
 /**
  * Check if PCI bus probing is allowed
  *
+ * @v pci              PCI device
  * @ret ok             Bus probing is allowed
  */
 static inline __always_inline int
-PCIAPI_INLINE ( ecam, pci_can_probe ) ( void ) {
+PCIAPI_INLINE ( ecam, pci_can_probe ) ( struct pci_device *pci __unused ) {
        return 1;
 }
 
index 9aca02f65b4f0e71f9f89dbd47bb4bf5b763ee52..956795254a583e83ac59d404229773600957806d 100644 (file)
@@ -35,10 +35,11 @@ extern int efipci_write ( struct pci_device *pci, unsigned long location,
 /**
  * Check if PCI bus probing is allowed
  *
+ * @v pci              PCI device
  * @ret ok             Bus probing is allowed
  */
 static inline __always_inline int
-PCIAPI_INLINE ( efi, pci_can_probe ) ( void ) {
+PCIAPI_INLINE ( efi, pci_can_probe ) ( struct pci_device *pci __unused ) {
        return 0;
 }
 
index 2b19e13c325918bfd2bcb6dd158445f6dd370303..f9cd9881940d1b27494b7185070100ddd1932fd1 100644 (file)
@@ -25,10 +25,11 @@ extern int linux_pci_write ( struct pci_device *pci, unsigned long where,
 /**
  * Check if PCI bus probing is allowed
  *
+ * @v pci              PCI device
  * @ret ok             Bus probing is allowed
  */
 static inline __always_inline int
-PCIAPI_INLINE ( linux, pci_can_probe ) ( void ) {
+PCIAPI_INLINE ( linux, pci_can_probe ) ( struct pci_device *pci __unused ) {
        return 1;
 }
 
index 476ede202ed759f9e523adfea9ba0407c008496f..0cdcdc10989ff47f9cd64a100d87066c914a0174 100644 (file)
@@ -22,10 +22,11 @@ struct pci_device;
 /**
  * Check if PCI bus probing is allowed
  *
+ * @v pci              PCI device
  * @ret ok             Bus probing is allowed
  */
 static inline __always_inline int
-PCIAPI_INLINE ( null, pci_can_probe ) ( void ) {
+PCIAPI_INLINE ( null, pci_can_probe ) ( struct pci_device *pci __unused ) {
        return 0;
 }
 
index 456e29e6ee41d4dc869c53b0aba24212b5d49930..0d32adf81ed5175824d31c031ff071745cc3adbc 100644 (file)
@@ -72,9 +72,10 @@ struct pci_range {
 /**
  * Check if PCI bus probing is allowed
  *
+ * @v pci              PCI device
  * @ret ok             Bus probing is allowed
  */
-int pci_can_probe ( void );
+int pci_can_probe ( struct pci_device *pci );
 
 /**
  * Find next PCI bus:dev.fn address range in system
@@ -163,6 +164,7 @@ void * pci_ioremap ( struct pci_device *pci, unsigned long bus_addr,
 /** A runtime selectable PCI I/O API */
 struct pci_api {
        const char *name;
+       typeof ( pci_can_probe ) ( * pci_can_probe );
        typeof ( pci_discover ) ( * pci_discover );
        typeof ( pci_read_config_byte ) ( * pci_read_config_byte );
        typeof ( pci_read_config_word ) ( * pci_read_config_word );
@@ -198,6 +200,7 @@ struct pci_api {
 #define PROVIDE_PCIAPI_RUNTIME( subsys, priority )                        \
        struct pci_api pciapi_ ## subsys __pci_api ( priority ) = {        \
                .name = #subsys,                                           \
+               .pci_can_probe = PCIAPI_INLINE ( subsys, pci_can_probe ),  \
                .pci_discover = PCIAPI_INLINE ( subsys, pci_discover ),    \
                .pci_read_config_byte =                                    \
                        PCIAPI_INLINE ( subsys, pci_read_config_byte ),    \
index 1feef56cb8bc9a3c50d575b3aeb66ea3685d9656..52268908c901ce8a0344af30f9ddd8e06dc7b6d6 100644 (file)
@@ -15,14 +15,4 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define PCIAPI_PREFIX_cloud __cloud_
 #endif
 
-/**
- * Check if PCI bus probing is allowed
- *
- * @ret ok             Bus probing is allowed
- */
-static inline __always_inline int
-PCIAPI_INLINE ( cloud, pci_can_probe ) ( void ) {
-       return 1;
-}
-
 #endif /* _IPXE_PCICLOUD_H */