summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>1999-10-25 19:39:20 +0000
committerJason Wright <jason@cvs.openbsd.org>1999-10-25 19:39:20 +0000
commita322c4a317e25852bdda0fae9511463965be5f23 (patch)
tree6221c0eb9e8fce6044d9205f193b6aac9bbf0141
parent379d52f84f4953d8ba7934bfad3366b8b3953bfc (diff)
use bus_dma instead of [u]vm_page_alloc_contig
-rw-r--r--sys/dev/pci/if_ti.c102
-rw-r--r--sys/dev/pci/if_tireg.h3
2 files changed, 73 insertions, 32 deletions
diff --git a/sys/dev/pci/if_ti.c b/sys/dev/pci/if_ti.c
index 653bebccc84..c8c2cd86d12 100644
--- a/sys/dev/pci/if_ti.c
+++ b/sys/dev/pci/if_ti.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ti.c,v 1.6 1999/10/04 12:37:17 jason Exp $ */
+/* $OpenBSD: if_ti.c,v 1.7 1999/10/25 19:39:18 jason Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -560,24 +560,41 @@ void ti_handle_events(sc)
int ti_alloc_jumbo_mem(sc)
struct ti_softc *sc;
{
- caddr_t ptr;
- register int i;
- struct ti_jpool_entry *entry;
+ caddr_t ptr, kva;
+ bus_dma_segment_t seg;
+ bus_dmamap_t dmamap;
+ int i, rseg;
+ struct ti_jpool_entry *entry;
/* Grab a big chunk o' storage. */
-#ifndef UVM
- sc->ti_cdata.ti_jumbo_buf = (caddr_t) vm_page_alloc_contig(
- TI_JMEM, 0x100000, 0xffffffff, PAGE_SIZE);
-#else
- sc->ti_cdata.ti_jumbo_buf = (caddr_t) uvm_pagealloc_contig(
- TI_JMEM, 0x100000, 0xffffffff, PAGE_SIZE);
-#endif
-
- if (sc->ti_cdata.ti_jumbo_buf == NULL) {
- printf("%s: no memory for jumbo buffers!\n",
- sc->sc_dv.dv_xname);
- return(ENOBUFS);
+ if (bus_dmamem_alloc(sc->sc_dmatag, TI_JMEM, PAGE_SIZE, 0,
+ &seg, 1, &rseg, BUS_DMA_NOWAIT)) {
+ printf("%s: can't alloc rx buffers\n", sc->sc_dv.dv_xname);
+ return (ENOBUFS);
+ }
+ if (bus_dmamem_map(sc->sc_dmatag, &seg, rseg, TI_JMEM, &kva,
+ BUS_DMA_NOWAIT)) {
+ printf("%s: can't map dma buffers (%d bytes)\n",
+ sc->sc_dv.dv_xname, TI_JMEM);
+ bus_dmamem_free(sc->sc_dmatag, &seg, rseg);
+ return (ENOBUFS);
+ }
+ if (bus_dmamap_create(sc->sc_dmatag, TI_JMEM, 1,
+ TI_JMEM, 0, BUS_DMA_NOWAIT, &dmamap)) {
+ printf("%s: can't create dma map\n", sc->sc_dv.dv_xname);
+ bus_dmamem_unmap(sc->sc_dmatag, kva, TI_JMEM);
+ bus_dmamem_free(sc->sc_dmatag, &seg, rseg);
+ return (ENOBUFS);
+ }
+ if (bus_dmamap_load(sc->sc_dmatag, dmamap, kva, TI_JMEM,
+ NULL, BUS_DMA_NOWAIT)) {
+ printf("%s: can't load dma map\n", sc->sc_dv.dv_xname);
+ bus_dmamap_destroy(sc->sc_dmatag, dmamap);
+ bus_dmamem_unmap(sc->sc_dmatag, kva, TI_JMEM);
+ bus_dmamem_free(sc->sc_dmatag, &seg, rseg);
+ return (ENOBUFS);
}
+ sc->ti_cdata.ti_jumbo_buf = (caddr_t)kva;
LIST_INIT(&sc->ti_jfree_listhead);
LIST_INIT(&sc->ti_jinuse_listhead);
@@ -594,10 +611,13 @@ int ti_alloc_jumbo_mem(sc)
entry = malloc(sizeof(struct ti_jpool_entry),
M_DEVBUF, M_NOWAIT);
if (entry == NULL) {
- free(sc->ti_cdata.ti_jumbo_buf, M_DEVBUF);
+ bus_dmamap_unload(sc->sc_dmatag, dmamap);
+ bus_dmamap_destroy(sc->sc_dmatag, dmamap);
+ bus_dmamem_unmap(sc->sc_dmatag, kva, TI_JMEM);
+ bus_dmamem_free(sc->sc_dmatag, &seg, rseg);
sc->ti_cdata.ti_jumbo_buf = NULL;
- printf("%s: no memory for jumbo "
- "buffer queue!\n", sc->sc_dv.dv_xname);
+ printf("%s: no memory for jumbo buffer queue\n",
+ sc->sc_dv.dv_xname);
return(ENOBUFS);
}
entry->slot = i;
@@ -1507,9 +1527,12 @@ ti_attach(parent, self, aux)
const char *intrstr = NULL;
bus_addr_t iobase;
bus_size_t iosize;
- int s;
+ bus_dma_segment_t seg;
+ bus_dmamap_t dmamap;
+ int s, rseg;
u_int32_t command;
struct ifnet *ifp;
+ caddr_t kva;
s = splimp();
@@ -1589,19 +1612,36 @@ ti_attach(parent, self, aux)
ether_sprintf(sc->arpcom.ac_enaddr));
/* Allocate the general information block and ring buffers. */
-#ifndef UVM
- sc->ti_rdata = (struct ti_ring_data *) vm_page_alloc_contig(
- sizeof(struct ti_ring_data), 0x100000, 0xffffffff, PAGE_SIZE);
-#else
- sc->ti_rdata = (struct ti_ring_data *) uvm_pagealloc_contig(
- sizeof(struct ti_ring_data), 0x100000, 0xffffffff, PAGE_SIZE);
-#endif
-
- if (sc->ti_rdata == NULL) {
- printf("%s: no memory for list buffers!\n", sc->sc_dv.dv_xname);
+ sc->sc_dmatag = pa->pa_dmat;
+ if (bus_dmamem_alloc(sc->sc_dmatag, sizeof(struct ti_ring_data),
+ PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) {
+ printf("%s: can't alloc rx buffers\n", sc->sc_dv.dv_xname);
goto fail;
}
-
+ if (bus_dmamem_map(sc->sc_dmatag, &seg, rseg,
+ sizeof(struct ti_ring_data), &kva, BUS_DMA_NOWAIT)) {
+ printf("%s: can't map dma buffers (%d bytes)\n",
+ sc->sc_dv.dv_xname, sizeof(struct ti_ring_data));
+ bus_dmamem_free(sc->sc_dmatag, &seg, rseg);
+ goto fail;
+ }
+ if (bus_dmamap_create(sc->sc_dmatag, sizeof(struct ti_ring_data), 1,
+ sizeof(struct ti_ring_data), 0, BUS_DMA_NOWAIT, &dmamap)) {
+ printf("%s: can't create dma map\n", sc->sc_dv.dv_xname);
+ bus_dmamem_unmap(sc->sc_dmatag, kva,
+ sizeof(struct ti_ring_data));
+ bus_dmamem_free(sc->sc_dmatag, &seg, rseg);
+ goto fail;
+ }
+ if (bus_dmamap_load(sc->sc_dmatag, dmamap, kva,
+ sizeof(struct ti_ring_data), NULL, BUS_DMA_NOWAIT)) {
+ bus_dmamap_destroy(sc->sc_dmatag, dmamap);
+ bus_dmamem_unmap(sc->sc_dmatag, kva,
+ sizeof(struct ti_ring_data));
+ bus_dmamem_free(sc->sc_dmatag, &seg, rseg);
+ goto fail;
+ }
+ sc->ti_rdata = (struct ti_ring_data *)kva;
bzero(sc->ti_rdata, sizeof(struct ti_ring_data));
/* Try to allocate memory for jumbo buffers. */
diff --git a/sys/dev/pci/if_tireg.h b/sys/dev/pci/if_tireg.h
index b9f84248c29..a7ecc842fe8 100644
--- a/sys/dev/pci/if_tireg.h
+++ b/sys/dev/pci/if_tireg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tireg.h,v 1.3 1999/10/03 13:06:30 jason Exp $ */
+/* $OpenBSD: if_tireg.h,v 1.4 1999/10/25 19:39:19 jason Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -1114,6 +1114,7 @@ struct ti_softc {
struct ifmedia ifmedia; /* media info */
u_int8_t ti_hwrev; /* Tigon rev (1 or 2) */
u_int8_t ti_linkstat; /* Link state */
+ bus_dma_tag_t sc_dmatag;
struct ti_ring_data *ti_rdata; /* rings */
struct ti_chain_data ti_cdata; /* mbufs */
#define ti_ev_prodidx ti_rdata->ti_ev_prodidx_r