TTM questions

James Simmons jsimmons at
Thu Jul 15 08:54:12 PDT 2010

	Now that I'm adding in TTM support to my 3Dfx driver I have a questions.
First I noticed in almost every driver for ttm initialization that two
struct ttm_global_reference global_ref are allocated. One for TTM_GLOBAL_TTM_MEM
and one for TTM_GLOBAL_TTM_BO. For a graphics card with only VRAM fb memory do 
you need to allocate the TTM_GLOBAL_TTM_BO area? From what I can tell that is yes. 
	After you set that up do pretty much do a:

ret = ttm_bo_device_init(&bdev, bo_global_ref.ref.object,
                         &my_bo_driver, DRM_FILE_PAGE_OFFSET,
if (ret) {
        return ret;

ret = ttm_bo_init_mm(bdev, TTM_PL_VRAM, vram_size >> PAGE_SHIFT);
if (ret) {
        DRM_ERROR(dev, "failed\n");
        return ret;

// vram start
placement.fpfn = 0;
// static fb pci region length
placement.lpfn = pci_resource_len(pdev, num); // static fb pci region 
// Anything else needed in placement?

// What is the alignment for non-tile framebuffers?
// Is this related to info->pixmap.buf_align
page_align = PAGE_MASK;

// Usually the driver wants to start at the very beginning of vram
buffer_start = 0;
ttm_buffer_object *bo = kmalloc(sizeof(*bo);

ret = ttm_bo_init(&bdev, &bo, vram_size, TTM_PL_VRAM, 
                 &placement, align, buffer_start, false, NULL, 
                 vram_size, my_bo_del_ttm);
if (ret) {
	// ttm will call my_bo_del_ttm if it fails..
        return ret;

// Is the below needed ?
ret = ttm_bo_reserve(bo, false, false, false, 0);
if (ret)
        return ret;

ret = ttm_bo_validate(bo, &nvbo->placement, false, false, false);


Please fill in what I'm missing.

More information about the dri-devel mailing list