drm/i915/gvt: Dma-buf support for GVT-g
Subsystems (5)
v18 cover drm/i915/gvt: Dma-buf support for GVT-g
v17->v18:
1) unmap vgpu's opregion when destroying vgpu.
2) update comments for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
v16->v17:
1) modify VFIO_DEVICE_GET_GFX_DMABUF interface. (Alex)
2) add comments for x_hot/y_hot. (Gerd)
v15->v16:
1) add cursor hotspot fields in struct vfio_device_gfx_plane_info. (Gerd)
2) clean up some typos and add comments for VFIO_DEVICE_QUERY_GFX_PLANE. (Alex)
3) seperate the GEM Proxy part to another patch-set. (Joonas and Chris)
https://lists.freedesktop.org/archives/intel-gvt-dev/2017-November/002377.html
4) please note that this patch-set needs 3) to be applied first.
5) rebase to 4.14.0-rc6.
v14->15:
1) add VFIO_DEVICE_GET_GFX_DMABUF ABI. (Gerd)
2) add intel_vgpu_dmabuf_cleanup() to clean up the vGPU's dmabuf. (Gerd)
v13->v14:
1) add PROBE, DMABUF and REGION flags. (Alex)
2) return -ENXIO when gem proxy object is banned by ioctl. (Chris) (Daniel)
3) add some details about the float pixel format. (Daniel)
4) add F suffix to the defined name. (Daniel)
5) refine pixel format table. (Zhenyu)
v12->v13:
1) add comments to GEM proxy. (Chris)
2) don't ban GEM proxy in i915_gem_sw_finish_ioctl. (Chris)
3) check GEM proxy bar after finishing i915_gem_object_wait. (Chris)
4) remove GEM proxy bar in i915_gem_madvise_ioctl.
v11->v12:
1) add drm_format_mod back. (Gerd and Zhenyu)
2) add region_index. (Gerd)
3) refine the lifecycle of dmabuf.
4) send to dri-devel at lists.freedesktop.org. (Ville)
v10->v11:
1) rename plane_type to drm_plane_type. (Gerd)
2) move fields of vfio_device_query_gfx_plane to
vfio_device_gfx_plane_info. (Gerd)
3) remove drm_format_mod, start fields. (Daniel)
4) remove plane_id.
v9->v10:
1) remove dma-buf management
2) refine the ABI API VFIO_DEVICE_QUERY_GFX_PLANE
3) track the dma-buf create and release in kernel mode
v8->v9:
1) refine the dma-buf ioctl definition
2) add a lock to protect the dmabuf list
3) move drm format change to a separate patch
4) codes cleanup
v7->v8:
1) refine framebuffer decoder code
2) fix a bug in decoding primary plane
v6->v7:
1) release dma-buf related allocations in dma-buf's associated release function.
2) refine ioctl interface for querying plane info or create dma-buf
3) refine framebuffer decoder code
4) the patch series is based on 4.12.0-rc1
v5->v6:
1) align the dma-buf life cycle with the vfio device.
2) add the dma-buf related operations in a separate patch.
3) i915 releated changes.
v4->v5:
1) fix bug while checking whether the gem obj is gvt's dma-buf when user change caching mode or domains. Add a helper function to do it.
2) add definition for the query plane and create dma-buf.
v3->v4:
1) fix bug while checking whether the gem obj is gvt's dma-buf when set caching mode or doamins.
v2->v3:
1) add a field gvt_plane_info in the drm_i915_gem_obj structure to save the decoded plane information to avoid look up while need the plane info.
2) declare a new flag I915_GEM_OBJECT_IS_GVT_DMABUF in drm_i915_gem_object to represent the gem obj for gvt's dma-buf. The tiling mode, caching mode and domains can not be changed for this kind of gem object.
3) change dma-buf related information to be more generic. So other vendor can use the same interface.
v1->v2:
1) create a management fd for dma-buf operations.
2) alloc gem object's backing storage in gem obj's get_pages() callback.
This patch set adds the dma-buf support for intel GVT-g.
dma-buf is an uniform mechanism to share DMA buffers across different devices and subsystems. dma-buf for intel GVT-g is mainly used to share the vgpu's framebuffer to userspace to leverage userspace graphics stacks to render the framebuffer to the display monitor.
The main idea is that we create a gem object and set vgpu's framebuffer as its backing storage. Then, export a dma-buf associated with this gem object. With the fd of this dma-buf, userspace can directly handle this buffer.
This patch set can be tried with the following example:
git://git.kraxel.org/qemu branch: work/intel-vgpu
A topic branch with the latest patch set is:
https://github.com/intel/gvt-linux.git branch: topic/dmabuf
Tina Zhang (6):
drm/i915/gvt: Add framebuffer decoder support
drm: Introduce RGB 64-bit 16:16:16:16 float format drm/i915/gvt: Add RGB 64-bit 16:16:16:16 float format drm/i915/gvt: Add opregion support
vfio: ABI for mdev display dma-buf operation drm/i915/gvt: Dmabuf support for GVT-g
drivers/gpu/drm/i915/gvt/Makefile | 3 +- drivers/gpu/drm/i915/gvt/display.c | 2 +- drivers/gpu/drm/i915/gvt/display.h | 2 + drivers/gpu/drm/i915/gvt/dmabuf.c | 523 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/dmabuf.h | 67 +++++ drivers/gpu/drm/i915/gvt/fb_decoder.c | 521 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/fb_decoder.h | 169 +++++++++++ drivers/gpu/drm/i915/gvt/gvt.c | 2 + drivers/gpu/drm/i915/gvt/gvt.h | 12 + drivers/gpu/drm/i915/gvt/hypercall.h | 3 + drivers/gpu/drm/i915/gvt/kvmgt.c | 157 +++++++++- drivers/gpu/drm/i915/gvt/mpt.h | 45 +++ drivers/gpu/drm/i915/gvt/opregion.c | 29 +- drivers/gpu/drm/i915/gvt/vgpu.c | 9 +- drivers/gpu/drm/i915/i915_gem_object.h | 2 + include/uapi/drm/drm_fourcc.h | 4 + include/uapi/linux/vfio.h | 62 ++++ 17 files changed, 1600 insertions(+), 12 deletions(-) create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.c create mode 100644 drivers/gpu/drm/i915/gvt/dmabuf.h create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.c create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.h
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v18 1/6 drm/i915/gvt: Add framebuffer decoder support
This patch is to introduce the framebuffer decoder which can decode guest OS's framebuffer information, including primary, cursor and sprite plane.
v16:
- rebase to 4.14.0-rc6.
v14:
- refine pixel format table. (Zhenyu)
v9:
- move drm format change to a separate patch. (Xiaoguang)
v8:
- fix a bug in decoding primary plane. (Tina)
v7:
- refine framebuffer decoder code. (Zhenyu)
--- drivers/gpu/drm/i915/gvt/Makefile | 3 +- drivers/gpu/drm/i915/gvt/display.c | 2 +- drivers/gpu/drm/i915/gvt/display.h | 2 + drivers/gpu/drm/i915/gvt/fb_decoder.c | 507 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/fb_decoder.h | 169 ++++++++++++ drivers/gpu/drm/i915/gvt/gvt.h | 1 + 6 files changed, 682 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.c create mode 100644 drivers/gpu/drm/i915/gvt/fb_decoder.h
drivers/gpu/drm/i915/gvt/Makefile +2 -1
@@ -1,7 +1,8 @@ GVT_DIR := gvt GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \ interrupt.o gtt.o cfg_space.o opregion.o mmio.o display.o edid.o \ - execlist.o scheduler.o sched_policy.o render.o cmd_parser.o debugfs.o + execlist.o scheduler.o sched_policy.o render.o cmd_parser.o debugfs.o \ + fb_decoder.o ccflags-y += -I$(src) -I$(src)/$(GVT_DIR) i915-y += $(addprefix $(GVT_DIR)/, $(GVT_SOURCE))
drivers/gpu/drm/i915/gvt/display.c +1 -1
@@ -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
@@ -179,4 +179,6 @@ int intel_vgpu_init_display(struct intel_vgpu *vgpu, u64 resolution);void intel_vgpu_reset_display (struct intel_vgpu *vgpu);void intel_vgpu_clean_display (struct intel_vgpu *vgpu); +int pipe_is_enabled (struct intel_vgpu *vgpu,int pipe); +#endif
drivers/gpu/drm/i915/gvt/fb_decoder.c new file +507 -0
507 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/fb_decoder.h new file +169 -0
169 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/gvt.h +1 -0
@@ -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
PATCH v18 2/6 drm: Introduce RGB 64-bit 16:16:16:16 float format
In reply to Tina ZhangThe RGB 64-bit 16:16:16:16 float pixel format is needed by some Apps in windows. The float format in each component is 1:5:10 MSb-sign:exponent:
fraction.
This patch is to introduce the format to drm, so that the windows guest's framebuffer in this kind of format can be recognized and used by linux host.
v14:
- add some details about the float pixel format. (Daniel)
- add F suffix to the defined name. (Daniel)
v12:
- send to dri-devel at lists.freedesktop.org. (Ville)
v9:
- separated from framebuffer decoder patch. (Zhenyu) (Xiaoguang)
--- include/uapi/drm/drm_fourcc.h | 4 ++++ 1 file changed, 4 insertions(+)
include/uapi/drm/drm_fourcc.h +4 -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 16:16:16:16 Floating Point */ +#define DRM_FORMAT_XRGB161616F fourcc_code('X', 'R', '3', 'F')/* [63:0] x:R:G:B 16:16:16:16 little endian */ +#define DRM_FORMAT_XBGR161616F fourcc_code('X', 'B', '3', 'F')/* [63:0] x:B:G:R 16:16:16:16 little endian */ +/* * 2 plane RGB + A * index 0 = RGB plane, same format as the corresponding non _A8 format has
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v18 3/6 drm/i915/gvt: Add RGB 64-bit 16:16:16:16 float format
In reply to Tina ZhangThe RGB 64-bit 16:16:16:16 float pixel format is needed by windows 10 guest VM. This patch is to add this pixel format support to gvt device model. Without this patch, some Apps, e.g. "DXGIGammaVM.exe", will crash and make guest screen black.
--- drivers/gpu/drm/i915/gvt/fb_decoder.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/gvt/fb_decoder.c +21 -7
@@ -52,6 +52,8 @@ static struct pixel_format bdw_pixel_formats[] = { {DRM_FORMAT_XRGB2101010, 32, "32-bit BGRX (2:10:10:10 MSB-X:R:G:B)"}, {DRM_FORMAT_XBGR8888, 32, "32-bit RGBX (8:8:8:8 MSB-X:B:G:R)"}, + {DRM_FORMAT_XRGB161616F, 64, + "64-bit XRGB Floating Point (16:16:16:16 MSB-X:R:G:B)"},/* non-supported format has bpp default to 0 */ {0, 0, NULL},
@@ -73,13 +75,18 @@ static struct pixel_format skl_pixel_formats[] = { {DRM_FORMAT_XBGR2101010, 32, "32-bit RGBX (2:10:10:10 MSB-X:B:G:R)"}, {DRM_FORMAT_XRGB2101010, 32, "32-bit BGRX (2:10:10:10 MSB-X:R:G:B)"}, + {DRM_FORMAT_XRGB161616F, 64, + "64-bit XRGB Floating Point (16:16:16:16 MSB-X:R:G:B)"}, + {DRM_FORMAT_XBGR161616F, 64, + "64-bit XBGR Floating Point (16:16:16:16 MSB-X:B:G:R)"}, +/* non-supported format has bpp default to 0 */ {0, 0, NULL}, };static int bdw_format_to_drm (int format) { -int bdw_pixel_formats_index =6 ; +int bdw_pixel_formats_index =7 ;switch (format) {case DISPPLANE_8BPP :
@@ -100,7 +107,9 @@ static int bdw_format_to_drm(int format)case DISPPLANE_RGBX888 : bdw_pixel_formats_index =5 ;break ; - +case DISPPLANE_RGBX161616 : + bdw_pixel_formats_index =6 ; +break ;default :break ; }
@@ -111,7 +120,7 @@ static int bdw_format_to_drm(int format)static int skl_format_to_drm (int format,bool rgb_order,bool alpha,int yuv_order) { -int skl_pixel_formats_index =12 ; +int skl_pixel_formats_index =14 ;switch (format) {case PLANE_CTL_FORMAT_INDEXED :
@@ -129,6 +138,9 @@ static int skl_format_to_drm(int format, bool rgb_order, bool alpha,case PLANE_CTL_FORMAT_XRGB_2101010 : skl_pixel_formats_index = rgb_order ?10 :11 ;break ; +case PLANE_CTL_FORMAT_XRGB_16161616F : + skl_pixel_formats_index = rgb_order ?12 :13 ; +break ;case PLANE_CTL_FORMAT_YUV422 : skl_pixel_formats_index = yuv_order >>16 ;if (skl_pixel_formats_index >3 )
@@ -389,11 +401,13 @@ int intel_vgpu_decode_cursor_plane(struct intel_vgpu *vgpu,#define SPRITE_FORMAT_NUM (1 << 3)static struct pixel_format sprite_pixel_formats[SPRITE_FORMAT_NUM ] = { - [0x0 ] = {DRM_FORMAT_YUV422 ,16 ,"YUV 16-bit 4:2:2 packed" }, - [0x1 ] = {DRM_FORMAT_XRGB2101010 ,32 ,"RGB 32-bit 2:10:10:10" }, - [0x2 ] = {DRM_FORMAT_XRGB8888 ,32 ,"RGB 32-bit 8:8:8:8" }, + [0x0 ] = {DRM_FORMAT_YUV422 ,16 ,"16-bit YUV 4:2:2 packed" }, + [0x1 ] = {DRM_FORMAT_XRGB2101010 ,32 ,"32-bit BGRX (2:10:10:10 MSB-X:R:G:B)" }, + [0x2 ] = {DRM_FORMAT_XRGB8888 ,32 ,"32-bit RGBX (8:8:8:8 MSB-X:B:G:R)" }, + [0x3 ] = {DRM_FORMAT_XRGB161616F ,64 , +"64-bit XRGB Floating Point (16:16:16:16 MSB-X:R:G:B)" }, [0x4 ] = {DRM_FORMAT_AYUV ,32 , -"YUV 32-bit 4:4:4 packed (8:8:8:8 MSB-X:Y:U:V)" }, +"32-bit YUV 4:4:4 packed (8:8:8:8 MSB-X:Y:U:V)" }, };/**
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v18 4/6 drm/i915/gvt: Add opregion support
In reply to Tina ZhangWindows guest driver needs vbt in opregion, to configure the setting for display. Without opregion support, the display registers won't be set and this blocks display model to get the correct information of the guest display plane.
This patch is to provide a virtual opregion for guest. Current implementation is to fill the virtual opregion with the content in host's opregion. The original author of this patch is Xiaoguang Chen.
v18:
- unmap vgpu's opregion when destroying vgpu.
v16:
- rebase to 4.14.0-rc6.
--- drivers/gpu/drm/i915/gvt/hypercall.h | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 104 ++++++++++++++++++++++++++++++++++- drivers/gpu/drm/i915/gvt/mpt.h | 15 +++++ drivers/gpu/drm/i915/gvt/opregion.c | 29 ++++++++-- drivers/gpu/drm/i915/gvt/vgpu.c | 4 ++ 5 files changed, 144 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/gvt/hypercall.h +1 -0
@@ -55,6 +55,7 @@ struct intel_gvt_mpt { unsigned long mfn, unsigned int nr, bool map);int (*set_trap_area)(unsigned long handle,u64 start,u64 end,bool map); +int (*set_opregion)(void *vgpu); };extern struct intel_gvt_mpt xengt_mpt;
drivers/gpu/drm/i915/gvt/kvmgt.c +101 -3
152 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/mpt.h +15 -0
@@ -294,4 +294,19 @@ static inline int intel_gvt_hypervisor_set_trap_area( return intel_gvt_host.mpt->set_trap_area(vgpu->handle, start, end, map); } +/** +* intel_gvt_hypervisor_set_opregion - Set opregion for guest +* @vgpu: a vGPU +* +* Returns: +* Zero on success, negative error code if failed. +*/ +static inline int intel_gvt_hypervisor_set_opregion (struct intel_vgpu *vgpu) +{ +if (!intel_gvt_host.mpt->set_opregion) +return 0 ; + +return intel_gvt_host.mpt->set_opregion (vgpu); +} +#endif /* _GVT_MPT_H_ */
drivers/gpu/drm/i915/gvt/opregion.c +23 -6
@@ -272,6 +272,9 @@ void intel_vgpu_clean_opregion(struct intel_vgpu *vgpu) get_order(INTEL_GVT_OPREGION_SIZE));vgpu_opregion (vgpu)->va =NULL ; + }else if (intel_gvt_host.hypervisor_type ==INTEL_GVT_HYPERVISOR_KVM ) { +memunmap (vgpu_opregion (vgpu)->va); +vgpu_opregion (vgpu)->va =NULL ; } }
@@ -285,23 +288,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
@@ -386,6 +386,10 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,if (ret) goto out_clean_sched_policy; + ret =intel_gvt_hypervisor_set_opregion (vgpu); +if (ret) + goto out_clean_sched_policy; +mutex_unlock (&gvt->lock);return vgpu;
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v18 5/6 vfio: ABI for mdev display dma-buf operation
In reply to Tina ZhangAdd VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user query and get a plane and its information. So far, two types of buffers are supported:
buffers based on dma-buf and buffers based on region.
This ioctl can be invoked with:
1) Either DMABUF or REGION flag. Vendor driver returns a plane_info successfully only when the specific kind of buffer is supported.
2) Flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver returns success only when the specific kind of buffer is supported.
Add VFIO_DEVICE_GET_GFX_DMABUF ioctl command to let user get a specific dma-buf fd of an exposed MDEV buffer provided by dmabuf_id which was returned in VFIO_DEVICE_QUERY_GFX_PLANE ioctl command.
The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned dmabuf_id in struct vfio_device_ query_gfx_plane can be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value of dmabuf_id to see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.
v18:
- update comments for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
v17:
- modify VFIO_DEVICE_GET_GFX_DMABUF interface. (Alex)
v16:
- add x_hot and y_hot fields. (Gerd)
- add comments for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.
v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)
v14:
- add PROBE, DMABUF and REGION flags. (Alex)
v12:
- add drm_format_mod back. (Gerd and Zhenyu)
- add region_index. (Gerd)
v11:
- rename plane_type to drm_plane_type. (Gerd)
- move fields of vfio_device_query_gfx_plane to vfio_device_gfx_plane_info. (Gerd)
- remove drm_format_mod, start fields. (Daniel)
- remove plane_id.
v10:
- refine the ABI API VFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)
v3:
- add a field gvt_plane_info in the drm_i915_gem_obj structure to save the decoded plane information to avoid look up while need the plane info. (Gerd)
--- include/uapi/linux/vfio.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
include/uapi/linux/vfio.h +62 -0
@@ -502,6 +502,68 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14, +* struct vfio_device_query_gfx_plane) +* +* Set the drm_plane_type and flags, then retrieve the gfx plane info. +* +* flags supported: +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set +* to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no +* support for dma-buf. +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set +* to ask if the mdev supports region. 0 on support, -EINVAL on no +* support for region. +* - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set +* with each call to query the plane info. +* - Others are invalid and return -EINVAL. +* +* Note: +* 1. Plane could be disabled by guest. In that case, success will be +* returned with zero-initialized drm_format, size, width and height +* fields. +* 2. x_hot/y_hot is set to 0xFFFFFFFF if no hotspot information available +* +* Return: 0 on success, -errno on other failure. +*/ +struct vfio_device_gfx_plane_info { +__u32 argsz; +__u32 flags; +#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) +#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) +#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2) +/* in */ +__u32 drm_plane_type;/* type of plane: DRM_PLANE_TYPE_* */ +/* out */ +__u32 drm_format;/* drm format of plane */ +__u64 drm_format_mod;/* tiled mode */ +__u32 width;/* width of plane */ +__u32 height;/* height of plane */ +__u32 stride;/* stride of plane */ +__u32 size;/* size of plane in bytes, align on page*/ +__u32 x_pos;/* horizontal position of cursor plane */ +__u32 y_pos;/* vertical position of cursor plane*/ +__u32 x_hot;/* horizontal position of cursor hotspot */ +__u32 y_hot;/* vertical position of cursor hotspot */ +union { +__u32 region_index;/* region index */ +__u32 dmabuf_id;/* dma-buf id */ + }; +}; + +#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) + +/** +* VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15, __u32) +* +* Return a new dma-buf file descriptor for an exposed guest framebuffer +* described by the provided dmabuf_id. The dmabuf_id is returned from VFIO_ +* DEVICE_QUERY_GFX_PLANE as a token of the exposed guest framebuffer. +*/ + +#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15) +/* -------- 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
Re: [PATCH v18 5/6] vfio: ABI for mdev display dma-buf operation
Quoted 15 lines · Tina Zhang
Add
VFIO_DEVICE_QUERY_GFX_PLANEioctl command to let user query and get a plane and its information. So far, two types of buffers are supported:
buffers based on dma-buf and buffers based on region.This ioctl can be invoked with:
1) Either DMABUF or REGION flag. Vendor driver returns aplane_infosuccessfully only when the specific kind of buffer is supported.
2) Flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver returns success only when the specific kind of buffer is supported.Add
VFIO_DEVICE_GET_GFX_DMABUFioctl command to let user get a specific dma-buf fd of an exposed MDEV buffer provided bydmabuf_idwhich was returned inVFIO_DEVICE_QUERY_GFX_PLANEioctl command.
Quoted 6 lines
The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned
dmabuf_idin structvfio_device_query_gfx_planecan be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value ofdmabuf_idto see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v18 5/6] vfio: ABI for mdev display dma-buf operation
In reply to Tina ZhangQuoted 129 lines · On Wed, 15 Nov 2017 17:11:54 +0800 Tina Zhang <[email protected]> wrote:
Add
VFIO_DEVICE_QUERY_GFX_PLANEioctl command to let user query and get a plane and its information. So far, two types of buffers are supported:
buffers based on dma-buf and buffers based on region.This ioctl can be invoked with:
1) Either DMABUF or REGION flag. Vendor driver returns aplane_infosuccessfully only when the specific kind of buffer is supported.
2) Flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver returns success only when the specific kind of buffer is supported.Add
VFIO_DEVICE_GET_GFX_DMABUFioctl command to let user get a specific dma-buf fd of an exposed MDEV buffer provided bydmabuf_idwhich was returned inVFIO_DEVICE_QUERY_GFX_PLANEioctl command.The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned
dmabuf_idin structvfio_device_query_gfx_planecan be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value ofdmabuf_idto see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.v18:
- update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)v17:
- modifyVFIO_DEVICE_GET_GFX_DMABUFinterface. (Alex)v16:
- addx_hotandy_hotfields. (Gerd)
- add comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)v14:
- add PROBE, DMABUF and REGION flags. (Alex)v12:
- adddrm_format_modback. (Gerd and Zhenyu)
- addregion_index. (Gerd)v11:
- renameplane_typetodrm_plane_type. (Gerd)
- move fields ofvfio_device_query_gfx_planetovfio_device_gfx_plane_info. (Gerd)
- removedrm_format_mod, start fields. (Daniel)
- removeplane_id.v10:
- refine the ABI APIVFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)v3:
- add a fieldgvt_plane_infoin thedrm_i915_gem_objstructure to save the decoded plane information to avoid look up while need the plane info. (Gerd)Signed-off-by Tina Zhang <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Alex Williamson <[email protected]>Cc Daniel Vetter <[email protected]>--- include/uapi/linux/vfio.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)include/uapi/linux/vfio.h +55
-0@@ -502,6 +502,68 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14, +* struct vfio_device_query_gfx_plane) +* +* Set the drm_plane_type and flags, then retrieve the gfx plane info. +* +* flags supported: +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set +* to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no +* support for dma-buf. +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set +* to ask if the mdev supports region. 0 on support, -EINVAL on no +* support for region. +* - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set +* with each call to query the plane info. +* - Others are invalid and return -EINVAL. +* +* Note: +* 1. Plane could be disabled by guest. In that case, success will be +* returned with zero-initialized drm_format, size, width and height +* fields. +* 2. x_hot/y_hot is set to 0xFFFFFFFF if no hotspot information available +* +* Return: 0 on success, -errno on other failure. +*/ +struct vfio_device_gfx_plane_info { +__u32 argsz; +__u32 flags; +#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) +#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) +#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2) +/* in */ +__u32 drm_plane_type;/* type of plane: DRM_PLANE_TYPE_* */ +/* out */ +__u32 drm_format;/* drm format of plane */ +__u64 drm_format_mod;/* tiled mode */ +__u32 width;/* width of plane */ +__u32 height;/* height of plane */ +__u32 stride;/* stride of plane */ +__u32 size;/* size of plane in bytes, align on page*/ +__u32 x_pos;/* horizontal position of cursor plane */ +__u32 y_pos;/* vertical position of cursor plane*/ +__u32 x_hot;/* horizontal position of cursor hotspot */ +__u32 y_hot;/* vertical position of cursor hotspot */ +union { +__u32 region_index;/* region index */ +__u32 dmabuf_id;/* dma-buf id */ + }; +}; + +#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) + +/** +* VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15, __u32) +*
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 569
Quoted 10 lines
include/uapi/linux/vfio.h +7
-0+* Return a new dma-buf file descriptor for an exposed guest framebuffer +* described by the provided dmabuf_id. The dmabuf_id is returned from VFIO_ +* DEVICE_QUERY_GFX_PLANE as a token of the exposed guest framebuffer. +*/ + +#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15) +/* -------- API for Type1 VFIO IOMMU -------- */ /**
Looks good to me. Kirti, have you had a chance yet to verify this is sufficient for your region-based approach? It would be great to get confirmation of that ASAP so we can get this in. Thanks,
Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v18 5/6] vfio: ABI for mdev display dma-buf operation
Quoted 141 lines · Alex Williamson
Quoted 138 lines · On Wed, 15 Nov 2017 17:11:54 +0800 Tina Zhang <[email protected]> wrote:
Add
VFIO_DEVICE_QUERY_GFX_PLANEioctl command to let user query and get a plane and its information. So far, two types of buffers are supported:
buffers based on dma-buf and buffers based on region.This ioctl can be invoked with:
1) Either DMABUF or REGION flag. Vendor driver returns aplane_infosuccessfully only when the specific kind of buffer is supported.
2) Flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver returns success only when the specific kind of buffer is supported.Add
VFIO_DEVICE_GET_GFX_DMABUFioctl command to let user get a specific dma-buf fd of an exposed MDEV buffer provided bydmabuf_idwhich was returned inVFIO_DEVICE_QUERY_GFX_PLANEioctl command.The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned
dmabuf_idin structvfio_device_query_gfx_planecan be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value ofdmabuf_idto see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.v18:
- update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)v17:
- modifyVFIO_DEVICE_GET_GFX_DMABUFinterface. (Alex)v16:
- addx_hotandy_hotfields. (Gerd)
- add comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)v14:
- add PROBE, DMABUF and REGION flags. (Alex)v12:
- adddrm_format_modback. (Gerd and Zhenyu)
- addregion_index. (Gerd)v11:
- renameplane_typetodrm_plane_type. (Gerd)
- move fields ofvfio_device_query_gfx_planetovfio_device_gfx_plane_info. (Gerd)
- removedrm_format_mod, start fields. (Daniel)
- removeplane_id.v10:
- refine the ABI APIVFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)v3:
- add a fieldgvt_plane_infoin thedrm_i915_gem_objstructure to save the decoded plane information to avoid look up while need the plane info. (Gerd)Signed-off-by Tina Zhang <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Alex Williamson <[email protected]>Cc Daniel Vetter <[email protected]>--- include/uapi/linux/vfio.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)include/uapi/linux/vfio.h +62
-0@@ -502,6 +502,68 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14, +* struct vfio_device_query_gfx_plane) +* +* Set the drm_plane_type and flags, then retrieve the gfx plane info. +* +* flags supported: +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set +* to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no +* support for dma-buf. +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set +* to ask if the mdev supports region. 0 on support, -EINVAL on no +* support for region. +* - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set +* with each call to query the plane info. +* - Others are invalid and return -EINVAL. +* +* Note: +* 1. Plane could be disabled by guest. In that case, success will be +* returned with zero-initialized drm_format, size, width and height +* fields. +* 2. x_hot/y_hot is set to 0xFFFFFFFF if no hotspot information available +* +* Return: 0 on success, -errno on other failure. +*/ +struct vfio_device_gfx_plane_info { +__u32 argsz; +__u32 flags; +#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) +#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) +#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2) +/* in */ +__u32 drm_plane_type;/* type of plane: DRM_PLANE_TYPE_* */ +/* out */ +__u32 drm_format;/* drm format of plane */ +__u64 drm_format_mod;/* tiled mode */ +__u32 width;/* width of plane */ +__u32 height;/* height of plane */ +__u32 stride;/* stride of plane */ +__u32 size;/* size of plane in bytes, align on page*/ +__u32 x_pos;/* horizontal position of cursor plane */ +__u32 y_pos;/* vertical position of cursor plane*/ +__u32 x_hot;/* horizontal position of cursor hotspot */ +__u32 y_hot;/* vertical position of cursor hotspot */ +union { +__u32 region_index;/* region index */ +__u32 dmabuf_id;/* dma-buf id */ + }; +}; + +#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) + +/** +* VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15, __u32) +* +* Return a new dma-buf file descriptor for an exposed guest framebuffer +* described by the provided dmabuf_id. The dmabuf_id is returned from VFIO_ +* DEVICE_QUERY_GFX_PLANE as a token of the exposed guest framebuffer. +*/ + +#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15) +/* -------- API for Type1 VFIO IOMMU -------- */
Quoted 6 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 569
Quoted 1 line
include/uapi/linux/vfio.h +0
-0/** Looks good to me. Kirti, have you had a chance yet to verify this is sufficient for your region-based approach? It would be great to get confirmation of that ASAP so we can get this in. Thanks,
Alex, do you mind by merging this just through gvt tree? Or you would like to merge this then send pull request for us then we can apply left?
Signature · 3 lines
Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v18 5/6] vfio: ABI for mdev display dma-buf operation
Quoted 149 lines · On Thu, 16 Nov 2017 11:21:56 +0800 Zhenyu Wang <[email protected]> wrote:
Quoted 141 lines · Alex Williamson
Quoted 138 lines · On Wed, 15 Nov 2017 17:11:54 +0800 Tina Zhang <[email protected]> wrote:
Add
VFIO_DEVICE_QUERY_GFX_PLANEioctl command to let user query and get a plane and its information. So far, two types of buffers are supported:
buffers based on dma-buf and buffers based on region.This ioctl can be invoked with:
1) Either DMABUF or REGION flag. Vendor driver returns aplane_infosuccessfully only when the specific kind of buffer is supported.
2) Flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver returns success only when the specific kind of buffer is supported.Add
VFIO_DEVICE_GET_GFX_DMABUFioctl command to let user get a specific dma-buf fd of an exposed MDEV buffer provided bydmabuf_idwhich was returned inVFIO_DEVICE_QUERY_GFX_PLANEioctl command.The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned
dmabuf_idin structvfio_device_query_gfx_planecan be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value ofdmabuf_idto see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.v18:
- update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)v17:
- modifyVFIO_DEVICE_GET_GFX_DMABUFinterface. (Alex)v16:
- addx_hotandy_hotfields. (Gerd)
- add comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)v14:
- add PROBE, DMABUF and REGION flags. (Alex)v12:
- adddrm_format_modback. (Gerd and Zhenyu)
- addregion_index. (Gerd)v11:
- renameplane_typetodrm_plane_type. (Gerd)
- move fields ofvfio_device_query_gfx_planetovfio_device_gfx_plane_info. (Gerd)
- removedrm_format_mod, start fields. (Daniel)
- removeplane_id.v10:
- refine the ABI APIVFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)v3:
- add a fieldgvt_plane_infoin thedrm_i915_gem_objstructure to save the decoded plane information to avoid look up while need the plane info. (Gerd)Signed-off-by Tina Zhang <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Alex Williamson <[email protected]>Cc Daniel Vetter <[email protected]>--- include/uapi/linux/vfio.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)include/uapi/linux/vfio.h +62
-0@@ -502,6 +502,68 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14, +* struct vfio_device_query_gfx_plane) +* +* Set the drm_plane_type and flags, then retrieve the gfx plane info. +* +* flags supported: +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set +* to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no +* support for dma-buf. +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set +* to ask if the mdev supports region. 0 on support, -EINVAL on no +* support for region. +* - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set +* with each call to query the plane info. +* - Others are invalid and return -EINVAL. +* +* Note: +* 1. Plane could be disabled by guest. In that case, success will be +* returned with zero-initialized drm_format, size, width and height +* fields. +* 2. x_hot/y_hot is set to 0xFFFFFFFF if no hotspot information available +* +* Return: 0 on success, -errno on other failure. +*/ +struct vfio_device_gfx_plane_info { +__u32 argsz; +__u32 flags; +#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) +#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) +#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2) +/* in */ +__u32 drm_plane_type;/* type of plane: DRM_PLANE_TYPE_* */ +/* out */ +__u32 drm_format;/* drm format of plane */ +__u64 drm_format_mod;/* tiled mode */ +__u32 width;/* width of plane */ +__u32 height;/* height of plane */ +__u32 stride;/* stride of plane */ +__u32 size;/* size of plane in bytes, align on page*/ +__u32 x_pos;/* horizontal position of cursor plane */ +__u32 y_pos;/* vertical position of cursor plane*/ +__u32 x_hot;/* horizontal position of cursor hotspot */ +__u32 y_hot;/* vertical position of cursor hotspot */ +union { +__u32 region_index;/* region index */ +__u32 dmabuf_id;/* dma-buf id */ + }; +}; + +#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) + +/** +* VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15, __u32) +* +* Return a new dma-buf file descriptor for an exposed guest framebuffer +* described by the provided dmabuf_id. The dmabuf_id is returned from VFIO_ +* DEVICE_QUERY_GFX_PLANE as a token of the exposed guest framebuffer. +*/ + +#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15) +/* -------- API for Type1 VFIO IOMMU -------- */ Quoted 6 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 569
Quoted 1 line
include/uapi/linux/vfio.h +0
-0/** Looks good to me. Kirti, have you had a chance yet to verify this is sufficient for your region-based approach? It would be great to get confirmation of that ASAP so we can get this in. Thanks,
Quoted 2 lines
Alex, do you mind by merging this just through gvt tree? Or you would like to merge this then send pull request for us then we can apply left?
I'm fine with this going through the gvt tree, but I want some confirmation from nvidia that this meets their needs as well before I provide an ack. Thanks,
Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v18 5/6] vfio: ABI for mdev display dma-buf operation
Kirti?
Quoted 152 lines · On Wed, 15 Nov 2017 21:11:42 -0700 Alex Williamson…
Quoted 149 lines · On Thu, 16 Nov 2017 11:21:56 +0800 Zhenyu Wang <[email protected]> wrote:
Quoted 147 lines · Alex Williamson
Quoted 129 lines · On Wed, 15 Nov 2017 17:11:54 +0800 Tina Zhang <[email protected]> wrote:
Add
VFIO_DEVICE_QUERY_GFX_PLANEioctl command to let user query and get a plane and its information. So far, two types of buffers are supported:
buffers based on dma-buf and buffers based on region.This ioctl can be invoked with:
1) Either DMABUF or REGION flag. Vendor driver returns aplane_infosuccessfully only when the specific kind of buffer is supported.
2) Flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver returns success only when the specific kind of buffer is supported.Add
VFIO_DEVICE_GET_GFX_DMABUFioctl command to let user get a specific dma-buf fd of an exposed MDEV buffer provided bydmabuf_idwhich was returned inVFIO_DEVICE_QUERY_GFX_PLANEioctl command.The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned
dmabuf_idin structvfio_device_query_gfx_planecan be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value ofdmabuf_idto see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.v18:
- update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)v17:
- modifyVFIO_DEVICE_GET_GFX_DMABUFinterface. (Alex)v16:
- addx_hotandy_hotfields. (Gerd)
- add comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)v14:
- add PROBE, DMABUF and REGION flags. (Alex)v12:
- adddrm_format_modback. (Gerd and Zhenyu)
- addregion_index. (Gerd)v11:
- renameplane_typetodrm_plane_type. (Gerd)
- move fields ofvfio_device_query_gfx_planetovfio_device_gfx_plane_info. (Gerd)
- removedrm_format_mod, start fields. (Daniel)
- removeplane_id.v10:
- refine the ABI APIVFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)v3:
- add a fieldgvt_plane_infoin thedrm_i915_gem_objstructure to save the decoded plane information to avoid look up while need the plane info. (Gerd)Signed-off-by Tina Zhang <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Alex Williamson <[email protected]>Cc Daniel Vetter <[email protected]>--- include/uapi/linux/vfio.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)include/uapi/linux/vfio.h +55
-0@@ -502,6 +502,68 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14, +* struct vfio_device_query_gfx_plane) +* +* Set the drm_plane_type and flags, then retrieve the gfx plane info. +* +* flags supported: +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set +* to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no +* support for dma-buf. +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set +* to ask if the mdev supports region. 0 on support, -EINVAL on no +* support for region. +* - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set +* with each call to query the plane info. +* - Others are invalid and return -EINVAL. +* +* Note: +* 1. Plane could be disabled by guest. In that case, success will be +* returned with zero-initialized drm_format, size, width and height +* fields. +* 2. x_hot/y_hot is set to 0xFFFFFFFF if no hotspot information available +* +* Return: 0 on success, -errno on other failure. +*/ +struct vfio_device_gfx_plane_info { +__u32 argsz; +__u32 flags; +#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) +#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) +#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2) +/* in */ +__u32 drm_plane_type;/* type of plane: DRM_PLANE_TYPE_* */ +/* out */ +__u32 drm_format;/* drm format of plane */ +__u64 drm_format_mod;/* tiled mode */ +__u32 width;/* width of plane */ +__u32 height;/* height of plane */ +__u32 stride;/* stride of plane */ +__u32 size;/* size of plane in bytes, align on page*/ +__u32 x_pos;/* horizontal position of cursor plane */ +__u32 y_pos;/* vertical position of cursor plane*/ +__u32 x_hot;/* horizontal position of cursor hotspot */ +__u32 y_hot;/* vertical position of cursor hotspot */ +union { +__u32 region_index;/* region index */ +__u32 dmabuf_id;/* dma-buf id */ + }; +}; + +#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) + +/** +* VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15, __u32) +* include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 569
Quoted 10 lines
include/uapi/linux/vfio.h +7
-0+* Return a new dma-buf file descriptor for an exposed guest framebuffer +* described by the provided dmabuf_id. The dmabuf_id is returned from VFIO_ +* DEVICE_QUERY_GFX_PLANE as a token of the exposed guest framebuffer. +*/ + +#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15) +/* -------- API for Type1 VFIO IOMMU -------- */ /** Looks good to me. Kirti, have you had a chance yet to verify this is sufficient for your region-based approach? It would be great to get confirmation of that ASAP so we can get this in. Thanks,
Quoted 8 lines
Quoted 2 lines
Alex, do you mind by merging this just through gvt tree? Or you would like to merge this then send pull request for us then we can apply left?
I'm fine with this going through the gvt tree, but I want some confirmation from nvidia that this meets their needs as well before I provide an ack. Thanks,
Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Kirti Wankhede
Reviewed-byRe: [PATCH v18 5/6] vfio: ABI for mdev display dma-buf operation
Extremely sorry for the delay.
This works for VFIO_GFX_PLANE_TYPE_REGION. Tested with local changes.
Thanks,
Kirti
Quoted 166 lines · Alex Williamson
Kirti?
Quoted 160 lines · On Wed, 15 Nov 2017 21:11:42 -0700 Alex Williamson…
Quoted 149 lines · On Thu, 16 Nov 2017 11:21:56 +0800 Zhenyu Wang <[email protected]> wrote:
Quoted 141 lines · Alex Williamson
Quoted 138 lines · On Wed, 15 Nov 2017 17:11:54 +0800 Tina Zhang <[email protected]> wrote:
Add
VFIO_DEVICE_QUERY_GFX_PLANEioctl command to let user query and get a plane and its information. So far, two types of buffers are supported:
buffers based on dma-buf and buffers based on region.This ioctl can be invoked with:
1) Either DMABUF or REGION flag. Vendor driver returns aplane_infosuccessfully only when the specific kind of buffer is supported.
2) Flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver returns success only when the specific kind of buffer is supported.Add
VFIO_DEVICE_GET_GFX_DMABUFioctl command to let user get a specific dma-buf fd of an exposed MDEV buffer provided bydmabuf_idwhich was returned inVFIO_DEVICE_QUERY_GFX_PLANEioctl command.The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned
dmabuf_idin structvfio_device_query_gfx_planecan be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value ofdmabuf_idto see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.v18:
- update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)v17:
- modifyVFIO_DEVICE_GET_GFX_DMABUFinterface. (Alex)v16:
- addx_hotandy_hotfields. (Gerd)
- add comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)v14:
- add PROBE, DMABUF and REGION flags. (Alex)v12:
- adddrm_format_modback. (Gerd and Zhenyu)
- addregion_index. (Gerd)v11:
- renameplane_typetodrm_plane_type. (Gerd)
- move fields ofvfio_device_query_gfx_planetovfio_device_gfx_plane_info. (Gerd)
- removedrm_format_mod, start fields. (Daniel)
- removeplane_id.v10:
- refine the ABI APIVFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)v3:
- add a fieldgvt_plane_infoin thedrm_i915_gem_objstructure to save the decoded plane information to avoid look up while need the plane info. (Gerd)Signed-off-by Tina Zhang <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Alex Williamson <[email protected]>Cc Daniel Vetter <[email protected]>--- include/uapi/linux/vfio.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)include/uapi/linux/vfio.h +62
-0@@ -502,6 +502,68 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14, +* struct vfio_device_query_gfx_plane) +* +* Set the drm_plane_type and flags, then retrieve the gfx plane info. +* +* flags supported: +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set +* to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no +* support for dma-buf. +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set +* to ask if the mdev supports region. 0 on support, -EINVAL on no +* support for region. +* - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set +* with each call to query the plane info. +* - Others are invalid and return -EINVAL. +* +* Note: +* 1. Plane could be disabled by guest. In that case, success will be +* returned with zero-initialized drm_format, size, width and height +* fields. +* 2. x_hot/y_hot is set to 0xFFFFFFFF if no hotspot information available +* +* Return: 0 on success, -errno on other failure. +*/ +struct vfio_device_gfx_plane_info { +__u32 argsz; +__u32 flags; +#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) +#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) +#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2) +/* in */ +__u32 drm_plane_type;/* type of plane: DRM_PLANE_TYPE_* */ +/* out */ +__u32 drm_format;/* drm format of plane */ +__u64 drm_format_mod;/* tiled mode */ +__u32 width;/* width of plane */ +__u32 height;/* height of plane */ +__u32 stride;/* stride of plane */ +__u32 size;/* size of plane in bytes, align on page*/ +__u32 x_pos;/* horizontal position of cursor plane */ +__u32 y_pos;/* vertical position of cursor plane*/ +__u32 x_hot;/* horizontal position of cursor hotspot */ +__u32 y_hot;/* vertical position of cursor hotspot */ +union { +__u32 region_index;/* region index */ +__u32 dmabuf_id;/* dma-buf id */ + }; +}; + +#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) + +/** +* VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15, __u32) +* +* Return a new dma-buf file descriptor for an exposed guest framebuffer +* described by the provided dmabuf_id. The dmabuf_id is returned from VFIO_ +* DEVICE_QUERY_GFX_PLANE as a token of the exposed guest framebuffer. +*/ + +#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15) +/* -------- API for Type1 VFIO IOMMU -------- */ Quoted 6 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 569
Quoted 1 line
include/uapi/linux/vfio.h +0
-0/** Looks good to me. Kirti, have you had a chance yet to verify this is sufficient for your region-based approach? It would be great to get confirmation of that ASAP so we can get this in. Thanks,
Quoted 2 lines
Alex, do you mind by merging this just through gvt tree? Or you would like to merge this then send pull request for us then we can apply left?
I'm fine with this going through the gvt tree, but I want some confirmation from nvidia that this meets their needs as well before I provide an ack. Thanks,
Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Alex Williamson
Acked-byRe: [PATCH v18 5/6] vfio: ABI for mdev display dma-buf operation
Quoted 4 lines · On Sat, 18 Nov 2017 23:29:31 +0530 Kirti Wankhede <[email protected]> wrote:
Extremely sorry for the delay.
This works forVFIO_GFX_PLANE_TYPE_REGION. Tested with local changes.Reviewed-by Kirti Wankhede <[email protected]>
With that,
Quoted 159 lines · Alex Williamson
Quoted 158 lines
Kirti?
Quoted 152 lines · On Wed, 15 Nov 2017 21:11:42 -0700 Alex Williamson…
Quoted 149 lines · On Thu, 16 Nov 2017 11:21:56 +0800 Zhenyu Wang <[email protected]> wrote:
Quoted 147 lines · Alex Williamson
Quoted 129 lines · On Wed, 15 Nov 2017 17:11:54 +0800 Tina Zhang <[email protected]> wrote:
Add
VFIO_DEVICE_QUERY_GFX_PLANEioctl command to let user query and get a plane and its information. So far, two types of buffers are supported:
buffers based on dma-buf and buffers based on region.This ioctl can be invoked with:
1) Either DMABUF or REGION flag. Vendor driver returns aplane_infosuccessfully only when the specific kind of buffer is supported.
2) Flag PROBE. And at the same time either DMABUF or REGION must be set, so that vendor driver returns success only when the specific kind of buffer is supported.Add
VFIO_DEVICE_GET_GFX_DMABUFioctl command to let user get a specific dma-buf fd of an exposed MDEV buffer provided bydmabuf_idwhich was returned inVFIO_DEVICE_QUERY_GFX_PLANEioctl command.The life cycle of an exposed MDEV buffer is handled by userspace and tracked by kernel space. The returned
dmabuf_idin structvfio_device_query_gfx_planecan be a new id of a new exposed buffer or an old id of a re-exported buffer. Host user can check the value ofdmabuf_idto see if it needs to create new resources according to the new exposed buffer or just re-use the existing resource related to the old buffer.v18:
- update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)v17:
- modifyVFIO_DEVICE_GET_GFX_DMABUFinterface. (Alex)v16:
- addx_hotandy_hotfields. (Gerd)
- add comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase to 4.14.0-rc6.v15:
- add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)v14:
- add PROBE, DMABUF and REGION flags. (Alex)v12:
- adddrm_format_modback. (Gerd and Zhenyu)
- addregion_index. (Gerd)v11:
- renameplane_typetodrm_plane_type. (Gerd)
- move fields ofvfio_device_query_gfx_planetovfio_device_gfx_plane_info. (Gerd)
- removedrm_format_mod, start fields. (Daniel)
- removeplane_id.v10:
- refine the ABI APIVFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)v3:
- add a fieldgvt_plane_infoin thedrm_i915_gem_objstructure to save the decoded plane information to avoid look up while need the plane info. (Gerd)Signed-off-by Tina Zhang <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Alex Williamson <[email protected]>Cc Daniel Vetter <[email protected]>--- include/uapi/linux/vfio.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)include/uapi/linux/vfio.h +55
-0@@ -502,6 +502,68 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14, +* struct vfio_device_query_gfx_plane) +* +* Set the drm_plane_type and flags, then retrieve the gfx plane info. +* +* flags supported: +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set +* to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no +* support for dma-buf. +* - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set +* to ask if the mdev supports region. 0 on support, -EINVAL on no +* support for region. +* - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set +* with each call to query the plane info. +* - Others are invalid and return -EINVAL. +* +* Note: +* 1. Plane could be disabled by guest. In that case, success will be +* returned with zero-initialized drm_format, size, width and height +* fields. +* 2. x_hot/y_hot is set to 0xFFFFFFFF if no hotspot information available +* +* Return: 0 on success, -errno on other failure. +*/ +struct vfio_device_gfx_plane_info { +__u32 argsz; +__u32 flags; +#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) +#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) +#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2) +/* in */ +__u32 drm_plane_type;/* type of plane: DRM_PLANE_TYPE_* */ +/* out */ +__u32 drm_format;/* drm format of plane */ +__u64 drm_format_mod;/* tiled mode */ +__u32 width;/* width of plane */ +__u32 height;/* height of plane */ +__u32 stride;/* stride of plane */ +__u32 size;/* size of plane in bytes, align on page*/ +__u32 x_pos;/* horizontal position of cursor plane */ +__u32 y_pos;/* vertical position of cursor plane*/ +__u32 x_hot;/* horizontal position of cursor hotspot */ +__u32 y_hot;/* vertical position of cursor hotspot */ +union { +__u32 region_index;/* region index */ +__u32 dmabuf_id;/* dma-buf id */ + }; +}; + +#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) + +/** +* VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15, __u32) +* include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 569
Quoted 10 lines
include/uapi/linux/vfio.h +7
-0+* Return a new dma-buf file descriptor for an exposed guest framebuffer +* described by the provided dmabuf_id. The dmabuf_id is returned from VFIO_ +* DEVICE_QUERY_GFX_PLANE as a token of the exposed guest framebuffer. +*/ + +#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15) +/* -------- API for Type1 VFIO IOMMU -------- */ /** Looks good to me. Kirti, have you had a chance yet to verify this is sufficient for your region-based approach? It would be great to get confirmation of that ASAP so we can get this in. Thanks,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Alex, do you mind by merging this just through gvt tree? Or you would like to merge this then send pull request for us then we can apply left?
I'm fine with this going through the gvt tree, but I want some confirmation from nvidia that this meets their needs as well before I provide an ack. Thanks,
Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v18 6/6 drm/i915/gvt: Dmabuf support for GVT-g
In reply to Tina ZhangThis 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.
v17:
- modify VFIO_DEVICE_GET_GFX_DMABUF interface. (Alex)
v16:
- add x_hot and y_hot. (Gerd)
- add flag validation for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
- rebase 4.14.0-rc6.
v15:
- add VFIO_DEVICE_GET_GFX_DMABUF ABI. (Gerd)
- add intel_vgpu_dmabuf_cleanup() to clean up the vGPU's dmabuf. (Gerd)
v14:
- add PROBE, DMABUF and REGION flags. (Alex)
v12:
- refine the lifecycle of dmabuf.
v9:
- remove dma-buf management. (Alex)
- track the dma-buf create and release in kernel mode. (Gerd) (Daniel)
v8:
- refine the dma-buf ioctl definition.(Alex)
- add a lock to protect the dmabuf list. (Alex)
v7:
- release dma-buf related allocations in dma-buf's associated release function. (Alex)
- refine ioctl interface for querying plane info or create dma-buf. (Alex)
v6:
- align the dma-buf life cycle with the vfio device. (Alex)
- add the dma-buf related operations in a separate patch. (Gerd)
- i915 related changes. (Chris)
v5:
- fix bug while checking whether the gem obj is gvt's dma-buf when user change caching mode or domains. Add a helper function to do it. (Xiaoguang)
- add definition for the query plane and create dma-buf. (Xiaoguang)
v4:
- fix bug while checking whether the gem obj is gvt's dma-buf when set caching mode or doamins. (Xiaoguang)
v3:
- declare a new flag I915_GEM_OBJECT_IS_GVT_DMABUF in drm_i915_gem_object to represent the gem obj for gvt's dma-buf. The tiling mode, caching mode and domains can not be changed for this kind of gem object. (Alex)
- change dma-buf related information to be more generic. So other vendor can use the same interface. (Alex)
v2:
- create a management fd for dma-buf operations. (Alex)
- alloc gem object's backing storage in gem obj's get_pages() callback. (Chris)
--- drivers/gpu/drm/i915/gvt/Makefile | 2 +- drivers/gpu/drm/i915/gvt/dmabuf.c | 523 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/dmabuf.h | 67 +++++ drivers/gpu/drm/i915/gvt/gvt.c | 2 + drivers/gpu/drm/i915/gvt/gvt.h | 11 + drivers/gpu/drm/i915/gvt/hypercall.h | 2 + drivers/gpu/drm/i915/gvt/kvmgt.c | 53 ++++ drivers/gpu/drm/i915/gvt/mpt.h | 30 ++ drivers/gpu/drm/i915/gvt/vgpu.c | 5 +- drivers/gpu/drm/i915/i915_gem_object.h | 2 + 10 files changed, 695 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
@@ -2,7 +2,7 @@ GVT_DIR := gvt GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \ interrupt.o gtt.o cfg_space.o opregion.o mmio.o display.o edid.o \ execlist.o scheduler.o sched_policy.o render.o cmd_parser.o debugfs.o \ - fb_decoder.o + fb_decoder.o dmabuf.o ccflags-y += -I$(src) -I$(src)/$(GVT_DIR) i915-y += $(addprefix $(GVT_DIR)/, $(GVT_SOURCE))
drivers/gpu/drm/i915/gvt/dmabuf.c new file +523 -0
523 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/dmabuf.h new file +67 -0
67 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/gvt.c +2 -0
@@ -181,6 +181,8 @@ static const struct intel_gvt_ops intel_gvt_ops = { .vgpu_deactivate = intel_gvt_deactivate_vgpu, .gvt_find_vgpu_type = intel_gvt_find_vgpu_type, .get_gvt_attrs = intel_get_gvt_attrs, + .vgpu_query_plane = intel_vgpu_query_plane, + .vgpu_get_dmabuf = intel_vgpu_get_dmabuf, };/**
drivers/gpu/drm/i915/gvt/gvt.h +11 -0
@@ -47,6 +47,7 @@#include "render.h" #include "cmd_parser.h" #include "fb_decoder.h" +#include "dmabuf.h" #define GVT_MAX_VGPU 8
@@ -208,8 +209,16 @@ struct intel_vgpu {struct kvm *kvm;struct work_struct release_work;atomic_t released; + struct vfio_device *vfio_device; } vdev;#endif + +struct list_head dmabuf_obj_list_head; +struct mutex dmabuf_lock; +struct idr object_idr; + +struct completion vblank_done; + };/* validating GM healthy status*/
@@ -543,6 +552,8 @@ struct intel_gvt_ops { const char *name);bool (*get_gvt_attrs)(struct attribute ***type_attrs,struct attribute_group ***intel_vgpu_type_groups); +int (*vgpu_query_plane)(struct intel_vgpu *vgpu,void *); +int (*vgpu_get_dmabuf)(struct intel_vgpu *vgpu,unsigned int ); };
drivers/gpu/drm/i915/gvt/hypercall.h +2 -0
@@ -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 +53 -0
87 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/mpt.h +30 -0
@@ -309,4 +309,34 @@ static inline int intel_gvt_hypervisor_set_opregion(struct intel_vgpu *vgpu) return intel_gvt_host.mpt->set_opregion(vgpu); } +/** +* intel_gvt_hypervisor_get_vfio_device - increase vfio device ref count +* @vgpu: a vGPU +* +* Returns: +* Zero on success, negative error code if failed. +*/ +static inline int intel_gvt_hypervisor_get_vfio_device (struct intel_vgpu *vgpu) +{ +if (!intel_gvt_host.mpt->get_vfio_device) +return 0 ; + +return intel_gvt_host.mpt->get_vfio_device (vgpu); +} + +/** +* intel_gvt_hypervisor_put_vfio_device - decrease vfio device ref count +* @vgpu: a vGPU +* +* Returns: +* Zero on success, negative error code if failed. +*/ +static inline void intel_gvt_hypervisor_put_vfio_device (struct intel_vgpu *vgpu) +{ +if (!intel_gvt_host.mpt->put_vfio_device) +return ; + + intel_gvt_host.mpt->put_vfio_device (vgpu); +} +#endif /* _GVT_MPT_H_ */
drivers/gpu/drm/i915/gvt/vgpu.c +4 -1
@@ -236,6 +236,7 @@ void intel_gvt_deactivate_vgpu(struct intel_vgpu *vgpu) }intel_vgpu_stop_schedule (vgpu); +intel_vgpu_dmabuf_cleanup (vgpu);mutex_unlock (&gvt->lock); }
@@ -265,6 +266,7 @@ void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu)intel_gvt_hypervisor_detach_vgpu (vgpu);intel_vgpu_free_resource (vgpu);intel_vgpu_clean_mmio (vgpu); +intel_vgpu_dmabuf_cleanup (vgpu);vfree (vgpu);intel_gvt_update_vgpu_types (gvt);
@@ -349,7 +351,8 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt, vgpu->handle = param->handle; vgpu->gvt = gvt; vgpu->sched_ctl.weight = param->weight; - +INIT_LIST_HEAD (&vgpu->dmabuf_obj_list_head); +idr_init (&vgpu->object_idr);intel_vgpu_init_cfg_space (vgpu, param->primary); ret =intel_vgpu_init_mmio (vgpu);
drivers/gpu/drm/i915/i915_gem_object.h +2 -0
@@ -260,6 +260,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
Patchwork
CI✗ Fi.CI.BAT: failure for drm/i915/gvt: Dma-buf support for GVT-g
In reply to Tina Zhang== Series Details ==
== Series Details ==
Series: drm/i915/gvt: Dma-buf support for GVT-g
URL : https://patchwork.freedesktop.org/series/33854/
State : failure
== Summary ==
Series 33854 revision 1 was fully merged or fully failed: no git log
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 15 lines · Tina Zhang
v17->v18:
1) unmap vgpu's opregion when destroying vgpu.
2) update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)This patch set adds the dma-buf support for intel GVT-g.
dma-buf is an uniform mechanism to share DMA buffers across different devices and subsystems. dma-buf for intel GVT-g is mainly used to share the vgpu's framebuffer to userspace to leverage userspace graphics stacks to render the framebuffer to the display monitor.
The main idea is that we create a gem object and set vgpu's framebuffer as its backing storage. Then, export a dma-buf associated with this gem object. With the fd of this dma-buf, userspace can directly handle this buffer.
Quoted 5 lines
This patch set can be tried with the following example:
git://git.kraxel.org/qemubranch: work/intel-vgpuA topic branch with the latest patch set is:
https://github.com/intel/gvt-linux.git branch: topic/dmabuf
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 16 lines · On Wed, 15 Nov 2017 11:49:00 +0100 Gerd Hoffmann <[email protected]> wrote:
Quoted 15 lines · Tina Zhang
v17->v18:
1) unmap vgpu's opregion when destroying vgpu.
2) update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)This patch set adds the dma-buf support for intel GVT-g.
dma-buf is an uniform mechanism to share DMA buffers across different devices and subsystems. dma-buf for intel GVT-g is mainly used to share the vgpu's framebuffer to userspace to leverage userspace graphics stacks to render the framebuffer to the display monitor.
The main idea is that we create a gem object and set vgpu's framebuffer as its backing storage. Then, export a dma-buf associated with this gem object. With the fd of this dma-buf, userspace can directly handle this buffer.
Quoted 7 lines
Quoted 5 lines
This patch set can be tried with the following example:
git://git.kraxel.org/qemubranch: work/intel-vgpuA topic branch with the latest patch set is:
https://github.com/intel/gvt-linux.git branch: topic/dmabufTested-by Gerd Hoffmann <[email protected]>
Hi Gerd,
Can you share the xml snippets required for the VM to make this work? Last I tried I couldn't get the display/video/hostdev configuration to get any enhanced behavior through the dmabuf. Thanks,
Alex
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines
Quoted 5 lines
Quoted 3 lines
This patch set can be tried with the following example:
git://git.kraxel.org/qemubranch: work/intel-vgpuTested-by Gerd Hoffmann <[email protected]>Hi Gerd,
Can you share the xml snippets required for the VM to make this work? Last I tried I couldn't get the display/video/hostdev configuration to get any enhanced behavior through the dmabuf. Thanks,
qemu built from the branch listed above.
Testing with a shell script right now, see below. First argument is the mode. "vgpu-gtk" works fine. "vgpu-spice-remote" works too, even remotely, but it's not very efficient (grabs display data via opengl ReadPixels, then sends it over classic spice protocol).
For the latter I have a libvirt snippet too, which has to jump through a few loops due to libvirt not having support for vgou display yet, with the most annonying issue being that libvirt insists adding a emulated vga to the guest if you configure spice.
HTH,
Gerd
====================== cut here ==================== #!/bin/sh
# args
mode="${1-vga}"; shift# config
vers="26"
live="$(ls -t $HOME/iso/Fedora*Live*${vers}*.iso | head -1)"
name="$(basename $live)"
qemu="/usr/local/bin/qemu-system-x86_64"
uuid="aca92d96-6654-43d9-8f45-544c19e89f20"
path="/sys/bus/mdev/devices/${uuid}"###########################################################################
# tweaks
case "$mode" in
vga)
args="-vga std"
;;
virtio)
args="-vga virtio"
;;
virtio-gl)
args=""
args="$args -vga virtio"
args="$args -display gtk,gl=on"
;;
vgpu-gtk)
args=""
args="$args -vga none"
args="$args -display gtk,gl=on"
args="$args -device vfio-pci,sysfsdev=${path},addr=0x5,x-display=on"
qemu="sudo $qemu"
;;
vgpu-sdl)
# intel sdl 1.2 patches ...
args=""
args="$args -vga none"
args="$args -display sdl"
args="$args -device vfio-pci,sysfsdev=${path},addr=0x5"
qemu="sudo $qemu"
;;
vgpu-spice-local)
# using spice, passing around dma-bufs
# FIXME: launch remote-viewer on unix socket
args=""
args="$args -vga none"
args="$args -spice disable-ticketing,gl=on,unix,addr=/tmp/spice-vgpu"
args="$args -device vfio-pci,sysfsdev=${path},addr=0x5,x-display=on"
qemu="sudo $qemu"
;;
vgpu-spice-remote)
# using spice, readpixels dmabuf,
# send traditional spice display updates
(sleep 1; remote-viewer spice://localhost:5909) &
args=""
args="$args -vga none"
args="$args -display egl-headless"
args="$args -spice disable-ticketing,gl=off,port=5909"
args="$args -device vfio-pci,sysfsdev=${path},addr=0x5,x-display=on"
qemu="sudo $qemu"
;;
*)
echo "unknown mode: $mode"
echo "valid modes:"
echo " vga virtio virtio-gl vgpu-gtk vgpu-sdl"
echo " vgpu-spice-local vgpu-spice-remote"
exit 1
;;
esac###########################################################################
# go!
set -ex
exec $qemu -enable-kvm -name "$name" \ -boot menu=on -m 2G -usb \ -drive if=none,id=live,media=cdrom,file="$live" \ -netdev user,id=unet \ \ -device virtio-net-pci,addr=0x08,netdev=unet \ -device virtio-scsi-pci,addr=0x09 \ -device scsi-cd,drive=live,scsi-id=4,bootindex=1 \ -device usb-tablet \ \ $args "$@"
====================== cut here ====================
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>liveiso-vgpu-remote</name> <uuid>a2fc1e5e-8370-44b2-a31f-140f441e0355</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-2.8'>hvm</type>
<bootmenu enable='yes'/>
<bios useserial='yes'/>
</os>
<features>
<acpi/>
<apic/>
<vmport state='off'/>
</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Broadwell</model>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/local/bin/qemu-system-x86_64</emulator>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw' cache='none' io='native'/>
<source file='/home/kraxel/iso/Fedora-Workstation-Live-x86_64-26-1.5.iso'/>
<target dev='sda' bus='scsi'/>
<readonly/>
<boot order='1'/>
<address type='drive' controller='0' bus='0' target='4' unit='0'/>
</disk>
<controller type='pci' index='0' model='pci-root'/>
<controller type='scsi' index='0' model='virtio-scsi'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</controller>
<controller type='usb' index='0' model='nec-xhci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x14' function='0x0'/>
</controller>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</controller>
<interface type='network'>
<mac address='52:54:00:28:99:99'/>
<source network='bios'/>
<model type='virtio'/>
<boot order='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<input type='tablet' bus='usb'>
<address type='usb' bus='0' port='1'/>
</input>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='spice' autoport='yes'>
<listen type='address'/>
</graphics>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x19' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='16384' heads='1' primary='yes'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci'>
<source>
<address uuid='aca92d96-6654-43d9-8f45-544c19e89f20'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</hostdev>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
</memballoon>
</devices>
<qemu:commandline>
<qemu:arg value='-set'/>
<qemu:arg value='device.video0.driver=ne2k_pci'/>
<qemu:arg value='-set'/>
<qemu:arg value='device.hostdev0.x-display=yes'/>
<qemu:arg value='-display'/>
<qemu:arg value='egl-headless'/> </qemu:commandline>
</domain>
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 16 lines · Gerd Hoffmann
Quoted 15 lines · Tina Zhang
v17->v18:
1) unmap vgpu's opregion when destroying vgpu.
2) update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)This patch set adds the dma-buf support for intel GVT-g.
dma-buf is an uniform mechanism to share DMA buffers across different devices and subsystems. dma-buf for intel GVT-g is mainly used to share the vgpu's framebuffer to userspace to leverage userspace graphics stacks to render the framebuffer to the display monitor.
The main idea is that we create a gem object and set vgpu's framebuffer as its backing storage. Then, export a dma-buf associated with this gem object. With the fd of this dma-buf, userspace can directly handle this buffer.
Quoted 8 lines
Quoted 5 lines
This patch set can be tried with the following example:
git://git.kraxel.org/qemubranch: work/intel-vgpuA topic branch with the latest patch set is:
https://github.com/intel/gvt-linux.git branch: topic/dmabufTested-by Gerd Hoffmann <[email protected]>
After debugging with Tina on one left race that fixed by
https://lists.freedesktop.org/archives/intel-gvt-dev/2017-November/002505.html
I still need below qemu fix for proper cursor handling, otherwise qemu just crashed when I click in my terminal program which hides cursor then.
hw/vfio/display.c +3 -2
@@ -169,8 +169,9 @@ static void vfio_display_dmabuf_update(void *opaque) cursor =vfio_display_get_dmabuf (vdev,DRM_PLANE_TYPE_CURSOR );if (vdev->cursor != cursor) { vdev->cursor = cursor; -dpy_gl_cursor_dmabuf (vdev->display_con, - &cursor->buf); +if (cursor) +dpy_gl_cursor_dmabuf (vdev->display_con, + &cursor->buf); free_bufs = true; }if (cursor !=NULL ) {
And with these it seems pretty fine now that I'll queue them up for -next pull.
thanks
Signature · 3 lines
Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 40 lines
-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Zhenyu Wang
Sent: Thursday, November 23, 2017 2:13 PM
To: Gerd Hoffmann <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; intel- [email protected]; [email protected]; Wang, Zhi A <[email protected]>; [email protected]; [email protected]; Zhang, Tina <[email protected]>; [email protected]; Lv, Zhiyuan <[email protected]>; [email protected]; [email protected]; [email protected]; Yuan, Hang <[email protected]>
Subject: Re: [PATCH v18 0/6] drm/i915/gvt: Dma-buf support for GVT-gQuoted 7 lines · Gerd Hoffmann
Quoted 6 lines · Tina Zhang
v17->v18:
1) unmap vgpu's opregion when destroying vgpu.
2) update comments forVFIO_DEVICE_GET_GFX_DMABUF. (Alex)This patch set adds the dma-buf support for intel GVT-g.
Quoted 7 lines
Quoted 7 lines
dma-buf is an uniform mechanism to share DMA buffers across different devices and subsystems. dma-buf for intel GVT-g is mainly used to share the vgpu's framebuffer to userspace to leverage userspace graphics stacks to render the framebuffer to the display monitor.
The main idea is that we create a gem object and set vgpu's framebuffer as its backing storage. Then, export a dma-buf associated with
this gem object.
Quoted 8 lines
Quoted 7 lines
With the fd of this dma-buf, userspace can directly handle this buffer.
This patch set can be tried with the following example:
git://git.kraxel.org/qemubranch: work/intel-vgpuA topic branch with the latest patch set is:
https://github.com/intel/gvt-linux.git branch: topic/dmabuf
Quoted 6 lines
Quoted 2 lines
Tested-by Gerd Hoffmann <[email protected]>After debugging with Tina on one left race that fixed by
https://lists.freedesktop.org/archives/intel-gvt-dev/2017-
November/002505.html
The next version of this patch set will include this patch. Thanks.
BR,
Tina
Quoted 29 lines
I still need below qemu fix for proper cursor handling, otherwise qemu just crashed when I click in my terminal program which hides cursor then.
hw/vfio/display.c index renamed from hw/vfio/display.c +0
-0
e500ec2cb1..d9a044b080100644hw/vfio/display.c +3
-2@@ -169,8 +169,9 @@ static void vfio_display_dmabuf_update(void *opaque) cursor =vfio_display_get_dmabuf (vdev,DRM_PLANE_TYPE_CURSOR );if (vdev->cursor != cursor) { vdev->cursor = cursor; -dpy_gl_cursor_dmabuf (vdev->display_con, - &cursor->buf); +if (cursor) +dpy_gl_cursor_dmabuf (vdev->display_con, + &cursor->buf); free_bufs = true; }if (cursor !=NULL ) {And with these it seems pretty fine now that I'll queue them up for -next pull.
thanks
--
Open Source Technology Center, Intel ltd.$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827