All of lore.kernel.org
 help / color / mirror / Atom feed
* TTM questions
@ 2010-07-15 15:54 James Simmons
  2010-07-15 17:22 ` Jerome Glisse
  0 siblings, 1 reply; 3+ messages in thread
From: James Simmons @ 2010-07-15 15:54 UTC (permalink / raw)
  To: DRI development list


	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,
                         dma_flag);
if (ret) {
	DRM_ERROR("failed!!!\n");
        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);

ttm_bo_unreserve(bo);


Please fill in what I'm missing.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: TTM questions
  2010-07-15 15:54 TTM questions James Simmons
@ 2010-07-15 17:22 ` Jerome Glisse
  0 siblings, 0 replies; 3+ messages in thread
From: Jerome Glisse @ 2010-07-15 17:22 UTC (permalink / raw)
  To: James Simmons; +Cc: DRI development list

On 07/15/2010 11:54 AM, James Simmons wrote:
>
> 	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:
>

Yes you need to have the global stuff this are accounting stuff.

> ret = ttm_bo_device_init(&bdev, bo_global_ref.ref.object,
>                           &my_bo_driver, DRM_FILE_PAGE_OFFSET,
>                           dma_flag);
> if (ret) {
> 	DRM_ERROR("failed!!!\n");
>          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?
>

fpfn & lfpn are page frame number ie if you want to have your
buffer allocated between address 0x10000000 & 0x20000000 you
set :
placement.fpfn = 0x10000000 / 4096;
placement.lpfn = 0x20000000 / 4096;

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

Alignement is to force your buffer to be aligned on some address.
For instance some hw need that the 8 lower bits of the framebuffer
address to be zero to have this set:
page_align = 256; //(2^8)

> // 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);
>
> ttm_bo_unreserve(bo);
>
>
> Please fill in what I'm missing.
>

bo_reserve/unreserve is for reserving a bo as multiple context might
access same bo. By reserving/unreserving you assure you are the only
one accessing the bo.

ttm_bo_validate is used when you want the gpu to do some work with the
bo. You need the memory manager to place the bo into visible gpu ram
and that's what ttm_bo_validate do. Once a bo is no more needed ttm
might move it out of vram in your back.

Hope it helps.

Cheers,
Jerome

^ permalink raw reply	[flat|nested] 3+ messages in thread

* TTM questions.
@ 2010-12-28 21:27 James Simmons
  0 siblings, 0 replies; 3+ messages in thread
From: James Simmons @ 2010-12-28 21:27 UTC (permalink / raw)
  To: Thomas Hellstrom; +Cc: DRI development list


Hi!

	So I recently got my new motherboard with a AGP port for continued 
development of 3Dfx KMS. Well this board comes with a built in VIA 
based IGP. Well that chipset is poorly supported so I started to work on 
the via drm driver. Currently I'm porting it to the TTM infrastructure.
	So the first step is a xxx_ttm_global_init. In fact I made a 
"generic" function for this. Will submit a patch at a later date. Second 
step was to create the ttm_bo_device via ttm_bo_device_init. This appears 
to be map to each graphics card in the system. After this you begin 
calling ttm_bo_init_mm for each different memory region of the card. So 
for the via chipset I managed to do this for the framebuffer,mmio region, 
and AGP. That was the easy part.
	Now I'm attemping to create the needed ttm_buffer_object for when 
the user request a memory region via ttm_bo_init, actually I'm using 
ttm_bo_create. So currently the driver fails to create the ttm_buffer_object
due to having a invalid placement. To fix this issue I need to sort some 
things out. What I have noticed is in ttm_buffer_object we have a field,
struct ttm_mem_reg mem, which appears to represent the region this 
ttm_buffer_object represents. We also have ttm_bus_placement which is 
apart of ttm_mem_reg. ttm_mem_reg represents some memory region handled 
by one of the ttm_mem_type_managers. Now the confusing part is ttm_bo_mem_compat.
How  does the placement relate to the ttm_mem_reg? Also I noticed in the 
radeon and nouveau driver you have something like this in a xxx_bo struct.

strcut ttm_placement placement
u32 placements[3];
u32 busy_placements[3];

Do each of those placements map to the different type of memory regions 
that where registered via ttm_bo_init_mm? If that is the case why are
placements not apart of ttm_mem_type_manager. Their seems to be a relation 
to the ttm_mem_type_manager flags and the flags to the placements. Is this 
correct? Could then placements be generated from the flags of the 
ttm_mem_type_manager?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-28 21:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-15 15:54 TTM questions James Simmons
2010-07-15 17:22 ` Jerome Glisse
  -- strict thread matches above, loose matches on Subject: below --
2010-12-28 21:27 James Simmons

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.