@ -43,6 +43,7 @@
# include <linux/pagemap.h>
# include <linux/debugfs.h>
# include "amdgpu.h"
# include "amdgpu_trace.h"
# include "bif/bif_4_1_d.h"
# define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
@ -662,6 +663,38 @@ release_pages:
return r ;
}
static void amdgpu_trace_dma_map ( struct ttm_tt * ttm )
{
struct amdgpu_device * adev = amdgpu_ttm_adev ( ttm - > bdev ) ;
struct amdgpu_ttm_tt * gtt = ( void * ) ttm ;
unsigned i ;
if ( unlikely ( trace_amdgpu_ttm_tt_populate_enabled ( ) ) ) {
for ( i = 0 ; i < ttm - > num_pages ; i + + ) {
trace_amdgpu_ttm_tt_populate (
adev ,
gtt - > ttm . dma_address [ i ] ,
page_to_phys ( ttm - > pages [ i ] ) ) ;
}
}
}
static void amdgpu_trace_dma_unmap ( struct ttm_tt * ttm )
{
struct amdgpu_device * adev = amdgpu_ttm_adev ( ttm - > bdev ) ;
struct amdgpu_ttm_tt * gtt = ( void * ) ttm ;
unsigned i ;
if ( unlikely ( trace_amdgpu_ttm_tt_unpopulate_enabled ( ) ) ) {
for ( i = 0 ; i < ttm - > num_pages ; i + + ) {
trace_amdgpu_ttm_tt_unpopulate (
adev ,
gtt - > ttm . dma_address [ i ] ,
page_to_phys ( ttm - > pages [ i ] ) ) ;
}
}
}
/* prepare the sg table with the user pages */
static int amdgpu_ttm_tt_pin_userptr ( struct ttm_tt * ttm )
{
@ -688,6 +721,8 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm)
drm_prime_sg_to_page_addr_arrays ( ttm - > sg , ttm - > pages ,
gtt - > ttm . dma_address , ttm - > num_pages ) ;
amdgpu_trace_dma_map ( ttm ) ;
return 0 ;
release_sg :
@ -721,6 +756,8 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
put_page ( page ) ;
}
amdgpu_trace_dma_unmap ( ttm ) ;
sg_free_table ( ttm - > sg ) ;
}
@ -892,7 +929,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_bo_device *bdev,
static int amdgpu_ttm_tt_populate ( struct ttm_tt * ttm )
{
struct amdgpu_device * adev ;
struct amdgpu_device * adev = amdgpu_ttm_adev ( ttm - > bdev ) ;
struct amdgpu_ttm_tt * gtt = ( void * ) ttm ;
unsigned i ;
int r ;
@ -915,14 +952,14 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm)
drm_prime_sg_to_page_addr_arrays ( ttm - > sg , ttm - > pages ,
gtt - > ttm . dma_address , ttm - > num_pages ) ;
ttm - > state = tt_unbound ;
return 0 ;
r = 0 ;
goto trace_mappings ;
}
adev = amdgpu_ttm_adev ( ttm - > bdev ) ;
# ifdef CONFIG_SWIOTLB
if ( swiotlb_nr_tbl ( ) ) {
return ttm_dma_populate ( & gtt - > ttm , adev - > dev ) ;
r = ttm_dma_populate ( & gtt - > ttm , adev - > dev ) ;
goto trace_mappings ;
}
# endif
@ -945,7 +982,12 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm)
return - EFAULT ;
}
}
return 0 ;
r = 0 ;
trace_mappings :
if ( likely ( ! r ) )
amdgpu_trace_dma_map ( ttm ) ;
return r ;
}
static void amdgpu_ttm_tt_unpopulate ( struct ttm_tt * ttm )
@ -966,6 +1008,8 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)
adev = amdgpu_ttm_adev ( ttm - > bdev ) ;
amdgpu_trace_dma_unmap ( ttm ) ;
# ifdef CONFIG_SWIOTLB
if ( swiotlb_nr_tbl ( ) ) {
ttm_dma_unpopulate ( & gtt - > ttm , adev - > dev ) ;