LCOV - code coverage report
Current view: top level - dev/pci/drm/radeon - radeon_prime.c (source / functions) Hit Total Coverage
Test: 6.4 Lines: 0 6 0.0 %
Date: 2018-10-19 03:25:38 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2012 Advanced Micro Devices, Inc.
       3             :  *
       4             :  * Permission is hereby granted, free of charge, to any person obtaining a
       5             :  * copy of this software and associated documentation files (the "Software"),
       6             :  * to deal in the Software without restriction, including without limitation
       7             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
       8             :  * and/or sell copies of the Software, and to permit persons to whom the
       9             :  * Software is furnished to do so, subject to the following conditions:
      10             :  *
      11             :  * The above copyright notice and this permission notice shall be included in
      12             :  * all copies or substantial portions of the Software.
      13             :  *
      14             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      15             :  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      16             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
      17             :  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
      18             :  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
      19             :  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
      20             :  * OTHER DEALINGS IN THE SOFTWARE.
      21             :  *
      22             :  * based on nouveau_prime.c
      23             :  *
      24             :  * Authors: Alex Deucher
      25             :  */
      26             : #include <dev/pci/drm/drmP.h>
      27             : 
      28             : #include "radeon.h"
      29             : #include <dev/pci/drm/radeon_drm.h>
      30             : 
      31             : #ifdef notyet
      32             : 
      33             : struct sg_table *radeon_gem_prime_get_sg_table(struct drm_gem_object *obj)
      34             : {
      35             :         struct radeon_bo *bo = gem_to_radeon_bo(obj);
      36             :         int npages = bo->tbo.num_pages;
      37             : 
      38             :         return drm_prime_pages_to_sg(bo->tbo.ttm->pages, npages);
      39             : }
      40             : 
      41             : void *radeon_gem_prime_vmap(struct drm_gem_object *obj)
      42             : {
      43             :         struct radeon_bo *bo = gem_to_radeon_bo(obj);
      44             :         int ret;
      45             : 
      46             :         ret = ttm_bo_kmap(&bo->tbo, 0, bo->tbo.num_pages,
      47             :                           &bo->dma_buf_vmap);
      48             :         if (ret)
      49             :                 return ERR_PTR(ret);
      50             : 
      51             :         return bo->dma_buf_vmap.virtual;
      52             : }
      53             : 
      54             : void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
      55             : {
      56             :         struct radeon_bo *bo = gem_to_radeon_bo(obj);
      57             : 
      58             :         ttm_bo_kunmap(&bo->dma_buf_vmap);
      59             : }
      60             : 
      61             : struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
      62             :                                                         struct dma_buf_attachment *attach,
      63             :                                                         struct sg_table *sg)
      64             : {
      65             :         struct reservation_object *resv = attach->dmabuf->resv;
      66             :         struct radeon_device *rdev = dev->dev_private;
      67             :         struct radeon_bo *bo;
      68             :         int ret;
      69             : 
      70             :         ww_mutex_lock(&resv->lock, NULL);
      71             :         ret = radeon_bo_create(rdev, attach->dmabuf->size, PAGE_SIZE, false,
      72             :                                RADEON_GEM_DOMAIN_GTT, 0, sg, resv, &bo);
      73             :         ww_mutex_unlock(&resv->lock);
      74             :         if (ret)
      75             :                 return ERR_PTR(ret);
      76             : 
      77             :         mutex_lock(&rdev->gem.mutex);
      78             :         list_add_tail(&bo->list, &rdev->gem.objects);
      79             :         mutex_unlock(&rdev->gem.mutex);
      80             : 
      81             :         return &bo->gem_base;
      82             : }
      83             : 
      84             : int radeon_gem_prime_pin(struct drm_gem_object *obj)
      85             : {
      86             :         struct radeon_bo *bo = gem_to_radeon_bo(obj);
      87             :         int ret = 0;
      88             : 
      89             :         ret = radeon_bo_reserve(bo, false);
      90             :         if (unlikely(ret != 0))
      91             :                 return ret;
      92             : 
      93             :         /* pin buffer into GTT */
      94             :         ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL);
      95             :         radeon_bo_unreserve(bo);
      96             :         return ret;
      97             : }
      98             : 
      99             : void radeon_gem_prime_unpin(struct drm_gem_object *obj)
     100             : {
     101             :         struct radeon_bo *bo = gem_to_radeon_bo(obj);
     102             :         int ret = 0;
     103             : 
     104             :         ret = radeon_bo_reserve(bo, false);
     105             :         if (unlikely(ret != 0))
     106             :                 return;
     107             : 
     108             :         radeon_bo_unpin(bo);
     109             :         radeon_bo_unreserve(bo);
     110             : }
     111             : 
     112             : 
     113             : struct reservation_object *radeon_gem_prime_res_obj(struct drm_gem_object *obj)
     114             : {
     115             :         struct radeon_bo *bo = gem_to_radeon_bo(obj);
     116             : 
     117             :         return bo->tbo.resv;
     118             : }
     119             : 
     120             : #endif
     121             : 
     122           0 : struct dma_buf *radeon_gem_prime_export(struct drm_device *dev,
     123             :                                         struct drm_gem_object *gobj,
     124             :                                         int flags)
     125             : {
     126           0 :         struct radeon_bo *bo = gem_to_radeon_bo(gobj);
     127           0 :         if (radeon_ttm_tt_has_userptr(bo->tbo.ttm))
     128           0 :                 return ERR_PTR(-EPERM);
     129           0 :         return drm_gem_prime_export(dev, gobj, flags);
     130           0 : }

Generated by: LCOV version 1.13