drm/i915/gvt: Dma-buf support for GVT-g
Subsystems (5)
v8 cover drm/i915/gvt: Dma-buf support for GVT-g
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.
User need to create a fd(for intel GVT-g dma-buf support it is a:dma-buf management fd) then user can use this fd to query the plane information or create a dma-buf. The life cycle of this fd is managed by GVT-g user do not need to care about that.
We have an example program on how to use the dma-buf. You can download the program to have a try. Good luck :)
git repo: https://github.com/01org/igvtg-qemu branch:kvmgt_dmabuf_example
Xiaoguang Chen (6):
drm/i915/gvt: Extend the GVT-g architecture to support vfio device
region
drm/i915/gvt: OpRegion support for GVT-g
drm/i915/gvt: Frame buffer decoder support for GVT-g
vfio: Define vfio based vgpu's dma-buf operations drm/i915/gvt: Dmabuf support for GVT-g
drm/i915/gvt: Adding user interface for dma-buf
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 | 298 +++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/dmabuf.h | 42 ++++ drivers/gpu/drm/i915/gvt/fb_decoder.c | 425 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/fb_decoder.h | 171 +++++++++++++ drivers/gpu/drm/i915/gvt/gvt.c | 3 + drivers/gpu/drm/i915/gvt/gvt.h | 7 + drivers/gpu/drm/i915/gvt/hypercall.h | 4 + drivers/gpu/drm/i915/gvt/kvmgt.c | 254 +++++++++++++++++++- 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 | 26 +- drivers/gpu/drm/i915/i915_gem_object.h | 9 + drivers/gpu/drm/i915/i915_gem_tiling.c | 5 + include/uapi/drm/drm_fourcc.h | 6 + include/uapi/linux/vfio.h | 58 +++++ 19 files changed, 1380 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 v8 1/6 drm/i915/gvt: Extend the GVT-g architecture to support vfio device region
--- drivers/gpu/drm/i915/gvt/kvmgt.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gvt/kvmgt.c +18 -3
@@ -53,11 +53,21 @@ static const struct intel_gvt_ops *intel_gvt_ops;#define VFIO_PCI_INDEX_TO_OFFSET (index) ((u64)(index) << VFIO_PCI_OFFSET_SHIFT)#define VFIO_PCI_OFFSET_MASK (((u64)(1) << VFIO_PCI_OFFSET_SHIFT) - 1) +struct vfio_region ; +struct intel_vgpu_regops { +size_t (*rw)(struct intel_vgpu *vgpu,char *buf, +size_t count,loff_t *ppos,bool iswrite); +void (*release)(struct intel_vgpu *vgpu, +struct vfio_region *region); +}; +struct vfio_region {u32 type;u32 subtype;size_t size;u32 flags; +const struct intel_vgpu_regops *ops; +void *data; };struct kvmgt_pgfn {
@@ -642,7 +652,7 @@ static ssize_t intel_vgpu_rw(struct mdev_device *mdev, char *buf,int ret = -EINVAL ; -if (index >=VFIO_PCI_NUM_REGIONS ) { +if (index >=VFIO_PCI_NUM_REGIONS + vgpu->vdev.num_regions) {gvt_vgpu_err ("invalid index: %u\n" , index);return -EINVAL ; }
@@ -676,8 +686,11 @@ static ssize_t intel_vgpu_rw(struct mdev_device *mdev, char *buf,case VFIO_PCI_BAR5_REGION_INDEX :case VFIO_PCI_VGA_REGION_INDEX :case VFIO_PCI_ROM_REGION_INDEX : +break ;default : -gvt_vgpu_err ("unsupported region: %u\n" , index); + index -=VFIO_PCI_NUM_REGIONS ; +return vgpu->vdev.region[index].ops->rw (vgpu, buf, count, + ppos, is_write); }return ret ==0 ? count : ret;
@@ -940,7 +953,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, info.flags =VFIO_DEVICE_FLAGS_PCI ; info.flags |=VFIO_DEVICE_FLAGS_RESET ; - info.num_regions =VFIO_PCI_NUM_REGIONS ; + info.num_regions =VFIO_PCI_NUM_REGIONS + + vgpu->vdev.num_regions; info.num_irqs =VFIO_PCI_NUM_IRQS ; return copy_to_user((void __user *)arg, &info, minsz) ?
@@ -1061,6 +1075,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, }if (caps.size) { + info.flags |=VFIO_REGION_INFO_FLAG_CAPS ;if (info.argsz <sizeof (info) + caps.size) { info.argsz =sizeof (info) + caps.size; info.cap_offset =0 ;
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v8 2/6 drm/i915/gvt: OpRegion support for GVT-g
In reply to Xiaoguang ChenOpRegion is needed to support display related operation for intel vgpu.
A vfio device region is added to intel vgpu to deliver the host OpRegion information to user space so user space can construct the OpRegion for vgpu.
--- drivers/gpu/drm/i915/gvt/hypercall.h | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 88 ++++++++++++++++++++++++++++++++++++ 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, 128 insertions(+), 6 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 +88 -0
106 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/mpt.h +15 -0
@@ -293,4 +293,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
@@ -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
@@ -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
PATCH v8 3/6 drm/i915/gvt: Frame buffer decoder support for GVT-g
In reply to Xiaoguang Chendecode frambuffer attributes of 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 | 425 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/fb_decoder.h | 171 ++++++++++++++ drivers/gpu/drm/i915/gvt/gvt.h | 1 + include/uapi/drm/drm_fourcc.h | 6 + 7 files changed, 608 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 + execlist.o scheduler.o sched_policy.o render.o cmd_parser.o \ + fb_decoder.o ccflags-y += -I$(src) -I$(src)/$(GVT_DIR) -Wall 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 +425 -0
425 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/fb_decoder.h new file +171 -0
171 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
include/uapi/drm/drm_fourcc.h +6 -0
@@ -161,6 +161,12 @@ extern "C" {#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4')/* non-subsampled Cb (1) and Cr (2) planes */ #define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4')/* non-subsampled Cr (1) and Cb (2) planes */ +/* +* Intel GVT-g plane format definition +*/ +#define DRM_FORMAT_XRGB161616_GVT fourcc_code('X', 'R', '4', '8')/* [63:0] x:R:G:B 16:16:16:16 little endian */ +#define DRM_FORMAT_XBGR161616_GVT fourcc_code('X', 'B', '4', '8')/* [63:0] x:B:G:R 16:16:16:16 little endian */ +/* * Format Modifiers:
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v8 4/6 vfio: Define vfio based vgpu's dma-buf operations
In reply to Xiaoguang ChenHere we defined a new ioctl to create a fd for a vfio device based on the input type. Now only one type is supported that is a dma-buf management fd.
Two ioctls are defined for the dma-buf management fd: query the vfio vgpu's plane information and create a dma-buf for a plane.
--- include/uapi/linux/vfio.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
include/uapi/linux/vfio.h +58 -0
@@ -502,6 +502,64 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_GET_FD - _IO(VFIO_TYPE, VFIO_BASE + 14, __u32) +* +* Create a fd for a vfio device based on the input type +* Vendor driver should handle this ioctl to create a fd and manage the +* life cycle of this fd. +* +* Return: a fd if vendor support that type, -errno if not supported +*/ + +#define VFIO_DEVICE_GET_FD _IO(VFIO_TYPE, VFIO_BASE + 14) + +struct vfio_vgpu_plane_info { +__u64 start; +__u64 drm_format_mod; +__u32 drm_format; +__u32 width; +__u32 height; +__u32 stride; +__u32 size; +__u32 x_pos; +__u32 y_pos; +__u32 padding; +}; + +#define VFIO_DEVICE_DMABUF_MGR_FD 0/* Supported fd types */ + +/* +* VFIO_DEVICE_QUERY_PLANE - _IO(VFIO_TYPE, VFIO_BASE + 15, +* struct vfio_vgpu_query_plane) +* Query plane information +*/ +struct vfio_vgpu_query_plane { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__u32 plane_id; +__u32 padding; +}; + +#define VFIO_DEVICE_QUERY_PLANE _IO(VFIO_TYPE, VFIO_BASE + 15) + +/* +* VFIO_DEVICE_CREATE_DMABUF - _IO(VFIO, VFIO_BASE + 16, +* struct vfio_vgpu_create_dmabuf) +* +* Create a dma-buf for a plane +*/ +struct vfio_vgpu_create_dmabuf { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__s32 fd; +__u32 plane_id; +}; + +#define VFIO_DEVICE_CREATE_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 16) +/* -------- 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
PATCH v8 5/6 drm/i915/gvt: Dmabuf support for GVT-g
In reply to Xiaoguang Chendmabuf for GVT-g can be exported to users who can use the dmabuf to show the desktop of vm which use intel vgpu.
Currently we provide query and create new dmabuf operations.
Users of dmabuf can cache some created dmabufs and related information such as the framebuffer's address, size, tiling mode, width, height etc. When refresh the screen first query the currnet vgpu's frambuffer and compare with the cached ones(address, size, tiling, width, height etc) if found one then reuse the found dmabuf to gain performance improvment.
If there is no dmabuf created yet or not found in the cached dmabufs then need to create a new dmabuf. To create a dmabuf first a gem object will be created and the backing storage of this gem object is the vgpu's framebuffer(primary/cursor).
Set caching mode, change tiling mode and set domains of this gem object is not supported.
Then associate this gem object to a dmabuf and export this dmabuf. A file descriptor will be generated for this dmabuf and this file descriptor can be sent to user space to do display.
--- drivers/gpu/drm/i915/gvt/Makefile | 2 +- drivers/gpu/drm/i915/gvt/dmabuf.c | 263 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/dmabuf.h | 37 +++++ drivers/gpu/drm/i915/gvt/gvt.h | 1 + drivers/gpu/drm/i915/i915_gem.c | 26 +++- drivers/gpu/drm/i915/i915_gem_object.h | 9 ++ drivers/gpu/drm/i915/i915_gem_tiling.c | 5 + 7 files changed, 341 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 \ - fb_decoder.o + fb_decoder.o dmabuf.o ccflags-y += -I$(src) -I$(src)/$(GVT_DIR) -Wall i915-y += $(addprefix $(GVT_DIR)/, $(GVT_SOURCE))
drivers/gpu/drm/i915/gvt/dmabuf.c new file +263 -0
263 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/dmabuf.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright(c) 2017 Intel Corporation. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +*/ + +#ifndef _GVT_DMABUF_H_ +#define _GVT_DMABUF_H_ + +struct intel_vgpu_fb_info { +struct intel_vgpu *vgpu; +uint32_t fb_addr; +uint32_t fb_size; +}; + +int intel_vgpu_query_plane (struct intel_vgpu *vgpu,void *args); +int intel_vgpu_create_dmabuf (struct intel_vgpu *vgpu,void *args); + +#endif
drivers/gpu/drm/i915/gvt/gvt.h +1 -0
@@ -47,6 +47,7 @@#include "render.h" #include "cmd_parser.h" #include "fb_decoder.h" +#include "dmabuf.h" #define GVT_MAX_VGPU 8
drivers/gpu/drm/i915/i915_gem.c +25 -1
@@ -1609,6 +1609,12 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,if (!obj)return -ENOENT ; +/* proxy gem object does not support setting domain */ +if (i915_gem_object_is_proxy (obj)) { + err = -EPERM ; + goto out; + } +/* Try to flush the object off the GPU without holding the lock. * We will repeat the flush holding the lock in the normal manner * to catch cases where we are gazumped.
@@ -1677,6 +1683,12 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,if (!obj)return -ENOENT ; +/* proxy gem obj does not support this operation */ +if (i915_gem_object_is_proxy (obj)) { +i915_gem_object_put (obj); +return -EPERM ; + } +/* Pinned buffers may be scanout, so flush the cache */ i915_gem_object_flush_if_display (obj);i915_gem_object_put (obj);
@@ -1727,7 +1739,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,
@@ -3717,6 +3729,12 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,if (!obj)return -ENOENT ; +/* proxy gem obj does not support setting caching mode */ +if (i915_gem_object_is_proxy (obj)) { + ret = -EPERM ; + goto out; + } +if (obj->cache_level == level) goto out;
@@ -4168,6 +4186,12 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,if (!obj)return -ENOENT ; +/* proxy gem obj does not support changing backding storage */ +if (i915_gem_object_is_proxy (obj)) { + err = -EPERM ; + goto out; + } + err =mutex_lock_interruptible (&obj->mm.lock);if (err) goto out;
drivers/gpu/drm/i915/i915_gem_object.h +9 -0
@@ -39,6 +39,7 @@ struct drm_i915_gem_object_ops {unsigned int flags;#define I915_GEM_OBJECT_HAS_STRUCT_PAGE 0x1#define I915_GEM_OBJECT_IS_SHRINKABLE 0x2 +#define I915_GEM_OBJECT_IS_PROXY 0x4/* Interface between the GEM object and its backing storage. * get_pages() is called once prior to the use of the associated set
@@ -184,6 +185,8 @@ struct drm_i915_gem_object { } userptr;unsigned long scratch; + +void *gvt_info; };/** for phys allocated objects */
@@ -286,6 +289,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 +5 -0
@@ -345,6 +345,11 @@ i915_gem_set_tiling_ioctl(struct drm_device *dev, void *data,if (!obj)return -ENOENT ; +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 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v8 6/6 drm/i915/gvt: Adding user interface for dma-buf
In reply to Xiaoguang ChenUser space should create the management fd for the dma-buf operation first. Then user can query the plane information and create dma-buf if necessary using the management fd.
--- drivers/gpu/drm/i915/gvt/dmabuf.c | 37 ++++++++- drivers/gpu/drm/i915/gvt/dmabuf.h | 5 ++ drivers/gpu/drm/i915/gvt/gvt.c | 3 + drivers/gpu/drm/i915/gvt/gvt.h | 5 ++ drivers/gpu/drm/i915/gvt/hypercall.h | 3 + drivers/gpu/drm/i915/gvt/kvmgt.c | 145 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/mpt.h | 30 ++++++++ drivers/gpu/drm/i915/gvt/vgpu.c | 2 + 8 files changed, 229 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/dmabuf.c +36 -1
@@ -81,6 +81,28 @@ static void intel_vgpu_gem_put_pages(struct drm_i915_gem_object *obj,static void intel_vgpu_gem_release (struct drm_i915_gem_object *obj) { +struct intel_vgpu_dmabuf_obj *dmabuf_obj; +struct intel_vgpu_fb_info *fb_info; +struct intel_vgpu *vgpu =NULL ; +struct list_head *pos; + + fb_info = (struct intel_vgpu_fb_info *)obj->gvt_info; +if (WARN_ON (!fb_info && !fb_info->vgpu)) { +gvt_vgpu_err ("gvt info is invalid\n" ); + goto out; + } + + vgpu = fb_info->vgpu; +list_for_each (pos, &vgpu->dmabuf_obj_list_head) { + dmabuf_obj = container_of(pos, struct intel_vgpu_dmabuf_obj, + list); +if ((dmabuf_obj !=NULL ) && (dmabuf_obj->obj == obj)) { +kfree (dmabuf_obj); +break ; + } + } +intel_gvt_hypervisor_put_vfio_device (vgpu); +out:kfree (obj->gvt_info); }
@@ -215,6 +237,7 @@ int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void *args)struct vfio_vgpu_create_dmabuf *gvt_dmabuf = args;struct intel_vgpu_fb_info *fb_info;int ret; +struct intel_vgpu_dmabuf_obj *dmabuf_obj; ret =intel_vgpu_get_plane_info (dev, vgpu, &gvt_dmabuf->plane_info, gvt_dmabuf->plane_id);
@@ -237,6 +260,16 @@ int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void *args) fb_info->vgpu = vgpu; obj->gvt_info = fb_info; + dmabuf_obj =kmalloc (sizeof (*dmabuf_obj),GFP_KERNEL ); +if (!dmabuf_obj) { +gvt_vgpu_err ("alloc dmabuf_obj failed\n" ); + ret = -ENOMEM ; + goto out_free_info; + } + dmabuf_obj->obj = obj; +INIT_LIST_HEAD (&dmabuf_obj->list); +list_add_tail (&dmabuf_obj->list, &vgpu->dmabuf_obj_list_head); + dmabuf =i915_gem_prime_export (dev, &obj->base,DRM_CLOEXEC |DRM_RDWR );if (IS_ERR (dmabuf)) {
@@ -250,11 +283,13 @@ int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void *args)gvt_vgpu_err ("create dma-buf fd failed ret:%d\n" , ret); goto out_free; } - +intel_gvt_hypervisor_get_vfio_device (vgpu); gvt_dmabuf->fd = ret;return 0 ; out_free: +kfree (dmabuf_obj); +out_free_info:kfree (fb_info); out:i915_gem_object_put (obj);
drivers/gpu/drm/i915/gvt/dmabuf.h +5 -0
@@ -31,6 +31,11 @@ struct intel_vgpu_fb_info {uint32_t fb_size; }; +struct intel_vgpu_dmabuf_obj { +struct drm_i915_gem_object *obj; +struct list_head list; +}; +int intel_vgpu_query_plane (struct intel_vgpu *vgpu,void *args);int intel_vgpu_create_dmabuf (struct intel_vgpu *vgpu,void *args);
drivers/gpu/drm/i915/gvt/gvt.c +3 -0
@@ -54,6 +54,9 @@ 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, + .vgpu_create_dmabuf = intel_vgpu_create_dmabuf, + };/**
drivers/gpu/drm/i915/gvt/gvt.h +5 -0
@@ -185,8 +185,11 @@ struct intel_vgpu {struct kvm *kvm;struct work_struct release_work;atomic_t released; +struct vfio_device *vfio_device; } vdev;#endif +atomic_t mgr_fd_opened; +struct list_head dmabuf_obj_list_head; }; struct intel_gvt_gm {
@@ -467,6 +470,8 @@ 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 *); +int (*vgpu_create_dmabuf)(struct intel_vgpu *vgpu,void *); };
drivers/gpu/drm/i915/gvt/hypercall.h +3 -0
@@ -56,6 +56,9 @@ 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)(unsigned long handle); +void (*put_vfio_device)(unsigned long handle); + };extern struct intel_gvt_mpt xengt_mpt;
drivers/gpu/drm/i915/gvt/kvmgt.c +145 -0
169 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/mpt.h +30 -0
@@ -308,4 +308,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->handle); +} + +/** +* 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->handle); +} +#endif /* _GVT_MPT_H_ */
drivers/gpu/drm/i915/gvt/vgpu.c +2 -0
@@ -346,6 +346,8 @@ 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); +atomic_set (&vgpu->mgr_fd_opened,0 );intel_vgpu_init_cfg_space (vgpu, param->primary);
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 (rev8)
In reply to Xiaoguang Chen== Series Details ==
== Series Details ==
Series: drm/i915/gvt: dma-buf support for GVT-g (rev8)
URL : https://patchwork.freedesktop.org/series/23686/
State : failure
== Summary ==
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHK scripts/mod/devicetable-offsets.h
CHK include/generated/compile.h
CHK kernel/config_data.h
CC [M] drivers/gpu/drm/i915/i915_drv.o
In file included from drivers/gpu/drm/i915/i915_vma.h:34:0,
from drivers/gpu/drm/i915/intel_uc.h:31,
from drivers/gpu/drm/i915/i915_drv.h:61,
from drivers/gpu/drm/i915/i915_drv.c:49:drivers/gpu/drm/i915/i915_gem_object.h:40:1: error: expected specifier-qualifier-list before ‘<<’ token
<<<<<<< 56374caa89c2bba6a4d52641bc091d84052eec27
^drivers/gpu/drm/i915/i915_gem_object.h:40:9: error: invalid suffix "caa89c2bba6a4d52641bc091d84052eec27" on integer constant
<<<<<<< 56374caa89c2bba6a4d52641bc091d84052eec27
^
drivers/gpu/drm/i915/i915_gem_object.h:44:0: error: "I915_GEM_OBJECT_HAS_STRUCT_PAGE" redefined [-Werror]
#define I915_GEM_OBJECT_HAS_STRUCT_PAGE 0x1
^drivers/gpu/drm/i915/i915_gem_object.h:41:0: note: this is the location of the previous definition
#define I915_GEM_OBJECT_HAS_STRUCT_PAGE BIT(0)
^drivers/gpu/drm/i915/i915_gem_object.h:45:0: error: "I915_GEM_OBJECT_IS_SHRINKABLE" redefined [-Werror]
#define I915_GEM_OBJECT_IS_SHRINKABLE 0x2
^drivers/gpu/drm/i915/i915_gem_object.h:42:0: note: this is the location of the previous definition
#define I915_GEM_OBJECT_IS_SHRINKABLE BIT(1)
^
cc1: all warnings being treated as errorsscripts/Makefile.build:302: recipe for target 'drivers/gpu/drm/i915/i915_drv.o' failed make[4]: *** [drivers/gpu/drm/i915/i915_drv.o] Error 1scripts/Makefile.build:561: recipe for target 'drivers/gpu/drm/i915' failed
make[3]: *** [drivers/gpu/drm/i915] Error 2scripts/Makefile.build:561: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2scripts/Makefile.build:561: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1016: recipe for target 'drivers' failed
make: *** [drivers] Error 2
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operations
In reply to Xiaoguang ChenQuoted 35 lines · On Fri, 9 Jun 2017 14:50:40 +0800 Xiaoguang Chen <[email protected]>…
Here we defined a new ioctl to create a fd for a vfio device based on the input type. Now only one type is supported that is a dma-buf management fd.
Two ioctls are defined for the dma-buf management fd: query the vfio vgpu's plane information and create a dma-buf for a plane.Signed-off-by Xiaoguang Chen <[email protected]>--- include/uapi/linux/vfio.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)include/uapi/linux/vfio.h +16
-0@@ -502,6 +502,64 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_GET_FD - _IO(VFIO_TYPE, VFIO_BASE + 14, __u32) +* +* Create a fd for a vfio device based on the input type +* Vendor driver should handle this ioctl to create a fd and manage the +* life cycle of this fd. +* +* Return: a fd if vendor support that type, -errno if not supported +*/ + +#define VFIO_DEVICE_GET_FD _IO(VFIO_TYPE, VFIO_BASE + 14) + +struct vfio_vgpu_plane_info { +__u64 start; +__u64 drm_format_mod; +__u32 drm_format;
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 530
Quoted 10 lines
include/uapi/linux/vfio.h +10
-0+__u32 width; +__u32 height; +__u32 stride; +__u32 size; +__u32 x_pos; +__u32 y_pos; +__u32 padding; +}; + +#define VFIO_DEVICE_DMABUF_MGR_FD 0/* Supported fd types */
Move this #define up above vfio_vgpu_plane_info to associate it with the VFIO_DEVICE_GET_FD ioctl.
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 542
Quoted 12 lines
include/uapi/linux/vfio.h +12
-0+ +/* +* VFIO_DEVICE_QUERY_PLANE - _IO(VFIO_TYPE, VFIO_BASE + 15, +* struct vfio_vgpu_query_plane) +* Query plane information +*/ +struct vfio_vgpu_query_plane { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__u32 plane_id; +__u32 padding;
This padding doesn't make sense.
Quoted 7 lines
include/uapi/linux/vfio.h +7
-0+}; + +#define VFIO_DEVICE_QUERY_PLANE _IO(VFIO_TYPE, VFIO_BASE + 15) + +/* +* VFIO_DEVICE_CREATE_DMABUF - _IO(VFIO, VFIO_BASE + 16, +* struct vfio_vgpu_create_dmabuf)
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 559
Quoted 10 lines
include/uapi/linux/vfio.h +10
-0+* +* Create a dma-buf for a plane +*/ +struct vfio_vgpu_create_dmabuf { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__s32 fd; +__u32 plane_id; +};
Both of these have a plane_id, should plane_id simply replace the padding in plane_info? If not, let's at least put them in the same order so that plane_id is after plane_info for both structs.
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 561
Quoted 2 lines
include/uapi/linux/vfio.h +2
-0+ +#define VFIO_DEVICE_CREATE_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 16)
I don't think these should be named just VFIO_DEVICE_foo, that implies they're ioctls on the vfio device fd, they're not. They need to be associated both in name and more complete descriptions as ioctls to the fd returned from a request for a VFIO_DEVICE_DMABUF_MGR_FD. Perhaps VFIO_DMABUF_MGR_QUERY_PLANE and VFIO_DMABUF_MGR_CREATE_DMABUF. I'm also not sure why we're using "vgpu" in the structure names here either, the ioctls aren't named after vgpus. Aren't these rather generic to graphics dmabufs, not specifically vgpus? Thanks,
Alex
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 565
Quoted 4 lines
include/uapi/linux/vfio.h +1
-0+/* -------- API for Type1 VFIO IOMMU -------- */ /**
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v8 6/6] drm/i915/gvt: Adding user interface for dma-buf
In reply to Xiaoguang ChenQuoted 22 lines · On Fri, 9 Jun 2017 14:50:42 +0800 Xiaoguang Chen <[email protected]>…
User space should create the management fd for the dma-buf operation first. Then user can query the plane information and create dma-buf if necessary using the management fd.
Signed-off-by Xiaoguang Chen <[email protected]>Tested-by Kechen Lu <[email protected]>--- drivers/gpu/drm/i915/gvt/dmabuf.c | 37 ++++++++- drivers/gpu/drm/i915/gvt/dmabuf.h | 5 ++ drivers/gpu/drm/i915/gvt/gvt.c | 3 + drivers/gpu/drm/i915/gvt/gvt.h | 5 ++ drivers/gpu/drm/i915/gvt/hypercall.h | 3 + drivers/gpu/drm/i915/gvt/kvmgt.c | 145 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/mpt.h | 30 ++++++++ drivers/gpu/drm/i915/gvt/vgpu.c | 2 + 8 files changed, 229 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/gvt/dmabuf.c +0
-0
drivers/gpu/drm/i915/gvt/dmabuf.c static void intel_vgpu_gem_put_pages(struct drm_i915_gem_object *obj, · line 86
Quoted 6 lines
drivers/gpu/drm/i915/gvt/dmabuf.c +3
-0@@ -81,6 +81,28 @@ static void intel_vgpu_gem_put_pages(struct drm_i915_gem_object *obj,static void intel_vgpu_gem_release (struct drm_i915_gem_object *obj) { +struct intel_vgpu_dmabuf_obj *dmabuf_obj; +struct intel_vgpu_fb_info *fb_info; +struct intel_vgpu *vgpu =NULL ;
unnecessary initialization
drivers/gpu/drm/i915/gvt/dmabuf.c static void intel_vgpu_gem_put_pages(struct drm_i915_gem_object *obj, · line 90
Quoted 4 lines
drivers/gpu/drm/i915/gvt/dmabuf.c +4
-0+struct list_head *pos; + + fb_info = (struct intel_vgpu_fb_info *)obj->gvt_info; +if (WARN_ON (!fb_info && !fb_info->vgpu)) {
||
drivers/gpu/drm/i915/gvt/dmabuf.c static void intel_vgpu_gem_put_pages(struct drm_i915_gem_object *obj, · line 101
Quoted 11 lines
drivers/gpu/drm/i915/gvt/dmabuf.c +11
-0+gvt_vgpu_err ("gvt info is invalid\n" ); + goto out; + } + + vgpu = fb_info->vgpu; +list_for_each (pos, &vgpu->dmabuf_obj_list_head) { + dmabuf_obj = container_of(pos, struct intel_vgpu_dmabuf_obj, + list); +if ((dmabuf_obj !=NULL ) && (dmabuf_obj->obj == obj)) { +kfree (dmabuf_obj); +break ;
Did we intend to remove it from the list?
Quoted 18 lines
drivers/gpu/drm/i915/gvt/dmabuf.c +5
-0+ } + } +intel_gvt_hypervisor_put_vfio_device (vgpu); +out:kfree (obj->gvt_info); }@@ -215,6 +237,7 @@ int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void *args)struct vfio_vgpu_create_dmabuf *gvt_dmabuf = args;struct intel_vgpu_fb_info *fb_info;int ret; +struct intel_vgpu_dmabuf_obj *dmabuf_obj; ret =intel_vgpu_get_plane_info (dev, vgpu, &gvt_dmabuf->plane_info, gvt_dmabuf->plane_id);@@ -237,6 +260,16 @@ int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void *args) fb_info->vgpu = vgpu; obj->gvt_info = fb_info;
drivers/gpu/drm/i915/gvt/dmabuf.c int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void *args) · line 271
Quoted 10 lines
drivers/gpu/drm/i915/gvt/dmabuf.c +9
-0+ dmabuf_obj =kmalloc (sizeof (*dmabuf_obj),GFP_KERNEL ); +if (!dmabuf_obj) { +gvt_vgpu_err ("alloc dmabuf_obj failed\n" ); + ret = -ENOMEM ; + goto out_free_info; + } + dmabuf_obj->obj = obj; +INIT_LIST_HEAD (&dmabuf_obj->list); +list_add_tail (&dmabuf_obj->list, &vgpu->dmabuf_obj_list_head);
Does this list need protection?
Quoted 142 lines
drivers/gpu/drm/i915/gvt/dmabuf.c +4
-1+ dmabuf =i915_gem_prime_export (dev, &obj->base,DRM_CLOEXEC |DRM_RDWR );if (IS_ERR (dmabuf)) {@@ -250,11 +283,13 @@ int intel_vgpu_create_dmabuf(struct intel_vgpu *vgpu, void *args)gvt_vgpu_err ("create dma-buf fd failed ret:%d\n" , ret); goto out_free; } - +intel_gvt_hypervisor_get_vfio_device (vgpu); gvt_dmabuf->fd = ret;return 0 ; out_free: +kfree (dmabuf_obj); +out_free_info:kfree (fb_info); out:i915_gem_object_put (obj);drivers/gpu/drm/i915/gvt/dmabuf.h +5
-0@@ -31,6 +31,11 @@ struct intel_vgpu_fb_info {uint32_t fb_size; }; +struct intel_vgpu_dmabuf_obj { +struct drm_i915_gem_object *obj; +struct list_head list; +}; +int intel_vgpu_query_plane (struct intel_vgpu *vgpu,void *args);int intel_vgpu_create_dmabuf (struct intel_vgpu *vgpu,void *args);drivers/gpu/drm/i915/gvt/gvt.c +3
-0@@ -54,6 +54,9 @@ 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, + .vgpu_create_dmabuf = intel_vgpu_create_dmabuf, + };/** drivers/gpu/drm/i915/gvt/gvt.h +5
-0@@ -185,8 +185,11 @@ struct intel_vgpu {struct kvm *kvm;struct work_struct release_work;atomic_t released; +struct vfio_device *vfio_device; } vdev;#endif +atomic_t mgr_fd_opened; +struct list_head dmabuf_obj_list_head; }; struct intel_gvt_gm {@@ -467,6 +470,8 @@ 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 *); +int (*vgpu_create_dmabuf)(struct intel_vgpu *vgpu,void *); };drivers/gpu/drm/i915/gvt/hypercall.h +3
-0@@ -56,6 +56,9 @@ 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)(unsigned long handle); +void (*put_vfio_device)(unsigned long handle); + };extern struct intel_gvt_mpt xengt_mpt;drivers/gpu/drm/i915/gvt/kvmgt.c +39
-0@@ -41,6 +41,7 @@#include <linux/kvm_host.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/anon_inodes.h> #include "i915_drv.h" #include "gvt.h" @@ -523,6 +524,117 @@ static int kvmgt_set_opregion(void *p_vgpu)return ret; } +static int kvmgt_get_vfio_device (unsigned long handle) +{ +struct kvmgt_guest_info *info; +struct intel_vgpu *vgpu; +struct vfio_device *device; + +if (!handle_valid (handle)) +return -ESRCH ; + + info = (struct kvmgt_guest_info *)handle; + vgpu = info->vgpu; + + device =vfio_device_get_from_dev (mdev_dev (vgpu->vdev.mdev)); +if (device ==NULL ) +return -ENODEV ; + vgpu->vdev.vfio_device = device; + +return 0 ; +} + +static void kvmgt_put_vfio_device (unsigned long handle) +{ +struct kvmgt_guest_info *info; +struct intel_vgpu *vgpu; + +if (!handle_valid (handle)) +return ; + + info = (struct kvmgt_guest_info *)handle; + vgpu = info->vgpu; + +vfio_device_put (vgpu->vdev.vfio_device); +} + +static int intel_vgpu_dmabuf_mgr_fd_mmap (struct file *file, +struct vm_area_struct *vma) +{ +return -EPERM ;
drivers/gpu/drm/i915/gvt/kvmgt.c static int kvmgt_set_opregion(void *p_vgpu) · line 574
Quoted 10 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +10
-0+} + +static int intel_vgpu_dmabuf_mgr_fd_release (struct inode *inode, +struct file *filp) +{ +struct intel_vgpu *vgpu = filp->private_data; +struct intel_vgpu_dmabuf_obj *obj; +struct list_head *pos; + +if (WARN_ON (!vgpu->vdev.vfio_device))
Doesn't seem possible, however any kvmgt_put_vfio_device() call will set this regardless of whether that calling path retained the reference or failed and released it, so the way vfio_device is cached here is rather sketchy in general.
Quoted 69 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +63
-0+return -ENODEV ; + +list_for_each (pos, &vgpu->dmabuf_obj_list_head) { + obj = container_of(pos, struct intel_vgpu_dmabuf_obj, list); +if (WARN_ON (!obj)) +return -ENODEV ; +i915_gem_object_put (obj->obj); + } +kvmgt_put_vfio_device (vgpu->handle); +atomic_set (&vgpu->mgr_fd_opened,0 ); + +return 0 ; +} + +static long intel_vgpu_dmabuf_mgr_fd_ioctl (struct file *filp, +unsigned int ioctl,unsigned long arg) +{ +struct intel_vgpu *vgpu = filp->private_data; +int minsz; +int ret =0 ; + +if (ioctl ==VFIO_DEVICE_QUERY_PLANE ) { +struct vfio_vgpu_query_plane plane_info; + + minsz = offsetofend(struct vfio_vgpu_query_plane, padding); +if (copy_from_user (&plane_info, (void __user *)arg, minsz)) +return -EFAULT ; +if (plane_info.argsz < minsz || plane_info.flags !=0 ) +return -EINVAL ; + ret = intel_gvt_ops->vgpu_query_plane (vgpu, &plane_info); +if (ret !=0 ) { +gvt_vgpu_err ("query plane failed:%d\n" , ret); +return -EINVAL ; + } +return copy_to_user ((void __user *)arg, &plane_info, minsz) ? + -EFAULT :0 ; + }else if (ioctl ==VFIO_DEVICE_CREATE_DMABUF ) { +struct vfio_vgpu_create_dmabuf dmabuf; + + minsz = offsetofend(struct vfio_vgpu_create_dmabuf, plane_id); +if (copy_from_user (&dmabuf, (void __user *)arg, minsz)) +return -EFAULT ; +if (dmabuf.argsz < minsz || dmabuf.flags !=0 ) +return -EINVAL ; + + ret = intel_gvt_ops->vgpu_create_dmabuf (vgpu, &dmabuf); +if (ret !=0 ) +return ret; + +return copy_to_user ((void __user *)arg, &dmabuf, minsz) ? + -EFAULT :0 ; + }else +gvt_vgpu_err ("unsupported mgr fd operation\n" ); + +return -EINVAL ; +} + +static const struct file_operations intel_vgpu_dmabuf_mgr_fd_ops = { + .release = intel_vgpu_dmabuf_mgr_fd_release, + .unlocked_ioctl = intel_vgpu_dmabuf_mgr_fd_ioctl, + .mmap = intel_vgpu_dmabuf_mgr_fd_mmap, + .llseek = noop_llseek, +};static int intel_vgpu_create (struct kobject *kobj,struct mdev_device *mdev) {struct intel_vgpu *vgpu =NULL ;@@ -1249,6 +1361,36 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, }else if (cmd ==VFIO_DEVICE_RESET ) { intel_gvt_ops->vgpu_reset (vgpu);
drivers/gpu/drm/i915/gvt/kvmgt.c static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, · line 1372
Quoted 10 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +9
-0return 0 ; + }else if (cmd ==VFIO_DEVICE_GET_FD ) { +int fd; +u32 type; +int ret; + +if (atomic_read (&vgpu->mgr_fd_opened)) { +gvt_vgpu_err ("mgr fd already opened\n" ); +return -EPERM ; + }
Should check what's being asked for first, if other types are created that are not supported by kvmgt we should consistently return -EINVAL, not -EINVAL if DMABUF_MGR isn't already opened and -EPERM if it is.
Quoted 9 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +9
-0+ +if (copy_from_user (&type, (void __user *)arg,sizeof (type))) +return -EINVAL ; +if (type !=VFIO_DEVICE_DMABUF_MGR_FD ) +return -EINVAL ; + + ret =kvmgt_get_vfio_device (vgpu->handle); +if (ret !=0 ) +return ret;
drivers/gpu/drm/i915/gvt/kvmgt.c static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, · line 1391
Quoted 10 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +10
-0+ + fd =anon_inode_getfd ("intel-vgpu-dmabuf-mgr-fd" , + &intel_vgpu_dmabuf_mgr_fd_ops, + vgpu,O_RDWR |O_CLOEXEC ); +if (fd <0 ) { +kvmgt_put_vfio_device (vgpu->handle); +gvt_vgpu_err ("create dmabuf mgr fd failed\n" ); +return -EINVAL ; + } +atomic_inc (&vgpu->mgr_fd_opened);
This doesn't seem like a super effective use of atomics, you could be sure to have only one open with a cmpxchg.
Quoted 59 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +5
-0+ +return fd; }return 0 ;@@ -1612,6 +1754,9 @@ struct intel_gvt_mpt kvmgt_mpt = { .write_gpa = kvmgt_write_gpa, .gfn_to_mfn = kvmgt_gfn_to_pfn, .set_opregion = kvmgt_set_opregion, + .get_vfio_device = kvmgt_get_vfio_device, + .put_vfio_device = kvmgt_put_vfio_device, + };EXPORT_SYMBOL_GPL (kvmgt_mpt);drivers/gpu/drm/i915/gvt/mpt.h +30
-0@@ -308,4 +308,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->handle); +} + +/** +* 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->handle); +} +#endif /* _GVT_MPT_H_ */ drivers/gpu/drm/i915/gvt/vgpu.c +0
-0
drivers/gpu/drm/i915/gvt/vgpu.c static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt, · line 353
Quoted 8 lines
drivers/gpu/drm/i915/gvt/vgpu.c +2
-0@@ -346,6 +346,8 @@ 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); +atomic_set (&vgpu->mgr_fd_opened,0 );intel_vgpu_init_cfg_space (vgpu, param->primary);
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RE: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operations
In reply to Alex WilliamsonQuoted 58 lines
-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Wednesday, June 14, 2017 5:25 AM
To: Chen, Xiaoguang <[email protected]>
Cc: [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; intel-gvt- [email protected]; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>
Subject: Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operationsQuoted 42 lines · On Fri, 9 Jun 2017 14:50:40 +0800 Xiaoguang Chen <[email protected]>…
Here we defined a new ioctl to create a fd for a vfio device based on the input type. Now only one type is supported that is a dma-buf management fd.
Two ioctls are defined for the dma-buf management fd: query the vfio vgpu's plane information and create a dma-buf for a plane.Signed-off-by Xiaoguang Chen <[email protected]>--- include/uapi/linux/vfio.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)include/uapi/linux/vfio.h +22
-0@@ -502,6 +502,64 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_GET_FD - _IO(VFIO_TYPE, VFIO_BASE + 14, __u32) +* +* Create a fd for a vfio device based on the input type +* Vendor driver should handle this ioctl to create a fd and manage +the +* life cycle of this fd. +* +* Return: a fd if vendor support that type, -errno if not supported +*/ + +#define VFIO_DEVICE_GET_FD _IO(VFIO_TYPE, VFIO_BASE + 14) + +struct vfio_vgpu_plane_info { +__u64 start; +__u64 drm_format_mod; +__u32 drm_format; +__u32 width; +__u32 height; +__u32 stride; +__u32 size; +__u32 x_pos;
Quoted 8 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 530
Quoted 5 lines
include/uapi/linux/vfio.h +5
-0+__u32 y_pos; +__u32 padding; +}; + +#define VFIO_DEVICE_DMABUF_MGR_FD 0/* Supported fd types */ Move this #define up above
vfio_vgpu_plane_infoto associate it with theVFIO_DEVICE_GET_FDioctl.
OK.
Quoted 15 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 542
Quoted 13 lines
include/uapi/linux/vfio.h +12
-0+ +/* +* VFIO_DEVICE_QUERY_PLANE - _IO(VFIO_TYPE, VFIO_BASE + 15, +* struct vfio_vgpu_query_plane) +* Query plane information +*/ +struct vfio_vgpu_query_plane { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__u32 plane_id; +__u32 padding;This padding doesn't make sense.
This padding is still needed if we do not move the plane_id into vfio_vgpu_plane_info. Right?
Quoted 9 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset {
Quoted 8 lines
include/uapi/linux/vfio.h +7
-0+}; + +#define VFIO_DEVICE_QUERY_PLANE _IO(VFIO_TYPE, VFIO_BASE + 15) + +/* +* VFIO_DEVICE_CREATE_DMABUF - _IO(VFIO, VFIO_BASE + 16, +* struct
vfio_vgpu_create_dmabuf)
Quoted 13 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 559
Quoted 10 lines
include/uapi/linux/vfio.h +10
-0+* +* Create a dma-buf for a plane +*/ +struct vfio_vgpu_create_dmabuf { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__s32 fd; +__u32 plane_id; +};Both of these have a
plane_id, shouldplane_idsimply replace the padding inplane_info?
Precisely speaking plane_id does not belong to the plane info. All the other information are decoded from plane except plane id.
Quoted 2 lines
If not, let's at least put them in the same order so that
plane_idis afterplane_infofor both structs.
Ok.
Quoted 11 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 562
Quoted 3 lines
include/uapi/linux/vfio.h +2
-0+ +#define VFIO_DEVICE_CREATE_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 16)I don't think these should be named just
VFIO_DEVICE_foo, that implies they're ioctls on the vfio device fd, they're not. They need to be associated both in name and more complete descriptions as ioctls to the fd returned from a request for aVFIO_DEVICE_DMABUF_MGR_FD. PerhapsVFIO_DMABUF_MGR_QUERY_PLANE
andVFIO_DMABUF_MGR_CREATE_DMABUF. I'm also not sure why we're using "vgpu" in the structure names here either, the ioctls aren't named after vgpus. Aren't these rather generic to graphics dmabufs, not specifically vgpus?
Make sense. I will change the names.
Thanks,
Quoted 7 lines
Alex
Quoted 4 lines
include/uapi/linux/vfio.h +1
-0+/* -------- API for Type1 VFIO IOMMU -------- */ /**
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operations
Quoted 81 lines · Xiaoguang
Quoted 56 lines
-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Wednesday, June 14, 2017 5:25 AM
To: Chen, Xiaoguang <[email protected]>
Cc: [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; intel-gvt- [email protected]; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>
Subject: Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operationsQuoted 42 lines · On Fri, 9 Jun 2017 14:50:40 +0800 Xiaoguang Chen <[email protected]>…
Here we defined a new ioctl to create a fd for a vfio device based on the input type. Now only one type is supported that is a dma-buf management fd.
Two ioctls are defined for the dma-buf management fd: query the vfio vgpu's plane information and create a dma-buf for a plane.Signed-off-by Xiaoguang Chen <[email protected]>--- include/uapi/linux/vfio.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)include/uapi/linux/vfio.h +22
-0@@ -502,6 +502,64 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_GET_FD - _IO(VFIO_TYPE, VFIO_BASE + 14, __u32) +* +* Create a fd for a vfio device based on the input type +* Vendor driver should handle this ioctl to create a fd and manage +the +* life cycle of this fd. +* +* Return: a fd if vendor support that type, -errno if not supported +*/ + +#define VFIO_DEVICE_GET_FD _IO(VFIO_TYPE, VFIO_BASE + 14) + +struct vfio_vgpu_plane_info { +__u64 start; +__u64 drm_format_mod; +__u32 drm_format; +__u32 width; +__u32 height; +__u32 stride; +__u32 size; +__u32 x_pos;Quoted 8 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 530
Quoted 5 lines
include/uapi/linux/vfio.h +5
-0+__u32 y_pos; +__u32 padding; +}; + +#define VFIO_DEVICE_DMABUF_MGR_FD 0/* Supported fd types */ Move this #define up above
vfio_vgpu_plane_infoto associate it with theVFIO_DEVICE_GET_FDioctl.OK.
Quoted 15 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 542
Quoted 13 lines
include/uapi/linux/vfio.h +12
-0+ +/* +* VFIO_DEVICE_QUERY_PLANE - _IO(VFIO_TYPE, VFIO_BASE + 15, +* struct vfio_vgpu_query_plane) +* Query plane information +*/ +struct vfio_vgpu_query_plane { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__u32 plane_id; +__u32 padding;This padding doesn't make sense.
Quoted 1 line
This padding is still needed if we do not move the
plane_idintovfio_vgpu_plane_info. Right?
I don't see why this padding is ever needed, can you explain? Does the structure not being a multiple of 8 bytes affect any of the offsets within the structure?
Quoted 21 lines
Quoted 8 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset {
Quoted 7 lines
include/uapi/linux/vfio.h +7
-0+}; + +#define VFIO_DEVICE_QUERY_PLANE _IO(VFIO_TYPE, VFIO_BASE + 15) + +/* +* VFIO_DEVICE_CREATE_DMABUF - _IO(VFIO, VFIO_BASE + 16, +* struct
vfio_vgpu_create_dmabuf)Quoted 13 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 559
Quoted 10 lines
include/uapi/linux/vfio.h +10
-0+* +* Create a dma-buf for a plane +*/ +struct vfio_vgpu_create_dmabuf { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__s32 fd; +__u32 plane_id; +};Both of these have a
plane_id, shouldplane_idsimply replace the padding inplane_info?
Quoted 1 line
Precisely speaking
plane_iddoes not belong to the plane info. All the other information are decoded from plane except plane id.
Ok, let's keep is separate then. Thanks,
Alex
Quoted 26 lines
Quoted 2 lines
If not, let's at least put them in the same order so that
plane_idis afterplane_infofor both structs.Ok.
Quoted 11 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 562
Quoted 3 lines
include/uapi/linux/vfio.h +2
-0+ +#define VFIO_DEVICE_CREATE_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 16)I don't think these should be named just
VFIO_DEVICE_foo, that implies they're ioctls on the vfio device fd, they're not. They need to be associated both in name and more complete descriptions as ioctls to the fd returned from a request for aVFIO_DEVICE_DMABUF_MGR_FD. PerhapsVFIO_DMABUF_MGR_QUERY_PLANE
andVFIO_DMABUF_MGR_CREATE_DMABUF. I'm also not sure why we're using "vgpu" in the structure names here either, the ioctls aren't named after vgpus. Aren't these rather generic to graphics dmabufs, not specifically vgpus?Make sense. I will change the names.
Thanks,
Quoted 7 lines
Alex
Quoted 4 lines
include/uapi/linux/vfio.h +1
-0+/* -------- API for Type1 VFIO IOMMU -------- */ /**
RE: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operations
Quoted 98 lines
-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Wednesday, June 14, 2017 11:06 AM
To: Chen, Xiaoguang <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; [email protected]; Wang, Zhi A <[email protected]>; [email protected]
Subject: Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operationsQuoted 82 lines · Xiaoguang
Quoted 57 lines
-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Wednesday, June 14, 2017 5:25 AM
To: Chen, Xiaoguang <[email protected]>
Cc: [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; intel-gvt- [email protected]; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>
Subject: Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operationsQuoted 42 lines · On Fri, 9 Jun 2017 14:50:40 +0800 Xiaoguang Chen <[email protected]>…
Here we defined a new ioctl to create a fd for a vfio device based on the input type. Now only one type is supported that is a dma-buf management fd.
Two ioctls are defined for the dma-buf management fd: query the vfio vgpu's plane information and create a dma-buf for a plane.Signed-off-by Xiaoguang Chen <[email protected]>--- include/uapi/linux/vfio.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)include/uapi/linux/vfio.h +22
-0@@ -502,6 +502,64 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_GET_FD - _IO(VFIO_TYPE, VFIO_BASE + 14, __u32) +* +* Create a fd for a vfio device based on the input type +* Vendor driver should handle this ioctl to create a fd and +manage the +* life cycle of this fd. +* +* Return: a fd if vendor support that type, -errno if not +supported */ + +#define VFIO_DEVICE_GET_FD _IO(VFIO_TYPE, VFIO_BASE + 14) + +struct vfio_vgpu_plane_info { +__u64 start; +__u64 drm_format_mod; +__u32 drm_format; +__u32 width; +__u32 height; +__u32 stride; +__u32 size; +__u32 x_pos;Quoted 8 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 530
Quoted 5 lines
include/uapi/linux/vfio.h +5
-0+__u32 y_pos; +__u32 padding; +}; + +#define VFIO_DEVICE_DMABUF_MGR_FD 0/* Supported fd types */ Move this #define up above
vfio_vgpu_plane_infoto associate it with theVFIO_DEVICE_GET_FDioctl.OK.
Quoted 15 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 542
Quoted 13 lines
include/uapi/linux/vfio.h +12
-0+ +/* +* VFIO_DEVICE_QUERY_PLANE - _IO(VFIO_TYPE, VFIO_BASE + 15, +* struct vfio_vgpu_query_plane) +* Query plane information +*/ +struct vfio_vgpu_query_plane { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__u32 plane_id; +__u32 padding;This padding doesn't make sense.
Quoted 4 lines
Quoted 1 line
This padding is still needed if we do not move the
plane_idinto
vfio_vgpu_plane_info. Right?I don't see why this padding is ever needed, can you explain?
I thought we add the padding to make sure the structure layout is the same in both 32bit and 64bit systems. Am I right?
Quoted 2 lines
Does the structure
not being a multiple of 8 bytes affect any of the offsets within the structure?
No. it will not affect any offsets in the structure.
Quoted 55 lines
Quoted 22 lines
Quoted 9 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset {
Quoted 8 lines
include/uapi/linux/vfio.h +7
-0+}; + +#define VFIO_DEVICE_QUERY_PLANE _IO(VFIO_TYPE, VFIO_BASE + 15) + +/* +* VFIO_DEVICE_CREATE_DMABUF - _IO(VFIO, VFIO_BASE + 16, +* struct
vfio_vgpu_create_dmabuf)Quoted 13 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 559
Quoted 10 lines
include/uapi/linux/vfio.h +10
-0+* +* Create a dma-buf for a plane +*/ +struct vfio_vgpu_create_dmabuf { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__s32 fd; +__u32 plane_id; +};Both of these have a
plane_id, shouldplane_idsimply replace the padding inplane_info?Quoted 1 line
Precisely speaking
plane_iddoes not belong to the plane info. All the otherinformation are decoded from plane except plane id.
Ok, let's keep is separate then. Thanks,
Alex
Quoted 13 lines
Quoted 2 lines
If not, let's at least put them in the same order so that
plane_idis afterplane_infofor both structs.Ok.
Quoted 9 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 562
Quoted 3 lines
include/uapi/linux/vfio.h +2
-0+ +#define VFIO_DEVICE_CREATE_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 16)I don't think these should be named just
VFIO_DEVICE_foo, that implies they're ioctls on the vfio device fd, they're not. They need to be associated both in name and more complete descriptions as ioctls to the fd returned from a request for aVFIO_DEVICE_DMABUF_MGR_FD. Perhaps
VFIO_DMABUF_MGR_QUERY_PLANEandQuoted 1 line
Quoted 1 line
VFIO_DMABUF_MGR_CREATE_DMABUF. I'm also not sure why we're using"vgpu" in the structure names here either, the ioctls aren't named after vgpus.
Quoted 10 lines
Quoted 1 line
Aren't these rather generic to graphics dmabufs, not specifically vgpus?
Make sense. I will change the names.
Thanks,
Quoted 6 lines
Alex
Quoted 3 lines
include/uapi/linux/vfio.h +1
-0+/* -------- API for Type1 VFIO IOMMU -------- */
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
/**
_______________________________________________
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
Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operations
Quoted 96 lines · Xiaoguang
Quoted 96 lines
-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Wednesday, June 14, 2017 11:06 AM
To: Chen, Xiaoguang <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; [email protected]; Wang, Zhi A <[email protected]>; [email protected]
Subject: Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operationsQuoted 82 lines · Xiaoguang
Quoted 57 lines
-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Wednesday, June 14, 2017 5:25 AM
To: Chen, Xiaoguang <[email protected]>
Cc: [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; intel-gvt- [email protected]; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>
Subject: Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operationsQuoted 42 lines · On Fri, 9 Jun 2017 14:50:40 +0800 Xiaoguang Chen <[email protected]>…
Here we defined a new ioctl to create a fd for a vfio device based on the input type. Now only one type is supported that is a dma-buf management fd.
Two ioctls are defined for the dma-buf management fd: query the vfio vgpu's plane information and create a dma-buf for a plane.Signed-off-by Xiaoguang Chen <[email protected]>--- include/uapi/linux/vfio.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)include/uapi/linux/vfio.h +22
-0@@ -502,6 +502,64 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_GET_FD - _IO(VFIO_TYPE, VFIO_BASE + 14, __u32) +* +* Create a fd for a vfio device based on the input type +* Vendor driver should handle this ioctl to create a fd and +manage the +* life cycle of this fd. +* +* Return: a fd if vendor support that type, -errno if not +supported */ + +#define VFIO_DEVICE_GET_FD _IO(VFIO_TYPE, VFIO_BASE + 14) + +struct vfio_vgpu_plane_info { +__u64 start; +__u64 drm_format_mod; +__u32 drm_format; +__u32 width; +__u32 height; +__u32 stride; +__u32 size; +__u32 x_pos;Quoted 8 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 530
Quoted 5 lines
include/uapi/linux/vfio.h +5
-0+__u32 y_pos; +__u32 padding; +}; + +#define VFIO_DEVICE_DMABUF_MGR_FD 0/* Supported fd types */ Move this #define up above
vfio_vgpu_plane_infoto associate it with theVFIO_DEVICE_GET_FDioctl.OK.
Quoted 15 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 542
Quoted 13 lines
include/uapi/linux/vfio.h +12
-0+ +/* +* VFIO_DEVICE_QUERY_PLANE - _IO(VFIO_TYPE, VFIO_BASE + 15, +* struct vfio_vgpu_query_plane) +* Query plane information +*/ +struct vfio_vgpu_query_plane { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__u32 plane_id; +__u32 padding;This padding doesn't make sense.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
This padding is still needed if we do not move the
plane_idinto
vfio_vgpu_plane_info. Right?I don't see why this padding is ever needed, can you explain?
I thought we add the padding to make sure the structure layout is the same in both 32bit and 64bit systems. Am I right?
Isn't it already the same without any of the padding here? Without the padding in vfio_vgpu_plane_info it's 4-byte aligned and we're following it with a 4-byte field, that works the same on 32 and 64bit. Padding the outer structure here makes no sense to me. Generally padding at the end of the structure is to allow flexibility in expanding it within that padding without breaking the ioctl. Here we use _IO and argsz/flags to do that. Thanks,
Alex
Quoted 66 lines
Quoted 2 lines
Does the structure
not being a multiple of 8 bytes affect any of the offsets within the structure?No. it will not affect any offsets in the structure.
Quoted 62 lines
Quoted 22 lines
Quoted 9 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset {
Quoted 8 lines
include/uapi/linux/vfio.h +7
-0+}; + +#define VFIO_DEVICE_QUERY_PLANE _IO(VFIO_TYPE, VFIO_BASE + 15) + +/* +* VFIO_DEVICE_CREATE_DMABUF - _IO(VFIO, VFIO_BASE + 16, +* struct
vfio_vgpu_create_dmabuf)Quoted 13 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 559
Quoted 10 lines
include/uapi/linux/vfio.h +10
-0+* +* Create a dma-buf for a plane +*/ +struct vfio_vgpu_create_dmabuf { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__s32 fd; +__u32 plane_id; +};Both of these have a
plane_id, shouldplane_idsimply replace the padding inplane_info?Quoted 1 line
Precisely speaking
plane_iddoes not belong to the plane info. All the otherinformation are decoded from plane except plane id.
Ok, let's keep is separate then. Thanks,
Alex
Quoted 13 lines
Quoted 2 lines
If not, let's at least put them in the same order so that
plane_idis afterplane_infofor both structs.Ok.
Quoted 9 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 562
Quoted 3 lines
include/uapi/linux/vfio.h +2
-0+ +#define VFIO_DEVICE_CREATE_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 16)I don't think these should be named just
VFIO_DEVICE_foo, that implies they're ioctls on the vfio device fd, they're not. They need to be associated both in name and more complete descriptions as ioctls to the fd returned from a request for aVFIO_DEVICE_DMABUF_MGR_FD. Perhaps
VFIO_DMABUF_MGR_QUERY_PLANEandQuoted 1 line
Quoted 1 line
VFIO_DMABUF_MGR_CREATE_DMABUF. I'm also not sure why we're using"vgpu" in the structure names here either, the ioctls aren't named after vgpus.
Quoted 12 lines
Quoted 1 line
Aren't these rather generic to graphics dmabufs, not specifically vgpus?
Make sense. I will change the names.
Thanks,
Quoted 7 lines
Alex
Quoted 4 lines
include/uapi/linux/vfio.h +1
-0+/* -------- API for Type1 VFIO IOMMU -------- */ /** _______________________________________________
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
RE: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operations
Quoted 122 lines
-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Wednesday, June 14, 2017 11:46 AM
To: Chen, Xiaoguang <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; [email protected]; Wang, Zhi A <[email protected]>; [email protected]
Subject: Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operationsQuoted 71 lines · Xiaoguang
Quoted 71 lines
-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of Alex Williamson
Sent: Wednesday, June 14, 2017 11:06 AM
To: Chen, Xiaoguang <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; [email protected]; Wang, Zhi A <[email protected]>; [email protected]
Subject: Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operationsQuoted 54 lines · Xiaoguang
Quoted 54 lines
-----Original Message-----
From: Alex Williamson [mailto:[email protected]]
Sent: Wednesday, June 14, 2017 5:25 AM
To: Chen, Xiaoguang <[email protected]>
Cc: [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; intel-gvt- [email protected]; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>
Subject: Re: [PATCH v8 4/6] vfio: Define vfio based vgpu's dma-buf operationsQuoted 39 lines · On Fri, 9 Jun 2017 14:50:40 +0800 Xiaoguang Chen <[email protected]>…
Here we defined a new ioctl to create a fd for a vfio device based on the input type. Now only one type is supported that is a dma-buf management fd.
Two ioctls are defined for the dma-buf management fd: query the vfio vgpu's plane information and create a dma-buf for a plane.Signed-off-by Xiaoguang Chen <[email protected]>--- include/uapi/linux/vfio.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)(quoted diff) +0
-0
b/include/uapi/linux/vfio.hindex ae46105..24427b7 100644include/uapi/linux/vfio.h +19
-0@@ -502,6 +502,64 @@ struct vfio_pci_hot_reset {#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** +* VFIO_DEVICE_GET_FD - _IO(VFIO_TYPE, VFIO_BASE + 14, __u32) +* +* Create a fd for a vfio device based on the input type +* Vendor driver should handle this ioctl to create a fd and +manage the +* life cycle of this fd. +* +* Return: a fd if vendor support that type, -errno if not +supported */ + +#define VFIO_DEVICE_GET_FD _IO(VFIO_TYPE, VFIO_BASE + 14) + +struct vfio_vgpu_plane_info { +__u64 start; +__u64 drm_format_mod; +__u32 drm_format; +__u32 width; +__u32 height;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+__u32 stride; +__u32 size; +__u32 x_pos; +__u32 y_pos; +__u32 padding; +}; + +#define VFIO_DEVICE_DMABUF_MGR_FD 0/* Supported fd types */
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Move this #define up above
vfio_vgpu_plane_infoto associate it with theVFIO_DEVICE_GET_FDioctl.OK.
Quoted 5 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset {
Quoted 5 lines
include/uapi/linux/vfio.h +4
-0+ +/* +* VFIO_DEVICE_QUERY_PLANE - _IO(VFIO_TYPE, VFIO_BASE + 15, +* struct
vfio_vgpu_query_plane)Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 542
Quoted 8 lines
include/uapi/linux/vfio.h +8
-0+* Query plane information +*/ +struct vfio_vgpu_query_plane { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__u32 plane_id; +__u32 padding;This padding doesn't make sense.
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
This padding is still needed if we do not move the
plane_idinto
vfio_vgpu_plane_info. Right?I don't see why this padding is ever needed, can you explain?
I thought we add the padding to make sure the structure layout is the same in
both 32bit and 64bit systems.
Quoted 8 lines
Quoted 1 line
Am I right?
Isn't it already the same without any of the padding here? Without the padding in
vfio_vgpu_plane_infoit's 4-byte aligned and we're following it with a 4-byte field, that works the same on 32 and 64bit. Padding the outer structure here makes no sense to me. Generally padding at the end of the structure is to allow flexibility in expanding it within that padding without breaking the ioctl. Here we use_IOand argsz/flags to do that. Thanks,
I got your point. Yes this padding is useless.
Thanks very much : )
Quoted 70 lines
Alex
Quoted 67 lines
Quoted 2 lines
Does the structure
not being a multiple of 8 bytes affect any of the offsets within the structure?No. it will not affect any offsets in the structure.
Quoted 63 lines
Quoted 21 lines
Quoted 9 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset {
Quoted 8 lines
include/uapi/linux/vfio.h +7
-0+}; + +#define VFIO_DEVICE_QUERY_PLANE _IO(VFIO_TYPE, VFIO_BASE + 15) + +/* +* VFIO_DEVICE_CREATE_DMABUF - _IO(VFIO, VFIO_BASE + 16, +* struct
vfio_vgpu_create_dmabuf)Quoted 12 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 559
Quoted 9 lines
include/uapi/linux/vfio.h +9
-0+* +* Create a dma-buf for a plane */ struct +vfio_vgpu_create_dmabuf { +__u32 argsz; +__u32 flags; +struct vfio_vgpu_plane_info plane_info; +__s32 fd; +__u32 plane_id; +};Both of these have a
plane_id, shouldplane_idsimply replace the padding inplane_info?Quoted 2 lines
Precisely speaking
plane_iddoes not belong to the plane info. All the otherinformation are decoded from plane except plane id.
Ok, let's keep is separate then. Thanks,
Alex
Quoted 14 lines
Quoted 2 lines
If not, let's at least put them in the same order so that
plane_idis afterplane_infofor both structs.Ok.
Quoted 10 lines
include/uapi/linux/vfio.h struct vfio_pci_hot_reset { · line 562
Quoted 4 lines
include/uapi/linux/vfio.h +3
-0+ +#define VFIO_DEVICE_CREATE_DMABUF _IO(VFIO_TYPE, VFIO_BASE + +16)I don't think these should be named just
VFIO_DEVICE_foo, that implies they're ioctls on the vfio device fd, they're not. They need to be associated both in name and more complete descriptions as ioctls to the fd returned from a request for aVFIO_DEVICE_DMABUF_MGR_FD. Perhaps
VFIO_DMABUF_MGR_QUERY_PLANEandQuoted 1 line
Quoted 1 line
VFIO_DMABUF_MGR_CREATE_DMABUF. I'm also not sure why we're using"vgpu" in the structure names here either, the ioctls aren't named after vgpus.
Quoted 12 lines
Quoted 1 line
Aren't these rather generic to graphics dmabufs, not specifically vgpus?
Make sense. I will change the names.
Thanks,
Quoted 7 lines
Alex
Quoted 4 lines
include/uapi/linux/vfio.h +1
-0+/* -------- API for Type1 VFIO IOMMU -------- */ /** _______________________________________________
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
Re: [PATCH v8 3/6] drm/i915/gvt: Frame buffer decoder support for GVT-g
In reply to Xiaoguang ChenQuoted 3 lines · Xiaoguang Chen
decode frambuffer attributes of primary, cursor and sprite plane
Signed-off-by Xiaoguang Chen <[email protected]>
...
Quoted 36 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c new file +36
-0+/** +* intel_vgpu_decode_primary_plane - Decode primary plane +* @vgpu: input vgpu +* @plane: primary plane to save decoded info +* This function is called for decoding plane +* +* Returns: +* 0 on success, non-zero if failed. +*/ +int intel_vgpu_decode_primary_plane (struct intel_vgpu *vgpu, +struct intel_vgpu_primary_plane_format *plane) +{ +u32 val, fmt; +struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; +int pipe; + + pipe =get_active_pipe (vgpu); +if (pipe >=I915_MAX_PIPES ) +return -ENODEV ; + + val =vgpu_vreg (vgpu,DSPCNTR (pipe)); + plane->enabled = !!(val &DISPLAY_PLANE_ENABLE ); +if (!plane->enabled) +return -ENODEV ; + +if (IS_SKYLAKE (dev_priv)) { + plane->tiled = (val &PLANE_CTL_TILED_MASK ) >> + _PLANE_CTL_TILED_SHIFT; + fmt =skl_format_to_drm ( + val &PLANE_CTL_FORMAT_MASK , + val &PLANE_CTL_ORDER_RGBX , + val &PLANE_CTL_ALPHA_MASK , + val &PLANE_CTL_YUV422_ORDER_MASK ); + plane->bpp = skl_pixel_formats[fmt].bpp; + plane->drm_format = skl_pixel_formats[fmt].drm_format; + }else {
drivers/gpu/drm/i915/gvt/fb_decoder.c line 219
Quoted 10 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c new file +10
-0+ plane->tiled = !!(val &DISPPLANE_TILED ); + fmt = (val &DISPPLANE_PIXFORMAT_MASK ) >> _PRI_PLANE_FMT_SHIFT; + plane->bpp = bdw_pixel_formats[fmt].bpp; + plane->drm_format = bdw_pixel_formats[fmt].drm_format; + } + +if (!skl_pixel_formats[fmt].bpp && !bdw_pixel_formats[fmt].bpp) { +gvt_vgpu_err ("Non-supported pixel format (0x%x)\n" , fmt); +return -EINVAL ; + }
Is this correct? shouldn't be plane->bpp as last time comment?
Quoted 5 lines
include/uapi/drm/drm_fourcc.h +0
-0
include/uapi/drm/drm_fourcc.h extern "C" { · line 170
Quoted 10 lines
include/uapi/drm/drm_fourcc.h +6
-0@@ -161,6 +161,12 @@ extern "C" {#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4')/* non-subsampled Cb (1) and Cr (2) planes */ #define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4')/* non-subsampled Cr (1) and Cb (2) planes */ +/* +* Intel GVT-g plane format definition +*/ +#define DRM_FORMAT_XRGB161616_GVT fourcc_code('X', 'R', '4', '8')/* [63:0] x:R:G:B 16:16:16:16 little endian */ +#define DRM_FORMAT_XBGR161616_GVT fourcc_code('X', 'B', '4', '8')/* [63:0] x:B:G:R 16:16:16:16 little endian */ +
This should be a seperate patch and not need GVT postfix for format definition.
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 v8 3/6] drm/i915/gvt: Frame buffer decoder support for GVT-g
Quoted 59 lines
-----Original Message-----
From: Zhenyu Wang [mailto:[email protected]]
Sent: Wednesday, June 14, 2017 5:39 PM
To: Chen, Xiaoguang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; intel-gvt- [email protected]; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>
Subject: Re: [PATCH v8 3/6] drm/i915/gvt: Frame buffer decoder support for GVT- gQuoted 3 lines · Xiaoguang Chen
decode frambuffer attributes of primary, cursor and sprite plane
Signed-off-by Xiaoguang Chen <[email protected]>...
Quoted 27 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c new file +27
-0+/** +* intel_vgpu_decode_primary_plane - Decode primary plane +* @vgpu: input vgpu +* @plane: primary plane to save decoded info +* This function is called for decoding plane +* +* Returns: +* 0 on success, non-zero if failed. +*/ +int intel_vgpu_decode_primary_plane (struct intel_vgpu *vgpu, +struct intel_vgpu_primary_plane_format *plane) { +u32 val, fmt; +struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; +int pipe; + + pipe =get_active_pipe (vgpu); +if (pipe >=I915_MAX_PIPES ) +return -ENODEV ; + + val =vgpu_vreg (vgpu,DSPCNTR (pipe)); + plane->enabled = !!(val &DISPLAY_PLANE_ENABLE ); +if (!plane->enabled) +return -ENODEV ; + +if (IS_SKYLAKE (dev_priv)) { + plane->tiled = (val &PLANE_CTL_TILED_MASK ) >> + _PLANE_CTL_TILED_SHIFT;drivers/gpu/drm/i915/gvt/fb_decoder.c
Quoted 10 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c new file +10
-0+ fmt =skl_format_to_drm ( + val &PLANE_CTL_FORMAT_MASK , + val &PLANE_CTL_ORDER_RGBX , + val &PLANE_CTL_ALPHA_MASK , + val &PLANE_CTL_YUV422_ORDER_MASK ); + plane->bpp = skl_pixel_formats[fmt].bpp; + plane->drm_format = skl_pixel_formats[fmt].drm_format; + }else { + plane->tiled = !!(val &DISPPLANE_TILED ); + fmt = (val & DISPPLANE_PIXFORMAT_MASK) >>
_PRI_PLANE_FMT_SHIFT;
Quoted 10 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c line 219
Quoted 8 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c new file +8
-0+ plane->bpp = bdw_pixel_formats[fmt].bpp; + plane->drm_format = bdw_pixel_formats[fmt].drm_format; + } + +if (!skl_pixel_formats[fmt].bpp && !bdw_pixel_formats[fmt].bpp) { +gvt_vgpu_err ("Non-supported pixel format (0x%x)\n" , fmt); +return -EINVAL ; + }Is this correct? shouldn't be
plane->bppas last time comment?
Yes. But use plane->bpp is more concisely. Will change.
Quoted 11 lines
include/uapi/drm/drm_fourcc.h extern "C" { · line 161
Quoted 7 lines
(quoted diff) +0
-0
b/include/uapi/drm/drm_fourcc.hindex 55e3010..400759f 100644include/uapi/drm/drm_fourcc.h +0
-0@@ -161,6 +161,12 @@ extern "C" {#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4')/* non- subsampled Cb (1) and Cr (2) planes */
include/uapi/drm/drm_fourcc.h extern "C" { · line 162
Quoted 1 line
include/uapi/drm/drm_fourcc.h +0
-0#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4')/* non- subsampled Cr (1) and Cb (2) planes */
Quoted 1 line
Quoted 10 lines
include/uapi/drm/drm_fourcc.h
Quoted 8 lines
include/uapi/drm/drm_fourcc.h +7
-0+/* +* Intel GVT-g plane format definition */ #define +DRM_FORMAT_XRGB161616_GVT fourcc_code('X', 'R', '4', '8')/* [63:0] +x:R:G:B 16:16:16:16 little endian */ #define +DRM_FORMAT_XBGR161616_GVT fourcc_code('X', 'B', '4', '8')/* [63:0] +x:B:G:R 16:16:16:16 little endian */ +This should be a seperate patch and not need GVT postfix for format definition.
OK.
Quoted 5 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