From 05f603434f839fd9e28b478ed3eff2fb75aab189 Mon Sep 17 00:00:00 2001 From: matt Date: Sun, 24 May 1998 22:37:23 +0000 Subject: [PATCH] More pmax coherency stuff. Getting close.. --- sys/dev/ic/pdq.c | 6 ++--- sys/dev/ic/pdq_ifsubr.c | 52 ++++++++++++++++++++++++++++++++++------- sys/dev/ic/pdqvar.h | 10 ++++---- 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/sys/dev/ic/pdq.c b/sys/dev/ic/pdq.c index 8c8a8eddc26b..b686ffc6fd9e 100644 --- a/sys/dev/ic/pdq.c +++ b/sys/dev/ic/pdq.c @@ -1,4 +1,4 @@ -/* $NetBSD: pdq.c,v 1.14 1998/05/24 21:40:06 matt Exp $ */ +/* $NetBSD: pdq.c,v 1.15 1998/05/24 22:37:23 matt Exp $ */ /*- * Copyright (c) 1995,1996 Matt Thomas @@ -1527,6 +1527,8 @@ pdq_initialize( pdq->pdq_unsolicited_info.ui_pa_bufstart = physaddr + 0x2000; } } + pdq->pdq_cbp = (volatile pdq_consumer_block_t *) &pdq->pdq_dbp->pdqdb_consumer; + pdq->pdq_pa_consumer_block = PDQ_DB_BUSPA(pdq, pdq->pdq_cbp); if (contig_bytes == sizeof(pdq_descriptor_block_t)) { pdq->pdq_unsolicited_info.ui_events = (pdq_unsolicited_event_t *) PDQ_OS_MEMALLOC( @@ -1555,8 +1557,6 @@ pdq_initialize( } dbp = pdq->pdq_dbp; - pdq->pdq_cbp = (volatile pdq_consumer_block_t *) &dbp->pdqdb_consumer; - pdq->pdq_pa_consumer_block = PDQ_DB_BUSPA(pdq, pdq->pdq_cbp); pdq->pdq_command_info.ci_request_bufstart = (pdq_uint8_t *) dbp->pdqdb_command_pool; pdq->pdq_command_info.ci_response_bufstart = (pdq_uint8_t *) dbp->pdqdb_command_pool + sizeof(dbp->pdqdb_command_pool) - PDQ_SIZE_COMMAND_RESPONSE; pdq->pdq_rx_info.rx_buffers = (void *) dbp->pdqdb_receive_buffers; diff --git a/sys/dev/ic/pdq_ifsubr.c b/sys/dev/ic/pdq_ifsubr.c index 17572c932deb..03bd551fcefa 100644 --- a/sys/dev/ic/pdq_ifsubr.c +++ b/sys/dev/ic/pdq_ifsubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: pdq_ifsubr.c,v 1.14 1998/05/24 21:40:06 matt Exp $ */ +/* $NetBSD: pdq_ifsubr.c,v 1.15 1998/05/24 22:37:23 matt Exp $ */ /*- * Copyright (c) 1995, 1996 Matt Thomas @@ -570,7 +570,7 @@ pdq_os_memalloc_contig( pdq_t *pdq) { pdq_softc_t * const sc = pdq->pdq_os_ctx; - bus_dma_segment_t db_segs[1], ui_segs[1]; + bus_dma_segment_t db_segs[1], ui_segs[1], cb_segs[1]; int db_nsegs = 0, ui_nsegs = 0; int steps = 0; int not_ok; @@ -580,54 +580,88 @@ pdq_os_memalloc_contig( sizeof(*pdq->pdq_dbp), db_segs, 1, &db_nsegs, BUS_DMA_NOWAIT); if (!not_ok) { - steps++; + steps = 1; not_ok = bus_dmamem_map(sc->sc_dmatag, db_segs, db_nsegs, sizeof(*pdq->pdq_dbp), (caddr_t *) &pdq->pdq_dbp, BUS_DMA_NOWAIT); } if (!not_ok) { - steps++; + steps = 2; not_ok = bus_dmamap_create(sc->sc_dmatag, db_segs[0].ds_len, 1, 0x2000, 0, BUS_DMA_NOWAIT, &sc->sc_dbmap); } if (!not_ok) { - steps++; + steps = 3; not_ok = bus_dmamap_load(sc->sc_dmatag, sc->sc_dbmap, pdq->pdq_dbp, sizeof(*pdq->pdq_dbp), NULL, BUS_DMA_NOWAIT); } if (!not_ok) { - steps++; + steps = 4; pdq->pdq_pa_descriptor_block = sc->sc_dbmap->dm_segs[0].ds_addr; not_ok = bus_dmamem_alloc(sc->sc_dmatag, PDQ_OS_PAGESIZE, PDQ_OS_PAGESIZE, PDQ_OS_PAGESIZE, ui_segs, 1, &ui_nsegs, BUS_DMA_NOWAIT); } if (!not_ok) { - steps++; + steps = 5; not_ok = bus_dmamem_map(sc->sc_dmatag, ui_segs, ui_nsegs, PDQ_OS_PAGESIZE, (caddr_t *) &pdq->pdq_unsolicited_info.ui_events, BUS_DMA_NOWAIT); } if (!not_ok) { - steps++; + steps = 6; not_ok = bus_dmamap_create(sc->sc_dmatag, ui_segs[0].ds_len, 1, PDQ_OS_PAGESIZE, 0, BUS_DMA_NOWAIT, &sc->sc_uimap); } if (!not_ok) { - steps++; + steps = 7; not_ok = bus_dmamap_load(sc->sc_dmatag, sc->sc_uimap, pdq->pdq_unsolicited_info.ui_events, PDQ_OS_PAGESIZE, NULL, BUS_DMA_NOWAIT); } if (!not_ok) { + steps = 8; pdq->pdq_unsolicited_info.ui_pa_bufstart = sc->sc_uimap->dm_segs[0].ds_addr; + cb_segs[0].ds_addr = db_segs[0].ds_addr + + offsetof(pdq_descriptor_block_t, pdqdb_consumer); + cb_segs[0].ds_len = sizeof(pdq_consumer_block_t); + not_ok = bus_dmamem_map(sc->sc_dmatag, cb_segs, 1, + sizeof(*pdq->pdq_cbp), (caddr_t *) &pdq->pdq_cbp, + BUS_DMA_NOWAIT|BUS_DMA_COHERENT); + } + if (!not_ok) { + steps = 9; + not_ok = bus_dmamap_create(sc->sc_dmatag, cb_segs[0].ds_len, 1, + 0x2000, 0, BUS_DMA_NOWAIT, &sc->sc_cbmap); + } + if (!not_ok) { + steps = 10; + not_ok = bus_dmamap_load(sc->sc_dmatag, sc->sc_cbmap, + (caddr_t) pdq->pdq_cbp, sizeof(*pdq->pdq_cbp), + NULL, BUS_DMA_NOWAIT); + } + if (!not_ok) { + pdq->pdq_pa_consumer_block = sc->sc_cbmap->dm_segs[0].ds_addr; return not_ok; } switch (steps) { + case 11: { + bus_dmamap_unload(sc->sc_dmatag, sc->sc_cbmap); + /* FALL THROUGH */ + } + case 10: { + bus_dmamap_destroy(sc->sc_dmatag, sc->sc_cbmap); + /* FALL THROUGH */ + } + case 9: { + bus_dmamem_unmap(sc->sc_dmatag, + (caddr_t) pdq->pdq_cbp, sizeof(*pdq->pdq_cbp)); + /* FALL THROUGH */ + } case 8: { bus_dmamap_unload(sc->sc_dmatag, sc->sc_uimap); /* FALL THROUGH */ diff --git a/sys/dev/ic/pdqvar.h b/sys/dev/ic/pdqvar.h index 9b0efa94efdc..3fa9bbb67501 100644 --- a/sys/dev/ic/pdqvar.h +++ b/sys/dev/ic/pdqvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: pdqvar.h,v 1.18 1998/05/24 21:40:05 matt Exp $ */ +/* $NetBSD: pdqvar.h,v 1.19 1998/05/24 22:37:23 matt Exp $ */ /*- * Copyright (c) 1995, 1996 Matt Thomas @@ -196,19 +196,19 @@ typedef bus_addr_t pdq_bus_memoffset_t; PDQ_OS_DESCBLOCK_SYNC((pdq), (d), (s), BUS_DMASYNC_POSTWRITE) #define PDQ_OS_CMDRQST_PRESYNC(pdq, s) \ PDQ_OS_DESCBLOCK_SYNC((pdq), \ - (pdq)->pdq_dbp->pdqdb_command_pool, \ + (pdq)->pdq_command_info.ci_request_bufstart, \ (s), BUS_DMASYNC_PREWRITE) #define PDQ_OS_CMDRSP_PRESYNC(pdq, s) \ PDQ_OS_DESCBLOCK_SYNC((pdq), \ - (pdq)->pdq_dbp->pdqdb_command_pool, \ + (pdq)->pdq_command_info.ci_response_bufstart, \ (s), BUS_DMASYNC_PREREAD) #define PDQ_OS_CMDRQST_POSTSYNC(pdq, s) \ PDQ_OS_DESCBLOCK_SYNC((pdq), \ - (pdq)->pdq_dbp->pdqdb_command_pool, \ + (pdq)->pdq_command_info.ci_request_bufstart, \ (s), BUS_DMASYNC_POSTWRITE) #define PDQ_OS_CMDRSP_POSTSYNC(pdq, s) \ PDQ_OS_DESCBLOCK_SYNC((pdq), \ - (pdq)->pdq_dbp->pdqdb_command_pool, \ + (pdq)->pdq_command_info.ci_response_bufstart, \ (s), BUS_DMASYNC_POSTREAD) #define PDQ_OS_RXPDU_PRESYNC(pdq, b, o, l) \ pdq_os_databuf_sync((pdq)->pdq_os_ctx, (b), (o), (l), \