aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/ttm
AgeCommit message (Collapse)AuthorFilesLines
2011-12-06drm/ttm: simplify memory accounting for ttm user v2Jerome Glisse2-12/+41
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 <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
2011-12-06drm/ttm: isolate dma data from ttm_tt V4Jerome Glisse3-85/+124
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 <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
2011-12-06drm/ttm: provide dma aware ttm page pool code V9Konrad Rzeszutek Wilk4-0/+1141
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]<-/--| dma_pool | \-----+------/ / \--------------------/ \----------------------------------------------/ [Two pools associated with the device (WC and UC), and the parallel list containing the 'struct dev' and 'struct dma_pool' entries] The maximum amount of dma pools a device can have is six: write-combined, uncached, and cached; then there are the DMA32 variants which are: write-combined dma32, uncached dma32, and cached dma32. Currently this code only gets activated when any variant of the SWIOTLB IOMMU code is running (Intel without VT-d, AMD without GART, IBM Calgary and Xen PV with PCI devices). Tested-by: Michel Dänzer <[email protected]> [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 <[email protected]> Reviewed-by: Jerome Glisse <[email protected]> Acked-by: Thomas Hellstrom <[email protected]>
2011-12-06drm/ttm: introduce callback for ttm_tt populate & unpopulate V4Jerome Glisse4-102/+86
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 <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
2011-12-06drm/ttm: merge ttm_backend and ttm_tt V5Jerome Glisse3-105/+51
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 <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
2011-12-06drm/ttm: page allocation use page array instead of listJerome Glisse2-62/+59
Use the ttm_tt pages array for pages allocations, move the list unwinding into the page allocation functions. Signed-off-by: Jerome Glisse <[email protected]>
2011-12-06drm/ttm: test for dma_address array allocation failureJerome Glisse1-1/+1
Signed-off-by: Jerome Glisse <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
2011-12-06drm/ttm: use ttm put pages function to properly restore cache attributeJerome Glisse1-1/+4
On failure we need to make sure the page we free has wb cache attribute. Do this pas call the proper ttm page helper function. Signed-off-by: Jerome Glisse <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
2011-12-06drm/ttm: remove split btw highmen and lowmem pageJerome Glisse1-9/+2
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 <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
2011-12-06drm/ttm: remove userspace backed ttm object supportJerome Glisse2-126/+1
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 <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
2011-11-22ttm: Don't return the bo reserved on error pathThomas Hellstrom1-1/+7
An unlikely race could case a bo to be returned reserved on an error path. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jerome Glisse <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-10-31gpu: Add export.h as required to drivers/gpu files.Paul Gortmaker1-0/+1
They need this to get all the EXPORT_SYMBOL variants and THIS_MODULE Signed-off-by: Paul Gortmaker <[email protected]>
2011-10-28Merge branch 'drm-core-next' of git://people.freedesktop.org/~airlied/linuxLinus Torvalds1-0/+1
* 'drm-core-next' of git://people.freedesktop.org/~airlied/linux: (290 commits) Revert "drm/ttm: add a way to bo_wait for either the last read or last write" Revert "drm/radeon/kms: add a new gem_wait ioctl with read/write flags" vmwgfx: Don't pass unused arguments to do_dirty functions vmwgfx: Emulate depth 32 framebuffers drm/radeon: Lower the severity of the radeon lockup messages. drm/i915/dp: Fix eDP on PCH DP on CPT/PPT drm/i915/dp: Introduce is_cpu_edp() drm/i915: use correct SPD type value drm/i915: fix ILK+ infoframe support drm/i915: add DP test request handling drm/i915: read full receiver capability field during DP hot plug drm/i915/dp: Remove eDP special cases from bandwidth checks drm/i915/dp: Fix the math in intel_dp_link_required drm/i915/panel: Always record the backlight level again (but cleverly) i915: Move i915_read/write out of line drm/i915: remove transcoder PLL mashing from mode_set per specs drm/i915: if transcoder disable fails, say which drm/i915: set watermarks for third pipe on IVB drm/i915: export a CPT mode set verification function drm/i915: fix transcoder PLL select masking ...
2011-10-27Revert "drm/ttm: add a way to bo_wait for either the last read or last write"Dave Airlie4-111/+33
This reverts commit dfadbbdb57b3f2bb33e14f129a43047c6f0caefa. Further upstream discussion between Marek and Thomas decided this wasn't fully baked and needed further work, so revert it before it hits mainline. Signed-off-by: Dave Airlie <[email protected]>
2011-10-18Merge tag 'v3.1-rc10' into drm-core-nextDave Airlie1-1/+2
There are a number of fixes in mainline required for code in -next, also there was a few conflicts I'd rather resolve myself. Signed-off-by: Dave Airlie <[email protected]> Conflicts: drivers/gpu/drm/radeon/evergreen.c drivers/gpu/drm/radeon/r600.c drivers/gpu/drm/radeon/radeon_asic.h
2011-10-18ttm: Fix error-path using an uninitialized valueThomas Hellstrom1-1/+1
Pointed out by Michel Daenzer. Signed-off-by: Thomas Hellstrom <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-10-05ttm: export ttm_bo_createThomas Hellstrom1-0/+1
Used by the vmwgfx driver. Signed-off-by: Thomas Hellstrom <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-09-14drm/ttm: request zeroed system memory pages for new TT buffer objectsBen Skeggs1-1/+2
Fixes an information leak to userspace, we were handing out un-zeroed pages for any newly created TTM_PL_TT buffer. Reported-by: Marcin Slusarz <[email protected]> Signed-off-by: Ben Skeggs <[email protected]> Tested-by: Marcin Slusarz <[email protected]> Cc: [email protected] Signed-off-by: Dave Airlie <[email protected]>
2011-08-31drm/ttm: add a way to bo_wait for either the last read or last writeMarek Olšák4-33/+111
Sometimes we want to know whether a buffer is busy and wait for it (bo_wait). However, sometimes it would be more useful to be able to query whether a buffer is busy and being either read or written, and wait until it's stopped being either read or written. The point of this is to be able to avoid unnecessary waiting, e.g. if a GPU has written something to a buffer and is now reading that buffer, and a CPU wants to map that buffer for read, it needs to only wait for the last write. If there were no write, there wouldn't be any waiting needed. This, or course, requires user space drivers to send read/write flags with each relocation (like we have read/write domains in radeon, so we can actually use those for something useful now). Now how this patch works: The read/write flags should passed to ttm_validate_buffer. TTM maintains separate sync objects of the last read and write for each buffer, in addition to the sync object of the last use of a buffer. ttm_bo_wait then operates with one the sync objects. Signed-off-by: Marek Olšák <[email protected]> Reviewed-by: Jerome Glisse <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-08-23drm/ttm: ensure ttm for new node is bound before calling move_notify()Ben Skeggs1-4/+6
This was true for new TTM_PL_SYSTEM and new TTM_PL_TT cases, but wasn't the case on TTM_PL_SYSTEM<->TTM_PL_TT moves, which causes trouble on some paths as nouveau's move_notify() hook requires that the dma addresses be valid at this point. Signed-off-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-08-23drm/ttm: unbind ttm before destroying node in accel move cleanupBen Skeggs1-1/+1
Nouveau makes the assumption that if a TTM is bound there will be a mm_node around for it and the backwards ordering here resulted in a use-after-free on some eviction paths. Signed-off-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-08-23drm/ttm: fix ttm_bo_add_ttm(user) failure pathMarcin Slusarz1-1/+3
ttm_tt_destroy kfrees passed object, so we need to nullify a reference to it. Signed-off-by: Marcin Slusarz <[email protected]> Cc: [email protected] Reviewed-by: Thomas Hellstrom <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-07-26atomic: use <linux/atomic.h>Arun Sharma4-4/+4
This allows us to move duplicated code in <asm/atomic.h> (atomic_inc_not_zero() for now) to <linux/atomic.h> Signed-off-by: Arun Sharma <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: David Miller <[email protected]> Cc: Eric Dumazet <[email protected]> Acked-by: Mike Frysinger <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-07-13Merge 3.0-rc7 into drm-core-nextDave Airlie1-2/+3
This pulls in all the drm fixes up to this point which are needed for some -next patches to work.
2011-06-27drm/ttm: use shmem_read_mapping_pageHugh Dickins1-2/+3
Soon tmpfs will stop supporting ->readpage and read_mapping_page(): once "tmpfs: add shmem_read_mapping_page_gfp" has been applied, this patch can be applied to ease the transition. ttm_tt_swapin() and ttm_tt_swapout() use shmem_read_mapping_page() in place of read_mapping_page(), since their swap_space has been created with shmem_file_setup(). Signed-off-by: Hugh Dickins <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Thomas Hellstrom <[email protected]> Cc: Dave Airlie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-06-21ttm: Fix spelling mistakes and remove unused #ifdefKonrad Rzeszutek Wilk1-8/+8
. and some comments to make it easier to understand. Ackedby: Randy Dunlap <[email protected]> [v2: Added some more updates from Randy Dunlap] Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-05-25vmscan: change shrinker API by passing shrink_control structYing Han1-1/+3
Change each shrinker's API by consolidating the existing parameters into shrink_control struct. This will simplify any further features added w/o touching each file of shrinker. [[email protected]: fix build] [[email protected]: fix warning] [[email protected]: fix up new shrinker API] [[email protected]: fix xfs warning] [[email protected]: update gfs2] Signed-off-by: Ying Han <[email protected]> Cc: KOSAKI Motohiro <[email protected]> Cc: Minchan Kim <[email protected]> Acked-by: Pavel Emelyanov <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Cc: Mel Gorman <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Steven Whitehouse <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-04-26Merge branch 'master' into for-nextJiri Kosina3-36/+16
Fast-forwarded to current state of Linus' tree as there are patches to be applied for files that didn't exist on the old branch.
2011-04-13Revert "ttm: Utilize the DMA API for pages that have TTM_PAGE_FLAG_DMA32 set."Dave Airlie1-23/+3
This reverts commit 69a07f0b117a40fcc1a479358d8e1f41793617f2. We've tracked a number of problems back to this, and Thomas thinks we should redesign this for .40/41 anyways so I'm happy to revert it. Signed-off-by: Dave Airlie <[email protected]>
2011-04-10drm: minor kref_put() nitsPaul Bolle1-1/+1
There's no need to pass kref_put() the address of a function (just the function will do just fine) nor to cast its unused return to void. Signed-off-by: Paul Bolle <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
2011-04-05drm: fix "persistant" typoJan Engelhardt2-13/+13
Signed-off-by: Jan Engelhardt <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-02-23Revert "ttm: Include the 'struct dev' when using the DMA API."Dave Airlie2-8/+7
This reverts commit 5a893fc28f0393adb7c885a871b8c59e623fd528. This causes a use after free in the ttm free alloc pages path, when it tries to get the be after the be has been destroyed. Signed-off-by: Dave Airlie <[email protected]>
2011-02-23Merge branch 'stable/ttm.pci-api.v5' of ↵Dave Airlie3-10/+40
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen into drm-next * 'stable/ttm.pci-api.v5' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen: ttm: Include the 'struct dev' when using the DMA API. nouveau/ttm/PCIe: Use dma_addr if TTM has set it. radeon/ttm/PCIe: Use dma_addr if TTM has set it. ttm: Expand (*populate) to support an array of DMA addresses. ttm: Utilize the DMA API for pages that have TTM_PAGE_FLAG_DMA32 set. ttm: Introduce a placeholder for DMA (bus) addresses.
2011-02-23drm/ttm: call driver move_notify() when doing system->tt bo movesBen Skeggs1-1/+2
Nouveau doesn't have enough information at ttm_backend_func.bind() time to implement things like tiled GART, or to keep a buffer at a constant address in the GPU virtual address space no matter where in physical memory it's placed. To resolve this, nouveau will handle binding of all buffers to the GPU itself from the move_notify() hook. This commit ensures it's called for all buffer moves. Talked to Dave about the impact on radeon, which uses move_notify, it doesn't look like anything should break there. Signed-off-by: Ben Skeggs <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2011-02-22ttm: Include the 'struct dev' when using the DMA API.Konrad Rzeszutek Wilk2-7/+8
This makes the accounting when using 'debug_dma_dump_mappings()' and CONFIG_DMA_API_DEBUG=y be assigned to the correct device instead of 'fallback'. No functional change - just cosmetic. Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
2011-01-27ttm: Expand (*populate) to support an array of DMA addresses.Konrad Rzeszutek Wilk2-2/+3
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 <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Tested-by: Ian Campbell <[email protected]>
2011-01-27ttm: Utilize the DMA API for pages that have TTM_PAGE_FLAG_DMA32 set.Konrad Rzeszutek Wilk1-3/+23
For pages that have the TTM_PAGE_FLAG_DMA32 flag set we use the DMA API. We save the bus address in our array which we use to program the GART (see "radeon/ttm/PCIe: Use dma_addr if TTM has set it." and "nouveau/ttm/PCIe: Use dma_addr if TTM has set it."). The reason behind using the DMA API is that under Xen we would end up programming the GART with the bounce buffer (SWIOTLB) DMA address instead of the physical DMA address of the TTM page. The reason being that alloc_page with GFP_DMA32 does not allocate pages under the the 4GB mark when running under Xen hypervisor. Under baremetal this means we do the DMA API call earlier instead of when we program the GART. For details please refer to: https://lkml.org/lkml/2011/1/7/251 [v2: Fixed indentation, revised desc, added Reviewed-by] Reviewed-by: Thomas Hellstrom <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Tested-by: Ian Campbell <[email protected]>
2011-01-27ttm: Introduce a placeholder for DMA (bus) addresses.Konrad Rzeszutek Wilk2-5/+13
This is right now limited to only non-pool constructs. [v2: Fixed indentation issues, add review-by tag] Reviewed-by: Thomas Hellstrom <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Tested-by: Ian Campbell <[email protected]>
2011-01-10Merge branch 'drm-core-next' of ↵Linus Torvalds4-111/+381
git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6 * 'drm-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: (390 commits) drm/radeon/kms: disable underscan by default drm/radeon/kms: only enable hdmi features if the monitor supports audio drm: Restore the old_fb upon modeset failure drm/nouveau: fix hwmon device binding radeon: consolidate asic-specific function decls for pre-r600 vga_switcheroo: comparing too few characters in strncmp() drm/radeon/kms: add NI pci ids drm/radeon/kms: don't enable pcie gen2 on NI yet drm/radeon/kms: add radeon_asic struct for NI asics drm/radeon/kms/ni: load default sclk/mclk/vddc at pm init drm/radeon/kms: add ucode loader for NI drm/radeon/kms: add support for DCE5 display LUTs drm/radeon/kms: add ni_reg.h drm/radeon/kms: add bo blit support for NI drm/radeon/kms: always use writeback/events for fences on NI drm/radeon/kms: adjust default clock/vddc tracking for pm on DCE5 drm/radeon/kms: add backend map workaround for barts drm/radeon/kms: fill gpu init for NI asics drm/radeon/kms: add disabled vbios accessor for NI asics drm/radeon/kms: handle NI thermal controller ...
2010-12-24drm/ttm: use cancel_delayed_work_sync() in ttm_boTejun Heo1-2/+1
Make ttm_bo::ttm_bo_device_release call cancel_delayed_work_sync() instead of calling cancel_delayed_work() followed by flush_scheduled_work(). This is to prepare for the deprecation and removal of flush_scheduled_work(). Signed-off-by: Tejun Heo <[email protected]> Cc:: Thomas Hellstrom <[email protected]> Cc:: Dave Airlie <[email protected]>
2010-12-16drm/ttm: delay freeing of old node during move_memcpy until after iounmapBen Skeggs1-1/+1
Drivers using their own implementation of io_mem_reserve/io_mem_free are likely to store the tracking information for the map in mem.mm_node, so it can't be freed while still mapped. Signed-off-by: Ben Skeggs<[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2010-11-22drm/ttm: Fix up io_mem_reserve / io_mem_free callingThomas Hellstrom3-30/+166
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 <[email protected]> Reviewed-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2010-11-22drm/ttm/vmwgfx: Have TTM manage the validation sequence.Thomas Hellstrom2-1/+5
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 <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2010-11-22drm/ttm: Improved fencing of buffer object listsThomas Hellstrom2-14/+33
Drastically reduce the number of spin lock / unlock operations by performing unreserving and fencing under global locks. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jerome Glisse <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2010-11-22drm/ttm/radeon/nouveau: Kill the bo lock in favour of a bo device fence_lockThomas Hellstrom4-37/+38
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 <[email protected]> Reviewed-by: Jerome Glisse <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2010-11-22drm/ttm: Don't deadlock on recursive multi-bo reservationsThomas Hellstrom1-3/+12
Add an aid for the driver to detect deadlocks on multi-bo reservations Update documentation. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jerome Glisse <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2010-11-22drm/ttm: Optimize ttm_eu_backoff_reservationThomas Hellstrom1-7/+8
Avoid the ttm_bo_unreserve() spinlocks by calling ttm_eu_backoff_reservation_locked under the lru spinlock. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jerome Glisse <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2010-11-22drm/ttm: Use kref_sub instead of repeatedly calling kref_putThomas Hellstrom1-4/+2
Signed-off-by: Thomas Hellstrom <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2010-11-22drm/ttm: Add a bo list reserve fastpath (v2)Dave Airlie2-27/+129
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 <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2010-11-18drm/ttm: Fix up a theoretical deadlockThomas Hellstrom1-0/+11
A process suspended waiting for a higher sequence or no sequence to unreserve, a bo may be beaten to the reservation by a process with a lower sequence. In that case the first process should give up trying to reserve and return -EAGAIN. In order for that to happen, we must wake waiting processes when we change sequence, so that they have a chance to detect the new sequence. Signed-off-by: Thomas Hellstrom <[email protected]> Signed-off-by: Dave Airlie <[email protected]>