diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 14:14:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 14:14:52 -0400 |
commit | 59534f7298c5e28aaa64e6ed550e247f64ee72ae (patch) | |
tree | b9fef7756abf897d9e1b10950cdf10bf6dfe5cb7 /drivers/gpu/drm/drm_gem.c | |
parent | ac3ee84c604502240122c47b52f0542ec8774f15 (diff) | |
parent | b486787ee4797d6e42a9bd3a6f079385ad0f4472 (diff) |
Merge branch 'drm-for-2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-for-2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: (207 commits)
drm/radeon/kms/pm/r600: select the mid clock mode for single head low profile
drm/radeon: fix power supply kconfig interaction.
drm/radeon/kms: record object that have been list reserved
drm/radeon: AGP memory is only I/O if the aperture can be mapped by the CPU.
drm/radeon/kms: don't default display priority to high on rs4xx
drm/edid: fix typo in 1600x1200@75 mode
drm/nouveau: fix i2c-related init table handlers
drm/nouveau: support init table i2c device identifier 0x81
drm/nouveau: ensure we've parsed i2c table entry for INIT_*I2C* handlers
drm/nouveau: display error message for any failed init table opcode
drm/nouveau: fix init table handlers to return proper error codes
drm/nv50: support fractional feedback divider on newer chips
drm/nv50: fix monitor detection on certain chipsets
drm/nv50: store full dcb i2c entry from vbios
drm/nv50: fix suspend/resume with DP outputs
drm/nv50: output calculated crtc pll when debugging on
drm/nouveau: dump pll limits entries when debugging is on
drm/nouveau: bios parser fixes for eDP boards
drm/nouveau: fix a nouveau_bo dereference after it's been destroyed
drm/nv40: remove some completed ctxprog TODOs
...
Diffstat (limited to 'drivers/gpu/drm/drm_gem.c')
-rw-r--r-- | drivers/gpu/drm/drm_gem.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index aa89d4b0b4c4..33dad3fa6043 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c | |||
@@ -124,6 +124,31 @@ drm_gem_destroy(struct drm_device *dev) | |||
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Initialize an already allocate GEM object of the specified size with | ||
128 | * shmfs backing store. | ||
129 | */ | ||
130 | int drm_gem_object_init(struct drm_device *dev, | ||
131 | struct drm_gem_object *obj, size_t size) | ||
132 | { | ||
133 | BUG_ON((size & (PAGE_SIZE - 1)) != 0); | ||
134 | |||
135 | obj->dev = dev; | ||
136 | obj->filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); | ||
137 | if (IS_ERR(obj->filp)) | ||
138 | return -ENOMEM; | ||
139 | |||
140 | kref_init(&obj->refcount); | ||
141 | kref_init(&obj->handlecount); | ||
142 | obj->size = size; | ||
143 | |||
144 | atomic_inc(&dev->object_count); | ||
145 | atomic_add(obj->size, &dev->object_memory); | ||
146 | |||
147 | return 0; | ||
148 | } | ||
149 | EXPORT_SYMBOL(drm_gem_object_init); | ||
150 | |||
151 | /** | ||
127 | * Allocate a GEM object of the specified size with shmfs backing store | 152 | * Allocate a GEM object of the specified size with shmfs backing store |
128 | */ | 153 | */ |
129 | struct drm_gem_object * | 154 | struct drm_gem_object * |
@@ -131,28 +156,22 @@ drm_gem_object_alloc(struct drm_device *dev, size_t size) | |||
131 | { | 156 | { |
132 | struct drm_gem_object *obj; | 157 | struct drm_gem_object *obj; |
133 | 158 | ||
134 | BUG_ON((size & (PAGE_SIZE - 1)) != 0); | ||
135 | |||
136 | obj = kzalloc(sizeof(*obj), GFP_KERNEL); | 159 | obj = kzalloc(sizeof(*obj), GFP_KERNEL); |
137 | if (!obj) | 160 | if (!obj) |
138 | goto free; | 161 | goto free; |
139 | 162 | ||
140 | obj->dev = dev; | 163 | if (drm_gem_object_init(dev, obj, size) != 0) |
141 | obj->filp = shmem_file_setup("drm mm object", size, VM_NORESERVE); | ||
142 | if (IS_ERR(obj->filp)) | ||
143 | goto free; | 164 | goto free; |
144 | 165 | ||
145 | kref_init(&obj->refcount); | ||
146 | kref_init(&obj->handlecount); | ||
147 | obj->size = size; | ||
148 | if (dev->driver->gem_init_object != NULL && | 166 | if (dev->driver->gem_init_object != NULL && |
149 | dev->driver->gem_init_object(obj) != 0) { | 167 | dev->driver->gem_init_object(obj) != 0) { |
150 | goto fput; | 168 | goto fput; |
151 | } | 169 | } |
152 | atomic_inc(&dev->object_count); | ||
153 | atomic_add(obj->size, &dev->object_memory); | ||
154 | return obj; | 170 | return obj; |
155 | fput: | 171 | fput: |
172 | /* Object_init mangles the global counters - readjust them. */ | ||
173 | atomic_dec(&dev->object_count); | ||
174 | atomic_sub(obj->size, &dev->object_memory); | ||
156 | fput(obj->filp); | 175 | fput(obj->filp); |
157 | free: | 176 | free: |
158 | kfree(obj); | 177 | kfree(obj); |
@@ -403,15 +422,15 @@ drm_gem_release(struct drm_device *dev, struct drm_file *file_private) | |||
403 | idr_destroy(&file_private->object_idr); | 422 | idr_destroy(&file_private->object_idr); |
404 | } | 423 | } |
405 | 424 | ||
406 | static void | 425 | void |
407 | drm_gem_object_free_common(struct drm_gem_object *obj) | 426 | drm_gem_object_release(struct drm_gem_object *obj) |
408 | { | 427 | { |
409 | struct drm_device *dev = obj->dev; | 428 | struct drm_device *dev = obj->dev; |
410 | fput(obj->filp); | 429 | fput(obj->filp); |
411 | atomic_dec(&dev->object_count); | 430 | atomic_dec(&dev->object_count); |
412 | atomic_sub(obj->size, &dev->object_memory); | 431 | atomic_sub(obj->size, &dev->object_memory); |
413 | kfree(obj); | ||
414 | } | 432 | } |
433 | EXPORT_SYMBOL(drm_gem_object_release); | ||
415 | 434 | ||
416 | /** | 435 | /** |
417 | * Called after the last reference to the object has been lost. | 436 | * Called after the last reference to the object has been lost. |
@@ -429,8 +448,6 @@ drm_gem_object_free(struct kref *kref) | |||
429 | 448 | ||
430 | if (dev->driver->gem_free_object != NULL) | 449 | if (dev->driver->gem_free_object != NULL) |
431 | dev->driver->gem_free_object(obj); | 450 | dev->driver->gem_free_object(obj); |
432 | |||
433 | drm_gem_object_free_common(obj); | ||
434 | } | 451 | } |
435 | EXPORT_SYMBOL(drm_gem_object_free); | 452 | EXPORT_SYMBOL(drm_gem_object_free); |
436 | 453 | ||
@@ -453,8 +470,6 @@ drm_gem_object_free_unlocked(struct kref *kref) | |||
453 | dev->driver->gem_free_object(obj); | 470 | dev->driver->gem_free_object(obj); |
454 | mutex_unlock(&dev->struct_mutex); | 471 | mutex_unlock(&dev->struct_mutex); |
455 | } | 472 | } |
456 | |||
457 | drm_gem_object_free_common(obj); | ||
458 | } | 473 | } |
459 | EXPORT_SYMBOL(drm_gem_object_free_unlocked); | 474 | EXPORT_SYMBOL(drm_gem_object_free_unlocked); |
460 | 475 | ||