Commit 710bb9cf authored by Rodrigo Vivi's avatar Rodrigo Vivi

Merge tag 'gvt-next-2019-08-13' of https://github.com/intel/gvt-linux into drm-intel-next-queued

gvt-next-2019-08-13

- Enhance command parser for extra length check (Fred)
- remove debugfs function return check (Greg)
- batch buffer end double check after shadow copy (Tina)
- one typo fix (Zhenyu)
- klocwork warning fix (Zhi)
- use struct_size() helper (Gustavo)
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
From: Zhenyu Wang <zhenyuw@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190813100604.GG19140@zhen-hp.sh.intel.com
parents 3a0f1604 220b65d8
This diff is collapsed.
...@@ -189,36 +189,19 @@ DEFINE_SIMPLE_ATTRIBUTE(vgpu_scan_nonprivbb_fops, ...@@ -189,36 +189,19 @@ DEFINE_SIMPLE_ATTRIBUTE(vgpu_scan_nonprivbb_fops,
/** /**
* intel_gvt_debugfs_add_vgpu - register debugfs entries for a vGPU * intel_gvt_debugfs_add_vgpu - register debugfs entries for a vGPU
* @vgpu: a vGPU * @vgpu: a vGPU
*
* Returns:
* Zero on success, negative error code if failed.
*/ */
int intel_gvt_debugfs_add_vgpu(struct intel_vgpu *vgpu) void intel_gvt_debugfs_add_vgpu(struct intel_vgpu *vgpu)
{ {
struct dentry *ent;
char name[16] = ""; char name[16] = "";
snprintf(name, 16, "vgpu%d", vgpu->id); snprintf(name, 16, "vgpu%d", vgpu->id);
vgpu->debugfs = debugfs_create_dir(name, vgpu->gvt->debugfs_root); vgpu->debugfs = debugfs_create_dir(name, vgpu->gvt->debugfs_root);
if (!vgpu->debugfs)
return -ENOMEM;
ent = debugfs_create_bool("active", 0444, vgpu->debugfs,
&vgpu->active);
if (!ent)
return -ENOMEM;
ent = debugfs_create_file("mmio_diff", 0444, vgpu->debugfs,
vgpu, &vgpu_mmio_diff_fops);
if (!ent)
return -ENOMEM;
ent = debugfs_create_file("scan_nonprivbb", 0644, vgpu->debugfs,
vgpu, &vgpu_scan_nonprivbb_fops);
if (!ent)
return -ENOMEM;
return 0; debugfs_create_bool("active", 0444, vgpu->debugfs, &vgpu->active);
debugfs_create_file("mmio_diff", 0444, vgpu->debugfs, vgpu,
&vgpu_mmio_diff_fops);
debugfs_create_file("scan_nonprivbb", 0644, vgpu->debugfs, vgpu,
&vgpu_scan_nonprivbb_fops);
} }
/** /**
...@@ -234,27 +217,15 @@ void intel_gvt_debugfs_remove_vgpu(struct intel_vgpu *vgpu) ...@@ -234,27 +217,15 @@ void intel_gvt_debugfs_remove_vgpu(struct intel_vgpu *vgpu)
/** /**
* intel_gvt_debugfs_init - register gvt debugfs root entry * intel_gvt_debugfs_init - register gvt debugfs root entry
* @gvt: GVT device * @gvt: GVT device
*
* Returns:
* zero on success, negative if failed.
*/ */
int intel_gvt_debugfs_init(struct intel_gvt *gvt) void intel_gvt_debugfs_init(struct intel_gvt *gvt)
{ {
struct drm_minor *minor = gvt->dev_priv->drm.primary; struct drm_minor *minor = gvt->dev_priv->drm.primary;
struct dentry *ent;
gvt->debugfs_root = debugfs_create_dir("gvt", minor->debugfs_root); gvt->debugfs_root = debugfs_create_dir("gvt", minor->debugfs_root);
if (!gvt->debugfs_root) {
gvt_err("Cannot create debugfs dir\n");
return -ENOMEM;
}
ent = debugfs_create_ulong("num_tracked_mmio", 0444, gvt->debugfs_root, debugfs_create_ulong("num_tracked_mmio", 0444, gvt->debugfs_root,
&gvt->mmio.num_tracked_mmio); &gvt->mmio.num_tracked_mmio);
if (!ent)
return -ENOMEM;
return 0;
} }
/** /**
......
...@@ -375,9 +375,7 @@ int intel_gvt_init_device(struct drm_i915_private *dev_priv) ...@@ -375,9 +375,7 @@ int intel_gvt_init_device(struct drm_i915_private *dev_priv)
} }
gvt->idle_vgpu = vgpu; gvt->idle_vgpu = vgpu;
ret = intel_gvt_debugfs_init(gvt); intel_gvt_debugfs_init(gvt);
if (ret)
gvt_err("debugfs registration failed, go on.\n");
gvt_dbg_core("gvt device initialization is done\n"); gvt_dbg_core("gvt device initialization is done\n");
dev_priv->gvt = gvt; dev_priv->gvt = gvt;
......
...@@ -334,6 +334,10 @@ struct intel_gvt { ...@@ -334,6 +334,10 @@ struct intel_gvt {
struct { struct {
struct engine_mmio *mmio; struct engine_mmio *mmio;
int ctx_mmio_count[I915_NUM_ENGINES]; int ctx_mmio_count[I915_NUM_ENGINES];
u32 *tlb_mmio_offset_list;
u32 tlb_mmio_offset_list_cnt;
u32 *mocs_mmio_offset_list;
u32 mocs_mmio_offset_list_cnt;
} engine_mmio_list; } engine_mmio_list;
struct dentry *debugfs_root; struct dentry *debugfs_root;
...@@ -682,9 +686,9 @@ static inline void intel_gvt_mmio_set_in_ctx( ...@@ -682,9 +686,9 @@ static inline void intel_gvt_mmio_set_in_ctx(
gvt->mmio.mmio_attribute[offset >> 2] |= F_IN_CTX; gvt->mmio.mmio_attribute[offset >> 2] |= F_IN_CTX;
} }
int intel_gvt_debugfs_add_vgpu(struct intel_vgpu *vgpu); void intel_gvt_debugfs_add_vgpu(struct intel_vgpu *vgpu);
void intel_gvt_debugfs_remove_vgpu(struct intel_vgpu *vgpu); void intel_gvt_debugfs_remove_vgpu(struct intel_vgpu *vgpu);
int intel_gvt_debugfs_init(struct intel_gvt *gvt); void intel_gvt_debugfs_init(struct intel_gvt *gvt);
void intel_gvt_debugfs_clean(struct intel_gvt *gvt); void intel_gvt_debugfs_clean(struct intel_gvt *gvt);
......
...@@ -672,7 +672,7 @@ void intel_gvt_clean_irq(struct intel_gvt *gvt) ...@@ -672,7 +672,7 @@ void intel_gvt_clean_irq(struct intel_gvt *gvt)
hrtimer_cancel(&irq->vblank_timer.timer); hrtimer_cancel(&irq->vblank_timer.timer);
} }
#define VBLNAK_TIMER_PERIOD 16000000 #define VBLANK_TIMER_PERIOD 16000000
/** /**
* intel_gvt_init_irq - initialize GVT-g IRQ emulation subsystem * intel_gvt_init_irq - initialize GVT-g IRQ emulation subsystem
...@@ -704,7 +704,7 @@ int intel_gvt_init_irq(struct intel_gvt *gvt) ...@@ -704,7 +704,7 @@ int intel_gvt_init_irq(struct intel_gvt *gvt)
hrtimer_init(&vblank_timer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); hrtimer_init(&vblank_timer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
vblank_timer->timer.function = vblank_timer_fn; vblank_timer->timer.function = vblank_timer_fn;
vblank_timer->period = VBLNAK_TIMER_PERIOD; vblank_timer->period = VBLANK_TIMER_PERIOD;
return 0; return 0;
} }
...@@ -1306,7 +1306,6 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, ...@@ -1306,7 +1306,6 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
unsigned int i; unsigned int i;
int ret; int ret;
struct vfio_region_info_cap_sparse_mmap *sparse = NULL; struct vfio_region_info_cap_sparse_mmap *sparse = NULL;
size_t size;
int nr_areas = 1; int nr_areas = 1;
int cap_type_id; int cap_type_id;
...@@ -1349,9 +1348,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, ...@@ -1349,9 +1348,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
VFIO_REGION_INFO_FLAG_WRITE; VFIO_REGION_INFO_FLAG_WRITE;
info.size = gvt_aperture_sz(vgpu->gvt); info.size = gvt_aperture_sz(vgpu->gvt);
size = sizeof(*sparse) + sparse = kzalloc(struct_size(sparse, areas, nr_areas),
(nr_areas * sizeof(*sparse->areas)); GFP_KERNEL);
sparse = kzalloc(size, GFP_KERNEL);
if (!sparse) if (!sparse)
return -ENOMEM; return -ENOMEM;
...@@ -1416,9 +1414,9 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, ...@@ -1416,9 +1414,9 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
switch (cap_type_id) { switch (cap_type_id) {
case VFIO_REGION_INFO_CAP_SPARSE_MMAP: case VFIO_REGION_INFO_CAP_SPARSE_MMAP:
ret = vfio_info_add_capability(&caps, ret = vfio_info_add_capability(&caps,
&sparse->header, sizeof(*sparse) + &sparse->header,
(sparse->nr_areas * struct_size(sparse, areas,
sizeof(*sparse->areas))); sparse->nr_areas));
if (ret) { if (ret) {
kfree(sparse); kfree(sparse);
return ret; return ret;
...@@ -1798,9 +1796,6 @@ static int kvmgt_guest_init(struct mdev_device *mdev) ...@@ -1798,9 +1796,6 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
"kvmgt_nr_cache_entries", "kvmgt_nr_cache_entries",
0444, vgpu->debugfs, 0444, vgpu->debugfs,
&vgpu->vdev.nr_cache_entries); &vgpu->vdev.nr_cache_entries);
if (!info->debugfs_cache_entries)
gvt_vgpu_err("Cannot create kvmgt debugfs entry\n");
return 0; return 0;
} }
......
...@@ -148,19 +148,27 @@ static struct { ...@@ -148,19 +148,27 @@ static struct {
u32 l3cc_table[GEN9_MOCS_SIZE / 2]; u32 l3cc_table[GEN9_MOCS_SIZE / 2];
} gen9_render_mocs; } gen9_render_mocs;
static void load_render_mocs(struct drm_i915_private *dev_priv) static u32 gen9_mocs_mmio_offset_list[] = {
{
i915_reg_t offset;
u32 regs[] = {
[RCS0] = 0xc800, [RCS0] = 0xc800,
[VCS0] = 0xc900, [VCS0] = 0xc900,
[VCS1] = 0xca00, [VCS1] = 0xca00,
[BCS0] = 0xcc00, [BCS0] = 0xcc00,
[VECS0] = 0xcb00, [VECS0] = 0xcb00,
}; };
static void load_render_mocs(struct drm_i915_private *dev_priv)
{
struct intel_gvt *gvt = dev_priv->gvt;
i915_reg_t offset;
u32 cnt = gvt->engine_mmio_list.mocs_mmio_offset_list_cnt;
u32 *regs = gvt->engine_mmio_list.mocs_mmio_offset_list;
int ring_id, i; int ring_id, i;
for (ring_id = 0; ring_id < ARRAY_SIZE(regs); ring_id++) { /* Platform doesn't have mocs mmios. */
if (!regs)
return;
for (ring_id = 0; ring_id < cnt; ring_id++) {
if (!HAS_ENGINE(dev_priv, ring_id)) if (!HAS_ENGINE(dev_priv, ring_id))
continue; continue;
offset.reg = regs[ring_id]; offset.reg = regs[ring_id];
...@@ -327,22 +335,28 @@ int intel_vgpu_restore_inhibit_context(struct intel_vgpu *vgpu, ...@@ -327,22 +335,28 @@ int intel_vgpu_restore_inhibit_context(struct intel_vgpu *vgpu,
return ret; return ret;
} }
static u32 gen8_tlb_mmio_offset_list[] = {
[RCS0] = 0x4260,
[VCS0] = 0x4264,
[VCS1] = 0x4268,
[BCS0] = 0x426c,
[VECS0] = 0x4270,
};
static void handle_tlb_pending_event(struct intel_vgpu *vgpu, int ring_id) static void handle_tlb_pending_event(struct intel_vgpu *vgpu, int ring_id)
{ {
struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
struct intel_uncore *uncore = &dev_priv->uncore; struct intel_uncore *uncore = &dev_priv->uncore;
struct intel_vgpu_submission *s = &vgpu->submission; struct intel_vgpu_submission *s = &vgpu->submission;
u32 *regs = vgpu->gvt->engine_mmio_list.tlb_mmio_offset_list;
u32 cnt = vgpu->gvt->engine_mmio_list.tlb_mmio_offset_list_cnt;
enum forcewake_domains fw; enum forcewake_domains fw;
i915_reg_t reg; i915_reg_t reg;
u32 regs[] = {
[RCS0] = 0x4260,
[VCS0] = 0x4264,
[VCS1] = 0x4268,
[BCS0] = 0x426c,
[VECS0] = 0x4270,
};
if (WARN_ON(ring_id >= ARRAY_SIZE(regs))) if (!regs)
return;
if (WARN_ON(ring_id >= cnt))
return; return;
if (!test_and_clear_bit(ring_id, (void *)s->tlb_handle_pending)) if (!test_and_clear_bit(ring_id, (void *)s->tlb_handle_pending))
...@@ -565,10 +579,17 @@ void intel_gvt_init_engine_mmio_context(struct intel_gvt *gvt) ...@@ -565,10 +579,17 @@ void intel_gvt_init_engine_mmio_context(struct intel_gvt *gvt)
{ {
struct engine_mmio *mmio; struct engine_mmio *mmio;
if (INTEL_GEN(gvt->dev_priv) >= 9) if (INTEL_GEN(gvt->dev_priv) >= 9) {
gvt->engine_mmio_list.mmio = gen9_engine_mmio_list; gvt->engine_mmio_list.mmio = gen9_engine_mmio_list;
else gvt->engine_mmio_list.tlb_mmio_offset_list = gen8_tlb_mmio_offset_list;
gvt->engine_mmio_list.tlb_mmio_offset_list_cnt = ARRAY_SIZE(gen8_tlb_mmio_offset_list);
gvt->engine_mmio_list.mocs_mmio_offset_list = gen9_mocs_mmio_offset_list;
gvt->engine_mmio_list.mocs_mmio_offset_list_cnt = ARRAY_SIZE(gen9_mocs_mmio_offset_list);
} else {
gvt->engine_mmio_list.mmio = gen8_engine_mmio_list; gvt->engine_mmio_list.mmio = gen8_engine_mmio_list;
gvt->engine_mmio_list.tlb_mmio_offset_list = gen8_tlb_mmio_offset_list;
gvt->engine_mmio_list.tlb_mmio_offset_list_cnt = ARRAY_SIZE(gen8_tlb_mmio_offset_list);
}
for (mmio = gvt->engine_mmio_list.mmio; for (mmio = gvt->engine_mmio_list.mmio;
i915_mmio_reg_valid(mmio->reg); mmio++) { i915_mmio_reg_valid(mmio->reg); mmio++) {
......
...@@ -420,9 +420,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt, ...@@ -420,9 +420,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
if (ret) if (ret)
goto out_clean_submission; goto out_clean_submission;
ret = intel_gvt_debugfs_add_vgpu(vgpu); intel_gvt_debugfs_add_vgpu(vgpu);
if (ret)
goto out_clean_sched_policy;
ret = intel_gvt_hypervisor_set_opregion(vgpu); ret = intel_gvt_hypervisor_set_opregion(vgpu);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment