Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Dec 2012 00:49:56 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r244846 - in projects/altix2/sys: kern sys
Message-ID:  <201212300049.qBU0nune084931@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Sun Dec 30 00:49:56 2012
New Revision: 244846
URL: http://svnweb.freebsd.org/changeset/base/244846

Log:
  o   Redefine the BUSDMA_SYNC_ operations to not conflict with the
      BUS_DMASYNC_ operations.
  o   Add BUSDMA_ALLOC_ZERO for allocation of pre-zeroed memory.

Modified:
  projects/altix2/sys/kern/subr_busdma.c
  projects/altix2/sys/sys/busdma.h

Modified: projects/altix2/sys/kern/subr_busdma.c
==============================================================================
--- projects/altix2/sys/kern/subr_busdma.c	Sun Dec 30 00:47:30 2012	(r244845)
+++ projects/altix2/sys/kern/subr_busdma.c	Sun Dec 30 00:49:56 2012	(r244846)
@@ -161,6 +161,8 @@ SYSINIT(busdma_kmem, SI_SUB_KMEM, SI_ORD
 
 /* Section 3.2: Debugging & tracing. */
 
+#define	BUSDMA_DEBUG	1
+
 static void
 _busdma_mtag_dump(const char *func, device_t dev, struct busdma_mtag *mtag)
 {
@@ -235,6 +237,7 @@ _busdma_data_dump(const char *func, stru
 			continue;
 		pa = MAX(seg->mds_busaddr, addr);
 		sz = MIN(seg->mds_busaddr + seg->mds_size, addr + len) - pa;
+		sz = MIN(sz, 128);	/* XXX arbitrary limit */
 		va = (void *)(seg->mds_vaddr + (pa - seg->mds_busaddr));
 		printf("%#jx: %*D\n", (uintmax_t)pa, sz, va, " ");
 	}
@@ -731,7 +734,7 @@ busdma_mem_alloc(struct busdma_tag *tag,
 	struct busdma_mtag mtag;
 	vm_size_t maxsz;
 	u_int idx;
-	int error;
+	int error, mflags;
 
 	CTR3(KTR_BUSDMA, "%s: tag=%p, flags=%#x", __func__, tag, flags);
 
@@ -754,6 +757,9 @@ busdma_mem_alloc(struct busdma_tag *tag,
 		goto fail;
 	}
 
+	mflags = 0;
+	mflags |= (flags & BUSDMA_ALLOC_ZERO) ? M_ZERO : 0;
+
 	idx = 0;
 	maxsz = tag->dt_maxsz;
 	while (maxsz > 0 && idx < tag->dt_nsegs) {
@@ -767,7 +773,7 @@ busdma_mem_alloc(struct busdma_tag *tag,
 		seg->mds_paddr = ~0UL;
 		seg->mds_size = MIN(maxsz, mtag.dmt_maxsz);
 		seg->mds_vaddr = kmem_alloc_contig(kernel_map, seg->mds_size,
-		    0, mtag.dmt_minaddr, mtag.dmt_maxaddr, mtag.dmt_align,
+		    mflags, mtag.dmt_minaddr, mtag.dmt_maxaddr, mtag.dmt_align,
 		    mtag.dmt_bndry, VM_MEMATTR_DEFAULT);
 		if (seg->mds_vaddr == 0) {
 			/* TODO: try a smaller segment size */
@@ -830,7 +836,8 @@ busdma_sync(struct busdma_md *md, u_int 
 
 	CTR3(KTR_BUSDMA, "%s: md=%p, op=%#x", __func__, md, op);
 
-	if ((op & BUSDMA_SYNC_PREWRITE) || (op & BUSDMA_SYNC_POSTREAD))
+	if ((op & BUSDMA_SYNC_PREWRITE) == BUSDMA_SYNC_PREWRITE ||
+	    (op & BUSDMA_SYNC_POSTREAD) == BUSDMA_SYNC_POSTREAD)
 		_busdma_data_dump(__func__, md, 0UL, ~0UL);
 }
 
@@ -842,6 +849,7 @@ busdma_sync_range(struct busdma_md *md, 
 	CTR5(KTR_BUSDMA, "%s: md=%p, op=%#x, addr=%#jx, len=%#jx", __func__,
 	    md, op, (uintmax_t)addr, (uintmax_t)len);
 
-	if ((op & BUSDMA_SYNC_PREWRITE) || (op & BUSDMA_SYNC_POSTREAD))
+	if ((op & BUSDMA_SYNC_PREWRITE) == BUSDMA_SYNC_PREWRITE ||
+	    (op & BUSDMA_SYNC_POSTREAD) == BUSDMA_SYNC_POSTREAD)
 		_busdma_data_dump(__func__, md, addr, len);
 }

Modified: projects/altix2/sys/sys/busdma.h
==============================================================================
--- projects/altix2/sys/sys/busdma.h	Sun Dec 30 00:47:30 2012	(r244845)
+++ projects/altix2/sys/sys/busdma.h	Sun Dec 30 00:49:56 2012	(r244846)
@@ -133,6 +133,8 @@ busdma_md_get_pointer(busdma_md_t md, u_
  */
 int busdma_mem_alloc(busdma_tag_t tag, u_int flags, busdma_md_t *md_p);
 
+#define	BUSDMA_ALLOC_ZERO	0x10000
+
 /*
  * busdma_mem_free
  * returns:		errno value
@@ -146,10 +148,10 @@ int busdma_stop(busdma_md_t md);
 void busdma_sync(busdma_md_t md, u_int);
 void busdma_sync_range(busdma_md_t md, u_int, vm_paddr_t, vm_size_t);
 
-#define	BUSDMA_SYNC_READ	0x1
-#define	BUSDMA_SYNC_WRITE	0x2
-#define	BUSDMA_SYNC_BEFORE	0x0
-#define	BUSDMA_SYNC_AFTER	0x4
+#define	BUSDMA_SYNC_READ	0x10000
+#define	BUSDMA_SYNC_WRITE	0x20000
+#define	BUSDMA_SYNC_BEFORE	0x40000
+#define	BUSDMA_SYNC_AFTER	0x80000
 
 #define	BUSDMA_SYNC_PREREAD	(BUSDMA_SYNC_BEFORE | BUSDMA_SYNC_READ)
 #define	BUSDMA_SYNC_PREWRITE	(BUSDMA_SYNC_BEFORE | BUSDMA_SYNC_WRITE)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212300049.qBU0nune084931>