Page MenuHomeFreeBSD

D56208.1795010085.diff
No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None

D56208.1795010085.diff

diff --git a/sys/powerpc/powerpc/busdma_bounce.c b/sys/powerpc/powerpc/busdma_bounce.c
--- a/sys/powerpc/powerpc/busdma_bounce.c
+++ b/sys/powerpc/powerpc/busdma_bounce.c
@@ -32,9 +32,9 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/domainset.h>
#include <sys/malloc.h>
#include <sys/bus.h>
-#include <sys/domainset.h>
#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
@@ -61,6 +61,25 @@
#define MAX_BPAGES MIN(8192, physmem/40)
+enum {
+ BF_COULD_BOUNCE = 0x01,
+ BF_MIN_ALLOC_COMP = 0x02,
+ BF_KMEM_ALLOC = 0x04,
+ BF_COHERENT = 0x10,
+};
+
+struct bounce_page;
+struct bounce_zone;
+
+struct bus_dma_tag {
+ struct bus_dma_tag_common common;
+ int map_count;
+ int bounce_flags;
+ struct bounce_zone *bounce_zone;
+ device_t iommu;
+ void *iommu_cookie;
+};
+
struct bus_dmamap {
STAILQ_HEAD(, bounce_page) bpages;
int pagesneeded;
@@ -79,8 +98,7 @@
static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata");
#define dmat_alignment(dmat) ((dmat)->common.alignment)
-/* XXX TODO: bounce flags? */
-#define dmat_bounce_flags(dmat) (0)
+#define dmat_bounce_flags(dmat) ((dmat)->bounce_flags)
#define dmat_boundary(dmat) ((dmat)->common.boundary)
#define dmat_domain(dmat) ((dmat)->common.domain)
#define dmat_flags(dmat) ((dmat)->common.flags)
@@ -91,20 +109,6 @@
#define dmat_maxsegsz(dmat) ((dmat)->common.maxsegsz)
#define dmat_nsegments(dmat) ((dmat)->common.nsegments)
-/*
- * Note: at this point the code requires a 'struct bus_dma_tag' to exist
- * or the included code will not function correctly.
- */
-
-struct bus_dma_tag {
- struct bus_dma_tag_common common;
- int map_count;
- int bounce_flags;
- struct bounce_zone *bounce_zone;
- device_t iommu;
- void *iommu_cookie;
-};
-
static SYSCTL_NODE(_hw, OID_AUTO, busdma, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"Busdma parameters");
@@ -127,9 +131,6 @@
return (false);
}
-#define BUS_DMA_COULD_BOUNCE BUS_DMA_BUS3
-#define BUS_DMA_MIN_ALLOC_COMP BUS_DMA_BUS4
-
static int
bounce_bus_dma_zone_setup(bus_dma_tag_t newtag)
{
@@ -152,7 +153,7 @@
error = ENOMEM;
}
/* Performed initial allocation */
- newtag->common.flags |= BUS_DMA_MIN_ALLOC_COMP;
+ newtag->bounce_flags |= BF_MIN_ALLOC_COMP;
return (error);
}
@@ -198,12 +199,12 @@
}
if (newtag->common.lowaddr < ptoa((vm_paddr_t)Maxmem) && newtag->iommu == NULL)
- newtag->common.flags |= BUS_DMA_COULD_BOUNCE;
+ newtag->bounce_flags |= BF_COULD_BOUNCE;
if (newtag->common.alignment > 1)
- newtag->common.flags |= BUS_DMA_COULD_BOUNCE;
+ newtag->bounce_flags |= BF_COULD_BOUNCE;
- if (((newtag->common.flags & BUS_DMA_COULD_BOUNCE) != 0) &&
+ if (((newtag->bounce_flags & BF_COULD_BOUNCE) != 0) &&
(flags & BUS_DMA_ALLOCNOW) != 0) {
/* Must bounce */
error = bounce_bus_dma_zone_setup(newtag);
@@ -272,7 +273,7 @@
* exclusion region, a data alignment that is stricter than 1, and/or
* an active address boundary.
*/
- if (dmat->common.flags & BUS_DMA_COULD_BOUNCE) {
+ if (dmat->bounce_flags & BF_COULD_BOUNCE) {
/* Must bounce */
struct bounce_zone *bz;
int maxpages;
@@ -291,7 +292,7 @@
maxpages = MAX_BPAGES;
else
maxpages = MIN(MAX_BPAGES, Maxmem -atop(dmat->common.lowaddr));
- if ((dmat->common.flags & BUS_DMA_MIN_ALLOC_COMP) == 0
+ if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0
|| (bz->map_count > 0 && bz->total_bpages < maxpages)) {
int pages;
@@ -301,9 +302,9 @@
if (alloc_bounce_pages(dmat, pages) < pages)
error = ENOMEM;
- if ((dmat->common.flags & BUS_DMA_MIN_ALLOC_COMP) == 0) {
+ if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0) {
if (error == 0)
- dmat->common.flags |= BUS_DMA_MIN_ALLOC_COMP;
+ dmat->bounce_flags |= BF_MIN_ALLOC_COMP;
} else {
error = 0;
}
@@ -335,7 +336,7 @@
static int
bounce_bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
{
- if (dmat->common.flags & BUS_DMA_COULD_BOUNCE) {
+ if (dmat->bounce_flags & BF_COULD_BOUNCE) {
if (STAILQ_FIRST(&map->bpages) != NULL) {
CTR3(KTR_BUSDMA, "%s: tag %p error %d",
__func__, dmat, EBUSY);
@@ -519,7 +520,7 @@
if (segs == NULL)
segs = map->segments;
- if ((dmat->common.flags & BUS_DMA_COULD_BOUNCE) != 0) {
+ if ((dmat->bounce_flags & BF_COULD_BOUNCE) != 0) {
_bus_dmamap_count_phys(dmat, map, buf, buflen, flags);
if (map->pagesneeded != 0) {
error = _bus_dmamap_reserve_pages(dmat, map, flags);
@@ -580,7 +581,7 @@
if (segs == NULL)
segs = map->segments;
- if ((dmat->common.flags & BUS_DMA_COULD_BOUNCE) != 0) {
+ if ((dmat->bounce_flags & BF_COULD_BOUNCE) != 0) {
_bus_dmamap_count_pages(dmat, map, pmap, buf, buflen, flags);
if (map->pagesneeded != 0) {
error = _bus_dmamap_reserve_pages(dmat, map, flags);
@@ -633,7 +634,7 @@
void *callback_arg)
{
- if (dmat->common.flags & BUS_DMA_COULD_BOUNCE) {
+ if (dmat->bounce_flags & BF_COULD_BOUNCE) {
map->dmat = dmat;
map->mem = *mem;
map->callback = callback;

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 18, 1:54 PM (13 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41825332
Default Alt Text
D56208.1795010085.diff (4 KB)

Event Timeline