summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/virtio/virtgpu_vq.c
Commit message (Collapse)AuthorAgeFilesLines
* drm/virtio: Return proper error codes instead of -1Dmitry Osipenko2022-07-191-3/+3
| | | | | | | | | | Don't return -1 in error cases, return proper error code. The returned error codes propagate to error messages and to userspace and it's always good to have a meaningful error number for debugging purposes. Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20220630200726.1884320-10-dmitry.osipenko@collabora.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: Improve DMA API usage for shmem BOsDmitry Osipenko2022-07-191-8/+5
| | | | | | | | | | | | | DRM API requires the DRM's driver to be backed with the device that can be used for generic DMA operations. The VirtIO-GPU device can't perform DMA operations if it uses PCI transport because PCI device driver creates a virtual VirtIO-GPU device that isn't associated with the PCI. Use PCI's GPU device for the DRM's device instead of the VirtIO-GPU device and drop DMA-related hacks from the VirtIO-GPU driver. Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20220630200726.1884320-8-dmitry.osipenko@collabora.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: Check whether transferred 2D BO is shmemDmitry Osipenko2022-07-191-1/+1
| | | | | | | | | | | Transferred 2D BO always must be a shmem BO. Add check for that to prevent NULL dereference if userspace passes a VRAM BO. Cc: stable@vger.kernel.org Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20220630200726.1884320-3-dmitry.osipenko@collabora.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm: Drop drm_edid.h from drm_crtc.hVille Syrjälä2022-06-201-0/+2
| | | | | | | | | | | | | | | | | | drm_crtc.h has no need for drm_edid.h, so don't include it. Avoids useless rebuilds of the entire universe when touching drm_edid.h. Quite a few placs do currently depend on drm_edid.h without actually including it directly. All of those need to be fixed up. v2: Fix up i915 and msm some more v3: Fix alphabetical ordering (Sam) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220614090245.30283-1-ville.syrjala@linux.intel.com Acked-by: Sam Ravnborg <sam@ravnborg.org> Acked-by: Jani Nikula <jani.nikula@intel.com>
* drm/virtio: implement context init: stop using drv->context when creating fenceGurchetan Singh2021-09-291-12/+3
| | | | | | | | | | | | | | | | The plumbing is all here to do this. Since we always use the default fence context when allocating a fence, this makes no functional difference. We can't process just the largest fence id anymore, since it's it's associated with different timelines. It's fine for fence_id 260 to signal before 259. As such, process each fence_id individually. Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> Acked-by: Lingfeng Yang <lfy@google.com> Link: http://patchwork.freedesktop.org/patch/msgid/20210921232024.817-9-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: implement context init: support init ioctlAnthoine Bourgeois2021-09-291-1/+3
| | | | | | | | | | | | | | | | | | This implements the context initialization ioctl. A list of params is passed in by userspace, and kernel driver validates them. The only currently supported param is VIRTGPU_CONTEXT_PARAM_CAPSET_ID. If the context has already been initialized, -EEXIST is returned. This happens after Linux userspace does dumb_create + followed by opening the Mesa virgl driver with the same virtgpu instance. However, for most applications, 3D contexts will be explicitly initialized when the feature is available. Signed-off-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com> Acked-by: Lingfeng Yang <lfy@google.com> Link: http://patchwork.freedesktop.org/patch/msgid/20210921232024.817-6-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* virtio-gpu: fix possible memory allocation failureliuyuntao2021-09-171-7/+1
| | | | | | | | | | | | | | | When kmem_cache_zalloc in virtio_gpu_get_vbuf fails, it will return an error code. But none of its callers checks this error code, and a core dump will take place. Considering many of its callers can't handle such error, I add a __GFP_NOFAIL flag when calling kmem_cache_zalloc to make sure it won't fail, and delete those unused error handlings. Fixes: dc5698e80cf724 ("Add virtio gpu driver.") Signed-off-by: Yuntao Liu <liuyuntao10@huawei.com> Link: http://patchwork.freedesktop.org/patch/msgid/20210828104321.3410312-1-liuyuntao10@huawei.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: Prepare resource_flush to accept a fenceVivek Kasireddy2021-06-231-2/+5
| | | | | | | | | | A fence will be added to resource_flush for resources that are guest blobs. Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20210610232456.671905-3-vivek.kasireddy@intel.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: Fix a double free in virtio_gpu_cmd_map()Dan Carpenter2020-11-061-3/+1
| | | | | | | | | | | This is freed both here and in the caller (virtio_gpu_vram_map()) so it's a double free. The correct place is only in the caller. Fixes: 16845c5d5409 ("drm/virtio: implement blob resources: implement vram object") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20201030114808.GD3251003@mwanda Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* Merge drm/drm-next into drm-misc-nextMaxime Ripard2020-11-021-8/+5
|\ | | | | | | | | | | Daniel needs -rc2 in drm-misc-next to merge some patches Signed-off-by: Maxime Ripard <maxime@cerno.tech>
| * Merge tag 'drm-misc-next-2020-09-21' of ↵Dave Airlie2020-09-231-22/+31
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://anongit.freedesktop.org/drm/drm-misc into drm-next drm-misc-next for 5.10: UAPI Changes: Cross-subsystem Changes: - virtio: Merged a PR for patches that will affect drm/virtio Core Changes: - dev: More devm_drm convertions and removal of drm_dev_init - atomic: Split out drm_atomic_helper_calc_timestamping_constants of drm_atomic_helper_update_legacy_modeset_state - ttm: More rework Driver Changes: - i915: selftests improvements - panfrost: support for Amlogic SoC - vc4: one fix - tree-wide: conversions to devm_drm_dev_alloc, - ast: simplifications of the atomic modesetting code - panfrost: multiple fixes - vc4: multiple fixes Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maxime Ripard <maxime@cerno.tech> Link: https://patchwork.freedesktop.org/patch/msgid/20200921152956.2gxnsdgxmwhvjyut@gilmour.lan
| * \ Merge branch 'for-5.10-drm-sg-fix' of https://github.com/mszyprow/linux into ↵Dave Airlie2020-09-171-7/+5
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | drm-next Please pull a set of fixes for various DRM drivers that finally resolve incorrect usage of the scatterlists (struct sg_table nents and orig_nents entries), what causes issues when IOMMU is used. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200910080505.24456-1-m.szyprowski@samsung.com
| | * | drm: virtio: fix common struct sg_table related issuesMarek Szyprowski2020-09-101-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_map_sg(). struct sg_table is a common structure used for describing a non-contiguous memory buffer, used commonly in the DRM and graphics subsystems. It consists of a scatterlist with memory pages and DMA addresses (sgl entry), as well as the number of scatterlist entries: CPU pages (orig_nents entry) and DMA mapped pages (nents entry). It turned out that it was a common mistake to misuse nents and orig_nents entries, calling DMA-mapping functions with a wrong number of entries or ignoring the number of mapped entries returned by the dma_map_sg() function. To avoid such issues, lets use a common dma-mapping wrappers operating directly on the struct sg_table objects and use scatterlist page iterators where possible. This, almost always, hides references to the nents and orig_nents entries, making the code robust, easier to follow and copy/paste safe. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
* | | | drm/virtio: Use UUID API for importing the UUIDAndy Shevchenko2020-10-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is import_uuid() function which imports u8 array to the uuid_t. Use it instead of open coding variant. This allows to hide the uuid_t internals. Reviewed-by: David Stevens <stevensd@chromium.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20201013132714.70973-1-andriy.shevchenko@linux.intel.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* | | | drm/virtio: implement blob resources: fix stride discrepancyGurchetan Singh2020-09-291-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old transfer ioctls may work on blob resources, and there is no TRANSFER_BLOB hypercall now for simplicity. The guest may have a image view on the blob resources such that the stride is not equal to width * bytes_per_pixel. For host-only blobs, we can repurpose the transfer ioctls to synchronize caches as well. For guest-only blobs, these operations are undefined for now so leave them out. Also, with seamless Wayland integration between guest/host looking increasingly attractive, it also makes sense to keep track of one value for stride. Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200924003214.662-16-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* | | | drm/virtio: implement blob resources: hypercall interfaceGurchetan Singh2020-09-291-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the blob hypercall interface. Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200924003214.662-13-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* | | | drm/virtio: implement blob resources: implement vram objectGerd Hoffmann2020-09-291-0/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A virtio-gpu vram object is based on range-based allocation. No guest shmemfs backing, so we call drm_gem_private_object_init. This is for host memory without any guest backing (atleast initially). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200924003214.662-12-gurchetansingh@chromium.org Co-developed-by: Gurchetan Singh <gurchetansingh@chromium.org> Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
* | | | drm/virtio: blob prep: make CPU responses more genericGurchetan Singh2020-09-291-5/+5
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | RESOURCE_MAP_BLOB / RESOURCE_UNMAP_BLOB can use this. Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200924003214.662-2-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* | | drm/virtio: add virtio_gpu_cmd_unref_resource error handlingGerd Hoffmann2020-09-151-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usually we wait for the host to complete the unref request, then cleanup the guest-side state of the object in the completion callback. When submitting the unref command failed the completion callback will not be called though, so cleanup right away. Fixes a WARN on stale mm entries on driver shutdown. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200908070723.6394-4-kraxel@redhat.com
* | | drm/virtio: return virtio_gpu_queue errorsGerd Hoffmann2020-09-151-18/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | In case queuing virtio commands fails (can happen when the device got unplugged) pass up the error. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200908070723.6394-3-kraxel@redhat.com
* | | Fix use after free in get_capset_info callback.Doug Horn2020-09-091-3/+7
|/ / | | | | | | | | | | | | | | | | | | If a response to virtio_gpu_cmd_get_capset_info takes longer than five seconds to return, the callback will access freed kernel memory in vg->capsets. Signed-off-by: Doug Horn <doughorn@google.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200902210847.2689-2-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* | Merge v5.9-rc1 into drm-misc-nextMaxime Ripard2020-08-181-2/+2
|\| | | | | | | | | | | Sam needs 5.9-rc1 to have dev_err_probe in to merge some patches. Signed-off-by: Maxime Ripard <maxime@cerno.tech>
| * virtio: virtio_has_iommu_quirk -> virtio_has_dma_quirkMichael S. Tsirkin2020-08-031-2/+2
| | | | | | | | | | | | | | | | Now that the corresponding feature bit has been renamed, rename the quirk too - it's about special ways to do DMA, not necessarily about the IOMMU. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | drm/virtio: Support virtgpu exported resourcesDavid Stevens2020-08-181-0/+55
|/ | | | | | | | | | | Add support for UUID-based resource sharing mechanism to virtgpu. This implements the new virtgpu commands and hooks them up to dma-buf's get_uuid callback. Signed-off-by: David Stevens <stevensd@chromium.org> Acked-by: Michael S. Tsirkin <mst@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200818071343.3461203-4-stevensd@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: make virtio_gpu_object_attach voidGurchetan Singh2020-04-031-5/+4
| | | | | | | | It always returns zero. Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200401223039.2860-4-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: factor out the sg_table from virtio_gpu_objectGurchetan Singh2020-03-091-2/+4
| | | | | | | | | | | | A resource will be a shmem based resource or a (planned) vram based resource, so it makes sense to factor out common fields (resource handle, dumb). v2: move mapped field to shmem object Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200305013212.130640-1-gurchetansingh@chromium.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: move remaining virtio_gpu_notify callsGerd Hoffmann2020-02-171-9/+0
| | | | | | | | | | Move all remaining virtio_gpu_notify() calls from virtio_gpu_cmd_* to the callers, for consistency reasons. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200214125535.26349-7-kraxel@redhat.com
* drm/virtio: batch display queryGerd Hoffmann2020-02-171-2/+0
| | | | | | | | | | | | | Move virtio_gpu_notify() to higher-level functions for virtio_gpu_cmd_get_display_info() and virtio_gpu_cmd_get_edids(). virtio_gpu_config_changed_work_func() and virtio_gpu_init() will batch commands and notify only once per update Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200214125535.26349-6-kraxel@redhat.com
* drm/virtio: batch resource creationGerd Hoffmann2020-02-171-3/+0
| | | | | | | | | | | | | | Move virtio_gpu_notify() to higher-level functions for virtio_gpu_cmd_create_resource(), virtio_gpu_cmd_resource_create_3d() and virtio_gpu_cmd_resource_attach_backing(). virtio_gpu_object_create() will batch commands and notify only once when creating a resource. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200214125535.26349-5-kraxel@redhat.com
* drm/virtio: batch plane updates (pageflip)Gerd Hoffmann2020-02-171-4/+0
| | | | | | | | | | | | | | Move virtio_gpu_notify() to higher-level functions for virtio_gpu_cmd_resource_flush(), virtio_gpu_cmd_set_scanout() and virtio_gpu_cmd_transfer_to_host_{2d,3d}(). virtio_gpu_primary_plane_update() will notify only once for a series of commands (restores plane update command batching). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200214125535.26349-4-kraxel@redhat.com
* drm/virtio: notify before waitingGerd Hoffmann2020-02-171-0/+1
| | | | | | | | | | | Before we are going to wait for virtqueue entries becoming available call virtio_gpu_notify() to make sure the host has seen everything we've submitted. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200214125535.26349-3-kraxel@redhat.com
* drm/virtio: rework notification for better batchingGerd Hoffmann2020-02-171-19/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Drop the virtio_gpu_{disable,enable}_notify(). Add a new virtio_gpu_notify() call instead, which must be called whenever the driver wants make sure the host is notified needed. Drop automatic notification from command submission. Add virtio_gpu_notify() calls after each command query instead. This allows more fine-grained control over host notification and can move around the notify calls in subsequent patches to batch command submissions. With this in place it is also possible to make notification optional for userspace ioctls. Page flip batching goes away (temporarely). v3: - move batching to separate patches. v2: - rebase to latest drm-misc-next. - use "if (!atomic_read())". - add review & test tags. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200214125535.26349-2-kraxel@redhat.com
* drm/virtio: fix error checkGerd Hoffmann2020-02-141-1/+1
| | | | | | | | | | The >= compare op must happen in cpu byte order, doing it in little endian fails on big endian machines like s390. Reported-by: Sebastian Mitterle <smitterl@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200214080100.1273-1-kraxel@redhat.com
* drm/virtio: add drm_driver.release callback.Gerd Hoffmann2020-02-121-12/+15
| | | | | | | | | | | | | | Split virtio_gpu_deinit(), move the drm shutdown and release to virtio_gpu_release(). Drop vqs_ready variable, instead use drm_dev_{enter,exit,unplug} to avoid touching hardware after device removal. Tidy up here and there. v4: add changelog. v3: use drm_dev_*(). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20200211135805.24436-1-kraxel@redhat.com
* drm/virtio: move virtio_gpu_mem_entry initialization to new functionGerd Hoffmann2020-02-101-48/+3
| | | | | | | | | | | Introduce new virtio_gpu_object_shmem_init() helper function which will create the virtio_gpu_mem_entry array, containing the backing storage information for the host. For the most path this just moves code from virtio_gpu_object_attach(). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200207074638.26386-5-kraxel@redhat.com Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
* drm/virtio: move mapping teardown to virtio_gpu_cleanup_object()Gerd Hoffmann2020-02-101-46/+0
| | | | | | | | | | | Stop sending DETACH_BACKING commands, that will happening anyway when releasing resources via UNREF. Handle guest-side cleanup in virtio_gpu_cleanup_object(), called when the host finished processing the UNREF command. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200207074638.26386-4-kraxel@redhat.com Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
* drm/virtio: resource teardown tweaksGerd Hoffmann2020-02-101-3/+26
| | | | | | | | | | Add new virtio_gpu_cleanup_object() helper function for object cleanup. Wire up callback function for resource unref, do cleanup from callback when we know the host stopped using the resource. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200207074638.26386-3-kraxel@redhat.com Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
* drm/virtio: simplify virtio_gpu_alloc_cmdGerd Hoffmann2020-02-101-17/+9
| | | | | | | | | Just call virtio_gpu_alloc_cmd_resp with some fixed args instead of duplicating most of the function body. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200207074638.26386-2-kraxel@redhat.com Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
* drm/virtio: fix ring free checkGerd Hoffmann2020-02-071-0/+3
| | | | | | | | | | If the virtio device supports indirect ring descriptors we need only one ring entry for the whole command. Take that into account when checking whenever the virtqueue has enough free entries for our command. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200207064653.14403-1-kraxel@redhat.com
* drm/virtio: move virtqueue_notify into virtio_gpu_queue_ctrl_sgsChia-I Wu2020-02-061-12/+10
| | | | | | | | | | It becomes clear that virtio_gpu_queue_fenced_ctrl_buffer should be responsible for setting up sgs and virtio_gpu_queue_ctrl_sgs should be responsible for queuing sgs. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-11-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: move the check for vqs_ready earlierChia-I Wu2020-02-061-5/+8
| | | | | | | | | | | When vqs_ready is false, vq should be considered invalid and we should not check vq->num_free. After this change, a fenced command queued before the vqs are ready will have fence id 0 and will be considered done. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-9-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: move locking into virtio_gpu_queue_ctrl_sgsChia-I Wu2020-02-061-35/+35
| | | | | | Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-8-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: set up virtqueue sgs before lockingChia-I Wu2020-02-061-31/+35
| | | | | | | | sgs setup does not need to be in the critical section. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-7-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: unlock object array on errorsChia-I Wu2020-02-061-1/+4
| | | | | | | | | We don't propagate erros to the callers. We have to unlock object arrays on errors. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-6-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: no need to pass virtio_gpu_ctrl_hdrChia-I Wu2020-02-061-12/+12
| | | | | | | | We can get it from vbuf. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-5-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: add virtio_gpu_vbuf_ctrl_hdrChia-I Wu2020-02-061-5/+15
| | | | | | | | It is a helper to return the virtio_gpu_ctrl_hdr in a vbuf. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-4-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: remove incorrect ENOSPC checkChia-I Wu2020-02-061-13/+6
| | | | | | | | | | | | | | | | | The handling of virtqueue_add_sgs ENOSPC error is incorrect because it can result in out-of-order virtqueue_add_sgs and break fences. We never get ENOSPC anyway because the caller waits until there is enough space (the other caller that did not wait was removed in commit 32d6c2c5b522 ("drm/virtio: Rewrite virtio_gpu_queue_ctrl_buffer using fenced version.")). Remove the incorrect and unnecessary error path. This also adds a WARN_ON(ret) until we properly handle errors. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Cc: David Riley <davidriley@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-3-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: fix a wait_event conditionChia-I Wu2020-02-061-1/+2
| | | | | | | | | | | outcnt may be greater than 1 since commit e1218b8c0cc1 ("drm/virtio: Use vmalloc for command buffer allocations."). Fixes: e1218b8c0cc1 ("drm/virtio: Use vmalloc for command buffer allocations.") Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Cc: David Riley <davidriley@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20200205181955.202485-2-olvaffe@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* drm/virtio: ratelimit error loggingGerd Hoffmann2020-02-061-3/+3
| | | | | | | | Avoid flooding the log in case we screw up badly. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200205102552.21409-1-kraxel@redhat.com
* drm/virtio: batch display update commands.Gerd Hoffmann2019-12-161-2/+21
| | | | | | | | | | | | | When the driver submits multiple commands in a row it makes sense to notify the host only after submitting the last one, so the host can process them all at once, with a single vmexit. Add functions to enable/disable notifications to allow that. Use the new functions for primary plane updates. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Link: http://patchwork.freedesktop.org/patch/msgid/20191212125346.8334-3-kraxel@redhat.com