aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
authorJohn-Mark Gurney <jmg@FreeBSD.org>2006-09-03 00:27:42 +0000
committerJohn-Mark Gurney <jmg@FreeBSD.org>2006-09-03 00:27:42 +0000
commit378f231e7d884bc4d5954638f602f7ff44dfe5b3 (patch)
tree2d913a3cb79e7a1579bdad59426344b90355f220 /sys/kern/subr_bus.c
parent01646adbc89c26f1148440064cdfe77336a61a8f (diff)
downloadsrc-378f231e7d884bc4d5954638f602f7ff44dfe5b3.tar.gz
src-378f231e7d884bc4d5954638f602f7ff44dfe5b3.zip
add a newbus method for obtaining the bus's bus_dma_tag_t... This is
required by arches like sparc64 (not yet implemented) and sun4v where there are seperate IOMMU's for each PCI bus... For all other arches, it will end up returning NULL, which makes it a no-op... Convert a few drivers (the ones we've been working w/ on sun4v) to the new convection... Eventually all drivers will need to replace the parent tag of NULL, w/ bus_get_dma_tag(dev), though dev is usually different for each driver, and will require hand inspection... Reviewed by: scottl (earlier version)
Notes
Notes: svn path=/head/; revision=161928
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r--sys/kern/subr_bus.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index ad2764de019e..3f0a9e21934e 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -3199,6 +3199,22 @@ bus_generic_config_intr(device_t dev, int irq, enum intr_trigger trig,
}
/**
+ * @brief Helper function for implementing BUS_GET_DMA_TAG().
+ *
+ * This simple implementation of BUS_GET_DMA_TAG() simply calls the
+ * BUS_GET_DMA_TAG() method of the parent of @p dev.
+ */
+bus_dma_tag_t
+bus_generic_get_dma_tag(device_t dev, device_t child)
+{
+
+ /* Propagate up the bus hierarchy until someone handles it. */
+ if (dev->parent != NULL)
+ return (BUS_GET_DMA_TAG(dev->parent, child));
+ return (NULL);
+}
+
+/**
* @brief Helper function for implementing BUS_GET_RESOURCE().
*
* This implementation of BUS_GET_RESOURCE() uses the
@@ -3599,6 +3615,23 @@ bus_child_location_str(device_t child, char *buf, size_t buflen)
return (BUS_CHILD_LOCATION_STR(parent, child, buf, buflen));
}
+/**
+ * @brief Wrapper function for BUS_GET_DMA_TAG().
+ *
+ * This function simply calls the BUS_GET_DMA_TAG() method of the
+ * parent of @p dev.
+ */
+bus_dma_tag_t
+bus_get_dma_tag(device_t dev)
+{
+ device_t parent;
+
+ parent = device_get_parent(dev);
+ if (parent == NULL)
+ return (NULL);
+ return (BUS_GET_DMA_TAG(parent, dev));
+}
+
/* Resume all devices and then notify userland that we're up again. */
static int
root_resume(device_t dev)