diff options
Diffstat (limited to 'drivers/gpu/drm/via')
-rw-r--r-- | drivers/gpu/drm/via/via_drv.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/via/via_map.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/via/via_mm.c | 72 |
3 files changed, 43 insertions, 41 deletions
diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h index 108ea71f399d..88edacc93006 100644 --- a/drivers/gpu/drm/via/via_drv.h +++ b/drivers/gpu/drm/via/via_drv.h | |||
@@ -24,7 +24,7 @@ | |||
24 | #ifndef _VIA_DRV_H_ | 24 | #ifndef _VIA_DRV_H_ |
25 | #define _VIA_DRV_H_ | 25 | #define _VIA_DRV_H_ |
26 | 26 | ||
27 | #include "drm_sman.h" | 27 | #include "drm_mm.h" |
28 | #define DRIVER_AUTHOR "Various" | 28 | #define DRIVER_AUTHOR "Various" |
29 | 29 | ||
30 | #define DRIVER_NAME "via" | 30 | #define DRIVER_NAME "via" |
@@ -88,9 +88,10 @@ typedef struct drm_via_private { | |||
88 | uint32_t irq_pending_mask; | 88 | uint32_t irq_pending_mask; |
89 | int *irq_map; | 89 | int *irq_map; |
90 | unsigned int idle_fault; | 90 | unsigned int idle_fault; |
91 | struct drm_sman sman; | ||
92 | int vram_initialized; | 91 | int vram_initialized; |
92 | struct drm_mm vram_mm; | ||
93 | int agp_initialized; | 93 | int agp_initialized; |
94 | struct drm_mm agp_mm; | ||
94 | /** Mapping of userspace keys to mm objects */ | 95 | /** Mapping of userspace keys to mm objects */ |
95 | struct idr object_idr; | 96 | struct idr object_idr; |
96 | unsigned long vram_offset; | 97 | unsigned long vram_offset; |
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c index fa5afbcf7e28..a2ab34365151 100644 --- a/drivers/gpu/drm/via/via_map.c +++ b/drivers/gpu/drm/via/via_map.c | |||
@@ -105,15 +105,9 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset) | |||
105 | dev_priv->chipset = chipset; | 105 | dev_priv->chipset = chipset; |
106 | 106 | ||
107 | idr_init(&dev->object_name_idr); | 107 | idr_init(&dev->object_name_idr); |
108 | ret = drm_sman_init(&dev_priv->sman, 2, 12, 8); | ||
109 | if (ret) { | ||
110 | kfree(dev_priv); | ||
111 | return ret; | ||
112 | } | ||
113 | 108 | ||
114 | ret = drm_vblank_init(dev, 1); | 109 | ret = drm_vblank_init(dev, 1); |
115 | if (ret) { | 110 | if (ret) { |
116 | drm_sman_takedown(&dev_priv->sman); | ||
117 | kfree(dev_priv); | 111 | kfree(dev_priv); |
118 | return ret; | 112 | return ret; |
119 | } | 113 | } |
@@ -125,7 +119,6 @@ int via_driver_unload(struct drm_device *dev) | |||
125 | { | 119 | { |
126 | drm_via_private_t *dev_priv = dev->dev_private; | 120 | drm_via_private_t *dev_priv = dev->dev_private; |
127 | 121 | ||
128 | drm_sman_takedown(&dev_priv->sman); | ||
129 | idr_remove_all(&dev_priv->object_idr); | 122 | idr_remove_all(&dev_priv->object_idr); |
130 | idr_destroy(&dev_priv->object_idr); | 123 | idr_destroy(&dev_priv->object_idr); |
131 | 124 | ||
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c index e6f2b6371b4e..bedb23d2ece0 100644 --- a/drivers/gpu/drm/via/via_mm.c +++ b/drivers/gpu/drm/via/via_mm.c | |||
@@ -28,26 +28,22 @@ | |||
28 | #include "drmP.h" | 28 | #include "drmP.h" |
29 | #include "via_drm.h" | 29 | #include "via_drm.h" |
30 | #include "via_drv.h" | 30 | #include "via_drv.h" |
31 | #include "drm_sman.h" | ||
32 | 31 | ||
33 | #define VIA_MM_ALIGN_SHIFT 4 | 32 | #define VIA_MM_ALIGN_SHIFT 4 |
34 | #define VIA_MM_ALIGN_MASK ((1 << VIA_MM_ALIGN_SHIFT) - 1) | 33 | #define VIA_MM_ALIGN_MASK ((1 << VIA_MM_ALIGN_SHIFT) - 1) |
35 | 34 | ||
35 | struct via_memblock { | ||
36 | struct drm_mm_node mm_node; | ||
37 | struct list_head owner_list; | ||
38 | }; | ||
39 | |||
36 | int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv) | 40 | int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
37 | { | 41 | { |
38 | drm_via_agp_t *agp = data; | 42 | drm_via_agp_t *agp = data; |
39 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 43 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
40 | int ret; | ||
41 | 44 | ||
42 | mutex_lock(&dev->struct_mutex); | 45 | mutex_lock(&dev->struct_mutex); |
43 | ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_AGP, 0, | 46 | drm_mm_init(&dev_priv->agp_mm, 0, agp->size >> VIA_MM_ALIGN_SHIFT); |
44 | agp->size >> VIA_MM_ALIGN_SHIFT); | ||
45 | |||
46 | if (ret) { | ||
47 | DRM_ERROR("AGP memory manager initialisation error\n"); | ||
48 | mutex_unlock(&dev->struct_mutex); | ||
49 | return ret; | ||
50 | } | ||
51 | 47 | ||
52 | dev_priv->agp_initialized = 1; | 48 | dev_priv->agp_initialized = 1; |
53 | dev_priv->agp_offset = agp->offset; | 49 | dev_priv->agp_offset = agp->offset; |
@@ -61,17 +57,9 @@ int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
61 | { | 57 | { |
62 | drm_via_fb_t *fb = data; | 58 | drm_via_fb_t *fb = data; |
63 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 59 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
64 | int ret; | ||
65 | 60 | ||
66 | mutex_lock(&dev->struct_mutex); | 61 | mutex_lock(&dev->struct_mutex); |
67 | ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_VIDEO, 0, | 62 | drm_mm_init(&dev_priv->vram_mm, 0, fb->size >> VIA_MM_ALIGN_SHIFT); |
68 | fb->size >> VIA_MM_ALIGN_SHIFT); | ||
69 | |||
70 | if (ret) { | ||
71 | DRM_ERROR("VRAM memory manager initialisation error\n"); | ||
72 | mutex_unlock(&dev->struct_mutex); | ||
73 | return ret; | ||
74 | } | ||
75 | 63 | ||
76 | dev_priv->vram_initialized = 1; | 64 | dev_priv->vram_initialized = 1; |
77 | dev_priv->vram_offset = fb->offset; | 65 | dev_priv->vram_offset = fb->offset; |
@@ -108,9 +96,14 @@ void via_lastclose(struct drm_device *dev) | |||
108 | return; | 96 | return; |
109 | 97 | ||
110 | mutex_lock(&dev->struct_mutex); | 98 | mutex_lock(&dev->struct_mutex); |
111 | drm_sman_cleanup(&dev_priv->sman); | 99 | if (dev_priv->vram_initialized) { |
112 | dev_priv->vram_initialized = 0; | 100 | drm_mm_takedown(&dev_priv->vram_mm); |
113 | dev_priv->agp_initialized = 0; | 101 | dev_priv->vram_initialized = 0; |
102 | } | ||
103 | if (dev_priv->agp_initialized) { | ||
104 | drm_mm_takedown(&dev_priv->agp_mm); | ||
105 | dev_priv->agp_initialized = 0; | ||
106 | } | ||
114 | mutex_unlock(&dev->struct_mutex); | 107 | mutex_unlock(&dev->struct_mutex); |
115 | } | 108 | } |
116 | 109 | ||
@@ -119,7 +112,7 @@ int via_mem_alloc(struct drm_device *dev, void *data, | |||
119 | { | 112 | { |
120 | drm_via_mem_t *mem = data; | 113 | drm_via_mem_t *mem = data; |
121 | int retval = 0, user_key; | 114 | int retval = 0, user_key; |
122 | struct drm_memblock_item *item; | 115 | struct via_memblock *item; |
123 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 116 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
124 | struct via_file_private *file_priv = file->driver_priv; | 117 | struct via_file_private *file_priv = file->driver_priv; |
125 | unsigned long tmpSize; | 118 | unsigned long tmpSize; |
@@ -137,13 +130,24 @@ int via_mem_alloc(struct drm_device *dev, void *data, | |||
137 | return -EINVAL; | 130 | return -EINVAL; |
138 | } | 131 | } |
139 | 132 | ||
140 | tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT; | 133 | item = kzalloc(sizeof(*item), GFP_KERNEL); |
141 | item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0, 0); | ||
142 | if (!item) { | 134 | if (!item) { |
143 | retval = -ENOMEM; | 135 | retval = -ENOMEM; |
144 | goto fail_alloc; | 136 | goto fail_alloc; |
145 | } | 137 | } |
146 | 138 | ||
139 | tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT; | ||
140 | if (mem->type == VIA_MEM_AGP) | ||
141 | retval = drm_mm_insert_node(&dev_priv->agp_mm, | ||
142 | &item->mm_node, | ||
143 | tmpSize, 0); | ||
144 | else | ||
145 | retval = drm_mm_insert_node(&dev_priv->vram_mm, | ||
146 | &item->mm_node, | ||
147 | tmpSize, 0); | ||
148 | if (retval) | ||
149 | goto fail_alloc; | ||
150 | |||
147 | again: | 151 | again: |
148 | if (idr_pre_get(&dev_priv->object_idr, GFP_KERNEL) == 0) { | 152 | if (idr_pre_get(&dev_priv->object_idr, GFP_KERNEL) == 0) { |
149 | retval = -ENOMEM; | 153 | retval = -ENOMEM; |
@@ -161,15 +165,15 @@ again: | |||
161 | 165 | ||
162 | mem->offset = ((mem->type == VIA_MEM_VIDEO) ? | 166 | mem->offset = ((mem->type == VIA_MEM_VIDEO) ? |
163 | dev_priv->vram_offset : dev_priv->agp_offset) + | 167 | dev_priv->vram_offset : dev_priv->agp_offset) + |
164 | (item->mm-> | 168 | ((item->mm_node.start) << VIA_MM_ALIGN_SHIFT); |
165 | offset(item->mm, item->mm_info) << VIA_MM_ALIGN_SHIFT); | ||
166 | mem->index = user_key; | 169 | mem->index = user_key; |
167 | 170 | ||
168 | return 0; | 171 | return 0; |
169 | 172 | ||
170 | fail_idr: | 173 | fail_idr: |
171 | drm_sman_free(item); | 174 | drm_mm_remove_node(&item->mm_node); |
172 | fail_alloc: | 175 | fail_alloc: |
176 | kfree(item); | ||
173 | mutex_unlock(&dev->struct_mutex); | 177 | mutex_unlock(&dev->struct_mutex); |
174 | 178 | ||
175 | mem->offset = 0; | 179 | mem->offset = 0; |
@@ -184,7 +188,7 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
184 | { | 188 | { |
185 | drm_via_private_t *dev_priv = dev->dev_private; | 189 | drm_via_private_t *dev_priv = dev->dev_private; |
186 | drm_via_mem_t *mem = data; | 190 | drm_via_mem_t *mem = data; |
187 | struct drm_memblock_item *obj; | 191 | struct via_memblock *obj; |
188 | int ret; | 192 | int ret; |
189 | 193 | ||
190 | mutex_lock(&dev->struct_mutex); | 194 | mutex_lock(&dev->struct_mutex); |
@@ -195,7 +199,9 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
195 | } | 199 | } |
196 | 200 | ||
197 | idr_remove(&dev_priv->object_idr, mem->index); | 201 | idr_remove(&dev_priv->object_idr, mem->index); |
198 | drm_sman_free(obj); | 202 | list_del(&obj->owner_list); |
203 | drm_mm_remove_node(&obj->mm_node); | ||
204 | kfree(obj); | ||
199 | mutex_unlock(&dev->struct_mutex); | 205 | mutex_unlock(&dev->struct_mutex); |
200 | 206 | ||
201 | DRM_DEBUG("free = 0x%lx\n", mem->index); | 207 | DRM_DEBUG("free = 0x%lx\n", mem->index); |
@@ -208,7 +214,7 @@ void via_reclaim_buffers_locked(struct drm_device *dev, | |||
208 | struct drm_file *file) | 214 | struct drm_file *file) |
209 | { | 215 | { |
210 | struct via_file_private *file_priv = file->driver_priv; | 216 | struct via_file_private *file_priv = file->driver_priv; |
211 | struct drm_memblock_item *entry, *next; | 217 | struct via_memblock *entry, *next; |
212 | 218 | ||
213 | mutex_lock(&dev->struct_mutex); | 219 | mutex_lock(&dev->struct_mutex); |
214 | if (list_empty(&file_priv->obj_list)) { | 220 | if (list_empty(&file_priv->obj_list)) { |
@@ -221,7 +227,9 @@ void via_reclaim_buffers_locked(struct drm_device *dev, | |||
221 | 227 | ||
222 | list_for_each_entry_safe(entry, next, &file_priv->obj_list, | 228 | list_for_each_entry_safe(entry, next, &file_priv->obj_list, |
223 | owner_list) { | 229 | owner_list) { |
224 | drm_sman_free(entry); | 230 | list_del(&entry->owner_list); |
231 | drm_mm_remove_node(&entry->mm_node); | ||
232 | kfree(entry); | ||
225 | } | 233 | } |
226 | mutex_unlock(&dev->struct_mutex); | 234 | mutex_unlock(&dev->struct_mutex); |
227 | return; | 235 | return; |