summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/virtio/virtgpu_object.c
AgeCommit message (Collapse)AuthorFilesLines
2019-09-04drm/virtio: pass gem reservation object to ttm initGerd Hoffmann1-1/+2
With this gem and ttm will use the same reservation object, so mixing and matching ttm / gem reservation helpers should work fine. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20190829103301.3539-2-kraxel@redhat.com
2019-08-28drm/virtio: module_param_named() requires linux/moduleparam.hStephen Rothwell1-0/+2
Fixes: 3e93bc2a58aa ("drm/virtio: make resource id workaround runtime switchable.") Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Link: http://patchwork.freedesktop.org/patch/msgid/20190828185516.22b03da8@canb.auug.org.au Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-08-27drm/virtio: make resource id workaround runtime switchable.Gerd Hoffmann1-20/+24
Also update the comment with a reference to the virglrenderer fix. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20190822102614.18164-1-kraxel@redhat.com
2019-03-28drm/virtio: rework resource creation workflow.Gerd Hoffmann1-3/+44
This patch moves the virtio_gpu_cmd_create_resource() call (which notifies the host about the new resource created) into the virtio_gpu_object_create() function. That way we can call virtio_gpu_cmd_create_resource() before ttm_bo_init(), so the host already knows about the object when ttm initializes the object and calls our driver callbacks. Specifically the object is already created when the virtio_gpu_ttm_tt_bind() callback invokes virtio_gpu_object_attach(), so the extra virtio_gpu_object_attach() calls done after virtio_gpu_object_create() are not needed any more. The fence support for the create ioctl becomes a bit more tricky though. The code moved into virtio_gpu_object_create() too. We first submit the (fenced) virtio_gpu_cmd_create_resource() command, then initialize the ttm object, and finally attach just created object to the fence for the command in case it didn't finish yet. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Noralf Trønnes <noralf@tronnes.org> Link: http://patchwork.freedesktop.org/patch/msgid/20190318113332.10900-6-kraxel@redhat.com
2019-03-28drm/virtio: use struct to pass params to virtio_gpu_object_create()Gerd Hoffmann1-17/+12
Create virtio_gpu_object_params, use that to pass object parameters to virtio_gpu_object_create. This is just the first step, followup patches will add more parameters to the struct. The plan is to use the struct for all object parameters. Drop unused "kernel" parameter for virtio_gpu_alloc_object(), it is unused and always false. Also drop "pinned" parameter. virtio-gpu doesn't shuffle around objects, so effecively they all are pinned anyway. Hardcode TTM_PL_FLAG_NO_EVICT so ttm knows. Doesn't change much for the moment as virtio-gpu supports TTM_PL_FLAG_TT only so there is no opportunity to move around objects. That'll probably change in the future though. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Noralf Trønnes <noralf@tronnes.org> Link: http://patchwork.freedesktop.org/patch/msgid/20190318113332.10900-3-kraxel@redhat.com
2019-02-11drm/virtio: do NOT reuse resource idsGerd Hoffmann1-0/+13
Bisected guest kernel changes crashing qemu. Landed at "6c1cd97bda drm/virtio: fix resource id handling". Looked again, and noticed we where not only leaking *some* ids, but *all* ids. The old code never ever called virtio_gpu_resource_id_put(). So, commit 6c1cd97bda effectively makes the linux kernel starting re-using IDs after releasing them, and apparently virglrenderer can't deal with that. Oops. This patch puts a temporary stopgap into place for the 5.0 release. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190208140409.15280-1-kraxel@redhat.com
2018-11-14drm/virtio: Use IDAs more efficientlyMatthew Wilcox1-3/+3
0-based IDAs are more efficient than any other base. Convert the 1-based IDAs to be 0-based. Signed-off-by: Matthew Wilcox <willy@infradead.org> Link: http://patchwork.freedesktop.org/patch/msgid/20181030165352.13065-2-willy@infradead.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-11-14drm/virtio: Handle error from virtio_gpu_resource_id_getMatthew Wilcox1-2/+11
ida_alloc() can return -ENOMEM in the highly unlikely case we run out of memory. The current code creates an object with an invalid ID. Signed-off-by: Matthew Wilcox <willy@infradead.org> Link: http://patchwork.freedesktop.org/patch/msgid/20181030165352.13065-1-willy@infradead.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-10-29drm/virtio: Replace IDRs with IDAsMatthew Wilcox1-10/+2
These IDRs were only being used to allocate unique numbers, not to look up pointers, so they can use the more space-efficient IDA instead. Signed-off-by: Matthew Wilcox <willy@infradead.org> Link: http://patchwork.freedesktop.org/patch/msgid/20180926160031.15721-2-willy@infradead.org [ kraxel: resolve conflict ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-10-29drm/virtio: fix resource id handlingGerd Hoffmann1-0/+23
Move virtio_gpu_resource_id_{get,put} to virtgpu_object.c and make them static. Allocate and free the id on creation and destroy, drop all other calls. That way objects have a valid handle for the whole lifetime of the object. Also fixes ids leaking. Worst offender are dumb buffers, and I think some error paths too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20181019061847.18958-7-kraxel@redhat.com
2018-10-29drm/virtio: track created object stateGerd Hoffmann1-1/+1
Track whenever the virtio_gpu_object is already created (i.e. host knows about it) in a new variable. Add checks to virtio_gpu_object_attach() to do nothing on objects not created yet. Make virtio_gpu_ttm_bo_destroy() use the new variable too, instead of expecting hw_res_handle indicating the object state. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20181019061847.18958-2-kraxel@redhat.com
2018-09-26virtio: Rework virtio_gpu_object_kmap()Ezequiel Garcia1-8/+3
Currently, virtio_gpu_object_kmap() is only called by virtio_gpufb_create(), when a DRM framebuffer is created. Thus, instead of returning the vmap'ed address, emit a warning if virtio_gpu_object_kmap is called on an already mapped object. With this change, kmap/kunmap calls are now balanced. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20180925161606.17980-3-ezequiel@collabora.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-09-26virtio: Add virtio_gpu_object_kunmap()Ezequiel Garcia1-0/+8
Implement a virtio_gpu_object_kunmap() to unmap the kernel mapping, and use it in the TTM object destroy path. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20180925161606.17980-2-ezequiel@collabora.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-02-26drm/ttm: drop persistent_swap_storage from ttm_bo_init and coChristian König1-1/+1
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 <christian.koenig@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2017-12-28drm/ttm: use an operation ctx for ttm_tt_populate in ttm_bo_driver (v2)Roger He1-1/+5
forward the operation context to ttm_tt_populate as well, and the ultimate goal is swapout enablement for reserved BOs. v2: squash in fix for vboxvideo Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Roger He <Hongbo.He@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2017-04-07drm/virtio: don't leak bo on drm_gem_object_init failureGerd Hoffmann1-1/+3
Reported-by: 李强 <liqiang6-s@360.cn> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170406155941.458-1-kraxel@redhat.com
2016-05-04drm/ttm: remove lazy parameter from ttm_bo_waitChristian König1-1/+1
Not used any more. Reviewed-by: Sinclair Yeh <syeh@vmware.com> Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2016-05-04drm/ttm: remove use_ticket parameter from ttm_bo_reserveChristian König1-1/+1
Not used any more. Reviewed-by: Sinclair Yeh <syeh@vmware.com> Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2015-10-16virtio-gpu: don't free things on ttm_bo_init failureDave Airlie1-8/+3
ttm_bo_init will call the destroy callback which will do all this, this was causing a double free. Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-06-03Add virtio gpu driver.Dave Airlie1-0/+170
This patch adds a kms driver for the virtio gpu. The xorg modesetting driver can handle the device just fine, the framebuffer for fbcon is there too. Qemu patches for the host side are under review currently. The pci version of the device comes in two variants: with and without vga compatibility. The former has a extra memory bar for the vga framebuffer, the later is a pure virtio device. The only concern for this driver is that in the virtio-vga case we have to kick out the firmware framebuffer. Initial revision has only 2d support, 3d (virgl) support requires some more work on the qemu side and will be added later. Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com>