diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2011-10-25 17:19:27 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2011-12-21 18:33:23 -0500 |
commit | 7a6e0daaf4058d1b7dd515bc470ec904454a798c (patch) | |
tree | 4646ba40836b290dafd47055d6ed485fd6c7bdc7 | |
parent | be2fb9da32cb88a1311350de3d1db8f9e461ae9f (diff) |
drm: kill drm_sman
No longer used.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/Makefile | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_sman.c | 211 | ||||
-rw-r--r-- | include/drm/drm_sman.h | 151 |
3 files changed, 1 insertions, 363 deletions
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 6307486b1637..0cde1b80fdb1 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile | |||
@@ -9,7 +9,7 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ | |||
9 | drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \ | 9 | drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \ |
10 | drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ | 10 | drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ |
11 | drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \ | 11 | drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \ |
12 | drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \ | 12 | drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \ |
13 | drm_crtc.o drm_modes.o drm_edid.o \ | 13 | drm_crtc.o drm_modes.o drm_edid.o \ |
14 | drm_info.o drm_debugfs.o drm_encoder_slave.o \ | 14 | drm_info.o drm_debugfs.o drm_encoder_slave.o \ |
15 | drm_trace_points.o drm_global.o drm_usb.o | 15 | drm_trace_points.o drm_global.o drm_usb.o |
diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c deleted file mode 100644 index a8ff350e50b8..000000000000 --- a/drivers/gpu/drm/drm_sman.c +++ /dev/null | |||
@@ -1,211 +0,0 @@ | |||
1 | /************************************************************************** | ||
2 | * | ||
3 | * Copyright 2006 Tungsten Graphics, Inc., Bismarck., ND., USA. | ||
4 | * All Rights Reserved. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | * copy of this software and associated documentation files (the | ||
8 | * "Software"), to deal in the Software without restriction, including | ||
9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
10 | * distribute, sub license, and/or sell copies of the Software, and to | ||
11 | * permit persons to whom the Software is furnished to do so, subject to | ||
12 | * the following conditions: | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, | ||
18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
20 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | * The above copyright notice and this permission notice (including the | ||
23 | * next paragraph) shall be included in all copies or substantial portions | ||
24 | * of the Software. | ||
25 | * | ||
26 | * | ||
27 | **************************************************************************/ | ||
28 | /* | ||
29 | * Simple memory manager interface that keeps track on allocate regions on a | ||
30 | * per "owner" basis. All regions associated with an "owner" can be released | ||
31 | * with a simple call. Typically if the "owner" exists. The owner is any | ||
32 | * "unsigned long" identifier. Can typically be a pointer to a file private | ||
33 | * struct or a context identifier. | ||
34 | * | ||
35 | * Authors: | ||
36 | * Thomas Hellström <thomas-at-tungstengraphics-dot-com> | ||
37 | */ | ||
38 | |||
39 | #include <linux/export.h> | ||
40 | #include "drm_sman.h" | ||
41 | |||
42 | struct drm_owner_item { | ||
43 | struct drm_hash_item owner_hash; | ||
44 | struct list_head sman_list; | ||
45 | struct list_head mem_blocks; | ||
46 | }; | ||
47 | |||
48 | void drm_sman_takedown(struct drm_sman * sman) | ||
49 | { | ||
50 | kfree(sman->mm); | ||
51 | } | ||
52 | |||
53 | EXPORT_SYMBOL(drm_sman_takedown); | ||
54 | |||
55 | int | ||
56 | drm_sman_init(struct drm_sman * sman, unsigned int num_managers, | ||
57 | unsigned int user_order, unsigned int owner_order) | ||
58 | { | ||
59 | int ret = 0; | ||
60 | |||
61 | sman->mm = kcalloc(num_managers, sizeof(*sman->mm), GFP_KERNEL); | ||
62 | if (!sman->mm) { | ||
63 | ret = -ENOMEM; | ||
64 | return ret; | ||
65 | } | ||
66 | sman->num_managers = num_managers; | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | EXPORT_SYMBOL(drm_sman_init); | ||
72 | |||
73 | static void *drm_sman_mm_allocate(void *private, unsigned long size, | ||
74 | unsigned alignment) | ||
75 | { | ||
76 | struct drm_mm *mm = (struct drm_mm *) private; | ||
77 | struct drm_mm_node *tmp; | ||
78 | |||
79 | tmp = drm_mm_search_free(mm, size, alignment, 1); | ||
80 | if (!tmp) { | ||
81 | return NULL; | ||
82 | } | ||
83 | tmp = drm_mm_get_block(tmp, size, alignment); | ||
84 | return tmp; | ||
85 | } | ||
86 | |||
87 | static void drm_sman_mm_free(void *private, void *ref) | ||
88 | { | ||
89 | struct drm_mm_node *node = (struct drm_mm_node *) ref; | ||
90 | |||
91 | drm_mm_put_block(node); | ||
92 | } | ||
93 | |||
94 | static void drm_sman_mm_destroy(void *private) | ||
95 | { | ||
96 | struct drm_mm *mm = (struct drm_mm *) private; | ||
97 | drm_mm_takedown(mm); | ||
98 | kfree(mm); | ||
99 | } | ||
100 | |||
101 | static unsigned long drm_sman_mm_offset(void *private, void *ref) | ||
102 | { | ||
103 | struct drm_mm_node *node = (struct drm_mm_node *) ref; | ||
104 | return node->start; | ||
105 | } | ||
106 | |||
107 | int | ||
108 | drm_sman_set_range(struct drm_sman * sman, unsigned int manager, | ||
109 | unsigned long start, unsigned long size) | ||
110 | { | ||
111 | struct drm_sman_mm *sman_mm; | ||
112 | struct drm_mm *mm; | ||
113 | int ret; | ||
114 | |||
115 | BUG_ON(manager >= sman->num_managers); | ||
116 | |||
117 | sman_mm = &sman->mm[manager]; | ||
118 | mm = kzalloc(sizeof(*mm), GFP_KERNEL); | ||
119 | if (!mm) { | ||
120 | return -ENOMEM; | ||
121 | } | ||
122 | sman_mm->private = mm; | ||
123 | ret = drm_mm_init(mm, start, size); | ||
124 | |||
125 | if (ret) { | ||
126 | kfree(mm); | ||
127 | return ret; | ||
128 | } | ||
129 | |||
130 | sman_mm->allocate = drm_sman_mm_allocate; | ||
131 | sman_mm->free = drm_sman_mm_free; | ||
132 | sman_mm->destroy = drm_sman_mm_destroy; | ||
133 | sman_mm->offset = drm_sman_mm_offset; | ||
134 | |||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | EXPORT_SYMBOL(drm_sman_set_range); | ||
139 | |||
140 | int | ||
141 | drm_sman_set_manager(struct drm_sman * sman, unsigned int manager, | ||
142 | struct drm_sman_mm * allocator) | ||
143 | { | ||
144 | BUG_ON(manager >= sman->num_managers); | ||
145 | sman->mm[manager] = *allocator; | ||
146 | |||
147 | return 0; | ||
148 | } | ||
149 | EXPORT_SYMBOL(drm_sman_set_manager); | ||
150 | |||
151 | struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int manager, | ||
152 | unsigned long size, unsigned alignment, | ||
153 | unsigned long owner) | ||
154 | { | ||
155 | void *tmp; | ||
156 | struct drm_sman_mm *sman_mm; | ||
157 | struct drm_memblock_item *memblock; | ||
158 | |||
159 | BUG_ON(manager >= sman->num_managers); | ||
160 | |||
161 | sman_mm = &sman->mm[manager]; | ||
162 | tmp = sman_mm->allocate(sman_mm->private, size, alignment); | ||
163 | |||
164 | if (!tmp) { | ||
165 | return NULL; | ||
166 | } | ||
167 | |||
168 | memblock = kzalloc(sizeof(*memblock), GFP_KERNEL); | ||
169 | |||
170 | if (!memblock) | ||
171 | goto out; | ||
172 | |||
173 | memblock->mm_info = tmp; | ||
174 | memblock->mm = sman_mm; | ||
175 | memblock->sman = sman; | ||
176 | |||
177 | return memblock; | ||
178 | |||
179 | out: | ||
180 | sman_mm->free(sman_mm->private, tmp); | ||
181 | |||
182 | return NULL; | ||
183 | } | ||
184 | |||
185 | EXPORT_SYMBOL(drm_sman_alloc); | ||
186 | |||
187 | void drm_sman_free(struct drm_memblock_item *item) | ||
188 | { | ||
189 | list_del(&item->owner_list); | ||
190 | item->mm->free(item->mm->private, item->mm_info); | ||
191 | kfree(item); | ||
192 | } | ||
193 | EXPORT_SYMBOL(drm_sman_free); | ||
194 | |||
195 | void drm_sman_cleanup(struct drm_sman *sman) | ||
196 | { | ||
197 | unsigned int i; | ||
198 | struct drm_sman_mm *sman_mm; | ||
199 | |||
200 | if (sman->mm) { | ||
201 | for (i = 0; i < sman->num_managers; ++i) { | ||
202 | sman_mm = &sman->mm[i]; | ||
203 | if (sman_mm->private) { | ||
204 | sman_mm->destroy(sman_mm->private); | ||
205 | sman_mm->private = NULL; | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | |||
211 | EXPORT_SYMBOL(drm_sman_cleanup); | ||
diff --git a/include/drm/drm_sman.h b/include/drm/drm_sman.h deleted file mode 100644 index 031e52189295..000000000000 --- a/include/drm/drm_sman.h +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
1 | /************************************************************************** | ||
2 | * | ||
3 | * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA. | ||
4 | * All Rights Reserved. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | * copy of this software and associated documentation files (the | ||
8 | * "Software"), to deal in the Software without restriction, including | ||
9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
10 | * distribute, sub license, and/or sell copies of the Software, and to | ||
11 | * permit persons to whom the Software is furnished to do so, subject to | ||
12 | * the following conditions: | ||
13 | * | ||
14 | * The above copyright notice and this permission notice (including the | ||
15 | * next paragraph) shall be included in all copies or substantial portions | ||
16 | * of the Software. | ||
17 | * | ||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | ||
21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, | ||
22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
25 | * | ||
26 | * | ||
27 | **************************************************************************/ | ||
28 | /* | ||
29 | * Simple memory MANager interface that keeps track on allocate regions on a | ||
30 | * per "owner" basis. All regions associated with an "owner" can be released | ||
31 | * with a simple call. Typically if the "owner" exists. The owner is any | ||
32 | * "unsigned long" identifier. Can typically be a pointer to a file private | ||
33 | * struct or a context identifier. | ||
34 | * | ||
35 | * Authors: | ||
36 | * Thomas Hellström <thomas-at-tungstengraphics-dot-com> | ||
37 | */ | ||
38 | |||
39 | #ifndef DRM_SMAN_H | ||
40 | #define DRM_SMAN_H | ||
41 | |||
42 | #include "drmP.h" | ||
43 | #include "drm_hashtab.h" | ||
44 | |||
45 | /* | ||
46 | * A class that is an abstration of a simple memory allocator. | ||
47 | * The sman implementation provides a default such allocator | ||
48 | * using the drm_mm.c implementation. But the user can replace it. | ||
49 | * See the SiS implementation, which may use the SiS FB kernel module | ||
50 | * for memory management. | ||
51 | */ | ||
52 | |||
53 | struct drm_sman_mm { | ||
54 | /* private info. If allocated, needs to be destroyed by the destroy | ||
55 | function */ | ||
56 | void *private; | ||
57 | |||
58 | /* Allocate a memory block with given size and alignment. | ||
59 | Return an opaque reference to the memory block */ | ||
60 | |||
61 | void *(*allocate) (void *private, unsigned long size, | ||
62 | unsigned alignment); | ||
63 | |||
64 | /* Free a memory block. "ref" is the opaque reference that we got from | ||
65 | the "alloc" function */ | ||
66 | |||
67 | void (*free) (void *private, void *ref); | ||
68 | |||
69 | /* Free all resources associated with this allocator */ | ||
70 | |||
71 | void (*destroy) (void *private); | ||
72 | |||
73 | /* Return a memory offset from the opaque reference returned from the | ||
74 | "alloc" function */ | ||
75 | |||
76 | unsigned long (*offset) (void *private, void *ref); | ||
77 | }; | ||
78 | |||
79 | struct drm_memblock_item { | ||
80 | struct list_head owner_list; | ||
81 | struct drm_hash_item user_hash; | ||
82 | void *mm_info; | ||
83 | struct drm_sman_mm *mm; | ||
84 | struct drm_sman *sman; | ||
85 | }; | ||
86 | |||
87 | struct drm_sman { | ||
88 | struct drm_sman_mm *mm; | ||
89 | int num_managers; | ||
90 | }; | ||
91 | |||
92 | /* | ||
93 | * Take down a memory manager. This function should only be called after a | ||
94 | * successful init and after a call to drm_sman_cleanup. | ||
95 | */ | ||
96 | |||
97 | extern void drm_sman_takedown(struct drm_sman * sman); | ||
98 | |||
99 | /* | ||
100 | * Allocate structures for a manager. | ||
101 | * num_managers are the number of memory pools to manage. (VRAM, AGP, ....) | ||
102 | * user_order is the log2 of the number of buckets in the user hash table. | ||
103 | * set this to approximately log2 of the max number of memory regions | ||
104 | * that will be allocated for _all_ pools together. | ||
105 | * owner_order is the log2 of the number of buckets in the owner hash table. | ||
106 | * set this to approximately log2 of | ||
107 | * the number of client file connections that will | ||
108 | * be using the manager. | ||
109 | * | ||
110 | */ | ||
111 | |||
112 | extern int drm_sman_init(struct drm_sman * sman, unsigned int num_managers, | ||
113 | unsigned int user_order, unsigned int owner_order); | ||
114 | |||
115 | /* | ||
116 | * Initialize a drm_mm.c allocator. Should be called only once for each | ||
117 | * manager unless a customized allogator is used. | ||
118 | */ | ||
119 | |||
120 | extern int drm_sman_set_range(struct drm_sman * sman, unsigned int manager, | ||
121 | unsigned long start, unsigned long size); | ||
122 | |||
123 | /* | ||
124 | * Initialize a customized allocator for one of the managers. | ||
125 | * (See the SiS module). The object pointed to by "allocator" is copied, | ||
126 | * so it can be destroyed after this call. | ||
127 | */ | ||
128 | |||
129 | extern int drm_sman_set_manager(struct drm_sman * sman, unsigned int mananger, | ||
130 | struct drm_sman_mm * allocator); | ||
131 | |||
132 | /* | ||
133 | * Allocate a memory block. Aligment is not implemented yet. | ||
134 | */ | ||
135 | |||
136 | extern struct drm_memblock_item *drm_sman_alloc(struct drm_sman * sman, | ||
137 | unsigned int manager, | ||
138 | unsigned long size, | ||
139 | unsigned alignment, | ||
140 | unsigned long owner); | ||
141 | |||
142 | extern void drm_sman_free(struct drm_memblock_item *item); | ||
143 | |||
144 | /* | ||
145 | * Frees all stale memory blocks associated with the memory manager. | ||
146 | * See idling above. | ||
147 | */ | ||
148 | |||
149 | extern void drm_sman_cleanup(struct drm_sman * sman); | ||
150 | |||
151 | #endif | ||