aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJoonas Lahtinen <joonas.lahtinen@linux.intel.com>2018-04-04 06:46:39 -0400
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>2018-04-04 06:46:40 -0400
commitfbcc85974a49e9a6f3deb67fe3a0d4fb1af49983 (patch)
tree4bff4ab639aec8e3ee3f19f80b7457b3d3267f49 /drivers
parent694f54f680f7fd8e9561928fbfc537d9afbc3d79 (diff)
parent10996f802109c83421ca30556cfe36ffc3bebae3 (diff)
Merge tag 'gvt-fixes-2018-04-03' of https://github.com/intel/gvt-linux into drm-intel-next-fixes
gvt-fixes-2018-04-03 - fix unhandled vfio ioctl return value (Gerd) - no-op user interrupt for vGPU (Zhipeng) - fix ggtt dma unmap (Changbin) - fix warning in fb decoder (Xiong) - dmabuf drm_format_mod fix (Tina) - misc cleanup Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180403072835.kltk47gcwy7kuenv@zhen-hp.sh.intel.com
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/i915/gvt/cmd_parser.c1
-rw-r--r--drivers/gpu/drm/i915/gvt/display.c10
-rw-r--r--drivers/gpu/drm/i915/gvt/dmabuf.c1
-rw-r--r--drivers/gpu/drm/i915/gvt/fb_decoder.c27
-rw-r--r--drivers/gpu/drm/i915/gvt/gtt.c52
-rw-r--r--drivers/gpu/drm/i915/gvt/gtt.h2
-rw-r--r--drivers/gpu/drm/i915/gvt/handlers.c1
-rw-r--r--drivers/gpu/drm/i915/gvt/kvmgt.c2
8 files changed, 69 insertions, 27 deletions
diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
index db6b94dda5df..d85939bd7b47 100644
--- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
+++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
@@ -1080,6 +1080,7 @@ static int cmd_handler_mi_user_interrupt(struct parser_exec_state *s)
1080{ 1080{
1081 set_bit(cmd_interrupt_events[s->ring_id].mi_user_interrupt, 1081 set_bit(cmd_interrupt_events[s->ring_id].mi_user_interrupt,
1082 s->workload->pending_events); 1082 s->workload->pending_events);
1083 patch_value(s, cmd_ptr(s, 0), MI_NOOP);
1083 return 0; 1084 return 0;
1084} 1085}
1085 1086
diff --git a/drivers/gpu/drm/i915/gvt/display.c b/drivers/gpu/drm/i915/gvt/display.c
index dd96ffc878ac..6d8180e8d1e2 100644
--- a/drivers/gpu/drm/i915/gvt/display.c
+++ b/drivers/gpu/drm/i915/gvt/display.c
@@ -169,6 +169,8 @@ static u8 dpcd_fix_data[DPCD_HEADER_SIZE] = {
169static void emulate_monitor_status_change(struct intel_vgpu *vgpu) 169static void emulate_monitor_status_change(struct intel_vgpu *vgpu)
170{ 170{
171 struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; 171 struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
172 int pipe;
173
172 vgpu_vreg_t(vgpu, SDEISR) &= ~(SDE_PORTB_HOTPLUG_CPT | 174 vgpu_vreg_t(vgpu, SDEISR) &= ~(SDE_PORTB_HOTPLUG_CPT |
173 SDE_PORTC_HOTPLUG_CPT | 175 SDE_PORTC_HOTPLUG_CPT |
174 SDE_PORTD_HOTPLUG_CPT); 176 SDE_PORTD_HOTPLUG_CPT);
@@ -267,6 +269,14 @@ static void emulate_monitor_status_change(struct intel_vgpu *vgpu)
267 if (IS_BROADWELL(dev_priv)) 269 if (IS_BROADWELL(dev_priv))
268 vgpu_vreg_t(vgpu, PCH_ADPA) &= ~ADPA_CRT_HOTPLUG_MONITOR_MASK; 270 vgpu_vreg_t(vgpu, PCH_ADPA) &= ~ADPA_CRT_HOTPLUG_MONITOR_MASK;
269 271
272 /* Disable Primary/Sprite/Cursor plane */
273 for_each_pipe(dev_priv, pipe) {
274 vgpu_vreg_t(vgpu, DSPCNTR(pipe)) &= ~DISPLAY_PLANE_ENABLE;
275 vgpu_vreg_t(vgpu, SPRCTL(pipe)) &= ~SPRITE_ENABLE;
276 vgpu_vreg_t(vgpu, CURCNTR(pipe)) &= ~CURSOR_MODE;
277 vgpu_vreg_t(vgpu, CURCNTR(pipe)) |= CURSOR_MODE_DISABLE;
278 }
279
270 vgpu_vreg_t(vgpu, PIPECONF(PIPE_A)) |= PIPECONF_ENABLE; 280 vgpu_vreg_t(vgpu, PIPECONF(PIPE_A)) |= PIPECONF_ENABLE;
271} 281}
272 282
diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c
index b555eb26f9ce..6f4f8e941fc2 100644
--- a/drivers/gpu/drm/i915/gvt/dmabuf.c
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
@@ -323,6 +323,7 @@ static void update_fb_info(struct vfio_device_gfx_plane_info *gvt_dmabuf,
323 struct intel_vgpu_fb_info *fb_info) 323 struct intel_vgpu_fb_info *fb_info)
324{ 324{
325 gvt_dmabuf->drm_format = fb_info->drm_format; 325 gvt_dmabuf->drm_format = fb_info->drm_format;
326 gvt_dmabuf->drm_format_mod = fb_info->drm_format_mod;
326 gvt_dmabuf->width = fb_info->width; 327 gvt_dmabuf->width = fb_info->width;
327 gvt_dmabuf->height = fb_info->height; 328 gvt_dmabuf->height = fb_info->height;
328 gvt_dmabuf->stride = fb_info->stride; 329 gvt_dmabuf->stride = fb_info->stride;
diff --git a/drivers/gpu/drm/i915/gvt/fb_decoder.c b/drivers/gpu/drm/i915/gvt/fb_decoder.c
index 6b50fe78dc1b..1c120683e958 100644
--- a/drivers/gpu/drm/i915/gvt/fb_decoder.c
+++ b/drivers/gpu/drm/i915/gvt/fb_decoder.c
@@ -245,16 +245,13 @@ int intel_vgpu_decode_primary_plane(struct intel_vgpu *vgpu,
245 plane->hw_format = fmt; 245 plane->hw_format = fmt;
246 246
247 plane->base = vgpu_vreg_t(vgpu, DSPSURF(pipe)) & I915_GTT_PAGE_MASK; 247 plane->base = vgpu_vreg_t(vgpu, DSPSURF(pipe)) & I915_GTT_PAGE_MASK;
248 if (!intel_gvt_ggtt_validate_range(vgpu, plane->base, 0)) { 248 if (!intel_gvt_ggtt_validate_range(vgpu, plane->base, 0))
249 gvt_vgpu_err("invalid gma address: %lx\n",
250 (unsigned long)plane->base);
251 return -EINVAL; 249 return -EINVAL;
252 }
253 250
254 plane->base_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm, plane->base); 251 plane->base_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm, plane->base);
255 if (plane->base_gpa == INTEL_GVT_INVALID_ADDR) { 252 if (plane->base_gpa == INTEL_GVT_INVALID_ADDR) {
256 gvt_vgpu_err("invalid gma address: %lx\n", 253 gvt_vgpu_err("Translate primary plane gma 0x%x to gpa fail\n",
257 (unsigned long)plane->base); 254 plane->base);
258 return -EINVAL; 255 return -EINVAL;
259 } 256 }
260 257
@@ -371,16 +368,13 @@ int intel_vgpu_decode_cursor_plane(struct intel_vgpu *vgpu,
371 alpha_plane, alpha_force); 368 alpha_plane, alpha_force);
372 369
373 plane->base = vgpu_vreg_t(vgpu, CURBASE(pipe)) & I915_GTT_PAGE_MASK; 370 plane->base = vgpu_vreg_t(vgpu, CURBASE(pipe)) & I915_GTT_PAGE_MASK;
374 if (!intel_gvt_ggtt_validate_range(vgpu, plane->base, 0)) { 371 if (!intel_gvt_ggtt_validate_range(vgpu, plane->base, 0))
375 gvt_vgpu_err("invalid gma address: %lx\n",
376 (unsigned long)plane->base);
377 return -EINVAL; 372 return -EINVAL;
378 }
379 373
380 plane->base_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm, plane->base); 374 plane->base_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm, plane->base);
381 if (plane->base_gpa == INTEL_GVT_INVALID_ADDR) { 375 if (plane->base_gpa == INTEL_GVT_INVALID_ADDR) {
382 gvt_vgpu_err("invalid gma address: %lx\n", 376 gvt_vgpu_err("Translate cursor plane gma 0x%x to gpa fail\n",
383 (unsigned long)plane->base); 377 plane->base);
384 return -EINVAL; 378 return -EINVAL;
385 } 379 }
386 380
@@ -476,16 +470,13 @@ int intel_vgpu_decode_sprite_plane(struct intel_vgpu *vgpu,
476 plane->drm_format = drm_format; 470 plane->drm_format = drm_format;
477 471
478 plane->base = vgpu_vreg_t(vgpu, SPRSURF(pipe)) & I915_GTT_PAGE_MASK; 472 plane->base = vgpu_vreg_t(vgpu, SPRSURF(pipe)) & I915_GTT_PAGE_MASK;
479 if (!intel_gvt_ggtt_validate_range(vgpu, plane->base, 0)) { 473 if (!intel_gvt_ggtt_validate_range(vgpu, plane->base, 0))
480 gvt_vgpu_err("invalid gma address: %lx\n",
481 (unsigned long)plane->base);
482 return -EINVAL; 474 return -EINVAL;
483 }
484 475
485 plane->base_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm, plane->base); 476 plane->base_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm, plane->base);
486 if (plane->base_gpa == INTEL_GVT_INVALID_ADDR) { 477 if (plane->base_gpa == INTEL_GVT_INVALID_ADDR) {
487 gvt_vgpu_err("invalid gma address: %lx\n", 478 gvt_vgpu_err("Translate sprite plane gma 0x%x to gpa fail\n",
488 (unsigned long)plane->base); 479 plane->base);
489 return -EINVAL; 480 return -EINVAL;
490 } 481 }
491 482
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
index d29281231507..78e55aafc8bc 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -530,6 +530,16 @@ static void ggtt_set_guest_entry(struct intel_vgpu_mm *mm,
530 false, 0, mm->vgpu); 530 false, 0, mm->vgpu);
531} 531}
532 532
533static void ggtt_get_host_entry(struct intel_vgpu_mm *mm,
534 struct intel_gvt_gtt_entry *entry, unsigned long index)
535{
536 struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;
537
538 GEM_BUG_ON(mm->type != INTEL_GVT_MM_GGTT);
539
540 pte_ops->get_entry(NULL, entry, index, false, 0, mm->vgpu);
541}
542
533static void ggtt_set_host_entry(struct intel_vgpu_mm *mm, 543static void ggtt_set_host_entry(struct intel_vgpu_mm *mm,
534 struct intel_gvt_gtt_entry *entry, unsigned long index) 544 struct intel_gvt_gtt_entry *entry, unsigned long index)
535{ 545{
@@ -1818,6 +1828,18 @@ int intel_vgpu_emulate_ggtt_mmio_read(struct intel_vgpu *vgpu, unsigned int off,
1818 return ret; 1828 return ret;
1819} 1829}
1820 1830
1831static void ggtt_invalidate_pte(struct intel_vgpu *vgpu,
1832 struct intel_gvt_gtt_entry *entry)
1833{
1834 struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops;
1835 unsigned long pfn;
1836
1837 pfn = pte_ops->get_pfn(entry);
1838 if (pfn != vgpu->gvt->gtt.scratch_mfn)
1839 intel_gvt_hypervisor_dma_unmap_guest_page(vgpu,
1840 pfn << PAGE_SHIFT);
1841}
1842
1821static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off, 1843static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
1822 void *p_data, unsigned int bytes) 1844 void *p_data, unsigned int bytes)
1823{ 1845{
@@ -1844,10 +1866,10 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
1844 1866
1845 memcpy((void *)&e.val64 + (off & (info->gtt_entry_size - 1)), p_data, 1867 memcpy((void *)&e.val64 + (off & (info->gtt_entry_size - 1)), p_data,
1846 bytes); 1868 bytes);
1847 m = e;
1848 1869
1849 if (ops->test_present(&e)) { 1870 if (ops->test_present(&e)) {
1850 gfn = ops->get_pfn(&e); 1871 gfn = ops->get_pfn(&e);
1872 m = e;
1851 1873
1852 /* one PTE update may be issued in multiple writes and the 1874 /* one PTE update may be issued in multiple writes and the
1853 * first write may not construct a valid gfn 1875 * first write may not construct a valid gfn
@@ -1868,8 +1890,12 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
1868 ops->set_pfn(&m, gvt->gtt.scratch_mfn); 1890 ops->set_pfn(&m, gvt->gtt.scratch_mfn);
1869 } else 1891 } else
1870 ops->set_pfn(&m, dma_addr >> PAGE_SHIFT); 1892 ops->set_pfn(&m, dma_addr >> PAGE_SHIFT);
1871 } else 1893 } else {
1894 ggtt_get_host_entry(ggtt_mm, &m, g_gtt_index);
1895 ggtt_invalidate_pte(vgpu, &m);
1872 ops->set_pfn(&m, gvt->gtt.scratch_mfn); 1896 ops->set_pfn(&m, gvt->gtt.scratch_mfn);
1897 ops->clear_present(&m);
1898 }
1873 1899
1874out: 1900out:
1875 ggtt_set_host_entry(ggtt_mm, &m, g_gtt_index); 1901 ggtt_set_host_entry(ggtt_mm, &m, g_gtt_index);
@@ -2030,7 +2056,7 @@ int intel_vgpu_init_gtt(struct intel_vgpu *vgpu)
2030 return PTR_ERR(gtt->ggtt_mm); 2056 return PTR_ERR(gtt->ggtt_mm);
2031 } 2057 }
2032 2058
2033 intel_vgpu_reset_ggtt(vgpu); 2059 intel_vgpu_reset_ggtt(vgpu, false);
2034 2060
2035 return create_scratch_page_tree(vgpu); 2061 return create_scratch_page_tree(vgpu);
2036} 2062}
@@ -2315,17 +2341,19 @@ void intel_vgpu_invalidate_ppgtt(struct intel_vgpu *vgpu)
2315/** 2341/**
2316 * intel_vgpu_reset_ggtt - reset the GGTT entry 2342 * intel_vgpu_reset_ggtt - reset the GGTT entry
2317 * @vgpu: a vGPU 2343 * @vgpu: a vGPU
2344 * @invalidate_old: invalidate old entries
2318 * 2345 *
2319 * This function is called at the vGPU create stage 2346 * This function is called at the vGPU create stage
2320 * to reset all the GGTT entries. 2347 * to reset all the GGTT entries.
2321 * 2348 *
2322 */ 2349 */
2323void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu) 2350void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu, bool invalidate_old)
2324{ 2351{
2325 struct intel_gvt *gvt = vgpu->gvt; 2352 struct intel_gvt *gvt = vgpu->gvt;
2326 struct drm_i915_private *dev_priv = gvt->dev_priv; 2353 struct drm_i915_private *dev_priv = gvt->dev_priv;
2327 struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops; 2354 struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops;
2328 struct intel_gvt_gtt_entry entry = {.type = GTT_TYPE_GGTT_PTE}; 2355 struct intel_gvt_gtt_entry entry = {.type = GTT_TYPE_GGTT_PTE};
2356 struct intel_gvt_gtt_entry old_entry;
2329 u32 index; 2357 u32 index;
2330 u32 num_entries; 2358 u32 num_entries;
2331 2359
@@ -2334,13 +2362,23 @@ void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu)
2334 2362
2335 index = vgpu_aperture_gmadr_base(vgpu) >> PAGE_SHIFT; 2363 index = vgpu_aperture_gmadr_base(vgpu) >> PAGE_SHIFT;
2336 num_entries = vgpu_aperture_sz(vgpu) >> PAGE_SHIFT; 2364 num_entries = vgpu_aperture_sz(vgpu) >> PAGE_SHIFT;
2337 while (num_entries--) 2365 while (num_entries--) {
2366 if (invalidate_old) {
2367 ggtt_get_host_entry(vgpu->gtt.ggtt_mm, &old_entry, index);
2368 ggtt_invalidate_pte(vgpu, &old_entry);
2369 }
2338 ggtt_set_host_entry(vgpu->gtt.ggtt_mm, &entry, index++); 2370 ggtt_set_host_entry(vgpu->gtt.ggtt_mm, &entry, index++);
2371 }
2339 2372
2340 index = vgpu_hidden_gmadr_base(vgpu) >> PAGE_SHIFT; 2373 index = vgpu_hidden_gmadr_base(vgpu) >> PAGE_SHIFT;
2341 num_entries = vgpu_hidden_sz(vgpu) >> PAGE_SHIFT; 2374 num_entries = vgpu_hidden_sz(vgpu) >> PAGE_SHIFT;
2342 while (num_entries--) 2375 while (num_entries--) {
2376 if (invalidate_old) {
2377 ggtt_get_host_entry(vgpu->gtt.ggtt_mm, &old_entry, index);
2378 ggtt_invalidate_pte(vgpu, &old_entry);
2379 }
2343 ggtt_set_host_entry(vgpu->gtt.ggtt_mm, &entry, index++); 2380 ggtt_set_host_entry(vgpu->gtt.ggtt_mm, &entry, index++);
2381 }
2344 2382
2345 ggtt_invalidate(dev_priv); 2383 ggtt_invalidate(dev_priv);
2346} 2384}
@@ -2360,5 +2398,5 @@ void intel_vgpu_reset_gtt(struct intel_vgpu *vgpu)
2360 * removing the shadow pages. 2398 * removing the shadow pages.
2361 */ 2399 */
2362 intel_vgpu_destroy_all_ppgtt_mm(vgpu); 2400 intel_vgpu_destroy_all_ppgtt_mm(vgpu);
2363 intel_vgpu_reset_ggtt(vgpu); 2401 intel_vgpu_reset_ggtt(vgpu, true);
2364} 2402}
diff --git a/drivers/gpu/drm/i915/gvt/gtt.h b/drivers/gpu/drm/i915/gvt/gtt.h
index a8b369cd352b..3792f2b7f4ff 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.h
+++ b/drivers/gpu/drm/i915/gvt/gtt.h
@@ -193,7 +193,7 @@ struct intel_vgpu_gtt {
193 193
194extern int intel_vgpu_init_gtt(struct intel_vgpu *vgpu); 194extern int intel_vgpu_init_gtt(struct intel_vgpu *vgpu);
195extern void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu); 195extern void intel_vgpu_clean_gtt(struct intel_vgpu *vgpu);
196void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu); 196void intel_vgpu_reset_ggtt(struct intel_vgpu *vgpu, bool invalidate_old);
197void intel_vgpu_invalidate_ppgtt(struct intel_vgpu *vgpu); 197void intel_vgpu_invalidate_ppgtt(struct intel_vgpu *vgpu);
198 198
199extern int intel_gvt_init_gtt(struct intel_gvt *gvt); 199extern int intel_gvt_init_gtt(struct intel_gvt *gvt);
diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
index 8c5d5d005854..a33c1c3e4a21 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -1150,6 +1150,7 @@ static int handle_g2v_notification(struct intel_vgpu *vgpu, int notification)
1150 switch (notification) { 1150 switch (notification) {
1151 case VGT_G2V_PPGTT_L3_PAGE_TABLE_CREATE: 1151 case VGT_G2V_PPGTT_L3_PAGE_TABLE_CREATE:
1152 root_entry_type = GTT_TYPE_PPGTT_ROOT_L3_ENTRY; 1152 root_entry_type = GTT_TYPE_PPGTT_ROOT_L3_ENTRY;
1153 /* fall through */
1153 case VGT_G2V_PPGTT_L4_PAGE_TABLE_CREATE: 1154 case VGT_G2V_PPGTT_L4_PAGE_TABLE_CREATE:
1154 mm = intel_vgpu_get_ppgtt_mm(vgpu, root_entry_type, pdps); 1155 mm = intel_vgpu_get_ppgtt_mm(vgpu, root_entry_type, pdps);
1155 return PTR_ERR_OR_ZERO(mm); 1156 return PTR_ERR_OR_ZERO(mm);
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index c16a492449d7..1466d8769ec9 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1301,7 +1301,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
1301 1301
1302 } 1302 }
1303 1303
1304 return 0; 1304 return -ENOTTY;
1305} 1305}
1306 1306
1307static ssize_t 1307static ssize_t