Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x68k Make x68k's floppy driver actually work with p...



details:   https://anonhg.NetBSD.org/src/rev/dd3dcdec6fb6
branches:  trunk
changeset: 779148:dd3dcdec6fb6
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun May 06 19:46:18 2012 +0000

description:
Make x68k's floppy driver actually work with proper bounce buffer xfer ops
on machines with extended high memories:

- dev/fd.c:
 - add missing bus_dmamap_sync(9) POSTREAD/POSTWRITE ops

- x68k/machdep.c:
 - update avail_end variable (which is used to check DMA'able memory range
   in intio.c) properly per probed extended memory regions

The problem was found during debugging XM6i's FDC emulation by
Y.Sugahara, isaki@, and me.

Should be pulled up to netbsd-6.

diffstat:

 sys/arch/x68k/dev/fd.c       |  10 ++++++++--
 sys/arch/x68k/x68k/machdep.c |  19 +++++++++++++++----
 2 files changed, 23 insertions(+), 6 deletions(-)

diffs (108 lines):

diff -r add1f0aa2ffe -r dd3dcdec6fb6 sys/arch/x68k/dev/fd.c
--- a/sys/arch/x68k/dev/fd.c    Sun May 06 17:27:22 2012 +0000
+++ b/sys/arch/x68k/dev/fd.c    Sun May 06 19:46:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.96 2012/02/02 19:43:01 tls Exp $      */
+/*     $NetBSD: fd.c,v 1.97 2012/05/06 19:46:18 tsutsui Exp $  */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.96 2012/02/02 19:43:01 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.97 2012/05/06 19:46:18 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m68k_arch.h"
@@ -148,6 +148,7 @@
        u_int8_t *sc_addr;                      /* physical address */
        struct dmac_channel_stat *sc_dmachan; /* intio DMA channel */
        struct dmac_dma_xfer *sc_xfer;  /* DMA transfer */
+       int sc_read;
 
        struct fd_softc *sc_fd[4];      /* pointers to children */
        TAILQ_HEAD(drivehead, fd_softc) sc_drives;
@@ -324,6 +325,7 @@
                                         (u_int8_t*) (fdc->sc_addr +
                                                      fddata)); /* XXX */
 
+       fdc->sc_read = read;
        dmac_start_xfer(fdc->sc_dmachan->ch_softc, fdc->sc_xfer);
 }
 
@@ -332,6 +334,10 @@
 {
        struct fdc_softc *fdc = arg;
 
+       bus_dmamap_sync(fdc->sc_dmat, fdc->sc_dmamap,
+           0, fdc->sc_dmamap->dm_mapsize,
+           fdc->sc_read ?
+           BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
        bus_dmamap_unload(fdc->sc_dmat, fdc->sc_dmamap);
 
        return 0;
diff -r add1f0aa2ffe -r dd3dcdec6fb6 sys/arch/x68k/x68k/machdep.c
--- a/sys/arch/x68k/x68k/machdep.c      Sun May 06 17:27:22 2012 +0000
+++ b/sys/arch/x68k/x68k/machdep.c      Sun May 06 19:46:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.181 2012/01/29 12:43:00 isaki Exp $      */
+/*     $NetBSD: machdep.c,v 1.182 2012/05/06 19:46:18 tsutsui Exp $    */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.181 2012/01/29 12:43:00 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.182 2012/05/06 19:46:18 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -174,6 +174,7 @@
 x68k_init(void)
 {
        u_int i;
+       paddr_t msgbuf_pa;
 
        /*
         * Tell the VM system about available physical memory.
@@ -181,17 +182,25 @@
        uvm_page_physload(atop(avail_start), atop(avail_end),
            atop(avail_start), atop(avail_end),
            VM_FREELIST_MAINMEM);
+
+       /*
+        * avail_end was pre-decremented in pmap_bootstrap to compensate
+        * for msgbuf pages, but avail_end is also used to check DMA'able
+        * memory range for intio devices and it would be updated per
+        * probed extended memories, so explicitly save msgbuf address here.
+        */
+       msgbuf_pa = avail_end;
+
 #ifdef EXTENDED_MEMORY
        setmemrange();
 #endif
 
        /*
         * Initialize error message buffer (at end of core).
-        * avail_end was pre-decremented in pmap_bootstrap to compensate.
         */
        for (i = 0; i < btoc(MSGBUFSIZE); i++)
                pmap_kenter_pa((vaddr_t)msgbufaddr + i * PAGE_SIZE,
-                   avail_end + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, 0);
+                   msgbuf_pa + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, 0);
        pmap_update(pmap_kernel());
        initmsgbuf(msgbufaddr, m68k_round_page(MSGBUFSIZE));
 }
@@ -1146,6 +1155,8 @@
                            atop(mlist[i].base), atop(h),
                            VM_FREELIST_HIGHMEM);
                        mem_size += h - (u_long) mlist[i].base;
+                       if (avail_end < h)
+                               avail_end = h;
                }
        }
 



Home | Main Index | Thread Index | Old Index