Hi Hans, On Mon, May 08, 2017 at 03:08:26PM +0200, Hans Verkuil wrote: > On 05/08/2017 02:56 PM, Sakari Ailus wrote: ... > >> The USERPTR mode is more dubious. Has this been tested? Can the DMA handle partially > >> filled pages? (I.e. there must be no requirements such as that the DMA has to start > >> at a page boundary, since that's not the case with USERPTR). > > > > I rememeber this has been discussed before. :-) > > > > Most hardware has some limitations on the granularity of the buffer start > > address, and the drivers still support USERPTR memory. In practice the C > > library allocated memory is always page aligned if the size is large enough, > > which is in practice the case for video buffers. > > That was not true the last time I checked. I can't remember what the exact > alignment was, although I do remember that it was different for 32 and 64 bit. Hmm. This just shows how little I really know about user space. :-I I just tested this to see how it really works out, and there doesn't seem to be much alignment at all. I believe my earlier recollection was likely related to a non-GNU C library (huh!). > > I am also pretty sure it was less than 64 bytes. It's been 2 years ago since > I last looked at this, though. As in here: 00:26:02 lanttu sailus [~]cat /tmp/foo.c #include <stdbool.h> #include <stdio.h> #include <stdlib.h> void main() { unsigned int i; for (i=0; i < 16; i++) printf("%x\n",malloc(1024*768*i)); } 00:26:03 lanttu sailus [~]gcc -o /tmp/foo /tmp/foo.c 00:26:06 lanttu sailus [~]/tmp/foo 8604008 f7525008 f73a4008 f7163008 f6e62008 f6aa1008 f6620008 f60df008 f5ade008 f541d008 f4c9c008 f445b008 f3b5a008 f3199008 f2718008 f1bd7008 So posix_memalign() (or memalign()) is needed to allocate page aligned memory. At least on GNU libc. -- Regards, Sakari Ailus e-mail: sakari.ailus@xxxxxx XMPP: sailus@xxxxxxxxxxxxxx