Subject: Re: memory questions
To: Filka Michal <michal.filka@strom.cz>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 04/12/2006 13:40:00
>> Yes, provided you do it properly.
> ... it means?

Using copyin/copyout, uiomove, double-mapping, etc.  Certainly not just
following pointers passed by userland.

>> If you want to DMA directly into user memory, [...]
> ... 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).

I'd have to look at the code, and quite possibly even then I wouldn't
see the problem.

> 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.

This is true on some machines.  On others, DMA uses virtual addresses
too.  On yet others (eg, the MicroVAX-II with its Q-bus mapping), it's
even more confusing - it's as if DMA uses virtual addresses, but with
an MMU distinct from the one used for the OS's virtual memory.

> However, I thought that pages forming logical view cannot be swapped
> out of memory.  Is it correct idea?

Eh.  Yes and no.

Virtual pages cannot be paged out; the concept doesn't really even make
sense.  But the physical pages backing them can be.  As I understand
it, memory allocated by bus_dmamem_alloc is not paged, though, so this
is not what's going on.

Again, I'd have to look at the code, and quite possibly wouldn't see
the problem even then - this is a part of the kernel I am comparatively
unfamiliar with.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B