Author: landonf
Date: Fri Jan 19 22:22:02 2018
New Revision: 328180
URL: https://svnweb.freebsd.org/changeset/base/328180

Log:
  bhndb_pci(4): Implement bridge support for CardBus-attached devices.
  
   - Extend the probe method to accept devclasses that inherit from the pci
     devclass (e.g. cardbus).
   - Some BCM4306-based CardBus adapters appear to advertise 4K SPROM, but
     only the first 2K is mapped into BAR0. We can safely assume that the
     SPROM data fits within the first 2K of the SPROM, rather than rejecting
     the SPROM mapping as invalid.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/bhnd/bhndb/bhndb_pci.c

Modified: head/sys/dev/bhnd/bhndb/bhndb_pci.c
==============================================================================
--- head/sys/dev/bhnd/bhndb/bhndb_pci.c Fri Jan 19 22:19:50 2018        
(r328179)
+++ head/sys/dev/bhnd/bhndb/bhndb_pci.c Fri Jan 19 22:22:02 2018        
(r328180)
@@ -264,8 +264,8 @@ bhndb_pci_probe(device_t dev)
        struct bhndb_pci_probe  *probe;
        struct bhndb_pci_core   *entry;
        bhnd_devclass_t          hostb_devclass;
-       device_t                 parent;
-       devclass_t               parent_bus, pci;
+       device_t                 parent, parent_bus;
+       devclass_t               pci, bus_devclass;
        int                      error;
 
        probe = NULL;
@@ -273,9 +273,20 @@ bhndb_pci_probe(device_t dev)
        /* Our parent must be a PCI/PCIe device. */
        pci = devclass_find("pci");
        parent = device_get_parent(dev);
-       parent_bus = device_get_devclass(device_get_parent(parent));
+       parent_bus = device_get_parent(parent);
+       if (parent_bus == NULL)
+               return (ENXIO);
 
-       if (parent_bus != pci)
+       /* The bus device class may inherit from 'pci' */
+       for (bus_devclass = device_get_devclass(parent_bus);
+           bus_devclass != NULL;
+           bus_devclass = devclass_get_parent(bus_devclass))
+       {
+               if (bus_devclass == pci)
+                       break;
+       }
+
+       if (bus_devclass != pci)
                return (ENXIO);
 
        /* Enable clocks */
@@ -629,12 +640,10 @@ bhndb_pci_sprom_size(struct bhndb_pci_softc *sc)
                return (0);
        }
 
-       if (sprom_sz > sprom_win->win_size) {
-               device_printf(sc->dev,
-                   "PCI sprom size (0x%x) overruns defined register window\n",
-                   sctl);
-               return (0);
-       }
+       /* If the device has a larger SPROM than can be addressed via our SPROM
+        * register window, the SPROM image data will still be located within
+        * the window's addressable range */
+       sprom_sz = MIN(sprom_sz, sprom_win->win_size);
 
        return (sprom_sz);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to