I'm reading through the documentation on importing and exporting DMA buffers and one thing confuses me
does it matter where I export a buffer from, if I can then import a buffer from a different device?
could I create generic GBM buffers and then import them to all the video devices?
dcz: from an API standpoint, yes 
as opposed to some practical standpoint?
in practice, it's often less ideal than that: the importing device might not be able to access it, the buffers alignments might not match between devices, etc. 
so if your platform is flexible enough, it'll work, if it's pickier you could get into troubles 
the buffers don't have to live in the main memory, right?
(I think it's the 3rd time I'm confused about this, so I'll make a writeup of this, so I hope you don't mind if I quote you)
I think they need to, dma-buf just wouldn't work otherwise
but I'm not sure what's the strategy typically used by TTM for example to deal with it
what's TTM?
probably move the buffer from VRAM to main memory
the "big" GPU memory allocator 
where you have multiple "layers" of memory, kind of like caches 
oh, so they could live in VRAM, so that's the connection to the device, and this is where the "not accessible" or "bad alignment" limitations come from
also the "import" naming is SUPER confusing because it's not the inverse of export
not quite
TTM is for desktop/server-grade GPUs that have VRAM 
here, the buffer might be in VRAM indeed, and wouldn't be accessible to devices not on the GPU
but plenty of other devices do not have VRAM at all 
and the buffer would be located in the system/main memory 
but still, devices connected to the main memory might have restrictions on which range of the system memory it can access 
a typical example is that you have a 64-bit system, but the register holding the buffer address is 32-bits wide 
so you can only access the lower 4GB of the RAM from that device, and if the buffer is allocated in the "upper" part, you're screwed 
ah, thanks, I didn't think of that
where does the alignment thing come from? simply from the differences of capabilities between the producing and the consuming device?
capabilities, but also hardware constraints / requirements 
like, if you allocate a buffer from the camera that needs a 32 bytes alignment, but import it on the GPU that requires a 256 bytes alignment, it doesn't work either 
(but the opposite would)
makes sense
that's what I meant by "capabilities", but from your answer I see there's a different definition?
I guess it's semantics, but it doesn't really depend on what the device is capable of, but rather how it was designed / built 
like, you can have a vehicle go to 300kph with 2, 3 or 4 wheels. Having 4 wheels on your car is a requirement, getting to 300kph is a capability 
I see what you mean
does this have any mistakes? https://gitlab.freedesktop.org/dcz_pf/libobscura/-/snippets/7810
I based this on libcamera sources, but I have no idea why REQBUFS is called twice
it's private I think?
this works https://gitlab.freedesktop.org/dcz_pf/snip/-/snippets/7811