summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2012-03-07 18:50:33 +0000
committerjhb <jhb@FreeBSD.org>2012-03-07 18:50:33 +0000
commit8696e15fa74558a90bcdc6bb97b3381c0327c92c (patch)
tree4d3ead6ea283ee1fae537cf95e0de080a44023bd
parent30c566d1d8e6e21a5fd40a35bf859a12e9ba03e1 (diff)
downloadFreeBSD-src-8696e15fa74558a90bcdc6bb97b3381c0327c92c.zip
FreeBSD-src-8696e15fa74558a90bcdc6bb97b3381c0327c92c.tar.gz
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.
-rw-r--r--sys/dev/pci/pci.c22
-rw-r--r--sys/dev/pci/pci_private.h1
2 files changed, 15 insertions, 8 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index e49308e..0874e4b 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -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 dev)
{
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
diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h
index 5a083bf..b4c0c9e 100644
--- a/sys/dev/pci/pci_private.h
+++ b/sys/dev/pci/pci_private.h
@@ -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;
OpenPOWER on IntegriCloud