From: Zhi Wang <zhi.a.wang@intel.com>
To: intel-gfx@lists.freedesktop.org, igvt-g@lists.01.org
Cc: daniel.vetter@ffwll.ch, david.j.cowperthwaite@intel.com
Subject: [RFC 23/29] drm/i915: gvt: Introduce GVT control interface
Date: Thu, 28 Jan 2016 18:21:45 +0800 [thread overview]
Message-ID: <1453976511-27322-24-git-send-email-zhi.a.wang@intel.com> (raw)
In-Reply-To: <1453976511-27322-1-git-send-email-zhi.a.wang@intel.com>
From: Yi Sun <yi.sun@intel.com>
This patch introduces the control interface for creating/destroying vGPUs.
Signed-off-by: Yi Sun <yi.sun@intel.com>
Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
---
drivers/gpu/drm/i915/gvt/Makefile | 2 +-
drivers/gpu/drm/i915/gvt/control.c | 181 +++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/gvt/gvt.c | 4 +
drivers/gpu/drm/i915/gvt/gvt.h | 8 ++
4 files changed, 194 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpu/drm/i915/gvt/control.c
diff --git a/drivers/gpu/drm/i915/gvt/Makefile b/drivers/gpu/drm/i915/gvt/Makefile
index c146c57..8874fe0 100644
--- a/drivers/gpu/drm/i915/gvt/Makefile
+++ b/drivers/gpu/drm/i915/gvt/Makefile
@@ -1,6 +1,6 @@
GVT_SOURCE := gvt.o params.o aperture_gm.o mmio.o handlers.o instance.o \
trace_points.o interrupt.o gtt.o cfg_space.o opregion.o utility.o \
- fb_decoder.o display.o edid.o
+ fb_decoder.o display.o edid.o control.o
ccflags-y += -I$(src) -I$(src)/.. -Wall -Werror -Wno-unused-function
i915_gvt-y := $(GVT_SOURCE)
diff --git a/drivers/gpu/drm/i915/gvt/control.c b/drivers/gpu/drm/i915/gvt/control.c
new file mode 100644
index 0000000..625d213
--- /dev/null
+++ b/drivers/gpu/drm/i915/gvt/control.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright(c) 2011-2016 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.
+ */
+
+#include "gvt.h"
+
+#define GVT_TYPE (';')
+#define GVT_BASE 0xA0
+
+#define GVT_CREATE_INSTANCE _IOW(GVT_TYPE, GVT_BASE + 0, struct gvt_instance_info)
+#define GVT_DESTROY_INSTANCE _IOW(GVT_TYPE, GVT_BASE + 1, s32)
+
+struct misc_device_client_info {
+ struct pgt_device *pdev;
+ struct vgt_device *vgt;
+ struct mutex lock;
+};
+
+static int misc_device_open(struct inode *inode, struct file *filp)
+{
+ struct miscdevice *dev = filp->private_data;
+ struct pgt_device *pdev = container_of(dev, struct pgt_device, control.misc_device);
+ struct misc_device_client_info *info = NULL;
+
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (!info) {
+ gvt_err("fail to allocate memory");
+ return -ENOMEM;
+ }
+
+ info->pdev = pdev;
+ mutex_init(&info->lock);
+
+ filp->private_data = info;
+
+ return 0;
+}
+
+static int misc_device_close(struct inode *inode, struct file *filp)
+{
+ struct misc_device_client_info *info = filp->private_data;
+
+ if (info->vgt)
+ gvt_destroy_instance(info->vgt);
+
+ kfree(info);
+ filp->private_data = NULL;
+ return 0;
+}
+
+static long misc_device_ioctl(struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ struct misc_device_client_info *info = filp->private_data;
+ struct gvt_instance_info param;
+ int r = 0;
+
+ if (copy_from_user(¶m, (void *)arg, sizeof(param)))
+ return -EFAULT;
+
+ mutex_lock(&info->lock);
+ switch(cmd) {
+ case GVT_CREATE_INSTANCE:
+ if (info->vgt) {
+ gvt_err("instance has already been created");
+ r = -EEXIST;
+ goto out;
+ }
+
+ info->vgt = gvt_create_instance(info->pdev, ¶m);
+
+ if (!info->vgt) {
+ gvt_err("fail to create instance");
+ r = -ENOMEM;
+ goto out;
+ }
+ break;
+ case GVT_DESTROY_INSTANCE:
+ if (!info->vgt) {
+ r = -ENODEV;
+ goto out;
+ }
+ gvt_destroy_instance(info->vgt);
+ info->vgt = NULL;
+ break;
+ default:
+ r = -EINVAL;
+ goto out;
+ }
+out:
+ mutex_unlock(&info->lock);
+ return r;
+}
+
+static struct file_operations misc_device_fops =
+{
+ .open = misc_device_open,
+ .release = misc_device_close,
+ .unlocked_ioctl = misc_device_ioctl,
+ .compat_ioctl = misc_device_ioctl,
+};
+
+void clean_misc_device(struct pgt_device *pdev)
+{
+ struct miscdevice *dev = &pdev->control.misc_device;
+
+ if (!list_empty(&dev->list))
+ misc_deregister(dev);
+
+ if (dev->name) {
+ kfree(dev->name);
+ dev->name = NULL;
+ }
+}
+
+bool setup_misc_device(struct pgt_device *pdev)
+{
+ struct miscdevice *dev = &pdev->control.misc_device;
+ unsigned long len;
+ char name[32];
+
+ len = snprintf(name, 32, "dri/gvt%d", pdev->id);
+ dev->name = kzalloc(len + 1, GFP_KERNEL);
+ if (!dev->name) {
+ gvt_err("fail to allocate memory");
+ return false;
+ }
+
+ dev->name = name;
+ dev->minor = MISC_DYNAMIC_MINOR;
+ dev->fops = &misc_device_fops;
+
+ INIT_LIST_HEAD(&dev->list);
+
+ if (misc_register(dev) < 0) {
+ gvt_err("fail to register miscdevice");
+ goto err;
+ }
+
+ return true;
+err:
+ clean_misc_device(pdev);
+ return false;
+}
+
+bool gvt_setup_control_interface(struct pgt_device *pdev)
+{
+ bool r;
+
+ r = setup_misc_device(pdev);
+ if (!r) {
+ gvt_err("fail to setup misc device node\n");
+ return false;
+ }
+
+ return true;
+}
+
+void gvt_clean_control_interface(struct pgt_device *pdev)
+{
+ clean_misc_device(pdev);
+}
diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c
index ea871cd..77fe5d39 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.c
+++ b/drivers/gpu/drm/i915/gvt/gvt.c
@@ -283,6 +283,7 @@ static bool init_service_thread(struct pgt_device *pdev)
static void clean_pgt_device(struct pgt_device *pdev)
{
clean_service_thread(pdev);
+ gvt_clean_control_interface(pdev);
gvt_clean_gtt(pdev);
gvt_irq_exit(pdev);
gvt_clean_mmio_emulation_state(pdev);
@@ -315,6 +316,9 @@ static bool init_pgt_device(struct pgt_device *pdev, struct drm_i915_private *de
if (!gvt_init_gtt(pdev))
goto err;
+ if (!gvt_setup_control_interface(pdev))
+ goto err;
+
if (!init_service_thread(pdev))
goto err;
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index b44b5b5..1d5c15c 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -163,6 +163,10 @@ struct gvt_gm_allocator {
struct drm_mm high_gm;
};
+struct gvt_device_control {
+ struct miscdevice misc_device;
+};
+
struct pgt_device {
struct mutex lock;
int id;
@@ -214,6 +218,7 @@ struct pgt_device {
struct pgt_statistics stat;
struct gvt_gtt_info gtt;
+ struct gvt_device_control control;
};
/* request types to wake up main thread */
@@ -688,6 +693,9 @@ bool register_mmio_handler(struct pgt_device *pdev, unsigned int start, int byte
bool gvt_update_display_events_emulation(struct pgt_device *pdev);
void gvt_emulate_display_events(struct pgt_device *pdev);
+bool gvt_setup_control_interface(struct pgt_device *pdev);
+void gvt_clean_control_interface(struct pgt_device *pdev);
+
#include "mpt.h"
#endif
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-01-28 10:24 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-28 10:21 [RFC 00/29] iGVT-g implementation in i915 Zhi Wang
2016-01-28 10:21 ` [RFC 01/29] drm/i915/gvt: Introduce the basic architecture of GVT-g Zhi Wang
2016-01-29 13:57 ` Joonas Lahtinen
2016-01-29 16:48 ` Chris Wilson
2016-02-03 6:28 ` Zhi Wang
2016-02-05 7:02 ` Zhiyuan Lv
2016-02-03 6:01 ` Zhi Wang
2016-02-03 7:01 ` Zhiyuan Lv
2016-02-04 11:25 ` Joonas Lahtinen
2016-02-16 9:54 ` Zhi Wang
2016-02-16 12:44 ` Jani Nikula
2016-02-16 14:08 ` Joonas Lahtinen
2016-01-28 10:21 ` [RFC 02/29] drm/i915: Introduce host graphics memory balloon for gvt Zhi Wang
2016-02-04 11:27 ` Joonas Lahtinen
2016-02-05 10:03 ` Zhiyuan Lv
2016-02-05 13:40 ` Joonas Lahtinen
2016-02-05 14:16 ` Zhiyuan Lv
2016-02-08 11:52 ` Joonas Lahtinen
2016-02-10 8:08 ` Daniel Vetter
2016-01-28 10:21 ` [RFC 03/29] drm/i915: Introduce GVT context creation API Zhi Wang
2016-01-28 10:21 ` [RFC 04/29] drm/i915: Ondemand populate context addressing mode bit Zhi Wang
2016-01-28 10:21 ` [RFC 05/29] drm/i915: Do not populate PPGTT root pointers for GVT context Zhi Wang
2016-01-28 10:21 ` [RFC 06/29] drm/i915: Do not initialize the engine state of " Zhi Wang
2016-01-28 10:21 ` [RFC 07/29] drm/i915: GVT context scheduling Zhi Wang
2016-01-28 10:21 ` [RFC 08/29] drm/i915: Support vGPU guest framebuffer GEM object Zhi Wang
2016-01-28 10:21 ` [RFC 09/29] drm/i915: gvt: Resource allocator Zhi Wang
2016-01-28 10:21 ` [RFC 10/29] drm/i915: gvt: Basic mmio emulation state Zhi Wang
2016-01-28 10:21 ` [RFC 11/29] drm/i915: gvt: update PVINFO page definition in i915_vgpu.h Zhi Wang
2016-01-28 10:21 ` [RFC 12/29] drm/i915: gvt: vGPU life cycle management Zhi Wang
2016-01-28 10:21 ` [RFC 13/29] drm/i915: gvt: trace stub Zhi Wang
2016-01-28 10:21 ` [RFC 14/29] drm/i915: gvt: vGPU interrupt emulation framework Zhi Wang
2016-01-28 10:21 ` [RFC 15/29] drm/i915: gvt: vGPU graphics memory " Zhi Wang
2016-01-28 10:21 ` [RFC 16/29] drm/i915: gvt: Generic MPT framework Zhi Wang
2016-01-28 10:21 ` [RFC 17/29] gvt: Xen hypervisor GVT-g MPT module Zhi Wang
2016-01-28 11:33 ` Joonas Lahtinen
2016-01-28 12:50 ` Zhiyuan Lv
2016-01-28 10:21 ` [RFC 18/29] drm/i915: gvt: vGPU configuration emulation Zhi Wang
2016-01-28 10:21 ` [RFC 19/29] drm/i915: gvt: vGPU OpRegion emulation Zhi Wang
2016-01-28 10:21 ` [RFC 20/29] drm/i915: gvt: vGPU framebuffer format decoder Zhi Wang
2016-01-28 10:21 ` [RFC 21/29] drm/i915: gvt: vGPU MMIO register emulation Zhi Wang
2016-01-28 10:21 ` [RFC 22/29] drm/i915: gvt: Full display virtualization Zhi Wang
2016-01-28 10:21 ` Zhi Wang [this message]
2016-01-28 10:21 ` [RFC 24/29] drm/i915: gvt: Full execlist status emulation Zhi Wang
2016-01-28 10:21 ` [RFC 25/29] drm/i915: gvt: vGPU execlist workload submission Zhi Wang
2016-01-28 10:21 ` [RFC 26/29] drm/i915: gvt: workload scheduler Zhi Wang
2016-01-28 10:21 ` [RFC 27/29] drm/i915: gvt: vGPU schedule policy framework Zhi Wang
2016-01-28 10:21 ` [RFC 28/29] drm/i915: gvt: vGPU context switch Zhi Wang
2016-01-28 10:21 ` [RFC 29/29] drm/i915: gvt: vGPU command scanner Zhi Wang
2016-01-28 17:15 ` ✗ Fi.CI.BAT: failure for iGVT-g implementation in i915 Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1453976511-27322-24-git-send-email-zhi.a.wang@intel.com \
--to=zhi.a.wang@intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=david.j.cowperthwaite@intel.com \
--cc=igvt-g@lists.01.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).