svn commit: r232667 - head/sys/dev/pci
John Baldwin
jhb at FreeBSD.org
Wed Mar 7 18:50:34 UTC 2012
Author: jhb
Date: Wed Mar 7 18:50:33 2012
New Revision: 232667
URL: http://svn.freebsd.org/changeset/base/232667
Log:
Simplify the PCI bus dma tag code a bit. First, don't create a tag at
all for platforms that only have 32-bit bus addresses. Second, remove
the 'tag_valid' flag from the softc. Instead, if we don't create a
tag in pci_attach_common(), just cache the value of our parent's tag
so that we always have a valid tag to return.
Modified:
head/sys/dev/pci/pci.c
head/sys/dev/pci/pci_private.h
Modified: head/sys/dev/pci/pci.c
==============================================================================
--- head/sys/dev/pci/pci.c Wed Mar 7 18:46:21 2012 (r232666)
+++ head/sys/dev/pci/pci.c Wed Mar 7 18:50:33 2012 (r232667)
@@ -77,10 +77,12 @@ __FBSDID("$FreeBSD$");
* However, in the case of PAE, DMA addresses can cross a 4GB
* boundary, so as a workaround use a 2GB boundary.
*/
+#if (BUS_SPACE_MAXADDR > 0xFFFFFFFF)
#ifdef PAE
-#define PCI_DMA_BOUNDARY (1u << 31)
+#define PCI_DMA_BOUNDARY 0x80000000
#else
-#define PCI_DMA_BOUNDARY ((bus_size_t)((uint64_t)1 << 32))
+#define PCI_DMA_BOUNDARY 0x100000000
+#endif
#endif
#define PCIR_IS_BIOS(cfg, reg) \
@@ -3232,7 +3234,10 @@ int
pci_attach_common(device_t dev)
{
struct pci_softc *sc;
- int busno, domain, error;
+ int busno, domain;
+#ifdef PCI_DMA_BOUNDARY
+ int error, tag_valid;
+#endif
sc = device_get_softc(dev);
domain = pcib_get_domain(dev);
@@ -3240,6 +3245,8 @@ pci_attach_common(device_t dev)
if (bootverbose)
device_printf(dev, "domain=%d, physical bus=%d\n",
domain, busno);
+#ifdef PCI_DMA_BOUNDARY
+ tag_valid = 0;
if (device_get_devclass(device_get_parent(device_get_parent(dev))) !=
devclass_find("pci")) {
error = bus_dma_tag_create(bus_get_dma_tag(dev), 1,
@@ -3250,8 +3257,11 @@ pci_attach_common(device_t dev)
device_printf(dev, "Failed to create DMA tag: %d\n",
error);
else
- sc->sc_dma_tag_valid = 1;
+ tag_valid = 1;
}
+ if (!tag_valid)
+#endif
+ sc->sc_dma_tag = bus_get_dma_tag(dev);
return (0);
}
@@ -4363,9 +4373,7 @@ pci_get_dma_tag(device_t bus, device_t d
{
struct pci_softc *sc = device_get_softc(bus);
- if (sc->sc_dma_tag_valid)
- return (sc->sc_dma_tag);
- return (bus_generic_get_dma_tag(bus, dev));
+ return (sc->sc_dma_tag);
}
uint32_t
Modified: head/sys/dev/pci/pci_private.h
==============================================================================
--- head/sys/dev/pci/pci_private.h Wed Mar 7 18:46:21 2012 (r232666)
+++ head/sys/dev/pci/pci_private.h Wed Mar 7 18:50:33 2012 (r232667)
@@ -40,7 +40,6 @@ DECLARE_CLASS(pci_driver);
struct pci_softc {
bus_dma_tag_t sc_dma_tag;
- int sc_dma_tag_valid;
};
extern int pci_do_power_resume;
More information about the svn-src-all
mailing list