diff options
| author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2017-04-20 17:33:52 -0400 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2017-06-02 03:57:05 -0400 |
| commit | bc20c85caba279b7c63146bab683ca1a81de9f79 (patch) | |
| tree | fc775496c33f32ca4feabf120a19cdb710f78e89 /drivers/gpu/drm/omapdrm | |
| parent | 16869083b9bec8c1090442bd176a5b376708aba0 (diff) | |
drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin()
The reflects the purpose of the function better.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/gpu/drm/omapdrm')
| -rw-r--r-- | drivers/gpu/drm/omapdrm/omap_drv.h | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/omapdrm/omap_fb.c | 6 | ||||
| -rw-r--r-- | drivers/gpu/drm/omapdrm/omap_fbdev.c | 9 | ||||
| -rw-r--r-- | drivers/gpu/drm/omapdrm/omap_gem.c | 38 | ||||
| -rw-r--r-- | drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 6 |
5 files changed, 39 insertions, 24 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index ef5001f1f5c8..f2db84767bf8 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h | |||
| @@ -188,8 +188,8 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll); | |||
| 188 | void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff); | 188 | void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff); |
| 189 | void omap_gem_dma_sync(struct drm_gem_object *obj, | 189 | void omap_gem_dma_sync(struct drm_gem_object *obj, |
| 190 | enum dma_data_direction dir); | 190 | enum dma_data_direction dir); |
| 191 | int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr); | 191 | int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr); |
| 192 | void omap_gem_put_paddr(struct drm_gem_object *obj); | 192 | void omap_gem_unpin(struct drm_gem_object *obj); |
| 193 | int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages, | 193 | int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages, |
| 194 | bool remap); | 194 | bool remap); |
| 195 | int omap_gem_put_pages(struct drm_gem_object *obj); | 195 | int omap_gem_put_pages(struct drm_gem_object *obj); |
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 444bf92c5252..2e8d77166e1f 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c | |||
| @@ -259,7 +259,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb) | |||
| 259 | 259 | ||
| 260 | for (i = 0; i < n; i++) { | 260 | for (i = 0; i < n; i++) { |
| 261 | struct plane *plane = &omap_fb->planes[i]; | 261 | struct plane *plane = &omap_fb->planes[i]; |
| 262 | ret = omap_gem_get_paddr(plane->bo, &plane->dma_addr); | 262 | ret = omap_gem_pin(plane->bo, &plane->dma_addr); |
| 263 | if (ret) | 263 | if (ret) |
| 264 | goto fail; | 264 | goto fail; |
| 265 | omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE); | 265 | omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE); |
| @@ -274,7 +274,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb) | |||
| 274 | fail: | 274 | fail: |
| 275 | for (i--; i >= 0; i--) { | 275 | for (i--; i >= 0; i--) { |
| 276 | struct plane *plane = &omap_fb->planes[i]; | 276 | struct plane *plane = &omap_fb->planes[i]; |
| 277 | omap_gem_put_paddr(plane->bo); | 277 | omap_gem_unpin(plane->bo); |
| 278 | plane->dma_addr = 0; | 278 | plane->dma_addr = 0; |
| 279 | } | 279 | } |
| 280 | 280 | ||
| @@ -300,7 +300,7 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb) | |||
| 300 | 300 | ||
| 301 | for (i = 0; i < n; i++) { | 301 | for (i = 0; i < n; i++) { |
| 302 | struct plane *plane = &omap_fb->planes[i]; | 302 | struct plane *plane = &omap_fb->planes[i]; |
| 303 | omap_gem_put_paddr(plane->bo); | 303 | omap_gem_unpin(plane->bo); |
| 304 | plane->dma_addr = 0; | 304 | plane->dma_addr = 0; |
| 305 | } | 305 | } |
| 306 | 306 | ||
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index dabb1affa2ca..daf81a0a2899 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c | |||
| @@ -162,10 +162,9 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, | |||
| 162 | * to it). Then we just need to be sure that we are able to re- | 162 | * to it). Then we just need to be sure that we are able to re- |
| 163 | * pin it in case of an opps. | 163 | * pin it in case of an opps. |
| 164 | */ | 164 | */ |
| 165 | ret = omap_gem_get_paddr(fbdev->bo, &dma_addr); | 165 | ret = omap_gem_pin(fbdev->bo, &dma_addr); |
| 166 | if (ret) { | 166 | if (ret) { |
| 167 | dev_err(dev->dev, | 167 | dev_err(dev->dev, "could not pin framebuffer\n"); |
| 168 | "could not map (paddr)! Skipping framebuffer alloc\n"); | ||
| 169 | ret = -ENOMEM; | 168 | ret = -ENOMEM; |
| 170 | goto fail; | 169 | goto fail; |
| 171 | } | 170 | } |
| @@ -303,8 +302,8 @@ void omap_fbdev_free(struct drm_device *dev) | |||
| 303 | 302 | ||
| 304 | fbdev = to_omap_fbdev(priv->fbdev); | 303 | fbdev = to_omap_fbdev(priv->fbdev); |
| 305 | 304 | ||
| 306 | /* release the ref taken in omap_fbdev_create() */ | 305 | /* unpin the GEM object pinned in omap_fbdev_create() */ |
| 307 | omap_gem_put_paddr(fbdev->bo); | 306 | omap_gem_unpin(fbdev->bo); |
| 308 | 307 | ||
| 309 | /* this will free the backing object */ | 308 | /* this will free the backing object */ |
| 310 | if (fbdev->fb) | 309 | if (fbdev->fb) |
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 | */ |
diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index 806e8b981b2b..6aaf28311f3a 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | |||
| @@ -41,7 +41,7 @@ static struct sg_table *omap_gem_map_dma_buf( | |||
| 41 | /* camera, etc, need physically contiguous.. but we need a | 41 | /* camera, etc, need physically contiguous.. but we need a |
| 42 | * better way to know this.. | 42 | * better way to know this.. |
| 43 | */ | 43 | */ |
| 44 | ret = omap_gem_get_paddr(obj, &dma_addr); | 44 | ret = omap_gem_pin(obj, &dma_addr); |
| 45 | if (ret) | 45 | if (ret) |
| 46 | goto out; | 46 | goto out; |
| 47 | 47 | ||
| @@ -54,7 +54,7 @@ static struct sg_table *omap_gem_map_dma_buf( | |||
| 54 | sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(dma_addr)), obj->size, 0); | 54 | sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(dma_addr)), obj->size, 0); |
| 55 | sg_dma_address(sg->sgl) = dma_addr; | 55 | sg_dma_address(sg->sgl) = dma_addr; |
| 56 | 56 | ||
| 57 | /* this should be after _get_paddr() to ensure we have pages attached */ | 57 | /* this must be after omap_gem_pin() to ensure we have pages attached */ |
| 58 | omap_gem_dma_sync(obj, dir); | 58 | omap_gem_dma_sync(obj, dir); |
| 59 | 59 | ||
| 60 | return sg; | 60 | return sg; |
| @@ -67,7 +67,7 @@ static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment, | |||
| 67 | struct sg_table *sg, enum dma_data_direction dir) | 67 | struct sg_table *sg, enum dma_data_direction dir) |
| 68 | { | 68 | { |
| 69 | struct drm_gem_object *obj = attachment->dmabuf->priv; | 69 | struct drm_gem_object *obj = attachment->dmabuf->priv; |
| 70 | omap_gem_put_paddr(obj); | 70 | omap_gem_unpin(obj); |
| 71 | sg_free_table(sg); | 71 | sg_free_table(sg); |
| 72 | kfree(sg); | 72 | kfree(sg); |
| 73 | } | 73 | } |
