From 8652a8aca614cc2576cf5d4c73d3b87e871ce004 Mon Sep 17 00:00:00 2001 From: Zhi Wang Date: Sun, 10 Sep 2017 22:01:10 +0800 Subject: [PATCH] drm/i915/gvt: Do not allocate initial ring scan buffer Git-commit: 8652a8aca614cc2576cf5d4c73d3b87e871ce004 Patch-mainline: v4.16-rc1 References: FATE#322643 bsc#1055900 Theoretically, the largest bulk of commands in the ring buffer of an engine might be the first submission, which usually contains a lot of commands to initialize the HW. After removing the initial allocation of the ring scan buffer and let krealloc() do everything we need, we still have a big chance to get the buffer of suitable size in the first submission. Tested on my SKL NUC. Signed-off-by: Zhi Wang Acked-by: Takashi Iwai --- drivers/gpu/drm/i915/gvt/execlist.c | 21 --------------------- drivers/gpu/drm/i915/gvt/gvt.h | 1 - 2 files changed, 22 deletions(-) --- a/drivers/gpu/drm/i915/gvt/execlist.c +++ b/drivers/gpu/drm/i915/gvt/execlist.c @@ -878,36 +878,15 @@ void intel_vgpu_clean_execlist(struct in } } -#define RESERVE_RING_BUFFER_SIZE ((1 * PAGE_SIZE)/8) int intel_vgpu_init_execlist(struct intel_vgpu *vgpu) { - struct intel_vgpu_submission *s = &vgpu->submission; enum intel_engine_id i; struct intel_engine_cs *engine; for_each_engine(engine, vgpu->gvt->dev_priv, i) init_vgpu_execlist(vgpu, i); - /* each ring has a shadow ring buffer until vgpu destroyed */ - for_each_engine(engine, vgpu->gvt->dev_priv, i) { - s->ring_scan_buffer[i] = - kmalloc(RESERVE_RING_BUFFER_SIZE, GFP_KERNEL); - if (!s->ring_scan_buffer[i]) { - gvt_vgpu_err("fail to alloc ring scan buffer\n"); - goto out; - } - s->ring_scan_buffer_size[i] = RESERVE_RING_BUFFER_SIZE; - } return 0; -out: - for_each_engine(engine, vgpu->gvt->dev_priv, i) { - if (s->ring_scan_buffer_size[i]) { - kfree(s->ring_scan_buffer[i]); - s->ring_scan_buffer[i] = NULL; - s->ring_scan_buffer_size[i] = 0; - } - } - return -ENOMEM; } void intel_vgpu_reset_execlist(struct intel_vgpu *vgpu, --- a/drivers/gpu/drm/i915/gvt/gvt.h +++ b/drivers/gpu/drm/i915/gvt/gvt.h @@ -150,7 +150,6 @@ struct intel_vgpu_submission { struct i915_gem_context *shadow_ctx; DECLARE_BITMAP(shadow_ctx_desc_updated, I915_NUM_ENGINES); DECLARE_BITMAP(tlb_handle_pending, I915_NUM_ENGINES); - /* 1/2K for each engine */ void *ring_scan_buffer[I915_NUM_ENGINES]; int ring_scan_buffer_size[I915_NUM_ENGINES]; };