[PATCH 02/23] drm/via: track obj->drm_fd relations in the driver
James Simmons
jsimmons at infradead.org
Wed Dec 7 08:21:10 PST 2011
> Exactly like the previous patch for sis.
>
> Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
Acked-by: James Simmons <jsimmons at infradead.org>
Same goes for PATCH 01 which I'm missing in my inbox.
> ---
> drivers/gpu/drm/via/via_drv.c | 25 +++++++++++++++++++++++++
> drivers/gpu/drm/via/via_mm.c | 22 ++++++++++++++--------
> include/drm/via_drm.h | 4 ++++
> 3 files changed, 43 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
> index 920a552..472adcf 100644
> --- a/drivers/gpu/drm/via/via_drv.c
> +++ b/drivers/gpu/drm/via/via_drv.c
> @@ -28,6 +28,29 @@
>
> #include "drm_pciids.h"
>
> +static int via_driver_open(struct drm_device *dev, struct drm_file *file)
> +{
> + struct via_file_private *file_priv;
> +
> + DRM_DEBUG_DRIVER("\n");
> + file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
> + if (!file_priv)
> + return -ENOMEM;
> +
> + file->driver_priv = file_priv;
> +
> + INIT_LIST_HEAD(&file_priv->obj_list);
> +
> + return 0;
> +}
> +
> +void via_driver_postclose(struct drm_device *dev, struct drm_file *file)
> +{
> + struct via_file_private *file_priv = file->driver_priv;
> +
> + kfree(file_priv);
> +}
> +
> static struct pci_device_id pciidlist[] = {
> viadrv_PCI_IDS
> };
> @@ -38,6 +61,8 @@ static struct drm_driver driver = {
> DRIVER_IRQ_SHARED,
> .load = via_driver_load,
> .unload = via_driver_unload,
> + .open = via_driver_open,
> + .postclose = via_driver_postclose,
> .context_dtor = via_final_context,
> .get_vblank_counter = via_get_vblank_counter,
> .enable_vblank = via_enable_vblank,
> diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
> index 6cc2dad..19bb77c 100644
> --- a/drivers/gpu/drm/via/via_mm.c
> +++ b/drivers/gpu/drm/via/via_mm.c
> @@ -115,12 +115,13 @@ void via_lastclose(struct drm_device *dev)
> }
>
> int via_mem_alloc(struct drm_device *dev, void *data,
> - struct drm_file *file_priv)
> + struct drm_file *file)
> {
> drm_via_mem_t *mem = data;
> int retval = 0;
> struct drm_memblock_item *item;
> drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
> + struct via_file_private *file_priv = file->driver_priv;
> unsigned long tmpSize;
>
> if (mem->type > VIA_MEM_AGP) {
> @@ -137,10 +138,10 @@ int via_mem_alloc(struct drm_device *dev, void *data,
> }
>
> tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
> - item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0,
> - (unsigned long)file_priv);
> - mutex_unlock(&dev->struct_mutex);
> + item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0, 0);
> +
> if (item) {
> + list_move(&item->owner_list, &file_priv->obj_list);
> mem->offset = ((mem->type == VIA_MEM_VIDEO) ?
> dev_priv->vram_offset : dev_priv->agp_offset) +
> (item->mm->
> @@ -153,6 +154,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,
> DRM_DEBUG("Video memory allocation failed\n");
> retval = -ENOMEM;
> }
> + mutex_unlock(&dev->struct_mutex);
>
> return retval;
> }
> @@ -173,12 +175,13 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
>
>
> void via_reclaim_buffers_locked(struct drm_device *dev,
> - struct drm_file *file_priv)
> + struct drm_file *file)
> {
> - drm_via_private_t *dev_priv = dev->dev_private;
> + struct via_file_private *file_priv = file->driver_priv;
> + struct drm_memblock_item *entry, *next;
>
> mutex_lock(&dev->struct_mutex);
> - if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)file_priv)) {
> + if (list_empty(&file_priv->obj_list)) {
> mutex_unlock(&dev->struct_mutex);
> return;
> }
> @@ -186,7 +189,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
> if (dev->driver->dma_quiescent)
> dev->driver->dma_quiescent(dev);
>
> - drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)file_priv);
> + list_for_each_entry_safe(entry, next, &file_priv->obj_list,
> + owner_list) {
> + drm_sman_free(entry);
> + }
> mutex_unlock(&dev->struct_mutex);
> return;
> }
> diff --git a/include/drm/via_drm.h b/include/drm/via_drm.h
> index fd11a5b..79b3b6e 100644
> --- a/include/drm/via_drm.h
> +++ b/include/drm/via_drm.h
> @@ -274,4 +274,8 @@ typedef struct drm_via_dmablit {
> drm_via_blitsync_t sync;
> } drm_via_dmablit_t;
>
> +struct via_file_private {
> + struct list_head obj_list;
> +};
> +
> #endif /* _VIA_DRM_H_ */
> --
> 1.7.7.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
More information about the dri-devel
mailing list