Skip to contentSkip to conversation

drm/i915/gvt: Dma-buf support for GVT-g

PATCH Superseded Tina Zhang 4 participants 22 messages Nov 6, 2017 – Nov 8, 2017

Subsystems (5)

v16 of 19 Superseded Latest is v19 →

lore
Share & tools
lore

Tina Zhang

author
#0 lore raw

v16 cover drm/i915/gvt: Dma-buf support for GVT-g

v15->v16:
1) add cursor hotspot fields in struct vfio_device_gfx_plane_info. (Gerd)
2) clean up some typos and add comments for VFIO_DEVICE_QUERY_GFX_PLANE. (Alex)
3) seperate the GEM Proxy part to another patch-set. (Joonas and Chris)
https://lists.freedesktop.org/archives/intel-gvt-dev/2017-November/002377.html
4) please note that this patch-set needs 3) to be applied first.
5) rebase to 4.14.0-rc6.

v14->15:
1) add VFIO_DEVICE_GET_GFX_DMABUF ABI. (Gerd)
2) add intel_vgpu_dmabuf_cleanup() to clean up the vGPU's dmabuf. (Gerd)

v13->v14:
1) add PROBE, DMABUF and REGION flags. (Alex)
2) return -ENXIO when gem proxy object is banned by ioctl. (Chris) (Daniel)
3) add some details about the float pixel format. (Daniel)
4) add F suffix to the defined name. (Daniel)
5) refine pixel format table. (Zhenyu)

v12->v13:
1) add comments to GEM proxy. (Chris)
2) don't ban GEM proxy in i915_gem_sw_finish_ioctl. (Chris)
3) check GEM proxy bar after finishing i915_gem_object_wait. (Chris)
4) remove GEM proxy bar in i915_gem_madvise_ioctl.

v11->v12:
1) add drm_format_mod back. (Gerd and Zhenyu)
2) add region_index. (Gerd)
3) refine the lifecycle of dmabuf.
4) send to dri-devel at lists.freedesktop.org. (Ville)

v10->v11:
1) rename plane_type to drm_plane_type. (Gerd)
2) move fields of vfio_device_query_gfx_plane to
vfio_device_gfx_plane_info. (Gerd)
3) remove drm_format_mod, start fields. (Daniel)
4) remove plane_id.

v9->v10:
1) remove dma-buf management
2) refine the ABI API VFIO_DEVICE_QUERY_GFX_PLANE
3) track the dma-buf create and release in kernel mode

v8->v9:
1) refine the dma-buf ioctl definition
2) add a lock to protect the dmabuf list
3) move drm format change to a separate patch
4) codes cleanup

v7->v8:
1) refine framebuffer decoder code
2) fix a bug in decoding primary plane

v6->v7:
1) release dma-buf related allocations in dma-buf's associated release function.
2) refine ioctl interface for querying plane info or create dma-buf
3) refine framebuffer decoder code
4) the patch series is based on 4.12.0-rc1

v5->v6:
1) align the dma-buf life cycle with the vfio device.
2) add the dma-buf related operations in a separate patch.
3) i915 releated changes.

v4->v5:
1) fix bug while checking whether the gem obj is gvt's dma-buf when user change caching mode or domains. Add a helper function to do it.
2) add definition for the query plane and create dma-buf.

v3->v4:
1) fix bug while checking whether the gem obj is gvt's dma-buf when set caching mode or doamins.

v2->v3:
1) add a field gvt_plane_info in the drm_i915_gem_obj structure to save the decoded plane information to avoid look up while need the plane info.
2) declare a new flag I915_GEM_OBJECT_IS_GVT_DMABUF in drm_i915_gem_object to represent the gem obj for gvt's dma-buf. The tiling mode, caching mode and domains can not be changed for this kind of gem object.
3) change dma-buf related information to be more generic. So other vendor can use the same interface.

v1->v2:
1) create a management fd for dma-buf operations.
2) alloc gem object's backing storage in gem obj's get_pages() callback.

This patch set adds the dma-buf support for intel GVT-g.

dma-buf is an uniform mechanism to share DMA buffers across different devices and subsystems. dma-buf for intel GVT-g is mainly used to share the vgpu's framebuffer to userspace to leverage userspace graphics stacks to render the framebuffer to the display monitor.

The main idea is that we create a gem object and set vgpu's framebuffer as its backing storage. Then, export a dma-buf associated with this gem object. With the fd of this dma-buf, userspace can directly handle this buffer.

This patch set can be tried with the following example:
git://git.kraxel.org/qemu branch: work/intel-vgpu

Tina Zhang (6):
drm/i915/gvt: Add framebuffer decoder support
drm: Introduce RGB 64-bit 16:16:16:16 float format drm/i915/gvt: Add RGB 64-bit 16:16:16:16 float format drm/i915/gvt: Add opregion support
vfio: ABI for mdev display dma-buf operation drm/i915/gvt: Dmabuf support for GVT-g

 drivers/gpu/drm/i915/gvt/Makefile      |   3 +-
 drivers/gpu/drm/i915/gvt/display.c     |   2 +-
 drivers/gpu/drm/i915/gvt/display.h     |   2 +
 drivers/gpu/drm/i915/gvt/dmabuf.c      | 527 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/dmabuf.h      |  67 +++++
 drivers/gpu/drm/i915/gvt/fb_decoder.c  | 521 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/fb_decoder.h  | 169 +++++++++++
 drivers/gpu/drm/i915/gvt/gvt.c         |   2 +
 drivers/gpu/drm/i915/gvt/gvt.h         |  12 +
 drivers/gpu/drm/i915/gvt/hypercall.h   |   3 +
 drivers/gpu/drm/i915/gvt/kvmgt.c       | 164 +++++++++-
 drivers/gpu/drm/i915/gvt/mpt.h         |  45 +++
 drivers/gpu/drm/i915/gvt/opregion.c    |  26 +-
 drivers/gpu/drm/i915/gvt/vgpu.c        |   9 +-
 drivers/gpu/drm/i915/i915_gem_object.h |   2 +
 include/uapi/drm/drm_fourcc.h          |   4 +
 include/uapi/linux/vfio.h              |  68 +++++
 17 files changed, 1614 insertions(+), 12 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.c
 create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.h
 create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.c
 create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.h
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v16 1/6 drm/i915/gvt: Add framebuffer decoder support

This patch is to introduce the framebuffer decoder which can decode guest OS's framebuffer information, including primary, cursor and sprite plane.

v16:
rebase to 4.14.0-rc6.

v14:
- refine pixel format table. (Zhenyu)

v9:
- move drm format change to a separate patch. (Xiaoguang)

v8:
- fix a bug in decoding primary plane. (Tina)

v7:
- refine framebuffer decoder code. (Zhenyu)

---
 drivers/gpu/drm/i915/gvt/Makefile     |   3 +-
 drivers/gpu/drm/i915/gvt/display.c    |   2 +-
 drivers/gpu/drm/i915/gvt/display.h    |   2 +
 drivers/gpu/drm/i915/gvt/fb_decoder.c | 507 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/fb_decoder.h | 169 ++++++++++++
 drivers/gpu/drm/i915/gvt/gvt.h        |   1 +
 6 files changed, 682 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.c
 create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.h
drivers/gpu/drm/i915/gvt/Makefile +2 -1
index 7100240..54d70df 100644
@@ -1,7 +1,8 @@
 GVT_DIR := gvt
 GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \
 	interrupt.o gtt.o cfg_space.o opregion.o mmio.o display.o edid.o \
-	execlist.o scheduler.o sched_policy.o render.o cmd_parser.o debugfs.o
+	execlist.o scheduler.o sched_policy.o render.o cmd_parser.o debugfs.o \
+	fb_decoder.o
 
 ccflags-y				+= -I$(src) -I$(src)/$(GVT_DIR)
 i915-y					+= $(addprefix $(GVT_DIR)/, $(GVT_SOURCE))
drivers/gpu/drm/i915/gvt/display.c +1 -1
index 3c31843..fb7fdba 100644
@@ -67,7 +67,7 @@ static int edp_pipe_is_enabled(struct intel_vgpu *vgpu)
 	return 1;
 }
 
-static int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe)
+int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe)
 {
 	struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
 
drivers/gpu/drm/i915/gvt/display.h +2 -0
index d73de22..b46b868 100644
@@ -179,4 +179,6 @@ int intel_vgpu_init_display(struct intel_vgpu *vgpu, u64 resolution);
 void intel_vgpu_reset_display(struct intel_vgpu *vgpu);
 void intel_vgpu_clean_display(struct intel_vgpu *vgpu);
 
+int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe);
+
 #endif
drivers/gpu/drm/i915/gvt/fb_decoder.c new file +507 -0

507 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/fb_decoder.h new file +169 -0

169 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/gvt.h +1 -0
index 27e8186..c8e496c 100644
@@ -46,6 +46,7 @@
 #include "sched_policy.h"
 #include "render.h"
 #include "cmd_parser.h"
+#include "fb_decoder.h"
 
 #define GVT_MAX_VGPU 8
 
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH v16 1/6] drm/i915/gvt: Add framebuffer decoder support

Hi,

Quoted 6 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c new file +4 -0
+static struct pixel_format bdw_pixel_formats[] = {
+	{DRM_FORMAT_C8, 8, "8-bit Indexed"},
 
+static struct pixel_format skl_pixel_formats[] = {
+	{DRM_FORMAT_YUYV, 16, "16-bit packed YUYV (8:8:8:8 MSB-

V:Y2:U:Y1)"},

Broadwell and Skylake.

What is the state for newer chipsets?

Is Kabylake supported by gvt meanwhile? Does it need specific fb decoder support, or is it compatible with skylake?

cheers,
Gerd

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

RE: [PATCH v16 1/6] drm/i915/gvt: Add framebuffer decoder support

Quoted 26 lines

-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Gerd Hoffmann
Sent: Monday, November 6, 2017 4:49 PM
To: Zhang, Tina <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH v16 1/6] drm/i915/gvt: Add framebuffer decoder support

Hi,

Quoted 6 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c new file +4 -0
+static struct pixel_format bdw_pixel_formats[] = {
+	{DRM_FORMAT_C8, 8, "8-bit Indexed"},
 
+static struct pixel_format skl_pixel_formats[] = {
+	{DRM_FORMAT_YUYV, 16, "16-bit packed YUYV (8:8:8:8 MSB-

V:Y2:U:Y1)"},

Broadwell and Skylake.

Quoted 4 lines

What is the state for newer chipsets?

Is Kabylake supported by gvt meanwhile? Does it need specific fb decoder support, or is it compatible with skylake?

Kabylake is supported by gvt. And the fb part should be compatible with skylake. But I haven't tested it yet. Besides, the current version needs to add some platform checking logic to support Kabylake. Thanks.

BR,
Tina

Quoted 8 lines

cheers,
Gerd

_______________________________________________
intel-gvt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#4 lore raw

PATCH v16 2/6 drm: Introduce RGB 64-bit 16:16:16:16 float format

In reply to Tina Zhang

The RGB 64-bit 16:16:16:16 float pixel format is needed by some Apps in windows. The float format in each component is 1:5:10 MSb-sign:exponent:
fraction.

This patch is to introduce the format to drm, so that the windows guest's framebuffer in this kind of format can be recognized and used by linux host.

v14:
- add some details about the float pixel format. (Daniel)
- add F suffix to the defined name. (Daniel)

v12:
- send to dri-devel at lists.freedesktop.org. (Ville)

v9:
- separated from framebuffer decoder patch. (Zhenyu) (Xiaoguang)

Cc Ville Syrjälä <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 include/uapi/drm/drm_fourcc.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/drm/drm_fourcc.h +4 -0
index 3ad838d..391d2e6 100644
@@ -113,6 +113,10 @@ extern "C" {
 
 #define DRM_FORMAT_AYUV		fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
 
+/* 64 bpp RGB 16:16:16:16 Floating Point */
+#define DRM_FORMAT_XRGB161616F  fourcc_code('X', 'R', '3', 'F') /* [63:0] x:R:G:B 16:16:16:16 little endian */
+#define DRM_FORMAT_XBGR161616F  fourcc_code('X', 'B', '3', 'F') /* [63:0] x:B:G:R 16:16:16:16 little endian */
+
 /*
  * 2 plane RGB + A
  * index 0 = RGB plane, same format as the corresponding non _A8 format has
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#5 lore raw

PATCH v16 3/6 drm/i915/gvt: Add RGB 64-bit 16:16:16:16 float format

In reply to Tina Zhang

The RGB 64-bit 16:16:16:16 float pixel format is needed by windows 10 guest VM. This patch is to add this pixel format support to gvt device model. Without this patch, some Apps, e.g. "DXGIGammaVM.exe", will crash and make guest screen black.

---
 drivers/gpu/drm/i915/gvt/fb_decoder.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/gvt/fb_decoder.c +21 -7
index 6c99c64..b9e0d8e 100644
@@ -52,6 +52,8 @@ static struct pixel_format bdw_pixel_formats[] = {
 
 	{DRM_FORMAT_XRGB2101010, 32, "32-bit BGRX (2:10:10:10 MSB-X:R:G:B)"},
 	{DRM_FORMAT_XBGR8888, 32, "32-bit RGBX (8:8:8:8 MSB-X:B:G:R)"},
+	{DRM_FORMAT_XRGB161616F, 64,
+		"64-bit XRGB Floating Point (16:16:16:16 MSB-X:R:G:B)"},
 
 	/* non-supported format has bpp default to 0 */
 	{0, 0, NULL},
@@ -73,13 +75,18 @@ static struct pixel_format skl_pixel_formats[] = {
 	{DRM_FORMAT_XBGR2101010, 32, "32-bit RGBX (2:10:10:10 MSB-X:B:G:R)"},
 	{DRM_FORMAT_XRGB2101010, 32, "32-bit BGRX (2:10:10:10 MSB-X:R:G:B)"},
 
+	{DRM_FORMAT_XRGB161616F, 64,
+		"64-bit XRGB Floating Point (16:16:16:16 MSB-X:R:G:B)"},
+	{DRM_FORMAT_XBGR161616F, 64,
+		"64-bit XBGR Floating Point (16:16:16:16 MSB-X:B:G:R)"},
+
 	/* non-supported format has bpp default to 0 */
 	{0, 0, NULL},
 };
 
 static int bdw_format_to_drm(int format)
 {
-	int bdw_pixel_formats_index = 6;
+	int bdw_pixel_formats_index = 7;
 
 	switch (format) {
 	case DISPPLANE_8BPP:
@@ -100,7 +107,9 @@ static int bdw_format_to_drm(int format)
 	case DISPPLANE_RGBX888:
 		bdw_pixel_formats_index = 5;
 		break;
-
+	case DISPPLANE_RGBX161616:
+		bdw_pixel_formats_index = 6;
+		break;
 	default:
 		break;
 	}
@@ -111,7 +120,7 @@ static int bdw_format_to_drm(int format)
 static int skl_format_to_drm(int format, bool rgb_order, bool alpha,
 	int yuv_order)
 {
-	int skl_pixel_formats_index = 12;
+	int skl_pixel_formats_index = 14;
 
 	switch (format) {
 	case PLANE_CTL_FORMAT_INDEXED:
@@ -129,6 +138,9 @@ static int skl_format_to_drm(int format, bool rgb_order, bool alpha,
 	case PLANE_CTL_FORMAT_XRGB_2101010:
 		skl_pixel_formats_index = rgb_order ? 10 : 11;
 		break;
+	case PLANE_CTL_FORMAT_XRGB_16161616F:
+		skl_pixel_formats_index = rgb_order ? 12 : 13;
+		break;
 	case PLANE_CTL_FORMAT_YUV422:
 		skl_pixel_formats_index = yuv_order >> 16;
 		if (skl_pixel_formats_index > 3)
@@ -389,11 +401,13 @@ int intel_vgpu_decode_cursor_plane(struct intel_vgpu *vgpu,
 #define SPRITE_FORMAT_NUM	(1 << 3)
 
 static struct pixel_format sprite_pixel_formats[SPRITE_FORMAT_NUM] = {
-	[0x0] = {DRM_FORMAT_YUV422, 16, "YUV 16-bit 4:2:2 packed"},
-	[0x1] = {DRM_FORMAT_XRGB2101010, 32, "RGB 32-bit 2:10:10:10"},
-	[0x2] = {DRM_FORMAT_XRGB8888, 32, "RGB 32-bit 8:8:8:8"},
+	[0x0] = {DRM_FORMAT_YUV422, 16, "16-bit YUV 4:2:2 packed"},
+	[0x1] = {DRM_FORMAT_XRGB2101010, 32, "32-bit BGRX (2:10:10:10 MSB-X:R:G:B)"},
+	[0x2] = {DRM_FORMAT_XRGB8888, 32, "32-bit RGBX (8:8:8:8 MSB-X:B:G:R)"},
+	[0x3]  = {DRM_FORMAT_XRGB161616F, 64,
+		    "64-bit XRGB Floating Point (16:16:16:16 MSB-X:R:G:B)"},
 	[0x4] = {DRM_FORMAT_AYUV, 32,
-		"YUV 32-bit 4:4:4 packed (8:8:8:8 MSB-X:Y:U:V)"},
+		"32-bit YUV 4:4:4 packed (8:8:8:8 MSB-X:Y:U:V)"},
 };
 
 /**
Signature · 1 line
2.7.4
author
#6 lore raw

PATCH v16 4/6 drm/i915/gvt: Add opregion support

In reply to Tina Zhang

Windows guest driver needs vbt in opregion, to configure the setting for display. Without opregion support, the display registers won't be set and this blocks display model to get the correct information of the guest display plane.

This patch is to provide a virtual opregion for guest. Current implementation is to fill the virtual opregion with the content in host's opregion. The original author of this patch is Xiaoguang Chen.

v16:
- rebase to 4.14.0-rc6

---
 drivers/gpu/drm/i915/gvt/hypercall.h |   1 +
 drivers/gpu/drm/i915/gvt/kvmgt.c     | 104 ++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/gvt/mpt.h       |  15 +++++
 drivers/gpu/drm/i915/gvt/opregion.c  |  26 +++++++--
 drivers/gpu/drm/i915/gvt/vgpu.c      |   4 ++
 5 files changed, 141 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/gvt/hypercall.h +1 -0
index df7f33a..32c345c 100644
@@ -55,6 +55,7 @@ struct intel_gvt_mpt {
 			      unsigned long mfn, unsigned int nr, bool map);
 	int (*set_trap_area)(unsigned long handle, u64 start, u64 end,
 			     bool map);
+	int (*set_opregion)(void *vgpu);
 };
 
 extern struct intel_gvt_mpt xengt_mpt;
drivers/gpu/drm/i915/gvt/kvmgt.c +101 -3

152 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/mpt.h +15 -0
index c436e20..c99e796 100644
@@ -294,4 +294,19 @@ static inline int intel_gvt_hypervisor_set_trap_area(
 	return intel_gvt_host.mpt->set_trap_area(vgpu->handle, start, end, map);
 }
 
+/**
+ * intel_gvt_hypervisor_set_opregion - Set opregion for guest
+ * @vgpu: a vGPU
+ *
+ * Returns:
+ * Zero on success, negative error code if failed.
+ */
+static inline int intel_gvt_hypervisor_set_opregion(struct intel_vgpu *vgpu)
+{
+	if (!intel_gvt_host.mpt->set_opregion)
+		return 0;
+
+	return intel_gvt_host.mpt->set_opregion(vgpu);
+}
+
 #endif /* _GVT_MPT_H_ */
drivers/gpu/drm/i915/gvt/opregion.c +20 -6
index 2533d1e..1e8b3d6 100644
@@ -285,23 +285,37 @@ void intel_vgpu_clean_opregion(struct intel_vgpu *vgpu)
  */
 int intel_vgpu_init_opregion(struct intel_vgpu *vgpu, u32 gpa)
 {
-	int ret;
+	int ret = 0;
+	unsigned long pfn;
 
 	gvt_dbg_core("vgpu%d: init vgpu opregion\n", vgpu->id);
 
-	if (intel_gvt_host.hypervisor_type == INTEL_GVT_HYPERVISOR_XEN) {
+	switch (intel_gvt_host.hypervisor_type) {
+	case INTEL_GVT_HYPERVISOR_KVM:
+		pfn = intel_gvt_hypervisor_gfn_to_mfn(vgpu, gpa >> PAGE_SHIFT);
+		vgpu_opregion(vgpu)->va = memremap(pfn << PAGE_SHIFT,
+						INTEL_GVT_OPREGION_SIZE,
+						MEMREMAP_WB);
+		if (!vgpu_opregion(vgpu)->va) {
+			gvt_vgpu_err("failed to map guest opregion\n");
+			ret = -EFAULT;
+		}
+		break;
+	case INTEL_GVT_HYPERVISOR_XEN:
 		gvt_dbg_core("emulate opregion from kernel\n");
 
 		ret = init_vgpu_opregion(vgpu, gpa);
 		if (ret)
-			return ret;
+			break;
 
 		ret = map_vgpu_opregion(vgpu, true);
-		if (ret)
-			return ret;
+		break;
+	default:
+		ret = -EINVAL;
+		gvt_vgpu_err("not supported hypervisor\n");
 	}
 
-	return 0;
+	return ret;
 }
 
 /**
drivers/gpu/drm/i915/gvt/vgpu.c +4 -0
index c6b82d1..42aee6b 100644
@@ -386,6 +386,10 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
 	if (ret)
 		goto out_clean_sched_policy;
 
+	ret = intel_gvt_hypervisor_set_opregion(vgpu);
+	if (ret)
+		goto out_clean_sched_policy;
+
 	mutex_unlock(&gvt->lock);
 
 	return vgpu;
Signature · 1 line
2.7.4
author
#7 lore raw

PATCH v16 5/6 vfio: ABI for mdev display dma-buf operation

In reply to Tina Zhang

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user query and get a plane and its related information. So far, two types of buffers are
supported: buffers based on dma-buf and buffers based on region.

This ioctl can be invoked with:
1) either DMABUF or REGION flag. Vendor driver returns a plane_info successfully only when the specific kind of buffer is supported.
2) flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver can return success only when the specific kind of buffer is supported.

Add VFIO_DEVICE_GET_GFX_DMABUF ioctl command to let user get an exposed dma-buf fd of a specific dmabuf_id which was returned in VFIO_DEVICE_QUERY _GFX_PLANE ioctl command.

The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned dmabuf_id in struct vfio_device_ query_gfx_plane can be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value of dmabuf_id to see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.

v16:
- add x_hot and y_hot fields. (Gerd)
- add comments for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.

v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)

v14:
- add PROBE, DMABUF and REGION flags. (Alex)

v12:
- add drm_format_mod back. (Gerd and Zhenyu)
- add region_index. (Gerd)

v11:
- rename plane_type to drm_plane_type. (Gerd)
- move fields of vfio_device_query_gfx_plane to vfio_device_gfx_plane_info. (Gerd)
- remove drm_format_mod, start fields. (Daniel)
- remove plane_id.

v10:
- refine the ABI API VFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)

v3:
- add a field gvt_plane_info in the drm_i915_gem_obj structure to save the decoded plane information to avoid look up while need the plane info. (Gerd)

Cc Gerd Hoffmann <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 include/uapi/linux/vfio.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
include/uapi/linux/vfio.h +68 -0
index ae46105..6c55668 100644
@@ -502,6 +502,74 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE + 13)
 
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14,
+ *                                    struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and flags, then retrieve the gfx plane info.
+ *
+ * flags supported:
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set
+ *   to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no
+ *   support for dma-buf.
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set
+ *   to ask if the mdev supports region. 0 on support, -EINVAL on no
+ *   support for region.
+ * - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set
+ *   with each call to query the plane info.
+ * - Others are invalid and return -EINVAL.
+ *
+ * Return: 0 on success, -ENODEV with all out fields zero on mdev
+ * device initialization, -errno on other failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0)
+#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1)
+#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_* */
+	/* out */
+	__u32 drm_format;	/* drm format of plane */
+	__u64 drm_format_mod;   /* tiled mode */
+	__u32 width;	/* width of plane */
+	__u32 height;	/* height of plane */
+	__u32 stride;	/* stride of plane */
+	__u32 size;	/* size of plane in bytes, align on page*/
+	__u32 x_pos;	/* horizontal position of cursor plane */
+	__u32 y_pos;	/* vertical position of cursor plane*/
+	__u32 x_hot;    /* horizontal position of cursor hotspot */
+	__u32 y_hot;    /* vertical position of cursor hotspot */
+	union {
+		__u32 region_index;	/* region index */
+		__u32 dmabuf_id;	/* dma-buf id */
+	};
+};
+
+#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
+
+/**
+ * VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15,
+ *				    struct vfio_device_gfx_dmabuf_fd)
+ *
+ * Retrieve dmabuf_fd of an exposed guest framebuffer referenced by dmabuf_id
+ * which is returned from VFIO_DEVICE_QUERY_GFX_PLANE as a token of the
+ * exposed guest framebuffer.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_dmabuf_fd {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 dmabuf_id;
+	/* out */
+	__s32 dmabuf_fd;
+};
+
+#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15)
+
 /* -------- API for Type1 VFIO IOMMU -------- */
 
 /**
Signature · 1 line
2.7.4
#8 lore raw

Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Quoted 126 lines · On Mon, 6 Nov 2017 10:19:17 +0800 Tina Zhang <[email protected]> wrote:

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user query and get a plane and its related information. So far, two types of buffers are
supported: buffers based on dma-buf and buffers based on region.

This ioctl can be invoked with:
1) either DMABUF or REGION flag. Vendor driver returns a plane_info successfully only when the specific kind of buffer is supported.
2) flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver can return success only when the specific kind of buffer is supported.

Add VFIO_DEVICE_GET_GFX_DMABUF ioctl command to let user get an exposed dma-buf fd of a specific dmabuf_id which was returned in VFIO_DEVICE_QUERY _GFX_PLANE ioctl command.

The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned dmabuf_id in struct vfio_device_ query_gfx_plane can be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value of dmabuf_id to see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.

v16:
- add x_hot and y_hot fields. (Gerd)
- add comments for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.

v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)

v14:
- add PROBE, DMABUF and REGION flags. (Alex)

v12:
- add drm_format_mod back. (Gerd and Zhenyu)
- add region_index. (Gerd)

v11:
- rename plane_type to drm_plane_type. (Gerd)
- move fields of vfio_device_query_gfx_plane to vfio_device_gfx_plane_info. (Gerd)
- remove drm_format_mod, start fields. (Daniel)
- remove plane_id.

v10:
- refine the ABI API VFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)

v3:
- add a field gvt_plane_info in the drm_i915_gem_obj structure to save the decoded plane information to avoid look up while need the plane info. (Gerd)

Cc Gerd Hoffmann <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 include/uapi/linux/vfio.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
include/uapi/linux/vfio.h +58 -0
index ae46105..6c55668 100644
@@ -502,6 +502,74 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE + 13)
 
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14,
+ *                                    struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and flags, then retrieve the gfx plane info.
+ *
+ * flags supported:
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set
+ *   to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no
+ *   support for dma-buf.
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set
+ *   to ask if the mdev supports region. 0 on support, -EINVAL on no
+ *   support for region.
+ * - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set
+ *   with each call to query the plane info.
+ * - Others are invalid and return -EINVAL.
+ *
+ * Return: 0 on success, -ENODEV with all out fields zero on mdev
+ * device initialization, -errno on other failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0)
+#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1)
+#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_* */
+	/* out */
+	__u32 drm_format;	/* drm format of plane */
+	__u64 drm_format_mod;   /* tiled mode */
+	__u32 width;	/* width of plane */
+	__u32 height;	/* height of plane */
+	__u32 stride;	/* stride of plane */
+	__u32 size;	/* size of plane in bytes, align on page*/
+	__u32 x_pos;	/* horizontal position of cursor plane */
+	__u32 y_pos;	/* vertical position of cursor plane*/
+	__u32 x_hot;    /* horizontal position of cursor hotspot */
+	__u32 y_hot;    /* vertical position of cursor hotspot */
+	union {
+		__u32 region_index;	/* region index */
+		__u32 dmabuf_id;	/* dma-buf id */
+	};
+};
+
+#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
+
+/**
+ * VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15,
+ *				    struct vfio_device_gfx_dmabuf_fd)
+ *
+ * Retrieve dmabuf_fd of an exposed guest framebuffer referenced by dmabuf_id
+ * which is returned from VFIO_DEVICE_QUERY_GFX_PLANE as a token of the
+ * exposed guest framebuffer.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_dmabuf_fd {

include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 572

Quoted 10 lines
include/uapi/linux/vfio.h +10 -0
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 dmabuf_id;
+	/* out */
+	__s32 dmabuf_fd;
+};
+
+#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15)
+

I thought we had agreed to make this behave similar to VFIO_GROUP_GET_DEVICE_FD, the ioctl would take a __u32 dmabuf_id and return the file descriptor as the ioctl return value. Thanks,

Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

RE: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Quoted 158 lines

-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Monday, November 6, 2017 10:39 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; Daniel Vetter <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; [email protected]
Subject: Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Quoted 67 lines · On Mon, 6 Nov 2017 10:19:17 +0800 Tina Zhang <[email protected]> wrote:

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user query and get a plane and its related information. So far, two types of buffers are
supported: buffers based on dma-buf and buffers based on region.

This ioctl can be invoked with:
1) either DMABUF or REGION flag. Vendor driver returns a plane_info successfully only when the specific kind of buffer is supported.
2) flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver can return success only when the specific kind of buffer is supported.

Add VFIO_DEVICE_GET_GFX_DMABUF ioctl command to let user get an exposed dma-buf fd of a specific dmabuf_id which was returned in VFIO_DEVICE_QUERY _GFX_PLANE ioctl command.

The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned dmabuf_id in struct vfio_device_ query_gfx_plane can be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value of dmabuf_id to see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.

v16:
- add x_hot and y_hot fields. (Gerd)
- add comments for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.

v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)

v14:
- add PROBE, DMABUF and REGION flags. (Alex)

v12:
- add drm_format_mod back. (Gerd and Zhenyu)
- add region_index. (Gerd)

v11:
- rename plane_type to drm_plane_type. (Gerd)
- move fields of vfio_device_query_gfx_plane to vfio_device_gfx_plane_info. (Gerd)
- remove drm_format_mod, start fields. (Daniel)
- remove plane_id.

v10:
- refine the ABI API VFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)

v3:
- add a field gvt_plane_info in the drm_i915_gem_obj structure to save the decoded plane information to avoid look up while need the plane info. (Gerd)

Cc Gerd Hoffmann <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 include/uapi/linux/vfio.h | 68
+++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
include/uapi/linux/vfio.h +0 -0
index ae46105..6c55668 100644

include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 503

Quoted 2 lines
include/uapi/linux/vfio.h +0 -0
@@ -502,6 +502,74 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE +

13)

include/uapi/linux/vfio.h struct vfio_pci_hot_reset {

Quoted 9 lines
include/uapi/linux/vfio.h +8 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14,
+ *                                    struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and flags, then retrieve the gfx plane info.
+ *
+ * flags supported:
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF

are set

include/uapi/linux/vfio.h struct vfio_pci_hot_reset {

Quoted 3 lines
include/uapi/linux/vfio.h +3 -0
+ *   to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no
+ *   support for dma-buf.
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION

are set

include/uapi/linux/vfio.h struct vfio_pci_hot_reset {

Quoted 3 lines
include/uapi/linux/vfio.h +3 -0
+ *   to ask if the mdev supports region. 0 on support, -EINVAL on no
+ *   support for region.
+ * - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION

is set

Quoted 52 lines
include/uapi/linux/vfio.h +52 -0
+ *   with each call to query the plane info.
+ * - Others are invalid and return -EINVAL.
+ *
+ * Return: 0 on success, -ENODEV with all out fields zero on mdev
+ * device initialization, -errno on other failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) #define
+VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) #define
+VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_* */
+	/* out */
+	__u32 drm_format;	/* drm format of plane */
+	__u64 drm_format_mod;   /* tiled mode */
+	__u32 width;	/* width of plane */
+	__u32 height;	/* height of plane */
+	__u32 stride;	/* stride of plane */
+	__u32 size;	/* size of plane in bytes, align on page*/
+	__u32 x_pos;	/* horizontal position of cursor plane */
+	__u32 y_pos;	/* vertical position of cursor plane*/
+	__u32 x_hot;    /* horizontal position of cursor hotspot */
+	__u32 y_hot;    /* vertical position of cursor hotspot */
+	union {
+		__u32 region_index;	/* region index */
+		__u32 dmabuf_id;	/* dma-buf id */
+	};
+};
+
+#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
+
+/**
+ * VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15,
+ *				    struct vfio_device_gfx_dmabuf_fd)
+ *
+ * Retrieve dmabuf_fd of an exposed guest framebuffer referenced by
+dmabuf_id
+ * which is returned from VFIO_DEVICE_QUERY_GFX_PLANE as a token of
+the
+ * exposed guest framebuffer.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_dmabuf_fd {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 dmabuf_id;
+	/* out */
+	__s32 dmabuf_fd;
Quoted 8 lines

include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 572

Quoted 4 lines
include/uapi/linux/vfio.h +4 -0
+};
+
+#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15)
+

I thought we had agreed to make this behave similar to VFIO_GROUP_GET_DEVICE_FD, the ioctl would take a __u32 dmabuf_id and return the file descriptor as the ioctl return value. Thanks,

If we follow VFIO_GROUP_GET_DEVICE_FD, we would lose flags functionality. Zhi and Zhenyu, how do you think about it?
Thanks.

BR,
Tina

Quoted 6 lines

Alex
_______________________________________________
intel-gvt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw

Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Hi,

Quoted 8 lines
Quoted 4 lines

I thought we had agreed to make this behave similar to VFIO_GROUP_GET_DEVICE_FD, the ioctl would take a __u32 dmabuf_id and
return the file descriptor as the ioctl return value.  Thanks,

If we follow VFIO_GROUP_GET_DEVICE_FD, we would lose flags functionality.
Zhi and Zhenyu, how do you think about it?

The ioctl is simple enough that not having flags should not be a problem I think.

Also note that dmabuf_id is received using the PLANE_INFO ioctl, so should the need arise to negotiate something in the future chances are high that it can be done using the PLANE_INFO ioctl flags.

cheers,
Gerd

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#11 lore raw

Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Quoted 11 lines · On Mon, 06 Nov 2017 10:05:34 +0100 Gerd Hoffmann <[email protected]> wrote:

Hi,

Quoted 8 lines
Quoted 4 lines

I thought we had agreed to make this behave similar to VFIO_GROUP_GET_DEVICE_FD, the ioctl would take a __u32 dmabuf_id and
return the file descriptor as the ioctl return value.  Thanks,

If we follow VFIO_GROUP_GET_DEVICE_FD, we would lose flags functionality.
Zhi and Zhenyu, how do you think about it?

Quoted 6 lines

The ioctl is simple enough that not having flags should not be a problem I think.

Also note that dmabuf_id is received using the PLANE_INFO ioctl, so should the need arise to negotiate something in the future chances are high that it can be done using the PLANE_INFO ioctl flags.

Right, the ioctl is "get fd for thing" so we have control of "thing". I think we had this same discussion on v15. Thanks,

Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#12 lore raw

RE: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Quoted 30 lines

-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Tuesday, November 7, 2017 4:37 AM
To: Gerd Hoffmann <[email protected]>
Cc: Zhang, Tina <[email protected]>; Tian, Kevin <[email protected]>; Daniel Vetter <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; [email protected]; intel-gvt- [email protected]; Wang, Zhi A <[email protected]>
Subject: Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Quoted 13 lines · On Mon, 06 Nov 2017 10:05:34 +0100 Gerd Hoffmann <[email protected]> wrote:

Hi,

Quoted 7 lines
Quoted 3 lines

I thought we had agreed to make this behave similar to VFIO_GROUP_GET_DEVICE_FD, the ioctl would take a __u32 dmabuf_id and return the file descriptor as the ioctl return value.  Thanks,

If we follow VFIO_GROUP_GET_DEVICE_FD, we would lose flags functionality.
Zhi and Zhenyu, how do you think about it?

The ioctl is simple enough that not having flags should not be a problem I think.

Quoted 6 lines
Quoted 3 lines

Also note that dmabuf_id is received using the PLANE_INFO ioctl, so should the need arise to negotiate something in the future chances are high that it can be done using the PLANE_INFO ioctl flags.

Right, the ioctl is "get fd for thing" so we have control of "thing". I think we had this same discussion on v15. Thanks,

Then, OK. Thanks.

BR,
Tina

Quoted 2 lines

Alex

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#13 lore raw

Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

In reply to Tina Zhang

Hi,

Quoted 16 lines

+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14,
+ *                                    struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and flags, then retrieve the gfx plane info.
+ *
+ * flags supported:
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set
+ *   to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no
+ *   support for dma-buf.
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set

Quoted 8 lines

+ *   to ask if the mdev supports region. 0 on support, -EINVAL on no
+ *   support for region.
+ * - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set
+ *   with each call to query the plane info.
+ * - Others are invalid and return -EINVAL.
+ *
+ * Return: 0 on success, -ENODEV with all out fields zero on mdev
+ * device initialization, -errno on other failure.

Should also not here that it is not an error if the guest has not defined a plane yet. The ioctl should return success in that case and zero-initialize plane info (drm_format + size + width + height fields).

Quoted 10 lines

+ */

include/uapi/linux/vfio.h +8 -0
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0)
+#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1)
+#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: 

DRM_PLANE_TYPE_* */

Add a head field here? People asked @ kvm forum about multihead support. Even if the initial driver version doesn't support it we could add a field so it becomes easier to add it at some point in the future.

Probing for available heads could be done with the PROBE flag, i.e. flags = PROBE | DMABUF, plane_type = PRIMARY, head = 0, 1, ...

include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 543

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 x_hot;    /* horizontal position of cursor hotspot */
+	__u32 y_hot;    /* vertical position of cursor hotspot */

Needs documentation how the driver signals "no hotspot information available" (using 0xffffffff for example).

cheers,
Gerd

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw

RE: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Quoted 45 lines

-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Gerd Hoffmann
Sent: Monday, November 6, 2017 5:01 PM
To: Zhang, Tina <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>; [email protected]; [email protected]
Cc: Daniel Vetter <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Hi,

Quoted 10 lines

+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14,
+ *                                    struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and flags, then retrieve the gfx plane info.
+ *
+ * flags supported:
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF

are

Quoted 5 lines

set
+ *   to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no
+ *   support for dma-buf.
+ * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION

are

Quoted 4 lines

set
+ *   to ask if the mdev supports region. 0 on support, -EINVAL on no
+ *   support for region.
+ * - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION

is set

Quoted 5 lines

+ *   with each call to query the plane info.
+ * - Others are invalid and return -EINVAL.
+ *
+ * Return: 0 on success, -ENODEV with all out fields zero on mdev
+ * device initialization, -errno on other failure.

Quoted 3 lines

Should also not here that it is not an error if the guest has not defined a plane yet. The ioctl should return success in that case and zero-initialize plane info (drm_format + size + width + height fields).

Indeed. I just need to update the comments, as this version is implemented with this in mind. Thanks.

Quoted 16 lines
Quoted 11 lines

+ */

include/uapi/linux/vfio.h +8 -0
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) #define
+VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) #define
+VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
+	/* in */
+	__u32 drm_plane_type;	/* type of plane:

DRM_PLANE_TYPE_* */

Add a head field here? People asked @ kvm forum about multihead support. Even if the initial driver version doesn't support it we could add a field so it becomes easier to add it at some point in the future.

Quoted 2 lines

Probing for available heads could be done with the PROBE flag, i.e. flags = PROBE | DMABUF, plane_type = PRIMARY, head = 0, 1, ...

Does the multihead mean multiple display monitor? So each head can have its own one primary plane, one cursor plane and maybe some sprite planes if supported. And the flow could be like this:
1) flags = PROBE | DMABUF, then return the number of heads in vfio_device_gfx_plane_info.head.
2) flags = DMABUF with plane_type = PRIMARY, head = 0, 1, ..., then return the id of the exposed framebuffer of that head.
Am I correct?

Another question is if the sprite plane is supported, how we're going to identify them, as there could be several sprite planes for one display monitor. Add another field "num_plane" for it? Then, I guess the flow could be like this:
1) flags = PROBE | DMABUF, then return the number of heads in vfio_device_gfx_plane_info.head.
2) flags = PROBE | DMABUF and head = 0, 1, ..., and plane_type = PRIMARY/CURSOR/SPRITE, then return the num_plane.
3) flags = DMABUF with plane_type = PRIMARY, head = 0, 1, ..., num_plane =0, 1, ..., then return the id of the exposed framebuffer of that head. Does it make sense?
Thanks.

Quoted 6 lines

include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 543

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 x_hot;    /* horizontal position of cursor hotspot */
+	__u32 y_hot;    /* vertical position of cursor hotspot */

Needs documentation how the driver signals "no hotspot information available" (using 0xffffffff for example).

This version has implemented this. I will update the comments. Thanks.

BR,
Tina

Quoted 8 lines

cheers,
Gerd

_______________________________________________
intel-gvt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#15 lore raw

Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Hi,

Quoted 6 lines
Quoted 6 lines

Add a head field here?  People asked @ kvm forum about multihead support.
Even if the initial driver version doesn't support it we could add a field so it
becomes easier to add it at some point in the future.

Quoted 6 lines
Quoted 2 lines

Probing for available heads could be done with the PROBE flag, i.e. flags = PROBE | DMABUF, plane_type = PRIMARY, head = 0, 1, ...

Does the multihead mean multiple display monitor? So each head can have its own one primary plane, one cursor plane and maybe some sprite planes if supported.

Yes and yes.

Quoted 3 lines

And the flow could be like this:
1) flags = PROBE | DMABUF, then return the number of heads in vfio_device_gfx_plane_info.head.

I'd suggest to use { .flags = PROBE | DMABUF, .head = 0 } to check whenever dmabuf is supported for head 0, then { .flags = PROBE | DMABUF, .head = 1 } to check for head 1 support, ...

Driver returns success if the head is supported and -EINVAL otherwise, simliar to the dmabuf vs. region probing.

It is less confusing because .head is always an input field then.

It is also a bit more flexible because different heads can support different modes (I don't expect drivers will actually use that though).

Quoted 2 lines

2) flags = DMABUF with plane_type = PRIMARY, head = 0, 1, ..., then return the id of the exposed framebuffer of that head.

Yes.

Quoted 3 lines

Another question is if the sprite plane is supported, how we're going to identify them, as there could be several sprite planes for one display monitor.

Do you mean DRM_PLANE_TYPE_OVERLAY?

Quoted 6 lines

Add another field "num_plane" for it? Then, I guess the flow could be like this:
1) flags = PROBE | DMABUF, then return the number of heads in vfio_device_gfx_plane_info.head.
2) flags = PROBE | DMABUF and head = 0, 1, ..., and plane_type = PRIMARY/CURSOR/SPRITE, then return the num_plane.

I'd suggest to do it simliar to the head probe outlined above, i.e. userspace calls { .flags = PROBE | DMABUF, .head = 0, .plane_type = OVERLAY, plane_num = 0, 1, 2, ... } and the driver returns -EINVAL or 0 depending on whenever it is supported or not.

cheers,
Gerd

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#16 lore raw

Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Quoted 25 lines · On Tue, 07 Nov 2017 09:03:21 +0100 Gerd Hoffmann <[email protected]> wrote:

Hi,

Quoted 6 lines
Quoted 6 lines

Add a head field here?  People asked @ kvm forum about multihead support.
Even if the initial driver version doesn't support it we could add a field so it
becomes easier to add it at some point in the future.

Quoted 6 lines
Quoted 2 lines

Probing for available heads could be done with the PROBE flag, i.e. flags = PROBE | DMABUF, plane_type = PRIMARY, head = 0, 1, ...

Does the multihead mean multiple display monitor? So each head can have its own one primary plane, one cursor plane and maybe some sprite planes if supported.

Yes and yes.

Quoted 3 lines

And the flow could be like this:
1) flags = PROBE | DMABUF, then return the number of heads in vfio_device_gfx_plane_info.head.

I'd suggest to use { .flags = PROBE | DMABUF, .head = 0 } to check whenever dmabuf is supported for head 0, then { .flags = PROBE | DMABUF, .head = 1 } to check for head 1 support, ...

Quoted 7 lines

Driver returns success if the head is supported and -EINVAL otherwise, simliar to the dmabuf vs. region probing.

It is less confusing because .head is always an input field then.

It is also a bit more flexible because different heads can support different modes (I don't expect drivers will actually use that though).

Should we then specify the error code for "head doesn't exist" vs "head doesn't support dmabuf", with the former taking precedence? Perhaps -ENODEV vs -EINVAL. Are the heads guaranteed to be contiguous (the first -ENODEV is the end of possible heads)? Thanks,

Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#17 lore raw

Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Hi,

Quoted 4 lines

Should we then specify the error code for "head doesn't exist" vs "head
doesn't support dmabuf", with the former taking precedence?  Perhaps -ENODEV vs -EINVAL.

NODEV for "head doesn't exist" and INVAL for "head doesn't support dmabuf/region/..." ?

Quoted 2 lines

Are the heads guaranteed to be contiguous (the
first -ENODEV is the end of possible heads)?

Yes, I think the valid heads should be contignous. The guest might still only use a non-contignous subset of the available heads though.

cheers,
Gerd

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#18 lore raw

Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Quoted 9 lines · On Wed, 08 Nov 2017 09:25:49 +0100 Gerd Hoffmann <[email protected]> wrote:

Hi,

Quoted 4 lines

Should we then specify the error code for "head doesn't exist" vs "head
doesn't support dmabuf", with the former taking precedence?  Perhaps -ENODEV vs -EINVAL.

NODEV for "head doesn't exist" and INVAL for "head doesn't support dmabuf/region/..." ?

Yes, exactly.

Quoted 5 lines
Quoted 2 lines

Are the heads guaranteed to be contiguous (the
first -ENODEV is the end of possible heads)?

Yes, I think the valid heads should be contignous. The guest might still only use a non-contignous subset of the available heads though.

Yep, I agree. Thanks,

Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#19 lore raw

RE: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

In reply to Gerd Hoffmann
Quoted 50 lines

-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Gerd Hoffmann
Sent: Tuesday, November 7, 2017 4:03 PM
To: Zhang, Tina <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>; [email protected]; [email protected]
Cc: Daniel Vetter <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation

Hi,

Quoted 11 lines
Quoted 7 lines

Add a head field here?  People asked @ kvm forum about multihead support.
Even if the initial driver version doesn't support it we could add a field so it becomes easier to add it at some point in the future.

Probing for available heads could be done with the PROBE flag, i.e. flags = PROBE | DMABUF, plane_type = PRIMARY, head = 0, 1, ...

Does the multihead mean multiple display monitor? So each head can have its own one primary plane, one cursor plane and maybe some sprite planes if supported.

Yes and yes.

Quoted 3 lines

And the flow could be like this:
1) flags = PROBE | DMABUF, then return the number of heads in vfio_device_gfx_plane_info.head.

I'd suggest to use { .flags = PROBE | DMABUF, .head = 0 } to check whenever dmabuf is supported for head 0, then { .flags = PROBE | DMABUF, .head = 1 } to check for head 1 support, ...

Driver returns success if the head is supported and -EINVAL otherwise, simliar to the dmabuf vs. region probing.

It is less confusing because .head is always an input field then.

It is also a bit more flexible because different heads can support different modes (I don't expect drivers will actually use that though).

Quoted 2 lines

2) flags = DMABUF with plane_type = PRIMARY, head = 0, 1, ..., then return the id of the exposed framebuffer of that head.

Quoted 7 lines

Yes.

Quoted 3 lines

Another question is if the sprite plane is supported, how we're going to identify them, as there could be several sprite planes for one display monitor.

Do you mean DRM_PLANE_TYPE_OVERLAY?

Yes.

Quoted 8 lines
Quoted 7 lines

Add another field "num_plane" for it? Then, I guess the flow could be like this:
1) flags = PROBE | DMABUF, then return the number of heads in vfio_device_gfx_plane_info.head.
2) flags = PROBE | DMABUF and head = 0, 1, ..., and plane_type = PRIMARY/CURSOR/SPRITE, then return the num_plane.

Quoted 4 lines

I'd suggest to do it simliar to the head probe outlined above, i.e. userspace calls { .flags = PROBE | DMABUF, .head = 0, .plane_type = OVERLAY, plane_num = 0, 1, 2, ... } and the driver returns -EINVAL or 0 depending on whenever it is supported or not.

Agree. Thanks.

BR,
Tina

Quoted 8 lines

cheers,
Gerd

_______________________________________________
intel-gvt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#20 lore raw

PATCH v16 6/6 drm/i915/gvt: Dmabuf support for GVT-g

In reply to Tina Zhang

This patch introduces a guest's framebuffer sharing mechanism based on dma-buf subsystem. With this sharing mechanism, guest's framebuffer can be shared between guest VM and host.

v16:
- add x_hot and y_hot. (Gerd)
- add flag validation for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase 4.14.0-rc6.

v15:
- add VFIO_DEVICE_GET_GFX_DMABUF ABI. (Gerd)
- add intel_vgpu_dmabuf_cleanup() to clean up the vGPU's dmabuf. (Gerd)

v14:
- add PROBE, DMABUF and REGION flags. (Alex)

v12:
- refine the lifecycle of dmabuf.

v9:
- remove dma-buf management. (Alex)
- track the dma-buf create and release in kernel mode. (Gerd) (Daniel)

v8:
- refine the dma-buf ioctl definition.(Alex)
- add a lock to protect the dmabuf list. (Alex)

v7:
- release dma-buf related allocations in dma-buf's associated release function. (Alex)
- refine ioctl interface for querying plane info or create dma-buf. (Alex)

v6:
- align the dma-buf life cycle with the vfio device. (Alex)
- add the dma-buf related operations in a separate patch. (Gerd)
- i915 related changes. (Chris)

v5:
- fix bug while checking whether the gem obj is gvt's dma-buf when user change caching mode or domains. Add a helper function to do it. (Xiaoguang)
- add definition for the query plane and create dma-buf. (Xiaoguang)

v4:
- fix bug while checking whether the gem obj is gvt's dma-buf when set caching mode or doamins. (Xiaoguang)

v3:
- declare a new flag I915_GEM_OBJECT_IS_GVT_DMABUF in drm_i915_gem_object to represent the gem obj for gvt's dma-buf. The tiling mode, caching mode and domains can not be changed for this kind of gem object. (Alex)
- change dma-buf related information to be more generic. So other vendor can use the same interface. (Alex)

v2:
- create a management fd for dma-buf operations. (Alex)
- alloc gem object's backing storage in gem obj's get_pages() callback. (Chris)

Cc Alex Williamson <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Gerd Hoffmann <[email protected]>
---
 drivers/gpu/drm/i915/gvt/Makefile      |   2 +-
 drivers/gpu/drm/i915/gvt/dmabuf.c      | 527 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/dmabuf.h      |  67 +++++
 drivers/gpu/drm/i915/gvt/gvt.c         |   2 +
 drivers/gpu/drm/i915/gvt/gvt.h         |  11 +
 drivers/gpu/drm/i915/gvt/hypercall.h   |   2 +
 drivers/gpu/drm/i915/gvt/kvmgt.c       |  60 ++++
 drivers/gpu/drm/i915/gvt/mpt.h         |  30 ++
 drivers/gpu/drm/i915/gvt/vgpu.c        |   5 +-
 drivers/gpu/drm/i915/i915_gem_object.h |   2 +
 10 files changed, 706 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.c
 create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.h
drivers/gpu/drm/i915/gvt/Makefile +1 -1
index 54d70df..cae06c1 100644
@@ -2,7 +2,7 @@ GVT_DIR := gvt
 GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \
 	interrupt.o gtt.o cfg_space.o opregion.o mmio.o display.o edid.o \
 	execlist.o scheduler.o sched_policy.o render.o cmd_parser.o debugfs.o \
-	fb_decoder.o
+	fb_decoder.o dmabuf.o
 
 ccflags-y				+= -I$(src) -I$(src)/$(GVT_DIR)
 i915-y					+= $(addprefix $(GVT_DIR)/, $(GVT_SOURCE))
drivers/gpu/drm/i915/gvt/dmabuf.c new file +527 -0

527 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/dmabuf.h new file +67 -0

67 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/gvt.c +2 -0
index cef06d5..2b050ff 100644
@@ -181,6 +181,8 @@ static const struct intel_gvt_ops intel_gvt_ops = {
 	.vgpu_deactivate = intel_gvt_deactivate_vgpu,
 	.gvt_find_vgpu_type = intel_gvt_find_vgpu_type,
 	.get_gvt_attrs = intel_get_gvt_attrs,
+	.vgpu_query_plane = intel_vgpu_query_plane,
+	.vgpu_get_dmabuf = intel_vgpu_get_dmabuf,
 };
 
 /**
drivers/gpu/drm/i915/gvt/gvt.h +11 -0
index c8e496c..cd1dc9d 100644
@@ -47,6 +47,7 @@
 #include "render.h"
 #include "cmd_parser.h"
 #include "fb_decoder.h"
+#include "dmabuf.h"
 
 #define GVT_MAX_VGPU 8
 
@@ -208,8 +209,16 @@ struct intel_vgpu {
 		struct kvm *kvm;
 		struct work_struct release_work;
 		atomic_t released;
+		struct vfio_device *vfio_device;
 	} vdev;
 #endif
+
+	struct list_head dmabuf_obj_list_head;
+	struct mutex dmabuf_lock;
+	struct idr object_idr;
+
+	struct completion vblank_done;
+
 };
 
 /* validating GM healthy status*/
@@ -543,6 +552,8 @@ struct intel_gvt_ops {
 			const char *name);
 	bool (*get_gvt_attrs)(struct attribute ***type_attrs,
 			struct attribute_group ***intel_vgpu_type_groups);
+	int (*vgpu_query_plane)(struct intel_vgpu *vgpu, void *);
+	int (*vgpu_get_dmabuf)(struct intel_vgpu *vgpu, void *);
 };
 
 
drivers/gpu/drm/i915/gvt/hypercall.h +2 -0
index 32c345c..a1bd82f 100644
@@ -56,6 +56,8 @@ struct intel_gvt_mpt {
 	int (*set_trap_area)(unsigned long handle, u64 start, u64 end,
 			     bool map);
 	int (*set_opregion)(void *vgpu);
+	int (*get_vfio_device)(void *vgpu);
+	void (*put_vfio_device)(void *vgpu);
 };
 
 extern struct intel_gvt_mpt xengt_mpt;
drivers/gpu/drm/i915/gvt/kvmgt.c +60 -0

94 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/mpt.h +30 -0
index c99e796..ca8005a 100644
@@ -309,4 +309,34 @@ static inline int intel_gvt_hypervisor_set_opregion(struct intel_vgpu *vgpu)
 	return intel_gvt_host.mpt->set_opregion(vgpu);
 }
 
+/**
+ * intel_gvt_hypervisor_get_vfio_device - increase vfio device ref count
+ * @vgpu: a vGPU
+ *
+ * Returns:
+ * Zero on success, negative error code if failed.
+ */
+static inline int intel_gvt_hypervisor_get_vfio_device(struct intel_vgpu *vgpu)
+{
+	if (!intel_gvt_host.mpt->get_vfio_device)
+		return 0;
+
+	return intel_gvt_host.mpt->get_vfio_device(vgpu);
+}
+
+/**
+ * intel_gvt_hypervisor_put_vfio_device - decrease vfio device ref count
+ * @vgpu: a vGPU
+ *
+ * Returns:
+ * Zero on success, negative error code if failed.
+ */
+static inline void intel_gvt_hypervisor_put_vfio_device(struct intel_vgpu *vgpu)
+{
+	if (!intel_gvt_host.mpt->put_vfio_device)
+		return;
+
+	intel_gvt_host.mpt->put_vfio_device(vgpu);
+}
+
 #endif /* _GVT_MPT_H_ */
drivers/gpu/drm/i915/gvt/vgpu.c +4 -1
index 42aee6b..b964848 100644
@@ -236,6 +236,7 @@ void intel_gvt_deactivate_vgpu(struct intel_vgpu *vgpu)
 	}
 
 	intel_vgpu_stop_schedule(vgpu);
+	intel_vgpu_dmabuf_cleanup(vgpu);
 
 	mutex_unlock(&gvt->lock);
 }
@@ -265,6 +266,7 @@ void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu)
 	intel_gvt_hypervisor_detach_vgpu(vgpu);
 	intel_vgpu_free_resource(vgpu);
 	intel_vgpu_clean_mmio(vgpu);
+	intel_vgpu_dmabuf_cleanup(vgpu);
 	vfree(vgpu);
 
 	intel_gvt_update_vgpu_types(gvt);
@@ -349,7 +351,8 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
 	vgpu->handle = param->handle;
 	vgpu->gvt = gvt;
 	vgpu->sched_ctl.weight = param->weight;
-
+	INIT_LIST_HEAD(&vgpu->dmabuf_obj_list_head);
+	idr_init(&vgpu->object_idr);
 	intel_vgpu_init_cfg_space(vgpu, param->primary);
 
 	ret = intel_vgpu_init_mmio(vgpu);
drivers/gpu/drm/i915/i915_gem_object.h +2 -0
index 63ce38c..3773155 100644
@@ -260,6 +260,8 @@ struct drm_i915_gem_object {
 		} userptr;
 
 		unsigned long scratch;
+
+		void *gvt_info;
 	};
 
 	/** for phys allocated objects */
Signature · 1 line
2.7.4
#21 lore raw

✗ Fi.CI.BAT: failure for drm/i915/gvt: Dma-buf support for GVT-g

In reply to Tina Zhang
== Series Details ==

== Series Details ==

Series: drm/i915/gvt: Dma-buf support for GVT-g
URL : https://patchwork.freedesktop.org/series/33222/
State : failure

== Summary ==

Series 33222 revision 1 was fully merged or fully failed: no git log

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx