drm/radeon: implement unpin function, v2
authorMaarten Lankhorst <m.b.lankhorst@gmail.com>
Thu, 27 Jun 2013 11:38:18 +0000 (13:38 +0200)
committerDave Airlie <airlied@redhat.com>
Fri, 28 Jun 2013 01:55:11 +0000 (11:55 +1000)
Changes since v1:
- Fixup compiler warning in unpin function.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/radeon/radeon_prime.c

index 00cc52e601fe35f7710aa7393b796d6670eba982..e5419b3501708ead90d8f9a82e984e37adc60e6d 100644 (file)
@@ -128,6 +128,7 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
                                                        size_t size,
                                                        struct sg_table *sg);
 int radeon_gem_prime_pin(struct drm_gem_object *obj);
+void radeon_gem_prime_unpin(struct drm_gem_object *obj);
 void *radeon_gem_prime_vmap(struct drm_gem_object *obj);
 void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
 extern long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd,
@@ -427,6 +428,7 @@ static struct drm_driver kms_driver = {
        .gem_prime_export = drm_gem_prime_export,
        .gem_prime_import = drm_gem_prime_import,
        .gem_prime_pin = radeon_gem_prime_pin,
+       .gem_prime_unpin = radeon_gem_prime_unpin,
        .gem_prime_get_sg_table = radeon_gem_prime_get_sg_table,
        .gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
        .gem_prime_vmap = radeon_gem_prime_vmap,
index 4940af7e75e6dd180de3ebd6d80e70897ea325d5..65b9eabd5a2f08b28e864c18e05ce060802dffb6 100644 (file)
@@ -88,11 +88,19 @@ int radeon_gem_prime_pin(struct drm_gem_object *obj)
 
        /* pin buffer into GTT */
        ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL);
-       if (ret) {
-               radeon_bo_unreserve(bo);
-               return ret;
-       }
        radeon_bo_unreserve(bo);
+       return ret;
+}
+
+void radeon_gem_prime_unpin(struct drm_gem_object *obj)
+{
+       struct radeon_bo *bo = gem_to_radeon_bo(obj);
+       int ret = 0;
 
-       return 0;
+       ret = radeon_bo_reserve(bo, false);
+       if (unlikely(ret != 0))
+               return;
+
+       radeon_bo_unpin(bo);
+       radeon_bo_unreserve(bo);
 }