mirror of
https://github.com/opnsense/src.git
synced 2026-07-16 12:33:07 -04:00
Use atomic operations to increment and decrement the refcount
in busdma tags. There are currently no tags shared accross different drivers so this isn't needed at the moment, but it will be required when we'll have a proper newbus method to get the parent busdma tag.
This commit is contained in:
parent
b79b44a90f
commit
fd1b2ab0c9
6 changed files with 23 additions and 22 deletions
|
|
@ -42,6 +42,7 @@
|
|||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_map.h>
|
||||
|
||||
#include <machine/atomic.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/sgmap.h>
|
||||
#include <machine/md_var.h>
|
||||
|
|
@ -179,9 +180,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
newtag->filterarg = parent->filterarg;
|
||||
newtag->parent = parent->parent;
|
||||
}
|
||||
if (newtag->parent != NULL) {
|
||||
parent->ref_count++;
|
||||
}
|
||||
if (newtag->parent != NULL)
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
}
|
||||
|
||||
if (newtag->lowaddr < ptoa(Maxmem) && (flags & BUS_DMA_ALLOCNOW) != 0) {
|
||||
|
|
@ -228,7 +228,7 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
|||
bus_dma_tag_t parent;
|
||||
|
||||
parent = dmat->parent;
|
||||
dmat->ref_count--;
|
||||
atomic_subtract_int(&dmat->ref_count, 1);
|
||||
if (dmat->ref_count == 0) {
|
||||
free(dmat, M_DEVBUF);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_map.h>
|
||||
|
||||
#include <machine/atomic.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/md_var.h>
|
||||
|
||||
|
|
@ -186,9 +187,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
newtag->filterarg = parent->filterarg;
|
||||
newtag->parent = parent->parent;
|
||||
}
|
||||
if (newtag->parent != NULL) {
|
||||
parent->ref_count++;
|
||||
}
|
||||
if (newtag->parent != NULL)
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
}
|
||||
|
||||
if (newtag->lowaddr < ptoa(Maxmem) && (flags & BUS_DMA_ALLOCNOW) != 0) {
|
||||
|
|
@ -235,7 +235,7 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
|||
bus_dma_tag_t parent;
|
||||
|
||||
parent = dmat->parent;
|
||||
dmat->ref_count--;
|
||||
atomic_subtract_int(&dmat->ref_count, 1);
|
||||
if (dmat->ref_count == 0) {
|
||||
free(dmat, M_DEVBUF);
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_map.h>
|
||||
|
||||
#include <machine/atomic.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/md_var.h>
|
||||
|
||||
|
|
@ -186,9 +187,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
newtag->filterarg = parent->filterarg;
|
||||
newtag->parent = parent->parent;
|
||||
}
|
||||
if (newtag->parent != NULL) {
|
||||
parent->ref_count++;
|
||||
}
|
||||
if (newtag->parent != NULL)
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
}
|
||||
|
||||
if (newtag->lowaddr < ptoa(Maxmem) && (flags & BUS_DMA_ALLOCNOW) != 0) {
|
||||
|
|
@ -235,7 +235,7 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
|||
bus_dma_tag_t parent;
|
||||
|
||||
parent = dmat->parent;
|
||||
dmat->ref_count--;
|
||||
atomic_subtract_int(&dmat->ref_count, 1);
|
||||
if (dmat->ref_count == 0) {
|
||||
free(dmat, M_DEVBUF);
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_map.h>
|
||||
|
||||
#include <machine/atomic.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/md_var.h>
|
||||
|
||||
|
|
@ -175,9 +176,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
newtag->filterarg = parent->filterarg;
|
||||
newtag->parent = parent->parent;
|
||||
}
|
||||
if (newtag->parent != NULL) {
|
||||
parent->ref_count++;
|
||||
}
|
||||
if (newtag->parent != NULL)
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
}
|
||||
|
||||
if (newtag->lowaddr < ptoa(Maxmem) && (flags & BUS_DMA_ALLOCNOW) != 0) {
|
||||
|
|
@ -224,7 +224,7 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
|||
bus_dma_tag_t parent;
|
||||
|
||||
parent = dmat->parent;
|
||||
dmat->ref_count--;
|
||||
atomic_subtract_int(&dmat->ref_count, 1);
|
||||
if (dmat->ref_count == 0) {
|
||||
free(dmat, M_DEVBUF);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ static const char rcsid[] =
|
|||
#include <vm/vm_page.h>
|
||||
#include <vm/vm_map.h>
|
||||
|
||||
#include <machine/atomic.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/cpufunc.h>
|
||||
|
||||
|
|
@ -133,9 +134,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
newtag->filterarg = parent->filterarg;
|
||||
newtag->parent = parent->parent;
|
||||
}
|
||||
if (newtag->parent != NULL) {
|
||||
parent->ref_count++;
|
||||
}
|
||||
if (newtag->parent != NULL)
|
||||
atomic_add_int(&parent->ref_count, 1);
|
||||
}
|
||||
|
||||
*dmat = newtag;
|
||||
|
|
@ -154,7 +154,7 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
|||
bus_dma_tag_t parent;
|
||||
|
||||
parent = dmat->parent;
|
||||
dmat->ref_count--;
|
||||
atomic_subtract_int(&dmat->ref_count, 1);
|
||||
if (dmat->ref_count == 0) {
|
||||
free(dmat, M_DEVBUF);
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@
|
|||
#include <vm/vm_map.h>
|
||||
|
||||
#include <machine/asi.h>
|
||||
#include <machine/atomic.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/bus_private.h>
|
||||
#include <machine/cache.h>
|
||||
|
|
@ -246,7 +247,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
|||
newtag->dt_boundary = ulmin(parent->dt_boundary,
|
||||
newtag->dt_boundary);
|
||||
}
|
||||
newtag->dt_parent->dt_ref_count++;
|
||||
atomic_add_int(&newtag->dt_parent->dt_ref_count, 1);
|
||||
|
||||
*dmat = newtag;
|
||||
return (0);
|
||||
|
|
@ -262,7 +263,7 @@ bus_dma_tag_destroy(bus_dma_tag_t dmat)
|
|||
return (EBUSY);
|
||||
while (dmat != NULL) {
|
||||
parent = dmat->dt_parent;
|
||||
dmat->dt_ref_count--;
|
||||
atomic_subtract_int(&dmat->dt_ref_count, 1);
|
||||
if (dmat->dt_ref_count == 0) {
|
||||
free(dmat, M_DEVBUF);
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue