Unify infrastructure for freeing on-card / GART memory.

main
Ian Romanick 2007-08-06 17:27:15 -07:00
parent 6718198897
commit f7ba02b745
4 changed files with 15 additions and 32 deletions

View File

@ -202,7 +202,9 @@ void xgi_cmdlist_cleanup(struct xgi_info * info)
xgi_waitfor_pci_idle(info); xgi_waitfor_pci_idle(info);
} }
xgi_pcie_free(info, info->cmdring.ring_gart_base, NULL); xgi_free(info, (XGI_MEMLOC_NON_LOCAL
| info->cmdring.ring_gart_base),
NULL);
info->cmdring.ring_hw_base = 0; info->cmdring.ring_hw_base = 0;
info->cmdring.ring_offset = 0; info->cmdring.ring_offset = 0;
info->cmdring.size = 0; info->cmdring.size = 0;

View File

@ -38,7 +38,7 @@
#define DRIVER_MAJOR 0 #define DRIVER_MAJOR 0
#define DRIVER_MINOR 10 #define DRIVER_MINOR 10
#define DRIVER_PATCHLEVEL 4 #define DRIVER_PATCHLEVEL 5
#include "xgi_cmdlist.h" #include "xgi_cmdlist.h"
#include "xgi_drm.h" #include "xgi_drm.h"
@ -89,8 +89,6 @@ struct xgi_info {
}; };
extern struct kmem_cache *xgi_mem_block_cache; extern struct kmem_cache *xgi_mem_block_cache;
extern int xgi_mem_free(struct xgi_mem_heap * heap, unsigned long offset,
struct drm_file * filp);
extern int xgi_mem_heap_init(struct xgi_mem_heap * heap, unsigned int start, extern int xgi_mem_heap_init(struct xgi_mem_heap * heap, unsigned int start,
unsigned int end); unsigned int end);
extern void xgi_mem_heap_cleanup(struct xgi_mem_heap * heap); extern void xgi_mem_heap_cleanup(struct xgi_mem_heap * heap);
@ -100,15 +98,12 @@ extern int xgi_fb_heap_init(struct xgi_info * info);
extern int xgi_alloc(struct xgi_info * info, struct xgi_mem_alloc * alloc, extern int xgi_alloc(struct xgi_info * info, struct xgi_mem_alloc * alloc,
struct drm_file * filp); struct drm_file * filp);
extern int xgi_fb_free(struct xgi_info * info, unsigned long offset, extern int xgi_free(struct xgi_info * info, unsigned long index,
struct drm_file * filp); struct drm_file * filp);
extern int xgi_pcie_heap_init(struct xgi_info * info); extern int xgi_pcie_heap_init(struct xgi_info * info);
extern void xgi_pcie_lut_cleanup(struct xgi_info * info); extern void xgi_pcie_lut_cleanup(struct xgi_info * info);
extern int xgi_pcie_free(struct xgi_info * info, unsigned long offset,
struct drm_file * filp);
extern void *xgi_find_pcie_virt(struct xgi_info * info, u32 address); extern void *xgi_find_pcie_virt(struct xgi_info * info, u32 address);
extern void xgi_free_all(struct xgi_info *, struct xgi_mem_heap *, extern void xgi_free_all(struct xgi_info *, struct xgi_mem_heap *,

View File

@ -169,8 +169,8 @@ static struct xgi_mem_block *xgi_mem_alloc(struct xgi_mem_heap * heap,
return (used_block); return (used_block);
} }
int xgi_mem_free(struct xgi_mem_heap * heap, unsigned long offset, static int xgi_mem_free(struct xgi_mem_heap * heap, unsigned long offset,
struct drm_file * filp) struct drm_file * filp)
{ {
struct xgi_mem_block *used_block = NULL, *block; struct xgi_mem_block *used_block = NULL, *block;
struct xgi_mem_block *prev, *next; struct xgi_mem_block *prev, *next;
@ -287,13 +287,16 @@ int xgi_fb_alloc_ioctl(struct drm_device * dev, void * data,
} }
int xgi_fb_free(struct xgi_info * info, unsigned long offset, int xgi_free(struct xgi_info * info, unsigned long index,
struct drm_file * filp) struct drm_file * filp)
{ {
int err = 0; int err = 0;
const unsigned heap = index & 0x03;
mutex_lock(&info->dev->struct_mutex); mutex_lock(&info->dev->struct_mutex);
err = xgi_mem_free(&info->fb_heap, offset, filp); err = xgi_mem_free((heap == XGI_MEMLOC_NON_LOCAL)
? &info->pcie_heap : &info->fb_heap,
(index & ~0x03), filp);
mutex_unlock(&info->dev->struct_mutex); mutex_unlock(&info->dev->struct_mutex);
return err; return err;
@ -305,7 +308,7 @@ int xgi_fb_free_ioctl(struct drm_device * dev, void * data,
{ {
struct xgi_info *info = dev->dev_private; struct xgi_info *info = dev->dev_private;
return xgi_fb_free(info, *(u32 *) data, filp); return xgi_free(info, XGI_MEMLOC_LOCAL | *(u32 *) data, filp);
} }

View File

@ -152,29 +152,12 @@ int xgi_pcie_alloc_ioctl(struct drm_device * dev, void * data,
} }
int xgi_pcie_free(struct xgi_info * info, unsigned long offset,
struct drm_file * filp)
{
int err;
mutex_lock(&info->dev->struct_mutex);
err = xgi_mem_free(&info->pcie_heap, offset, filp);
mutex_unlock(&info->dev->struct_mutex);
if (err) {
DRM_ERROR("xgi_pcie_free() failed at base 0x%lx\n", offset);
}
return err;
}
int xgi_pcie_free_ioctl(struct drm_device * dev, void * data, int xgi_pcie_free_ioctl(struct drm_device * dev, void * data,
struct drm_file * filp) struct drm_file * filp)
{ {
struct xgi_info *info = dev->dev_private; struct xgi_info *info = dev->dev_private;
return xgi_pcie_free(info, *(u32 *) data, filp); return xgi_free(info, XGI_MEMLOC_NON_LOCAL | *(u32 *) data, filp);
} }