bus_dma: Deduplicate locking helper functions.
- Move busdma_lock_mutex to subr_bus_dma.c. - Move _busdma_lock_dflt to subr_bus_dma.c. This function was named a couple of different things previously. It is not a public API but an internal helper used in place of a NULL pointer. The prototype is in <sys/bus_dma.h> as not all backends include <sys/bus_dma_internal.h>. Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D33694
This commit is contained in:
parent
85b4607324
commit
7def1e10b3
@ -375,41 +375,6 @@ must_bounce(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t paddr,
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convenience function for manipulating driver locks from busdma (during
|
||||
* busdma_swi, for example).
|
||||
*/
|
||||
void
|
||||
busdma_lock_mutex(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
struct mtx *dmtx;
|
||||
|
||||
dmtx = (struct mtx *)arg;
|
||||
switch (op) {
|
||||
case BUS_DMA_LOCK:
|
||||
mtx_lock(dmtx);
|
||||
break;
|
||||
case BUS_DMA_UNLOCK:
|
||||
mtx_unlock(dmtx);
|
||||
break;
|
||||
default:
|
||||
panic("Unknown operation 0x%x for busdma_lock_mutex!", op);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dflt_lock should never get called. It gets put into the dma tag when
|
||||
* lockfunc == NULL, which is only valid if the maps that are associated
|
||||
* with the tag are meant to never be defered.
|
||||
* XXX Should have a way to identify which driver is responsible here.
|
||||
*/
|
||||
static void
|
||||
dflt_lock(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
|
||||
panic("driver error: busdma dflt_lock called");
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a device specific dma_tag.
|
||||
*/
|
||||
@ -461,7 +426,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
||||
newtag->lockfunc = lockfunc;
|
||||
newtag->lockfuncarg = lockfuncarg;
|
||||
} else {
|
||||
newtag->lockfunc = dflt_lock;
|
||||
newtag->lockfunc = _busdma_dflt_lock;
|
||||
newtag->lockfuncarg = NULL;
|
||||
}
|
||||
|
||||
|
@ -51,41 +51,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/bus.h>
|
||||
#include <arm64/include/bus_dma_impl.h>
|
||||
|
||||
/*
|
||||
* Convenience function for manipulating driver locks from busdma (during
|
||||
* busdma_swi, for example).
|
||||
*/
|
||||
void
|
||||
busdma_lock_mutex(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
struct mtx *dmtx;
|
||||
|
||||
dmtx = (struct mtx *)arg;
|
||||
switch (op) {
|
||||
case BUS_DMA_LOCK:
|
||||
mtx_lock(dmtx);
|
||||
break;
|
||||
case BUS_DMA_UNLOCK:
|
||||
mtx_unlock(dmtx);
|
||||
break;
|
||||
default:
|
||||
panic("Unknown operation 0x%x for busdma_lock_mutex!", op);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dflt_lock should never get called. It gets put into the dma tag when
|
||||
* lockfunc == NULL, which is only valid if the maps that are associated
|
||||
* with the tag are meant to never be defered.
|
||||
* XXX Should have a way to identify which driver is responsible here.
|
||||
*/
|
||||
void
|
||||
bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
|
||||
panic("driver error: busdma dflt_lock called");
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if a match is made.
|
||||
*
|
||||
@ -154,7 +119,7 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
||||
common->lockfunc = lockfunc;
|
||||
common->lockfuncarg = lockfuncarg;
|
||||
} else {
|
||||
common->lockfunc = bus_dma_dflt_lock;
|
||||
common->lockfunc = _busdma_dflt_lock;
|
||||
common->lockfuncarg = NULL;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,6 @@ struct bus_dma_impl {
|
||||
bus_dmasync_op_t op);
|
||||
};
|
||||
|
||||
void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op);
|
||||
int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr);
|
||||
int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
||||
bus_size_t alignment,
|
||||
|
@ -42,8 +42,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/bus.h>
|
||||
#include <sys/callout.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/memdesc.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
@ -59,6 +61,43 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
/*
|
||||
* Convenience function for manipulating driver locks from busdma (during
|
||||
* busdma_swi, for example).
|
||||
*/
|
||||
void
|
||||
busdma_lock_mutex(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
struct mtx *dmtx;
|
||||
|
||||
dmtx = (struct mtx *)arg;
|
||||
switch (op) {
|
||||
case BUS_DMA_LOCK:
|
||||
mtx_lock(dmtx);
|
||||
break;
|
||||
case BUS_DMA_UNLOCK:
|
||||
mtx_unlock(dmtx);
|
||||
break;
|
||||
default:
|
||||
panic("Unknown operation 0x%x for busdma_lock_mutex!", op);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dflt_lock should never get called. It gets put into the dma tag when
|
||||
* lockfunc == NULL, which is only valid if the maps that are associated
|
||||
* with the tag are meant to never be deferred.
|
||||
*
|
||||
* XXX Should have a way to identify which driver is responsible here.
|
||||
*/
|
||||
void
|
||||
_busdma_dflt_lock(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
|
||||
panic("driver error: _bus_dma_dflt_lock called");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Load up data starting at offset within a region specified by a
|
||||
* list of virtual address ranges until either length or the region
|
||||
|
@ -146,40 +146,6 @@ run_filter(bus_dma_tag_t dmat, bus_addr_t paddr)
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convenience function for manipulating driver locks from busdma (during
|
||||
* busdma_swi, for example).
|
||||
*/
|
||||
void
|
||||
busdma_lock_mutex(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
struct mtx *dmtx;
|
||||
|
||||
dmtx = (struct mtx *)arg;
|
||||
switch (op) {
|
||||
case BUS_DMA_LOCK:
|
||||
mtx_lock(dmtx);
|
||||
break;
|
||||
case BUS_DMA_UNLOCK:
|
||||
mtx_unlock(dmtx);
|
||||
break;
|
||||
default:
|
||||
panic("Unknown operation 0x%x for busdma_lock_mutex!", op);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dflt_lock should never get called. It gets put into the dma tag when
|
||||
* lockfunc == NULL, which is only valid if the maps that are associated
|
||||
* with the tag are meant to never be defered.
|
||||
* XXX Should have a way to identify which driver is responsible here.
|
||||
*/
|
||||
static void
|
||||
dflt_lock(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
panic("driver error: busdma dflt_lock called");
|
||||
}
|
||||
|
||||
#define BUS_DMA_COULD_BOUNCE BUS_DMA_BUS3
|
||||
#define BUS_DMA_MIN_ALLOC_COMP BUS_DMA_BUS4
|
||||
/*
|
||||
@ -232,7 +198,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
|
||||
newtag->lockfunc = lockfunc;
|
||||
newtag->lockfuncarg = lockfuncarg;
|
||||
} else {
|
||||
newtag->lockfunc = dflt_lock;
|
||||
newtag->lockfunc = _busdma_dflt_lock;
|
||||
newtag->lockfuncarg = NULL;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,6 @@ struct bus_dma_impl {
|
||||
bus_dmasync_op_t op);
|
||||
};
|
||||
|
||||
void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op);
|
||||
int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr);
|
||||
int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
||||
bus_size_t alignment,
|
||||
|
@ -51,41 +51,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/bus.h>
|
||||
#include <machine/bus_dma_impl.h>
|
||||
|
||||
/*
|
||||
* Convenience function for manipulating driver locks from busdma (during
|
||||
* busdma_swi, for example).
|
||||
*/
|
||||
void
|
||||
busdma_lock_mutex(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
struct mtx *dmtx;
|
||||
|
||||
dmtx = (struct mtx *)arg;
|
||||
switch (op) {
|
||||
case BUS_DMA_LOCK:
|
||||
mtx_lock(dmtx);
|
||||
break;
|
||||
case BUS_DMA_UNLOCK:
|
||||
mtx_unlock(dmtx);
|
||||
break;
|
||||
default:
|
||||
panic("Unknown operation 0x%x for busdma_lock_mutex!", op);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dflt_lock should never get called. It gets put into the dma tag when
|
||||
* lockfunc == NULL, which is only valid if the maps that are associated
|
||||
* with the tag are meant to never be defered.
|
||||
* XXX Should have a way to identify which driver is responsible here.
|
||||
*/
|
||||
void
|
||||
bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
|
||||
panic("driver error: busdma dflt_lock called");
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if a match is made.
|
||||
*
|
||||
@ -156,7 +121,7 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
||||
common->lockfunc = lockfunc;
|
||||
common->lockfuncarg = lockfuncarg;
|
||||
} else {
|
||||
common->lockfunc = bus_dma_dflt_lock;
|
||||
common->lockfunc = _busdma_dflt_lock;
|
||||
common->lockfuncarg = NULL;
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,11 @@ typedef int bus_dma_filter_t(void *, bus_addr_t);
|
||||
*/
|
||||
void busdma_lock_mutex(void *arg, bus_dma_lock_op_t op);
|
||||
|
||||
/*
|
||||
* Internal helper function used by tags that do not defer loads.
|
||||
*/
|
||||
void _busdma_dflt_lock(void *arg, bus_dma_lock_op_t op);
|
||||
|
||||
/*
|
||||
* Allocate a device specific dma_tag encapsulating the constraints of
|
||||
* the parent tag in addition to other restrictions specified:
|
||||
|
@ -89,7 +89,6 @@ struct bus_dma_impl {
|
||||
#endif
|
||||
};
|
||||
|
||||
void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op);
|
||||
int bus_dma_run_filter(struct bus_dma_tag_common *dmat, vm_paddr_t paddr);
|
||||
int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
||||
bus_size_t alignment,
|
||||
|
@ -55,41 +55,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/bus.h>
|
||||
#include <x86/include/busdma_impl.h>
|
||||
|
||||
/*
|
||||
* Convenience function for manipulating driver locks from busdma (during
|
||||
* busdma_swi, for example).
|
||||
*/
|
||||
void
|
||||
busdma_lock_mutex(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
struct mtx *dmtx;
|
||||
|
||||
dmtx = (struct mtx *)arg;
|
||||
switch (op) {
|
||||
case BUS_DMA_LOCK:
|
||||
mtx_lock(dmtx);
|
||||
break;
|
||||
case BUS_DMA_UNLOCK:
|
||||
mtx_unlock(dmtx);
|
||||
break;
|
||||
default:
|
||||
panic("Unknown operation 0x%x for busdma_lock_mutex!", op);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dflt_lock should never get called. It gets put into the dma tag when
|
||||
* lockfunc == NULL, which is only valid if the maps that are associated
|
||||
* with the tag are meant to never be defered.
|
||||
* XXX Should have a way to identify which driver is responsible here.
|
||||
*/
|
||||
void
|
||||
bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op)
|
||||
{
|
||||
|
||||
panic("driver error: busdma dflt_lock called");
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if a match is made.
|
||||
*
|
||||
@ -161,7 +126,7 @@ common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
||||
common->lockfunc = lockfunc;
|
||||
common->lockfuncarg = lockfuncarg;
|
||||
} else {
|
||||
common->lockfunc = bus_dma_dflt_lock;
|
||||
common->lockfunc = _busdma_dflt_lock;
|
||||
common->lockfuncarg = NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user