FreeBSD/sys/dev/drm2/radeon/radeon_gart.c
/**
 * radeon_gart_init - init the driver info for managing the gart
 *
 * @rdev: radeon_device pointer
 *
 * Allocate the dummy page and init the gart driver info (all asics).
 * Returns 0 for success, error for failure.
 */
init the driver info for managing the gart
@rdev: radeon_device pointer

Allocate the dummy page and init the gart driver info (all asics).
Returns 0 for success, error for failure.
init the driver info for managing the gart @rdev : radeon_device pointer Allocate the dummy page and init the gart driver info ( all asics ) . Returns 0 for success error for failure .
int radeon_gart_init(struct radeon_device *rdev)
{
	int r, i;
	if (rdev->gart.pages) {
		return 0;
	}
	if (PAGE_SIZE < RADEON_GPU_PAGE_SIZE) {
		DRM_ERROR("Page size is smaller than GPU page size!\n");
		return -EINVAL;
	}
	r = radeon_dummy_page_init(rdev);
	if (r)
		return r;
	rdev->gart.num_cpu_pages = rdev->mc.gtt_size / PAGE_SIZE;
	rdev->gart.num_gpu_pages = rdev->mc.gtt_size / RADEON_GPU_PAGE_SIZE;
	DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n",
		 rdev->gart.num_cpu_pages, rdev->gart.num_gpu_pages);
	rdev->gart.pages = malloc(sizeof(void *) * rdev->gart.num_cpu_pages,
	    DRM_MEM_DRIVER, M_NOWAIT | M_ZERO);
	if (rdev->gart.pages == NULL) {
		radeon_gart_fini(rdev);
		return -ENOMEM;
	}
	rdev->gart.pages_addr = malloc(sizeof(dma_addr_t) *
					rdev->gart.num_cpu_pages,
					DRM_MEM_DRIVER, M_NOWAIT | M_ZERO);
	if (rdev->gart.pages_addr == NULL) {
		radeon_gart_fini(rdev);
		return -ENOMEM;
	}
	for (i = 0; i < rdev->gart.num_cpu_pages; i++) {
		rdev->gart.pages_addr[i] = rdev->dummy_page.addr;
	}
	return 0;
}
int radeon_gart_init ( struct radeon_device * rdev ) { int r , i ; if ( rdev -> gart . pages ) { return 0 ; } if ( PAGE_SIZE < RADEON_GPU_PAGE_SIZE ) { DRM_ERROR ( " \n " ) ; return - EINVAL ; } r = radeon_dummy_page_init ( rdev ) ; if ( r ) return r ; rdev -> gart . num_cpu_pages = rdev -> mc . gtt_size / PAGE_SIZE ; rdev -> gart . num_gpu_pages = rdev -> mc . gtt_size / RADEON_GPU_PAGE_SIZE ; DRM_INFO ( " \n " , rdev -> gart . num_cpu_pages , rdev -> gart . num_gpu_pages ) ; rdev -> gart . pages = malloc ( sizeof ( void * ) * rdev -> gart . num_cpu_pages , DRM_MEM_DRIVER , M_NOWAIT | M_ZERO ) ; if ( rdev -> gart . pages == NULL ) { radeon_gart_fini ( rdev ) ; return - ENOMEM ; } rdev -> gart . pages_addr = malloc ( sizeof ( dma_addr_t ) * rdev -> gart . num_cpu_pages , DRM_MEM_DRIVER , M_NOWAIT | M_ZERO ) ; if ( rdev -> gart . pages_addr == NULL ) { radeon_gart_fini ( rdev ) ; return - ENOMEM ; } for ( i = 0 ; i < rdev -> gart . num_cpu_pages ; i ++ ) { rdev -> gart . pages_addr [ i ] = rdev -> dummy_page . addr ; } return 0 ; }
radeon_gart_init - init the driver info for managing the gart
 @rdev: radeon_device pointer
radeon_gart_init - init the driver info for managing the gart @rdev : radeon_device pointer
/* We need PAGE_SIZE >= RADEON_GPU_PAGE_SIZE */ /* Compute table size */ /* Allocate pages table */ /* set GART entry to point to the dummy page by default */