Commit Graph

791166 Commits

Author SHA1 Message Date
Gerd Hoffmann
b3ca97fd4b UPSTREAM: drm/virtio: drop prime import/export callbacks
Also set prime_handle_to_fd and prime_fd_to_handle to NULL,
so drm will not advertive DRM_PRIME_CAP_{IMPORT,EXPORT} to
userspace.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20190110111545.26768-1-kraxel@redhat.com
(cherry picked from commit b318e3ff7c)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I604c266f985e52764924eb6deb5363bc7c01853e
2019-08-19 11:29:54 -07:00
Gerd Hoffmann
67456f4233 UPSTREAM: drm/virtio: do NOT reuse resource ids
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
(cherry picked from commit 16065fcdd1)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I606eecad29b877ad5da26dc9e4b5b71d99c8483d
2019-08-19 11:29:54 -07:00
Gerd Hoffmann
a62c058859 UPSTREAM: drm/virtio: drop virtio_gpu_fence_cleanup()
Just call drm_fence_put directly instead.
Also set vgfb->fence to NULL after dropping the reference.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181219122708.4586-4-kraxel@redhat.com
(cherry picked from commit cb66c6daa5)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I57ec957d37733db30aeb4b329415a1f81f59936f
2019-08-19 11:29:54 -07:00
Gerd Hoffmann
5186654ab5 UPSTREAM: drm/virtio: fix pageflip flush
Sending the flush command only makes sense if we actually have
a framebuffer attached to the scanout (handle != 0).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181219122708.4586-3-kraxel@redhat.com
(cherry picked from commit 6a01d277ac)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I9861c9e9c57c23fa2f6c67f0d5f6aac56bae5a4a
2019-08-19 11:29:54 -07:00
Gerd Hoffmann
fa3d9f0e0b UPSTREAM: drm/virtio: log error responses
If we got an error response code from the host, print it to the log.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181219122708.4586-2-kraxel@redhat.com
(cherry picked from commit 3630c2a24f)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I53e3c89cdf874e6cc0ea60ab6a619382d2c6ff23
2019-08-19 11:29:53 -07:00
Ezequiel Garcia
e8656dbe7a UPSTREAM: drm/virtio: Add missing virtqueue reset
As per the VirtIO spec, the virtqueues must be reset during cleanup
(see "3.3.1 Driver Requirements: Device Cleanup").

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20190102175507.4653-2-ezequiel@collabora.com
(cherry picked from commit edde9fc58e)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I3d40dd7771bacb91b64d99b2139cbe7d0b203f5d
2019-08-19 11:29:53 -07:00
Ezequiel Garcia
c1b2cd0cfb UPSTREAM: drm/virtio: Remove incorrect kfree()
The virtio_gpu_output is a member of struct virtio_gpu_device
and is not a dynamically-allocated chunk, so it's wrong to kfree() it.
Removing it fixes a memory corruption BUG() that can be triggered
when the virtio-gpu driver is removed.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20190102175507.4653-1-ezequiel@collabora.com
(cherry picked from commit 29cd2e2dac)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I57b78b049cecc5b8e89ea191dfa807e3725085ca
2019-08-19 11:29:53 -07:00
Gerd Hoffmann
c77fa1b8fc UPSTREAM: drm/virtio: switch to generic fbdev emulation
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181213134915.24722-1-kraxel@redhat.com
(cherry picked from commit 48a77d66cb)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I6f1506ee6bd92b1940b727549da45620cc7307c3
2019-08-19 11:29:53 -07:00
Gerd Hoffmann
b1007d2200 UPSTREAM: drm/virtio: virtio_gpu_cmd_resource_create_3d: drop unused fence arg
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181128151021.29565-3-kraxel@redhat.com
(cherry picked from commit d7a86dffc2)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I9f165ce8eb681cd11485da11975a91f1b1571255
2019-08-19 11:29:53 -07:00
Gerd Hoffmann
1e4ef4308a UPSTREAM: drm/virtio: fence: pass plain pointer
Since commit "9fdd90c0f4 drm/virtio: add virtio_gpu_alloc_fence()"
fences are not allocated any more by virtio_gpu_fence_emit().  So there
is no need to pass down a reference to the fence pointer, a plain
pointer is enough now.

Convert virtio_gpu_fence_emit() and callers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181128151021.29565-2-kraxel@redhat.com
(cherry picked from commit 4d55fd66b4)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Ic4bc8f628716d230a88eba4f7f9c45cb3fc5a1bb
2019-08-19 11:29:53 -07:00
Gerd Hoffmann
d4f5248ba0 UPSTREAM: drm/virtio: add edid support
linux guest driver implementation of the VIRTIO_GPU_F_EDID feature.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20181030063206.19528-3-kraxel@redhat.com
(cherry picked from commit b4b01b4995)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Idb4433b65dfee118a3bb36bd6900bafff0f8c430
2019-08-19 11:29:53 -07:00
Gerd Hoffmann
03f5384082 UPSTREAM: virtio-gpu: add VIRTIO_GPU_F_EDID feature
The feature allows the guest request an EDID blob (describing monitor
capabilities) for a given scanout (aka virtual monitor connector).

It brings a new command message, which has just a scanout field (beside
the standard virtio-gpu header) and a response message which carries the
EDID data.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181030063206.19528-2-kraxel@redhat.com
(cherry picked from commit 610c0c2b28)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I1d4c11844307845b5829f1220b35938823ac7924
2019-08-19 11:29:53 -07:00
Colin Ian King
11b8dd566c UPSTREAM: drm/virtio: fix memory leak of vfpriv on error return path
The allocation for vfpriv is being leaked on an error return path,
fix this by kfree'ing it before returning.

Detected by CoverityScan, CID#1475380 ("Resource Leak")

Fixes: 6a37c49a94 ("drm/virtio: Handle context ID allocation errors")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181107203122.6861-1-colin.king@canonical.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 040b595a91)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I67f199a9fa2243a79927c908cbc4f47ac9b16f3d
2019-08-19 11:29:53 -07:00
Gustavo Padovan
3b90a75ad0 UPSTREAM: drm/virtio: bump driver version after explicit synchronization addition
To reflect the (backward compatible) changes in the uabi we are bumping
the driver's version.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181112165157.32765-5-robert.foss@collabora.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 6862965261)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I2bf6fa3700b6391e83a59007f98a128f89639557
2019-08-19 11:29:52 -07:00
Robert Foss
a62554de89 UPSTREAM: drm/virtio: add in/out fence support for explicit synchronization
When the execbuf call receives an in-fence it will get the dma_fence
related to that fence fd and wait on it before submitting the draw call.

On the out-fence side we get fence returned by the submitted draw call
and attach it to a sync_file and send the sync_file fd to userspace. On
error -1 is returned to userspace.

VIRTGPU_EXECBUF_FENCE_FD_IN & VIRTGPU_EXECBUF_FENCE_FD_OUT
are supported at the simultaneously and can be flagged
for simultaneously.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181112165157.32765-4-robert.foss@collabora.com
Suggested-by: Rob Herring <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 2cd7b6f08b)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I169ce56d77083a8f7763225cd3e786ac057594c8
2019-08-19 11:29:52 -07:00
Robert Foss
54c534cf51 UPSTREAM: drm/virtio: add uapi for in and out explicit fences
Add a new field called fence_fd that will be used by userspace to send
in-fences to the kernel and receive out-fences created by the kernel.

This uapi enables virtio to take advantage of explicit synchronization of
dma-bufs.

There are two new flags:

* VIRTGPU_EXECBUF_FENCE_FD_IN to be used when passing an in-fence fd.
* VIRTGPU_EXECBUF_FENCE_FD_OUT to be used when requesting an out-fence fd

The execbuffer IOCTL is now read-write to allow the userspace to read the
out-fence.

On error -1 should be returned in the fence_fd field.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181112165157.32765-3-robert.foss@collabora.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit a56f9c868c)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Icdf083b865feb4e9b19998bc06ab18e2504608da
2019-08-19 11:29:52 -07:00
Robert Foss
cd33bd9aab UPSTREAM: drm/virtio: add virtio_gpu_alloc_fence()
Refactor fence creation, add fences to relevant GPU
operations and add cursor helper functions.

This removes the potential for allocation failures from the
cmd_submit and atomic_commit paths.
Now a fence will be allocated first and only after that
will we proceed with the rest of the execution.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181112165157.32765-2-robert.foss@collabora.com
Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 9fdd90c0f4)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I84003fd45344b1d3d368bd0d1669625c05fc11c2
2019-08-19 11:29:52 -07:00
Matthew Wilcox
39a21dedcf UPSTREAM: drm/virtio: Use IDAs more efficiently
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>
(cherry picked from commit 2ae7f165c0)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I163fea3a31358bbaa478c1ce49b42de413ddc9d5
2019-08-19 11:29:52 -07:00
Matthew Wilcox
d620c93af6 UPSTREAM: drm/virtio: Handle error from virtio_gpu_resource_id_get
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>
(cherry picked from commit 556c62e85f)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I0bc83d49fe6b40b6fb5d0e9b1da3cdf64b48f5b3
2019-08-19 11:29:52 -07:00
Sabyasachi Gupta
93d74d3618 UPSTREAM: gpu/drm/virtio/virtgpu_vq.c: Use kmem_cache_zalloc
Replaced kmem_cache_alloc + memset with kmem_cache_zalloc

Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/5bc9ff7e.1c69fb81.105c2.1fef@mx.google.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 7fea1e0f38)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I1ec7f1c43f6e68bb2d25fde7ab523d21700a41f4
2019-08-19 11:29:52 -07:00
Matthew Wilcox
2e3622b76b UPSTREAM: drm/virtio: Handle context ID allocation errors
It is possible to run out of memory while allocating IDs.  The current
code would create a context with an invalid ID; change it to return
-ENOMEM to userspace.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20180926160031.15721-3-willy@infradead.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 6a37c49a94)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I009960f3fb372875f9e0fab403e01d1148bed23d
2019-08-19 11:29:52 -07:00
Matthew Wilcox
063ff2742e UPSTREAM: drm/virtio: Replace IDRs with IDAs
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>
(cherry picked from commit 1938d1ae32)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Ie7a81e0eedc7adf6ae7f4d75a0b7fa2533fae577
2019-08-19 11:29:51 -07:00
Gerd Hoffmann
1142e84ccb UPSTREAM: drm/virtio: fix resource id handling
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
(cherry picked from commit 6c1cd97bda)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I4e1565804c923d18096edce63a5166015f4c9a4c
2019-08-19 11:29:51 -07:00
Gerd Hoffmann
bcc08f4c18 UPSTREAM: drm/virtio: drop resource_id argument.
We pass the obj anyway, so obj->hw_res_handle can be used instead
in virtio_gpu_object_attach() and virtio_gpu_cmd_create_resource().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181019061847.18958-6-kraxel@redhat.com
(cherry picked from commit 724cfdfd66)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Id1b7f9ff3a4e41fcc56e30ba6033caf12a252e43
2019-08-19 11:29:51 -07:00
Gerd Hoffmann
51face532e UPSTREAM: drm/virtio: use virtio_gpu_object->hw_res_handle in virtio_gpu_resource_create_ioctl()
Drop pointless res_id variable in virtio_gpu_resource_create_ioctl(),
just use the hw_res_handle field in virtio_gpu_object directly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181019061847.18958-5-kraxel@redhat.com
(cherry picked from commit 70a0d6a377)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Ie3ac3462acb28c780da97272466a6c3b2cc37b95
2019-08-19 11:29:51 -07:00
Gerd Hoffmann
68f8fc388a UPSTREAM: drm/virtio: use virtio_gpu_object->hw_res_handle in virtio_gpu_mode_dumb_create()
Drop pointless resid variable in virtio_gpu_mode_dumb_create(), just use
the hw_res_handle field in virtio_gpu_object directly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181019061847.18958-4-kraxel@redhat.com
(cherry picked from commit c40336ba5e)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I151241825d4c8c51297d29bd229d3cd6ccf411af
2019-08-19 11:29:51 -07:00
Gerd Hoffmann
7a7d7a4a65 UPSTREAM: drm/virtio: use virtio_gpu_object->hw_res_handle in virtio_gpufb_create()
Drop pointless resid variable in virtio_gpufb_create(), just use
the hw_res_handle field in virtio_gpu_object directly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181019061847.18958-3-kraxel@redhat.com
(cherry picked from commit ae0dc3cc38)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I3b9724f993a5407befd74534ec627703d49a91d5
2019-08-19 11:29:51 -07:00
Gerd Hoffmann
410c3fc1b5 BACKPORT: drm/virtio: track created object state
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
(cherry picked from commit 23c897d72c)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Ib0d2cf8e0d6cce9a16537c9cea7074532b0f8d5e
2019-08-19 11:29:51 -07:00
Emil Velikov
fbfa029b70 UPSTREAM: drm/virtio: document drm_dev_set_unique workaround
A while back we removed it, yet that lead to regressions. At some later
point, I've attempted to remove it again without fully grasping the
unique (pun intended) situation that virtio is in.

Add a bulky comment to document why the call should stay as-is, for the
next person who's around.

As a Tl;Dr: virtio sits on top of struct virtio_device, which confuses
dev_is_pci(), wrong info gets sent to userspace and X doesn't start.
Driver needs to explicitly call drm_dev_set_unique() to keep it working.

v2: Fix handful of typos (Laszlo)

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181024144252.16518-1-emil.l.velikov@gmail.com
(cherry picked from commit 4bdbd5f0ee)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I97320c3c715b87eb8ebb3ca14706ab1ba00ec45e
2019-08-19 11:29:51 -07:00
Ezequiel Garcia
688d54fe9e UPSTREAM: virtio: Support prime objects vmap/vunmap
Implement vmap/vunmap so we can export dmabufs to
other drivers, such as video4linux.

Tested with a virtio-gpu / vivid (virtual capture driver)
pipeline, where the vivid driver imports the dmabufs exported
by virtio-gpu.

Note that dma_buf_vmap() does its own vmap counting, so
it's not needed to take care of it in the driver.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180925161606.17980-4-ezequiel@collabora.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit a03fb71716)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Icab4912be0e3da5a6fd453eb42894e6a16344ad3
2019-08-19 11:29:51 -07:00
Ezequiel Garcia
8661999dad BACKPORT: virtio: Rework virtio_gpu_object_kmap()
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>
(cherry picked from commit a20c4173c4)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I970b24d86c43017aa9d58b6cdc6e4909c3870c31
2019-08-19 11:29:50 -07:00
Gerd Hoffmann
97587ca703 UPSTREAM: drm/virtio: pass virtio_gpu_object to virtio_gpu_cmd_transfer_to_host_{2d, 3d}
Pass virtio_gpu_object down to virtio_gpu_cmd_transfer_to_host_2d and
virtio_gpu_cmd_transfer_to_host_3d functions, instead of passing just
the virtio resource handle.

This is needed to lookup the scatter list of the object, for dma sync.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiandi An <jiandi.an@amd.com>
Tested-by: Jiandi An <jiandi.an@amd.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180920062924.6514-1-kraxel@redhat.com
(cherry picked from commit af334c5d41)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I6beb27bcb7734db8f15e32cd83464fe4bd9df1e5
2019-08-19 11:29:50 -07:00
Jiandi An
acae114d0d UPSTREAM: drm/virtio: add dma sync for dma mapped virtio gpu framebuffer pages
With virtio gpu ttm-pages being dma mapped, dma sync is needed when
swiotlb is used as bounce buffers, before TRANSFER_TO_HOST_2D/3D
commands are sent.

Signed-off-by: Jiandi An <jiandi.an@amd.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180919070931.91168-1-jiandi.an@amd.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 8f44ca2233)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Ic8b56c8257faaf0e5c17c6d084f8897bf0179d67
2019-08-19 11:29:50 -07:00
YueHaibing
3165dbdd09 UPSTREAM: drm/virtio: Remove set but not used variable 'bo'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/virtio/virtgpu_display.c: In function 'virtio_gpu_framebuffer_init':
drivers/gpu/drm/virtio/virtgpu_display.c:78:28: warning:
 variable 'bo' set but not used [-Wunused-but-set-variable]
  struct virtio_gpu_object *bo;
                            ^

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1536285837-150460-1-git-send-email-yuehaibing@huawei.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit ea4584c2f2)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I772ac50da441bfde2f8769ed9da5428e087429eb
2019-08-19 11:29:50 -07:00
Gerd Hoffmann
aa9e96899e UPSTREAM: drm/virtio: add iommu support.
Use the dma mapping api and properly add iommu mappings for
objects, unless virtio is in iommu quirk mode.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180829122026.27012-3-kraxel@redhat.com
(cherry picked from commit a3b815f09b)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: Iaddec4e040620ef7214f7a6c714a5d6032dd89b4
2019-08-19 11:29:50 -07:00
Gerd Hoffmann
4f1fa8b3db UPSTREAM: drm/virtio: add virtio_gpu_object_detach() function
The new function balances virtio_gpu_object_attach().

Also make virtio_gpu_cmd_resource_inval_backing() static and switch
call sites to the new virtio_gpu_object_attach() function.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180829122026.27012-2-kraxel@redhat.com
(cherry picked from commit b3f13ec958)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I8e152b15e7361a14aae318b1710e03bafec60ab6
2019-08-19 11:29:50 -07:00
Gerd Hoffmann
21165d9f51 UPSTREAM: drm/virtio: track virtual output state
Track whenever an virtual output (crtc) is enabled or disabled.

On atomic updates check for both framebuffer being present and crtc
being enabled to figure whenever the output is active or not.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180813152855.12863-1-kraxel@redhat.com
(cherry picked from commit 6c19787e10)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I2957c2793f14a77ddf7084ade9b360ee40509dcb
2019-08-19 11:29:50 -07:00
Dan Carpenter
64cfae1900 UPSTREAM: drm/virtio: fix bounds check in virtio_gpu_cmd_get_capset()
This doesn't affect runtime because in the current code "idx" is always
valid.

First, we read from "vgdev->capsets[idx].max_size" before checking
whether "idx" is within bounds.  And secondly the bounds check is off by
one so we could end up reading one element beyond the end of the
vgdev->capsets[] array.

Fixes: 62fb7a5e10 ("virtio-gpu: add 3d/virgl support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180704094250.m7sgvvzg3dhcvv3h@kili.mountain
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 09c4b49457)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I73320cd2012a6e712cb910c5ebedb665d99e1205
2019-08-19 11:29:50 -07:00
Thomas Zimmermann
a6147c0eb5 UPSTREAM: drm/virtio: Replace ttm_bo_unref with ttm_bo_put
The function ttm_bo_put releases a reference to a TTM buffer object. The
function's name is more aligned to the Linux kernel convention of naming
ref-counting function _get and _put.

A call to ttm_bo_unref takes the address of the TTM BO object's pointer and
clears the pointer's value to NULL. This is not necessary in most cases and
sometimes even worked around by the calling code. A call to ttm_bo_put only
releases the reference without clearing the pointer.

The current behaviour of cleaning the pointer is kept in the calling code,
but should be removed if not required in a later patch.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: http://patchwork.freedesktop.org/patch/msgid/20180731062127.10131-3-tzimmermann@suse.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 0e7a3d4b66)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I014fa5f259fafd3b8ea691adc993eaffc46dd5dc
2019-08-19 11:29:49 -07:00
Thomas Zimmermann
aff367cb6a UPSTREAM: drm/virtio: Replace ttm_bo_reference with ttm_bo_get
The function ttm_bo_get acquires a reference on a TTM buffer object. The
function's name is more aligned to the Linux kernel convention of naming
ref-counting function _get and _put.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: http://patchwork.freedesktop.org/patch/msgid/20180731062127.10131-2-tzimmermann@suse.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 94f4a12707)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I6a34c03e605780411140b895e5b84dcb794cea3d
2019-08-19 11:29:49 -07:00
Thomas Zimmermann
4ad5dc30b5 UPSTREAM: drm/virtio: Replace drm_dev_unref with drm_dev_put
This patch unifies the naming of DRM functions for reference counting
of struct drm_device. The resulting code is more aligned with the rest
of the Linux kernel interfaces.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: http://patchwork.freedesktop.org/patch/msgid/20180716074940.8691-1-tzimmermann@suse.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit eec97cd367)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I0a2d6876fe60ea14052812a4f7de91372dd29c06
2019-08-19 11:29:49 -07:00
Souptick Joarder
260f71fd38 UPSTREAM: gpu: drm: virtio: code cleanup
The fault handler code is commented since v4.2.
If there is no plan to enable the fault handler
code in future, we can remove this dead code.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180703153353.GA3375@jordon-HP-15-Notebook-PC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit e61e0f07ef)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I7b57d530254887cdcf6b403b11a6e30d3175e7b6
2019-08-19 11:29:49 -07:00
Gerd Hoffmann
4fdb8b8630 UPSTREAM: drm: byteorder: add DRM_FORMAT_HOST_*
Add fourcc variants in host byte order.  With these at hand we don't
need #ifdefs in drivers which support framebuffers in cpu endianess.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20180905060445.15008-3-kraxel@redhat.com
(cherry picked from commit ec2fae2558)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I2ca0265de54f1a0e5dc49f4c3575d3575f09d25e
2019-08-19 11:29:49 -07:00
Gerd Hoffmann
fb58ca2898 UPSTREAM: drm: add drm_connector_attach_edid_property()
drm_connector_init doesn't attach the edid property for some connector
types, drm_connector_attach_edid_property() can be used to enable the
edid property in these cases.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20181002111041.17053-2-kraxel@redhat.com
(cherry picked from commit 6b7e2d5c30)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I876c559cc0ef4fae7e74a42f5d4b0efa18b2fff2
2019-08-19 11:29:49 -07:00
Noralf Trønnes
8e18525889 UPSTREAM: drm/prime: Add drm_gem_prime_mmap()
Add a generic PRIME GEM mmap function.

v2: Fix link in docs (Daniel Vetter)

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181110145647.17580-3-noralf@tronnes.org
(cherry picked from commit 7698799f95)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I0322d5051ce4db5ac3ded3d367c0f261864b1bb1
2019-08-19 11:29:49 -07:00
Alistair Delva
3f0d9e2984 ANDROID: Remove unused cuttlefish build infra
Cuttlefish will use gki_defconfig on this branch.

Change-Id: I20d37d538ca8f4de80282c4a3a98dbcfb7c33170
Signed-off-by: Alistair Delva <adelva@google.com>
2019-08-19 14:41:39 +00:00
Jaegeuk Kim
281eb60c26 f2fs: fix build error on android tracepoints
Fixes: 5e2c340821b1 ("ANDROID: f2fs: add android fsync tracepoint")
Change-Id: Idbf409f931e6826cc71d32ff0042d64ea68502aa
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-08-17 00:18:14 +00:00
Quentin Perret
8e9d3d0740 ANDROID: sched/fair: Cap transient util in stune
boosted_cpu_util() sums the CFS and RT util signals before they are used
for frequency selection. While the util_avg signals are in sync,
util_est prevents cpu_util_cfs() from decreasing when a CFS task is
preempted by RT.

This util_est behaviour is beneficial in many scenarios, but it can
cause the sum of rt_util and cfs_util to go above SCHED_CAPACITY_SCALE.
Although benign, this transient value appears in the stune tracepoints,
and can cause confusion.

Work around the problem by capping the util sum to SCHED_CAPACITY_SCALE.

Bug: 120440300
Change-Id: I2be6eb157af86024e52ae11715f5637c77b201a3
Signed-off-by: Quentin Perret <quentin.perret@arm.com>
2019-08-16 14:46:14 +01:00
Greg Kroah-Hartman
b1e96f1650 Merge 4.19.67 into android-4.19
Changes in 4.19.67
	iio: cros_ec_accel_legacy: Fix incorrect channel setting
	iio: adc: max9611: Fix misuse of GENMASK macro
	staging: gasket: apex: fix copy-paste typo
	staging: android: ion: Bail out upon SIGKILL when allocating memory.
	crypto: ccp - Fix oops by properly managing allocated structures
	crypto: ccp - Add support for valid authsize values less than 16
	crypto: ccp - Ignore tag length when decrypting GCM ciphertext
	usb: usbfs: fix double-free of usb memory upon submiturb error
	usb: iowarrior: fix deadlock on disconnect
	sound: fix a memory leak bug
	mmc: cavium: Set the correct dma max segment size for mmc_host
	mmc: cavium: Add the missing dma unmap when the dma has finished.
	loop: set PF_MEMALLOC_NOIO for the worker thread
	Input: usbtouchscreen - initialize PM mutex before using it
	Input: elantech - enable SMBus on new (2018+) systems
	Input: synaptics - enable RMI mode for HP Spectre X360
	x86/mm: Check for pfn instead of page in vmalloc_sync_one()
	x86/mm: Sync also unmappings in vmalloc_sync_all()
	mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy()
	perf annotate: Fix s390 gap between kernel end and module start
	perf db-export: Fix thread__exec_comm()
	perf record: Fix module size on s390
	x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS
	gfs2: gfs2_walk_metadata fix
	usb: host: xhci-rcar: Fix timeout in xhci_suspend()
	usb: yurex: Fix use-after-free in yurex_delete
	usb: typec: tcpm: free log buf memory when remove debug file
	usb: typec: tcpm: remove tcpm dir if no children
	usb: typec: tcpm: Add NULL check before dereferencing config
	usb: typec: tcpm: Ignore unsupported/unknown alternate mode requests
	can: rcar_canfd: fix possible IRQ storm on high load
	can: peak_usb: fix potential double kfree_skb()
	netfilter: nfnetlink: avoid deadlock due to synchronous request_module
	vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn
	netfilter: Fix rpfilter dropping vrf packets by mistake
	netfilter: conntrack: always store window size un-scaled
	netfilter: nft_hash: fix symhash with modulus one
	scripts/sphinx-pre-install: fix script for RHEL/CentOS
	drm/amd/display: Wait for backlight programming completion in set backlight level
	drm/amd/display: use encoder's engine id to find matched free audio device
	drm/amd/display: Fix dc_create failure handling and 666 color depths
	drm/amd/display: Only enable audio if speaker allocation exists
	drm/amd/display: Increase size of audios array
	iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND
	nl80211: fix NL80211_HE_MAX_CAPABILITY_LEN
	mac80211: don't warn about CW params when not using them
	allocate_flower_entry: should check for null deref
	hwmon: (nct6775) Fix register address and added missed tolerance for nct6106
	drm: silence variable 'conn' set but not used
	cpufreq/pasemi: fix use-after-free in pas_cpufreq_cpu_init()
	s390/qdio: add sanity checks to the fast-requeue path
	ALSA: compress: Fix regression on compressed capture streams
	ALSA: compress: Prevent bypasses of set_params
	ALSA: compress: Don't allow paritial drain operations on capture streams
	ALSA: compress: Be more restrictive about when a drain is allowed
	perf tools: Fix proper buffer size for feature processing
	perf probe: Avoid calling freeing routine multiple times for same pointer
	drbd: dynamically allocate shash descriptor
	ACPI/IORT: Fix off-by-one check in iort_dev_find_its_id()
	nvme: fix multipath crash when ANA is deactivated
	ARM: davinci: fix sleep.S build error on ARMv4
	ARM: dts: bcm: bcm47094: add missing #cells for mdio-bus-mux
	scsi: megaraid_sas: fix panic on loading firmware crashdump
	scsi: ibmvfc: fix WARN_ON during event pool release
	scsi: scsi_dh_alua: always use a 2 second delay before retrying RTPG
	test_firmware: fix a memory leak bug
	tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop
	perf/core: Fix creating kernel counters for PMUs that override event->cpu
	s390/dma: provide proper ARCH_ZONE_DMA_BITS value
	HID: sony: Fix race condition between rumble and device remove.
	x86/purgatory: Do not use __builtin_memcpy and __builtin_memset
	ALSA: usb-audio: fix a memory leak bug
	can: peak_usb: pcan_usb_pro: Fix info-leaks to USB devices
	can: peak_usb: pcan_usb_fd: Fix info-leaks to USB devices
	hwmon: (nct7802) Fix wrong detection of in4 presence
	drm/i915: Fix wrong escape clock divisor init for GLK
	ALSA: firewire: fix a memory leak bug
	ALSA: hiface: fix multiple memory leak bugs
	ALSA: hda - Don't override global PCM hw info flag
	ALSA: hda - Workaround for crackled sound on AMD controller (1022:1457)
	mac80211: don't WARN on short WMM parameters from AP
	dax: dax_layout_busy_page() should not unmap cow pages
	SMB3: Fix deadlock in validate negotiate hits reconnect
	smb3: send CAP_DFS capability during session setup
	NFSv4: Fix an Oops in nfs4_do_setattr
	KVM: Fix leak vCPU's VMCS value into other pCPU
	mwifiex: fix 802.11n/WPA detection
	iwlwifi: don't unmap as page memory that was mapped as single
	iwlwifi: mvm: fix an out-of-bound access
	iwlwifi: mvm: don't send GEO_TX_POWER_LIMIT on version < 41
	iwlwifi: mvm: fix version check for GEO_TX_POWER_LIMIT support
	Linux 4.19.67

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I5ea813ed5ba6d1eeda51eb4031395ee3e8ba54c3
2019-08-16 11:27:10 +02:00
Greg Kroah-Hartman
a5aa80588f Linux 4.19.67 2019-08-16 10:12:54 +02:00