aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
AgeCommit message (Collapse)AuthorFilesLines
2018-07-03drm/vmwgfx: Move buffer object related code to vmwgfx_bo.cThomas Hellstrom1-619/+21
It makes more sense to have all the buffer object related code in a single file rather than splitting it up between the resource code and buffer object pinning utilities. Place all buffer object related code in vmwgfx_bo.c. Fix up headers and export resource functionality when needed in the buffer object code. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]> Reviewed-by: Deepak Rawat <[email protected]>
2018-07-03drm/vmwgfx: Replace vmw_dma_buffer with vmw_buffer_objectThomas Hellstrom1-139/+141
Initially vmware buffer objects were only used as DMA buffers, so the name DMA buffer was a natural one. However, currently they are used also as dumb buffers and MOBs backing guest backed objects so renaming them to buffer objects is logical. Particularly since there is a dmabuf subsystem in the kernel where a dma buffer means something completely different. This also renames user-space api structures and IOCTL names correspondingly, but the old names remain defined for now and the ABI hasn't changed. There are a couple of minor style changes to make checkpatch happy. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]> Reviewed-by: Deepak Rawat <[email protected]>
2018-06-29drm/vmwgfx: add SPDX idenitifier and clarify licenseDirk Hohndel (VMware)1-2/+2
This is dual licensed under GPL-2.0 or MIT. vmwgfx_msg.h is the odd one out that is GPL-2.0+ or MIT. Acked-by: Thomas Gleixner <[email protected]> Signed-off-by: Dirk Hohndel (VMware) <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2018-03-22drm/vmwgfx: Avoid pinning fbdev framebuffersThomas Hellstrom1-0/+23
fbdev framebuffers were previously pinned to be able to keep them mapped across updates. This commit introduces a mechanism that instead revalidates the map on each update, keeping the map cached across updates. The cached map is torn down if the underlying pages change. Typically on buffer object moves and swapouts. This should be nicer to the system when we have resource contention. Testing done: Basic fbdev functionality under Fedora 27. Signed-off-by: Thomas Hellstrom <[email protected]> Signed-off-by: Sinclair Yeh <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Deepak Rawat <[email protected]>
2018-02-26drm/ttm: drop persistent_swap_storage from ttm_bo_init and coChristian König1-2/+2
Never used as parameter, the only driver actually using this is nouveau and there it is initialized after the BO is initialized. Signed-off-by: Christian König <[email protected]> Reviewed-by: Michel Dänzer <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
2017-12-06drm/ttm: add operation ctx to ttm_bo_validate v2Christian König1-2/+4
Give moving a BO into place an operation context to work with. v2: rebased Signed-off-by: Christian König <[email protected]> Reviewed-by: Michel Dänzer <[email protected]> Reviewed-by: Chunming Zhou <[email protected]> Tested-by: Dieter Nützel <[email protected]> Tested-by: Michel Dänzer <[email protected]> Acked-by: Felix Kuehling <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
2017-07-17drm/vmwgfx: Fix NULL pointer comparisonRavikant B Sharma1-2/+2
Replace direct comparisons to NULL i.e. 'x == NULL' with '!x'. As per coding standard. Signed-off-by: Ravikant B Sharma <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]> Signed-off-by: Sinclair Yeh <[email protected]>
2017-04-11Backmerge tag 'v4.11-rc6' into drm-nextDave Airlie1-2/+2
Linux 4.11-rc6 drm-misc needs 4.11-rc5, may as well fix conflicts with rc6.
2017-03-31drm/vmwgfx: Re-implement the stream resource as a simple resource.Thomas Hellstrom1-254/+0
Provide and document a reference implementation. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]>
2017-03-30drm/ttm, drm/vmwgfx: Relax permission checking when opening surfacesThomas Hellstrom1-2/+2
Previously, when a surface was opened using a legacy (non prime) handle, it was verified to have been created by a client in the same master realm. Relax this so that opening is also allowed recursively if the client already has the surface open. This works around a regression in svga mesa where opening of a shared surface is used recursively to obtain surface information. Cc: <[email protected]> Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]>
2017-03-01gpu: drm: drivers: Convert printk(KERN_<LEVEL> to pr_<level>Joe Perches1-2/+2
Use a more common logging style. Miscellanea: o Coalesce formats and realign arguments o Neaten a few macros now using pr_<level> Signed-off-by: Joe Perches <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Sinclair Yeh <[email protected]> Acked-by: Patrik Jakobsson <[email protected]> Acked-by: Tomi Valkeinen <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/76355db47b31668bb64d996865ceee53bd66b11f.1488285953.git.joe@perches.com
2017-01-26drm/vmwgfx: Annotate ignored return valuesThomas Hellstrom1-2/+2
Cast return values to void since they, based on input arguments, are known to be zero. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]> Reviewed-by: Charmaine Lee <[email protected]>
2016-10-25dma-buf: Rename struct fence to dma_fenceChris Wilson1-1/+1
I plan to usurp the short name of struct fence for a core kernel struct, and so I need to rename the specialised fence/timeline for DMA operations to make room. A consensus was reached in https://lists.freedesktop.org/archives/dri-devel/2016-July/113083.html that making clear this fence applies to DMA operations was a good thing. Since then the patch has grown a bit as usage increases, so hopefully it remains a good thing! (v2...: rebase, rerun spatch) v3: Compile on msm, spotted a manual fixup that I broke. v4: Try again for msm, sorry Daniel coccinelle script: @@ @@ - struct fence + struct dma_fence @@ @@ - struct fence_ops + struct dma_fence_ops @@ @@ - struct fence_cb + struct dma_fence_cb @@ @@ - struct fence_array + struct dma_fence_array @@ @@ - enum fence_flag_bits + enum dma_fence_flag_bits @@ @@ ( - fence_init + dma_fence_init | - fence_release + dma_fence_release | - fence_free + dma_fence_free | - fence_get + dma_fence_get | - fence_get_rcu + dma_fence_get_rcu | - fence_put + dma_fence_put | - fence_signal + dma_fence_signal | - fence_signal_locked + dma_fence_signal_locked | - fence_default_wait + dma_fence_default_wait | - fence_add_callback + dma_fence_add_callback | - fence_remove_callback + dma_fence_remove_callback | - fence_enable_sw_signaling + dma_fence_enable_sw_signaling | - fence_is_signaled_locked + dma_fence_is_signaled_locked | - fence_is_signaled + dma_fence_is_signaled | - fence_is_later + dma_fence_is_later | - fence_later + dma_fence_later | - fence_wait_timeout + dma_fence_wait_timeout | - fence_wait_any_timeout + dma_fence_wait_any_timeout | - fence_wait + dma_fence_wait | - fence_context_alloc + dma_fence_context_alloc | - fence_array_create + dma_fence_array_create | - to_fence_array + to_dma_fence_array | - fence_is_array + dma_fence_is_array | - trace_fence_emit + trace_dma_fence_emit | - FENCE_TRACE + DMA_FENCE_TRACE | - FENCE_WARN + DMA_FENCE_WARN | - FENCE_ERR + DMA_FENCE_ERR ) ( ... ) Signed-off-by: Chris Wilson <[email protected]> Reviewed-by: Gustavo Padovan <[email protected]> Acked-by: Sumit Semwal <[email protected]> Acked-by: Christian König <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
2016-10-12drm/vmwgfx: Remove call to reservation_object_test_signaled_rcu before waitChris Wilson1-4/+2
Since fence_wait_timeout_reservation_object_wait_timeout_rcu() with a timeout of 0 becomes reservation_object_test_signaled_rcu(), we do not need to handle such conversion in the caller. The only challenge are those callers that wish to differentiate the error code between the nonblocking busy check and potentially blocking wait. Signed-off-by: Chris Wilson <[email protected]> Cc: Sinclair Yeh <[email protected]> Cc: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Sumit Semwal <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
2016-05-04drm/ttm: remove lazy parameter from ttm_bo_waitChristian König1-2/+2
Not used any more. Reviewed-by: Sinclair Yeh <[email protected]> Signed-off-by: Christian König <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
2016-05-04drm/ttm: remove use_ticket parameter from ttm_bo_reserveChristian König1-4/+3
Not used any more. Reviewed-by: Sinclair Yeh <[email protected]> Signed-off-by: Christian König <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
2015-09-14drm/vmwgfx: Fix up user_dmabuf refcountingThomas Hellstrom1-8/+21
If user space calls unreference on a user_dmabuf it will typically kill the struct ttm_base_object member which is responsible for the user-space visibility. However the dmabuf part may still be alive and refcounted. In some situations, like for shared guest-backed surface referencing/opening, the driver may try to reference the struct ttm_base_object member again, causing an immediate kernel warning and a later kernel NULL pointer dereference. Fix this by always maintaining a reference on the struct ttm_base_object member, in situations where it might subsequently be referenced. Cc: <[email protected]> Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]>
2015-08-12drm/vmwgfx: Fix copyright headersSinclair Yeh1-1/+1
Updating and fixing copyright headers. Bump version minor to signal vgpu10 support. Signed-off-by: Sinclair Yeh <[email protected]> Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]>
2015-08-12drm/vmwgfx: Add DX query support. Various fixes.Sinclair Yeh1-3/+98
Add support for vgpu10 queries. Functional- and formatting fixes. Signed-off-by: Sinclair Yeh <[email protected]> Signed-off-by: Thomas Hellstrom <[email protected]>
2015-08-12drm/vmwgfx: Initial DX supportThomas Hellstrom1-14/+34
Initial DX support. Co-authored with Sinclair Yeh, Charmaine Lee and Jakob Bornecrantz. Signed-off-by: Thomas Hellstrom <[email protected]> Signed-off-by: Sinclair Yeh <[email protected]> Signed-off-by: Charmaine Lee <[email protected]>
2015-08-05drm/vmwgfx: Kill a bunch of sparse warningsThomas Hellstrom1-10/+7
We're giving up all attempts to keep cpu- and device byte ordering separate. This silences sparse when compiled using make C=2 CF="-D__CHECK_ENDIAN__" Signed-off-by: Thomas Hellstrom <[email protected]>
2015-08-05drm/vmwgfx: Convert screen targets to new helpers v3Thomas Hellstrom1-1/+1
Also implements the missing readback function and fixes page flip in case of no event. v2: - Adapt to the work done for screen targets for 2d, in particular Handle proxy surface updates. - Remove execbuf quirks since we now use fifo reserve / commit. - Revert the initial placement of vmw dma buffers. v3: Address review comments. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]>
2015-08-05drm/vmwgfx: Add kms helpers for dirty- and readback functionsThomas Hellstrom1-8/+10
We need to make the dirty- and readback functions callable without a struct drm_file pointer. We also need to unify the handling of dirty- and readback cliprects that are now implemented in various places across the kms system, som add helpers to facilitate this. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]>
2015-08-05drm/vmwgfx: Introduce a pin count to allow for recursive pinning v2Thomas Hellstrom1-16/+20
v2: Fix dma buffer validation on resource pinning. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]>
2015-08-05drm/vmwgfx: Replace SurfaceDMA usage with SurfaceCopy in 2D VMsSinclair Yeh1-1/+1
This patch address the following underlying issues with SurfaceDMA * SurfaceDMA command does not work in a 2D VM, but we can wrap a proxy surface around the same DMA buffer and use the SurfaceCopy command which does work in a 2D VM. * Wrapping a DMA buffer with a proxy surface also gives us an added optimization path for the case when the DMA buf dimensions match the mode. In this case, the DMA buf can be pinned as the display surface, saving an extra copy. This only works in a 2D VM because we won't be doing any rendering operations directly to the display surface. v2 * Moved is_dmabuf_proxy field to vmw_framebuffer_surface * Undone coding style changes * Addressed other issues from review Signed-off-by: Sinclair Yeh <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
2015-08-05drm/vmwgfx: Add an interface to pin a resource v3Thomas Hellstrom1-1/+90
For screen targets it appears we need to pin surfaces while they are bound as screen targets, so add a small interface to do that. v2: Always increase pin_count on pin. v3: Add missing reservation sem. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]>
2015-08-05drm/vmwgfx: Fix an overlay lockdep errorThomas Hellstrom1-6/+6
Fix a circular locking dependency between struct vmw_overlay::mutex and struct vmw_private::reservation_sem Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]>
2014-12-03drm/ttm: optionally move duplicates to a separate listChristian König1-1/+1
This patch adds an optional list_head parameter to ttm_eu_reserve_buffers. If specified duplicates in the execbuf list are no longer reported as errors, but moved to this list instead. Reviewed-by: Thomas Hellstrom <[email protected]> Signed-off-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
2014-09-30drm/ttm: add reservation_object as argument to ttm_bo_initMaarten Lankhorst1-1/+1
This allows importing reservation objects from dma-bufs. Signed-off-by: Maarten Lankhorst <[email protected]>
2014-09-11drm/ttm: allow fence to be added as sharedChristian König1-0/+5
This patch adds a new flag to the ttm_validate_buffer list to add the fence as shared to the reservation object. Signed-off-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
2014-09-02drm/vmwgfx: use rcu in vmw_user_dmabuf_synccpu_grabMaarten Lankhorst1-6/+10
Signed-off-by: Maarten Lankhorst <[email protected]>
2014-09-02drm/ttm: flip the switch, and convert to dma_fenceMaarten Lankhorst1-10/+4
Signed-off-by: Maarten Lankhorst <[email protected]>
2014-09-02drm/vmwgfx: rework to new fence interface, v2Maarten Lankhorst1-5/+4
Use the new fence interface on vmwgfx too. Signed-off-by: Maarten Lankhorst <[email protected]> --- Changes since v1: Fix a sleeping function called from invalid context in enable_signaling.
2014-09-01drm/ttm: add interruptible parameter to ttm_eu_reserve_buffersMaarten Lankhorst1-1/+1
It seems some drivers really want this as a parameter, like vmwgfx. Signed-off-by: Maarten Lankhorst <[email protected]>
2014-09-01drm/ttm: kill fence_lockMaarten Lankhorst1-10/+6
No users are left, kill it off! :D Conversion to the reservation api is next on the list, after that the functionality can be restored with rcu. Signed-off-by: Maarten Lankhorst <[email protected]>
2014-07-22drm/ttm: Fix a few sparse warningsThierry Reding1-1/+1
The final parameter to ttm_bo_reserve() is a pointer, therefore callers should use NULL instead of 0. Fixes a bunch of sparse warnings of this type: warning: Using plain integer as NULL pointer Signed-off-by: Thierry Reding <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2014-03-28drm/vmwgfx: Tighten the security around buffer mapsThomas Hellstrom1-2/+7
Make sure only buffer objects that are referenced by the client can be mapped. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]>
2014-03-28drm/vmwgfx: Use a per-device semaphore for reservation protectionThomas Hellstrom1-9/+6
Don't use a per-master semaphore (ttm lock) for reservation protection, but rather a per-device semaphore. This is needed since clients connecting using render nodes aren't master aware. The ttm lock used should probably be replaced with a reader-write semaphore once the function down_xx_interruptible() is available. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]>
2014-03-02drm/vmwgfx: Make sure backing mobs are cleared when allocated. Update driver ↵Thomas Hellstrom1-2/+1
date. Backing mob contents is propagated to user-space, so make sure backing mobs are cleared when allocated. This also accidently fix rendering errors with celestia when emulating legacy mode. Also update driver date. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]>
2014-02-05drm/vmwgfx: Reemit context bindings when necessary v2Thomas Hellstrom1-1/+10
When a context is first referenced in the command stream, make sure that all scrubbed (as a result of eviction) bindings are re-emitted. Also make sure that all bound resources are put on the resource validate list. This is needed for legacy emulation, since legacy user-space drivers will typically not re-emit shader bindings. It also removes the requirement for user-space drivers to re-emit render-target- and texture bindings. Makes suspend and hibernate now also work with legacy user-space drivers on guest-backed devices. v2: Don't rebind on legacy devices. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jakob Bornecrantz <[email protected]>
2014-01-17drm/vmwgfx: Persistent tracking of context bindingsThomas Hellstrom1-0/+1
Only scrub context bindings when a bound resource is destroyed, or when the MOB backing the context is unbound. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Zack Rusin <[email protected]>
2014-01-17drm/vmwgfx: Implement a buffer object synccpu ioctl.Thomas Hellstrom1-1/+141
This ioctl enables inter-process synchronization of buffer objects, which is needed for mesa Guest-Backed objects. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]>
2014-01-17drm/vmwgfx: Hook up guest-backed surfacesThomas Hellstrom1-1/+4
Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Zack Rusin <[email protected]>
2014-01-17drm/vmwgfx: Detach backing store from its resources when it is evictedThomas Hellstrom1-1/+44
When the backing store buffer is evicted, Issue a readback from the resources and notify the resources that they are no longer bound to a valid backing store. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Zack Rusin <[email protected]>
2014-01-17drm/vmwgfx: Add the possibility to validate a buffer as a MOBThomas Hellstrom1-0/+2
Also do basic consistency checking. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Zack Rusin <[email protected]>
2013-12-04drm/vmwgfx: Fix dma buffer memory size accountingThomas Hellstrom1-10/+44
Also request kernel ttm_buffer objects for buffer objects that obviously aren't visible to user-space, and save some device address space. The accounting was broken in a couple of ways: 1) We did not differentiate between user dma buffers and kernel dma buffers. 2) The ttm_bo_acc_size function is broken in that it a) Doesn't take into account the size of the optional dma address array, b) Doesn't take into account the fact that drivers typically embed the ttm_tt structure. This needs to be fixed in ttm, but meanwhile provide a vmwgfx-specific function to do the job. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jakob Bornecrantz <[email protected]>
2013-12-04drm/vmwgfx: Fix up and comment the dumb buffer implementationThomas Hellstrom1-27/+37
Allocation was duplicating code. Comments were missing. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jakob Bornecrantz <[email protected]>
2013-11-18drm/vmwgfx: Make vmwgfx dma buffers prime awareThomas Hellstrom1-20/+25
Should we need to share dma buffers using prime, let's make them prime aware. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jakob Bornecrantz <[email protected]>
2013-11-18drm/vmwgfx: Make surfaces prime-awareThomas Hellstrom1-1/+1
Add prime exporting and imporing operations to surfaces Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jakob Bornecrantz <[email protected]>
2013-11-18drm/vmwgfx: Fix false lockdep warningThomas Hellstrom1-10/+6
A lockdep warning is hit when evicting surfaces and reserving the backup buffer. Since this buffer can only be reserved by the process holding the surface reservation or by the buffer eviction processes that use tryreserve, there is no real deadlock here, but there's no other way to silence lockdep than to use a tryreserve. This means the reservation might fail if the buffer is about to be evicted or swapped out, but we now have code in place to handle that reasonably well. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Jakob Bornecrantz <[email protected]>