aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2011-10-25 10:32:45 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2011-12-21 18:33:19 -0500
commitc828e20456301b0f5192a1f75e8bf8a6afd15551 (patch)
treeac305d3618dafc1f8c3d9f18011d91badee9aabe
parentfdc0b8a63c1124bb025a2846d41531a123845740 (diff)
drm/via: track obj->drm_fd relations in the driver
Exactly like the previous patch for sis. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/via/via_drv.c25
-rw-r--r--drivers/gpu/drm/via/via_mm.c22
-rw-r--r--include/drm/via_drm.h4
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 fb43fd368ce1..02661f35f7a0 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -30,6 +30,29 @@
30 30
31#include "drm_pciids.h" 31#include "drm_pciids.h"
32 32
33static int via_driver_open(struct drm_device *dev, struct drm_file *file)
34{
35 struct via_file_private *file_priv;
36
37 DRM_DEBUG_DRIVER("\n");
38 file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
39 if (!file_priv)
40 return -ENOMEM;
41
42 file->driver_priv = file_priv;
43
44 INIT_LIST_HEAD(&file_priv->obj_list);
45
46 return 0;
47}
48
49void via_driver_postclose(struct drm_device *dev, struct drm_file *file)
50{
51 struct via_file_private *file_priv = file->driver_priv;
52
53 kfree(file_priv);
54}
55
33static struct pci_device_id pciidlist[] = { 56static struct pci_device_id pciidlist[] = {
34 viadrv_PCI_IDS 57 viadrv_PCI_IDS
35}; 58};
@@ -51,6 +74,8 @@ static struct drm_driver driver = {
51 DRIVER_IRQ_SHARED, 74 DRIVER_IRQ_SHARED,
52 .load = via_driver_load, 75 .load = via_driver_load,
53 .unload = via_driver_unload, 76 .unload = via_driver_unload,
77 .open = via_driver_open,
78 .postclose = via_driver_postclose,
54 .context_dtor = via_final_context, 79 .context_dtor = via_final_context,
55 .get_vblank_counter = via_get_vblank_counter, 80 .get_vblank_counter = via_get_vblank_counter,
56 .enable_vblank = via_enable_vblank, 81 .enable_vblank = via_enable_vblank,
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index 6cc2dadae3ef..19bb77cdeb46 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)
115} 115}
116 116
117int via_mem_alloc(struct drm_device *dev, void *data, 117int via_mem_alloc(struct drm_device *dev, void *data,
118 struct drm_file *file_priv) 118 struct drm_file *file)
119{ 119{
120 drm_via_mem_t *mem = data; 120 drm_via_mem_t *mem = data;
121 int retval = 0; 121 int retval = 0;
122 struct drm_memblock_item *item; 122 struct drm_memblock_item *item;
123 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 123 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
124 struct via_file_private *file_priv = file->driver_priv;
124 unsigned long tmpSize; 125 unsigned long tmpSize;
125 126
126 if (mem->type > VIA_MEM_AGP) { 127 if (mem->type > VIA_MEM_AGP) {
@@ -137,10 +138,10 @@ int via_mem_alloc(struct drm_device *dev, void *data,
137 } 138 }
138 139
139 tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT; 140 tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
140 item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0, 141 item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0, 0);
141 (unsigned long)file_priv); 142
142 mutex_unlock(&dev->struct_mutex);
143 if (item) { 143 if (item) {
144 list_move(&item->owner_list, &file_priv->obj_list);
144 mem->offset = ((mem->type == VIA_MEM_VIDEO) ? 145 mem->offset = ((mem->type == VIA_MEM_VIDEO) ?
145 dev_priv->vram_offset : dev_priv->agp_offset) + 146 dev_priv->vram_offset : dev_priv->agp_offset) +
146 (item->mm-> 147 (item->mm->
@@ -153,6 +154,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,
153 DRM_DEBUG("Video memory allocation failed\n"); 154 DRM_DEBUG("Video memory allocation failed\n");
154 retval = -ENOMEM; 155 retval = -ENOMEM;
155 } 156 }
157 mutex_unlock(&dev->struct_mutex);
156 158
157 return retval; 159 return retval;
158} 160}
@@ -173,12 +175,13 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
173 175
174 176
175void via_reclaim_buffers_locked(struct drm_device *dev, 177void via_reclaim_buffers_locked(struct drm_device *dev,
176 struct drm_file *file_priv) 178 struct drm_file *file)
177{ 179{
178 drm_via_private_t *dev_priv = dev->dev_private; 180 struct via_file_private *file_priv = file->driver_priv;
181 struct drm_memblock_item *entry, *next;
179 182
180 mutex_lock(&dev->struct_mutex); 183 mutex_lock(&dev->struct_mutex);
181 if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)file_priv)) { 184 if (list_empty(&file_priv->obj_list)) {
182 mutex_unlock(&dev->struct_mutex); 185 mutex_unlock(&dev->struct_mutex);
183 return; 186 return;
184 } 187 }
@@ -186,7 +189,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
186 if (dev->driver->dma_quiescent) 189 if (dev->driver->dma_quiescent)
187 dev->driver->dma_quiescent(dev); 190 dev->driver->dma_quiescent(dev);
188 191
189 drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)file_priv); 192 list_for_each_entry_safe(entry, next, &file_priv->obj_list,
193 owner_list) {
194 drm_sman_free(entry);
195 }
190 mutex_unlock(&dev->struct_mutex); 196 mutex_unlock(&dev->struct_mutex);
191 return; 197 return;
192} 198}
diff --git a/include/drm/via_drm.h b/include/drm/via_drm.h
index fd11a5bd892d..79b3b6e0f6b3 100644
--- a/include/drm/via_drm.h
+++ b/include/drm/via_drm.h
@@ -274,4 +274,8 @@ typedef struct drm_via_dmablit {
274 drm_via_blitsync_t sync; 274 drm_via_blitsync_t sync;
275} drm_via_dmablit_t; 275} drm_via_dmablit_t;
276 276
277struct via_file_private {
278 struct list_head obj_list;
279};
280
277#endif /* _VIA_DRM_H_ */ 281#endif /* _VIA_DRM_H_ */