Module Name: src Committed By: tsutsui Date: Sun May 6 19:46:18 UTC 2012
Modified Files: src/sys/arch/x68k/dev: fd.c src/sys/arch/x68k/x68k: machdep.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/arch/x68k/dev/fd.c cvs rdiff -u -r1.181 -r1.182 src/sys/arch/x68k/x68k/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x68k/dev/fd.c diff -u src/sys/arch/x68k/dev/fd.c:1.96 src/sys/arch/x68k/dev/fd.c:1.97 --- src/sys/arch/x68k/dev/fd.c:1.96 Thu Feb 2 19:43:01 2012 +++ src/sys/arch/x68k/dev/fd.c Sun May 6 19:46:18 2012 @@ -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 @@ struct fdc_softc { 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 @@ fdc_dmastart(struct fdc_softc *fdc, int (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 @@ fdcdmaintr(void *arg) { 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; Index: src/sys/arch/x68k/x68k/machdep.c diff -u src/sys/arch/x68k/x68k/machdep.c:1.181 src/sys/arch/x68k/x68k/machdep.c:1.182 --- src/sys/arch/x68k/x68k/machdep.c:1.181 Sun Jan 29 12:43:00 2012 +++ src/sys/arch/x68k/x68k/machdep.c Sun May 6 19:46:18 2012 @@ -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 @@ void x68k_init(void) { u_int i; + paddr_t msgbuf_pa; /* * Tell the VM system about available physical memory. @@ -181,17 +182,25 @@ x68k_init(void) 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 @@ setmemrange(void) atop(mlist[i].base), atop(h), VM_FREELIST_HIGHMEM); mem_size += h - (u_long) mlist[i].base; + if (avail_end < h) + avail_end = h; } }