summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2007-01-30Indent according to xorg rules.Thomas Hellstrom
2007-01-30Add license header.Thomas Hellstrom
2007-01-30Add some relevant tests for the new buffer object interface.Thomas Hellstrom
2007-01-30Add the ttmtest test utility.Thomas Hellstrom
2007-01-30Clean up buffer object destruction somewhat.Thomas Hellstrom
2007-01-29Use pre-defined list_splice function.Thomas Hellstrom
2007-01-29s/buf/bo/ for consistency.Thomas Hellstrom
2007-01-29Some cleanup. A buffer object should only have one active memory type.Thomas Hellstrom
2007-01-28nouveau: determine chipset type at startup, instead of every time we use it.Ben Skeggs
2007-01-26make works ctx switch on nv10.Matthieu Castet
2007-01-26nouveau: oops, wrong indexing in nv17 regsPatrice Mandin
2007-01-26nouveau: read gpu type oncePatrice Mandin
2007-01-26nouveau: only save/restore nv17 regs on nv17,18 hwPatrice Mandin
2007-01-26nouveau: add extra pgraph registersPatrice Mandin
2007-01-26nouveau: add some nv10 pgraph definesPatrice Mandin
2007-01-25nouveau: simplify and fix BIG_ENDIAN flagsPatrice Mandin
2007-01-25Merge branch 'master' into crestlineNian Wu
2007-01-25Remove a scary error printed when we were leaking memory caches.Thomas Hellstrom
2007-01-25nouveau: nv4c default contextBen Skeggs
2007-01-25nouveau: always print nsource/nstatus regs on PGRAPH errorsBen Skeggs
2007-01-24vblank interrupt fixZou Nan hai
2007-01-19nouveau: fix getparam from 32-bit client on 64-bit kernelBen Skeggs
2007-01-19nouveau: re-add 6150 Go pciid (0x0244)Ben Skeggs
2007-01-18nouveau: cleanup nv30_graph.cJeremy Kolb
2007-01-18nouveau: Remove write to CTX_SIZE. This gives us proper nv3x PGRAPH switching.Jeremy Kolb
2007-01-18add missing quadro idDave Jones
2007-01-17nouveau: Try to get nv35 pgraph switching working. Doesn't quite yet.Jeremy Kolb
2007-01-16Merge branch 'master' into crestlineXiang, Haihao
2007-01-14nouveau: opps nv20 ctx ramin size was wrongMatthieu Castet
2007-01-13nouveau: opps restored the wrong channelMatthieu Castet
2007-01-13nouveau: nv20 graph ctx switch.Matthieu Castet
2007-01-13nouveau: first step to make graph ctx worksMatthieu Castet
2007-01-13nouveau: add and indent pgraph regsMatthieu Castet
2007-01-13nouveau: Oops, fix the nv04 RAMFC_DMA_FETCH value.Stephane Marchesin
2007-01-13nouveau: add missing symlinkDave Airlie
2007-01-12nouveau : remove useless init : we clear RAMIN beforeMatthieu Castet
2007-01-12Delay for a usec while spinning waiting for ring buffer space.Haihao Xiang
2007-01-12nouveau: get nv30 context switching to work.Jeremy Kolb
2007-01-11radeon: Fix u32 overflows when determining AGP base address in card space.Michel Dänzer
2007-01-10Revert "nouveau: Fill in context_init for nv10-nv3x."Dave Airlie
2007-01-09nouveau: Fill in context_init for nv10-nv3x.Jeremy Kolb jkolb@brandeis.edu
2007-01-10nouveau: Don't use DRIVER_USE_MTRR, we already setup our own mtrr over vram.Stephane Marchesin
2007-01-09ttm: make ttm alloc/free into alloc_pages/free_pagesDave Airlie
2007-01-09novueau: try resource 3 if resource 2 is 0 lengthDave Airlie
2007-01-08nouveau: fix nv4a context size.Stephane Marchesin
2007-01-08add export symbol for memory managerDave Airlie
2007-01-07Align whitespace with masterKeith Packard
2007-01-07Merge branch 'master' into crestlineKeith Packard
2007-01-08nouveau: nv4a context support.Stephane Marchesin
2007-01-08Merge branch 'master' of git+ssh://marcheu@git.freedesktop.org/git/mesa/drmStephane Marchesin
* permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * * **************************************************************************/ /* * Simple memory manager interface that keeps track on allocate regions on a * per "owner" basis. All regions associated with an "owner" can be released * with a simple call. Typically if the "owner" exists. The owner is any * "unsigned long" identifier. Can typically be a pointer to a file private * struct or a context identifier. * * Authors: * Thomas Hellström <thomas-at-tungstengraphics-dot-com> */ #include "drm_sman.h" typedef struct drm_owner_item { drm_hash_item_t owner_hash; struct list_head sman_list; struct list_head mem_blocks; } drm_owner_item_t; void drm_sman_takedown(drm_sman_t * sman) { drm_ht_remove(&sman->user_hash_tab); drm_ht_remove(&sman->owner_hash_tab); if (sman->mm) drm_free(sman->mm, sman->num_managers * sizeof(*sman->mm), DRM_MEM_MM); } EXPORT_SYMBOL(drm_sman_takedown); int drm_sman_init(drm_sman_t * sman, unsigned int num_managers, unsigned int user_order, unsigned int owner_order) { int ret = 0; sman->mm = (drm_sman_mm_t *) drm_calloc(num_managers, sizeof(*sman->mm), DRM_MEM_MM); if (!sman->mm) { ret = -ENOMEM; goto out; } sman->num_managers = num_managers; INIT_LIST_HEAD(&sman->owner_items); ret = drm_ht_create(&sman->owner_hash_tab, owner_order); if (ret) goto out1; ret = drm_ht_create(&sman->user_hash_tab, user_order); if (!ret) goto out; drm_ht_remove(&sman->owner_hash_tab); out1: drm_free(sman->mm, num_managers * sizeof(*sman->mm), DRM_MEM_MM); out: return ret; } EXPORT_SYMBOL(drm_sman_init); static void *drm_sman_mm_allocate(void *private, unsigned long size, unsigned alignment) { drm_mm_t *mm = (drm_mm_t *) private; drm_mm_node_t *tmp; tmp = drm_mm_search_free(mm, size, alignment, 1); if (!tmp) { return NULL; } tmp = drm_mm_get_block(tmp, size, alignment); return tmp; } static void drm_sman_mm_free(void *private, void *ref) { drm_mm_t *mm = (drm_mm_t *) private; drm_mm_node_t *node = (drm_mm_node_t *) ref; drm_mm_put_block(mm, node); } static void drm_sman_mm_destroy(void *private) { drm_mm_t *mm = (drm_mm_t *) private; drm_mm_takedown(mm); drm_free(mm, sizeof(*mm), DRM_MEM_MM); } static unsigned long drm_sman_mm_offset(void *private, void *ref) { drm_mm_node_t *node = (drm_mm_node_t *) ref; return node->start; } int drm_sman_set_range(drm_sman_t * sman, unsigned int manager, unsigned long start, unsigned long size) { drm_sman_mm_t *sman_mm; drm_mm_t *mm; int ret; BUG_ON(manager >= sman->num_managers); sman_mm = &sman->mm[manager]; mm = drm_calloc(1, sizeof(*mm), DRM_MEM_MM); if (!mm) { return -ENOMEM; } sman_mm->private = mm; ret = drm_mm_init(mm, start, size); if (ret) { drm_free(mm, sizeof(*mm), DRM_MEM_MM); return ret; } sman_mm->allocate = drm_sman_mm_allocate; sman_mm->free = drm_sman_mm_free; sman_mm->destroy = drm_sman_mm_destroy; sman_mm->offset = drm_sman_mm_offset; return 0; } EXPORT_SYMBOL(drm_sman_set_range); int drm_sman_set_manager(drm_sman_t * sman, unsigned int manager, drm_sman_mm_t * allocator) { BUG_ON(manager >= sman->num_managers); sman->mm[manager] = *allocator; return 0; } static drm_owner_item_t *drm_sman_get_owner_item(drm_sman_t * sman, unsigned long owner) { int ret; drm_hash_item_t *owner_hash_item; drm_owner_item_t *owner_item; ret = drm_ht_find_item(&sman->owner_hash_tab, owner, &owner_hash_item); if (!ret) { return drm_hash_entry(owner_hash_item, drm_owner_item_t, owner_hash); } owner_item = drm_calloc(1, sizeof(*owner_item), DRM_MEM_MM); if (!owner_item) goto out; INIT_LIST_HEAD(&owner_item->mem_blocks); owner_item->owner_hash.key = owner; if (drm_ht_insert_item(&sman->owner_hash_tab, &owner_item->owner_hash)) goto out1; list_add_tail(&owner_item->sman_list, &sman->owner_items); return owner_item; out1: drm_free(owner_item, sizeof(*owner_item), DRM_MEM_MM); out: return NULL; } drm_memblock_item_t *drm_sman_alloc(drm_sman_t *sman, unsigned int manager, unsigned long size, unsigned alignment, unsigned long owner) { void *tmp; drm_sman_mm_t *sman_mm; drm_owner_item_t *owner_item; drm_memblock_item_t *memblock; BUG_ON(manager >= sman->num_managers); sman_mm = &sman->mm[manager]; tmp = sman_mm->allocate(sman_mm->private, size, alignment); if (!tmp) { return NULL; } memblock = drm_calloc(1, sizeof(*memblock), DRM_MEM_MM); if (!memblock) goto out; memblock->mm_info = tmp; memblock->mm = sman_mm; memblock->sman = sman; if (drm_ht_just_insert_please (&sman->user_hash_tab, &memblock->user_hash, (unsigned long)memblock, 32, 0, 0)) goto out1; owner_item = drm_sman_get_owner_item(sman, owner); if (!owner_item) goto out2; list_add_tail(&memblock->owner_list, &owner_item->mem_blocks); return memblock; out2: drm_ht_remove_item(&sman->user_hash_tab, &memblock->user_hash); out1: drm_free(memblock, sizeof(*memblock), DRM_MEM_MM); out: sman_mm->free(sman_mm->private, tmp); return NULL; } EXPORT_SYMBOL(drm_sman_alloc); static void drm_sman_free(drm_memblock_item_t *item) { drm_sman_t *sman = item->sman; list_del(&item->owner_list); drm_ht_remove_item(&sman->user_hash_tab, &item->user_hash); item->mm->free(item->mm->private, item->mm_info); drm_free(item, sizeof(*item), DRM_MEM_MM); } int drm_sman_free_key(drm_sman_t *sman, unsigned int key) { drm_hash_item_t *hash_item; drm_memblock_item_t *memblock_item; if (drm_ht_find_item(&sman->user_hash_tab, key, &hash_item)) return -EINVAL; memblock_item = drm_hash_entry(hash_item, drm_memblock_item_t, user_hash); drm_sman_free(memblock_item); return 0; } EXPORT_SYMBOL(drm_sman_free_key); static void drm_sman_remove_owner(drm_sman_t *sman, drm_owner_item_t *owner_item) { list_del(&owner_item->sman_list); drm_ht_remove_item(&sman->owner_hash_tab, &owner_item->owner_hash); drm_free(owner_item, sizeof(*owner_item), DRM_MEM_MM); } int drm_sman_owner_clean(drm_sman_t *sman, unsigned long owner) { drm_hash_item_t *hash_item; drm_owner_item_t *owner_item; if (drm_ht_find_item(&sman->owner_hash_tab, owner, &hash_item)) { return -1; } owner_item = drm_hash_entry(hash_item, drm_owner_item_t, owner_hash); if (owner_item->mem_blocks.next == &owner_item->mem_blocks) { drm_sman_remove_owner(sman, owner_item); return -1; } return 0; } EXPORT_SYMBOL(drm_sman_owner_clean); static void drm_sman_do_owner_cleanup(drm_sman_t *sman, drm_owner_item_t *owner_item) { drm_memblock_item_t *entry, *next; list_for_each_entry_safe(entry, next, &owner_item->mem_blocks, owner_list) { drm_sman_free(entry); } drm_sman_remove_owner(sman, owner_item); } void drm_sman_owner_cleanup(drm_sman_t *sman, unsigned long owner) { drm_hash_item_t *hash_item; drm_owner_item_t *owner_item; if (drm_ht_find_item(&sman->owner_hash_tab, owner, &hash_item)) {