Get PCI vendor/device ID from userland

2013-07-26 Thread Jean-Sébastien Pédron
Hello,

While looking at pipe_loader_drm.c in Mesa, I see that udev is used on 
Linux to get the PCI ID of the device. I understand that getting this 
information is a general need in libdrm, Mesa, and so on.

Is there a portable way to obtain this?

If not, what do you think about adding an ioctl in drm to get the PCI ID 
of an opened device?

-- 
Jean-S?bastien P?dron


Questions about TTM buffer object maping

2013-07-12 Thread Jean-Sébastien Pédron
Le 11/07/2013 23:51, David Herrmann a ?crit :
> ->vm_open() isn't called for the first mmap(), afaik (only called
> during fork()s or similar). So the reference in ttm_bo_mmap() is a
> replacement for the reference you take in the ->vm_open() callback.

So the reference is acquired either in ttm_bo_mmap() or in 
ttm_bo_vm_open(), and always released in ttm_bo_vm_close().

Thanks to both of you!

-- 
Jean-S?bastien P?dron


Questions about TTM buffer object maping

2013-07-12 Thread Jean-Sébastien Pédron
Hi,

Thank you J?r?me and Daniel for your input, that's really helpful!

I have another question: in ttm_bo_mmap(), a reference to the buffer 
object is acquired at the beginning of the function. Another reference 
is acquired in ttm_bo_vm_open() (released in ttm_bo_vm_close()).

But where is the first reference released?

-- 
Jean-S?bastien P?dron


Questions about TTM buffer object maping

2013-07-11 Thread Jean-Sébastien Pédron
Hello,

I'm trying to understand how TTM buffer object mapping works on Linux, 
to make this behave properly on FreeBSD.

Here's what I think I understand:

When a buffer object is mmap()'d, ttm_bo_vm_open() is called. When 
there's a page fault, the page is looked up and inserted in the VMA 
using vm_insert_mixed(). When a buffer object is munmap()'d, 
ttm_bo_vm_close() is called, which drops a reference. When the last 
reference is dropped, the buffer object is destroyed.

What's still not clear to me is how munmap() works here. After talking 
about this on IRC with some people, I think that unmap_mapping_range() 
(called by ttm_bo_unmap_virtual_locked()) is equivalent to calling 
munmap() from userland. Is that true?

When a buffer object is moved, what happens to the mapping?

In particular, I see in ttm_bo_move_accel_cleanup() that the ttm 
structure can be transferred to ghost_obj, which is destroyed shortly 
after. This ends up in ttm_put_pages() which uses __free_page(), for 
each page of the buffer object. At this stage, is the ghost object 
already munmap()'d? Or does __free_page() unmap a page implicitly (ie. 
remove it from VMA)?

Sorry if my questions are stupid, I'm rather new to memory management.

-- 
Jean-S?bastien P?dron


Re: Questions about TTM buffer object maping

2013-07-11 Thread Jean-Sébastien Pédron

Le 11/07/2013 23:51, David Herrmann a écrit :

-vm_open() isn't called for the first mmap(), afaik (only called
during fork()s or similar). So the reference in ttm_bo_mmap() is a
replacement for the reference you take in the -vm_open() callback.


So the reference is acquired either in ttm_bo_mmap() or in 
ttm_bo_vm_open(), and always released in ttm_bo_vm_close().


Thanks to both of you!

--
Jean-Sébastien Pédron
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Questions about TTM buffer object maping

2013-07-10 Thread Jean-Sébastien Pédron

Hello,

I'm trying to understand how TTM buffer object mapping works on Linux, 
to make this behave properly on FreeBSD.


Here's what I think I understand:

When a buffer object is mmap()'d, ttm_bo_vm_open() is called. When 
there's a page fault, the page is looked up and inserted in the VMA 
using vm_insert_mixed(). When a buffer object is munmap()'d, 
ttm_bo_vm_close() is called, which drops a reference. When the last 
reference is dropped, the buffer object is destroyed.


What's still not clear to me is how munmap() works here. After talking 
about this on IRC with some people, I think that unmap_mapping_range() 
(called by ttm_bo_unmap_virtual_locked()) is equivalent to calling 
munmap() from userland. Is that true?


When a buffer object is moved, what happens to the mapping?

In particular, I see in ttm_bo_move_accel_cleanup() that the ttm 
structure can be transferred to ghost_obj, which is destroyed shortly 
after. This ends up in ttm_put_pages() which uses __free_page(), for 
each page of the buffer object. At this stage, is the ghost object 
already munmap()'d? Or does __free_page() unmap a page implicitly (ie. 
remove it from VMA)?


Sorry if my questions are stupid, I'm rather new to memory management.

--
Jean-Sébastien Pédron
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel