diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 052008a0..69338ea3 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -263,7 +263,7 @@ typedef struct drm_buf { void *dev_private; - + int dev_priv_size; #if DRM_DMA_HISTOGRAM cycles_t time_queued; /* Queued to kernel DMA queue */ diff --git a/linux/dma.c b/linux/dma.c index 53e7941b..d796e679 100644 --- a/linux/dma.c +++ b/linux/dma.c @@ -64,15 +64,24 @@ void drm_dma_takedown(drm_device_t *dev) dma->bufs[i].page_order, DRM_MEM_DMA); } - drm_free(dma->bufs[i].buflist, - dma->buf_count - * sizeof(*dma->bufs[0].buflist), - DRM_MEM_BUFS); drm_free(dma->bufs[i].seglist, - dma->buf_count + dma->bufs[i].seg_count * sizeof(*dma->bufs[0].seglist), DRM_MEM_SEGS); - drm_freelist_destroy(&dma->bufs[i].freelist); + } + if(dma->bufs[i].buf_count) { + for(j = 0; j < dma->bufs[i].buf_count; j++) { + if(dma->bufs[i].buflist[j].dev_private) { + drm_free(dma->bufs[i].buflist[j].dev_private, + dma->bufs[i].buflist[j].dev_priv_size, + DRM_MEM_BUFS); + } + } + drm_free(dma->bufs[i].buflist, + dma->bufs[i].buf_count * + sizeof(*dma->bufs[0].buflist), + DRM_MEM_BUFS); + drm_freelist_destroy(&dma->bufs[i].freelist); } } diff --git a/linux/drmP.h b/linux/drmP.h index 052008a0..69338ea3 100644 --- a/linux/drmP.h +++ b/linux/drmP.h @@ -263,7 +263,7 @@ typedef struct drm_buf { void *dev_private; - + int dev_priv_size; #if DRM_DMA_HISTOGRAM cycles_t time_queued; /* Queued to kernel DMA queue */ diff --git a/linux/mga_bufs.c b/linux/mga_bufs.c index e77f3389..1b779407 100644 --- a/linux/mga_bufs.c +++ b/linux/mga_bufs.c @@ -133,7 +133,7 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, buf->pid = 0; buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), DRM_MEM_BUFS); - + buf->dev_priv_size = sizeof(drm_mga_buf_priv_t); #if DRM_DMA_HISTOGRAM buf->time_queued = 0;