diff options
Diffstat (limited to 'drivers/gpu/drm/omapdrm/omap_gem.c')
-rw-r--r-- | drivers/gpu/drm/omapdrm/omap_gem.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 038a05918002..c9ad18ea31c8 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c | |||
@@ -66,9 +66,9 @@ struct omap_gem_object { | |||
66 | * | 66 | * |
67 | * Buffers mapped to the TILER have their DMA address pointing to the | 67 | * Buffers mapped to the TILER have their DMA address pointing to the |
68 | * TILER aperture. As TILER mappings are refcounted (through | 68 | * TILER aperture. As TILER mappings are refcounted (through |
69 | * dma_addr_cnt) the DMA address must be accessed through | 69 | * dma_addr_cnt) the DMA address must be accessed through omap_gem_pin() |
70 | * omap_get_get_paddr() to ensure that the mapping won't disappear | 70 | * to ensure that the mapping won't disappear unexpectedly. References |
71 | * unexpectedly. References must be released with omap_gem_put_paddr(). | 71 | * must be released with omap_gem_unpin(). |
72 | */ | 72 | */ |
73 | dma_addr_t dma_addr; | 73 | dma_addr_t dma_addr; |
74 | 74 | ||
@@ -784,10 +784,21 @@ void omap_gem_dma_sync(struct drm_gem_object *obj, | |||
784 | } | 784 | } |
785 | } | 785 | } |
786 | 786 | ||
787 | /* Get physical address for DMA.. if the buffer is not already contiguous, remap | 787 | /** |
788 | * it to pin in physically contiguous memory.. (ie. map in TILER) | 788 | * omap_gem_pin() - Pin a GEM object in memory |
789 | * @obj: the GEM object | ||
790 | * @dma_addr: the DMA address | ||
791 | * | ||
792 | * Pin the given GEM object in memory and fill the dma_addr pointer with the | ||
793 | * object's DMA address. If the buffer is not physically contiguous it will be | ||
794 | * remapped through the TILER to provide a contiguous view. | ||
795 | * | ||
796 | * Pins are reference-counted, calling this function multiple times is allowed | ||
797 | * as long the corresponding omap_gem_unpin() calls are balanced. | ||
798 | * | ||
799 | * Return 0 on success or a negative error code otherwise. | ||
789 | */ | 800 | */ |
790 | int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr) | 801 | int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) |
791 | { | 802 | { |
792 | struct omap_drm_private *priv = obj->dev->dev_private; | 803 | struct omap_drm_private *priv = obj->dev->dev_private; |
793 | struct omap_gem_object *omap_obj = to_omap_bo(obj); | 804 | struct omap_gem_object *omap_obj = to_omap_bo(obj); |
@@ -855,10 +866,15 @@ fail: | |||
855 | return ret; | 866 | return ret; |
856 | } | 867 | } |
857 | 868 | ||
858 | /* Release physical address, when DMA is no longer being performed.. this | 869 | /** |
859 | * could potentially unpin and unmap buffers from TILER | 870 | * omap_gem_unpin() - Unpin a GEM object from memory |
871 | * @obj: the GEM object | ||
872 | * | ||
873 | * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are | ||
874 | * reference-counted, the actualy unpin will only be performed when the number | ||
875 | * of calls to this function matches the number of calls to omap_gem_pin(). | ||
860 | */ | 876 | */ |
861 | void omap_gem_put_paddr(struct drm_gem_object *obj) | 877 | void omap_gem_unpin(struct drm_gem_object *obj) |
862 | { | 878 | { |
863 | struct omap_gem_object *omap_obj = to_omap_bo(obj); | 879 | struct omap_gem_object *omap_obj = to_omap_bo(obj); |
864 | int ret; | 880 | int ret; |
@@ -919,9 +935,9 @@ int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient) | |||
919 | * increasing the pin count (which we don't really do yet anyways, | 935 | * increasing the pin count (which we don't really do yet anyways, |
920 | * because we don't support swapping pages back out). And 'remap' | 936 | * because we don't support swapping pages back out). And 'remap' |
921 | * might not be quite the right name, but I wanted to keep it working | 937 | * might not be quite the right name, but I wanted to keep it working |
922 | * similarly to omap_gem_get_paddr(). Note though that mutex is not | 938 | * similarly to omap_gem_pin(). Note though that mutex is not |
923 | * aquired if !remap (because this can be called in atomic ctxt), | 939 | * aquired if !remap (because this can be called in atomic ctxt), |
924 | * but probably omap_gem_get_paddr() should be changed to work in the | 940 | * but probably omap_gem_unpin() should be changed to work in the |
925 | * same way. If !remap, a matching omap_gem_put_pages() call is not | 941 | * same way. If !remap, a matching omap_gem_put_pages() call is not |
926 | * required (and should not be made). | 942 | * required (and should not be made). |
927 | */ | 943 | */ |