All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerome Glisse <glisse@freedesktop.org>
To: James Simmons <jsimmons@infradead.org>
Cc: DRI development list <dri-devel@lists.freedesktop.org>
Subject: Re: TTM questions
Date: Thu, 15 Jul 2010 13:22:53 -0400	[thread overview]
Message-ID: <4C3F43ED.30507@freedesktop.org> (raw)
In-Reply-To: <alpine.LFD.2.00.1007151545150.1038@casper.infradead.org>

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

  reply	other threads:[~2010-07-15 17:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-15 15:54 TTM questions James Simmons
2010-07-15 17:22 ` Jerome Glisse [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-12-28 21:27 James Simmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C3F43ED.30507@freedesktop.org \
    --to=glisse@freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsimmons@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.