Subject: Re: memory questions
To: Filka Michal <michal.filka@strom.cz>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 04/12/2006 13:12:01
--YS7t75H5cNTCpbja
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Apr 12, 2006 at 12:52:49PM +0200, Filka Michal wrote:
> Yes, provided you do it properly.
> ... it means?
>=20
>   If you want to DMA directly into user memory,
> you have to (a) make sure the relevant pages are locked in memory for
> the duration and (b) do the correct dance to make sure caches and such
> are properly handled - this is part of why bus_dma exists, so the
> driver code can be insulated from the (heavily machine-specific)
> details of this dance..
> ... No I really don't want such thing. I have allocated a buffer for DMA
> access (bus_dmamem_alloc). I need to do some operations above it (namely
> Rx/Tx descriptors are stored there), but sometimes it fails (page
> fault). As I understand DMA in NetBSD, there are two views on same part
> of memory. First view is the "physical" one which is used by device,
> second one is "logical". In logical view is memory for DMA access mapped
> into virtual memory space. I simplified the description a little.
> However, I thought that pages forming logical view cannot be swapped out
> of memory. Is it correct idea?

You're probably mixing one for the other in your code.  Accessing the
physical address from the kernel will almost certainly give you a page
fault.  Unless you show some code where we could point at the errors,
you'll get little more information here than provided in bus_dma(9) and
source of NetBSD drivers.

--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.

--YS7t75H5cNTCpbja
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)

iQEVAwUBRDzggdgoQloHrPnoAQLqaQgAsh1Gusx5QVK0fOUHjntu9vEL7s1PPTir
nKRb+iWyOXAEIZp2qCcAHwcuPgBIrp5ix7XqPs+TlStTcjz6yrVIrfh/W10deU/N
BumuLXPp6ByFBDGS2lJG5vkWiiBCCuXgH3hxR+lQqbJN7C0i6+d4n/wnLVqv7+kS
bisu6XMUNlOxvOSLzCLD3PdsA99XIGS4chDkmyom+rCkvZ32ZfnHOFPVbQRLiw9A
gsntJshqdL1UA8iSM9LslXin1ZwkhbFf8qIDLNBMB3nPFpBGm6nlWne28xQ1yEuL
5UDls0R4yCYu7Tx0g2MtgY8VY1EL+6BB/TYswZFzpAp7QlnwYHdPmA==
=Q7R0
-----END PGP SIGNATURE-----

--YS7t75H5cNTCpbja--