06 Jan, 2012

1 commit

  • ttm tt rework modified the way we allocate and populate the
    ttm_tt structure, the AGP side was missing some bit to properly
    work. Fix those and fix radeon and nouveau AGP support.

    Tested on radeon only so far.

    Signed-off-by: Jerome Glisse
    Reviewed-by: Konrad Rzeszutek Wilk
    Signed-off-by: Dave Airlie

    Jerome Glisse
     

06 Dec, 2011

9 commits

  • Provide helper function to compute the kernel memory size needed
    for each buffer object. Move all the accounting inside ttm, simplifying
    driver and avoiding code duplication accross them.

    v2 fix accounting of ghost object, one would have thought that i
    would have run into the issue since a longtime but it seems
    ghost object are rare when you have plenty of vram ;)

    Signed-off-by: Jerome Glisse
    Reviewed-by: Thomas Hellstrom

    Jerome Glisse
     
  • Move dma data to a superset ttm_dma_tt structure which herit
    from ttm_tt. This allow driver that don't use dma functionalities
    to not have to waste memory for it.

    V2 Rebase on top of no memory account changes (where/when is my
    delorean when i need it ?)
    V3 Make sure page list is initialized empty
    V4 typo/syntax fixes

    Signed-off-by: Jerome Glisse
    Reviewed-by: Thomas Hellstrom

    Jerome Glisse
     
  • In TTM world the pages for the graphic drivers are kept in three different
    pools: write combined, uncached, and cached (write-back). When the pages
    are used by the graphic driver the graphic adapter via its built in MMU
    (or AGP) programs these pages in. The programming requires the virtual address
    (from the graphic adapter perspective) and the physical address (either System RAM
    or the memory on the card) which is obtained using the pci_map_* calls (which does the
    virtual to physical - or bus address translation). During the graphic application's
    "life" those pages can be shuffled around, swapped out to disk, moved from the
    VRAM to System RAM or vice-versa. This all works with the existing TTM pool code
    - except when we want to use the software IOTLB (SWIOTLB) code to "map" the physical
    addresses to the graphic adapter MMU. We end up programming the bounce buffer's
    physical address instead of the TTM pool memory's and get a non-worky driver.
    There are two solutions:
    1) using the DMA API to allocate pages that are screened by the DMA API, or
    2) using the pci_sync_* calls to copy the pages from the bounce-buffer and back.

    This patch fixes the issue by allocating pages using the DMA API. The second
    is a viable option - but it has performance drawbacks and potential correctness
    issues - think of the write cache page being bounced (SWIOTLB->TTM), the
    WC is set on the TTM page and the copy from SWIOTLB not making it to the TTM
    page until the page has been recycled in the pool (and used by another application).

    The bounce buffer does not get activated often - only in cases where we have
    a 32-bit capable card and we want to use a page that is allocated above the
    4GB limit. The bounce buffer offers the solution of copying the contents
    of that 4GB page to an location below 4GB and then back when the operation has been
    completed (or vice-versa). This is done by using the 'pci_sync_*' calls.
    Note: If you look carefully enough in the existing TTM page pool code you will
    notice the GFP_DMA32 flag is used - which should guarantee that the provided page
    is under 4GB. It certainly is the case, except this gets ignored in two cases:
    - If user specifies 'swiotlb=force' which bounces _every_ page.
    - If user is using a Xen's PV Linux guest (which uses the SWIOTLB and the
    underlaying PFN's aren't necessarily under 4GB).

    To not have this extra copying done the other option is to allocate the pages
    using the DMA API so that there is not need to map the page and perform the
    expensive 'pci_sync_*' calls.

    This DMA API capable TTM pool requires for this the 'struct device' to
    properly call the DMA API. It also has to track the virtual and bus address of
    the page being handed out in case it ends up being swapped out or de-allocated -
    to make sure it is de-allocated using the proper's 'struct device'.

    Implementation wise the code keeps two lists: one that is attached to the
    'struct device' (via the dev->dma_pools list) and a global one to be used when
    the 'struct device' is unavailable (think shrinker code). The global list can
    iterate over all of the 'struct device' and its associated dma_pool. The list
    in dev->dma_pools can only iterate the device's dma_pool.
    /[struct device_pool]\
    /---------------------------------------------------| dev |
    / +-------| dma_pool |
    /-----+------\ / \--------------------/
    |struct device| /-->[struct dma_pool for WC]</ /[struct device_pool]\
    | dma_pools +----+ /-| dev |
    | ... | \--->[struct dma_pool for uncached]
    [v1: Using swiotlb_nr_tbl instead of swiotlb_enabled]
    [v2: Major overhaul - added 'inuse_list' to seperate used from inuse and reorder
    the order of lists to get better performance.]
    [v3: Added comments/and some logic based on review, Added Jerome tag]
    [v4: rebase on top of ttm_tt & ttm_backend merge]
    [v5: rebase on top of ttm memory accounting overhaul]
    [v6: New rebase on top of more memory accouting changes]
    [v7: well rebase on top of no memory accounting changes]
    [v8: make sure pages list is initialized empty]
    [v9: calll ttm_mem_global_free_page in unpopulate for accurate accountg]
    Signed-off-by: Konrad Rzeszutek Wilk
    Reviewed-by: Jerome Glisse
    Acked-by: Thomas Hellstrom

    Konrad Rzeszutek Wilk
     
  • Move the page allocation and freeing to driver callback and
    provide ttm code helper function for those.

    Most intrusive change, is the fact that we now only fully
    populate an object this simplify some of code designed around
    the page fault design.

    V2 Rebase on top of memory accounting overhaul
    V3 New rebase on top of more memory accouting changes
    V4 Rebase on top of no memory account changes (where/when is my
    delorean when i need it ?)

    Signed-off-by: Jerome Glisse
    Reviewed-by: Konrad Rzeszutek Wilk
    Reviewed-by: Thomas Hellstrom

    Jerome Glisse
     
  • ttm_backend will only exist with a ttm_tt, and ttm_tt
    will only be of interest when bound to a backend. Merge them
    to avoid code and data duplication.

    V2 Rebase on top of memory accounting overhaul
    V3 Rebase on top of more memory accounting changes
    V4 Rebase on top of no memory account changes (where/when is my
    delorean when i need it ?)
    V5 make sure ttm is unbound before destroying, change commit
    message on suggestion from Tormod Volden

    Signed-off-by: Jerome Glisse
    Reviewed-by: Konrad Rzeszutek Wilk
    Reviewed-by: Thomas Hellstrom

    Jerome Glisse
     
  • Use the ttm_tt pages array for pages allocations, move the list
    unwinding into the page allocation functions.

    Signed-off-by: Jerome Glisse

    Jerome Glisse
     
  • This field is not use by any of the driver just drop it.

    Signed-off-by: Jerome Glisse
    Reviewed-by: Konrad Rzeszutek Wilk
    Reviewed-by: Thomas Hellstrom

    Jerome Glisse
     
  • Split btw highmem and lowmem page was rendered useless by the
    pool code. Remove it. Note further cleanup would change the
    ttm page allocation helper to actualy take an array instead
    of relying on list this could drasticly reduce the number of
    function call in the common case of allocation whole buffer.

    Signed-off-by: Jerome Glisse
    Reviewed-by: Konrad Rzeszutek Wilk
    Reviewed-by: Thomas Hellstrom

    Jerome Glisse
     
  • This was never use in none of the driver, properly using userspace
    page for bo would need more code (vma interaction mostly). Removing
    this dead code in preparation of ttm_tt & backend merge.

    Signed-off-by: Jerome Glisse
    Reviewed-by: Konrad Rzeszutek Wilk
    Reviewed-by: Thomas Hellstrom

    Jerome Glisse
     

27 Jul, 2011

1 commit

  • This allows us to move duplicated code in
    (atomic_inc_not_zero() for now) to

    Signed-off-by: Arun Sharma
    Reviewed-by: Eric Dumazet
    Cc: Ingo Molnar
    Cc: David Miller
    Cc: Eric Dumazet
    Acked-by: Mike Frysinger
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arun Sharma
     

21 Jun, 2011

1 commit


08 Apr, 2011

1 commit


05 Apr, 2011

1 commit


31 Mar, 2011

1 commit


23 Feb, 2011

3 commits


28 Jan, 2011

2 commits

  • We pass in the array of ttm pages to be populated in the GART/MM
    of the card (or AGP). Patch titled: "ttm: Utilize the DMA API for
    pages that have TTM_PAGE_FLAG_DMA32 set." uses the DMA API to make
    those pages have a proper DMA addresses (in the situation where
    page_to_phys or virt_to_phys do not give use the DMA (bus) address).

    Since we are using the DMA API on those pages, we should pass in the
    DMA address to this function so it can save it in its proper fields
    (later patches use it).

    [v2: Added reviewed-by tag]

    Reviewed-by: Thomas Hellstrom
    Signed-off-by: Konrad Rzeszutek Wilk
    Tested-by: Ian Campbell

    Konrad Rzeszutek Wilk
     
  • This is right now limited to only non-pool constructs.

    [v2: Fixed indentation issues, add review-by tag]

    Reviewed-by: Thomas Hellstrom
    Signed-off-by: Konrad Rzeszutek Wilk
    Tested-by: Ian Campbell

    Konrad Rzeszutek Wilk
     

22 Nov, 2010

6 commits

  • This patch attempts to fix up shortcomings with the current calling
    sequences.

    1) There's a fastpath where no locking occurs and only io_mem_reserved is
    called to obtain needed info for mapping. The fastpath is set per
    memory type manager.
    2) If the fastpath is disabled, io_mem_reserve and io_mem_free will be exactly
    balanced and not called recursively for the same struct ttm_mem_reg.
    3) Optionally the driver can choose to enable a per memory type manager LRU
    eviction mechanism that, when io_mem_reserve returns -EAGAIN will attempt
    to kill user-space mappings of memory in that manager to free up needed
    resources

    Signed-off-by: Thomas Hellstrom
    Reviewed-by: Ben Skeggs
    Signed-off-by: Dave Airlie

    Thomas Hellstrom
     
  • Rather than having the driver supply the validation sequence, leave that
    responsibility to TTM. This saves some confusion and a function argument.

    Signed-off-by: Thomas Hellstrom
    Signed-off-by: Dave Airlie

    Thomas Hellstrom
     
  • Drastically reduce the number of spin lock / unlock operations by performing
    unreserving and fencing under global locks.

    Signed-off-by: Thomas Hellstrom
    Reviewed-by: Jerome Glisse
    Signed-off-by: Dave Airlie

    Thomas Hellstrom
     
  • The bo lock used only to protect the bo sync object members, and since it
    is a per bo lock, fencing a buffer list will see a lot of locks and unlocks.
    Replace it with a per-device lock that protects the sync object members on
    *all* bos. Reading and setting these members will always be very quick, so
    the risc of heavy lock contention is microscopic. Note that waiting for
    sync objects will always take place outside of this lock.

    The bo device fence lock will eventually be replaced with a seqlock /
    rcu mechanism so we can determine that a bo is idle under a
    rcu / read seqlock.

    However this change will allow us to batch fencing and unreserving of
    buffers with a minimal amount of locking.

    Signed-off-by: Thomas Hellstrom
    Reviewed-by: Jerome Glisse
    Signed-off-by: Dave Airlie

    Thomas Hellstrom
     
  • Add an aid for the driver to detect deadlocks on multi-bo reservations
    Update documentation.

    Signed-off-by: Thomas Hellstrom
    Reviewed-by: Jerome Glisse
    Signed-off-by: Dave Airlie

    Thomas Hellstrom
     
  • Makes it possible to reserve a list of buffer objects with a single
    spin lock / unlock if there is no contention.
    Should improve cpu usage on SMP kernels.

    v2: Initialize private list members on reserve and don't call
    ttm_bo_list_ref_sub() with zero put_count.

    Signed-off-by: Thomas Hellstrom
    Signed-off-by: Dave Airlie

    Dave Airlie
     

10 Nov, 2010

1 commit


09 Nov, 2010

1 commit


21 Oct, 2010

1 commit


19 Oct, 2010

2 commits


06 Oct, 2010

1 commit

  • This fixes a race pointed out by Dave Airlie where we don't take a buffer
    object about to be destroyed off the LRU lists properly. It also fixes a rare
    case where a buffer object could be destroyed in the middle of an
    accelerated eviction.

    The patch also adds a utility function that can be used to prematurely
    release GPU memory space usage of an object waiting to be destroyed.
    For example during eviction or swapout.

    The above mentioned commit didn't queue the buffer on the delayed destroy
    list under some rare circumstances. It also didn't completely honor the
    remove_all parameter.

    Fixes:
    https://bugzilla.redhat.com/show_bug.cgi?id=615505
    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591061

    Signed-off-by: Thomas Hellstrom
    Signed-off-by: Dave Airlie

    Thomas Hellstrom
     

05 Oct, 2010

2 commits


04 Aug, 2010

1 commit


07 Jul, 2010

1 commit

  • Repeated ttm_page_alloc_init/fini fails noisily because the pool
    manager kobj isn't zeroed out between uses (we could do just that but
    statically allocated kobjects are generally considered a bad thing).
    Move it to kzalloc'ed memory.

    Note that this patch drops the refcounting behavior of the pool
    allocator init/fini functions: it would have led to a race condition
    in its current form, and anyway it was never exploited.

    This fixes a regression with reloading kms modules at runtime, since
    page allocator was introduced.

    Signed-off-by: Francisco Jerez
    Signed-off-by: Dave Airlie

    Francisco Jerez
     

22 May, 2010

1 commit

  • * 'drm-for-2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: (207 commits)
    drm/radeon/kms/pm/r600: select the mid clock mode for single head low profile
    drm/radeon: fix power supply kconfig interaction.
    drm/radeon/kms: record object that have been list reserved
    drm/radeon: AGP memory is only I/O if the aperture can be mapped by the CPU.
    drm/radeon/kms: don't default display priority to high on rs4xx
    drm/edid: fix typo in 1600x1200@75 mode
    drm/nouveau: fix i2c-related init table handlers
    drm/nouveau: support init table i2c device identifier 0x81
    drm/nouveau: ensure we've parsed i2c table entry for INIT_*I2C* handlers
    drm/nouveau: display error message for any failed init table opcode
    drm/nouveau: fix init table handlers to return proper error codes
    drm/nv50: support fractional feedback divider on newer chips
    drm/nv50: fix monitor detection on certain chipsets
    drm/nv50: store full dcb i2c entry from vbios
    drm/nv50: fix suspend/resume with DP outputs
    drm/nv50: output calculated crtc pll when debugging on
    drm/nouveau: dump pll limits entries when debugging is on
    drm/nouveau: bios parser fixes for eDP boards
    drm/nouveau: fix a nouveau_bo dereference after it's been destroyed
    drm/nv40: remove some completed ctxprog TODOs
    ...

    Linus Torvalds
     

18 May, 2010

1 commit


07 May, 2010

1 commit


20 Apr, 2010

1 commit

  • * drm-ttm-unmappable:
    drm/radeon/kms: enable use of unmappable VRAM V2
    drm/ttm: remove io_ field from TTM V6
    drm/vmwgfx: add support for new TTM fault callback V5
    drm/nouveau/kms: add support for new TTM fault callback V5
    drm/radeon/kms: add support for new fault callback V7
    drm/ttm: ttm_fault callback to allow driver to handle bo placement V6
    drm/ttm: split no_wait argument in 2 GPU or reserve wait

    Conflicts:
    drivers/gpu/drm/nouveau/nouveau_bo.c

    Dave Airlie