* [PATCH 00/24] Blob prerequisites + blob resources
@ 2020-08-14 2:39 Gurchetan Singh
2020-08-14 2:39 ` [PATCH 01/24] drm/virtio: Revert "drm/virtio: Call the right shmem helpers" Gurchetan Singh
` (23 more replies)
0 siblings, 24 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
Dear all,
I'm excited to share with you a breathtaking advance in the field of
virtualized graphics: blob resources.
Blob resources are size-based containers for host, guest, or host+guest
allocations. These resources are designed with multi-process 3D support
in mind, but also usable in virtio-gpu 2d. They are needed for GL4.5,
Vulkan and zero-copy virtio-gpu. Details in the various patches.
Patch 1 is a bug fix needed for drm-misc-next.
Patches 2-4 are David Steven's F_RESOURCE_UUID patches. The spec has been
approved by the virtio committee [a] and has ack's from many virtio [b] and
DRM luminaries, but has of yet the patches haven't been merged into
drm-misc-next. Hopefully, we can get a plan for these patches at least.
Patches 5-7 are Sebastien Boeuf's shm region patches, which have been
floating around for a while. Vivek sent them out with the latest
virtio-fs patches and perhaps we can merge these somehow too.
Patches 8-9 are random preparatory patches, and patches 10-12 are the uapi
changes, and patches 12-24 are the blob implementation. The entire tree
is available at:
https://gitlab.freedesktop.org/virgl/drm-misc-next/-/commits/resource-blob
Blob resources are a product of a congenial collaboration by many notable
personalities from the Linux VM graphics ecosystem. Thanks to everyone who
participated!
--- Open-source userspace ---
As per DRM requirements, there are open-source userspace implementations
of blob resources. Patches have been reviewed or landed in Mesa [c],
virglrenderer [d], AOSP [e], and crosvm [f]. Most of these features are
behind a flag though.
--- Testing ---
Testing has taken place with x86 and ARM chromebooks, as well as
standard Linux desktop environments. Intel/Nvidia GPUs have been tested.
For Mesa, blob resources have been tested with Piglit's ARB_buffer_storage
tests and apitraces. Apitraces of GL4.5 games show we're between 70% to
80% of host performance on Iris, based on a apitrace of a 2013 GL4.5 game:
11.204 FPS (guest)
15.947 FPS (host)
This is still better than the status quo, when said game was unplayable
with Virgl due to an inefficient GL4.3 fallback. But there's still room
for improvement if we want to match HW-assisted virtualization.
For gfxstream, blob resources have been tested with dEQP.vk.memory* and
running Vulkan applications in production with the "Cuttlefish" virtual
Android device [g].
Perhaps the best improvements come in terms of power. Blob resources have
been shown decrease power consumption when playing 1080p60fps video by 10%.
As such, embedded devices in particular should transition to zero-copy
blob resources.
[a] https://www.oasis-open.org/committees/ballot.php?id=3500
[b] https://lists.oasis-open.org/archives/virtio-dev/202006/msg00070.html
[c] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4821
[d] https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/374
[e] https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/1283761
[f] https://chromium.googlesource.com/chromiumos/platform/crosvm/+/refs/heads/master/devices/src/virtio/gpu/virtio_3d_backend.rs#815
[g] https://source.android.com/setup/create/cuttlefish
David Stevens (3):
virtio: add dma-buf support for exported objects
virtio-gpu: add VIRTIO_GPU_F_RESOURCE_UUID feature
drm/virtio: Support virtgpu exported resources
Gerd Hoffmann (6):
virtio-gpu api: blob resources
virtio-gpu api: host visible feature
drm/virtio: implement blob resources: probe for the feature.
drm/virtio: implement blob resources: probe for host visible region
drm/virtio: implement blob resources: implement vram object
drm/virtio: implement blob resources: resource create blob ioctl
Gurchetan Singh (12):
drm/virtio: Revert "drm/virtio: Call the right shmem helpers"
drm/virtio: blob prep: refactor getting pages and attaching backing
drm/virtio: blob prep: make CPU responses more generic
virtio-gpu api: cross-device feature
drm/virtio: implement blob resources: expose
virtio_gpu_resource_id_get
drm/virtio: implement blob resources: add new fields to internal
structs
drm/virtio: implement blob resources: hypercall interface
drm/virtio: implement blob resources: blob display integration
drm/virtio: implement blob resources: refactor UUID code somewhat
drm/virtio: implement blob resources: fix stride discrepancy
drm/virtio: implement blob resources: report blob mem to userspace
drm/virtio: advertise features to userspace
Sebastien Boeuf (3):
virtio: Add get_shm_region method
virtio: Implement get_shm_region for PCI transport
virtio: Implement get_shm_region for MMIO transport
drivers/gpu/drm/virtio/Makefile | 2 +-
drivers/gpu/drm/virtio/virtgpu_debugfs.c | 24 +++
drivers/gpu/drm/virtio/virtgpu_drv.c | 4 +
drivers/gpu/drm/virtio/virtgpu_drv.h | 90 +++++++++-
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 183 ++++++++++++++++++++-
drivers/gpu/drm/virtio/virtgpu_kms.c | 45 ++++-
drivers/gpu/drm/virtio/virtgpu_object.c | 44 +++--
drivers/gpu/drm/virtio/virtgpu_plane.c | 23 ++-
drivers/gpu/drm/virtio/virtgpu_prime.c | 112 ++++++++++++-
drivers/gpu/drm/virtio/virtgpu_vq.c | 200 ++++++++++++++++++++++-
drivers/gpu/drm/virtio/virtgpu_vram.c | 164 +++++++++++++++++++
drivers/virtio/Makefile | 2 +-
drivers/virtio/virtio.c | 6 +
drivers/virtio/virtio_dma_buf.c | 82 ++++++++++
drivers/virtio/virtio_mmio.c | 31 ++++
drivers/virtio/virtio_pci_modern.c | 102 ++++++++++++
include/linux/virtio.h | 1 +
include/linux/virtio_config.h | 19 +++
include/linux/virtio_dma_buf.h | 37 +++++
include/uapi/drm/virtgpu_drm.h | 39 ++++-
include/uapi/linux/virtio_gpu.h | 97 +++++++++++
include/uapi/linux/virtio_mmio.h | 11 ++
include/uapi/linux/virtio_pci.h | 11 +-
23 files changed, 1290 insertions(+), 39 deletions(-)
create mode 100644 drivers/gpu/drm/virtio/virtgpu_vram.c
create mode 100644 drivers/virtio/virtio_dma_buf.c
create mode 100644 include/linux/virtio_dma_buf.h
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 01/24] drm/virtio: Revert "drm/virtio: Call the right shmem helpers"
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 02/24] virtio: add dma-buf support for exported objects Gurchetan Singh
` (22 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
This reverts commit d323bb44e4d23802eb25d13de1f93f2335bd60d0.
Fixes a double-free regression:
[ 4.357928] drm_gem_shmem_free_object+0xb4/0x100
[ 4.358983] virtio_gpu_dequeue_ctrl_func+0xd9/0x290
[ 4.360343] process_one_work+0x1d2/0x3a0
[ 4.361581] worker_thread+0x45/0x3c0
[ 4.362645] kthread+0xf6/0x130
[ 4.363543] ? process_one_work+0x3a0/0x3a0
[ 4.364770] ? kthread_park+0x80/0x80
[ 4.365799] ret_from_fork+0x35/0x40
[ 4.367103] Modules linked in:
[ 4.367958] CR2: 0000000000000018
[ 4.368857] ---[ end trace db84f7a2974d5c79 ]---
[ 4.370118] RIP: 0010:dma_direct_unmap_sg+0x1f/0x60
In addition, virtio has it's own set of dma-ops so there's not an
obviously clean way to transition to shmem helpers.
Fixes: d323bb44e4d2 ("drm/virtio: Call the right shmem helpers")
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
---
drivers/gpu/drm/virtio/virtgpu_object.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index 346cef5ce251..1359eb8f1a02 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -150,7 +150,13 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
if (ret < 0)
return -EINVAL;
- shmem->pages = drm_gem_shmem_get_pages_sgt(&bo->base.base);
+ /*
+ * virtio_gpu uses drm_gem_shmem_get_sg_table instead of
+ * drm_gem_shmem_get_pages_sgt because virtio has it's own set of
+ * dma-ops. This is discouraged for other drivers, but should be fine
+ * since virtio_gpu doesn't support dma-buf import from other devices.
+ */
+ shmem->pages = drm_gem_shmem_get_sg_table(&bo->base.base);
if (!shmem->pages) {
drm_gem_shmem_unpin(&bo->base.base);
return -EINVAL;
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 02/24] virtio: add dma-buf support for exported objects
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
2020-08-14 2:39 ` [PATCH 01/24] drm/virtio: Revert "drm/virtio: Call the right shmem helpers" Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 03/24] virtio-gpu: add VIRTIO_GPU_F_RESOURCE_UUID feature Gurchetan Singh
` (21 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: David Stevens <stevensd@chromium.org>
This change adds a new flavor of dma-bufs that can be used by virtio
drivers to share exported objects. A virtio dma-buf can be queried by
virtio drivers to obtain the UUID which identifies the underlying
exported object.
Signed-off-by: David Stevens <stevensd@chromium.org>
---
drivers/virtio/Makefile | 2 +-
drivers/virtio/virtio.c | 6 +++
drivers/virtio/virtio_dma_buf.c | 82 +++++++++++++++++++++++++++++++++
include/linux/virtio.h | 1 +
include/linux/virtio_dma_buf.h | 37 +++++++++++++++
5 files changed, 127 insertions(+), 1 deletion(-)
create mode 100644 drivers/virtio/virtio_dma_buf.c
create mode 100644 include/linux/virtio_dma_buf.h
diff --git a/drivers/virtio/Makefile b/drivers/virtio/Makefile
index 4d993791f2d7..49da768ee7fd 100644
--- a/drivers/virtio/Makefile
+++ b/drivers/virtio/Makefile
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_VIRTIO) += virtio.o virtio_ring.o
+obj-$(CONFIG_VIRTIO) += virtio.o virtio_ring.o virtio_dma_buf.o
obj-$(CONFIG_VIRTIO_MMIO) += virtio_mmio.o
obj-$(CONFIG_VIRTIO_PCI) += virtio_pci.o
virtio_pci-y := virtio_pci_modern.o virtio_pci_common.o
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index a977e32a88f2..5d46f0ded92d 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -357,6 +357,12 @@ int register_virtio_device(struct virtio_device *dev)
}
EXPORT_SYMBOL_GPL(register_virtio_device);
+bool is_virtio_device(struct device *dev)
+{
+ return dev->bus == &virtio_bus;
+}
+EXPORT_SYMBOL_GPL(is_virtio_device);
+
void unregister_virtio_device(struct virtio_device *dev)
{
int index = dev->index; /* save for after device release */
diff --git a/drivers/virtio/virtio_dma_buf.c b/drivers/virtio/virtio_dma_buf.c
new file mode 100644
index 000000000000..fa0d3a668f53
--- /dev/null
+++ b/drivers/virtio/virtio_dma_buf.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * dma-bufs for virtio exported objects
+ *
+ * Copyright (C) 2020 Google, Inc.
+ */
+
+#include <linux/virtio_dma_buf.h>
+
+/**
+ * virtio_dma_buf_export - Creates a new dma-buf for a virtio exported object
+ * @exp_info: [in] see dma_buf_export(). ops MUST refer to a dma_buf_ops
+ * struct embedded in a virtio_dma_buf_ops.
+ *
+ * This wraps dma_buf_export() to allow virtio drivers to create a dma-buf
+ * for an virtio exported object that can be queried by other virtio drivers
+ * for the object's UUID.
+ */
+struct dma_buf *virtio_dma_buf_export(
+ const struct dma_buf_export_info *exp_info)
+{
+ const struct virtio_dma_buf_ops *virtio_ops = container_of(
+ exp_info->ops, const struct virtio_dma_buf_ops, ops);
+
+ if (!exp_info->ops
+ || exp_info->ops->attach != &virtio_dma_buf_attach
+ || !virtio_ops->get_uuid) {
+ return ERR_PTR(-EINVAL);
+ }
+
+ return dma_buf_export(exp_info);
+}
+EXPORT_SYMBOL(virtio_dma_buf_export);
+
+/**
+ * virtio_dma_buf_attach - mandatory attach callback for virtio dma-bufs
+ */
+int virtio_dma_buf_attach(struct dma_buf *dma_buf,
+ struct dma_buf_attachment *attach)
+{
+ int ret;
+ const struct virtio_dma_buf_ops *ops = container_of(
+ dma_buf->ops, const struct virtio_dma_buf_ops, ops);
+
+ if (ops->device_attach) {
+ ret = ops->device_attach(dma_buf, attach);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(virtio_dma_buf_attach);
+
+/**
+ * is_virtio_dma_buf - returns true if the given dma-buf is a virtio dma-buf
+ * @dma_buf: buffer to query
+ */
+bool is_virtio_dma_buf(struct dma_buf *dma_buf)
+{
+ return dma_buf->ops->attach == &virtio_dma_buf_attach;
+}
+EXPORT_SYMBOL(is_virtio_dma_buf);
+
+/**
+ * virtio_dma_buf_get_uuid - gets the uuid of the virtio dma-buf's exported object
+ * @dma_buf: [in] buffer to query
+ * @uuid: [out] the uuid
+ *
+ * Returns: 0 on success, negative on failure.
+ */
+int virtio_dma_buf_get_uuid(struct dma_buf *dma_buf,
+ uuid_t *uuid)
+{
+ const struct virtio_dma_buf_ops *ops = container_of(
+ dma_buf->ops, const struct virtio_dma_buf_ops, ops);
+
+ if (!is_virtio_dma_buf(dma_buf))
+ return -EINVAL;
+
+ return ops->get_uuid(dma_buf, uuid);
+}
+EXPORT_SYMBOL(virtio_dma_buf_get_uuid);
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index a493eac08393..55ea329fe72a 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -127,6 +127,7 @@ static inline struct virtio_device *dev_to_virtio(struct device *_dev)
void virtio_add_status(struct virtio_device *dev, unsigned int status);
int register_virtio_device(struct virtio_device *dev);
void unregister_virtio_device(struct virtio_device *dev);
+bool is_virtio_device(struct device *dev);
void virtio_break_device(struct virtio_device *dev);
diff --git a/include/linux/virtio_dma_buf.h b/include/linux/virtio_dma_buf.h
new file mode 100644
index 000000000000..394bf04362d7
--- /dev/null
+++ b/include/linux/virtio_dma_buf.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * dma-bufs for virtio exported objects
+ *
+ * Copyright (C) 2020 Google, Inc.
+ */
+
+#ifndef _LINUX_VIRTIO_DMA_BUF_H
+#define _LINUX_VIRTIO_DMA_BUF_H
+
+#include <linux/dma-buf.h>
+#include <linux/uuid.h>
+#include <linux/virtio.h>
+
+/**
+ * struct virtio_dma_buf_ops - operations possible on exported object dma-buf
+ * @ops: the base dma_buf_ops. ops.attach MUST be virtio_dma_buf_attach.
+ * @device_attach: [optional] callback invoked by virtio_dma_buf_attach during
+ * all attach operations.
+ * @get_uid: [required] callback to get the uuid of the exported object.
+ */
+struct virtio_dma_buf_ops {
+ struct dma_buf_ops ops;
+ int (*device_attach)(struct dma_buf *dma_buf,
+ struct dma_buf_attachment *attach);
+ int (*get_uuid)(struct dma_buf *dma_buf, uuid_t *uuid);
+};
+
+int virtio_dma_buf_attach(struct dma_buf *dma_buf,
+ struct dma_buf_attachment *attach);
+
+struct dma_buf *virtio_dma_buf_export(
+ const struct dma_buf_export_info *exp_info);
+bool is_virtio_dma_buf(struct dma_buf *dma_buf);
+int virtio_dma_buf_get_uuid(struct dma_buf *dma_buf, uuid_t *uuid);
+
+#endif /* _LINUX_VIRTIO_DMA_BUF_H */
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 03/24] virtio-gpu: add VIRTIO_GPU_F_RESOURCE_UUID feature
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
2020-08-14 2:39 ` [PATCH 01/24] drm/virtio: Revert "drm/virtio: Call the right shmem helpers" Gurchetan Singh
2020-08-14 2:39 ` [PATCH 02/24] virtio: add dma-buf support for exported objects Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 04/24] drm/virtio: Support virtgpu exported resources Gurchetan Singh
` (20 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: David Stevens <stevensd@chromium.org>
This feature allows the guest to request a UUID from the host for a
particular virtio_gpu resource. The UUID can then be shared with other
virtio devices, to allow the other host devices to access the
virtio_gpu's corresponding host resource.
Signed-off-by: David Stevens <stevensd@chromium.org>
---
include/uapi/linux/virtio_gpu.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h
index 0c85914d9369..9721d58b4d58 100644
--- a/include/uapi/linux/virtio_gpu.h
+++ b/include/uapi/linux/virtio_gpu.h
@@ -50,6 +50,10 @@
* VIRTIO_GPU_CMD_GET_EDID
*/
#define VIRTIO_GPU_F_EDID 1
+/*
+ * VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID
+ */
+#define VIRTIO_GPU_F_RESOURCE_UUID 2
enum virtio_gpu_ctrl_type {
VIRTIO_GPU_UNDEFINED = 0,
@@ -66,6 +70,7 @@ enum virtio_gpu_ctrl_type {
VIRTIO_GPU_CMD_GET_CAPSET_INFO,
VIRTIO_GPU_CMD_GET_CAPSET,
VIRTIO_GPU_CMD_GET_EDID,
+ VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID,
/* 3d commands */
VIRTIO_GPU_CMD_CTX_CREATE = 0x0200,
@@ -87,6 +92,7 @@ enum virtio_gpu_ctrl_type {
VIRTIO_GPU_RESP_OK_CAPSET_INFO,
VIRTIO_GPU_RESP_OK_CAPSET,
VIRTIO_GPU_RESP_OK_EDID,
+ VIRTIO_GPU_RESP_OK_RESOURCE_UUID,
/* error responses */
VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200,
@@ -340,4 +346,17 @@ enum virtio_gpu_formats {
VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM = 134,
};
+/* VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID */
+struct virtio_gpu_resource_assign_uuid {
+ struct virtio_gpu_ctrl_hdr hdr;
+ __le32 resource_id;
+ __le32 padding;
+};
+
+/* VIRTIO_GPU_RESP_OK_RESOURCE_UUID */
+struct virtio_gpu_resp_resource_uuid {
+ struct virtio_gpu_ctrl_hdr hdr;
+ __u8 uuid[16];
+};
+
#endif
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 04/24] drm/virtio: Support virtgpu exported resources
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (2 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 03/24] virtio-gpu: add VIRTIO_GPU_F_RESOURCE_UUID feature Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 05/24] virtio: Add get_shm_region method Gurchetan Singh
` (19 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: David Stevens <stevensd@chromium.org>
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>
---
drivers/gpu/drm/virtio/virtgpu_drv.c | 3 +
drivers/gpu/drm/virtio/virtgpu_drv.h | 20 ++++++
drivers/gpu/drm/virtio/virtgpu_kms.c | 4 ++
drivers/gpu/drm/virtio/virtgpu_prime.c | 96 +++++++++++++++++++++++++-
drivers/gpu/drm/virtio/virtgpu_vq.c | 55 +++++++++++++++
5 files changed, 175 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
index ab4bed78e656..b039f493bda9 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -165,6 +165,7 @@ static unsigned int features[] = {
VIRTIO_GPU_F_VIRGL,
#endif
VIRTIO_GPU_F_EDID,
+ VIRTIO_GPU_F_RESOURCE_UUID,
};
static struct virtio_driver virtio_gpu_driver = {
.feature_table = features,
@@ -202,6 +203,8 @@ static struct drm_driver driver = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_mmap = drm_gem_prime_mmap,
+ .gem_prime_export = virtgpu_gem_prime_export,
+ .gem_prime_import = virtgpu_gem_prime_import,
.gem_prime_import_sg_table = virtgpu_gem_prime_import_sg_table,
.gem_create_object = virtio_gpu_create_object,
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 9ff9f4ac0522..fc84b4b526ff 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -49,6 +49,10 @@
#define DRIVER_MINOR 1
#define DRIVER_PATCHLEVEL 0
+#define UUID_INITIALIZING 0
+#define UUID_INITIALIZED 1
+#define UUID_INITIALIZATION_FAILED 2
+
struct virtio_gpu_object_params {
uint32_t format;
uint32_t width;
@@ -71,6 +75,9 @@ struct virtio_gpu_object {
uint32_t hw_res_handle;
bool dumb;
bool created;
+
+ int uuid_state;
+ uuid_t uuid;
};
#define gem_to_virtio_gpu_obj(gobj) \
container_of((gobj), struct virtio_gpu_object, base.base)
@@ -200,6 +207,7 @@ struct virtio_gpu_device {
bool has_virgl_3d;
bool has_edid;
bool has_indirect;
+ bool has_resource_assign_uuid;
struct work_struct config_changed_work;
@@ -210,6 +218,8 @@ struct virtio_gpu_device {
struct virtio_gpu_drv_capset *capsets;
uint32_t num_capsets;
struct list_head cap_cache;
+
+ spinlock_t resource_export_lock;
};
struct virtio_gpu_fpriv {
@@ -336,6 +346,10 @@ void virtio_gpu_dequeue_fence_func(struct work_struct *work);
void virtio_gpu_notify(struct virtio_gpu_device *vgdev);
+int
+virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object_array *objs);
+
/* virtgpu_display.c */
void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
@@ -367,6 +381,12 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo);
/* virtgpu_prime.c */
+struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
+ int flags);
+struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev,
+ struct dma_buf *buf);
+int virtgpu_gem_prime_get_uuid(struct drm_gem_object *obj,
+ uuid_t *uuid);
struct drm_gem_object *virtgpu_gem_prime_import_sg_table(
struct drm_device *dev, struct dma_buf_attachment *attach,
struct sg_table *sgt);
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 0a5c8cf409fb..bf060c69850f 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -118,6 +118,7 @@ int virtio_gpu_init(struct drm_device *dev)
vgdev->dev = dev->dev;
spin_lock_init(&vgdev->display_info_lock);
+ spin_lock_init(&vgdev->resource_export_lock);
ida_init(&vgdev->ctx_id_ida);
ida_init(&vgdev->resource_ida);
init_waitqueue_head(&vgdev->resp_wq);
@@ -146,6 +147,9 @@ int virtio_gpu_init(struct drm_device *dev)
if (virtio_has_feature(vgdev->vdev, VIRTIO_RING_F_INDIRECT_DESC)) {
vgdev->has_indirect = true;
}
+ if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_UUID)) {
+ vgdev->has_resource_assign_uuid = true;
+ }
DRM_INFO("features: %cvirgl %cedid\n",
vgdev->has_virgl_3d ? '+' : '-',
diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
index 050d24c39a8f..acd14ef73d56 100644
--- a/drivers/gpu/drm/virtio/virtgpu_prime.c
+++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -23,12 +23,102 @@
*/
#include <drm/drm_prime.h>
+#include <linux/virtio_dma_buf.h>
#include "virtgpu_drv.h"
-/* Empty Implementations as there should not be any other driver for a virtual
- * device that might share buffers with virtgpu
- */
+static int virtgpu_virtio_get_uuid(struct dma_buf *buf,
+ uuid_t *uuid)
+{
+ struct drm_gem_object *obj = buf->priv;
+ struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
+ struct virtio_gpu_device *vgdev = obj->dev->dev_private;
+
+ wait_event(vgdev->resp_wq, bo->uuid_state != UUID_INITIALIZING);
+ if (bo->uuid_state != UUID_INITIALIZED)
+ return -ENODEV;
+
+ uuid_copy(uuid, &bo->uuid);
+
+ return 0;
+}
+
+const struct virtio_dma_buf_ops virtgpu_dmabuf_ops = {
+ .ops = {
+ .cache_sgt_mapping = true,
+ .attach = virtio_dma_buf_attach,
+ .detach = drm_gem_map_detach,
+ .map_dma_buf = drm_gem_map_dma_buf,
+ .unmap_dma_buf = drm_gem_unmap_dma_buf,
+ .release = drm_gem_dmabuf_release,
+ .mmap = drm_gem_dmabuf_mmap,
+ .vmap = drm_gem_dmabuf_vmap,
+ .vunmap = drm_gem_dmabuf_vunmap,
+ },
+ .device_attach = drm_gem_map_attach,
+ .get_uuid = virtgpu_virtio_get_uuid,
+};
+
+struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
+ int flags)
+{
+ struct dma_buf *buf;
+ struct drm_device *dev = obj->dev;
+ struct virtio_gpu_device *vgdev = dev->dev_private;
+ struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
+ struct virtio_gpu_object_array *objs;
+ int ret = 0;
+ DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
+
+ if (vgdev->has_resource_assign_uuid) {
+ objs = virtio_gpu_array_alloc(1);
+ if (!objs)
+ return ERR_PTR(-ENOMEM);
+ virtio_gpu_array_add_obj(objs, &bo->base.base);
+
+ ret = virtio_gpu_cmd_resource_assign_uuid(vgdev, objs);
+ if (ret)
+ return ERR_PTR(ret);
+ virtio_gpu_notify(vgdev);
+ } else {
+ bo->uuid_state = UUID_INITIALIZATION_FAILED;
+ }
+
+ exp_info.ops = &virtgpu_dmabuf_ops.ops;
+ exp_info.size = obj->size;
+ exp_info.flags = flags;
+ exp_info.priv = obj;
+ exp_info.resv = obj->resv;
+
+ buf = virtio_dma_buf_export(&exp_info);
+ if (IS_ERR(buf))
+ return buf;
+
+ drm_dev_get(dev);
+ drm_gem_object_get(obj);
+
+ return buf;
+}
+
+struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev,
+ struct dma_buf *buf)
+{
+ struct drm_gem_object *obj;
+
+ if (buf->ops == &virtgpu_dmabuf_ops.ops) {
+ obj = buf->priv;
+ if (obj->dev == dev) {
+ /*
+ * Importing dmabuf exported from our own gem increases
+ * refcount on gem itself instead of f_count of dmabuf.
+ */
+ drm_gem_object_get(obj);
+ return obj;
+ }
+ }
+
+ return drm_gem_prime_import(dev, buf);
+}
struct drm_gem_object *virtgpu_gem_prime_import_sg_table(
struct drm_device *dev, struct dma_buf_attachment *attach,
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 9e663a5d9952..55af6fc7bc7c 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -1107,3 +1107,58 @@ void virtio_gpu_cursor_ping(struct virtio_gpu_device *vgdev,
memcpy(cur_p, &output->cursor, sizeof(output->cursor));
virtio_gpu_queue_cursor(vgdev, vbuf);
}
+
+static void virtio_gpu_cmd_resource_uuid_cb(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_vbuffer *vbuf)
+{
+ struct virtio_gpu_object *obj =
+ gem_to_virtio_gpu_obj(vbuf->objs->objs[0]);
+ struct virtio_gpu_resp_resource_uuid *resp =
+ (struct virtio_gpu_resp_resource_uuid *)vbuf->resp_buf;
+ uint32_t resp_type = le32_to_cpu(resp->hdr.type);
+
+ spin_lock(&vgdev->resource_export_lock);
+ WARN_ON(obj->uuid_state != UUID_INITIALIZING);
+
+ if (resp_type == VIRTIO_GPU_RESP_OK_RESOURCE_UUID &&
+ obj->uuid_state == UUID_INITIALIZING) {
+ memcpy(&obj->uuid.b, resp->uuid, sizeof(obj->uuid.b));
+ obj->uuid_state = UUID_INITIALIZED;
+ } else {
+ obj->uuid_state = UUID_INITIALIZATION_FAILED;
+ }
+ spin_unlock(&vgdev->resource_export_lock);
+
+ wake_up_all(&vgdev->resp_wq);
+}
+
+int
+virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object_array *objs)
+{
+ struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
+ struct virtio_gpu_resource_assign_uuid *cmd_p;
+ struct virtio_gpu_vbuffer *vbuf;
+ struct virtio_gpu_resp_resource_uuid *resp_buf;
+
+ resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL);
+ if (!resp_buf) {
+ spin_lock(&vgdev->resource_export_lock);
+ bo->uuid_state = UUID_INITIALIZATION_FAILED;
+ spin_unlock(&vgdev->resource_export_lock);
+ virtio_gpu_array_put_free(objs);
+ return -ENOMEM;
+ }
+
+ cmd_p = virtio_gpu_alloc_cmd_resp(vgdev,
+ virtio_gpu_cmd_resource_uuid_cb, &vbuf, sizeof(*cmd_p),
+ sizeof(struct virtio_gpu_resp_resource_uuid), resp_buf);
+ memset(cmd_p, 0, sizeof(*cmd_p));
+
+ cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID);
+ cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
+
+ vbuf->objs = objs;
+ virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
+ return 0;
+}
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 05/24] virtio: Add get_shm_region method
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (3 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 04/24] drm/virtio: Support virtgpu exported resources Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 06/24] virtio: Implement get_shm_region for PCI transport Gurchetan Singh
` (18 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: Sebastien Boeuf <sebastien.boeuf@intel.com>
Virtio defines 'shared memory regions' that provide a continuously
shared region between the host and guest.
Provide a method to find a particular region on a device.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
include/linux/virtio_config.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index bb4cc4910750..af4d98addc61 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -10,6 +10,11 @@
struct irq_affinity;
+struct virtio_shm_region {
+ u64 addr;
+ u64 len;
+};
+
/**
* virtio_config_ops - operations for configuring a virtio device
* Note: Do not assume that a transport implements all of the operations
@@ -65,6 +70,9 @@ struct irq_affinity;
* the caller can then copy.
* @set_vq_affinity: set the affinity for a virtqueue (optional).
* @get_vq_affinity: get the affinity for a virtqueue (optional).
+ * @get_shm_region: get a shared memory region based on the index.
+ * This does not reserve the resources and caller is expected to call
+ * devm_request_mem_region() or similar to reserve resources.
*/
typedef void vq_callback_t(struct virtqueue *);
struct virtio_config_ops {
@@ -88,6 +96,8 @@ struct virtio_config_ops {
const struct cpumask *cpu_mask);
const struct cpumask *(*get_vq_affinity)(struct virtio_device *vdev,
int index);
+ bool (*get_shm_region)(struct virtio_device *vdev,
+ struct virtio_shm_region *region, u8 id);
};
/* If driver didn't advertise the feature, it will never appear. */
@@ -250,6 +260,15 @@ int virtqueue_set_affinity(struct virtqueue *vq, const struct cpumask *cpu_mask)
return 0;
}
+static inline
+bool virtio_get_shm_region(struct virtio_device *vdev,
+ struct virtio_shm_region *region, u8 id)
+{
+ if (!vdev->config->get_shm_region)
+ return false;
+ return vdev->config->get_shm_region(vdev, region, id);
+}
+
static inline bool virtio_is_little_endian(struct virtio_device *vdev)
{
return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) ||
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 06/24] virtio: Implement get_shm_region for PCI transport
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (4 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 05/24] virtio: Add get_shm_region method Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 07/24] virtio: Implement get_shm_region for MMIO transport Gurchetan Singh
` (17 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: Sebastien Boeuf <sebastien.boeuf@intel.com>
On PCI the shm regions are found using capability entries;
find a region by searching for the capability.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
drivers/virtio/virtio_pci_modern.c | 102 +++++++++++++++++++++++++++++
include/uapi/linux/virtio_pci.h | 11 +++-
2 files changed, 112 insertions(+), 1 deletion(-)
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index db93cedd262f..484c2669e1f3 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -444,6 +444,106 @@ static void del_vq(struct virtio_pci_vq_info *info)
vring_del_virtqueue(vq);
}
+static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id,
+ u8 *bar, u64 *offset, u64 *len)
+{
+ int pos;
+
+ for (pos = pci_find_capability(dev, PCI_CAP_ID_VNDR); pos > 0;
+ pos = pci_find_next_capability(dev, pos, PCI_CAP_ID_VNDR)) {
+ u8 type, cap_len, id;
+ u32 tmp32;
+ u64 res_offset, res_length;
+
+ pci_read_config_byte(dev, pos + offsetof(struct virtio_pci_cap,
+ cfg_type),
+ &type);
+
+ if (type != VIRTIO_PCI_CAP_SHARED_MEMORY_CFG)
+ continue;
+
+ pci_read_config_byte(dev, pos + offsetof(struct virtio_pci_cap,
+ cap_len),
+ &cap_len);
+
+ if (cap_len != sizeof(struct virtio_pci_cap64)) {
+ dev_err(&dev->dev, "%s: shm cap with bad size offset:%d, size: %d\n",
+ __func__, pos, cap_len);
+ continue;
+ }
+
+ pci_read_config_byte(dev, pos + offsetof(struct virtio_pci_cap,
+ id),
+ &id);
+ if (id != required_id)
+ continue;
+
+ /* Type, and ID match, looks good */
+ pci_read_config_byte(dev, pos + offsetof(struct virtio_pci_cap,
+ bar),
+ bar);
+
+ /* Read the lower 32bit of length and offset */
+ pci_read_config_dword(dev, pos + offsetof(struct virtio_pci_cap,
+ offset),
+ &tmp32);
+ res_offset = tmp32;
+ pci_read_config_dword(dev, pos + offsetof(struct virtio_pci_cap,
+ length),
+ &tmp32);
+ res_length = tmp32;
+
+ /* and now the top half */
+ pci_read_config_dword(dev,
+ pos + offsetof(struct virtio_pci_cap64,
+ offset_hi),
+ &tmp32);
+
+ res_offset |= ((u64)tmp32) << 32;
+ pci_read_config_dword(dev,
+ pos + offsetof(struct virtio_pci_cap64,
+ length_hi),
+ &tmp32);
+ res_length |= ((u64)tmp32) << 32;
+
+ *offset = res_offset;
+ *len = res_length;
+
+ return pos;
+ }
+
+ return 0;
+}
+
+static bool vp_get_shm_region(struct virtio_device *vdev,
+ struct virtio_shm_region *region, u8 id)
+{
+ struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+ struct pci_dev *pci_dev = vp_dev->pci_dev;
+ u8 bar;
+ u64 offset, len;
+ phys_addr_t phys_addr;
+ size_t bar_len;
+
+ if (!virtio_pci_find_shm_cap(pci_dev, id, &bar, &offset, &len))
+ return false;
+
+ phys_addr = pci_resource_start(pci_dev, bar);
+ bar_len = pci_resource_len(pci_dev, bar);
+
+ if (offset + len > bar_len) {
+ dev_err(&pci_dev->dev,
+ "%s: bar shorter than cap offset+len\n",
+ __func__);
+ return false;
+ }
+
+ region->len = len;
+ region->addr = (u64) phys_addr + offset;
+
+ return true;
+}
+
static const struct virtio_config_ops virtio_pci_config_nodev_ops = {
.get = NULL,
.set = NULL,
@@ -458,6 +558,7 @@ static const struct virtio_config_ops virtio_pci_config_nodev_ops = {
.bus_name = vp_bus_name,
.set_vq_affinity = vp_set_vq_affinity,
.get_vq_affinity = vp_get_vq_affinity,
+ .get_shm_region = vp_get_shm_region,
};
static const struct virtio_config_ops virtio_pci_config_ops = {
@@ -474,6 +575,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = {
.bus_name = vp_bus_name,
.set_vq_affinity = vp_set_vq_affinity,
.get_vq_affinity = vp_get_vq_affinity,
+ .get_shm_region = vp_get_shm_region,
};
/**
diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_pci.h
index 90007a1abcab..3a86f36d7e3d 100644
--- a/include/uapi/linux/virtio_pci.h
+++ b/include/uapi/linux/virtio_pci.h
@@ -113,6 +113,8 @@
#define VIRTIO_PCI_CAP_DEVICE_CFG 4
/* PCI configuration access */
#define VIRTIO_PCI_CAP_PCI_CFG 5
+/* Additional shared memory capability */
+#define VIRTIO_PCI_CAP_SHARED_MEMORY_CFG 8
/* This is the PCI capability header: */
struct virtio_pci_cap {
@@ -121,11 +123,18 @@ struct virtio_pci_cap {
__u8 cap_len; /* Generic PCI field: capability length */
__u8 cfg_type; /* Identifies the structure. */
__u8 bar; /* Where to find it. */
- __u8 padding[3]; /* Pad to full dword. */
+ __u8 id; /* Multiple capabilities of the same type */
+ __u8 padding[2]; /* Pad to full dword. */
__le32 offset; /* Offset within bar. */
__le32 length; /* Length of the structure, in bytes. */
};
+struct virtio_pci_cap64 {
+ struct virtio_pci_cap cap;
+ __le32 offset_hi; /* Most sig 32 bits of offset */
+ __le32 length_hi; /* Most sig 32 bits of length */
+};
+
struct virtio_pci_notify_cap {
struct virtio_pci_cap cap;
__le32 notify_off_multiplier; /* Multiplier for queue_notify_off. */
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 07/24] virtio: Implement get_shm_region for MMIO transport
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (5 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 06/24] virtio: Implement get_shm_region for PCI transport Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 08/24] drm/virtio: blob prep: refactor getting pages and attaching backing Gurchetan Singh
` (16 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: Sebastien Boeuf <sebastien.boeuf@intel.com>
On MMIO a new set of registers is defined for finding SHM
regions. Add their definitions and use them to find the region.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
---
drivers/virtio/virtio_mmio.c | 31 +++++++++++++++++++++++++++++++
include/uapi/linux/virtio_mmio.h | 11 +++++++++++
2 files changed, 42 insertions(+)
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 627ac0487494..238383ff1064 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -498,6 +498,36 @@ static const char *vm_bus_name(struct virtio_device *vdev)
return vm_dev->pdev->name;
}
+static bool vm_get_shm_region(struct virtio_device *vdev,
+ struct virtio_shm_region *region, u8 id)
+{
+ struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+ u64 len, addr;
+
+ /* Select the region we're interested in */
+ writel(id, vm_dev->base + VIRTIO_MMIO_SHM_SEL);
+
+ /* Read the region size */
+ len = (u64) readl(vm_dev->base + VIRTIO_MMIO_SHM_LEN_LOW);
+ len |= (u64) readl(vm_dev->base + VIRTIO_MMIO_SHM_LEN_HIGH) << 32;
+
+ region->len = len;
+
+ /* Check if region length is -1. If that's the case, the shared memory
+ * region does not exist and there is no need to proceed further.
+ */
+ if (len == ~(u64)0)
+ return false;
+
+ /* Read the region base address */
+ addr = (u64) readl(vm_dev->base + VIRTIO_MMIO_SHM_BASE_LOW);
+ addr |= (u64) readl(vm_dev->base + VIRTIO_MMIO_SHM_BASE_HIGH) << 32;
+
+ region->addr = addr;
+
+ return true;
+}
+
static const struct virtio_config_ops virtio_mmio_config_ops = {
.get = vm_get,
.set = vm_set,
@@ -510,6 +540,7 @@ static const struct virtio_config_ops virtio_mmio_config_ops = {
.get_features = vm_get_features,
.finalize_features = vm_finalize_features,
.bus_name = vm_bus_name,
+ .get_shm_region = vm_get_shm_region,
};
diff --git a/include/uapi/linux/virtio_mmio.h b/include/uapi/linux/virtio_mmio.h
index c4b09689ab64..0650f91bea6c 100644
--- a/include/uapi/linux/virtio_mmio.h
+++ b/include/uapi/linux/virtio_mmio.h
@@ -122,6 +122,17 @@
#define VIRTIO_MMIO_QUEUE_USED_LOW 0x0a0
#define VIRTIO_MMIO_QUEUE_USED_HIGH 0x0a4
+/* Shared memory region id */
+#define VIRTIO_MMIO_SHM_SEL 0x0ac
+
+/* Shared memory region length, 64 bits in two halves */
+#define VIRTIO_MMIO_SHM_LEN_LOW 0x0b0
+#define VIRTIO_MMIO_SHM_LEN_HIGH 0x0b4
+
+/* Shared memory region base address, 64 bits in two halves */
+#define VIRTIO_MMIO_SHM_BASE_LOW 0x0b8
+#define VIRTIO_MMIO_SHM_BASE_HIGH 0x0bc
+
/* Configuration atomicity value */
#define VIRTIO_MMIO_CONFIG_GENERATION 0x0fc
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 08/24] drm/virtio: blob prep: refactor getting pages and attaching backing
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (6 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 07/24] virtio: Implement get_shm_region for MMIO transport Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 09/24] drm/virtio: blob prep: make CPU responses more generic Gurchetan Singh
` (15 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
Useful for upcoming blob resources.
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_object.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index 1359eb8f1a02..9d68f260d998 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -227,22 +227,22 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
goto err_put_objs;
}
+ ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents);
+ if (ret != 0) {
+ virtio_gpu_free_object(&shmem_obj->base);
+ return ret;
+ }
+
if (params->virgl) {
virtio_gpu_cmd_resource_create_3d(vgdev, bo, params,
objs, fence);
+ virtio_gpu_object_attach(vgdev, bo, ents, nents);
} else {
virtio_gpu_cmd_create_resource(vgdev, bo, params,
objs, fence);
+ virtio_gpu_object_attach(vgdev, bo, ents, nents);
}
- ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents);
- if (ret != 0) {
- virtio_gpu_free_object(&shmem_obj->base);
- return ret;
- }
-
- virtio_gpu_object_attach(vgdev, bo, ents, nents);
-
*bo_ptr = bo;
return 0;
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 09/24] drm/virtio: blob prep: make CPU responses more generic
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (7 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 08/24] drm/virtio: blob prep: refactor getting pages and attaching backing Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 10/24] virtio-gpu api: blob resources Gurchetan Singh
` (14 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
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>
---
drivers/gpu/drm/virtio/virtgpu_drv.h | 6 +++---
drivers/gpu/drm/virtio/virtgpu_prime.c | 6 +++---
drivers/gpu/drm/virtio/virtgpu_vq.c | 10 +++++-----
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index fc84b4b526ff..c74c38123ff6 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -49,9 +49,9 @@
#define DRIVER_MINOR 1
#define DRIVER_PATCHLEVEL 0
-#define UUID_INITIALIZING 0
-#define UUID_INITIALIZED 1
-#define UUID_INITIALIZATION_FAILED 2
+#define STATE_INITIALIZING 0
+#define STATE_OK 1
+#define STATE_ERR 2
struct virtio_gpu_object_params {
uint32_t format;
diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
index acd14ef73d56..3552db128ba3 100644
--- a/drivers/gpu/drm/virtio/virtgpu_prime.c
+++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -34,8 +34,8 @@ static int virtgpu_virtio_get_uuid(struct dma_buf *buf,
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
struct virtio_gpu_device *vgdev = obj->dev->dev_private;
- wait_event(vgdev->resp_wq, bo->uuid_state != UUID_INITIALIZING);
- if (bo->uuid_state != UUID_INITIALIZED)
+ wait_event(vgdev->resp_wq, bo->uuid_state != STATE_INITIALIZING);
+ if (bo->uuid_state != STATE_OK)
return -ENODEV;
uuid_copy(uuid, &bo->uuid);
@@ -81,7 +81,7 @@ struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
return ERR_PTR(ret);
virtio_gpu_notify(vgdev);
} else {
- bo->uuid_state = UUID_INITIALIZATION_FAILED;
+ bo->uuid_state = STATE_ERR;
}
exp_info.ops = &virtgpu_dmabuf_ops.ops;
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 55af6fc7bc7c..3f225a08ecf3 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -1118,14 +1118,14 @@ static void virtio_gpu_cmd_resource_uuid_cb(struct virtio_gpu_device *vgdev,
uint32_t resp_type = le32_to_cpu(resp->hdr.type);
spin_lock(&vgdev->resource_export_lock);
- WARN_ON(obj->uuid_state != UUID_INITIALIZING);
+ WARN_ON(obj->uuid_state != STATE_INITIALIZING);
if (resp_type == VIRTIO_GPU_RESP_OK_RESOURCE_UUID &&
- obj->uuid_state == UUID_INITIALIZING) {
+ obj->uuid_state == STATE_INITIALIZING) {
memcpy(&obj->uuid.b, resp->uuid, sizeof(obj->uuid.b));
- obj->uuid_state = UUID_INITIALIZED;
+ obj->uuid_state = STATE_OK;
} else {
- obj->uuid_state = UUID_INITIALIZATION_FAILED;
+ obj->uuid_state = STATE_ERR;
}
spin_unlock(&vgdev->resource_export_lock);
@@ -1144,7 +1144,7 @@ virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev,
resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL);
if (!resp_buf) {
spin_lock(&vgdev->resource_export_lock);
- bo->uuid_state = UUID_INITIALIZATION_FAILED;
+ bo->uuid_state = STATE_ERR;
spin_unlock(&vgdev->resource_export_lock);
virtio_gpu_array_put_free(objs);
return -ENOMEM;
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 10/24] virtio-gpu api: blob resources
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (8 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 09/24] drm/virtio: blob prep: make CPU responses more generic Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 11/24] virtio-gpu api: host visible feature Gurchetan Singh
` (13 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: Gerd Hoffmann <kraxel@redhat.com>
A blob resource is a container for:
- VIRTGPU_BLOB_MEM_GUEST: a guest memory allocation
(referred to as a "guest-only blob resource")
- VIRTGPU_BLOB_MEM_HOST3D: a host3d memory allocation
(referred to as a "host-only blob resource")
- VIRTGPU_BLOB_MEM_HOST3D_GUEST: a guest + host3d memory allocation
(referred to as a "default blob resource").
The memory properties of the blob resource must be described by
`blob_mem`.
For default and guest only blob resources set, `nents` guest system
pages are assigned to the resource. For default blob resources,
these guest pages are used for transfer operations. Attach/detach is
also possible to allow swap-in/swap-out, but isn't required since it
may not be applicable to future blob mem types
(shared guest/guest vram).
Host allocations depend on whether the 3D is supported. If 3D is not
supported, the only valid field for `blob_mem` is
VIRTGPU_BLOB_MEM_GUEST.
If 3D is supported, the virtio-gpu resource is created from the
context local object identified by the `blob_id`. The actual host
allocation done by the EXECBUFFER ioctl or for convenience the
`cmd` field in the RESOURCE_CREATE_BLOB ioctl.
Userspace must specify if the blob resource is intended to be used
for userspace mapping, sharing between virtio-gpu contexts and/or
sharing between virtio devices. This is done via `blob_flags`.
For 3D hosts, both VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D and
VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D may be used to update
the host resource. There is no restriction on the image/buffer
view the guest/host userspace has on the blob resource.
VIRTIO_GPU_CMD_SET_SCANOUT_BLOB / VIRTIO_GPU_CMD_RESOURCE_FLUSH may
be used with blob resources as well. The modifier is intentionally
left out of SCANOUT_BLOB, and auxilary blobs are also left out
as a simplification.
The use case for blob resources is zero-copy, needed for coherent
memory in virglrenderer. Host only blob resources are not mappable
without the feature described in the next patch, but are shareable.
Future work:
- Emulated coherent `blob_mem` type for QEMU/vhost-user
- A `blob_mem` type for guest-only resources imported in
cache-coherent FOSS GPU/display drivers.
- Display integration involving the blob model using seamless
Wayland windows.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Co-developed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Lingfeng Yang <lfy@google.com>
---
include/uapi/drm/virtgpu_drm.h | 37 +++++++++++++++++++++++++++-
include/uapi/linux/virtio_gpu.h | 43 +++++++++++++++++++++++++++++++++
2 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h
index f06a789f34cd..bb224f604c9e 100644
--- a/include/uapi/drm/virtgpu_drm.h
+++ b/include/uapi/drm/virtgpu_drm.h
@@ -46,6 +46,7 @@ extern "C" {
#define DRM_VIRTGPU_TRANSFER_TO_HOST 0x07
#define DRM_VIRTGPU_WAIT 0x08
#define DRM_VIRTGPU_GET_CAPS 0x09
+#define DRM_VIRTGPU_RESOURCE_CREATE_BLOB 0x0a
#define VIRTGPU_EXECBUF_FENCE_FD_IN 0x01
#define VIRTGPU_EXECBUF_FENCE_FD_OUT 0x02
@@ -71,6 +72,7 @@ struct drm_virtgpu_execbuffer {
#define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
#define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */
+#define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */
struct drm_virtgpu_getparam {
__u64 param;
@@ -100,7 +102,7 @@ struct drm_virtgpu_resource_info {
__u32 bo_handle;
__u32 res_handle;
__u32 size;
- __u32 stride;
+ __u32 blob_mem;
};
struct drm_virtgpu_3d_box {
@@ -117,6 +119,8 @@ struct drm_virtgpu_3d_transfer_to_host {
struct drm_virtgpu_3d_box box;
__u32 level;
__u32 offset;
+ __u32 stride;
+ __u32 layer_stride;
};
struct drm_virtgpu_3d_transfer_from_host {
@@ -124,6 +128,8 @@ struct drm_virtgpu_3d_transfer_from_host {
struct drm_virtgpu_3d_box box;
__u32 level;
__u32 offset;
+ __u32 stride;
+ __u32 layer_stride;
};
#define VIRTGPU_WAIT_NOWAIT 1 /* like it */
@@ -140,6 +146,31 @@ struct drm_virtgpu_get_caps {
__u32 pad;
};
+struct drm_virtgpu_resource_create_blob {
+#define VIRTGPU_BLOB_MEM_GUEST 0x0001
+#define VIRTGPU_BLOB_MEM_HOST3D 0x0002
+#define VIRTGPU_BLOB_MEM_HOST3D_GUEST 0x0003
+
+#define VIRTGPU_BLOB_FLAG_USE_MAPPABLE 0x0001
+#define VIRTGPU_BLOB_FLAG_USE_SHAREABLE 0x0002
+#define VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004
+ /* zero is invalid blob_mem */
+ __u32 blob_mem;
+ __u32 blob_flags;
+ __u32 bo_handle;
+ __u32 res_handle;
+ __u64 size;
+
+ /*
+ * for 3D contexts with VIRTGPU_BLOB_MEM_HOST3D_GUEST and
+ * VIRTGPU_BLOB_MEM_HOST3D otherwise, must be zero.
+ */
+ __u32 pad;
+ __u32 cmd_size;
+ __u64 cmd;
+ __u64 blob_id;
+};
+
#define DRM_IOCTL_VIRTGPU_MAP \
DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)
@@ -175,6 +206,10 @@ struct drm_virtgpu_get_caps {
DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \
struct drm_virtgpu_get_caps)
+#define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE_BLOB, \
+ struct drm_virtgpu_resource_create_blob)
+
#if defined(__cplusplus)
}
#endif
diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h
index 9721d58b4d58..a27ea3215d67 100644
--- a/include/uapi/linux/virtio_gpu.h
+++ b/include/uapi/linux/virtio_gpu.h
@@ -55,6 +55,11 @@
*/
#define VIRTIO_GPU_F_RESOURCE_UUID 2
+/*
+ * VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB
+ */
+#define VIRTIO_GPU_F_RESOURCE_BLOB 3
+
enum virtio_gpu_ctrl_type {
VIRTIO_GPU_UNDEFINED = 0,
@@ -71,6 +76,8 @@ enum virtio_gpu_ctrl_type {
VIRTIO_GPU_CMD_GET_CAPSET,
VIRTIO_GPU_CMD_GET_EDID,
VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID,
+ VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB,
+ VIRTIO_GPU_CMD_SET_SCANOUT_BLOB,
/* 3d commands */
VIRTIO_GPU_CMD_CTX_CREATE = 0x0200,
@@ -359,4 +366,40 @@ struct virtio_gpu_resp_resource_uuid {
__u8 uuid[16];
};
+/* VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB */
+struct virtio_gpu_resource_create_blob {
+ struct virtio_gpu_ctrl_hdr hdr;
+ __le32 resource_id;
+#define VIRTIO_GPU_BLOB_MEM_GUEST 0x0001
+#define VIRTIO_GPU_BLOB_MEM_HOST3D 0x0002
+#define VIRTIO_GPU_BLOB_MEM_HOST3D_GUEST 0x0003
+
+#define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE 0x0001
+#define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE 0x0002
+#define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004
+ /* zero is invalid blob mem */
+ __le32 blob_mem;
+ __le32 blob_flags;
+ __le64 blob_id;
+ __le64 size;
+ __le32 nr_entries;
+ /*
+ * sizeof(nr_entries * virtio_gpu_mem_entry) bytes follow
+ */
+};
+
+/* VIRTIO_GPU_CMD_SET_SCANOUT_BLOB */
+struct virtio_gpu_set_scanout_blob {
+ struct virtio_gpu_ctrl_hdr hdr;
+ struct virtio_gpu_rect r;
+ __le32 scanout_id;
+ __le32 resource_id;
+ __le32 width;
+ __le32 height;
+ __le32 format;
+ __le32 padding;
+ __le32 strides[4];
+ __le32 offsets[4];
+};
+
#endif
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 11/24] virtio-gpu api: host visible feature
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (9 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 10/24] virtio-gpu api: blob resources Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 12/24] virtio-gpu api: cross-device feature Gurchetan Singh
` (12 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: Gerd Hoffmann <kraxel@redhat.com>
This patch adds a new virtgpu feature that allows directly
mapping host allocated resources.
This is based on virtio shared memory regions, which allows
querying for memory regions using PCI transport. Each shared
memory region has an associated "shmid", the meaning of which
is device specific.
For virtio-gpu, we can define the shared memory region with id
VIRTIO_GPU_SHM_ID_HOST_VISIBLE to be the "host visible memory
region".
The presence of the host visible memory region means the following
hypercalls are supported:
1) VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB
This hypercall tells the host to inject the host resource's
mapping in an offset into virtio-gpu's PCI address space.
This is typically done via KVM_SET_USER_MEMORY_REGION on Linux
hosts.
On success, VIRTIO_GPU_RESP_OK_MAP_INFO is returned, which
specifies the host buffer's caching type and possibly in the
future performance hints about the buffer..
2) VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB
This hypercall tells the host to remove the host resource's
mapping from the guest VM.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Co-developed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: Lingfeng Yang <lfy@google.com>
---
include/uapi/drm/virtgpu_drm.h | 1 +
include/uapi/linux/virtio_gpu.h | 35 +++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h
index bb224f604c9e..e1b1518f9acc 100644
--- a/include/uapi/drm/virtgpu_drm.h
+++ b/include/uapi/drm/virtgpu_drm.h
@@ -73,6 +73,7 @@ struct drm_virtgpu_execbuffer {
#define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
#define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */
#define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */
+#define VIRTGPU_PARAM_HOST_VISIBLE 4 /* Host blob resources are mappable */
struct drm_virtgpu_getparam {
__u64 param;
diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h
index a27ea3215d67..fee69725964c 100644
--- a/include/uapi/linux/virtio_gpu.h
+++ b/include/uapi/linux/virtio_gpu.h
@@ -88,6 +88,8 @@ enum virtio_gpu_ctrl_type {
VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D,
VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D,
VIRTIO_GPU_CMD_SUBMIT_3D,
+ VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB,
+ VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB,
/* cursor commands */
VIRTIO_GPU_CMD_UPDATE_CURSOR = 0x0300,
@@ -100,6 +102,7 @@ enum virtio_gpu_ctrl_type {
VIRTIO_GPU_RESP_OK_CAPSET,
VIRTIO_GPU_RESP_OK_EDID,
VIRTIO_GPU_RESP_OK_RESOURCE_UUID,
+ VIRTIO_GPU_RESP_OK_MAP_INFO,
/* error responses */
VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200,
@@ -110,6 +113,11 @@ enum virtio_gpu_ctrl_type {
VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER,
};
+enum virtio_gpu_shm_id {
+ VIRTIO_GPU_SHM_ID_UNDEFINED = 0,
+ VIRTIO_GPU_SHM_ID_HOST_VISIBLE = 1
+};
+
#define VIRTIO_GPU_FLAG_FENCE (1 << 0)
struct virtio_gpu_ctrl_hdr {
@@ -402,4 +410,31 @@ struct virtio_gpu_set_scanout_blob {
__le32 offsets[4];
};
+/* VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB */
+struct virtio_gpu_resource_map_blob {
+ struct virtio_gpu_ctrl_hdr hdr;
+ __le32 resource_id;
+ __le32 padding;
+ __le64 offset;
+};
+
+/* VIRTIO_GPU_RESP_OK_MAP_INFO */
+#define VIRTIO_GPU_MAP_CACHE_MASK 0x0f
+#define VIRTIO_GPU_MAP_CACHE_NONE 0x00
+#define VIRTIO_GPU_MAP_CACHE_CACHED 0x01
+#define VIRTIO_GPU_MAP_CACHE_UNCACHED 0x02
+#define VIRTIO_GPU_MAP_CACHE_WC 0x03
+struct virtio_gpu_resp_map_info {
+ struct virtio_gpu_ctrl_hdr hdr;
+ __u32 map_info;
+ __u32 padding;
+};
+
+/* VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB */
+struct virtio_gpu_resource_unmap_blob {
+ struct virtio_gpu_ctrl_hdr hdr;
+ __le32 resource_id;
+ __le32 padding;
+};
+
#endif
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 12/24] virtio-gpu api: cross-device feature
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (10 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 11/24] virtio-gpu api: host visible feature Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 13/24] drm/virtio: implement blob resources: probe for the feature Gurchetan Singh
` (11 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
This feature was recently added to virtio-gpu, lets make
it userspace queryable.
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
include/uapi/drm/virtgpu_drm.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h
index e1b1518f9acc..b9ec26e9c646 100644
--- a/include/uapi/drm/virtgpu_drm.h
+++ b/include/uapi/drm/virtgpu_drm.h
@@ -74,6 +74,7 @@ struct drm_virtgpu_execbuffer {
#define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */
#define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */
#define VIRTGPU_PARAM_HOST_VISIBLE 4 /* Host blob resources are mappable */
+#define VIRTGPU_PARAM_CROSS_DEVICE 5 /* Cross virtio-device resource sharing */
struct drm_virtgpu_getparam {
__u64 param;
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 13/24] drm/virtio: implement blob resources: probe for the feature.
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (11 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 12/24] virtio-gpu api: cross-device feature Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 14/24] drm/virtio: implement blob resources: probe for host visible region Gurchetan Singh
` (10 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_debugfs.c | 1 +
drivers/gpu/drm/virtio/virtgpu_drv.c | 1 +
drivers/gpu/drm/virtio/virtgpu_drv.h | 1 +
drivers/gpu/drm/virtio/virtgpu_kms.c | 10 +++++++---
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
index 3221520f61f0..e99d1c3c0a66 100644
--- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c
+++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
@@ -48,6 +48,7 @@ static int virtio_gpu_features(struct seq_file *m, void *data)
virtio_add_bool(m, "virgl", vgdev->has_virgl_3d);
virtio_add_bool(m, "edid", vgdev->has_edid);
virtio_add_bool(m, "indirect", vgdev->has_indirect);
+ virtio_add_bool(m, "blob resources", vgdev->has_resource_blob);
virtio_add_int(m, "cap sets", vgdev->num_capsets);
virtio_add_int(m, "scanouts", vgdev->num_scanouts);
return 0;
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
index b039f493bda9..3d04e428be14 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -166,6 +166,7 @@ static unsigned int features[] = {
#endif
VIRTIO_GPU_F_EDID,
VIRTIO_GPU_F_RESOURCE_UUID,
+ VIRTIO_GPU_F_RESOURCE_BLOB,
};
static struct virtio_driver virtio_gpu_driver = {
.feature_table = features,
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index c74c38123ff6..a529727d6114 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -208,6 +208,7 @@ struct virtio_gpu_device {
bool has_edid;
bool has_indirect;
bool has_resource_assign_uuid;
+ bool has_resource_blob;
struct work_struct config_changed_work;
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index bf060c69850f..4167673b97d6 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -150,10 +150,14 @@ int virtio_gpu_init(struct drm_device *dev)
if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_UUID)) {
vgdev->has_resource_assign_uuid = true;
}
+ if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_BLOB)) {
+ vgdev->has_resource_blob = true;
+ }
- DRM_INFO("features: %cvirgl %cedid\n",
- vgdev->has_virgl_3d ? '+' : '-',
- vgdev->has_edid ? '+' : '-');
+ DRM_INFO("features: %cvirgl %cedid %cresource_blob\n",
+ vgdev->has_virgl_3d ? '+' : '-',
+ vgdev->has_edid ? '+' : '-',
+ vgdev->has_resource_blob ? '+' : '-');
ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL);
if (ret) {
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 14/24] drm/virtio: implement blob resources: probe for host visible region
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (12 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 13/24] drm/virtio: implement blob resources: probe for the feature Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-16 13:10 ` kernel test robot
2020-08-14 2:39 ` [PATCH 15/24] drm/virtio: implement blob resources: expose virtio_gpu_resource_id_get Gurchetan Singh
` (9 subsequent siblings)
23 siblings, 1 reply; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: Gerd Hoffmann <kraxel@redhat.com>
The availability of the host visible region means host 3D
allocations can be directly mapped in the guest.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Co-developed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_debugfs.c | 5 +++++
drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++
drivers/gpu/drm/virtio/virtgpu_kms.c | 27 ++++++++++++++++++++++--
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
index e99d1c3c0a66..ea27cae28ab4 100644
--- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c
+++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
@@ -51,6 +51,11 @@ static int virtio_gpu_features(struct seq_file *m, void *data)
virtio_add_bool(m, "blob resources", vgdev->has_resource_blob);
virtio_add_int(m, "cap sets", vgdev->num_capsets);
virtio_add_int(m, "scanouts", vgdev->num_scanouts);
+ if (vgdev->host_visible_region.len) {
+ seq_printf(m, "%-16s : 0x%lx +0x%lx\n", "host visible region",
+ (unsigned long)vgdev->host_visible_region.addr,
+ (unsigned long)vgdev->host_visible_region.len);
+ }
return 0;
}
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index a529727d6114..c8405449c4a3 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -209,6 +209,8 @@ struct virtio_gpu_device {
bool has_indirect;
bool has_resource_assign_uuid;
bool has_resource_blob;
+ bool has_host_visible;
+ struct virtio_shm_region host_visible_region;
struct work_struct config_changed_work;
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 4167673b97d6..d3641eda7077 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -153,11 +153,27 @@ int virtio_gpu_init(struct drm_device *dev)
if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_BLOB)) {
vgdev->has_resource_blob = true;
}
+ if (virtio_get_shm_region(vgdev->vdev, &vgdev->host_visible_region,
+ VIRTIO_GPU_SHM_ID_HOST_VISIBLE)) {
+ if (!devm_request_mem_region(&vgdev->vdev->dev,
+ vgdev->host_visible_region.addr,
+ vgdev->host_visible_region.len,
+ dev_name(&vgdev->vdev->dev))) {
+ DRM_ERROR("Could not reserve host visible region\n");
+ goto err_vqs;
+ }
+
+ DRM_INFO("Host memory window: 0x%lx +0x%lx\n",
+ (unsigned long)vgdev->host_visible_region.addr,
+ (unsigned long)vgdev->host_visible_region.len);
+ vgdev->has_host_visible = true;
+ }
- DRM_INFO("features: %cvirgl %cedid %cresource_blob\n",
+ DRM_INFO("features: %cvirgl %cedid %cresource_blob %chost_visible\n",
vgdev->has_virgl_3d ? '+' : '-',
vgdev->has_edid ? '+' : '-',
- vgdev->has_resource_blob ? '+' : '-');
+ vgdev->has_resource_blob ? '+' : '-',
+ vgdev->has_host_visible ? '+' : '-');
ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL);
if (ret) {
@@ -241,6 +257,13 @@ void virtio_gpu_release(struct drm_device *dev)
virtio_gpu_free_vbufs(vgdev);
virtio_gpu_cleanup_cap_cache(vgdev);
kfree(vgdev->capsets);
+
+ if (vgdev->has_host_visible) {
+ devm_release_mem_region(&vgdev->vdev->dev,
+ vgdev->host_visible_region.addr,
+ vgdev->host_visible_region.len);
+ }
+
kfree(vgdev);
}
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 15/24] drm/virtio: implement blob resources: expose virtio_gpu_resource_id_get
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (13 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 14/24] drm/virtio: implement blob resources: probe for host visible region Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 16/24] drm/virtio: implement blob resources: add new fields to internal structs Gurchetan Singh
` (8 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
VRAM object will need it.
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++
drivers/gpu/drm/virtio/virtgpu_object.c | 3 +--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index c8405449c4a3..71743916300d 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -383,6 +383,8 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo);
+int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
+ uint32_t *resid);
/* virtgpu_prime.c */
struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
int flags);
diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index 9d68f260d998..792a2ae1bf97 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -31,8 +31,7 @@
static int virtio_gpu_virglrenderer_workaround = 1;
module_param_named(virglhack, virtio_gpu_virglrenderer_workaround, int, 0400);
-static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
- uint32_t *resid)
+int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, uint32_t *resid)
{
if (virtio_gpu_virglrenderer_workaround) {
/*
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 16/24] drm/virtio: implement blob resources: add new fields to internal structs
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (14 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 15/24] drm/virtio: implement blob resources: expose virtio_gpu_resource_id_get Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 17/24] drm/virtio: implement blob resources: implement vram object Gurchetan Singh
` (7 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
Useful for upcoming blob resources.
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_drv.h | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 71743916300d..34636cb5a93c 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -54,13 +54,16 @@
#define STATE_ERR 2
struct virtio_gpu_object_params {
- uint32_t format;
- uint32_t width;
- uint32_t height;
unsigned long size;
bool dumb;
/* 3d */
bool virgl;
+ bool blob;
+
+ /* classic resources only */
+ uint32_t format;
+ uint32_t width;
+ uint32_t height;
uint32_t target;
uint32_t bind;
uint32_t depth;
@@ -68,6 +71,12 @@ struct virtio_gpu_object_params {
uint32_t last_level;
uint32_t nr_samples;
uint32_t flags;
+
+ /* blob resources only */
+ uint32_t ctx_id;
+ uint32_t blob_mem;
+ uint32_t blob_flags;
+ uint64_t blob_id;
};
struct virtio_gpu_object {
@@ -75,6 +84,8 @@ struct virtio_gpu_object {
uint32_t hw_res_handle;
bool dumb;
bool created;
+ bool host3d_blob, guest_blob;
+ uint32_t blob_mem, blob_flags;
int uuid_state;
uuid_t uuid;
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 17/24] drm/virtio: implement blob resources: implement vram object
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (15 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 16/24] drm/virtio: implement blob resources: add new fields to internal structs Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 5:39 ` kernel test robot
2020-08-14 2:39 ` [PATCH 18/24] drm/virtio: implement blob resources: hypercall interface Gurchetan Singh
` (6 subsequent siblings)
23 siblings, 1 reply; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: Gerd Hoffmann <kraxel@redhat.com>
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>
Co-developed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/Makefile | 2 +-
drivers/gpu/drm/virtio/virtgpu_debugfs.c | 18 +++
drivers/gpu/drm/virtio/virtgpu_drv.h | 23 ++++
drivers/gpu/drm/virtio/virtgpu_kms.c | 8 ++
drivers/gpu/drm/virtio/virtgpu_object.c | 12 ++
drivers/gpu/drm/virtio/virtgpu_vq.c | 66 +++++++++
drivers/gpu/drm/virtio/virtgpu_vram.c | 162 +++++++++++++++++++++++
7 files changed, 290 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpu/drm/virtio/virtgpu_vram.c
diff --git a/drivers/gpu/drm/virtio/Makefile b/drivers/gpu/drm/virtio/Makefile
index 92aa2b3d349d..b99fa4a73b68 100644
--- a/drivers/gpu/drm/virtio/Makefile
+++ b/drivers/gpu/drm/virtio/Makefile
@@ -3,7 +3,7 @@
# Makefile for the drm device driver. This driver provides support for the
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
-virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o \
+virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o virtgpu_vram.o \
virtgpu_display.o virtgpu_vq.o \
virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \
virtgpu_ioctl.o virtgpu_prime.o virtgpu_trace_points.o
diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
index ea27cae28ab4..f81cfbff8c0b 100644
--- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c
+++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
@@ -71,9 +71,27 @@ virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
return 0;
}
+static int
+virtio_gpu_debugfs_host_visible_mm(struct seq_file *m, void *data)
+{
+ struct drm_info_node *node = (struct drm_info_node *) m->private;
+ struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
+ struct drm_printer p;
+
+ if (!vgdev->has_host_visible) {
+ seq_printf(m, "Host allocations not visible to guest\n");
+ return 0;
+ }
+
+ p = drm_seq_file_printer(m);
+ drm_mm_print(&vgdev->host_visible_mm, &p);
+ return 0;
+}
+
static struct drm_info_list virtio_gpu_debugfs_list[] = {
{ "virtio-gpu-features", virtio_gpu_features },
{ "virtio-gpu-irq-fence", virtio_gpu_debugfs_irq_info, 0, NULL },
+ { "virtio-gpu-host-visible-mm", virtio_gpu_debugfs_host_visible_mm },
};
#define VIRTIO_GPU_DEBUGFS_ENTRIES ARRAY_SIZE(virtio_gpu_debugfs_list)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 34636cb5a93c..61f57b04525b 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -99,9 +99,19 @@ struct virtio_gpu_object_shmem {
uint32_t mapped;
};
+struct virtio_gpu_object_vram {
+ struct virtio_gpu_object base;
+ uint32_t map_state;
+ uint32_t map_info;
+ struct drm_mm_node vram_node;
+};
+
#define to_virtio_gpu_shmem(virtio_gpu_object) \
container_of((virtio_gpu_object), struct virtio_gpu_object_shmem, base)
+#define to_virtio_gpu_vram(virtio_gpu_object) \
+ container_of((virtio_gpu_object), struct virtio_gpu_object_vram, base)
+
struct virtio_gpu_object_array {
struct ww_acquire_ctx ticket;
struct list_head next;
@@ -222,6 +232,7 @@ struct virtio_gpu_device {
bool has_resource_blob;
bool has_host_visible;
struct virtio_shm_region host_visible_region;
+ struct drm_mm host_visible_mm;
struct work_struct config_changed_work;
@@ -234,6 +245,7 @@ struct virtio_gpu_device {
struct list_head cap_cache;
spinlock_t resource_export_lock;
+ spinlock_t host_visible_lock;
};
struct virtio_gpu_fpriv {
@@ -364,6 +376,12 @@ int
virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object_array *objs);
+int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object_array *objs, uint64_t offset);
+
+void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object *bo);
+
/* virtgpu_display.c */
void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
@@ -410,4 +428,9 @@ struct drm_gem_object *virtgpu_gem_prime_import_sg_table(
/* virtgpu_debugfs.c */
void virtio_gpu_debugfs_init(struct drm_minor *minor);
+/* virtgpu_vram.c */
+bool virtio_gpu_is_vram(struct virtio_gpu_object *bo);
+int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object_params *params,
+ struct virtio_gpu_object **bo_ptr);
#endif
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index d3641eda7077..b1454c9d00e2 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -119,6 +119,7 @@ int virtio_gpu_init(struct drm_device *dev)
spin_lock_init(&vgdev->display_info_lock);
spin_lock_init(&vgdev->resource_export_lock);
+ spin_lock_init(&vgdev->host_visible_lock);
ida_init(&vgdev->ctx_id_ida);
ida_init(&vgdev->resource_ida);
init_waitqueue_head(&vgdev->resp_wq);
@@ -167,6 +168,9 @@ int virtio_gpu_init(struct drm_device *dev)
(unsigned long)vgdev->host_visible_region.addr,
(unsigned long)vgdev->host_visible_region.len);
vgdev->has_host_visible = true;
+ drm_mm_init(&vgdev->host_visible_mm,
+ (unsigned long)vgdev->host_visible_region.addr,
+ (unsigned long)vgdev->host_visible_region.len);
}
DRM_INFO("features: %cvirgl %cedid %cresource_blob %chost_visible\n",
@@ -256,6 +260,10 @@ void virtio_gpu_release(struct drm_device *dev)
virtio_gpu_modeset_fini(vgdev);
virtio_gpu_free_vbufs(vgdev);
virtio_gpu_cleanup_cap_cache(vgdev);
+
+ if (vgdev->has_host_visible)
+ drm_mm_takedown(&vgdev->host_visible_mm);
+
kfree(vgdev->capsets);
if (vgdev->has_host_visible) {
diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index 792a2ae1bf97..432b9985ef2e 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -83,6 +83,18 @@ void virtio_gpu_cleanup_object(struct virtio_gpu_object *bo)
}
drm_gem_shmem_free_object(&bo->base.base);
+ } else if (virtio_gpu_is_vram(bo)) {
+ struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo);
+
+ spin_lock(&vgdev->host_visible_lock);
+ if (drm_mm_node_allocated(&vram->vram_node))
+ drm_mm_remove_node(&vram->vram_node);
+
+ spin_unlock(&vgdev->host_visible_lock);
+
+ drm_gem_free_mmap_offset(&vram->base.base.base);
+ drm_gem_object_release(&vram->base.base.base);
+ kfree(vram);
}
}
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 3f225a08ecf3..09db56c69424 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -1162,3 +1162,69 @@ virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev,
virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
return 0;
}
+
+static void virtio_gpu_cmd_resource_map_cb(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_vbuffer *vbuf)
+{
+ struct virtio_gpu_object *bo =
+ gem_to_virtio_gpu_obj(vbuf->objs->objs[0]);
+ struct virtio_gpu_resp_map_info *resp =
+ (struct virtio_gpu_resp_map_info *)vbuf->resp_buf;
+ struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo);
+ uint32_t resp_type = le32_to_cpu(resp->hdr.type);
+
+ spin_lock(&vgdev->host_visible_lock);
+
+ if (resp_type == VIRTIO_GPU_RESP_OK_MAP_INFO) {
+ vram->map_info = resp->map_info;
+ vram->map_state = STATE_OK;
+ } else {
+ vram->map_state = STATE_ERR;
+ }
+
+ spin_unlock(&vgdev->host_visible_lock);
+ wake_up_all(&vgdev->resp_wq);
+}
+
+int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object_array *objs, uint64_t offset)
+{
+ struct virtio_gpu_resource_map_blob *cmd_p;
+ struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
+ struct virtio_gpu_vbuffer *vbuf;
+ struct virtio_gpu_resp_map_info *resp_buf;
+
+ resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL);
+ if (!resp_buf) {
+ virtio_gpu_array_put_free(objs);
+ return -ENOMEM;
+ }
+
+ cmd_p = virtio_gpu_alloc_cmd_resp(vgdev,
+ virtio_gpu_cmd_resource_map_cb, &vbuf, sizeof(*cmd_p),
+ sizeof(struct virtio_gpu_resp_map_info), resp_buf);
+ memset(cmd_p, 0, sizeof(*cmd_p));
+
+ cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB);
+ cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
+ cmd_p->offset = offset;
+ vbuf->objs = objs;
+
+ virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
+ return 0;
+}
+
+void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object *bo)
+{
+ struct virtio_gpu_resource_unmap_blob *cmd_p;
+ struct virtio_gpu_vbuffer *vbuf;
+
+ cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
+ memset(cmd_p, 0, sizeof(*cmd_p));
+
+ cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB);
+ cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
+
+ virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
+}
diff --git a/drivers/gpu/drm/virtio/virtgpu_vram.c b/drivers/gpu/drm/virtio/virtgpu_vram.c
new file mode 100644
index 000000000000..3e7e29e56781
--- /dev/null
+++ b/drivers/gpu/drm/virtio/virtgpu_vram.c
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "virtgpu_drv.h"
+
+static void virtio_gpu_vram_free(struct drm_gem_object *obj)
+{
+ struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
+ struct virtio_gpu_device *vgdev = obj->dev->dev_private;
+ struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo);
+ bool unmap;
+
+ if (bo->created) {
+ spin_lock(&vgdev->host_visible_lock);
+ unmap = drm_mm_node_allocated(&vram->vram_node);
+ spin_unlock(&vgdev->host_visible_lock);
+
+ if (unmap)
+ virtio_gpu_cmd_unmap(vgdev, bo);
+
+ virtio_gpu_cmd_unref_resource(vgdev, bo);
+ virtio_gpu_notify(vgdev);
+ return;
+ }
+}
+
+static const struct vm_operations_struct virtio_gpu_vram_vm_ops = {
+ .open = drm_gem_vm_open,
+ .close = drm_gem_vm_close,
+};
+
+static int virtio_gpu_vram_mmap(struct drm_gem_object *obj,
+ struct vm_area_struct *vma)
+{
+ int ret;
+ struct virtio_gpu_device *vgdev = obj->dev->dev_private;
+ struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
+ struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo);
+ unsigned long vm_size = vma->vm_end - vma->vm_start;
+
+ if (!(bo->blob_flags & VIRTGPU_BLOB_FLAG_USE_MAPPABLE))
+ return -EINVAL;
+
+ wait_event(vgdev->resp_wq, vram->map_state != STATE_INITIALIZING);
+ if (vram->map_state != STATE_OK)
+ return -EINVAL;
+
+ vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
+ vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND;
+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+ vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
+ vma->vm_ops = &virtio_gpu_vram_vm_ops;
+
+ if (vram->map_info == VIRTIO_GPU_MAP_CACHE_WC)
+ vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+ else if (vram->map_info == VIRTIO_GPU_MAP_CACHE_UNCACHED)
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+ /* Partial mappings of GEM buffers don't happen much in practice. */
+ if (vm_size != vram->vram_node.size)
+ return -EINVAL;
+
+ ret = io_remap_pfn_range(vma, vma->vm_start,
+ vram->vram_node.start >> PAGE_SHIFT,
+ vm_size, vma->vm_page_prot);
+ return ret;
+}
+
+static const struct drm_gem_object_funcs virtio_gpu_vram_funcs = {
+ .open = virtio_gpu_gem_object_open,
+ .close = virtio_gpu_gem_object_close,
+ .free = virtio_gpu_vram_free,
+ .mmap = virtio_gpu_vram_mmap,
+};
+
+bool virtio_gpu_is_vram(struct virtio_gpu_object *bo)
+{
+ return bo->base.base.funcs == &virtio_gpu_vram_funcs;
+}
+
+static int virtio_gpu_vram_map(struct virtio_gpu_object *bo)
+{
+ int ret;
+ uint64_t offset;
+ struct virtio_gpu_object_array *objs;
+ struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private;
+ struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo);
+
+ if (!vgdev->has_host_visible)
+ return -EINVAL;
+
+ spin_lock(&vgdev->host_visible_lock);
+ ret = drm_mm_insert_node(&vgdev->host_visible_mm, &vram->vram_node,
+ bo->base.base.size);
+ spin_unlock(&vgdev->host_visible_lock);
+
+ if (ret)
+ return ret;
+
+ objs = virtio_gpu_array_alloc(1);
+ if (!objs) {
+ ret = -ENOMEM;
+ goto err_remove_node;
+ }
+
+ virtio_gpu_array_add_obj(objs, &bo->base.base);
+ /*TODO: Add an error checking helper function in drm_mm.h */
+ offset = vram->vram_node.start - vgdev->host_visible_region.addr;
+
+ ret = virtio_gpu_cmd_map(vgdev, objs, offset);
+ if (ret) {
+ virtio_gpu_array_put_free(objs);
+ goto err_remove_node;
+ }
+
+ return 0;
+
+err_remove_node:
+ spin_lock(&vgdev->host_visible_lock);
+ drm_mm_remove_node(&vram->vram_node);
+ spin_unlock(&vgdev->host_visible_lock);
+ return ret;
+}
+
+int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object_params *params,
+ struct virtio_gpu_object **bo_ptr)
+{
+ struct drm_gem_object *obj;
+ struct virtio_gpu_object_vram *vram;
+ int ret;
+
+ vram = kzalloc(sizeof(*vram), GFP_KERNEL);
+ if (!vram)
+ return -ENOMEM;
+
+ obj = &vram->base.base.base;
+ obj->funcs = &virtio_gpu_vram_funcs;
+ drm_gem_private_object_init(vgdev->ddev, obj, params->size);
+
+ /* Create fake offset */
+ ret = drm_gem_create_mmap_offset(obj);
+ if (ret) {
+ kfree(vram);
+ return ret;
+ }
+
+ ret = virtio_gpu_resource_id_get(vgdev, &vram->base.hw_res_handle);
+ if (ret) {
+ kfree(vram);
+ return ret;
+ }
+
+ if (params->blob_flags & VIRTGPU_BLOB_FLAG_USE_MAPPABLE) {
+ ret = virtio_gpu_vram_map(&vram->base);
+ if (ret) {
+ virtio_gpu_vram_free(obj);
+ return ret;
+ }
+ }
+
+ *bo_ptr = &vram->base;
+ return 0;
+}
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 18/24] drm/virtio: implement blob resources: hypercall interface
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (16 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 17/24] drm/virtio: implement blob resources: implement vram object Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 6:12 ` kernel test robot
2020-08-14 2:39 ` [PATCH 19/24] drm/virtio: implement blob resources: blob display integration Gurchetan Singh
` (5 subsequent siblings)
23 siblings, 1 reply; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
This implements the blob hypercall interface.
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_drv.h | 15 +++++++
drivers/gpu/drm/virtio/virtgpu_vq.c | 65 ++++++++++++++++++++++++++++
2 files changed, 80 insertions(+)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 61f57b04525b..fe9bb95a408b 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -35,6 +35,7 @@
#include <drm/drm_drv.h>
#include <drm/drm_encoder.h>
#include <drm/drm_fb_helper.h>
+#include <drm/drm_fourcc.h>
#include <drm/drm_gem.h>
#include <drm/drm_gem_shmem_helper.h>
#include <drm/drm_ioctl.h>
@@ -382,6 +383,20 @@ int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev,
void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object *bo);
+void
+virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object *bo,
+ struct virtio_gpu_object_params *params,
+ struct virtio_gpu_mem_entry *ents,
+ uint32_t nents);
+void
+virtio_gpu_cmd_set_scanout_blob(struct virtio_gpu_device *vgdev,
+ uint32_t scanout_id,
+ struct virtio_gpu_object *bo,
+ struct drm_framebuffer *fb,
+ uint32_t width, uint32_t height,
+ uint32_t x, uint32_t y);
+
/* virtgpu_display.c */
void virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 09db56c69424..de4356a183d2 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -1228,3 +1228,68 @@ void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev,
virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
}
+
+void
+virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object *bo,
+ struct virtio_gpu_object_params *params,
+ struct virtio_gpu_mem_entry *ents,
+ uint32_t nents)
+{
+ struct virtio_gpu_resource_create_blob *cmd_p;
+ struct virtio_gpu_vbuffer *vbuf;
+
+ cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
+ memset(cmd_p, 0, sizeof(*cmd_p));
+
+ cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB);
+ cmd_p->hdr.ctx_id = cpu_to_le32(params->ctx_id);
+ cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
+ cmd_p->blob_mem = cpu_to_le32(params->blob_mem);
+ cmd_p->blob_flags = cpu_to_le32(params->blob_flags);
+ cmd_p->blob_id = cpu_to_le64(params->blob_id);
+ cmd_p->size = cpu_to_le64(params->size);
+ cmd_p->nr_entries = cpu_to_le32(nents);
+
+ vbuf->data_buf = ents;
+ vbuf->data_size = sizeof(*ents) * nents;
+
+ virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
+ bo->created = true;
+}
+
+void virtio_gpu_cmd_set_scanout_blob(struct virtio_gpu_device *vgdev,
+ uint32_t scanout_id,
+ struct virtio_gpu_object *bo,
+ struct drm_framebuffer *fb,
+ uint32_t width, uint32_t height,
+ uint32_t x, uint32_t y)
+{
+ uint32_t i;
+ struct virtio_gpu_set_scanout_blob *cmd_p;
+ struct virtio_gpu_vbuffer *vbuf;
+ uint32_t format = virtio_gpu_translate_format(fb->format->format);
+
+ cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
+ memset(cmd_p, 0, sizeof(*cmd_p));
+
+ cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_SET_SCANOUT_BLOB);
+ cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
+ cmd_p->scanout_id = cpu_to_le32(scanout_id);
+
+ cmd_p->format = cpu_to_le32(format);
+ cmd_p->width = cpu_to_le32(fb->width);
+ cmd_p->height = cpu_to_le32(fb->height);
+
+ for (i = 0; i < 4; i++) {
+ cmd_p->strides[i] = cpu_to_le32(fb->pitches[i]);
+ cmd_p->offsets[i] = cpu_to_le64(fb->offsets[i]);
+ }
+
+ cmd_p->r.width = cpu_to_le32(width);
+ cmd_p->r.height = cpu_to_le32(height);
+ cmd_p->r.x = cpu_to_le32(x);
+ cmd_p->r.y = cpu_to_le32(y);
+
+ virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
+}
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 19/24] drm/virtio: implement blob resources: blob display integration
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (17 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 18/24] drm/virtio: implement blob resources: hypercall interface Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 20/24] drm/virtio: implement blob resources: refactor UUID code somewhat Gurchetan Singh
` (4 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
SCANOUT_BLOB forwards the DRM framebuffer metadata to the host. The
modifier is intentionally left out -- it may be possible to query
the host for that.
We also assume one blob resource per DRM framebuffer. That too is
an intentional simplification.
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_plane.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
index 52d24179bcec..1e0754e77723 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -172,12 +172,23 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
plane->state->src_h >> 16,
plane->state->src_x >> 16,
plane->state->src_y >> 16);
- virtio_gpu_cmd_set_scanout(vgdev, output->index,
- bo->hw_res_handle,
- plane->state->src_w >> 16,
- plane->state->src_h >> 16,
- plane->state->src_x >> 16,
- plane->state->src_y >> 16);
+
+ if (bo->host3d_blob || bo->guest_blob) {
+ virtio_gpu_cmd_set_scanout_blob(
+ vgdev, output->index, bo,
+ plane->state->fb,
+ plane->state->src_w >> 16,
+ plane->state->src_h >> 16,
+ plane->state->src_x >> 16,
+ plane->state->src_y >> 16);
+ } else {
+ virtio_gpu_cmd_set_scanout(vgdev, output->index,
+ bo->hw_res_handle,
+ plane->state->src_w >> 16,
+ plane->state->src_h >> 16,
+ plane->state->src_x >> 16,
+ plane->state->src_y >> 16);
+ }
}
virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle,
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 20/24] drm/virtio: implement blob resources: refactor UUID code somewhat
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (18 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 19/24] drm/virtio: implement blob resources: blob display integration Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 21/24] drm/virtio: implement blob resources: fix stride discrepancy Gurchetan Singh
` (3 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
For upcoming blob resources, userspace can specify that the
resource will be used for cross-device sharing. This is mainly
for exportable blobs that will only shared with the virtgpu
display but not across devices.
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++
drivers/gpu/drm/virtio/virtgpu_prime.c | 42 ++++++++++++++++++--------
2 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index fe9bb95a408b..71c2ea2e3c83 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -430,6 +430,8 @@ bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo);
int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
uint32_t *resid);
/* virtgpu_prime.c */
+int virtio_gpu_resource_assign_uuid(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object *bo);
struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
int flags);
struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev,
diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
index 3552db128ba3..1ef1e2f22633 100644
--- a/drivers/gpu/drm/virtio/virtgpu_prime.c
+++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -59,6 +59,24 @@ const struct virtio_dma_buf_ops virtgpu_dmabuf_ops = {
.get_uuid = virtgpu_virtio_get_uuid,
};
+int virtio_gpu_resource_assign_uuid(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_object *bo)
+{
+ int ret;
+ struct virtio_gpu_object_array *objs;
+
+ objs = virtio_gpu_array_alloc(1);
+ if (!objs)
+ return -ENOMEM;
+
+ virtio_gpu_array_add_obj(objs, &bo->base.base);
+ ret = virtio_gpu_cmd_resource_assign_uuid(vgdev, objs);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
int flags)
{
@@ -66,22 +84,20 @@ struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj,
struct drm_device *dev = obj->dev;
struct virtio_gpu_device *vgdev = dev->dev_private;
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
- struct virtio_gpu_object_array *objs;
int ret = 0;
+ bool blob = bo->host3d_blob || bo->guest_blob;
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
- if (vgdev->has_resource_assign_uuid) {
- objs = virtio_gpu_array_alloc(1);
- if (!objs)
- return ERR_PTR(-ENOMEM);
- virtio_gpu_array_add_obj(objs, &bo->base.base);
-
- ret = virtio_gpu_cmd_resource_assign_uuid(vgdev, objs);
- if (ret)
- return ERR_PTR(ret);
- virtio_gpu_notify(vgdev);
- } else {
- bo->uuid_state = STATE_ERR;
+ if (!blob) {
+ if (vgdev->has_resource_assign_uuid) {
+ ret = virtio_gpu_resource_assign_uuid(vgdev, bo);
+ if (ret)
+ return ERR_PTR(ret);
+
+ virtio_gpu_notify(vgdev);
+ } else {
+ bo->uuid_state = STATE_ERR;
+ }
}
exp_info.ops = &virtgpu_dmabuf_ops.ops;
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 21/24] drm/virtio: implement blob resources: fix stride discrepancy
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (19 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 20/24] drm/virtio: implement blob resources: refactor UUID code somewhat Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 22/24] drm/virtio: implement blob resources: report blob mem to userspace Gurchetan Singh
` (2 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
The old transfer ioctls may work on blob resources, and 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.
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>
---
drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +++
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 35 +++++++++++++++++++++++---
drivers/gpu/drm/virtio/virtgpu_vq.c | 14 +++++++++--
3 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 71c2ea2e3c83..444b65c8d4ee 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -349,12 +349,16 @@ void virtio_gpu_cmd_submit(struct virtio_gpu_device *vgdev,
void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev,
uint32_t ctx_id,
uint64_t offset, uint32_t level,
+ uint32_t stride,
+ uint32_t layer_stride,
struct drm_virtgpu_3d_box *box,
struct virtio_gpu_object_array *objs,
struct virtio_gpu_fence *fence);
void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
uint32_t ctx_id,
uint64_t offset, uint32_t level,
+ uint32_t stride,
+ uint32_t layer_stride,
struct drm_virtgpu_3d_box *box,
struct virtio_gpu_object_array *objs,
struct virtio_gpu_fence *fence);
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index 7a2430e34e00..0075995a9f5b 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -311,6 +311,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,
struct virtio_gpu_device *vgdev = dev->dev_private;
struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
struct drm_virtgpu_3d_transfer_from_host *args = data;
+ struct virtio_gpu_object *bo;
struct virtio_gpu_object_array *objs;
struct virtio_gpu_fence *fence;
int ret;
@@ -324,6 +325,17 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,
if (objs == NULL)
return -ENOENT;
+ bo = gem_to_virtio_gpu_obj(objs->objs[0]);
+ if (bo->guest_blob && !bo->host3d_blob) {
+ ret = -EINVAL;
+ goto err_put_free;
+ }
+
+ if (!bo->host3d_blob && (args->stride || args->layer_stride)) {
+ ret = -EINVAL;
+ goto err_put_free;
+ }
+
ret = virtio_gpu_array_lock_resv(objs);
if (ret != 0)
goto err_put_free;
@@ -333,9 +345,10 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,
ret = -ENOMEM;
goto err_unlock;
}
+
virtio_gpu_cmd_transfer_from_host_3d
- (vgdev, vfpriv->ctx_id, offset, args->level,
- &args->box, objs, fence);
+ (vgdev, vfpriv->ctx_id, offset, args->level, args->stride,
+ args->layer_stride, &args->box, objs, fence);
dma_fence_put(&fence->f);
virtio_gpu_notify(vgdev);
return 0;
@@ -353,6 +366,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
struct virtio_gpu_device *vgdev = dev->dev_private;
struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
struct drm_virtgpu_3d_transfer_to_host *args = data;
+ struct virtio_gpu_object *bo;
struct virtio_gpu_object_array *objs;
struct virtio_gpu_fence *fence;
int ret;
@@ -362,6 +376,12 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
if (objs == NULL)
return -ENOENT;
+ bo = gem_to_virtio_gpu_obj(objs->objs[0]);
+ if (bo->guest_blob && !bo->host3d_blob) {
+ ret = -EINVAL;
+ goto err_put_free;
+ }
+
if (!vgdev->has_virgl_3d) {
virtio_gpu_cmd_transfer_to_host_2d
(vgdev, offset,
@@ -369,6 +389,12 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
objs, NULL);
} else {
virtio_gpu_create_context(dev, file);
+
+ if (!bo->host3d_blob && (args->stride || args->layer_stride)) {
+ ret = -EINVAL;
+ goto err_put_free;
+ }
+
ret = virtio_gpu_array_lock_resv(objs);
if (ret != 0)
goto err_put_free;
@@ -380,8 +406,9 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
virtio_gpu_cmd_transfer_to_host_3d
(vgdev,
- vfpriv ? vfpriv->ctx_id : 0, offset,
- args->level, &args->box, objs, fence);
+ vfpriv ? vfpriv->ctx_id : 0, offset, args->level,
+ args->stride, args->layer_stride, &args->box, objs,
+ fence);
dma_fence_put(&fence->f);
}
virtio_gpu_notify(vgdev);
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index de4356a183d2..78cec150218c 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -1008,6 +1008,8 @@ virtio_gpu_cmd_resource_create_3d(struct virtio_gpu_device *vgdev,
void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
uint32_t ctx_id,
uint64_t offset, uint32_t level,
+ uint32_t stride,
+ uint32_t layer_stride,
struct drm_virtgpu_3d_box *box,
struct virtio_gpu_object_array *objs,
struct virtio_gpu_fence *fence)
@@ -1016,12 +1018,14 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
struct virtio_gpu_transfer_host_3d *cmd_p;
struct virtio_gpu_vbuffer *vbuf;
bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev);
- struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo);
- if (use_dma_api)
+ if (virtio_gpu_is_shmem(bo) && use_dma_api) {
+ struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo);
+
dma_sync_sg_for_device(vgdev->vdev->dev.parent,
shmem->pages->sgl, shmem->pages->nents,
DMA_TO_DEVICE);
+ }
cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
memset(cmd_p, 0, sizeof(*cmd_p));
@@ -1034,6 +1038,8 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
convert_to_hw_box(&cmd_p->box, box);
cmd_p->offset = cpu_to_le64(offset);
cmd_p->level = cpu_to_le32(level);
+ cmd_p->stride = cpu_to_le32(stride);
+ cmd_p->layer_stride = cpu_to_le32(layer_stride);
virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, fence);
}
@@ -1041,6 +1047,8 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev,
uint32_t ctx_id,
uint64_t offset, uint32_t level,
+ uint32_t stride,
+ uint32_t layer_stride,
struct drm_virtgpu_3d_box *box,
struct virtio_gpu_object_array *objs,
struct virtio_gpu_fence *fence)
@@ -1060,6 +1068,8 @@ void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev,
convert_to_hw_box(&cmd_p->box, box);
cmd_p->offset = cpu_to_le64(offset);
cmd_p->level = cpu_to_le32(level);
+ cmd_p->stride = cpu_to_le32(stride);
+ cmd_p->layer_stride = cpu_to_le32(layer_stride);
virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, fence);
}
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 22/24] drm/virtio: implement blob resources: report blob mem to userspace
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (20 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 21/24] drm/virtio: implement blob resources: fix stride discrepancy Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-14 2:39 ` [PATCH 23/24] drm/virtio: implement blob resources: resource create blob ioctl Gurchetan Singh
2020-08-14 2:40 ` [PATCH 24/24] drm/virtio: advertise features to userspace Gurchetan Singh
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
The stride field has never been used, so repurpose it to be
"blob_mem". This way, userspace can know the memory properties
of the blob if it's passed between userspace processes and
no suitable userspace API exists to transmit that knowledge.
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index 0075995a9f5b..7dbe24248a20 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -300,6 +300,9 @@ static int virtio_gpu_resource_info_ioctl(struct drm_device *dev, void *data,
ri->size = qobj->base.base.size;
ri->res_handle = qobj->hw_res_handle;
+ if (qobj->host3d_blob || qobj->guest_blob)
+ ri->blob_mem = qobj->blob_mem;
+
drm_gem_object_put(gobj);
return 0;
}
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 23/24] drm/virtio: implement blob resources: resource create blob ioctl
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (21 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 22/24] drm/virtio: implement blob resources: report blob mem to userspace Gurchetan Singh
@ 2020-08-14 2:39 ` Gurchetan Singh
2020-08-17 17:46 ` Anthoine Bourgeois
2020-08-14 2:40 ` [PATCH 24/24] drm/virtio: advertise features to userspace Gurchetan Singh
23 siblings, 1 reply; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:39 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
From: Gerd Hoffmann <kraxel@redhat.com>
Implement resource create blob as specified.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Co-developed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +-
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 136 ++++++++++++++++++++++++
drivers/gpu/drm/virtio/virtgpu_object.c | 5 +-
drivers/gpu/drm/virtio/virtgpu_vram.c | 2 +
4 files changed, 144 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 444b65c8d4ee..3e9ec5b1fb63 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -255,8 +255,8 @@ struct virtio_gpu_fpriv {
struct mutex context_lock;
};
-/* virtgpu_ioctl.c */
-#define DRM_VIRTIO_NUM_IOCTLS 10
+/* virtio_ioctl.c */
+#define DRM_VIRTIO_NUM_IOCTLS 11
extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS];
void virtio_gpu_create_context(struct drm_device *dev, struct drm_file *file);
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index 7dbe24248a20..47ac32b7031a 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -34,6 +34,10 @@
#include "virtgpu_drv.h"
+#define VIRTGPU_BLOB_FLAG_USE_MASK (VIRTGPU_BLOB_FLAG_USE_MAPPABLE | \
+ VIRTGPU_BLOB_FLAG_USE_SHAREABLE | \
+ VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE)
+
void virtio_gpu_create_context(struct drm_device *dev, struct drm_file *file)
{
struct virtio_gpu_device *vgdev = dev->dev_private;
@@ -520,6 +524,134 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,
return 0;
}
+static int verify_blob(struct virtio_gpu_device *vgdev,
+ struct virtio_gpu_fpriv *vfpriv,
+ struct virtio_gpu_object_params *params,
+ struct drm_virtgpu_resource_create_blob *rc_blob,
+ bool *guest_blob, bool *host3d_blob)
+{
+ if (!vgdev->has_resource_blob)
+ return -EINVAL;
+
+ if ((rc_blob->blob_flags & ~VIRTGPU_BLOB_FLAG_USE_MASK) ||
+ !rc_blob->blob_flags)
+ return -EINVAL;
+
+ if (rc_blob->blob_flags & VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) {
+ if (!vgdev->has_resource_assign_uuid)
+ return -EINVAL;
+ }
+
+ switch (rc_blob->blob_mem) {
+ case VIRTGPU_BLOB_MEM_GUEST:
+ *guest_blob = true;
+ break;
+ case VIRTGPU_BLOB_MEM_HOST3D_GUEST:
+ *guest_blob = true;
+ fallthrough;
+ case VIRTGPU_BLOB_MEM_HOST3D:
+ *host3d_blob = true;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (*host3d_blob) {
+ if (!vgdev->has_virgl_3d)
+ return -EINVAL;
+
+ /* Must be dword aligned. */
+ if ((rc_blob->cmd_size) % 4 != 0)
+ return -EINVAL;
+
+ params->ctx_id = vfpriv->ctx_id;
+ params->blob_id = rc_blob->blob_id;
+ } else {
+ if (rc_blob->blob_id != 0)
+ return -EINVAL;
+
+ if (rc_blob->cmd_size != 0)
+ return -EINVAL;
+ }
+
+ params->blob_mem = rc_blob->blob_mem;
+ params->size = rc_blob->size;
+ params->blob = true;
+ params->blob_flags = rc_blob->blob_flags;
+ return 0;
+}
+
+static int virtio_gpu_resource_create_blob(struct drm_device *dev,
+ void *data, struct drm_file *file)
+{
+ int ret = 0;
+ uint32_t handle = 0;
+ struct drm_gem_object *obj;
+ struct virtio_gpu_object *bo;
+ bool host3d_blob, guest_blob;
+ struct virtio_gpu_object_params params = { 0 };
+ struct virtio_gpu_device *vgdev = dev->dev_private;
+ struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
+ struct drm_virtgpu_resource_create_blob *rc_blob = data;
+
+ guest_blob = host3d_blob = false;
+ if (verify_blob(vgdev, vfpriv, ¶ms, rc_blob,
+ &guest_blob, &host3d_blob))
+ return -EINVAL;
+
+ if (vgdev->has_virgl_3d)
+ virtio_gpu_create_context(dev, file);
+
+ if (rc_blob->cmd_size) {
+ void *buf;
+
+ buf = memdup_user(u64_to_user_ptr(rc_blob->cmd),
+ rc_blob->cmd_size);
+
+ if (IS_ERR(buf))
+ return PTR_ERR(buf);
+
+ virtio_gpu_cmd_submit(vgdev, buf, rc_blob->cmd_size,
+ vfpriv->ctx_id, NULL, NULL);
+ }
+
+ if (guest_blob)
+ ret = virtio_gpu_object_create(vgdev, ¶ms, &bo, NULL);
+ else if (!guest_blob && host3d_blob)
+ ret = virtio_gpu_vram_create(vgdev, ¶ms, &bo);
+ else
+ return -EINVAL;
+
+ if (ret < 0)
+ return ret;
+
+ bo->guest_blob = guest_blob;
+ bo->host3d_blob = host3d_blob;
+ bo->blob_mem = rc_blob->blob_mem;
+ bo->blob_flags = rc_blob->blob_flags;
+
+ obj = &bo->base.base;
+ if (params.blob_flags & VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) {
+ ret = virtio_gpu_resource_assign_uuid(vgdev, bo);
+ if (ret) {
+ drm_gem_object_release(obj);
+ return ret;
+ }
+ }
+
+ ret = drm_gem_handle_create(file, obj, &handle);
+ if (ret) {
+ drm_gem_object_release(obj);
+ return ret;
+ }
+ drm_gem_object_put(obj);
+
+ rc_blob->res_handle = bo->hw_res_handle;
+ rc_blob->bo_handle = handle;
+
+ return 0;
+}
+
struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = {
DRM_IOCTL_DEF_DRV(VIRTGPU_MAP, virtio_gpu_map_ioctl,
DRM_RENDER_ALLOW),
@@ -552,4 +684,8 @@ struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = {
DRM_IOCTL_DEF_DRV(VIRTGPU_GET_CAPS, virtio_gpu_get_caps_ioctl,
DRM_RENDER_ALLOW),
+
+ DRM_IOCTL_DEF_DRV(VIRTGPU_RESOURCE_CREATE_BLOB,
+ virtio_gpu_resource_create_blob,
+ DRM_RENDER_ALLOW),
};
diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index 432b9985ef2e..43f383946a7d 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -244,7 +244,10 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
return ret;
}
- if (params->virgl) {
+ if (params->blob) {
+ virtio_gpu_cmd_resource_create_blob(vgdev, bo, params,
+ ents, nents);
+ } else if (params->virgl) {
virtio_gpu_cmd_resource_create_3d(vgdev, bo, params,
objs, fence);
virtio_gpu_object_attach(vgdev, bo, ents, nents);
diff --git a/drivers/gpu/drm/virtio/virtgpu_vram.c b/drivers/gpu/drm/virtio/virtgpu_vram.c
index 3e7e29e56781..d8ea11bd07fe 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vram.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vram.c
@@ -149,6 +149,8 @@ int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev,
return ret;
}
+ virtio_gpu_cmd_resource_create_blob(vgdev, &vram->base, params, NULL,
+ 0);
if (params->blob_flags & VIRTGPU_BLOB_FLAG_USE_MAPPABLE) {
ret = virtio_gpu_vram_map(&vram->base);
if (ret) {
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 24/24] drm/virtio: advertise features to userspace
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
` (22 preceding siblings ...)
2020-08-14 2:39 ` [PATCH 23/24] drm/virtio: implement blob resources: resource create blob ioctl Gurchetan Singh
@ 2020-08-14 2:40 ` Gurchetan Singh
23 siblings, 0 replies; 29+ messages in thread
From: Gurchetan Singh @ 2020-08-14 2:40 UTC (permalink / raw)
To: dri-devel, virtio-dev; +Cc: sebastien.boeuf, kraxel, vgoyal, mst
New api changes are now available to userspace.
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index 47ac32b7031a..f3737dc0f8ea 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -216,6 +216,15 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data,
case VIRTGPU_PARAM_CAPSET_QUERY_FIX:
value = 1;
break;
+ case VIRTGPU_PARAM_RESOURCE_BLOB:
+ value = vgdev->has_resource_blob == true ? 1 : 0;
+ break;
+ case VIRTGPU_PARAM_HOST_VISIBLE:
+ value = vgdev->has_host_visible == true ? 1 : 0;
+ break;
+ case VIRTGPU_PARAM_CROSS_DEVICE:
+ value = vgdev->has_resource_assign_uuid == true ? 1 : 0;
+ break;
default:
return -EINVAL;
}
--
2.24.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 17/24] drm/virtio: implement blob resources: implement vram object
2020-08-14 2:39 ` [PATCH 17/24] drm/virtio: implement blob resources: implement vram object Gurchetan Singh
@ 2020-08-14 5:39 ` kernel test robot
0 siblings, 0 replies; 29+ messages in thread
From: kernel test robot @ 2020-08-14 5:39 UTC (permalink / raw)
To: Gurchetan Singh, dri-devel, virtio-dev
Cc: sebastien.boeuf, kbuild-all, kraxel, vgoyal, mst
[-- Attachment #1: Type: text/plain, Size: 2975 bytes --]
Hi Gurchetan,
I love your patch! Perhaps something to improve:
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip linus/master next-20200814]
[cannot apply to tegra-drm/drm/tegra/for-next drm/drm-next drm-exynos/exynos-drm-next v5.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Gurchetan-Singh/Blob-prerequisites-blob-resources/20200814-104250
base: git://anongit.freedesktop.org/drm-intel for-linux-next
config: parisc-randconfig-s031-20200813 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-168-g9554805c-dirty
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/virtio/virtgpu_vq.c:1210:23: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le64 [usertype] offset @@ got unsigned long long [usertype] offset @@
>> drivers/gpu/drm/virtio/virtgpu_vq.c:1210:23: sparse: expected restricted __le64 [usertype] offset
>> drivers/gpu/drm/virtio/virtgpu_vq.c:1210:23: sparse: got unsigned long long [usertype] offset
vim +1210 drivers/gpu/drm/virtio/virtgpu_vq.c
1188
1189 int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev,
1190 struct virtio_gpu_object_array *objs, uint64_t offset)
1191 {
1192 struct virtio_gpu_resource_map_blob *cmd_p;
1193 struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
1194 struct virtio_gpu_vbuffer *vbuf;
1195 struct virtio_gpu_resp_map_info *resp_buf;
1196
1197 resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL);
1198 if (!resp_buf) {
1199 virtio_gpu_array_put_free(objs);
1200 return -ENOMEM;
1201 }
1202
1203 cmd_p = virtio_gpu_alloc_cmd_resp(vgdev,
1204 virtio_gpu_cmd_resource_map_cb, &vbuf, sizeof(*cmd_p),
1205 sizeof(struct virtio_gpu_resp_map_info), resp_buf);
1206 memset(cmd_p, 0, sizeof(*cmd_p));
1207
1208 cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB);
1209 cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
> 1210 cmd_p->offset = offset;
1211 vbuf->objs = objs;
1212
1213 virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
1214 return 0;
1215 }
1216
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28443 bytes --]
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 18/24] drm/virtio: implement blob resources: hypercall interface
2020-08-14 2:39 ` [PATCH 18/24] drm/virtio: implement blob resources: hypercall interface Gurchetan Singh
@ 2020-08-14 6:12 ` kernel test robot
0 siblings, 0 replies; 29+ messages in thread
From: kernel test robot @ 2020-08-14 6:12 UTC (permalink / raw)
To: Gurchetan Singh, dri-devel, virtio-dev
Cc: sebastien.boeuf, kbuild-all, kraxel, vgoyal, mst
[-- Attachment #1: Type: text/plain, Size: 3411 bytes --]
Hi Gurchetan,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip linus/master next-20200814]
[cannot apply to tegra-drm/drm/tegra/for-next drm/drm-next drm-exynos/exynos-drm-next v5.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Gurchetan-Singh/Blob-prerequisites-blob-resources/20200814-104250
base: git://anongit.freedesktop.org/drm-intel for-linux-next
config: parisc-randconfig-s031-20200813 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-168-g9554805c-dirty
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
drivers/gpu/drm/virtio/virtgpu_vq.c:1210:23: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le64 [usertype] offset @@ got unsigned long long [usertype] offset @@
drivers/gpu/drm/virtio/virtgpu_vq.c:1210:23: sparse: expected restricted __le64 [usertype] offset
drivers/gpu/drm/virtio/virtgpu_vq.c:1210:23: sparse: got unsigned long long [usertype] offset
>> drivers/gpu/drm/virtio/virtgpu_vq.c:1286:35: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le32 @@ got restricted __le64 [usertype] @@
>> drivers/gpu/drm/virtio/virtgpu_vq.c:1286:35: sparse: expected restricted __le32
>> drivers/gpu/drm/virtio/virtgpu_vq.c:1286:35: sparse: got restricted __le64 [usertype]
vim +1286 drivers/gpu/drm/virtio/virtgpu_vq.c
1260
1261 void virtio_gpu_cmd_set_scanout_blob(struct virtio_gpu_device *vgdev,
1262 uint32_t scanout_id,
1263 struct virtio_gpu_object *bo,
1264 struct drm_framebuffer *fb,
1265 uint32_t width, uint32_t height,
1266 uint32_t x, uint32_t y)
1267 {
1268 uint32_t i;
1269 struct virtio_gpu_set_scanout_blob *cmd_p;
1270 struct virtio_gpu_vbuffer *vbuf;
1271 uint32_t format = virtio_gpu_translate_format(fb->format->format);
1272
1273 cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
1274 memset(cmd_p, 0, sizeof(*cmd_p));
1275
1276 cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_SET_SCANOUT_BLOB);
1277 cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
1278 cmd_p->scanout_id = cpu_to_le32(scanout_id);
1279
1280 cmd_p->format = cpu_to_le32(format);
1281 cmd_p->width = cpu_to_le32(fb->width);
1282 cmd_p->height = cpu_to_le32(fb->height);
1283
1284 for (i = 0; i < 4; i++) {
1285 cmd_p->strides[i] = cpu_to_le32(fb->pitches[i]);
> 1286 cmd_p->offsets[i] = cpu_to_le64(fb->offsets[i]);
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28443 bytes --]
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 14/24] drm/virtio: implement blob resources: probe for host visible region
2020-08-14 2:39 ` [PATCH 14/24] drm/virtio: implement blob resources: probe for host visible region Gurchetan Singh
@ 2020-08-16 13:10 ` kernel test robot
0 siblings, 0 replies; 29+ messages in thread
From: kernel test robot @ 2020-08-16 13:10 UTC (permalink / raw)
To: Gurchetan Singh, dri-devel, virtio-dev
Cc: sebastien.boeuf, kbuild-all, kraxel, vgoyal, mst
[-- Attachment #1: Type: text/plain, Size: 12369 bytes --]
Hi Gurchetan,
I love your patch! Perhaps something to improve:
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip linus/master next-20200814]
[cannot apply to tegra-drm/drm/tegra/for-next drm/drm-next drm-exynos/exynos-drm-next v5.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Gurchetan-Singh/Blob-prerequisites-blob-resources/20200814-104250
base: git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-m021-20200816 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
smatch warnings:
drivers/gpu/drm/virtio/virtgpu_kms.c:227 virtio_gpu_init() error: uninitialized symbol 'ret'.
# https://github.com/0day-ci/linux/commit/ded3d7b8bb13eb8599f8d410f184521214e13328
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gurchetan-Singh/Blob-prerequisites-blob-resources/20200814-104250
git checkout ded3d7b8bb13eb8599f8d410f184521214e13328
vim +/ret +227 drivers/gpu/drm/virtio/virtgpu_kms.c
62fb7a5e10962a Gerd Hoffmann 2014-10-28 94
d516e75c71c985 Ezequiel Garcia 2019-01-08 95 int virtio_gpu_init(struct drm_device *dev)
dc5698e80cf724 Dave Airlie 2013-09-09 96 {
dc5698e80cf724 Dave Airlie 2013-09-09 97 static vq_callback_t *callbacks[] = {
dc5698e80cf724 Dave Airlie 2013-09-09 98 virtio_gpu_ctrl_ack, virtio_gpu_cursor_ack
dc5698e80cf724 Dave Airlie 2013-09-09 99 };
f7ad26ff952b3c Stefan Hajnoczi 2015-12-17 100 static const char * const names[] = { "control", "cursor" };
dc5698e80cf724 Dave Airlie 2013-09-09 101
dc5698e80cf724 Dave Airlie 2013-09-09 102 struct virtio_gpu_device *vgdev;
dc5698e80cf724 Dave Airlie 2013-09-09 103 /* this will expand later */
dc5698e80cf724 Dave Airlie 2013-09-09 104 struct virtqueue *vqs[2];
62fb7a5e10962a Gerd Hoffmann 2014-10-28 105 u32 num_scanouts, num_capsets;
dc5698e80cf724 Dave Airlie 2013-09-09 106 int ret;
dc5698e80cf724 Dave Airlie 2013-09-09 107
18e51064c42ca3 Daniel Vetter 2017-05-24 108 if (!virtio_has_feature(dev_to_virtio(dev->dev), VIRTIO_F_VERSION_1))
dc5698e80cf724 Dave Airlie 2013-09-09 109 return -ENODEV;
dc5698e80cf724 Dave Airlie 2013-09-09 110
dc5698e80cf724 Dave Airlie 2013-09-09 111 vgdev = kzalloc(sizeof(struct virtio_gpu_device), GFP_KERNEL);
dc5698e80cf724 Dave Airlie 2013-09-09 112 if (!vgdev)
dc5698e80cf724 Dave Airlie 2013-09-09 113 return -ENOMEM;
dc5698e80cf724 Dave Airlie 2013-09-09 114
dc5698e80cf724 Dave Airlie 2013-09-09 115 vgdev->ddev = dev;
dc5698e80cf724 Dave Airlie 2013-09-09 116 dev->dev_private = vgdev;
18e51064c42ca3 Daniel Vetter 2017-05-24 117 vgdev->vdev = dev_to_virtio(dev->dev);
dc5698e80cf724 Dave Airlie 2013-09-09 118 vgdev->dev = dev->dev;
dc5698e80cf724 Dave Airlie 2013-09-09 119
dc5698e80cf724 Dave Airlie 2013-09-09 120 spin_lock_init(&vgdev->display_info_lock);
f6e6d9eff0b4e9 David Stevens 2020-08-13 121 spin_lock_init(&vgdev->resource_export_lock);
1938d1ae32fefa Matthew Wilcox 2018-09-26 122 ida_init(&vgdev->ctx_id_ida);
1938d1ae32fefa Matthew Wilcox 2018-09-26 123 ida_init(&vgdev->resource_ida);
dc5698e80cf724 Dave Airlie 2013-09-09 124 init_waitqueue_head(&vgdev->resp_wq);
dc5698e80cf724 Dave Airlie 2013-09-09 125 virtio_gpu_init_vq(&vgdev->ctrlq, virtio_gpu_dequeue_ctrl_func);
dc5698e80cf724 Dave Airlie 2013-09-09 126 virtio_gpu_init_vq(&vgdev->cursorq, virtio_gpu_dequeue_cursor_func);
dc5698e80cf724 Dave Airlie 2013-09-09 127
f54d1867005c33 Chris Wilson 2016-10-25 128 vgdev->fence_drv.context = dma_fence_context_alloc(1);
dc5698e80cf724 Dave Airlie 2013-09-09 129 spin_lock_init(&vgdev->fence_drv.lock);
dc5698e80cf724 Dave Airlie 2013-09-09 130 INIT_LIST_HEAD(&vgdev->fence_drv.fences);
62fb7a5e10962a Gerd Hoffmann 2014-10-28 131 INIT_LIST_HEAD(&vgdev->cap_cache);
dc5698e80cf724 Dave Airlie 2013-09-09 132 INIT_WORK(&vgdev->config_changed_work,
dc5698e80cf724 Dave Airlie 2013-09-09 133 virtio_gpu_config_changed_work_func);
dc5698e80cf724 Dave Airlie 2013-09-09 134
f0c6cef7e7174b Gerd Hoffmann 2019-08-30 135 INIT_WORK(&vgdev->obj_free_work,
f0c6cef7e7174b Gerd Hoffmann 2019-08-30 136 virtio_gpu_array_put_free_work);
f0c6cef7e7174b Gerd Hoffmann 2019-08-30 137 INIT_LIST_HEAD(&vgdev->obj_free_list);
f0c6cef7e7174b Gerd Hoffmann 2019-08-30 138 spin_lock_init(&vgdev->obj_free_lock);
f0c6cef7e7174b Gerd Hoffmann 2019-08-30 139
ff2ac58a45914c Laurent Vivier 2017-01-24 140 #ifdef __LITTLE_ENDIAN
62fb7a5e10962a Gerd Hoffmann 2014-10-28 141 if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_VIRGL))
62fb7a5e10962a Gerd Hoffmann 2014-10-28 142 vgdev->has_virgl_3d = true;
ff2ac58a45914c Laurent Vivier 2017-01-24 143 #endif
b4b01b4995fb15 Gerd Hoffmann 2018-10-30 144 if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_EDID)) {
b4b01b4995fb15 Gerd Hoffmann 2018-10-30 145 vgdev->has_edid = true;
b4b01b4995fb15 Gerd Hoffmann 2018-10-30 146 }
5edbb56082567d Gerd Hoffmann 2020-02-07 147 if (virtio_has_feature(vgdev->vdev, VIRTIO_RING_F_INDIRECT_DESC)) {
5edbb56082567d Gerd Hoffmann 2020-02-07 148 vgdev->has_indirect = true;
5edbb56082567d Gerd Hoffmann 2020-02-07 149 }
f6e6d9eff0b4e9 David Stevens 2020-08-13 150 if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_UUID)) {
f6e6d9eff0b4e9 David Stevens 2020-08-13 151 vgdev->has_resource_assign_uuid = true;
f6e6d9eff0b4e9 David Stevens 2020-08-13 152 }
bfb6d04f29ac99 Gerd Hoffmann 2020-08-13 153 if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_BLOB)) {
bfb6d04f29ac99 Gerd Hoffmann 2020-08-13 154 vgdev->has_resource_blob = true;
bfb6d04f29ac99 Gerd Hoffmann 2020-08-13 155 }
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 156 if (virtio_get_shm_region(vgdev->vdev, &vgdev->host_visible_region,
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 157 VIRTIO_GPU_SHM_ID_HOST_VISIBLE)) {
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 158 if (!devm_request_mem_region(&vgdev->vdev->dev,
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 159 vgdev->host_visible_region.addr,
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 160 vgdev->host_visible_region.len,
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 161 dev_name(&vgdev->vdev->dev))) {
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 162 DRM_ERROR("Could not reserve host visible region\n");
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 163 goto err_vqs;
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 164 }
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 165
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 166 DRM_INFO("Host memory window: 0x%lx +0x%lx\n",
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 167 (unsigned long)vgdev->host_visible_region.addr,
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 168 (unsigned long)vgdev->host_visible_region.len);
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 169 vgdev->has_host_visible = true;
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 170 }
62fb7a5e10962a Gerd Hoffmann 2014-10-28 171
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 172 DRM_INFO("features: %cvirgl %cedid %cresource_blob %chost_visible\n",
9e370dfec4fee8 Gerd Hoffmann 2019-10-18 173 vgdev->has_virgl_3d ? '+' : '-',
bfb6d04f29ac99 Gerd Hoffmann 2020-08-13 174 vgdev->has_edid ? '+' : '-',
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 175 vgdev->has_resource_blob ? '+' : '-',
ded3d7b8bb13eb Gerd Hoffmann 2020-08-13 176 vgdev->has_host_visible ? '+' : '-');
9e370dfec4fee8 Gerd Hoffmann 2019-10-18 177
9b2bbdb2275884 Michael S. Tsirkin 2017-03-06 178 ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL);
dc5698e80cf724 Dave Airlie 2013-09-09 179 if (ret) {
dc5698e80cf724 Dave Airlie 2013-09-09 180 DRM_ERROR("failed to find virt queues\n");
dc5698e80cf724 Dave Airlie 2013-09-09 181 goto err_vqs;
dc5698e80cf724 Dave Airlie 2013-09-09 182 }
dc5698e80cf724 Dave Airlie 2013-09-09 183 vgdev->ctrlq.vq = vqs[0];
dc5698e80cf724 Dave Airlie 2013-09-09 184 vgdev->cursorq.vq = vqs[1];
dc5698e80cf724 Dave Airlie 2013-09-09 185 ret = virtio_gpu_alloc_vbufs(vgdev);
dc5698e80cf724 Dave Airlie 2013-09-09 186 if (ret) {
dc5698e80cf724 Dave Airlie 2013-09-09 187 DRM_ERROR("failed to alloc vbufs\n");
dc5698e80cf724 Dave Airlie 2013-09-09 188 goto err_vbufs;
dc5698e80cf724 Dave Airlie 2013-09-09 189 }
dc5698e80cf724 Dave Airlie 2013-09-09 190
dc5698e80cf724 Dave Airlie 2013-09-09 191 /* get display info */
dc5698e80cf724 Dave Airlie 2013-09-09 192 virtio_cread(vgdev->vdev, struct virtio_gpu_config,
dc5698e80cf724 Dave Airlie 2013-09-09 193 num_scanouts, &num_scanouts);
dc5698e80cf724 Dave Airlie 2013-09-09 194 vgdev->num_scanouts = min_t(uint32_t, num_scanouts,
dc5698e80cf724 Dave Airlie 2013-09-09 195 VIRTIO_GPU_MAX_SCANOUTS);
dc5698e80cf724 Dave Airlie 2013-09-09 196 if (!vgdev->num_scanouts) {
dc5698e80cf724 Dave Airlie 2013-09-09 197 DRM_ERROR("num_scanouts is zero\n");
dc5698e80cf724 Dave Airlie 2013-09-09 198 ret = -EINVAL;
dc5698e80cf724 Dave Airlie 2013-09-09 199 goto err_scanouts;
dc5698e80cf724 Dave Airlie 2013-09-09 200 }
62fb7a5e10962a Gerd Hoffmann 2014-10-28 201 DRM_INFO("number of scanouts: %d\n", num_scanouts);
62fb7a5e10962a Gerd Hoffmann 2014-10-28 202
62fb7a5e10962a Gerd Hoffmann 2014-10-28 203 virtio_cread(vgdev->vdev, struct virtio_gpu_config,
62fb7a5e10962a Gerd Hoffmann 2014-10-28 204 num_capsets, &num_capsets);
62fb7a5e10962a Gerd Hoffmann 2014-10-28 205 DRM_INFO("number of cap sets: %d\n", num_capsets);
dc5698e80cf724 Dave Airlie 2013-09-09 206
d516e75c71c985 Ezequiel Garcia 2019-01-08 207 virtio_gpu_modeset_init(vgdev);
dc5698e80cf724 Dave Airlie 2013-09-09 208
dc5698e80cf724 Dave Airlie 2013-09-09 209 virtio_device_ready(vgdev->vdev);
dc5698e80cf724 Dave Airlie 2013-09-09 210
62fb7a5e10962a Gerd Hoffmann 2014-10-28 211 if (num_capsets)
62fb7a5e10962a Gerd Hoffmann 2014-10-28 212 virtio_gpu_get_capsets(vgdev, num_capsets);
b4b01b4995fb15 Gerd Hoffmann 2018-10-30 213 if (vgdev->has_edid)
b4b01b4995fb15 Gerd Hoffmann 2018-10-30 214 virtio_gpu_cmd_get_edids(vgdev);
441012aff674c8 Dave Airlie 2015-06-16 215 virtio_gpu_cmd_get_display_info(vgdev);
234489ea55f81a Gerd Hoffmann 2020-02-14 216 virtio_gpu_notify(vgdev);
441012aff674c8 Dave Airlie 2015-06-16 217 wait_event_timeout(vgdev->resp_wq, !vgdev->display_info_pending,
441012aff674c8 Dave Airlie 2015-06-16 218 5 * HZ);
dc5698e80cf724 Dave Airlie 2013-09-09 219 return 0;
dc5698e80cf724 Dave Airlie 2013-09-09 220
dc5698e80cf724 Dave Airlie 2013-09-09 221 err_scanouts:
dc5698e80cf724 Dave Airlie 2013-09-09 222 virtio_gpu_free_vbufs(vgdev);
dc5698e80cf724 Dave Airlie 2013-09-09 223 err_vbufs:
dc5698e80cf724 Dave Airlie 2013-09-09 224 vgdev->vdev->config->del_vqs(vgdev->vdev);
dc5698e80cf724 Dave Airlie 2013-09-09 225 err_vqs:
dc5698e80cf724 Dave Airlie 2013-09-09 226 kfree(vgdev);
dc5698e80cf724 Dave Airlie 2013-09-09 @227 return ret;
dc5698e80cf724 Dave Airlie 2013-09-09 228 }
dc5698e80cf724 Dave Airlie 2013-09-09 229
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 47589 bytes --]
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 23/24] drm/virtio: implement blob resources: resource create blob ioctl
2020-08-14 2:39 ` [PATCH 23/24] drm/virtio: implement blob resources: resource create blob ioctl Gurchetan Singh
@ 2020-08-17 17:46 ` Anthoine Bourgeois
0 siblings, 0 replies; 29+ messages in thread
From: Anthoine Bourgeois @ 2020-08-17 17:46 UTC (permalink / raw)
To: Gurchetan Singh
Cc: virtio-dev, mst, dri-devel, sebastien.boeuf, kraxel, vgoyal
On Thu, Aug 13, 2020 at 07:39:59PM -0700, Gurchetan Singh wrote:
>From: Gerd Hoffmann <kraxel@redhat.com>
>
>Implement resource create blob as specified.
>
>Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>Co-developed-by: Gurchetan Singh <gurchetansingh@chromium.org>
>Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
>Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
>---
> drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +-
> drivers/gpu/drm/virtio/virtgpu_ioctl.c | 136 ++++++++++++++++++++++++
> drivers/gpu/drm/virtio/virtgpu_object.c | 5 +-
> drivers/gpu/drm/virtio/virtgpu_vram.c | 2 +
> 4 files changed, 144 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
>index 444b65c8d4ee..3e9ec5b1fb63 100644
>--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
>+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
>@@ -255,8 +255,8 @@ struct virtio_gpu_fpriv {
> struct mutex context_lock;
> };
>
>-/* virtgpu_ioctl.c */
>-#define DRM_VIRTIO_NUM_IOCTLS 10
>+/* virtio_ioctl.c */
>+#define DRM_VIRTIO_NUM_IOCTLS 11
> extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS];
> void virtio_gpu_create_context(struct drm_device *dev, struct drm_file *file);
>
>diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
>index 7dbe24248a20..47ac32b7031a 100644
>--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
>+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
>@@ -34,6 +34,10 @@
>
> #include "virtgpu_drv.h"
>
>+#define VIRTGPU_BLOB_FLAG_USE_MASK (VIRTGPU_BLOB_FLAG_USE_MAPPABLE | \
>+ VIRTGPU_BLOB_FLAG_USE_SHAREABLE | \
>+ VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE)
>+
> void virtio_gpu_create_context(struct drm_device *dev, struct drm_file *file)
> {
> struct virtio_gpu_device *vgdev = dev->dev_private;
>@@ -520,6 +524,134 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev,
> return 0;
> }
>
>+static int verify_blob(struct virtio_gpu_device *vgdev,
>+ struct virtio_gpu_fpriv *vfpriv,
>+ struct virtio_gpu_object_params *params,
>+ struct drm_virtgpu_resource_create_blob *rc_blob,
>+ bool *guest_blob, bool *host3d_blob)
>+{
>+ if (!vgdev->has_resource_blob)
>+ return -EINVAL;
>+
>+ if ((rc_blob->blob_flags & ~VIRTGPU_BLOB_FLAG_USE_MASK) ||
>+ !rc_blob->blob_flags)
>+ return -EINVAL;
>+
>+ if (rc_blob->blob_flags & VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) {
>+ if (!vgdev->has_resource_assign_uuid)
>+ return -EINVAL;
>+ }
>+
>+ switch (rc_blob->blob_mem) {
>+ case VIRTGPU_BLOB_MEM_GUEST:
>+ *guest_blob = true;
>+ break;
>+ case VIRTGPU_BLOB_MEM_HOST3D_GUEST:
>+ *guest_blob = true;
>+ fallthrough;
>+ case VIRTGPU_BLOB_MEM_HOST3D:
>+ *host3d_blob = true;
>+ break;
>+ default:
>+ return -EINVAL;
>+ }
>+
>+ if (*host3d_blob) {
>+ if (!vgdev->has_virgl_3d)
>+ return -EINVAL;
>+
>+ /* Must be dword aligned. */
>+ if ((rc_blob->cmd_size) % 4 != 0)
>+ return -EINVAL;
>+
>+ params->ctx_id = vfpriv->ctx_id;
>+ params->blob_id = rc_blob->blob_id;
>+ } else {
>+ if (rc_blob->blob_id != 0)
>+ return -EINVAL;
>+
>+ if (rc_blob->cmd_size != 0)
>+ return -EINVAL;
>+ }
>+
>+ params->blob_mem = rc_blob->blob_mem;
>+ params->size = rc_blob->size;
>+ params->blob = true;
>+ params->blob_flags = rc_blob->blob_flags;
>+ return 0;
>+}
>+
>+static int virtio_gpu_resource_create_blob(struct drm_device *dev,
>+ void *data, struct drm_file *file)
>+{
>+ int ret = 0;
>+ uint32_t handle = 0;
>+ struct drm_gem_object *obj;
>+ struct virtio_gpu_object *bo;
>+ bool host3d_blob, guest_blob;
>+ struct virtio_gpu_object_params params = { 0 };
>+ struct virtio_gpu_device *vgdev = dev->dev_private;
>+ struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
>+ struct drm_virtgpu_resource_create_blob *rc_blob = data;
>+
>+ guest_blob = host3d_blob = false;
>+ if (verify_blob(vgdev, vfpriv, ¶ms, rc_blob,
>+ &guest_blob, &host3d_blob))
>+ return -EINVAL;
>+
>+ if (vgdev->has_virgl_3d)
>+ virtio_gpu_create_context(dev, file);
>+
>+ if (rc_blob->cmd_size) {
>+ void *buf;
>+
>+ buf = memdup_user(u64_to_user_ptr(rc_blob->cmd),
>+ rc_blob->cmd_size);
>+
>+ if (IS_ERR(buf))
>+ return PTR_ERR(buf);
>+
>+ virtio_gpu_cmd_submit(vgdev, buf, rc_blob->cmd_size,
>+ vfpriv->ctx_id, NULL, NULL);
>+ }
>+
>+ if (guest_blob)
>+ ret = virtio_gpu_object_create(vgdev, ¶ms, &bo, NULL);
>+ else if (!guest_blob && host3d_blob)
>+ ret = virtio_gpu_vram_create(vgdev, ¶ms, &bo);
>+ else
>+ return -EINVAL;
>+
>+ if (ret < 0)
>+ return ret;
>+
>+ bo->guest_blob = guest_blob;
>+ bo->host3d_blob = host3d_blob;
>+ bo->blob_mem = rc_blob->blob_mem;
>+ bo->blob_flags = rc_blob->blob_flags;
>+
>+ obj = &bo->base.base;
>+ if (params.blob_flags & VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) {
>+ ret = virtio_gpu_resource_assign_uuid(vgdev, bo);
>+ if (ret) {
>+ drm_gem_object_release(obj);
>+ return ret;
>+ }
>+ }
>+
>+ ret = drm_gem_handle_create(file, obj, &handle);
>+ if (ret) {
>+ drm_gem_object_release(obj);
>+ return ret;
>+ }
>+ drm_gem_object_put(obj);
>+
>+ rc_blob->res_handle = bo->hw_res_handle;
>+ rc_blob->bo_handle = handle;
>+
>+ return 0;
>+}
>+
> struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = {
> DRM_IOCTL_DEF_DRV(VIRTGPU_MAP, virtio_gpu_map_ioctl,
> DRM_RENDER_ALLOW),
>@@ -552,4 +684,8 @@ struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = {
>
> DRM_IOCTL_DEF_DRV(VIRTGPU_GET_CAPS, virtio_gpu_get_caps_ioctl,
> DRM_RENDER_ALLOW),
>+
>+ DRM_IOCTL_DEF_DRV(VIRTGPU_RESOURCE_CREATE_BLOB,
>+ virtio_gpu_resource_create_blob,
Should the function be suffixed by _ioctl like the others?
Other than than, all the serie is:
Reviewed-by: Anthoine Bourgeois <anthoine.bourgeois@gmail.com>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2020-08-17 17:47 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-14 2:39 [PATCH 00/24] Blob prerequisites + blob resources Gurchetan Singh
2020-08-14 2:39 ` [PATCH 01/24] drm/virtio: Revert "drm/virtio: Call the right shmem helpers" Gurchetan Singh
2020-08-14 2:39 ` [PATCH 02/24] virtio: add dma-buf support for exported objects Gurchetan Singh
2020-08-14 2:39 ` [PATCH 03/24] virtio-gpu: add VIRTIO_GPU_F_RESOURCE_UUID feature Gurchetan Singh
2020-08-14 2:39 ` [PATCH 04/24] drm/virtio: Support virtgpu exported resources Gurchetan Singh
2020-08-14 2:39 ` [PATCH 05/24] virtio: Add get_shm_region method Gurchetan Singh
2020-08-14 2:39 ` [PATCH 06/24] virtio: Implement get_shm_region for PCI transport Gurchetan Singh
2020-08-14 2:39 ` [PATCH 07/24] virtio: Implement get_shm_region for MMIO transport Gurchetan Singh
2020-08-14 2:39 ` [PATCH 08/24] drm/virtio: blob prep: refactor getting pages and attaching backing Gurchetan Singh
2020-08-14 2:39 ` [PATCH 09/24] drm/virtio: blob prep: make CPU responses more generic Gurchetan Singh
2020-08-14 2:39 ` [PATCH 10/24] virtio-gpu api: blob resources Gurchetan Singh
2020-08-14 2:39 ` [PATCH 11/24] virtio-gpu api: host visible feature Gurchetan Singh
2020-08-14 2:39 ` [PATCH 12/24] virtio-gpu api: cross-device feature Gurchetan Singh
2020-08-14 2:39 ` [PATCH 13/24] drm/virtio: implement blob resources: probe for the feature Gurchetan Singh
2020-08-14 2:39 ` [PATCH 14/24] drm/virtio: implement blob resources: probe for host visible region Gurchetan Singh
2020-08-16 13:10 ` kernel test robot
2020-08-14 2:39 ` [PATCH 15/24] drm/virtio: implement blob resources: expose virtio_gpu_resource_id_get Gurchetan Singh
2020-08-14 2:39 ` [PATCH 16/24] drm/virtio: implement blob resources: add new fields to internal structs Gurchetan Singh
2020-08-14 2:39 ` [PATCH 17/24] drm/virtio: implement blob resources: implement vram object Gurchetan Singh
2020-08-14 5:39 ` kernel test robot
2020-08-14 2:39 ` [PATCH 18/24] drm/virtio: implement blob resources: hypercall interface Gurchetan Singh
2020-08-14 6:12 ` kernel test robot
2020-08-14 2:39 ` [PATCH 19/24] drm/virtio: implement blob resources: blob display integration Gurchetan Singh
2020-08-14 2:39 ` [PATCH 20/24] drm/virtio: implement blob resources: refactor UUID code somewhat Gurchetan Singh
2020-08-14 2:39 ` [PATCH 21/24] drm/virtio: implement blob resources: fix stride discrepancy Gurchetan Singh
2020-08-14 2:39 ` [PATCH 22/24] drm/virtio: implement blob resources: report blob mem to userspace Gurchetan Singh
2020-08-14 2:39 ` [PATCH 23/24] drm/virtio: implement blob resources: resource create blob ioctl Gurchetan Singh
2020-08-17 17:46 ` Anthoine Bourgeois
2020-08-14 2:40 ` [PATCH 24/24] drm/virtio: advertise features to userspace Gurchetan Singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).