Add a buffer object manager for TTM maps.

main
Thomas Hellstrom 2006-10-02 14:03:15 +02:00
parent d85b99435f
commit a31046b873
3 changed files with 35 additions and 20 deletions

View File

@ -163,6 +163,10 @@
#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
#define DRM_MAP_HASH_OFFSET 0x10000000 #define DRM_MAP_HASH_OFFSET 0x10000000
#define DRM_MAP_HASH_ORDER 12
#define DRM_OBJECT_HASH_ORDER 12
#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
/*@}*/ /*@}*/
@ -532,6 +536,25 @@ typedef struct drm_sigdata {
drm_hw_lock_t *lock; drm_hw_lock_t *lock;
} drm_sigdata_t; } drm_sigdata_t;
/*
* Generic memory manager structs
*/
typedef struct drm_mm_node {
struct list_head fl_entry;
struct list_head ml_entry;
int free;
unsigned long start;
unsigned long size;
void *private;
} drm_mm_node_t;
typedef struct drm_mm {
drm_mm_node_t root_node;
} drm_mm_t;
/** /**
* Mappings list * Mappings list
*/ */
@ -540,6 +563,7 @@ typedef struct drm_map_list {
drm_hash_item_t hash; drm_hash_item_t hash;
drm_map_t *map; /**< mapping */ drm_map_t *map; /**< mapping */
drm_u64_t user_token; drm_u64_t user_token;
drm_mm_node_t *file_offset_node;
} drm_map_list_t; } drm_map_list_t;
typedef drm_map_t drm_local_map_t; typedef drm_map_t drm_local_map_t;
@ -572,24 +596,6 @@ typedef struct ati_pcigart_info {
drm_local_map_t mapping; drm_local_map_t mapping;
} drm_ati_pcigart_info; } drm_ati_pcigart_info;
/*
* Generic memory manager structs
*/
typedef struct drm_mm_node {
struct list_head fl_entry;
struct list_head ml_entry;
int free;
unsigned long start;
unsigned long size;
void *private;
} drm_mm_node_t;
typedef struct drm_mm {
drm_mm_node_t root_node;
} drm_mm_t;
/* /*
* User space objects and their references. * User space objects and their references.
*/ */
@ -866,6 +872,7 @@ typedef struct drm_device {
drm_map_list_t *maplist; /**< Linked list of regions */ drm_map_list_t *maplist; /**< Linked list of regions */
int map_count; /**< Number of mappable regions */ int map_count; /**< Number of mappable regions */
drm_open_hash_t map_hash; /**< User token hash table for maps */ drm_open_hash_t map_hash; /**< User token hash table for maps */
drm_mm_t offset_manager; /**< User token manager */
drm_open_hash_t object_hash; /**< User token hash table for objects */ drm_open_hash_t object_hash; /**< User token hash table for objects */
/** \name Context handle management */ /** \name Context handle management */

View File

@ -377,6 +377,7 @@ static void drm_cleanup(drm_device_t * dev)
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
dev->maplist = NULL; dev->maplist = NULL;
drm_ht_remove(&dev->map_hash); drm_ht_remove(&dev->map_hash);
drm_mm_takedown(&dev->offset_manager);
drm_ht_remove(&dev->object_hash); drm_ht_remove(&dev->object_hash);
} }

View File

@ -83,17 +83,24 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
if (dev->maplist == NULL) if (dev->maplist == NULL)
return -ENOMEM; return -ENOMEM;
INIT_LIST_HEAD(&dev->maplist->head); INIT_LIST_HEAD(&dev->maplist->head);
if (drm_ht_create(&dev->map_hash, 12)) { if (drm_ht_create(&dev->map_hash, DRM_MAP_HASH_ORDER)) {
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
return -ENOMEM; return -ENOMEM;
} }
if (drm_mm_init(&dev->offset_manager, DRM_FILE_PAGE_OFFSET_START,
if (drm_ht_create(&dev->object_hash, 12)) { DRM_FILE_PAGE_OFFSET_SIZE)) {
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
drm_ht_remove(&dev->map_hash); drm_ht_remove(&dev->map_hash);
return -ENOMEM; return -ENOMEM;
} }
if (drm_ht_create(&dev->object_hash, DRM_OBJECT_HASH_ORDER)) {
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
drm_ht_remove(&dev->map_hash);
drm_mm_takedown(&dev->offset_manager);
return -ENOMEM;
}
/* the DRM has 6 counters */ /* the DRM has 6 counters */
dev->counters = 6; dev->counters = 6;
dev->types[0] = _DRM_STAT_LOCK; dev->types[0] = _DRM_STAT_LOCK;