Re: DRM memory manager on cards with hardware contexts

2006-10-05 Thread Thomas Hellström
Ben, I've implemented a version of the drm_mm code that unmaps ptes using unmap_mapping_range, and remaps IO space using io_remap_pfn_range() for a single page in nopage. This has the side effect that I need to double check in nopage() after taking the object mutex that the pte in question

Re: DRM memory manager on cards with hardware contexts

2006-10-05 Thread Benjamin Herrenschmidt
On Thu, 2006-10-05 at 17:52 +0200, Thomas Hellström wrote: Ben, I've implemented a version of the drm_mm code that unmaps ptes using unmap_mapping_range, and remaps IO space using io_remap_pfn_range() for a single page in nopage. This has the side effect that I need to double check in

Re: DRM memory manager on cards with hardware contexts

2006-10-05 Thread Benjamin Herrenschmidt
On Thu, 2006-10-05 at 17:52 +0200, Thomas Hellström wrote: Ben, I've implemented a version of the drm_mm code that unmaps ptes using unmap_mapping_range, and remaps IO space using io_remap_pfn_range() for a single page in nopage. This has the side effect that I need to double check in

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Thomas Hellström
Benjamin Herrenschmidt wrote: OK. It seems like mmap locks are needed even for unmap_mapping_range(). Well, I came to the opposite conclusion :) unmap_mapping_range() uses the truncate count mecanism to guard against a racing no_page(). The idea is that: no_page()

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Benjamin Herrenschmidt
OK. i was reffering to another approach: Copying _to_ VRAM /AGP: lock_mmap_sems() unmap_mapping_range() (or similar) copy() / flip() foreach_affected_vma{ io_remap_pfn_range() /* Map vram / AGP space */ } unlock_mmap_sem() This works like a charm in the drm memory manager but it

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Benjamin Herrenschmidt
* objects have rwsem to protect migration. * no_page() does: - takes that object read sem - if object is in vram or other non-memory location then do io_remap_pfn_range() and get a dummy page struct pointer - else get the struct page of the object page in memory - release the

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Thomas Hellström
Benjamin Herrenschmidt wrote: OK. i was reffering to another approach: Copying _to_ VRAM /AGP: lock_mmap_sems() unmap_mapping_range() (or similar) copy() / flip() foreach_affected_vma{ io_remap_pfn_range() /* Map vram / AGP space */ } unlock_mmap_sem() This works like a charm in the drm

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Benjamin Herrenschmidt
I'm finding this an interesting discussion. If it shifts to lkml, for instance, is there a way to follow *and post* on the thread without either subscribing to lkml or requiring myself to be on the CC list? I don't know if lkml allows non-subscriber posted, I think it does tho. So you can

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Ville Syrjälä
On Thu, Sep 21, 2006 at 07:18:07PM +1000, Benjamin Herrenschmidt wrote: I'm finding this an interesting discussion. If it shifts to lkml, for instance, is there a way to follow *and post* on the thread without either subscribing to lkml or requiring myself to be on the CC list? I

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Benjamin Herrenschmidt
No, that's probably the safest approach we can use until NOPAGE_RETRY arrives. Only I was not sure it'd be safe to call io_remap_pfn_range() from within nopage, in case it modifies some internal mm structs that the kernel nopage() code expects to be untouched. It does a couple of things

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Keith Whitwell
Ville Syrjälä wrote: On Thu, Sep 21, 2006 at 07:18:07PM +1000, Benjamin Herrenschmidt wrote: I'm finding this an interesting discussion. If it shifts to lkml, for instance, is there a way to follow *and post* on the thread without either subscribing to lkml or requiring myself to be on the

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Thomas Hellström
Benjamin Herrenschmidt wrote: No, that's probably the safest approach we can use until NOPAGE_RETRY arrives. Only I was not sure it'd be safe to call io_remap_pfn_range() from within nopage, in case it modifies some internal mm structs that the kernel nopage() code expects to be untouched.

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Benjamin Herrenschmidt
Hmm, the comments to handle_pte_fault(), which is calling do_nopage gives some insight.. * Note the page_table_lock. It is to protect against kswapd removing * pages from under us. Note that kswapd only ever _removes_ pages, never * adds them. As such, once we have noticed that the

Re: DRM memory manager on cards with hardware contexts

2006-09-21 Thread Thomas Hellström
Thomas Hellström wrote: Benjamin Herrenschmidt wrote: Hmm, the comments to handle_pte_fault(), which is calling do_nopage gives some insight.. * Note the page_table_lock. It is to protect against kswapd removing * pages from under us. Note that kswapd only ever _removes_ pages, never *

Re: DRM memory manager on cards with hardware contexts

2006-09-20 Thread Thomas Hellström
Benjamin Herrenschmidt wrote: On Tue, 2006-09-19 at 12:49 +0200, Thomas Hellström wrote: Benjamin Herrenschmidt wrote: On Tue, 2006-09-19 at 11:27 +0200, Thomas Hellström wrote: But this should be the same problem encountered by the

Re: DRM memory manager on cards with hardware contexts

2006-09-20 Thread Benjamin Herrenschmidt
I don't think so. We are not doing vram yet in the TTM code, but I think a general eviction would consist of 1) locking mmap_sems for all processes mapping the buffer. 2) zap the page table. Any attempt to access will be blocked by mmap_sem in nopage(). 3) Copy contents from vram to

Re: DRM memory manager on cards with hardware contexts

2006-09-20 Thread Benjamin Herrenschmidt
OK. It seems like mmap locks are needed even for unmap_mapping_range(). Well, I came to the opposite conclusion :) unmap_mapping_range() uses the truncate count mecanism to guard against a racing no_page(). The idea is that: no_page() itself internally takes the per-obkect lock/mutex

Re: DRM memory manager on cards with hardware contexts

2006-09-19 Thread Benjamin Herrenschmidt
On Tue, 2006-09-19 at 11:27 +0200, Thomas Hellström wrote: But this should be the same problem encountered by the agpgart driver? x86 and x86-64 calls change_page_attr() to take care of this. On powerpc it is simply a noop. (asm/agp.h) Possibly. We sort-of ignore the issue for now on PowerPC

Re: DRM memory manager on cards with hardware contexts

2006-09-19 Thread Thomas Hellström
Benjamin Herrenschmidt wrote: On Tue, 2006-09-19 at 11:27 +0200, Thomas Hellström wrote: But this should be the same problem encountered by the agpgart driver? x86 and x86-64 calls change_page_attr() to take care of this. On powerpc it is simply a noop. (asm/agp.h)

Re: DRM memory manager on cards with hardware contexts

2006-09-19 Thread Stephane Marchesin
Thomas Hellström wrote: Benjamin Herrenschmidt wrote: On Tue, 2006-09-19 at 11:27 +0200, Thomas Hellström wrote: But this should be the same problem encountered by the agpgart driver? x86 and x86-64 calls change_page_attr() to take care of this. On powerpc it is simply a noop.

Re: DRM memory manager on cards with hardware contexts

2006-09-18 Thread Keith Whitwell
Dave Airlie wrote: Obviously, we are interested in making use of the new DRM memory manager on that hardware. Now if I understand how it works correctly, this new memory manager allocates opaque handles which are not to be used as offset in memory, because they are not. Therefore, a

Re: DRM memory manager on cards with hardware contexts

2006-09-18 Thread Benjamin Herrenschmidt
Yes, this is really a different hardware model than we're used to dealing with for DRI drivers, however it's not a problem for the most part - if you don't need to take the lock, don't. But then you need some other way of dealing with the other hacky stuff we get away with by lock

Re: DRM memory manager on cards with hardware contexts

2006-09-18 Thread Thomas Hellström
Benjamin Herrenschmidt wrote: Yes, this is really a different hardware model than we're used to dealing with for DRI drivers, however it's not a problem for the most part - if you don't need to take the lock, don't. But then you need some other way of dealing with the other hacky

Re: DRM memory manager on cards with hardware contexts

2006-09-18 Thread Benjamin Herrenschmidt
Actually, the TTM memory manager already does this, but also changes the caching policy of the linear kernel map. The later is not portable unfortunately, and can have other serious performance impacts. Typically, the kernel linear map is mapped using larger page sizes, or in some cases,

Re: DRM memory manager on cards with hardware contexts

2006-09-18 Thread Ian Romanick
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Keith Whitwell wrote: Extending the memory manager would involve adding an ability to lock and unlock surfaces to VRAM/AGP addresses - this would require kernel interaction I guess. The driver would have to lock the surfaces then be free to

Re: DRM memory manager on cards with hardware contexts

2006-09-18 Thread Benjamin Herrenschmidt
On Mon, 2006-09-18 at 16:46 +0200, Thomas Hellström wrote: Unfortunately this leads to rather costly cache and TLB flushes. Particularly on SMP. I think Keith was referring to the drawbacks with buffers pinned in AGP or VRAM space. What about a futex-like approach: A shared are mapped by

DRM memory manager on cards with hardware contexts

2006-09-17 Thread Stephane Marchesin
Hello, Before explaining the issue, let me first introduce the context a bit. We are working on hardware that supports multiple contexts. By allocating one context to each application, we can achieve full graphics command submission from user space (each context is actually simply a command

Re: DRM memory manager on cards with hardware contexts

2006-09-17 Thread Dave Airlie
Obviously, we are interested in making use of the new DRM memory manager on that hardware. Now if I understand how it works correctly, this new memory manager allocates opaque handles which are not to be used as offset in memory, because they are not. Therefore, a translation from the handle