svn commit: r236536 - projects/altix2/sys/kern
Marcel Moolenaar
marcel at FreeBSD.org
Mon Jun 4 06:00:58 UTC 2012
Author: marcel
Date: Mon Jun 4 06:00:57 2012
New Revision: 236536
URL: http://svn.freebsd.org/changeset/base/236536
Log:
o Add a default implementation of busdma_iommu_xlate that yields an
identify mapping (i.e. does not change the mtag and returns 0).
o Add _busdma_iommu_xlate that walks the device hierarchy until it
reaches the root. This allows all devices on the path from leaf
to root to contribute to the final mtag.
Modified:
projects/altix2/sys/kern/busdma_if.m
projects/altix2/sys/kern/subr_busdma.c
Modified: projects/altix2/sys/kern/busdma_if.m
==============================================================================
--- projects/altix2/sys/kern/busdma_if.m Mon Jun 4 04:24:59 2012 (r236535)
+++ projects/altix2/sys/kern/busdma_if.m Mon Jun 4 06:00:57 2012 (r236536)
@@ -31,10 +31,19 @@
INTERFACE busdma;
+# Default implementations
+CODE {
+ static int
+ default_iommu_xlate(device_t dev, busdma_mtag_t mtag)
+ {
+ return (0);
+ }
+};
+
METHOD int iommu_xlate {
device_t dev;
busdma_mtag_t mtag;
-};
+} DEFAULT default_iommu_xlate;
METHOD int iommu_map {
device_t dev;
Modified: projects/altix2/sys/kern/subr_busdma.c
==============================================================================
--- projects/altix2/sys/kern/subr_busdma.c Mon Jun 4 04:24:59 2012 (r236535)
+++ projects/altix2/sys/kern/subr_busdma.c Mon Jun 4 06:00:57 2012 (r236536)
@@ -107,6 +107,17 @@ static MALLOC_DEFINE(M_BUSDMA_MD, "busdm
static MALLOC_DEFINE(M_BUSDMA_TAG, "busdma_tag", "DMA tags");
static void
+_busdma_mtag_dump(const char *func, device_t dev, struct busdma_mtag *mtag)
+{
+
+ printf("[%s: %s: min=%#lx, max=%#lx, size=%#lx, align=%#lx, "
+ "bndry=%#lx]\n", __func__,
+ (dev != NULL) ? device_get_nameunit(dev) : "*",
+ mtag->dmt_minaddr, mtag->dmt_maxaddr, mtag->dmt_maxsz,
+ mtag->dmt_align, mtag->dmt_bndry);
+}
+
+static void
_busdma_tag_dump(const char *func, device_t dev, struct busdma_tag *tag)
{
@@ -209,6 +220,22 @@ _busdma_md_create(struct busdma_tag *tag
return (md);
}
+static int
+_busdma_iommu_xlate(device_t dev, struct busdma_mtag *mtag)
+{
+ int error;
+
+ error = 0;
+ while (!error && dev != NULL) {
+ _busdma_mtag_dump(__func__, dev, mtag);
+ error = BUSDMA_IOMMU_XLATE(dev, mtag);
+ if (!error)
+ dev = device_get_parent(dev);
+ }
+ _busdma_mtag_dump(__func__, dev, mtag);
+ return (error);
+}
+
int
busdma_tag_create(device_t dev, bus_addr_t align, bus_addr_t bndry,
bus_addr_t maxaddr, bus_size_t maxsz, u_int nsegs, bus_size_t maxsegsz,
@@ -381,7 +408,6 @@ busdma_mem_alloc(struct busdma_tag *tag,
struct busdma_md *md;
struct busdma_md_seg *seg;
struct busdma_mtag mtag;
- device_t bus;
vm_size_t maxsz;
u_int idx;
int error;
@@ -390,18 +416,20 @@ busdma_mem_alloc(struct busdma_tag *tag,
if (md == NULL)
return (ENOMEM);
+ idx = 0;
+
mtag.dmt_minaddr = tag->dt_minaddr;
mtag.dmt_maxaddr = tag->dt_maxaddr;
mtag.dmt_maxsz = tag->dt_maxsegsz;
mtag.dmt_align = tag->dt_align;
mtag.dmt_bndry = tag->dt_bndry;
- bus = device_get_parent(tag->dt_device);
- error = BUSDMA_IOMMU_XLATE(bus, &mtag);
- if (error)
- printf("BUSDMA_IOMMU_XLATE: error=%d\n", error);
+ error = _busdma_iommu_xlate(tag->dt_device, &mtag);
+ if (error) {
+ printf("_busdma_iommu_xlate: error=%d\n", error);
+ goto fail;
+ }
- idx = 0;
maxsz = tag->dt_maxsz;
while (maxsz > 0 && idx < tag->dt_nsegs) {
seg = &md->md_seg[idx];
@@ -420,7 +448,7 @@ busdma_mem_alloc(struct busdma_tag *tag,
}
if (maxsz == 0) {
md->md_nsegs = idx;
- error = BUSDMA_IOMMU_MAP(bus, md);
+ error = BUSDMA_IOMMU_MAP(tag->dt_device, md);
if (error)
printf("BUSDMA_IOMMU_MAP: error=%d\n", error);
_busdma_md_dump(__func__, md);
More information about the svn-src-projects
mailing list