diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2013-11-08 05:12:51 -0500 |
---|---|---|
committer | Thomas Hellstrom <thellstrom@vmware.com> | 2013-11-18 07:12:19 -0500 |
commit | 79e5f810032cd166bc71580ca01401ff212688ed (patch) | |
tree | 342c7fa6bec9873aed0b3d77049da99a70378c3e /drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | |
parent | 69977ff55eac7fc26fb78de5ec1d9a9ab802d9fd (diff) |
drm/vmwgfx: Make surfaces prime-aware
Add prime exporting and imporing operations to surfaces
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_surface.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 582814339748..7de2ea8bd553 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | |||
@@ -38,7 +38,7 @@ | |||
38 | * @size: TTM accounting size for the surface. | 38 | * @size: TTM accounting size for the surface. |
39 | */ | 39 | */ |
40 | struct vmw_user_surface { | 40 | struct vmw_user_surface { |
41 | struct ttm_base_object base; | 41 | struct ttm_prime_object prime; |
42 | struct vmw_surface srf; | 42 | struct vmw_surface srf; |
43 | uint32_t size; | 43 | uint32_t size; |
44 | uint32_t backup_handle; | 44 | uint32_t backup_handle; |
@@ -580,7 +580,8 @@ static int vmw_surface_init(struct vmw_private *dev_priv, | |||
580 | static struct vmw_resource * | 580 | static struct vmw_resource * |
581 | vmw_user_surface_base_to_res(struct ttm_base_object *base) | 581 | vmw_user_surface_base_to_res(struct ttm_base_object *base) |
582 | { | 582 | { |
583 | return &(container_of(base, struct vmw_user_surface, base)->srf.res); | 583 | return &(container_of(base, struct vmw_user_surface, |
584 | prime.base)->srf.res); | ||
584 | } | 585 | } |
585 | 586 | ||
586 | /** | 587 | /** |
@@ -599,7 +600,7 @@ static void vmw_user_surface_free(struct vmw_resource *res) | |||
599 | kfree(srf->offsets); | 600 | kfree(srf->offsets); |
600 | kfree(srf->sizes); | 601 | kfree(srf->sizes); |
601 | kfree(srf->snooper.image); | 602 | kfree(srf->snooper.image); |
602 | ttm_base_object_kfree(user_srf, base); | 603 | ttm_prime_object_kfree(user_srf, prime); |
603 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); | 604 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); |
604 | } | 605 | } |
605 | 606 | ||
@@ -616,7 +617,7 @@ static void vmw_user_surface_base_release(struct ttm_base_object **p_base) | |||
616 | { | 617 | { |
617 | struct ttm_base_object *base = *p_base; | 618 | struct ttm_base_object *base = *p_base; |
618 | struct vmw_user_surface *user_srf = | 619 | struct vmw_user_surface *user_srf = |
619 | container_of(base, struct vmw_user_surface, base); | 620 | container_of(base, struct vmw_user_surface, prime.base); |
620 | struct vmw_resource *res = &user_srf->srf.res; | 621 | struct vmw_resource *res = &user_srf->srf.res; |
621 | 622 | ||
622 | *p_base = NULL; | 623 | *p_base = NULL; |
@@ -790,8 +791,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
790 | } | 791 | } |
791 | srf->snooper.crtc = NULL; | 792 | srf->snooper.crtc = NULL; |
792 | 793 | ||
793 | user_srf->base.shareable = false; | 794 | user_srf->prime.base.shareable = false; |
794 | user_srf->base.tfile = NULL; | 795 | user_srf->prime.base.tfile = NULL; |
795 | 796 | ||
796 | /** | 797 | /** |
797 | * From this point, the generic resource management functions | 798 | * From this point, the generic resource management functions |
@@ -803,9 +804,9 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
803 | goto out_unlock; | 804 | goto out_unlock; |
804 | 805 | ||
805 | tmp = vmw_resource_reference(&srf->res); | 806 | tmp = vmw_resource_reference(&srf->res); |
806 | ret = ttm_base_object_init(tfile, &user_srf->base, | 807 | ret = ttm_prime_object_init(tfile, res->backup_size, &user_srf->prime, |
807 | req->shareable, VMW_RES_SURFACE, | 808 | req->shareable, VMW_RES_SURFACE, |
808 | &vmw_user_surface_base_release, NULL); | 809 | &vmw_user_surface_base_release, NULL); |
809 | 810 | ||
810 | if (unlikely(ret != 0)) { | 811 | if (unlikely(ret != 0)) { |
811 | vmw_resource_unreference(&tmp); | 812 | vmw_resource_unreference(&tmp); |
@@ -813,7 +814,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
813 | goto out_unlock; | 814 | goto out_unlock; |
814 | } | 815 | } |
815 | 816 | ||
816 | rep->sid = user_srf->base.hash.key; | 817 | rep->sid = user_srf->prime.base.hash.key; |
817 | vmw_resource_unreference(&res); | 818 | vmw_resource_unreference(&res); |
818 | 819 | ||
819 | ttm_read_unlock(&vmaster->lock); | 820 | ttm_read_unlock(&vmaster->lock); |
@@ -823,7 +824,7 @@ out_no_copy: | |||
823 | out_no_offsets: | 824 | out_no_offsets: |
824 | kfree(srf->sizes); | 825 | kfree(srf->sizes); |
825 | out_no_sizes: | 826 | out_no_sizes: |
826 | ttm_base_object_kfree(user_srf, base); | 827 | ttm_prime_object_kfree(user_srf, prime); |
827 | out_no_user_srf: | 828 | out_no_user_srf: |
828 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); | 829 | ttm_mem_global_free(vmw_mem_glob(dev_priv), size); |
829 | out_unlock: | 830 | out_unlock: |
@@ -859,13 +860,14 @@ int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, | |||
859 | return -EINVAL; | 860 | return -EINVAL; |
860 | } | 861 | } |
861 | 862 | ||
862 | if (unlikely(base->object_type != VMW_RES_SURFACE)) | 863 | if (unlikely(ttm_base_object_type(base) != VMW_RES_SURFACE)) |
863 | goto out_bad_resource; | 864 | goto out_bad_resource; |
864 | 865 | ||
865 | user_srf = container_of(base, struct vmw_user_surface, base); | 866 | user_srf = container_of(base, struct vmw_user_surface, prime.base); |
866 | srf = &user_srf->srf; | 867 | srf = &user_srf->srf; |
867 | 868 | ||
868 | ret = ttm_ref_object_add(tfile, &user_srf->base, TTM_REF_USAGE, NULL); | 869 | ret = ttm_ref_object_add(tfile, &user_srf->prime.base, |
870 | TTM_REF_USAGE, NULL); | ||
869 | if (unlikely(ret != 0)) { | 871 | if (unlikely(ret != 0)) { |
870 | DRM_ERROR("Could not add a reference to a surface.\n"); | 872 | DRM_ERROR("Could not add a reference to a surface.\n"); |
871 | goto out_no_reference; | 873 | goto out_no_reference; |