mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 02:37:15 +00:00
busdma: remove parent tag tracking
Without filter functions, we do not need to keep track of tag ancestry. All inheritance of the parent tag's parameters occurs when creating the new child tag. Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42895
This commit is contained in:
parent
900907f439
commit
1228b93b41
|
@ -77,7 +77,6 @@ struct bounce_page;
|
|||
struct bounce_zone;
|
||||
|
||||
struct bus_dma_tag {
|
||||
bus_dma_tag_t parent;
|
||||
bus_size_t alignment;
|
||||
bus_addr_t boundary;
|
||||
bus_addr_t lowaddr;
|
||||
|
@ -86,7 +85,6 @@ struct bus_dma_tag {
|
|||
u_int nsegments;
|
||||
bus_size_t maxsegsz;
|
||||
int flags;
|
||||
int ref_count;
|
||||
int map_count;
|
||||
bus_dma_lock_t *lockfunc;
|
||||
void *lockfuncarg;
|
||||
|
@ -332,10 +330,7 @@ might_bounce(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t addr,
|
|||
*
|
||||
* Bouncing can be triggered by DMA that doesn't begin and end on cacheline
|
||||
* boundaries, or doesn't begin on an alignment boundary, or falls within the
|
||||
* exclusion zone of any tag in the ancestry chain.
|
||||
*
|
||||
* For exclusions, walk the chain of tags comparing paddr to the exclusion zone
|
||||
* within each tag.
|
||||
* exclusion zone of the tag.
|
||||
*/
|
||||
static int
|
||||
must_bounce(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t paddr,
|
||||
|
@ -353,17 +348,11 @@ must_bounce(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t paddr,
|
|||
return (1);
|
||||
|
||||
/*
|
||||
* Even though each tag has an exclusion zone that is a superset of its
|
||||
* own and all its ancestors' exclusions, the exclusion zone of each tag
|
||||
* up the chain must be checked within the loop, because the busdma
|
||||
* rules say the filter function is called only when the address lies
|
||||
* within the low-highaddr range of the tag that filterfunc belongs to.
|
||||
* Check the tag's exclusion zone.
|
||||
*/
|
||||
while (dmat != NULL && exclusion_bounce(dmat)) {
|
||||
if (paddr >= dmat->lowaddr && paddr <= dmat->highaddr)
|
||||
return (1);
|
||||
dmat = dmat->parent;
|
||||
}
|
||||
if (exclusion_bounce(dmat) &&
|
||||
paddr >= dmat->lowaddr && paddr <= dmat->highaddr)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -405,7 +394,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
return (ENOMEM);
|
||||
}
|
||||
|
||||
newtag->parent = parent;
|
||||
newtag->alignment = alignment;
|
||||
newtag->boundary = boundary;
|
||||
newtag->lowaddr = trunc_page((vm_paddr_t)lowaddr) + (PAGE_SIZE - 1);
|
||||
|
@ -415,7 +403,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
newtag->nsegments = nsegments;
|
||||
newtag->maxsegsz = maxsegsz;
|
||||
newtag->flags = flags;
|
||||
newtag->ref_count = 1; /* Count ourself */
|
||||
newtag->map_count = 0;
|
||||
if (lockfunc != NULL) {
|
||||
newtag->lockfunc = lockfunc;
|
||||
|
@ -437,14 +424,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
else if (parent->boundary != 0)
|
||||
newtag->boundary = MIN(parent->boundary,
|
||||
newtag->boundary);
|
||||
|
||||
/*
|
||||
* Short circuit to looking at our parent directly since we
|
||||
* have encapsulated all of its information.
|
||||
*/
|
||||
newtag->parent = parent->parent;
|
||||
if (newtag->parent != NULL)
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
}
|
||||
|
||||
if (exclusion_bounce_check(newtag->lowaddr, newtag->highaddr))
|
||||
|
@ -504,7 +483,6 @@ bus_dma_template_clone(bus_dma_template_t *t, bus_dma_tag_t dmat)
|
|||
if (t == NULL || dmat == NULL)
|
||||
return;
|
||||
|
||||
t->parent = dmat->parent;
|
||||
t->alignment = dmat->alignment;
|
||||
t->boundary = dmat->boundary;
|
||||
t->lowaddr = dmat->lowaddr;
|
||||
|
@ -527,39 +505,17 @@ bus_dma_tag_set_domain(bus_dma_tag_t dmat, int domain)
|
|||
int
|
||||
bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
||||
{
|
||||
#ifdef KTR
|
||||
bus_dma_tag_t dmat_copy = dmat;
|
||||
#endif
|
||||
int error;
|
||||
|
||||
error = 0;
|
||||
int error = 0;
|
||||
|
||||
if (dmat != NULL) {
|
||||
if (dmat->map_count != 0) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (dmat != NULL) {
|
||||
bus_dma_tag_t parent;
|
||||
|
||||
parent = dmat->parent;
|
||||
atomic_subtract_int(&dmat->ref_count, 1);
|
||||
if (dmat->ref_count == 0) {
|
||||
atomic_subtract_32(&tags_total, 1);
|
||||
free(dmat, M_BUSDMA);
|
||||
/*
|
||||
* Last reference count, so
|
||||
* release our reference
|
||||
* count on our parent.
|
||||
*/
|
||||
dmat = parent;
|
||||
} else
|
||||
dmat = NULL;
|
||||
}
|
||||
free(dmat, M_BUSDMA);
|
||||
}
|
||||
out:
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat_copy, error);
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
|
@ -309,42 +309,19 @@ bounce_bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
static int
|
||||
bounce_bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
||||
{
|
||||
#ifdef KTR
|
||||
bus_dma_tag_t dmat_copy;
|
||||
#endif
|
||||
bus_dma_tag_t parent;
|
||||
int error;
|
||||
|
||||
error = 0;
|
||||
#ifdef KTR
|
||||
dmat_copy = dmat;
|
||||
#endif
|
||||
|
||||
int error = 0;
|
||||
|
||||
if (dmat != NULL) {
|
||||
if (dmat->map_count != 0) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
while (dmat != NULL) {
|
||||
parent = (bus_dma_tag_t)dmat->common.parent;
|
||||
atomic_subtract_int(&dmat->common.ref_count, 1);
|
||||
if (dmat->common.ref_count == 0) {
|
||||
if (dmat->segments != NULL)
|
||||
free(dmat->segments, M_DEVBUF);
|
||||
free(dmat, M_DEVBUF);
|
||||
/*
|
||||
* Last reference count, so
|
||||
* release our reference
|
||||
* count on our parent.
|
||||
*/
|
||||
dmat = parent;
|
||||
} else
|
||||
dmat = NULL;
|
||||
}
|
||||
if (dmat->segments != NULL)
|
||||
free(dmat->segments, M_DEVBUF);
|
||||
free(dmat, M_DEVBUF);
|
||||
}
|
||||
out:
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat_copy, error);
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,12 +61,8 @@ int
|
|||
bus_dma_run_filter(struct bus_dma_tag_common *tc, bus_addr_t paddr)
|
||||
{
|
||||
|
||||
while (tc != NULL) {
|
||||
if (paddr > tc->lowaddr && paddr <= tc->highaddr)
|
||||
return (1);
|
||||
|
||||
tc = tc->parent;
|
||||
}
|
||||
if (paddr > tc->lowaddr && paddr <= tc->highaddr)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -99,7 +95,6 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
|||
|
||||
common = newtag;
|
||||
common->impl = &bus_dma_bounce_impl;
|
||||
common->parent = parent;
|
||||
common->alignment = alignment;
|
||||
common->boundary = boundary;
|
||||
common->lowaddr = trunc_page((vm_paddr_t)lowaddr) + (PAGE_SIZE - 1);
|
||||
|
@ -108,7 +103,6 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
|||
common->nsegments = nsegments;
|
||||
common->maxsegsz = maxsegsz;
|
||||
common->flags = flags;
|
||||
common->ref_count = 1; /* Count ourself */
|
||||
if (lockfunc != NULL) {
|
||||
common->lockfunc = lockfunc;
|
||||
common->lockfuncarg = lockfuncarg;
|
||||
|
@ -130,13 +124,7 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
|||
common->boundary);
|
||||
}
|
||||
|
||||
/*
|
||||
* Short circuit looking at our parent directly since we have
|
||||
* encapsulated all of its information.
|
||||
*/
|
||||
common->parent = parent->parent;
|
||||
common->domain = parent->domain;
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
}
|
||||
common->domain = vm_phys_domain_match(common->domain, 0ul,
|
||||
common->lowaddr);
|
||||
|
@ -184,7 +172,6 @@ bus_dma_template_clone(bus_dma_template_t *t, bus_dma_tag_t dmat)
|
|||
|
||||
common = (struct bus_dma_tag_common *)dmat;
|
||||
|
||||
t->parent = (bus_dma_tag_t)common->parent;
|
||||
t->alignment = common->alignment;
|
||||
t->boundary = common->boundary;
|
||||
t->lowaddr = common->lowaddr;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
struct bus_dma_tag_common {
|
||||
struct bus_dma_impl *impl;
|
||||
struct bus_dma_tag_common *parent;
|
||||
bus_size_t alignment;
|
||||
bus_addr_t boundary;
|
||||
bus_addr_t lowaddr;
|
||||
|
@ -42,7 +41,6 @@ struct bus_dma_tag_common {
|
|||
int flags;
|
||||
bus_dma_lock_t *lockfunc;
|
||||
void *lockfuncarg;
|
||||
int ref_count;
|
||||
int domain;
|
||||
};
|
||||
|
||||
|
|
|
@ -394,33 +394,24 @@ iommu_bus_dma_tag_set_domain(bus_dma_tag_t dmat)
|
|||
static int
|
||||
iommu_bus_dma_tag_destroy(bus_dma_tag_t dmat1)
|
||||
{
|
||||
struct bus_dma_tag_iommu *dmat, *parent;
|
||||
struct bus_dma_tag_iommu *dmat_copy __unused;
|
||||
struct bus_dma_tag_iommu *dmat;
|
||||
int error;
|
||||
|
||||
error = 0;
|
||||
dmat_copy = dmat = (struct bus_dma_tag_iommu *)dmat1;
|
||||
dmat = (struct bus_dma_tag_iommu *)dmat1;
|
||||
|
||||
if (dmat != NULL) {
|
||||
if (dmat->map_count != 0) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
while (dmat != NULL) {
|
||||
parent = (struct bus_dma_tag_iommu *)dmat->common.parent;
|
||||
if (atomic_fetchadd_int(&dmat->common.ref_count, -1) ==
|
||||
1) {
|
||||
if (dmat == dmat->ctx->tag)
|
||||
iommu_free_ctx(dmat->ctx);
|
||||
free(dmat->segments, M_IOMMU_DMAMAP);
|
||||
free(dmat, M_DEVBUF);
|
||||
dmat = parent;
|
||||
} else
|
||||
dmat = NULL;
|
||||
}
|
||||
if (dmat == dmat->ctx->tag)
|
||||
iommu_free_ctx(dmat->ctx);
|
||||
free(dmat->segments, M_IOMMU_DMAMAP);
|
||||
free(dmat, M_DEVBUF);
|
||||
}
|
||||
out:
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat_copy, error);
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@ struct bounce_page;
|
|||
struct bounce_zone;
|
||||
|
||||
struct bus_dma_tag {
|
||||
bus_dma_tag_t parent;
|
||||
bus_size_t alignment;
|
||||
bus_addr_t boundary;
|
||||
bus_addr_t lowaddr;
|
||||
|
@ -72,7 +71,6 @@ struct bus_dma_tag {
|
|||
bus_size_t maxsegsz;
|
||||
u_int nsegments;
|
||||
int flags;
|
||||
int ref_count;
|
||||
int map_count;
|
||||
bus_dma_lock_t *lockfunc;
|
||||
void *lockfuncarg;
|
||||
|
@ -126,15 +124,12 @@ run_filter(bus_dma_tag_t dmat, bus_addr_t paddr)
|
|||
|
||||
retval = 0;
|
||||
|
||||
do {
|
||||
if (dmat->iommu == NULL &&
|
||||
paddr > dmat->lowaddr && paddr <= dmat->highaddr)
|
||||
retval = 1;
|
||||
if (!vm_addr_align_ok(paddr, dmat->alignment))
|
||||
retval = 1;
|
||||
if (dmat->iommu == NULL &&
|
||||
paddr > dmat->lowaddr && paddr <= dmat->highaddr)
|
||||
retval = 1;
|
||||
if (!vm_addr_align_ok(paddr, dmat->alignment))
|
||||
retval = 1;
|
||||
|
||||
dmat = dmat->parent;
|
||||
} while (retval == 0 && dmat != NULL);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
@ -177,7 +172,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
return (ENOMEM);
|
||||
}
|
||||
|
||||
newtag->parent = parent;
|
||||
newtag->alignment = alignment;
|
||||
newtag->boundary = boundary;
|
||||
newtag->lowaddr = trunc_page((vm_paddr_t)lowaddr) + (PAGE_SIZE - 1);
|
||||
|
@ -186,7 +180,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
newtag->nsegments = nsegments;
|
||||
newtag->maxsegsz = maxsegsz;
|
||||
newtag->flags = flags;
|
||||
newtag->ref_count = 1; /* Count ourself */
|
||||
newtag->map_count = 0;
|
||||
if (lockfunc != NULL) {
|
||||
newtag->lockfunc = lockfunc;
|
||||
|
@ -206,13 +199,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
newtag->boundary = MIN(parent->boundary,
|
||||
newtag->boundary);
|
||||
|
||||
/*
|
||||
* Short circuit looking at our parent directly since we have
|
||||
* encapsulated all of its information.
|
||||
*/
|
||||
newtag->parent = parent->parent;
|
||||
if (newtag->parent != NULL)
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
newtag->iommu = parent->iommu;
|
||||
newtag->iommu_cookie = parent->iommu_cookie;
|
||||
}
|
||||
|
@ -265,7 +251,6 @@ bus_dma_template_clone(bus_dma_template_t *t, bus_dma_tag_t dmat)
|
|||
if (t == NULL || dmat == NULL)
|
||||
return;
|
||||
|
||||
t->parent = dmat->parent;
|
||||
t->alignment = dmat->alignment;
|
||||
t->boundary = dmat->boundary;
|
||||
t->lowaddr = dmat->lowaddr;
|
||||
|
@ -288,11 +273,7 @@ bus_dma_tag_set_domain(bus_dma_tag_t dmat, int domain)
|
|||
int
|
||||
bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
||||
{
|
||||
bus_dma_tag_t dmat_copy __unused;
|
||||
int error;
|
||||
|
||||
error = 0;
|
||||
dmat_copy = dmat;
|
||||
int error = 0;
|
||||
|
||||
if (dmat != NULL) {
|
||||
if (dmat->map_count != 0) {
|
||||
|
@ -300,25 +281,10 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
|||
goto out;
|
||||
}
|
||||
|
||||
while (dmat != NULL) {
|
||||
bus_dma_tag_t parent;
|
||||
|
||||
parent = dmat->parent;
|
||||
atomic_subtract_int(&dmat->ref_count, 1);
|
||||
if (dmat->ref_count == 0) {
|
||||
free(dmat, M_DEVBUF);
|
||||
/*
|
||||
* Last reference count, so
|
||||
* release our reference
|
||||
* count on our parent.
|
||||
*/
|
||||
dmat = parent;
|
||||
} else
|
||||
dmat = NULL;
|
||||
}
|
||||
free(dmat, M_DEVBUF);
|
||||
}
|
||||
out:
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat_copy, error);
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
struct bus_dma_tag_common {
|
||||
struct bus_dma_impl *impl;
|
||||
struct bus_dma_tag_common *parent;
|
||||
bus_size_t alignment;
|
||||
bus_addr_t boundary;
|
||||
bus_addr_t lowaddr;
|
||||
|
@ -42,7 +41,6 @@ struct bus_dma_tag_common {
|
|||
int flags;
|
||||
bus_dma_lock_t *lockfunc;
|
||||
void *lockfuncarg;
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
struct bus_dma_impl {
|
||||
|
|
|
@ -196,38 +196,19 @@ bounce_bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
static int
|
||||
bounce_bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
||||
{
|
||||
#ifdef KTR
|
||||
bus_dma_tag_t dmat_copy = dmat;
|
||||
#endif
|
||||
bus_dma_tag_t parent;
|
||||
int error;
|
||||
|
||||
error = 0;
|
||||
int error = 0;
|
||||
|
||||
if (dmat != NULL) {
|
||||
if (dmat->map_count != 0) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
while (dmat != NULL) {
|
||||
parent = (bus_dma_tag_t)dmat->common.parent;
|
||||
atomic_subtract_int(&dmat->common.ref_count, 1);
|
||||
if (dmat->common.ref_count == 0) {
|
||||
if (dmat->segments != NULL)
|
||||
free(dmat->segments, M_DEVBUF);
|
||||
free(dmat, M_DEVBUF);
|
||||
/*
|
||||
* Last reference count, so
|
||||
* release our reference
|
||||
* count on our parent.
|
||||
*/
|
||||
dmat = parent;
|
||||
} else
|
||||
dmat = NULL;
|
||||
}
|
||||
if (dmat->segments != NULL)
|
||||
free(dmat->segments, M_DEVBUF);
|
||||
free(dmat, M_DEVBUF);
|
||||
}
|
||||
out:
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat_copy, error);
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,13 +62,10 @@ bus_dma_run_filter(struct bus_dma_tag_common *tc, bus_addr_t paddr)
|
|||
int retval;
|
||||
|
||||
retval = 0;
|
||||
do {
|
||||
if ((paddr > tc->lowaddr && paddr <= tc->highaddr) ||
|
||||
!vm_addr_align_ok(paddr, tc->alignment))
|
||||
retval = 1;
|
||||
if ((paddr > tc->lowaddr && paddr <= tc->highaddr) ||
|
||||
!vm_addr_align_ok(paddr, tc->alignment))
|
||||
retval = 1;
|
||||
|
||||
tc = tc->parent;
|
||||
} while (retval == 0 && tc != NULL);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
@ -100,7 +97,6 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
|||
|
||||
common = newtag;
|
||||
common->impl = &bus_dma_bounce_impl;
|
||||
common->parent = parent;
|
||||
common->alignment = alignment;
|
||||
common->boundary = boundary;
|
||||
common->lowaddr = trunc_page((vm_paddr_t)lowaddr) + (PAGE_SIZE - 1);
|
||||
|
@ -109,7 +105,6 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
|||
common->nsegments = nsegments;
|
||||
common->maxsegsz = maxsegsz;
|
||||
common->flags = flags;
|
||||
common->ref_count = 1; /* Count ourself */
|
||||
if (lockfunc != NULL) {
|
||||
common->lockfunc = lockfunc;
|
||||
common->lockfuncarg = lockfuncarg;
|
||||
|
@ -129,13 +124,6 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
|||
common->boundary = MIN(parent->boundary,
|
||||
common->boundary);
|
||||
}
|
||||
|
||||
/*
|
||||
* Short circuit looking at our parent directly since we have
|
||||
* encapsulated all of its information.
|
||||
*/
|
||||
common->parent = parent->parent;
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
}
|
||||
*dmat = common;
|
||||
return (0);
|
||||
|
@ -181,7 +169,6 @@ bus_dma_template_clone(bus_dma_template_t *t, bus_dma_tag_t dmat)
|
|||
|
||||
common = (struct bus_dma_tag_common *)dmat;
|
||||
|
||||
t->parent = (bus_dma_tag_t)common->parent;
|
||||
t->alignment = common->alignment;
|
||||
t->boundary = common->boundary;
|
||||
t->lowaddr = common->lowaddr;
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
struct bus_dma_tag_common {
|
||||
struct bus_dma_impl *impl;
|
||||
struct bus_dma_tag_common *parent;
|
||||
bus_size_t alignment;
|
||||
bus_addr_t boundary;
|
||||
bus_addr_t lowaddr;
|
||||
|
@ -44,7 +43,6 @@ struct bus_dma_tag_common {
|
|||
int flags;
|
||||
bus_dma_lock_t *lockfunc;
|
||||
void *lockfuncarg;
|
||||
int ref_count;
|
||||
int domain;
|
||||
};
|
||||
|
||||
|
|
|
@ -128,7 +128,6 @@ device_tag_init(struct dmar_ctx *ctx, device_t dev)
|
|||
|
||||
domain = CTX2DOM(ctx);
|
||||
maxaddr = MIN(domain->iodom.end, BUS_SPACE_MAXADDR);
|
||||
ctx->context.tag->common.ref_count = 1; /* Prevent free */
|
||||
ctx->context.tag->common.impl = &bus_dma_iommu_impl;
|
||||
ctx->context.tag->common.boundary = 0;
|
||||
ctx->context.tag->common.lowaddr = maxaddr;
|
||||
|
|
|
@ -227,38 +227,19 @@ bounce_bus_dma_tag_set_domain(bus_dma_tag_t dmat)
|
|||
static int
|
||||
bounce_bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
||||
{
|
||||
#ifdef KTR
|
||||
bus_dma_tag_t dmat_copy = dmat;
|
||||
#endif
|
||||
bus_dma_tag_t parent;
|
||||
int error;
|
||||
|
||||
error = 0;
|
||||
int error = 0;
|
||||
|
||||
if (dmat != NULL) {
|
||||
if (dmat->map_count != 0) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
while (dmat != NULL) {
|
||||
parent = (bus_dma_tag_t)dmat->common.parent;
|
||||
atomic_subtract_int(&dmat->common.ref_count, 1);
|
||||
if (dmat->common.ref_count == 0) {
|
||||
if (dmat->segments != NULL)
|
||||
free(dmat->segments, M_DEVBUF);
|
||||
free(dmat, M_DEVBUF);
|
||||
/*
|
||||
* Last reference count, so
|
||||
* release our reference
|
||||
* count on our parent.
|
||||
*/
|
||||
dmat = parent;
|
||||
} else
|
||||
dmat = NULL;
|
||||
}
|
||||
if (dmat->segments != NULL)
|
||||
free(dmat->segments, M_DEVBUF);
|
||||
free(dmat, M_DEVBUF);
|
||||
}
|
||||
out:
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat_copy, error);
|
||||
CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat, error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,14 +67,11 @@ bus_dma_run_filter(struct bus_dma_tag_common *tc, vm_paddr_t paddr)
|
|||
int retval;
|
||||
|
||||
retval = 0;
|
||||
do {
|
||||
if (paddr >= BUS_SPACE_MAXADDR ||
|
||||
(paddr > tc->lowaddr && paddr <= tc->highaddr) ||
|
||||
!vm_addr_align_ok(paddr, tc->alignment))
|
||||
retval = 1;
|
||||
if (paddr >= BUS_SPACE_MAXADDR ||
|
||||
(paddr > tc->lowaddr && paddr <= tc->highaddr) ||
|
||||
!vm_addr_align_ok(paddr, tc->alignment))
|
||||
retval = 1;
|
||||
|
||||
tc = tc->parent;
|
||||
} while (retval == 0 && tc != NULL);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
@ -106,7 +103,6 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
|||
|
||||
common = newtag;
|
||||
common->impl = &bus_dma_bounce_impl;
|
||||
common->parent = parent;
|
||||
common->alignment = alignment;
|
||||
common->boundary = boundary;
|
||||
common->lowaddr = trunc_page((vm_paddr_t)lowaddr) + (PAGE_SIZE - 1);
|
||||
|
@ -115,7 +111,6 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
|||
common->nsegments = nsegments;
|
||||
common->maxsegsz = maxsegsz;
|
||||
common->flags = flags;
|
||||
common->ref_count = 1; /* Count ourself */
|
||||
if (lockfunc != NULL) {
|
||||
common->lockfunc = lockfunc;
|
||||
common->lockfuncarg = lockfuncarg;
|
||||
|
@ -136,13 +131,7 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
|||
common->boundary);
|
||||
}
|
||||
|
||||
/*
|
||||
* Short circuit looking at our parent directly since we have
|
||||
* encapsulated all of its information.
|
||||
*/
|
||||
common->parent = parent->parent;
|
||||
common->domain = parent->domain;
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
}
|
||||
common->domain = vm_phys_domain_match(common->domain, 0ul,
|
||||
common->lowaddr);
|
||||
|
@ -204,7 +193,6 @@ bus_dma_template_clone(bus_dma_template_t *t, bus_dma_tag_t dmat)
|
|||
|
||||
common = (struct bus_dma_tag_common *)dmat;
|
||||
|
||||
t->parent = (bus_dma_tag_t)common->parent;
|
||||
t->alignment = common->alignment;
|
||||
t->boundary = common->boundary;
|
||||
t->lowaddr = common->lowaddr;
|
||||
|
|
Loading…
Reference in a new issue