Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/next68k/dev allow unaligned pointers in bus_dmamap_...



details:   https://anonhg.NetBSD.org/src/rev/d6c04e82d741
branches:  trunk
changeset: 511280:d6c04e82d741
user:      dbj <dbj%NetBSD.org@localhost>
date:      Sat Jun 16 09:08:05 2001 +0000

description:
allow unaligned pointers in bus_dmamap_sync

diffstat:

 sys/arch/next68k/dev/bus_dma.c |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (51 lines):

diff -r ad549c61f36e -r d6c04e82d741 sys/arch/next68k/dev/bus_dma.c
--- a/sys/arch/next68k/dev/bus_dma.c    Sat Jun 16 08:28:39 2001 +0000
+++ b/sys/arch/next68k/dev/bus_dma.c    Sat Jun 16 09:08:05 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.23 2001/05/28 22:11:45 chs Exp $ */
+/* $NetBSD: bus_dma.c,v 1.24 2001/06/16 09:08:05 dbj Exp $ */
 
 /*
  * This file was taken from from alpha/common/bus_dma.c
@@ -46,7 +46,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.23 2001/05/28 22:11:45 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.24 2001/06/16 09:08:05 dbj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -447,7 +447,6 @@
        int ops;
 {
        /* flush/purge the cache.
-        * assumes pointers are aligned
         * @@@ should probably be fixed to use offset and len args.
         */
 
@@ -456,6 +455,9 @@
                for(i=0;i<map->dm_nsegs;i++) {
                        bus_addr_t p = map->dm_segs[i].ds_addr;
                        bus_addr_t e = p+map->dm_segs[i].ds_len;
+                       /* If the pointers are unaligned, it's ok to flush surrounding cache line */
+                       p -= p%16;
+                       if (e % 16) e += 16-(e%16);
 #ifdef DIAGNOSTIC
                        if ((p % 16) || (e % 16)) {
                                panic("unaligned address in _bus_dmamap_sync while flushing.\n"
@@ -488,6 +490,14 @@
                for(i=0;i<map->dm_nsegs;i++) {
                        bus_addr_t p = map->dm_segs[i].ds_addr;
                        bus_addr_t e = p+map->dm_segs[i].ds_len;
+                       if (p % 16) {
+                               p -= p%16;
+                               DCFL(p);
+                       }
+                       if (e % 16) {
+                               e += 16-(e%16);
+                               DCFL(e-16);
+                       }
 #ifdef DIAGNOSTIC
                        if ((p % 16) || (e % 16)) {
                                panic("unaligned address in _bus_dmamap_sync while purging.\n"



Home | Main Index | Thread Index | Old Index