aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/ttm/ttm_bo_util.c
AgeCommit message (Collapse)AuthorFilesLines
2020-11-09drm/ttm: Add vmap/vunmap to TTM and TTM GEM helpersThomas Zimmermann1-0/+72
The new functions ttm_bo_{vmap,vunmap}() map and unmap a TTM BO in kernel address space. The mapping's address is returned as struct dma_buf_map. Each function is a simplified version of TTM's existing kmap code. Both functions respect the memory's location ani/or writecombine flags. On top TTM's functions, GEM TTM helpers got drm_gem_ttm_{vmap,vunmap}(), two helpers that convert a GEM object into the TTM BO and forward the call to TTM's vmap/vunmap. These helpers can be dropped into the rsp GEM object callbacks. v5: * use size_t for storing mapping size (Christian) * ignore premapped memory areas correctly in ttm_bo_vunmap() * rebase onto latest TTM interfaces (Christian) * remove BUG() from ttm_bo_vmap() (Christian) v4: * drop ttm_kmap_obj_to_dma_buf() in favor of vmap helpers (Daniel, Christian) Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Christian König <[email protected]> Acked-by: Daniel Vetter <[email protected]> Tested-by: Sam Ravnborg <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-23drm/ttm: remove overlapping memcpy supportDave Airlie1-16/+3
remove the overlapping memcp support as it's never used. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-21drm/ttm: remove move to new and inline into remainging place.Dave Airlie1-20/+0
This show the remaining bind callback, which my next series of patches will aim to remove. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-21drm/ttm: add move to system into driversDave Airlie1-21/+0
This moves the to system move into the drivers, and moves all the unbinds in the move path under driver control Note: radeon/nouveau already wait so don't duplicate it. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-21drm/ttm: minor cleanup to move to systemDave Airlie1-3/+1
resource free already sets the domain to system, and old_mem isn't really needed. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-21drm/ttm: move some move binds into the driversDave Airlie1-1/+0
This just gives the driver control over some of the bind paths. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-20drm/ttm: drop ttm_bo_move_ttm wrapperDave Airlie1-19/+0
The apis to move old/new are in place everywhere so this is no longer needed. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-20drm/ttm: add move old to system to drivers.Dave Airlie1-2/+3
Uninline ttm_bo_move_ttm. Eventually want to unhook the unbind out. Reviewed-by: Ben Skeggs <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-20drm/ttm: use new move interface for known system->ttm movesDave Airlie1-0/+1
In all 3 drivers there is a case where the driver knows the bo is in SYSTEM so don't call the api that checks that. Reviewed-by: Ben Skeggs <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-20drm/ttm: split out the move to system from move ttm codeDave Airlie1-14/+25
Reviewed-by: Ben Skeggs <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-20drm/ttm: refactor out common code to setup a new tt backed resourceDave Airlie1-11/+23
This factors out the code to setup non-system tt. The same code was used twice in the move paths. Reviewed-by: Ben Skeggs <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-19drm/ttm: drop free old node wrapper.Dave Airlie1-8/+3
This isn't really used anymore, if drivers needs it later, just add back an inline wrapper. Reviewed-by: Christian König <[email protected]> Reviewed-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-10-15drm/ttm: nuke caching placement flagsChristian König1-7/+3
Changing the caching on the fly never really worked flawlessly. So stop this completely and just let drivers specific the desired caching in the tt or bus object. Signed-off-by: Christian König <[email protected]> Reviewed-by: Michael J. Ruhl <[email protected]> Link: https://patchwork.freedesktop.org/patch/394256/
2020-10-15drm/ttm: use caching instead of placement for ttm_io_protChristian König1-9/+14
Instead of the placement flags use the caching of the bus mapping or tt object for the page protection flags. Signed-off-by: Christian König <[email protected]> Reviewed-by: Michael J. Ruhl <[email protected]> Link: https://patchwork.freedesktop.org/patch/394255/
2020-09-24drm/ttm: add ttm_bo_pin()/ttm_bo_unpin() v2Christian König1-1/+1
As an alternative to the placement flag add a pin count to the ttm buffer object. v2: add dma_resv_assert_help() calls Signed-off-by: Christian König <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Huang Rui <[email protected]> Link: https://patchwork.freedesktop.org/patch/391596/?series=81973&rev=1
2020-09-24drm/ttm: add bo wait that takes a ctx wrapper.Dave Airlie1-2/+2
I'm thinking of pushing the wait into the drivers. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-18drm/ttm: drop special pipeline accel cleanup function.Dave Airlie1-57/+32
The two accel cleanup paths were mostly the same once refactored. Just pass a bool to say if the evictions are to be pipelined. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-18drm/ttm: make common function for wait/free node path.Dave Airlie1-18/+20
The pipeline and accel cleansups has similiar paths here. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-18drm/ttm: move ghost object creation to a common functionDave Airlie1-62/+42
Both accel cleanup and pipeline move had the same code, make a single function for it. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-18drm/ttm: add a simple assign mem to bo wrapperDave Airlie1-12/+6
This pattern is called in a few places, just clean it up. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-18drm/ttm: protect against reentrant bind in the driversDave Airlie1-5/+0
This moves the generic tracking into the drivers and protects against reentrancy in the drivers. It fixes up radeon and agp to be able to query the bound status as that is required. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-16drm/ttm: split bound/populated flags.Dave Airlie1-4/+11
Move bound up into the bo object, and keep populated with the tt object. The ghost object handling needs to follow the flags at the bo level now instead of it being part of the ttm tt object. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-16drm/ttm: move ttm binding/unbinding out of ttm_tt paths.Dave Airlie1-3/+2
Move these up to the bo level, moving ttm_tt to just being backing store. Next step is to move the bound flag out. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-16drm/ttm: split populate out from binding.Dave Airlie1-1/+6
Drivers have to call populate themselves now before binding. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-16drm/ttm: tt destroy move null check to outer function.Dave Airlie1-0/+1
This just makes things easier later. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-16drm/ttm: wrap tt destroy. (v2)Dave Airlie1-12/+6
All places this was called was using bo->ttm either direct or indirectly. v2: move to ttm_bo Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-16drm/ttm/tt: add wrappers to set tt state.Dave Airlie1-1/+1
This adds 2 getters and 4 setters, however unbound and populated are currently the same thing, this will change, it also drops a BUG_ON that seems not that useful. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-11drm/ttm: nuke memory type flagsChristian König1-2/+0
It's not supported to specify more than one of those flags. So it never made sense to make this a flag in the first place. Nuke the flags and specify directly which memory type to use. Signed-off-by: Christian König <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/389826/?series=81551&rev=1
2020-09-08drm/ttm: merge offset and base in ttm_bus_placementChristian König1-11/+6
This is used by TTM to communicate the physical address which should be used with ioremap(), ioremap_wc(). We don't need to separate the base and offset in any way here. Signed-off-by: Christian König <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/389457/
2020-09-08drm/ttm: remove bdev from ttm_ttDave Airlie1-7/+7
I want to split this structure up and use it differently, step one remove bdev pointer from it and pass it explicitly. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-09-03drm/ttm: remove io_reserve_lru handling v3Christian König1-108/+9
That is not used any more. v2: keep the NULL checks in TTM. v3: remove unused variable Signed-off-by: Christian König <[email protected]> Acked-by: Daniel Vetter <[email protected]> Reviewed-by: Ben Skeggs <[email protected]> Link: https://patchwork.freedesktop.org/patch/388646/
2020-08-24drm/ttm: drop bus.size from bus placement.Dave Airlie1-3/+4
This is always calculated the same, and only used in a couple of places. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-08-24drm/ttm: init mem->bus in common code.Dave Airlie1-0/+5
The drivers all do the same thing here. Reviewed-by: Christian König <[email protected]> for both. Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-08-12Merge drm/drm-next into drm-misc-nextThomas Zimmermann1-5/+2
Backmerging drm-next into drm-misc-next for nouveau and panel updates. Resolves a conflict between ttm and nouveau, where struct ttm_mem_res got renamed to struct ttm_resource. Signed-off-by: Thomas Zimmermann <[email protected]>
2020-08-12drm/ttm: give resource functions their own [ch] filesChristian König1-2/+2
This is a separate object we work within TTM. Signed-off-by: Christian König <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/384338/?series=80346&rev=1
2020-08-12drm/ttm: revert "drm/ttm: make TT creation purely optional v3"Christian König1-5/+2
This reverts commit 2ddef17678bc2ea1d20517dd2b4ed4aa967ffa8b. As it turned out VMWGFX needs a much wider audit to fix this. Signed-off-by: Christian König <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-08-06drm/ttm: rename ttm_mem_reg to ttm_resource.Dave Airlie1-23/+23
This name better reflects what the object does. I didn't rename all the pointers it seemed too messy. Signed-off-by: Dave Airlie <[email protected]> Acked-by: Christian König <[email protected]> Reviewed-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-08-06drm/ttm: rename ttm_mem_type_manager -> ttm_resource_manager.Dave Airlie1-13/+13
This name makes a lot more sense, since these are about managing driver resources rather than just memory ranges. Acked-by: Christian König <[email protected]> Reviewed-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-08-06drm/ttm: add wrapper to get manager from bdev.Dave Airlie1-10/+10
This will allow different abstractions later. Acked-by: Christian König <[email protected]> Reviewed-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-07-31drm/ttm: remove TTM_MEMTYPE_FLAG_FIXED v2Christian König1-6/+6
Instead use a boolean field in the memory manager structure. Also invert the meaning of the field since the use of a TT structure is the special case here. v2: cleanup zero init. Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Reviewed-by: Thomas Zimmermann <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/382079/
2020-07-21drm/ttm: cleanup coding style and implementation.Christian König1-49/+48
Only functional change is to always keep io_reserved_count up to date for debugging even when it is not used otherwise. Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/378242/
2020-07-21drm/ttm: remove io_reserve_fastpath flagChristian König1-4/+4
Just use the use_io_reserve_lru flag. It doesn't make much sense to have two flags. Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/378238/
2020-07-21drm/ttm: cleanup io_mem interface with nouveauChristian König1-2/+2
Nouveau is the only user of this functionality and evicting io space on -EAGAIN is really a misuse of the return code. Instead switch to using -ENOSPC here which makes much more sense and simplifies the code. This could unbreak something as we now cleanly return EAGAIN, but the chance for this are rather low. Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/378237/
2020-06-29drm/ttm: make TT creation purely optional v3Christian König1-2/+5
We only need the page array when the BO is about to be accessed. So not only populate, but also create it on demand. v2: move NULL check into ttm_tt_create() v3: fix the occurrence in ttm_bo_kmap_ttm as well Signed-off-by: Christian König <[email protected]> Reviewed-by: Michael J. Ruhl <[email protected]> Link: https://patchwork.freedesktop.org/patch/373182/
2020-06-04drm: remove drm specific kmap_atomic codeIra Weiny1-52/+4
kmap_atomic_prot() is now exported by all architectures. Use this function rather than open coding a driver specific kmap_atomic. [[email protected]: include linux/highmem.h] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ira Weiny <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Christian König <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Acked-by: Daniel Vetter <[email protected]> Cc: Al Viro <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Chris Zankel <[email protected]> Cc: Dan Williams <[email protected]> Cc: Dave Hansen <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Helge Deller <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Max Filippov <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
2020-03-11Merge v5.6-rc5 into drm-nextDave Airlie1-0/+1
Requested my mripard for some misc patches that need this as a base. Signed-off-by: Dave Airlie <[email protected]>
2020-02-26drm/ttm: fix leaking fences via ttm_buffer_object_transferAhzo1-0/+1
Set the drm_device to NULL, so that the newly created buffer object doesn't appear to use the embedded gem object. This is necessary, because otherwise no corresponding dma_resv_fini for the dma_resv_init is called, resulting in a memory leak. The dma_resv_fini in ttm_bo_release_list is only called if the embedded gem object is not used, which is determined by checking if the drm_device is NULL. Bug: https://gitlab.freedesktop.org/drm/amd/issues/958 Fixes: 1e053b10ba60 ("drm/ttm: use gem reservation object") Reviewed-by: Christian König <[email protected]> Signed-off-by: Ahzo <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Signed-off-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/355089/
2020-02-17Merge v5.6-rc2 into drm-misc-nextMaxime Ripard1-2/+2
Lyude needs some patches in 5.6-rc2 and we didn't bring drm-misc-next forward yet, so it looks like a good occasion. Signed-off-by: Maxime Ripard <[email protected]>
2020-02-12drm/ttm: rework BO delayed delete. v2Christian König1-1/+0
This patch reworks the whole delayed deletion of BOs which aren't idle. Instead of having two counters for the BO structure we resurrect the BO when we find that a deleted BO is not idle yet. This has many advantages, especially that we don't need to increment/decrement the BOs reference counter any more when it moves on the LRUs. v2: remove duplicate ttm_tt_destroy, fix holde lock for LRU move Signed-off-by: Christian König <[email protected]> Reviewed-by: xinhui pan <[email protected]> Link: https://patchwork.freedesktop.org/patch/352912/
2020-02-11drm/ttm: refine ghost BO resv criteriaChristian König1-1/+1
Ghost BOs need to stick with the resv object only when the origin is imported. This is a low hanging fruit to avoid OOM situations on evictions. Signed-off-by: Christian König <[email protected]> Reviewed-by: xinhui pan <[email protected]> Link: https://patchwork.freedesktop.org/patch/352740/