summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux-core/drmP.h6
-rw-r--r--linux-core/drm_agpsupport.c28
-rw-r--r--linux-core/drm_fence.c1
-rw-r--r--linux-core/drm_ttm.h1
-rw-r--r--linux-core/i915_buffer.c4
5 files changed, 24 insertions, 16 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index c8297228..88f4c2cc 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -1258,8 +1258,10 @@ extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size
extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
-extern drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev);
-extern drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev);
+extern drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev,
+ drm_ttm_backend_t *backend);
+extern drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev,
+ drm_ttm_backend_t *backend);
/* Stub support (drm_stub.h) */
extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c
index 60ebc567..22987b07 100644
--- a/linux-core/drm_agpsupport.c
+++ b/linux-core/drm_agpsupport.c
@@ -625,9 +625,7 @@ static void drm_agp_clear_ttm(drm_ttm_backend_t *backend) {
DRM_DEBUG("drm_agp_clear_ttm\n");
if (mem) {
- if (mem->is_bound) {
- drm_agp_unbind_memory(mem);
- }
+ backend->unbind(backend);
agp_free_memory(mem);
}
@@ -639,25 +637,28 @@ static void drm_agp_destroy_ttm(drm_ttm_backend_t *backend) {
drm_agp_ttm_priv *agp_priv;
if (backend) {
- DRM_DEBUG("drm_agp_destroy_ttm\n");
- agp_priv = (drm_agp_ttm_priv *) backend->private;
+ DRM_DEBUG("drm_agp_destroy_ttm\n");
+ agp_priv = (drm_agp_ttm_priv *) backend->private;
if (agp_priv) {
if (agp_priv->mem) {
- drm_agp_clear_ttm(backend);
+ backend->clear(backend);
}
drm_free(agp_priv, sizeof(*agp_priv), DRM_MEM_MAPPINGS);
}
- drm_free(backend, sizeof(*backend), DRM_MEM_MAPPINGS);
+ if (backend->needs_free)
+ drm_free(backend, sizeof(*backend), DRM_MEM_MAPPINGS);
}
}
-drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev) {
+drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev,
+ drm_ttm_backend_t *backend) {
drm_ttm_backend_t *agp_be;
drm_agp_ttm_priv *agp_priv;
- agp_be = drm_calloc(1, sizeof(*agp_be), DRM_MEM_MAPPINGS);
+ agp_be = (backend != NULL) ? backend:
+ drm_calloc(1, sizeof(*agp_be), DRM_MEM_MAPPINGS);
if (!agp_be)
return NULL;
@@ -681,16 +682,20 @@ drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev) {
agp_be->bind = drm_agp_bind_ttm;
agp_be->unbind = drm_agp_unbind_ttm;
agp_be->destroy = drm_agp_destroy_ttm;
+ agp_be->needs_free = (backend == NULL);
return agp_be;
}
EXPORT_SYMBOL(drm_agp_init_ttm_uncached);
-drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev) {
+drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev,
+ drm_ttm_backend_t *backend) {
drm_ttm_backend_t *agp_be;
drm_agp_ttm_priv *agp_priv;
- agp_be = drm_calloc(1, sizeof(*agp_be), DRM_MEM_MAPPINGS);
+
+ agp_be = (backend != NULL) ? backend:
+ drm_calloc(1, sizeof(*agp_be), DRM_MEM_MAPPINGS);
if (!agp_be)
return NULL;
@@ -714,6 +719,7 @@ drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev) {
agp_be->bind = drm_agp_bind_ttm;
agp_be->unbind = drm_agp_unbind_ttm;
agp_be->destroy = drm_agp_destroy_ttm;
+ agp_be->needs_free = (backend == NULL);
return agp_be;
}
EXPORT_SYMBOL(drm_agp_init_ttm_cached);
diff --git a/linux-core/drm_fence.c b/linux-core/drm_fence.c
index ca6c8576..3e20f129 100644
--- a/linux-core/drm_fence.c
+++ b/linux-core/drm_fence.c
@@ -438,7 +438,6 @@ int drm_fence_object_create(drm_device_t * dev, uint32_t type,
drm_fence_object_t *fence;
int ret;
drm_fence_manager_t *fm = &dev->fm;
- unsigned long fl;
fence = kmem_cache_alloc(drm_cache.fence_object, GFP_KERNEL);
if (!fence)
diff --git a/linux-core/drm_ttm.h b/linux-core/drm_ttm.h
index d647578c..d65b17de 100644
--- a/linux-core/drm_ttm.h
+++ b/linux-core/drm_ttm.h
@@ -47,6 +47,7 @@
typedef struct drm_ttm_backend {
unsigned long aperture_base;
void *private;
+ int needs_free;
int (*needs_cache_adjust) (struct drm_ttm_backend * backend);
int (*populate) (struct drm_ttm_backend * backend,
unsigned long num_pages, struct page ** pages);
diff --git a/linux-core/i915_buffer.c b/linux-core/i915_buffer.c
index 9e8ae4a9..2d76f075 100644
--- a/linux-core/i915_buffer.c
+++ b/linux-core/i915_buffer.c
@@ -36,9 +36,9 @@
drm_ttm_backend_t *i915_create_ttm_backend_entry(drm_device_t *dev, int cached)
{
if (cached)
- return drm_agp_init_ttm_cached(dev);
+ return drm_agp_init_ttm_cached(dev, NULL);
else
- return drm_agp_init_ttm_uncached(dev);
+ return drm_agp_init_ttm_uncached(dev, NULL);
}
int i915_fence_types(uint32_t buffer_flags, uint32_t *class, uint32_t *type)