Skip to contentSkip to conversation

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

PATCH Superseded Tina Zhang 7 participants 31 messages Jul 25, 2017 – Aug 22, 2017

Subsystems (5)

v13 of 19 Superseded Latest is v19 →

lore
Share & tools
lore

Tina Zhang

author
#0 lore raw

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

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 [email protected]. (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 releated 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 a uniform mechanism to share DMA buffers across different devices and sub-systems.
dma-buf for intel GVT-g is mainly used to share the vgpu's framebuffer to other users or sub-systems so they can use the dma-buf to show the desktop of a vm which uses intel vgpu.

The main idea is we create a gem object and set vgpu's framebuffer as the backing storage of this gem object. And associate this gem obj to a dma-buf object then export this dma-buf at the meantime generate a file descriptor for this dma-buf. Finally deliver this file descriptor to user space. And user can use this dma-buf fd to do render or other operations.

Tina Zhang (7):
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 support drm/i915/gvt: Add opregion support
vfio: ABI for mdev display dma-buf operation drm/i915: Introduce GEM proxy
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      | 380 ++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/dmabuf.h      |  58 +++++
 drivers/gpu/drm/i915/gvt/fb_decoder.c  | 440 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/fb_decoder.h  | 175 +++++++++++++
 drivers/gpu/drm/i915/gvt/gvt.c         |   1 +
 drivers/gpu/drm/i915/gvt/gvt.h         |  10 +
 drivers/gpu/drm/i915/gvt/hypercall.h   |   3 +
 drivers/gpu/drm/i915/gvt/kvmgt.c       | 151 ++++++++++-
 drivers/gpu/drm/i915/gvt/mpt.h         |  45 ++++
 drivers/gpu/drm/i915/gvt/opregion.c    |  26 +-
 drivers/gpu/drm/i915/gvt/vgpu.c        |   6 +-
 drivers/gpu/drm/i915/i915_gem.c        |  24 +-
 drivers/gpu/drm/i915/i915_gem_object.h |   9 +
 drivers/gpu/drm/i915/i915_gem_tiling.c |   8 +
 include/uapi/drm/drm_fourcc.h          |   4 +
 include/uapi/linux/vfio.h              |  28 +++
 19 files changed, 1362 insertions(+), 13 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 · 6 lines
2.7.4

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

PATCH v13 1/7 drm/i915/gvt: Add framebuffer decoder support

Framebuffer decoder returns guest framebuffer information. Guest framebuffer includes primary, cursor and sprite plane.

---
 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 | 429 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/fb_decoder.h | 175 ++++++++++++++
 drivers/gpu/drm/i915/gvt/gvt.h        |   1 +
 6 files changed, 610 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 f5486cb9..019d596 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
+	execlist.o scheduler.o sched_policy.o render.o cmd_parser.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 2deb05f..58d90cf 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 +429 -0

429 lines not on this page · raw message

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

175 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/gvt.h +1 -0
index ba53ad1..d0fe4d0 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 · 6 lines
2.7.4

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

PATCH v13 2/7 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 windows guest VM. This patch is to introduce the format to drm.

v1:
Suggested by Ville to submit this patch to dri-devel.

---
 include/uapi/drm/drm_fourcc.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/drm/drm_fourcc.h +4 -0
index 7586c46..3e002e3 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 */
+#define DRM_FORMAT_XRGB161616  fourcc_code('X', 'R', '4', '8') /* [63:0] x:R:G:B 16:16:16:16 little endian */
+#define DRM_FORMAT_XBGR161616  fourcc_code('X', 'B', '4', '8') /* [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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

Re: [PATCH v13 2/7] drm: Introduce RGB 64-bit 16:16:16:16 float format

Quoted 17 lines · Tina Zhang

The RGB 64-bit 16:16:16:16 float pixel format is needed by windows guest VM. This patch is to introduce the format to drm.

v1:
Suggested by Ville to submit this patch to dri-devel.

---
 include/uapi/drm/drm_fourcc.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/drm/drm_fourcc.h +0 -0
index 7586c46..3e002e3 100644

include/uapi/drm/drm_fourcc.h extern "C" { · line 118

Quoted 6 lines
include/uapi/drm/drm_fourcc.h +3 -0
@@ -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 */
+#define DRM_FORMAT_XRGB161616  fourcc_code('X', 'R', '4', '8') /* [63:0] x:R:G:B 16:16:16:16 little endian */
+#define DRM_FORMAT_XBGR161616  fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */

I think the comment should go a bit more into detail what the float format is supposed to look like. And I think we should have a F or _FLOAT suffix to the defined name, since the same layout could also work for integers (and some hw somewhere probably has that. Maybe also put that F into the last slot of the fourcc.
-Daniel

Quoted 7 lines
include/uapi/drm/drm_fourcc.h +1 -0
+
 /*
  * 2 plane RGB + A
  * index 0 = RGB plane, same format as the corresponding non _A8 format has
Signature · 1 line
2.7.4
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Re: [PATCH v13 2/7] drm: Introduce RGB 64-bit 16:16:16:16 float format

Quoted 37 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Tuesday, August 15, 2017 10:50 PM
To: Zhang, Tina <[email protected]>
Cc: [email protected]; [email protected]; dri- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tian, Kevin <[email protected]>; Chen, Xiaoguang <[email protected]>
Subject: Re: [PATCH v13 2/7] drm: Introduce RGB 64-bit 16:16:16:16 float format

Quoted 17 lines · Tina Zhang

The RGB 64-bit 16:16:16:16 float pixel format is needed by windows guest VM. This patch is to introduce the format to drm.

v1:
Suggested by Ville to submit this patch to dri-devel.

---
 include/uapi/drm/drm_fourcc.h | 4 ++++
 1 file changed, 4 insertions(+)
(quoted diff) +0 -0

b/include/uapi/drm/drm_fourcc.h index 7586c46..3e002e3 100644

include/uapi/drm/drm_fourcc.h extern "C" { · line 114

Quoted 2 lines
include/uapi/drm/drm_fourcc.h +0 -0
@@ -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 */

Quoted 1 line
Quoted 11 lines

include/uapi/drm/drm_fourcc.h

Quoted 5 lines
include/uapi/drm/drm_fourcc.h +5 -0
+/* 64 bpp RGB */
+#define DRM_FORMAT_XRGB161616  fourcc_code('X', 'R', '4', '8') /*
+[63:0] x:R:G:B 16:16:16:16 little endian */ #define
+DRM_FORMAT_XBGR161616  fourcc_code('X', 'B', '4', '8') /* [63:0]
+x:B:G:R 16:16:16:16 little endian */

I think the comment should go a bit more into detail what the float format is supposed to look like. And I think we should have a F or _FLOAT suffix to the defined name, since the same layout could also work for integers (and some hw somewhere probably has that. Maybe also put that F into the last slot of the fourcc.

Thanks. I prefer to add F and also put F into the last slot of the fourcc. I'm not sure about the code rule. Does it make sense?
#define DRM_FORMAT_XRGB161616F fourcc_code('X', 'R', '3', 'F')
Where '3' stands for the three fields (R, G, B) without Alpha.

BR,
Tina

Quoted 10 lines

-Daniel

Quoted 8 lines

+
/*
* 2 plane RGB + A
* index 0 = RGB plane, same format as the corresponding non _A8
format has
--
2.7.4

Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

#5 lore raw

Re: [PATCH v13 2/7] drm: Introduce RGB 64-bit 16:16:16:16 float format

Quoted 48 lines · Tina
Quoted 37 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Tuesday, August 15, 2017 10:50 PM
To: Zhang, Tina <[email protected]>
Cc: [email protected]; [email protected]; dri- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tian, Kevin <[email protected]>; Chen, Xiaoguang <[email protected]>
Subject: Re: [PATCH v13 2/7] drm: Introduce RGB 64-bit 16:16:16:16 float format

Quoted 17 lines · Tina Zhang

The RGB 64-bit 16:16:16:16 float pixel format is needed by windows guest VM. This patch is to introduce the format to drm.

v1:
Suggested by Ville to submit this patch to dri-devel.

---
 include/uapi/drm/drm_fourcc.h | 4 ++++
 1 file changed, 4 insertions(+)
(quoted diff) +0 -0

b/include/uapi/drm/drm_fourcc.h index 7586c46..3e002e3 100644

include/uapi/drm/drm_fourcc.h extern "C" { · line 114

Quoted 2 lines
include/uapi/drm/drm_fourcc.h +0 -0
@@ -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 */

Quoted 1 line
Quoted 11 lines

include/uapi/drm/drm_fourcc.h

Quoted 5 lines
include/uapi/drm/drm_fourcc.h +5 -0
+/* 64 bpp RGB */
+#define DRM_FORMAT_XRGB161616  fourcc_code('X', 'R', '4', '8') /*
+[63:0] x:R:G:B 16:16:16:16 little endian */ #define
+DRM_FORMAT_XBGR161616  fourcc_code('X', 'B', '4', '8') /* [63:0]
+x:B:G:R 16:16:16:16 little endian */

I think the comment should go a bit more into detail what the float format is supposed to look like. And I think we should have a F or _FLOAT suffix to the defined name, since the same layout could also work for integers (and some hw somewhere probably has that. Maybe also put that F into the last slot of the fourcc.

Quoted 4 lines

Thanks. I prefer to add F and also put F into the last slot of the fourcc. I'm not sure about the code rule. Does it make sense?
#define DRM_FORMAT_XRGB161616F fourcc_code('X', 'R', '3', 'F')
Where '3' stands for the three fields (R, G, B) without Alpha.

Seems reasonable. There's not really any rules for fourcc codes, the only semi-standard ones (and not even those are really standard) are only for video formats. Best we can do is try to be somewhat consistent in drm_fourcc.h.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#6 lore raw

PATCH v13 3/7 drm/i915/gvt: Add RGB 64-bit 16:16:16:16 float format support

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 | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/gvt/fb_decoder.c +11 -0
index 2bd5b3c..739ca81 100644
@@ -54,6 +54,8 @@ static struct pixel_format bdw_pixel_formats[PRIMARY_FORMAT_NUM] = {
 		"32-bit RGBX (2:10:10:10 MSB-X:B:G:R)"},
 	[0xa] = {DRM_FORMAT_XRGB2101010, 32,
 		"32-bit BGRX (2:10:10:10 MSB-X:R:G:B)"},
+	[0xc] = {DRM_FORMAT_XRGB161616, 64,
+		"64-bit RGBX Floating Point(16:16:16:16 MSB-X:B:G:R)"},
 	[0xe] = {DRM_FORMAT_XBGR8888, 32,
 		"32-bit RGBX (8:8:8:8 MSB-X:B:G:R)"},
 };
@@ -75,6 +77,10 @@ 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_XRGB161616, 64,
+		"64-bit XRGB (16:16:16:16 MSB-X:R:G:B)"},
+	{DRM_FORMAT_XBGR161616, 64,
+		"64-bit XBGR (16:16:16:16 MSB-X:B:G:R)"},
 
 	/* non-supported format has bpp default to 0 */
 	{0, 0, NULL},
@@ -101,6 +107,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)
@@ -321,6 +330,8 @@ 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"},
+	[0x3]  = {DRM_FORMAT_XRGB161616, 64,
+		    "RGB 64-bit 16:16:16:16 Floating Point"},
 	[0x4] = {DRM_FORMAT_AYUV, 32,
 		"YUV 32-bit 4:4:4 packed (8:8:8:8 MSB-X:Y:U:V)"},
 };
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#7 lore raw

PATCH v13 4/7 drm/i915/gvt: Add opregion support

In reply to Tina Zhang

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

---
 drivers/gpu/drm/i915/gvt/hypercall.h |   1 +
 drivers/gpu/drm/i915/gvt/kvmgt.c     | 109 ++++++++++++++++++++++++++++++++++-
 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, 146 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 +106 -3

157 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/mpt.h +15 -0
index f0e5487..9e73f2e 100644
@@ -292,4 +292,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 3117991..04c0452 100644
@@ -113,23 +113,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 90c14e6..03f9539 100644
@@ -383,6 +383,10 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
 	if (ret)
 		goto out_clean_shadow_ctx;
 
+	ret = intel_gvt_hypervisor_set_opregion(vgpu);
+	if (ret)
+		goto out_clean_shadow_ctx;
+
 	mutex_unlock(&gvt->lock);
 
 	return vgpu;
Signature · 6 lines
2.7.4

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

PATCH v13 5/7 vfio: ABI for mdev display dma-buf operation

In reply to Tina Zhang

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user mode query and get the plan and its related information.

The dma-buf's life cycle is handled by user mode and tracked by kernel. The returned fd in struct vfio_device_query_gfx_plane can be a new fd or an old fd of a re-exported dma-buf. Host User mode can check the value of fd and to see if it needs to create new resource according to the new fd or just use the existed resource related to the old fd.

---
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/uapi/linux/vfio.h +28 -0
index ae46105..827a230 100644
@@ -502,6 +502,34 @@ 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 retrieve information about the gfx plane.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* 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, upper left corner in pixels */
+	__u32 y_pos;	/* vertical position of cursor plane, upper left corner in lines*/
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */
+};
+
+#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
+
+
 /* -------- API for Type1 VFIO IOMMU -------- */
 
 /**
Signature · 6 lines
2.7.4

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

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

Hi,

Quoted 6 lines

+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14, struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about the gfx plane.

+ *

Quoted 1 line

+ * Return: 0 on success, -errno on failure.

I think this should be more verbose, especially documenting that the "guest driver didn't initialize the display yet" case isn't and error and fields should be set to zero then (as discussed on the list).

Quoted 19 lines

+ */

include/uapi/linux/vfio.h +5 -0
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane:

DRM_PLANE_TYPE_* */

include/uapi/linux/vfio.h +7 -0
+	/* 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*/

(quoted diff) +1 -0
+	__u32 x_pos;	/* horizontal position of cursor plane,

upper left corner in pixels */

(quoted diff) +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane,

upper left corner in lines*/

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

Quoted 3 lines
include/uapi/linux/vfio.h +3 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */
+};

Looks good to me.

Unfortunately I havn't been able to test the whole series yet due to being busy with other stuff, and I'm about to leave for my summer vacation. Will be back online on Aug 21st.

cheers,
Gerd

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

#10 lore raw

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

Quoted 22 lines

-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Gerd Hoffmann
Sent: Friday, July 28, 2017 4:27 PM
To: Zhang, Tina <[email protected]>; [email protected]; intel- [email protected]; [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Tian, Kevin <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Hi,

Quoted 6 lines

+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14, struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about the gfx plane.

Quoted 6 lines

+ *

Quoted 1 line

+ * Return: 0 on success, -errno on failure.

I think this should be more verbose, especially documenting that the "guest driver didn't initialize the display yet" case isn't and error and fields should be set to zero then (as discussed on the list).

I can add this in the next version.
Thanks.

Tina

Quoted 26 lines
Quoted 20 lines

+ */

include/uapi/linux/vfio.h +5 -0
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane:

DRM_PLANE_TYPE_* */

include/uapi/linux/vfio.h +7 -0
+	/* 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*/

(quoted diff) +1 -0
+	__u32 x_pos;	/* horizontal position of cursor plane,

upper left corner in pixels */

(quoted diff) +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane,

upper left corner in lines*/

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

Quoted 3 lines
include/uapi/linux/vfio.h +3 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */
+};

Looks good to me.

Quoted 3 lines

Unfortunately I havn't been able to test the whole series yet due to being busy with other stuff, and I'm about to leave for my summer vacation. Will be back online on Aug 21st.

Fine to me. I will also update our qemu sample code and some wiki according to the current interface in the next version, which may give you some help for your test.
Thanks.

Tina

Quoted 9 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

#11 lore raw

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

In reply to Tina Zhang
Quoted 35 lines · On Tue, 25 Jul 2017 17:28:18 +0800 Tina Zhang <[email protected]> wrote:

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user mode query and get the plan and its related information.

The dma-buf's life cycle is handled by user mode and tracked by kernel. The returned fd in struct vfio_device_query_gfx_plane can be a new fd or an old fd of a re-exported dma-buf. Host User mode can check the value of fd and to see if it needs to create new resource according to the new fd or just use the existed resource related to the old fd.

---
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/uapi/linux/vfio.h +13 -0
index ae46105..827a230 100644
@@ -502,6 +502,34 @@ 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 retrieve information about the gfx plane.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_* */
+	/* out */

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

Quoted 10 lines
include/uapi/linux/vfio.h +10 -0
+	__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, upper left corner in pixels */
+	__u32 y_pos;	/* vertical position of cursor plane, upper left corner in lines*/
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating those resources yet?

Kirti, does this otherwise meet your needs?

Thanks,
Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw

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

Quoted 55 lines · Alex Williamson
Quoted 35 lines · On Tue, 25 Jul 2017 17:28:18 +0800 Tina Zhang <[email protected]> wrote:

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user mode query and get the plan and its related information.

The dma-buf's life cycle is handled by user mode and tracked by kernel. The returned fd in struct vfio_device_query_gfx_plane can be a new fd or an old fd of a re-exported dma-buf. Host User mode can check the value of fd and to see if it needs to create new resource according to the new fd or just use the existed resource related to the old fd.

---
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/uapi/linux/vfio.h +13 -0
index ae46105..827a230 100644
@@ -502,6 +502,34 @@ 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 retrieve information about the gfx plane.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_* */
+	/* out */

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

Quoted 10 lines
include/uapi/linux/vfio.h +10 -0
+	__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, upper left corner in pixels */
+	__u32 y_pos;	/* vertical position of cursor plane, upper left corner in lines*/
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating those resources yet?

Quoted 2 lines

Kirti, does this otherwise meet your needs?

I wanted to test my change with this interface, but I couldn't, was busy with other stuff.
This structure looks good to me for region type support.

Quoted 2 lines

What are the errno values to differentiate
unsupported vs not initialized?

In previous version discussion, we decided that vendor driver should set all members to 0 in such cases. Mainly, if size is 0 then there is nothing to copy.

Thanks,
Kirti

Quoted 3 lines

Thanks,
Alex

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

#13 lore raw

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

In reply to Alex Williamson
Quoted 63 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Wednesday, August 2, 2017 5:18 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; intel- [email protected]; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; intel-gvt- [email protected]; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 19 lines · On Tue, 25 Jul 2017 17:28:18 +0800 Tina Zhang <[email protected]> wrote:

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user mode query and get the plan and its related information.

The dma-buf's life cycle is handled by user mode and tracked by kernel. The returned fd in struct vfio_device_query_gfx_plane can be a new fd or an old fd of a re-exported dma-buf. Host User mode can check the value of fd and to see if it needs to create new resource according to the new fd or just use the existed resource related to the old fd.

---
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/uapi/linux/vfio.h +0 -0
index ae46105..827a230 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,34 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE +

13)

Quoted 12 lines
include/uapi/linux/vfio.h +11 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14,
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about the gfx plane.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;

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

Quoted 10 lines
include/uapi/linux/vfio.h +10 -0
+	/* 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, upper left corner

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left corner in

lines*/

Quoted 7 lines

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating those resources yet?

Dma-buf won't use region_index, which means region_index is zero all the time for dma-buf usage. As we discussed, there won't be errno if not initialized, just keep all fields zero. I will add the comments about these in the next version. Thanks

Tina

Quoted 9 lines

Kirti, does this otherwise meet your needs?

Thanks,
Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#14 lore raw

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

Quoted 68 lines · Tina
Quoted 61 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Wednesday, August 2, 2017 5:18 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; intel- [email protected]; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; intel-gvt- [email protected]; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 19 lines · On Tue, 25 Jul 2017 17:28:18 +0800 Tina Zhang <[email protected]> wrote:

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user mode query and get the plan and its related information.

The dma-buf's life cycle is handled by user mode and tracked by kernel. The returned fd in struct vfio_device_query_gfx_plane can be a new fd or an old fd of a re-exported dma-buf. Host User mode can check the value of fd and to see if it needs to create new resource according to the new fd or just use the existed resource related to the old fd.

---
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/uapi/linux/vfio.h +0 -0
index ae46105..827a230 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,34 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE +  

13)

Quoted 12 lines
include/uapi/linux/vfio.h +11 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14,
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about the gfx plane.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;

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

Quoted 10 lines
include/uapi/linux/vfio.h +10 -0
+	/* 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, upper left corner  

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left corner in  

lines*/

Quoted 7 lines

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */  

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating those resources yet?

Quoted 3 lines

Dma-buf won't use region_index, which means region_index is zero all the time for dma-buf usage. As we discussed, there won't be errno if not initialized, just keep all fields zero. I will add the comments about these in the next version. Thanks

Zero is a valid region index.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

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

Quoted 86 lines

-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Thursday, August 3, 2017 11:38 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 15 lines · Tina
Quoted 15 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Wednesday, August 2, 2017 5:18 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; intel- [email protected]; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; intel-gvt- [email protected]; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

On Tue, 25 Jul 2017 17:28:18 +0800
Tina Zhang <[email protected]> wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user mode query and get the plan and its related information.

The dma-buf's life cycle is handled by user mode and tracked by kernel. The returned fd in struct vfio_device_query_gfx_plane can be a new fd or an old fd of a re-exported dma-buf. Host User mode can check the value of fd and to see if it needs to create new resource according to the new fd or just use the existed resource related to the old

fd.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
---
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/uapi/linux/vfio.h +0 -0
index ae46105..827a230 100644
@@ -502,6 +502,34 @@ struct vfio_pci_hot_reset {
 
Quoted 5 lines
Quoted 5 lines

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

Quoted 1 line
include/uapi/linux/vfio.h +0 -0
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE +

13)

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE +

14,

Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
include/uapi/linux/vfio.h +9 -0
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about the gfx plane.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;

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

Quoted 10 lines
include/uapi/linux/vfio.h +10 -0
+	/* 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, upper left corner

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left corner in

lines*/

Quoted 7 lines
Quoted 7 lines

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating

Quoted 7 lines

those resources yet?

Quoted 1 line

Dma-buf won't use region_index, which means region_index is zero all the

time for dma-buf usage.

Quoted 2 lines

As we discussed, there won't be errno if not initialized, just keep all fields zero. I will add the comments about these in the next version. Thanks

Zero is a valid region index.

If zero is valid, can we find out other invalid value? How about 0xffffffff?

Tina
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#16 lore raw

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

Quoted 84 lines · Tina
Quoted 84 lines

-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Thursday, August 3, 2017 11:38 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 15 lines · Tina
Quoted 15 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Wednesday, August 2, 2017 5:18 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; intel- [email protected]; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; intel-gvt- [email protected]; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

On Tue, 25 Jul 2017 17:28:18 +0800
Tina Zhang <[email protected]> wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user mode query and get the plan and its related information.

The dma-buf's life cycle is handled by user mode and tracked by kernel. The returned fd in struct vfio_device_query_gfx_plane can be a new fd or an old fd of a re-exported dma-buf. Host User mode can check the value of fd and to see if it needs to create new resource according to the new fd or just use the existed resource related to the old

fd.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
---
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/uapi/linux/vfio.h +0 -0
index ae46105..827a230 100644
@@ -502,6 +502,34 @@ struct vfio_pci_hot_reset {
 
Quoted 5 lines
Quoted 5 lines

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

Quoted 1 line
include/uapi/linux/vfio.h +0 -0
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE +  

13)

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE +  

14,

Quoted 29 lines
Quoted 29 lines
Quoted 9 lines
include/uapi/linux/vfio.h +9 -0
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about the gfx plane.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;

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

Quoted 10 lines
include/uapi/linux/vfio.h +10 -0
+	/* 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, upper left corner  

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left corner in  

lines*/

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */  

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating

Quoted 8 lines
Quoted 7 lines

those resources yet?

Quoted 1 line

Dma-buf won't use region_index, which means region_index is zero all the

time for dma-buf usage.

Quoted 2 lines

As we discussed, there won't be errno if not initialized, just keep all fields zero. I will add the comments about these in the next version. Thanks

Zero is a valid region index.

If zero is valid, can we find out other invalid value? How about 0xffffffff?

Unlikely, but also valid. Isn't this why we have a flags field in the structure, so we don't need to rely on implicit values as invalid. Also, all of the previously discussed usage models needs to be documented, either here in the header or in a Documentation/ file. Thanks,

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#17 lore raw

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

Quoted 119 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Thursday, August 3, 2017 10:43 PM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 28 lines · Tina
Quoted 28 lines

-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Thursday, August 3, 2017 11:38 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 13 lines · Tina
Quoted 13 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Wednesday, August 2, 2017 5:18 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; intel- [email protected]; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; intel-gvt- [email protected]; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · On Tue, 25 Jul 2017 17:28:18 +0800 Tina Zhang <[email protected]> wrote:

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user

mode

Quoted 21 lines
Quoted 21 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

query and get the plan and its related information.

The dma-buf's life cycle is handled by user mode and tracked by kernel. The returned fd in struct vfio_device_query_gfx_plane can be a new fd or an old fd of a re-exported dma-buf. Host User mode can check the value of fd and to see if it needs to create new resource according to the new fd or just use the existed resource related to the old

fd.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
---
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
(quoted diff) +0 -0

b/include/uapi/linux/vfio.h index ae46105..827a230 100644

include/uapi/linux/vfio.h +0 -0
@@ -502,6 +502,34 @@ struct vfio_pci_hot_reset {
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

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

Quoted 1 line
include/uapi/linux/vfio.h +0 -0
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE +

13)

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE

+

Quoted 4 lines
Quoted 4 lines

14,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/uapi/linux/vfio.h +3 -0
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about the gfx

plane.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_*

*/

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+	/* 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, upper

left corner

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left

corner in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

lines*/

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating

Quoted 5 lines
Quoted 5 lines

those resources yet?

Quoted 2 lines

Dma-buf won't use region_index, which means region_index is zero all the

time for dma-buf usage.

Quoted 1 line

As we discussed, there won't be errno if not initialized, just keep all fields

zero.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

I will add the comments about these in the next version. Thanks

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Zero is a valid region index.

If zero is valid, can we find out other invalid value? How about 0xffffffff?

Unlikely, but also valid. Isn't this why we have a flags field in the structure, so we don't need to rely on implicit values as invalid.
Also, all of the previously discussed usage models needs to be documented, either here in the header or in a Documentation/ file.

According to the previously discussion, we also have the following propose:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

struct vfio_device_gfx_query_caps {
        __u32 argsz;
        __u32 flags;
        enum vfio_device_gfx_type;
};

So, we may need to add one more ioctl, e.g. VFIO_DEVICE_QUERY_GFX_CAPS. User mode can query this before querying the plan info, and to see which usage (dma-buf or region) is supported.
Does it still make sense?
Thanks.

Tina

Quoted 7 lines

Thanks,

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

#18 lore raw

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

In reply to Alex Williamson

After going through the previous discussions, here are some summaries may be related to the current discussion:
1. How does user mode figure the device capabilities between region and dma-buf? VFIO_DEVICE_GET_REGION_INFO could tell if the mdev supports region case.
Otherwise, the mdev supports dma-buf.

2. For dma-buf, how to differentiate unsupported vs not initialized?
For dma-buf, when the mdev doesn't support some arguments, -EINVAL will be returned. And -errno will return when meeting other failures, like -ENOMEM. If the mdev is not initialized, there won't be any returned err. Just zero all the fields in structure vfio_device_gfx_plane_info.

3. The id field in structure vfio_device_gfx_plane_info
So far we haven't figured out the usage of this field for dma-buf usage. So, this field is changed to "region_index" and only used for region usage. In previous discussions, we thought this "id" field might be used for both dma-buf and region usages.
So, we proposed some ways, like adding flags field to the structure. Another way to do it was to add this:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

 struct vfio_device_gfx_query_caps {
         __u32 argsz;
         __u32 flags;
         enum vfio_device_gfx_type;

};
Obviously, we don't need to consider this again, unless we find the "region_index" means something for dma-buf usage.

Thanks.

BR,
Tina

Quoted 156 lines

-----Original Message-----
From: Zhang, Tina
Sent: Monday, August 7, 2017 11:23 AM
To: 'Alex Williamson' <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: RE: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 45 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Thursday, August 3, 2017 10:43 PM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 29 lines · Tina
Quoted 29 lines

-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Thursday, August 3, 2017 11:38 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 14 lines · Tina
Quoted 14 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]]
On Behalf Of Alex Williamson
Sent: Wednesday, August 2, 2017 5:18 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; intel- [email protected]; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; intel-gvt- [email protected]; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · On Tue, 25 Jul 2017 17:28:18 +0800 Tina Zhang <[email protected]> wrote:

Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user

mode

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

query and get the plan and its related information.

The dma-buf's life cycle is handled by user mode and tracked by

kernel.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The returned fd in struct vfio_device_query_gfx_plane can be a new fd or an old fd of a re-exported dma-buf. Host User mode can check the value of fd and to see if it needs to create new resource according to the new fd or just use the existed resource related to the old

fd.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

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

Quoted 7 lines
(quoted diff) +0 -0

b/include/uapi/linux/vfio.h index ae46105..827a230 100644

include/uapi/linux/vfio.h +0 -0
@@ -502,6 +502,34 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE,

VFIO_BASE +

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

13)

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE,

VFIO_BASE

Quoted 46 lines

+

Quoted 5 lines
Quoted 5 lines

14,

Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
include/uapi/linux/vfio.h +4 -0
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about
+the gfx

plane.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_*

*/

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+	/* 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, upper

left corner

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left

corner in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

lines*/

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating

Quoted 6 lines
Quoted 6 lines

those resources yet?

Quoted 2 lines

Dma-buf won't use region_index, which means region_index is zero all the

time for dma-buf usage.

Quoted 2 lines

As we discussed, there won't be errno if not initialized, just keep all fields

zero.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

I will add the comments about these in the next version. Thanks

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Zero is a valid region index.

If zero is valid, can we find out other invalid value? How about 0xffffffff?

Unlikely, but also valid. Isn't this why we have a flags field in the structure, so we don't need to rely on implicit values as invalid. Also, all of the previously discussed usage models needs to be documented, either here in the header or in a Documentation/ file.

According to the previously discussion, we also have the following propose:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

struct vfio_device_gfx_query_caps {
        __u32 argsz;
        __u32 flags;
        enum vfio_device_gfx_type;
};
Quoted 5 lines

So, we may need to add one more ioctl, e.g. VFIO_DEVICE_QUERY_GFX_CAPS. User mode can query this before querying the plan info, and to see which usage (dma-buf or region) is supported.
Does it still make sense?
Thanks.

So, I think we can rely on VFIO_DEVICE_GET_REGION_INFO to tell user mode whether the region case is using, instead of introducing a new ioctl. Thanks

Tina

Quoted 11 lines

Tina

Quoted 7 lines

Thanks,

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#19 lore raw

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

Quoted 4 lines · Tina

After going through the previous discussions, here are some summaries may be related to the current discussion:
1. How does user mode figure the device capabilities between region and dma-buf? VFIO_DEVICE_GET_REGION_INFO could tell if the mdev supports region case.
Otherwise, the mdev supports dma-buf.

Why do we need to make this assumption? What happens when dma-buf is superseded? What happens if a device supports both dma-buf and regions? We have a flags field in vfio_device_gfx_plane_info, doesn't it make sense to use it to identify which field, between region_index and fd, is valid? We could even put region_index and fd into a union with the flag bits indicating how to interpret the union, but I'm not sure everyone was onboard with this idea. Seems like a waste of 4 bytes not to do that though.

Thinking further, is the user ever in a situation where they query the graphics plane info and can handle either a dma-buf or a region? It seems more likely that the user needs to know early on which is supported and would then require that they continue to see compatible plane information... Should the user then be able to specify whether they want a dma-buf or a region? Perhaps these flag bits are actually input and the return should be -errno if the driver cannot produce something compatible.

Maybe we'd therefore define 3 flag bits: PROBE, DMABUF, REGION. In this initial implementation, DMABUF or REGION would always be set by the user to request that type of interface. Additionally, the QUERY bit could be set to probe compatibility, thus if PROBE and REGION are set, the vendor driver would return success only if it supports the region based interface. If PROBE and DMABUF are set, the vendor driver returns success only if the dma-buf based interface is supported. The value of the remainder of the structure is undefined for PROBE. Additionally setting both DMABUF and REGION is invalid. Undefined flags bits must be validated as zero by the drivers for future use (thus if we later define DMABUFv2, an older driver should automatically return -errno when probed or requested).

It seems like this handles all the cases, the user can ask what's supported and specifies the interface they want on every call. The user therefore can also choose between region_index and fd and we can make that a union.

Quoted 3 lines

2. For dma-buf, how to differentiate unsupported vs not initialized?
For dma-buf, when the mdev doesn't support some arguments, -EINVAL will be returned. And -errno will return when meeting other failures, like -ENOMEM. If the mdev is not initialized, there won't be any returned err. Just zero all the fields in structure vfio_device_gfx_plane_info.

So we're relying on special values again :-\ For which fields is zero not a valid value? I prefer the probe interface above unless there are better ideas.

Quoted 10 lines

3. The id field in structure vfio_device_gfx_plane_info
So far we haven't figured out the usage of this field for dma-buf usage. So, this field is changed to "region_index" and only used for region usage. In previous discussions, we thought this "id" field might be used for both dma-buf and region usages.
So, we proposed some ways, like adding flags field to the structure. Another way to do it was to add this:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

Quoted 6 lines
 struct vfio_device_gfx_query_caps {
         __u32 argsz;
         __u32 flags;
         enum vfio_device_gfx_type;

};
Obviously, we don't need to consider this again, unless we find the "region_index" means something for dma-buf usage.

The usefulness of this ioctl seems really limited and once again we get into a situation where having two ioctls leaves doubt whether this is describing the current plane state. Thanks,

Alex

Quoted 86 lines
Quoted 81 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

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

Quoted 10 lines
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
(quoted diff) +0 -0

b/include/uapi/linux/vfio.h index ae46105..827a230 100644

include/uapi/linux/vfio.h +0 -0
@@ -502,6 +502,34 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE,  

VFIO_BASE +

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

13)

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE,  

VFIO_BASE

Quoted 46 lines

+

Quoted 5 lines
Quoted 5 lines

14,

Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
include/uapi/linux/vfio.h +4 -0
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about
+the gfx  

plane.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_*  

*/

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+	/* 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, upper  

left corner

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left  

corner in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

lines*/

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */  

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating

Quoted 6 lines
Quoted 6 lines

those resources yet?

Quoted 2 lines

Dma-buf won't use region_index, which means region_index is zero all the

time for dma-buf usage.

Quoted 2 lines

As we discussed, there won't be errno if not initialized, just keep all fields

zero.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

I will add the comments about these in the next version. Thanks

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Zero is a valid region index.

If zero is valid, can we find out other invalid value? How about 0xffffffff?

Unlikely, but also valid. Isn't this why we have a flags field in the structure, so we don't need to rely on implicit values as invalid. Also, all of the previously discussed usage models needs to be documented, either here in the header or in a Documentation/ file.

According to the previously discussion, we also have the following propose:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

struct vfio_device_gfx_query_caps {
        __u32 argsz;
        __u32 flags;
        enum vfio_device_gfx_type;
};
Quoted 5 lines

So, we may need to add one more ioctl, e.g. VFIO_DEVICE_QUERY_GFX_CAPS. User mode can query this before querying the plan info, and to see which usage (dma-buf or region) is supported.
Does it still make sense?
Thanks.

Quoted 15 lines

So, I think we can rely on VFIO_DEVICE_GET_REGION_INFO to tell user mode whether the region case is using, instead of introducing a new ioctl. Thanks

Tina

Quoted 11 lines

Tina

Quoted 7 lines

Thanks,

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#20 lore raw

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

Quoted 9 lines · Alex Williamson
Quoted 4 lines · Tina

After going through the previous discussions, here are some summaries may be related to the current discussion:
1. How does user mode figure the device capabilities between region and dma-buf? VFIO_DEVICE_GET_REGION_INFO could tell if the mdev supports region case.
Otherwise, the mdev supports dma-buf.

Why do we need to make this assumption?

Right, we should not make such assumption. Vendor driver might not support both or disable console vnc ( for example, for performance testing console VNC need to be disabled)

Quoted 9 lines

What happens when dma-buf is
superseded? What happens if a device supports both dma-buf and regions? We have a flags field in vfio_device_gfx_plane_info, doesn't it make sense to use it to identify which field, between region_index and fd, is valid? We could even put region_index and fd into a union with the flag bits indicating how to interpret the union, but I'm not sure everyone was onboard with this idea. Seems like a waste of 4 bytes not to do that though.

Agree.

Quoted 9 lines

Thinking further, is the user ever in a situation where they query the graphics plane info and can handle either a dma-buf or a region? It seems more likely that the user needs to know early on which is supported and would then require that they continue to see compatible plane information... Should the user then be able to specify whether they want a dma-buf or a region? Perhaps these flag bits are actually input and the return should be -errno if the driver cannot produce something compatible.

Quoted 13 lines

Maybe we'd therefore define 3 flag bits: PROBE, DMABUF, REGION. In this initial implementation, DMABUF or REGION would always be set by the user to request that type of interface. Additionally, the QUERY bit could be set to probe compatibility, thus if PROBE and REGION are set, the vendor driver would return success only if it supports the region based interface. If PROBE and DMABUF are set, the vendor driver returns success only if the dma-buf based interface is supported. The value of the remainder of the structure is undefined for PROBE. Additionally setting both DMABUF and REGION is invalid. Undefined flags bits must be validated as zero by the drivers for future use (thus if we later define DMABUFv2, an older driver should automatically return -errno when probed or requested).

Are you saying all of this to be part of VFIO_DEVICE_QUERY_GFX_PLANE ioctl?

Let me summarize what we need, taking QEMU as reference:
1. From vfio_initfn(), for REGION case, get region info:
vfio_get_dev_region_info(.., VFIO_REGION_SUBTYPE_CONSOLE_REGION, &vdev->console_opregion)

If above return success, setup console REGION and mmap. I don't know what is required for DMABUF at this moment.

If console VNC is supported either DMABUF or REGION, initialize console and register its callback operations:

static const GraphicHwOps vfio_console_ops = {
.gfx_update = vfio_console_update_display,
};

vdev->console = graphic_console_init(DEVICE(vdev), 0, &vfio_console_ops, vdev);

2. On above console registration, vfio_console_update_display() gets called for each refresh cycle of console. In that:
- call ioctl(VFIO_DEVICE_QUERY_GFX_PLANE)
- if (queried size > 0), update QEMU console surface (for REGION case read mmaped region, for DMABUF read surface using fd)

Alex, in your proposal above, my understanding is ioctl(VFIO_DEVICE_QUERY_GFX_PLANE) with PROBE flag should be called in step #1.
In step #2, ioctl(VFIO_DEVICE_QUERY_GFX_PLANE) will be without PROBE flag, but either DMABUF or REGION flag based on what is returned as supported by vendor driver in step #1. Is that correct?

Quoted 5 lines

It seems like this handles all the cases, the user can ask what's supported and specifies the interface they want on every call. The user therefore can also choose between region_index and fd and we can make that a union.

Quoted 8 lines
Quoted 3 lines

2. For dma-buf, how to differentiate unsupported vs not initialized?
For dma-buf, when the mdev doesn't support some arguments, -EINVAL will be returned. And -errno will return when meeting other failures, like -ENOMEM. If the mdev is not initialized, there won't be any returned err. Just zero all the fields in structure vfio_device_gfx_plane_info.

So we're relying on special values again :-\ For which fields is zero not a valid value? I prefer the probe interface above unless there are better ideas.

PROBE will be called during vdev initialization and after that vfio_console_update_display() gets called at every console refresh cycle. But until driver in guest is loaded, mmaped buffer/ DMABUF will not be populated with correct surface data. In that case for QUERY, vendor driver should return (atleast) size=0 which means there is nothing to copy. Once guest driver is loaded and surface is created by guest driver, QUERY interface should return valid size.

Thanks,
Kirti

Quoted 17 lines
Quoted 10 lines

3. The id field in structure vfio_device_gfx_plane_info
So far we haven't figured out the usage of this field for dma-buf usage. So, this field is changed to "region_index" and only used for region usage. In previous discussions, we thought this "id" field might be used for both dma-buf and region usages.
So, we proposed some ways, like adding flags field to the structure. Another way to do it was to add this:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

Quoted 6 lines
 struct vfio_device_gfx_query_caps {
         __u32 argsz;
         __u32 flags;
         enum vfio_device_gfx_type;

};
Obviously, we don't need to consider this again, unless we find the "region_index" means something for dma-buf usage.

Quoted 108 lines

The usefulness of this ioctl seems really limited and once again we get into a situation where having two ioctls leaves doubt whether this is describing the current plane state. Thanks,

Alex

Quoted 101 lines
Quoted 81 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

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

Quoted 10 lines
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
(quoted diff) +0 -0

b/include/uapi/linux/vfio.h index ae46105..827a230 100644

include/uapi/linux/vfio.h +0 -0
@@ -502,6 +502,34 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE,  

VFIO_BASE +

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

13)

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE,  

VFIO_BASE

Quoted 46 lines

+

Quoted 5 lines
Quoted 5 lines

14,

Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
include/uapi/linux/vfio.h +4 -0
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about
+the gfx  

plane.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_*  

*/

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+	/* 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, upper  

left corner

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left  

corner in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

lines*/

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */  

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating

Quoted 6 lines
Quoted 6 lines

those resources yet?

Quoted 2 lines

Dma-buf won't use region_index, which means region_index is zero all the

time for dma-buf usage.

Quoted 2 lines

As we discussed, there won't be errno if not initialized, just keep all fields

zero.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

I will add the comments about these in the next version. Thanks

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Zero is a valid region index.

If zero is valid, can we find out other invalid value? How about 0xffffffff?

Unlikely, but also valid. Isn't this why we have a flags field in the structure, so we don't need to rely on implicit values as invalid. Also, all of the previously discussed usage models needs to be documented, either here in the header or in a Documentation/ file.

According to the previously discussion, we also have the following propose:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

struct vfio_device_gfx_query_caps {
        __u32 argsz;
        __u32 flags;
        enum vfio_device_gfx_type;
};
Quoted 5 lines

So, we may need to add one more ioctl, e.g. VFIO_DEVICE_QUERY_GFX_CAPS. User mode can query this before querying the plan info, and to see which usage (dma-buf or region) is supported.
Does it still make sense?
Thanks.

So, I think we can rely on VFIO_DEVICE_GET_REGION_INFO to tell user mode whether the region case is using, instead of introducing a new ioctl. Thanks

Tina

Quoted 11 lines

Tina

Quoted 7 lines

Thanks,

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

#21 lore raw

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

Quoted 63 lines · On Tue, 8 Aug 2017 14:18:07 +0530 Kirti Wankhede <[email protected]> wrote:
Quoted 9 lines · Alex Williamson
Quoted 4 lines · Tina

After going through the previous discussions, here are some summaries may be related to the current discussion:
1. How does user mode figure the device capabilities between region and dma-buf? VFIO_DEVICE_GET_REGION_INFO could tell if the mdev supports region case.
Otherwise, the mdev supports dma-buf.

Why do we need to make this assumption?

Right, we should not make such assumption. Vendor driver might not support both or disable console vnc ( for example, for performance testing console VNC need to be disabled)

Quoted 9 lines

What happens when dma-buf is
superseded? What happens if a device supports both dma-buf and regions? We have a flags field in vfio_device_gfx_plane_info, doesn't it make sense to use it to identify which field, between region_index and fd, is valid? We could even put region_index and fd into a union with the flag bits indicating how to interpret the union, but I'm not sure everyone was onboard with this idea. Seems like a waste of 4 bytes not to do that though.

Agree.

Quoted 9 lines

Thinking further, is the user ever in a situation where they query the graphics plane info and can handle either a dma-buf or a region? It seems more likely that the user needs to know early on which is supported and would then require that they continue to see compatible plane information... Should the user then be able to specify whether they want a dma-buf or a region? Perhaps these flag bits are actually input and the return should be -errno if the driver cannot produce something compatible.

Quoted 13 lines

Maybe we'd therefore define 3 flag bits: PROBE, DMABUF, REGION. In this initial implementation, DMABUF or REGION would always be set by the user to request that type of interface. Additionally, the QUERY bit could be set to probe compatibility, thus if PROBE and REGION are set, the vendor driver would return success only if it supports the region based interface. If PROBE and DMABUF are set, the vendor driver returns success only if the dma-buf based interface is supported. The value of the remainder of the structure is undefined for PROBE. Additionally setting both DMABUF and REGION is invalid. Undefined flags bits must be validated as zero by the drivers for future use (thus if we later define DMABUFv2, an older driver should automatically return -errno when probed or requested).

Are you saying all of this to be part of VFIO_DEVICE_QUERY_GFX_PLANE ioctl?

Let me summarize what we need, taking QEMU as reference:
1. From vfio_initfn(), for REGION case, get region info:
vfio_get_dev_region_info(.., VFIO_REGION_SUBTYPE_CONSOLE_REGION, &vdev->console_opregion)

If above return success, setup console REGION and mmap. I don't know what is required for DMABUF at this moment.

If console VNC is supported either DMABUF or REGION, initialize console and register its callback operations:

Quoted 6 lines

static const GraphicHwOps vfio_console_ops = {
.gfx_update = vfio_console_update_display,
};

vdev->console = graphic_console_init(DEVICE(vdev), 0, &vfio_console_ops, vdev);

I might structure it that vfio_initfn() would call ioctl(VFIO_DEVICE_QUERY_GFX_PLANE) with the PROBE bit set with either DMABUF or REGION set as the interface type in the flags field. If REGION is the probed interface and success is returned, then QEMU might go look for regions of the appropriate type, however the vfio_device_gfx_plane_info structure is canonical source for the region index, so QEMU would probably be wise to use that and only use the region type for consistency testing.

Quoted 5 lines

2. On above console registration, vfio_console_update_display() gets called for each refresh cycle of console. In that:
- call ioctl(VFIO_DEVICE_QUERY_GFX_PLANE)
- if (queried size > 0), update QEMU console surface (for REGION case read mmaped region, for DMABUF read surface using fd)

The ioctl would be called with REGION or DMABUF based on the initial probe call, ex. we probed that REGION is supported and now we continue to ask for region based updates. QEMU would need to verify the region index matches that already mapped, remapping a different region if necessary, and interpret the graphics parameters to provide the screen update.

Quoted 6 lines

Alex, in your proposal above, my understanding is ioctl(VFIO_DEVICE_QUERY_GFX_PLANE) with PROBE flag should be called in step #1.
In step #2, ioctl(VFIO_DEVICE_QUERY_GFX_PLANE) will be without PROBE flag, but either DMABUF or REGION flag based on what is returned as supported by vendor driver in step #1. Is that correct?

Yes, that's the idea. Does it make sense/provide value?

Quoted 14 lines
Quoted 5 lines

It seems like this handles all the cases, the user can ask what's supported and specifies the interface they want on every call. The user therefore can also choose between region_index and fd and we can make that a union.

Quoted 8 lines
Quoted 3 lines

2. For dma-buf, how to differentiate unsupported vs not initialized?
For dma-buf, when the mdev doesn't support some arguments, -EINVAL will be returned. And -errno will return when meeting other failures, like -ENOMEM. If the mdev is not initialized, there won't be any returned err. Just zero all the fields in structure vfio_device_gfx_plane_info.

So we're relying on special values again :-\ For which fields is zero not a valid value? I prefer the probe interface above unless there are better ideas.

Quoted 7 lines

PROBE will be called during vdev initialization and after that vfio_console_update_display() gets called at every console refresh cycle. But until driver in guest is loaded, mmaped buffer/ DMABUF will not be populated with correct surface data. In that case for QUERY, vendor driver should return (atleast) size=0 which means there is nothing to copy. Once guest driver is loaded and surface is created by guest driver, QUERY interface should return valid size.

That seems reasonable and well specified. Thanks,

Alex

Quoted 117 lines
Quoted 117 lines
Quoted 10 lines

3. The id field in structure vfio_device_gfx_plane_info
So far we haven't figured out the usage of this field for dma-buf usage. So, this field is changed to "region_index" and only used for region usage. In previous discussions, we thought this "id" field might be used for both dma-buf and region usages.
So, we proposed some ways, like adding flags field to the structure. Another way to do it was to add this:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

Quoted 6 lines
 struct vfio_device_gfx_query_caps {
         __u32 argsz;
         __u32 flags;
         enum vfio_device_gfx_type;

};
Obviously, we don't need to consider this again, unless we find the "region_index" means something for dma-buf usage.

The usefulness of this ioctl seems really limited and once again we get into a situation where having two ioctls leaves doubt whether this is describing the current plane state. Thanks,

Alex

Quoted 94 lines
Quoted 81 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

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

Quoted 10 lines
 include/uapi/linux/vfio.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
(quoted diff) +0 -0

b/include/uapi/linux/vfio.h index ae46105..827a230 100644

include/uapi/linux/vfio.h +0 -0
@@ -502,6 +502,34 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE,    

VFIO_BASE +

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

13)

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE,    

VFIO_BASE

Quoted 46 lines

+

Quoted 5 lines
Quoted 5 lines

14,

Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
include/uapi/linux/vfio.h +4 -0
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information about
+the gfx    

plane.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_*    

*/

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+	/* 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, upper    

left corner

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left    

corner in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

lines*/

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */    

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating

Quoted 6 lines
Quoted 6 lines

those resources yet?

Quoted 2 lines

Dma-buf won't use region_index, which means region_index is zero all the

time for dma-buf usage.

Quoted 2 lines

As we discussed, there won't be errno if not initialized, just keep all fields

zero.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

I will add the comments about these in the next version. Thanks

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Zero is a valid region index.

If zero is valid, can we find out other invalid value? How about 0xffffffff?

Unlikely, but also valid. Isn't this why we have a flags field in the structure, so we don't need to rely on implicit values as invalid. Also, all of the previously discussed usage models needs to be documented, either here in the header or in a Documentation/ file.

According to the previously discussion, we also have the following propose:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

struct vfio_device_gfx_query_caps {
        __u32 argsz;
        __u32 flags;
        enum vfio_device_gfx_type;
};
Quoted 5 lines

So, we may need to add one more ioctl, e.g. VFIO_DEVICE_QUERY_GFX_CAPS. User mode can query this before querying the plan info, and to see which usage (dma-buf or region) is supported.
Does it still make sense?
Thanks.

So, I think we can rely on VFIO_DEVICE_GET_REGION_INFO to tell user mode whether the region case is using, instead of introducing a new ioctl. Thanks

Tina

Quoted 4 lines

Tina

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks,

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

#22 lore raw

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

Quoted 95 lines · Alex Williamson
Quoted 63 lines · On Tue, 8 Aug 2017 14:18:07 +0530 Kirti Wankhede <[email protected]> wrote:
Quoted 9 lines · Alex Williamson
Quoted 4 lines · Tina

After going through the previous discussions, here are some summaries may be related to the current discussion:
1. How does user mode figure the device capabilities between region and dma-buf? VFIO_DEVICE_GET_REGION_INFO could tell if the mdev supports region case.
Otherwise, the mdev supports dma-buf.

Why do we need to make this assumption?

Right, we should not make such assumption. Vendor driver might not support both or disable console vnc ( for example, for performance testing console VNC need to be disabled)

Quoted 9 lines

What happens when dma-buf is
superseded? What happens if a device supports both dma-buf and regions? We have a flags field in vfio_device_gfx_plane_info, doesn't it make sense to use it to identify which field, between region_index and fd, is valid? We could even put region_index and fd into a union with the flag bits indicating how to interpret the union, but I'm not sure everyone was onboard with this idea. Seems like a waste of 4 bytes not to do that though.

Agree.

Quoted 9 lines

Thinking further, is the user ever in a situation where they query the graphics plane info and can handle either a dma-buf or a region? It seems more likely that the user needs to know early on which is supported and would then require that they continue to see compatible plane information... Should the user then be able to specify whether they want a dma-buf or a region? Perhaps these flag bits are actually input and the return should be -errno if the driver cannot produce something compatible.

Quoted 13 lines

Maybe we'd therefore define 3 flag bits: PROBE, DMABUF, REGION. In this initial implementation, DMABUF or REGION would always be set by the user to request that type of interface. Additionally, the QUERY bit could be set to probe compatibility, thus if PROBE and REGION are set, the vendor driver would return success only if it supports the region based interface. If PROBE and DMABUF are set, the vendor driver returns success only if the dma-buf based interface is supported. The value of the remainder of the structure is undefined for PROBE. Additionally setting both DMABUF and REGION is invalid. Undefined flags bits must be validated as zero by the drivers for future use (thus if we later define DMABUFv2, an older driver should automatically return -errno when probed or requested).

Are you saying all of this to be part of VFIO_DEVICE_QUERY_GFX_PLANE ioctl?

Let me summarize what we need, taking QEMU as reference:
1. From vfio_initfn(), for REGION case, get region info:
vfio_get_dev_region_info(.., VFIO_REGION_SUBTYPE_CONSOLE_REGION, &vdev->console_opregion)

If above return success, setup console REGION and mmap. I don't know what is required for DMABUF at this moment.

If console VNC is supported either DMABUF or REGION, initialize console and register its callback operations:

Quoted 6 lines

static const GraphicHwOps vfio_console_ops = {
.gfx_update = vfio_console_update_display,
};

vdev->console = graphic_console_init(DEVICE(vdev), 0, &vfio_console_ops, vdev);

I might structure it that vfio_initfn() would call ioctl(VFIO_DEVICE_QUERY_GFX_PLANE) with the PROBE bit set with either DMABUF or REGION set as the interface type in the flags field. If REGION is the probed interface and success is returned, then QEMU might go look for regions of the appropriate type, however the vfio_device_gfx_plane_info structure is canonical source for the region index, so QEMU would probably be wise to use that and only use the region type for consistency testing.

Quoted 5 lines

2. On above console registration, vfio_console_update_display() gets called for each refresh cycle of console. In that:
- call ioctl(VFIO_DEVICE_QUERY_GFX_PLANE)
- if (queried size > 0), update QEMU console surface (for REGION case read mmaped region, for DMABUF read surface using fd)

The ioctl would be called with REGION or DMABUF based on the initial probe call, ex. we probed that REGION is supported and now we continue to ask for region based updates. QEMU would need to verify the region index matches that already mapped, remapping a different region if necessary, and interpret the graphics parameters to provide the screen update.

Quoted 9 lines
Quoted 6 lines

Alex, in your proposal above, my understanding is ioctl(VFIO_DEVICE_QUERY_GFX_PLANE) with PROBE flag should be called in step #1.
In step #2, ioctl(VFIO_DEVICE_QUERY_GFX_PLANE) will be without PROBE flag, but either DMABUF or REGION flag based on what is returned as supported by vendor driver in step #1. Is that correct?

Yes, that's the idea. Does it make sense/provide value?

Yes, sounds good to me.

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

#23 lore raw

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

In reply to Alex Williamson
Quoted 23 lines

-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Tuesday, August 8, 2017 1:43 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 1 line · Tina

After going through the previous discussions, here are some summaries may

be related to the current discussion:

Quoted 1 line

1. How does user mode figure the device capabilities between region and

dma-buf?

Quoted 2 lines

VFIO_DEVICE_GET_REGION_INFO could tell if the mdev supports region case. Otherwise, the mdev supports dma-buf.

Quoted 7 lines

Why do we need to make this assumption? What happens when dma-buf is superseded? What happens if a device supports both dma-buf and regions? We have a flags field in vfio_device_gfx_plane_info, doesn't it make sense to use it to identify which field, between region_index and fd, is valid? We could even put region_index and fd into a union with the flag bits indicating how to interpret the union, but I'm not sure everyone was onboard with this idea. Seems like a waste of 4 bytes not to do that though.

It seems we discussed this idea before:
https://lists.freedesktop.org/archives/intel-gvt-dev/2017-June/001304.html
https://lists.freedesktop.org/archives/intel-gvt-dev/2017-June/001333.html
Thanks.

Tina

Quoted 8 lines

Thinking further, is the user ever in a situation where they query the graphics plane info and can handle either a dma-buf or a region? It seems more likely that the user needs to know early on which is supported and would then require that they continue to see compatible plane information... Should the user then be able to specify whether they want a dma-buf or a region? Perhaps these flag bits are actually input and the return should be -errno if the driver cannot produce something compatible.

From the previously discussion, it seems user space workflow will look quite different for these two cases. So once user space finds out which case is supported, it just uses that case, and won't change it.

Meanwhile, I'm not sure whether there will be a mdev would like to support both region and dma-buf cases. In my opinion, either region or dma-buf is supported by one mdev. (Yeah, agree, there may be other cases in future)
It's like we want to propose a general interface used to share guest's buffer with host. And the general interface, so far, has two choice: region and dma-buf. So each mdev likes this interface can implement one kind of it and gets the benefit from the general interface. So, if we think about this, the difference in user mode should be as little as possible. Thanks.

Tina

Quoted 13 lines

Maybe we'd therefore define 3 flag bits: PROBE, DMABUF, REGION. In this initial implementation, DMABUF or REGION would always be set by the user to request that type of interface. Additionally, the QUERY bit could be set to probe compatibility, thus if PROBE and REGION are set, the vendor driver would return success only if it supports the region based interface. If PROBE and DMABUF are set, the vendor driver returns success only if the dma-buf based interface is supported. The value of the remainder of the structure is undefined for PROBE. Additionally setting both DMABUF and REGION is invalid. Undefined flags bits must be validated as zero by the drivers for future use (thus if we later define DMABUFv2, an older driver should automatically return -errno when probed or requested).

Quoted 3 lines

It seems like this handles all the cases, the user can ask what's supported and specifies the interface they want on every call. The user therefore can also choose between region_index and fd and we can make that a union.

Agree, that's a good proposal, which can handle all the cases.
I'm just not sure about the usage case of "on every call". In previous discussion, it seems we think static is enough. Thanks.

Tina

Quoted 144 lines
Quoted 3 lines

2. For dma-buf, how to differentiate unsupported vs not initialized? For dma-buf, when the mdev doesn't support some arguments, -EINVAL will

be returned. And -errno will return when meeting other failures, like -ENOMEM.

Quoted 1 line

If the mdev is not initialized, there won't be any returned err. Just zero all the

fields in structure vfio_device_gfx_plane_info.

So we're relying on special values again :-\ For which fields is zero not a valid value? I prefer the probe interface above unless there are better ideas.

Quoted 2 lines

3. The id field in structure vfio_device_gfx_plane_info So far we haven't figured out the usage of this field for dma-buf usage. So, this field is

changed to "region_index" and only used for region usage.

Quoted 1 line

In previous discussions, we thought this "id" field might be used for both dma-

buf and region usages.

Quoted 1 line

So, we proposed some ways, like adding flags field to the structure. Another

way to do it was to add this:

Quoted 6 lines

enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

Quoted 6 lines
 struct vfio_device_gfx_query_caps {
         __u32 argsz;
         __u32 flags;
         enum vfio_device_gfx_type;

};
Obviously, we don't need to consider this again, unless we find the

"region_index" means something for dma-buf usage.

The usefulness of this ioctl seems really limited and once again we get into a situation where having two ioctls leaves doubt whether this is describing the current plane state. Thanks,

Alex

Quoted 79 lines
Quoted 79 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
 include/uapi/linux/vfio.h | 28
++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
(quoted diff) +0 -0

b/include/uapi/linux/vfio.h index ae46105..827a230 100644

include/uapi/linux/vfio.h +0 -0
@@ -502,6 +502,34 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE,

VFIO_BASE +

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

13)

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE,

VFIO_BASE

Quoted 47 lines

+

Quoted 5 lines
Quoted 5 lines

14,

Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
include/uapi/linux/vfio.h +4 -0
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information
+about the gfx

plane.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_*

*/

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+	/* 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, upper

left corner

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left

corner in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

lines*/

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating

Quoted 6 lines
Quoted 6 lines

those resources yet?

Quoted 2 lines

Dma-buf won't use region_index, which means region_index is zero all the

time for dma-buf usage.

Quoted 2 lines

As we discussed, there won't be errno if not initialized, just keep all fields

zero.

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

I will add the comments about these in the next version. Thanks

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Zero is a valid region index.

If zero is valid, can we find out other invalid value? How about 0xffffffff?

Unlikely, but also valid. Isn't this why we have a flags field in the structure, so we don't need to rely on implicit values as invalid. Also, all of the previously discussed usage models needs to be documented, either here in the header or in a Documentation/ file.

According to the previously discussion, we also have the following propose:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

Quoted 6 lines
Quoted 6 lines
struct vfio_device_gfx_query_caps {
        __u32 argsz;
        __u32 flags;
        enum vfio_device_gfx_type;
};

So, we may need to add one more ioctl, e.g.

VFIO_DEVICE_QUERY_GFX_CAPS.

Quoted 5 lines
Quoted 4 lines

User mode can query this before querying the plan info, and to see which usage (dma-buf or region) is supported.
Does it still make sense?
Thanks.

So, I think we can rely on VFIO_DEVICE_GET_REGION_INFO to tell user mode

whether the region case is using, instead of introducing a new ioctl.

Quoted 14 lines

Thanks

Tina

Quoted 11 lines

Tina

Quoted 7 lines

Thanks,

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#24 lore raw

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

Quoted 28 lines · Tina
Quoted 21 lines

-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Tuesday, August 8, 2017 1:43 AM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; Wang, Zhi A <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH v13 5/7] vfio: ABI for mdev display dma-buf operation

Quoted 1 line · Tina

After going through the previous discussions, here are some summaries may

be related to the current discussion:

Quoted 1 line

1. How does user mode figure the device capabilities between region and

dma-buf?

Quoted 2 lines

VFIO_DEVICE_GET_REGION_INFO could tell if the mdev supports region case. Otherwise, the mdev supports dma-buf.

Quoted 7 lines

Why do we need to make this assumption? What happens when dma-buf is superseded? What happens if a device supports both dma-buf and regions? We have a flags field in vfio_device_gfx_plane_info, doesn't it make sense to use it to identify which field, between region_index and fd, is valid? We could even put region_index and fd into a union with the flag bits indicating how to interpret the union, but I'm not sure everyone was onboard with this idea. Seems like a waste of 4 bytes not to do that though.

Quoted 3 lines

It seems we discussed this idea before:
https://lists.freedesktop.org/archives/intel-gvt-dev/2017-June/001304.html
https://lists.freedesktop.org/archives/intel-gvt-dev/2017-June/001333.html

These are both from Gerd. Gerd, do you have any objection to using a union to provide either the dmabuf fd or region index? It's inefficient to provide separate fields when we can only provide one or the other and I don't like the idea of using implicit values to determine which is active.

Quoted 10 lines
Quoted 7 lines

Thinking further, is the user ever in a situation where they query the graphics plane info and can handle either a dma-buf or a region? It seems more likely that the user needs to know early on which is supported and would then require that they continue to see compatible plane information... Should the user then be able to specify whether they want a dma-buf or a region? Perhaps these flag bits are actually input and the return should be -errno if the driver cannot produce something compatible.

From the previously discussion, it seems user space workflow will look quite different for these two cases. So once user space finds out which case is supported, it just uses that case, and won't change it.

And that's supported, the user tests whether a given interface type is supported and continues to request updates for that interface type.

Quoted 3 lines

Meanwhile, I'm not sure whether there will be a mdev would like to support both region and dma-buf cases. In my opinion, either region or dma-buf is supported by one mdev. (Yeah, agree, there may be other cases in future)

There's no requirement to support both.

Quoted 4 lines

It's like we want to propose a general interface used to share guest's buffer with host. And the general interface, so far, has two choice: region and dma-buf. So each mdev likes this interface can implement one kind of it and gets the benefit from the general interface. So, if we think about this, the difference in user mode should be as little as possible.

The difference seems pretty minimal here, the user probes supported interface types, and explicitly picks one by requesting updates using that interface type. The difference is only in the interpretation of one dword field. Furthermore, we're not limiting ourselves to these two interface types, this same API could support dmabuf-v2 if we define a flag bit for it and define the structure of the interface union.

Quoted 12 lines
Quoted 12 lines

Maybe we'd therefore define 3 flag bits: PROBE, DMABUF, REGION. In this initial implementation, DMABUF or REGION would always be set by the user to request that type of interface. Additionally, the QUERY bit could be set to probe compatibility, thus if PROBE and REGION are set, the vendor driver would return success only if it supports the region based interface. If PROBE and DMABUF are set, the vendor driver returns success only if the dma-buf based interface is supported. The value of the remainder of the structure is undefined for PROBE. Additionally setting both DMABUF and REGION is invalid. Undefined flags bits must be validated as zero by the drivers for future use (thus if we later define DMABUFv2, an older driver should automatically return -errno when probed or requested).

Quoted 5 lines
Quoted 3 lines

It seems like this handles all the cases, the user can ask what's supported and specifies the interface they want on every call. The user therefore can also choose between region_index and fd and we can make that a union.

Agree, that's a good proposal, which can handle all the cases.
I'm just not sure about the usage case of "on every call". In previous discussion, it seems we think static is enough.

Is it somehow a problem for the user to set the type bit in the flag on every call? This makes it explicit that the user is asking for an update for a specific interface type, if the vendor driver doesn't support it, return -errno. This makes it explicit whether the return is a dmabuf fd or a region index and the user knows how to interpret that union because they have asked for a specific type. As you've likely gathered from my previous replies, I don't like implicit interfaces. I don't want the interpretation of a field to depend on something the user has done in the past and I see no reason to impose a limitation on the vendor driver supporting only one of two pre-defined interfaces types. Thanks,

Alex

Quoted 143 lines
Quoted 143 lines
Quoted 2 lines

2. For dma-buf, how to differentiate unsupported vs not initialized? For dma-buf, when the mdev doesn't support some arguments, -EINVAL will

be returned. And -errno will return when meeting other failures, like -ENOMEM.

Quoted 1 line

If the mdev is not initialized, there won't be any returned err. Just zero all the

fields in structure vfio_device_gfx_plane_info.

So we're relying on special values again :-\ For which fields is zero not a valid value? I prefer the probe interface above unless there are better ideas.

Quoted 2 lines

3. The id field in structure vfio_device_gfx_plane_info So far we haven't figured out the usage of this field for dma-buf usage. So, this field is

changed to "region_index" and only used for region usage.

Quoted 1 line

In previous discussions, we thought this "id" field might be used for both dma-

buf and region usages.

Quoted 1 line

So, we proposed some ways, like adding flags field to the structure. Another

way to do it was to add this:

Quoted 6 lines

enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

Quoted 6 lines
 struct vfio_device_gfx_query_caps {
         __u32 argsz;
         __u32 flags;
         enum vfio_device_gfx_type;

};
Obviously, we don't need to consider this again, unless we find the

"region_index" means something for dma-buf usage.

The usefulness of this ioctl seems really limited and once again we get into a situation where having two ioctls leaves doubt whether this is describing the current plane state. Thanks,

Alex

Quoted 79 lines
Quoted 79 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
 include/uapi/linux/vfio.h | 28
++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
(quoted diff) +0 -0

b/include/uapi/linux/vfio.h index ae46105..827a230 100644

include/uapi/linux/vfio.h +0 -0
@@ -502,6 +502,34 @@ struct vfio_pci_hot_reset {
 
 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE,  

VFIO_BASE +

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

13)

Quoted 3 lines
include/uapi/linux/vfio.h +2 -0
+/**
+ * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE,  

VFIO_BASE

Quoted 47 lines

+

Quoted 5 lines
Quoted 5 lines

14,

Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
include/uapi/linux/vfio.h +4 -0
+struct vfio_device_query_gfx_plane)
+ *
+ * Set the drm_plane_type and retrieve information
+about the gfx  

plane.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_device_gfx_plane_info {
+	__u32 argsz;
+	__u32 flags;
+	/* in */
+	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_*  

*/

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
include/uapi/linux/vfio.h +8 -0
+	/* 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, upper  

left corner

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in pixels */

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

Quoted 1 line
include/uapi/linux/vfio.h +1 -0
+	__u32 y_pos;	/* vertical position of cursor plane, upper left  

corner in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

lines*/

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

Quoted 2 lines
include/uapi/linux/vfio.h +2 -0
+	__u32 region_index;
+	__s32 fd;	/* dma-buf fd */  

How do I know which of these is valid, region_index or fd? Can I ask for one vs the other? What are the errno values to differentiate unsupported vs not initialized? Is there a "probe" flag that I can use to determine what the device supports without allocating

Quoted 6 lines
Quoted 6 lines

those resources yet?

Quoted 2 lines

Dma-buf won't use region_index, which means region_index is zero all the

time for dma-buf usage.

Quoted 2 lines

As we discussed, there won't be errno if not initialized, just keep all fields

zero.

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

I will add the comments about these in the next version. Thanks

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Zero is a valid region index.

If zero is valid, can we find out other invalid value? How about 0xffffffff?

Unlikely, but also valid. Isn't this why we have a flags field in the structure, so we don't need to rely on implicit values as invalid. Also, all of the previously discussed usage models needs to be documented, either here in the header or in a Documentation/ file.

According to the previously discussion, we also have the following propose:
enum vfio_device_gfx_type {
VFIO_DEVICE_GFX_NONE,
VFIO_DEVICE_GFX_DMABUF,
VFIO_DEVICE_GFX_REGION,
};

Quoted 6 lines
Quoted 6 lines
struct vfio_device_gfx_query_caps {
        __u32 argsz;
        __u32 flags;
        enum vfio_device_gfx_type;
};

So, we may need to add one more ioctl, e.g.

VFIO_DEVICE_QUERY_GFX_CAPS.

Quoted 5 lines
Quoted 4 lines

User mode can query this before querying the plan info, and to see which usage (dma-buf or region) is supported.
Does it still make sense?
Thanks.

So, I think we can rely on VFIO_DEVICE_GET_REGION_INFO to tell user mode

whether the region case is using, instead of introducing a new ioctl.

Quoted 14 lines

Thanks

Tina

Quoted 11 lines

Tina

Quoted 7 lines

Thanks,

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines
Quoted 4 lines

_______________________________________________
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

#25 lore raw

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

Hi,

Quoted 2 lines

These are both from Gerd.  Gerd, do you have any objection to using a union to provide either the dmabuf fd or region index?

No.

Quoted 9 lines
Quoted 8 lines

It's like we want to propose a general interface used to share guest's buffer with host. And the
general interface, so far, has two choice: region and dma-buf. So each mdev likes this interface
can implement one kind of it and gets the benefit from the general interface.
So, if we think about this, the difference in user mode should be as little as possible.

Quoted 7 lines

The difference seems pretty minimal here, the user probes supported interface types, and explicitly picks one by requesting updates using that interface type.  The difference is only in the interpretation of one dword field.  Furthermore, we're not limiting ourselves to these two interface types, this same API could support dmabuf-v2 if we define
a flag bit for it and define the structure of the interface union.

Yep, using the flags is more future-proof and continues to work in case another interface type shows up (unlike looking for a gfx region being present).

Quoted 7 lines
Quoted 3 lines

Agree, that's a good proposal, which can handle all the cases. I'm just not sure about the usage case of "on every call". In previous discussion, it seems we think static is enough.

Is it somehow a problem for the user to set the type bit in the flag on
every call?

Not at all.

cheers,
Gerd

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author
#26 lore raw

PATCH v13 6/7 drm/i915: Introduce GEM proxy

In reply to Tina Zhang

GEM proxy is a kind of GEM, whose backing physical memory is pinned and produced by guest VM and is used by host as read only. With GEM proxy, host is able to access guest physical memory through GEM object interface. As GEM proxy is such a special kind of GEM, a new flag I915_GEM_OBJECT_IS_PROXY is introduced to ban host from changing the backing storage of GEM proxy.

---
 drivers/gpu/drm/i915/i915_gem.c        | 24 +++++++++++++++++++++++-
 drivers/gpu/drm/i915/i915_gem_object.h |  7 +++++++
 drivers/gpu/drm/i915/i915_gem_tiling.c |  8 ++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +23 -1
index 1b2dfa8..75530fb 100644
@@ -1624,6 +1624,16 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
 	if (err)
 		goto out;
 
+	/* Proxy objects do not control access to the backing storage, ergo
+	 * they cannot be used as a means to manipulate the cache domain
+	 * tracking for that backing storage. The proxy object is always
+	 * considered to be outside of any cache domain.
+	 */
+	if (i915_gem_object_is_proxy(obj)) {
+		err = -EPERM;
+		goto out;
+	}
+
 	/* Flush and acquire obj->pages so that we are coherent through
 	 * direct access in memory with previous cached writes through
 	 * shmemfs and that our cache domain tracking remains valid.
@@ -1680,6 +1690,10 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
 	if (!obj)
 		return -ENOENT;
 
+	/* Proxy objects are barred from CPU access, so there is no
+	 * need to ban sw_finish as it is a nop.
+	 */
+
 	/* Pinned buffers may be scanout, so flush the cache */
 	i915_gem_object_flush_if_display(obj);
 	i915_gem_object_put(obj);
@@ -1730,7 +1744,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
 	 */
 	if (!obj->base.filp) {
 		i915_gem_object_put(obj);
-		return -EINVAL;
+		return -EPERM;
 	}
 
 	addr = vm_mmap(obj->base.filp, 0, args->size,
@@ -3764,6 +3778,14 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
 	if (!obj)
 		return -ENOENT;
 
+	/* The caching mode of proxy object is handled by its generator, and not
+	 * expected to be changed by user mode.
+	 */
+	if (i915_gem_object_is_proxy(obj)) {
+		ret = -EPERM;
+		goto out;
+	}
+
 	if (obj->cache_level == level)
 		goto out;
 
drivers/gpu/drm/i915/i915_gem_object.h +7 -0
index 5b19a49..f3b382a 100644
@@ -39,6 +39,7 @@ struct drm_i915_gem_object_ops {
 	unsigned int flags;
 #define I915_GEM_OBJECT_HAS_STRUCT_PAGE BIT(0)
 #define I915_GEM_OBJECT_IS_SHRINKABLE   BIT(1)
+#define I915_GEM_OBJECT_IS_PROXY	BIT(2)
 
 	/* Interface between the GEM object and its backing storage.
 	 * get_pages() is called once prior to the use of the associated set
@@ -300,6 +301,12 @@ i915_gem_object_is_shrinkable(const struct drm_i915_gem_object *obj)
 }
 
 static inline bool
+i915_gem_object_is_proxy(const struct drm_i915_gem_object *obj)
+{
+	return obj->ops->flags & I915_GEM_OBJECT_IS_PROXY;
+}
+
+static inline bool
 i915_gem_object_is_active(const struct drm_i915_gem_object *obj)
 {
 	return obj->active_count;
drivers/gpu/drm/i915/i915_gem_tiling.c +8 -0
index fb5231f..d12859d 100644
@@ -345,6 +345,14 @@ i915_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
 	if (!obj)
 		return -ENOENT;
 
+	/* The tiling mode of proxy objects is handled by its generator, and not
+	 * expected to be changed by user mode.
+	 */
+	if (i915_gem_object_is_proxy(obj)) {
+		err = -EPERM;
+		goto err;
+	}
+
 	if (!i915_tiling_ok(obj, args->tiling_mode, args->stride)) {
 		err = -EINVAL;
 		goto err;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#27 lore raw

Re: [Intel-gfx] [PATCH v13 6/7] drm/i915: Introduce GEM proxy

Quoted 7 lines · Tina Zhang

GEM proxy is a kind of GEM, whose backing physical memory is pinned and produced by guest VM and is used by host as read only. With GEM proxy, host is able to access guest physical memory through GEM object interface. As GEM proxy is such a special kind of GEM, a new flag I915_GEM_OBJECT_IS_PROXY is introduced to ban host from changing the backing storage of GEM proxy.

It is a good idea to add a changelog here to indicate what was changed since the last patch revision. It'll be easier for the reviewer to spot the differences.

It's also a good idea to add Cc: line for somebody who provided previous review, this will, too, allow spotting the patch quicker.

Quoted 1 line

<SNIP>

drivers/gpu/drm/i915/i915_gem.c i915_gem_mmap_ioctl(struct drm_device *dev, void *data, · line 1748

Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -1730,7 +1744,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
  	 */
  	if (!obj->base.filp) {
  		i915_gem_object_put(obj);
-		return -EINVAL;
+		return -EPERM;
  	}

This hunk should be separate bugfix patch, but other than that the patch looks OK to me.

I'll let Chris comment if he feels previous comments were adequately addressed.

Regards, Joonas

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#28 lore raw

RE: [Intel-gfx] [PATCH v13 6/7] drm/i915: Introduce GEM proxy

Quoted 23 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Joonas Lahtinen
Sent: Monday, August 7, 2017 4:24 PM
To: Zhang, Tina <[email protected]>; [email protected]; intel- [email protected]; [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tian, Kevin <[email protected]>
Subject: Re: [Intel-gfx] [PATCH v13 6/7] drm/i915: Introduce GEM proxy

Quoted 7 lines · Tina Zhang

GEM proxy is a kind of GEM, whose backing physical memory is pinned and produced by guest VM and is used by host as read only. With GEM proxy, host is able to access guest physical memory through GEM object interface. As GEM proxy is such a special kind of GEM, a new flag I915_GEM_OBJECT_IS_PROXY is introduced to ban host from changing the backing storage of GEM proxy.

Quoted 5 lines

It is a good idea to add a changelog here to indicate what was changed since the last patch revision. It'll be easier for the reviewer to spot the differences.

It's also a good idea to add Cc: line for somebody who provided previous review, this will, too, allow spotting the patch quicker.

Indeed. Thanks.

Tina

Quoted 7 lines
Quoted 2 lines

<SNIP>

Review i915_gem_mmap_ioctl(struct drm_device *dev,

Quoted 1 line
(quoted diff) +0 -0
@@ -1730,7 +1744,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev,

void *data,

Quoted 9 lines

drivers/gpu/drm/i915/i915_gem.c i915_gem_mmap_ioctl(struct drm_device *dev, void *data, · line 1748

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +1 -1
  	 */
  	if (!obj->base.filp) {
  		i915_gem_object_put(obj);
-		return -EINVAL;
+		return -EPERM;
  	}

This hunk should be separate bugfix patch, but other than that the patch looks OK to me.

Thanks. I will send this patch separately.

Tina

Quoted 12 lines

I'll let Chris comment if he feels previous comments were adequately addressed.

Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author
#29 lore raw

PATCH v13 7/7 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.

---
 drivers/gpu/drm/i915/gvt/Makefile      |   2 +-
 drivers/gpu/drm/i915/gvt/dmabuf.c      | 380 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/dmabuf.h      |  58 +++++
 drivers/gpu/drm/i915/gvt/gvt.c         |   1 +
 drivers/gpu/drm/i915/gvt/gvt.h         |   9 +
 drivers/gpu/drm/i915/gvt/hypercall.h   |   2 +
 drivers/gpu/drm/i915/gvt/kvmgt.c       |  42 ++++
 drivers/gpu/drm/i915/gvt/mpt.h         |  30 +++
 drivers/gpu/drm/i915/gvt/vgpu.c        |   2 +-
 drivers/gpu/drm/i915/i915_gem_object.h |   2 +
 10 files changed, 526 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 019d596..18f43cb 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 \
-	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 +380 -0

380 lines not on this page · raw message

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

58 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/gvt.c +1 -0
index c27c683..f77770b 100644
@@ -54,6 +54,7 @@ static const struct intel_gvt_ops intel_gvt_ops = {
 	.vgpu_reset = intel_gvt_reset_vgpu,
 	.vgpu_activate = intel_gvt_activate_vgpu,
 	.vgpu_deactivate = intel_gvt_deactivate_vgpu,
+	.vgpu_query_plane = intel_vgpu_query_plane,
 };
 
 /**
drivers/gpu/drm/i915/gvt/gvt.h +9 -0
index d0fe4d0..da3ca64 100644
@@ -47,6 +47,7 @@
 #include "render.h"
 #include "cmd_parser.h"
 #include "fb_decoder.h"
+#include "dmabuf.h"
 
 #define GVT_MAX_VGPU 8
 
@@ -183,8 +184,15 @@ 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_list_lock;
+
+	struct completion vblank_done;
+
 };
 
 struct intel_gvt_gm {
@@ -488,6 +496,7 @@ struct intel_gvt_ops {
 	void (*vgpu_reset)(struct intel_vgpu *);
 	void (*vgpu_activate)(struct intel_vgpu *);
 	void (*vgpu_deactivate)(struct intel_vgpu *);
+	int (*vgpu_query_plane)(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 +42 -0

76 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/mpt.h +30 -0
index 9e73f2e..86443ff 100644
@@ -307,4 +307,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 +1 -1
index 03f9539..f208ad0 100644
@@ -346,7 +346,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
 	vgpu->gvt = gvt;
 	vgpu->sched_ctl.weight = param->weight;
 	bitmap_zero(vgpu->tlb_handle_pending, I915_NUM_ENGINES);
-
+	INIT_LIST_HEAD(&vgpu->dmabuf_obj_list_head);
 	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 f3b382a..c91e336 100644
@@ -199,6 +199,8 @@ struct drm_i915_gem_object {
 		} userptr;
 
 		unsigned long scratch;
+
+		void *gvt_info;
 	};
 
 	/** for phys allocated objects */
Signature · 6 lines
2.7.4

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

✗ Fi.CI.BAT: warning 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/27844/
State : warning

== Summary ==

Series 27844v1 drm/i915/gvt: Dma-buf support for GVT-g
https://patchwork.freedesktop.org/api/1.0/series/27844/revisions/1/mbox/

Test gem_ringfill:

        Subgroup basic-default:
                pass       -> SKIP       (fi-bsw-n3050)
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-atomic:
                fail       -> PASS       (fi-snb-2600) fdo#100215
Test kms_flip:
        Subgroup basic-flip-vs-modeset:
                pass       -> SKIP       (fi-skl-x1585l) fdo#101781
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-byt-n2820) fdo#101705

fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781
fdo#101705 https://bugs.freedesktop.org/show_bug.cgi?id=101705

fi-bdw-5557u     total:280  pass:269  dwarn:0   dfail:0   fail:0   skip:11  time:444s
fi-bdw-gvtdvm    total:280  pass:265  dwarn:1   dfail:0   fail:0   skip:14  time:430s
fi-blb-e6850     total:280  pass:225  dwarn:1   dfail:0   fail:0   skip:54  time:352s
fi-bsw-n3050     total:280  pass:243  dwarn:0   dfail:0   fail:0   skip:37  time:529s
fi-bxt-j4205     total:280  pass:261  dwarn:0   dfail:0   fail:0   skip:19  time:512s
fi-byt-j1900     total:280  pass:256  dwarn:0   dfail:0   fail:0   skip:24  time:493s
fi-byt-n2820     total:280  pass:252  dwarn:0   dfail:0   fail:0   skip:28  time:489s
fi-glk-2a        total:280  pass:261  dwarn:0   dfail:0   fail:0   skip:19  time:600s
fi-hsw-4770      total:280  pass:264  dwarn:0   dfail:0   fail:0   skip:16  time:440s
fi-hsw-4770r     total:280  pass:264  dwarn:0   dfail:0   fail:0   skip:16  time:415s
fi-ilk-650       total:280  pass:230  dwarn:0   dfail:0   fail:0   skip:50  time:417s
fi-ivb-3520m     total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:504s
fi-ivb-3770      total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:478s
fi-kbl-7500u     total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:469s
fi-kbl-7560u     total:280  pass:270  dwarn:0   dfail:0   fail:0   skip:10  time:575s
fi-kbl-r         total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:587s
fi-pnv-d510      total:280  pass:223  dwarn:2   dfail:0   fail:0   skip:55  time:566s
fi-skl-6260u     total:280  pass:270  dwarn:0   dfail:0   fail:0   skip:10  time:456s
fi-skl-6700hq    total:280  pass:263  dwarn:0   dfail:0   fail:0   skip:17  time:585s
fi-skl-6700k     total:280  pass:262  dwarn:0   dfail:0   fail:0   skip:18  time:473s
fi-skl-6770hq    total:280  pass:270  dwarn:0   dfail:0   fail:0   skip:10  time:482s
fi-skl-gvtdvm    total:280  pass:266  dwarn:1   dfail:0   fail:0   skip:13  time:440s
fi-skl-x1585l    total:280  pass:269  dwarn:0   dfail:0   fail:0   skip:11  time:472s
fi-snb-2520m     total:280  pass:252  dwarn:0   dfail:0   fail:0   skip:28  time:542s
fi-snb-2600      total:280  pass:251  dwarn:0   dfail:0   fail:0   skip:29  time:399s

9e377e5fc2f8360c01787ebfe16e1bea778b4d9d drm-tip: 2017y-07m-25d-07h-06m-30s UTC integration manifest 35d5cd644bed drm/i915/gvt: Dmabuf support for GVT-g
9b4dfe796c3c drm/i915: Introduce GEM proxy
1399f4fa4e78 vfio: ABI for mdev display dma-buf operation
bcf25e9eb909 drm/i915/gvt: Add opregion support
1297435bc1a6 drm/i915/gvt: Add RGB 64-bit 16:16:16:16 float format support aea01e3fd71a drm: Introduce RGB 64-bit 16:16:16:16 float format
833445cae249 drm/i915/gvt: Add framebuffer decoder support

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5271/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx