Subject: Re: CVS commit: src/sys
To: None <tech-kern@netbsd.org>
From: Yorick Hardy <yhardy@uj.ac.za>
List: tech-kern
Date: 02/23/2007 16:36:33
This is a multi-part message in MIME format.
--------------000902010601060508050801
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
> Log Message:
> add a pair of new bus_dma(9) functions:
> int _bus_dmatag_subregion(bus_dma_tag_t tag,
> bus_addr_t min_addr,
> bus_addr_t max_addr,
> bus_dma_tag_t *newtag,
> int flags)
> void _bus_dmatag_destroy(bus_dma_tag_t tag)
>
> that allow a (normally broken/limited) device to restrict the bus address
> range it can talk to. this is used by bce(4) to limit DMA addresses to
> 1GB range, the maximum the chip can address.
>
> all this is from Yorick Hardy <yhardy@uj.ac.za> with input from several
> people on tech-kern.
>
> XXX: bus_dma(9) needs an update still.
>
How does this look? (Attached)
--
Kind regards,
Yorick Hardy
--------------000902010601060508050801
Content-Type: text/plain;
name="bus_dma.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="bus_dma.patch"
--- share/man/man9/bus_dma.9.orig 2007-02-23 16:21:58.000000000 +0200
+++ share/man/man9/bus_dma.9 2007-02-23 16:33:57.000000000 +0200
@@ -52,7 +52,9 @@
.Nm bus_dmamem_free ,
.Nm bus_dmamem_map ,
.Nm bus_dmamem_unmap ,
-.Nm bus_dmamem_mmap
+.Nm bus_dmamem_mmap ,
+.Nm bus_dmatag_subregion ,
+.Nm bus_dmatag_destroy
.Nd Bus and Machine Independent DMA Mapping Interface
.Sh SYNOPSIS
.In machine/bus.h
@@ -92,6 +94,11 @@
.Ft paddr_t
.Fn bus_dmamem_mmap "bus_dma_tag_t tag" "bus_dma_segment_t *segs" \
"int nsegs" "off_t off" "int prot" "int flags"
+.Ft int
+.Fn bus_dmatag_subregion "bus_dma_tag_t tag" "bus_addr_t min_addr" \
+"bus_addr_t max_addr" "bus_dma_tag_t *newtag" "int flags"
+.Ft void
+.Fn bus_dmatag_destroy "bus_dma_tag_t tag"
.Sh DESCRIPTION
Provide a bus- and machine-independent "DMA mapping interface."
.Sh NOTES
@@ -777,6 +784,53 @@
.Pp
Returns -1 to indicate failure.
Otherwise, returns an opaque value to be interpreted by the device pager.
+.It Fn bus_dmatag_subregion "tag" "min_addr" "max_addr" "newtag" "flags"
+Creates a new bus_dma_tag_t in
+.Fa newtag
+from
+.Fa tag
+with the added constraint that data will only be transferred to
+memory addresses in the range (subregion)
+.Fa min_addr
+to
+.Fa max_addr.
+The arguments are as follows:
+.Bl -tag -width nsegs -compact
+.It Fa tag
+This is the bus_dma_tag_t passed down from the parent driver via
+.Fa \*[Lt]bus\*[Gt]_attach_args .
+.It Fa min_addr
+The low address constraint for DMA transfers.
+This address is included.
+.It Fa max_addr
+The high address constraint for DMA transfers.
+This address is not included.
+.It Fa newtag
+A pointer to a bus_dma_tag_t which will store
+the tag limited to the subregion.
+.It Fa flags
+Flags are defined as follows:
+.Bl -tag -width BUS_DMA_COHERENT -compact
+.It Dv BUS_DMA_NOWAIT
+It is not safe to wait (sleep) for resources during this call.
+.El
+.El
+.Pp
+Returns 0 on success, or an error code to indicate mode of failure.
+Architectures which do not yet support this operation return EOPNOTSUPP.
+.It Fn bus_dmatag_destroy "tag"
+Frees any resources associated with
+.Fa tag
+when the tag is no longer needed.
+.Fn bus_dmatag_destroy
+should always be called when a
+.Fa tag
+created by
+.Fn bus_dmatag_subregion
+is no longer needed.
+If given valid arguments,
+.Fn bus_dmatag_destroy
+always succeeds.
.El
.Sh SEE ALSO
.Xr bus_space 9
--------------000902010601060508050801--