Skip to content

Commit 214782d

Browse files
Merge tag 'gvt-fixes-2018-11-07' of https://github.com/intel/gvt-linux into drm-intel-fixes
gvt-fixes-2018-11-07 - Fix invalidate of old ggtt entry (Hang) - Fix partial ggtt entry update in any order (Hang) - Fix one mask setting for chicken reg (Xinyun) - Fix eDP warning in guest (Longhe) Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> From: Zhenyu Wang <zhenyuw@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20181107023137.GO25194@zhen-hp.sh.intel.com
2 parents df5e31c + 5e7154f commit 214782d

File tree

4 files changed

+70
-64
lines changed

4 files changed

+70
-64
lines changed

drivers/gpu/drm/i915/gvt/gtt.c

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,6 @@ static struct intel_vgpu_mm *intel_vgpu_create_ggtt_mm(struct intel_vgpu *vgpu)
19051905
vgpu_free_mm(mm);
19061906
return ERR_PTR(-ENOMEM);
19071907
}
1908-
mm->ggtt_mm.last_partial_off = -1UL;
19091908

19101909
return mm;
19111910
}
@@ -1930,7 +1929,6 @@ void _intel_vgpu_mm_release(struct kref *mm_ref)
19301929
invalidate_ppgtt_mm(mm);
19311930
} else {
19321931
vfree(mm->ggtt_mm.virtual_ggtt);
1933-
mm->ggtt_mm.last_partial_off = -1UL;
19341932
}
19351933

19361934
vgpu_free_mm(mm);
@@ -2168,6 +2166,8 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
21682166
struct intel_gvt_gtt_entry e, m;
21692167
dma_addr_t dma_addr;
21702168
int ret;
2169+
struct intel_gvt_partial_pte *partial_pte, *pos, *n;
2170+
bool partial_update = false;
21712171

21722172
if (bytes != 4 && bytes != 8)
21732173
return -EINVAL;
@@ -2178,68 +2178,57 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
21782178
if (!vgpu_gmadr_is_valid(vgpu, gma))
21792179
return 0;
21802180

2181-
ggtt_get_guest_entry(ggtt_mm, &e, g_gtt_index);
2182-
2181+
e.type = GTT_TYPE_GGTT_PTE;
21832182
memcpy((void *)&e.val64 + (off & (info->gtt_entry_size - 1)), p_data,
21842183
bytes);
21852184

21862185
/* If ggtt entry size is 8 bytes, and it's split into two 4 bytes
2187-
* write, we assume the two 4 bytes writes are consecutive.
2188-
* Otherwise, we abort and report error
2186+
* write, save the first 4 bytes in a list and update virtual
2187+
* PTE. Only update shadow PTE when the second 4 bytes comes.
21892188
*/
21902189
if (bytes < info->gtt_entry_size) {
2191-
if (ggtt_mm->ggtt_mm.last_partial_off == -1UL) {
2192-
/* the first partial part*/
2193-
ggtt_mm->ggtt_mm.last_partial_off = off;
2194-
ggtt_mm->ggtt_mm.last_partial_data = e.val64;
2195-
return 0;
2196-
} else if ((g_gtt_index ==
2197-
(ggtt_mm->ggtt_mm.last_partial_off >>
2198-
info->gtt_entry_size_shift)) &&
2199-
(off != ggtt_mm->ggtt_mm.last_partial_off)) {
2200-
/* the second partial part */
2201-
2202-
int last_off = ggtt_mm->ggtt_mm.last_partial_off &
2203-
(info->gtt_entry_size - 1);
2204-
2205-
memcpy((void *)&e.val64 + last_off,
2206-
(void *)&ggtt_mm->ggtt_mm.last_partial_data +
2207-
last_off, bytes);
2208-
2209-
ggtt_mm->ggtt_mm.last_partial_off = -1UL;
2210-
} else {
2211-
int last_offset;
2212-
2213-
gvt_vgpu_err("failed to populate guest ggtt entry: abnormal ggtt entry write sequence, last_partial_off=%lx, offset=%x, bytes=%d, ggtt entry size=%d\n",
2214-
ggtt_mm->ggtt_mm.last_partial_off, off,
2215-
bytes, info->gtt_entry_size);
2216-
2217-
/* set host ggtt entry to scratch page and clear
2218-
* virtual ggtt entry as not present for last
2219-
* partially write offset
2220-
*/
2221-
last_offset = ggtt_mm->ggtt_mm.last_partial_off &
2222-
(~(info->gtt_entry_size - 1));
2223-
2224-
ggtt_get_host_entry(ggtt_mm, &m, last_offset);
2225-
ggtt_invalidate_pte(vgpu, &m);
2226-
ops->set_pfn(&m, gvt->gtt.scratch_mfn);
2227-
ops->clear_present(&m);
2228-
ggtt_set_host_entry(ggtt_mm, &m, last_offset);
2229-
ggtt_invalidate(gvt->dev_priv);
2230-
2231-
ggtt_get_guest_entry(ggtt_mm, &e, last_offset);
2232-
ops->clear_present(&e);
2233-
ggtt_set_guest_entry(ggtt_mm, &e, last_offset);
2234-
2235-
ggtt_mm->ggtt_mm.last_partial_off = off;
2236-
ggtt_mm->ggtt_mm.last_partial_data = e.val64;
2190+
bool found = false;
2191+
2192+
list_for_each_entry_safe(pos, n,
2193+
&ggtt_mm->ggtt_mm.partial_pte_list, list) {
2194+
if (g_gtt_index == pos->offset >>
2195+
info->gtt_entry_size_shift) {
2196+
if (off != pos->offset) {
2197+
/* the second partial part*/
2198+
int last_off = pos->offset &
2199+
(info->gtt_entry_size - 1);
2200+
2201+
memcpy((void *)&e.val64 + last_off,
2202+
(void *)&pos->data + last_off,
2203+
bytes);
2204+
2205+
list_del(&pos->list);
2206+
kfree(pos);
2207+
found = true;
2208+
break;
2209+
}
2210+
2211+
/* update of the first partial part */
2212+
pos->data = e.val64;
2213+
ggtt_set_guest_entry(ggtt_mm, &e, g_gtt_index);
2214+
return 0;
2215+
}
2216+
}
22372217

2238-
return 0;
2218+
if (!found) {
2219+
/* the first partial part */
2220+
partial_pte = kzalloc(sizeof(*partial_pte), GFP_KERNEL);
2221+
if (!partial_pte)
2222+
return -ENOMEM;
2223+
partial_pte->offset = off;
2224+
partial_pte->data = e.val64;
2225+
list_add_tail(&partial_pte->list,
2226+
&ggtt_mm->ggtt_mm.partial_pte_list);
2227+
partial_update = true;
22392228
}
22402229
}
22412230

2242-
if (ops->test_present(&e)) {
2231+
if (!partial_update && (ops->test_present(&e))) {
22432232
gfn = ops->get_pfn(&e);
22442233
m = e;
22452234

@@ -2263,16 +2252,18 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
22632252
} else
22642253
ops->set_pfn(&m, dma_addr >> PAGE_SHIFT);
22652254
} else {
2266-
ggtt_get_host_entry(ggtt_mm, &m, g_gtt_index);
2267-
ggtt_invalidate_pte(vgpu, &m);
22682255
ops->set_pfn(&m, gvt->gtt.scratch_mfn);
22692256
ops->clear_present(&m);
22702257
}
22712258

22722259
out:
2260+
ggtt_set_guest_entry(ggtt_mm, &e, g_gtt_index);
2261+
2262+
ggtt_get_host_entry(ggtt_mm, &e, g_gtt_index);
2263+
ggtt_invalidate_pte(vgpu, &e);
2264+
22732265
ggtt_set_host_entry(ggtt_mm, &m, g_gtt_index);
22742266
ggtt_invalidate(gvt->dev_priv);
2275-
ggtt_set_guest_entry(ggtt_mm, &e, g_gtt_index);
22762267
return 0;
22772268
}
22782269

@@ -2430,6 +2421,8 @@ int intel_vgpu_init_gtt(struct intel_vgpu *vgpu)
24302421

24312422
intel_vgpu_reset_ggtt(vgpu, false);
24322423

2424+
INIT_LIST_HEAD(&gtt->ggtt_mm->ggtt_mm.partial_pte_list);
2425+
24332426
return create_scratch_page_tree(vgpu);
24342427
}
24352428

@@ -2454,6 +2447,14 @@ static void intel_vgpu_destroy_all_ppgtt_mm(struct intel_vgpu *vgpu)
24542447

24552448
static void intel_vgpu_destroy_ggtt_mm(struct intel_vgpu *vgpu)
24562449
{
2450+
struct intel_gvt_partial_pte *pos;
2451+
2452+
list_for_each_entry(pos,
2453+
&vgpu->gtt.ggtt_mm->ggtt_mm.partial_pte_list, list) {
2454+
gvt_dbg_mm("partial PTE update on hold 0x%lx : 0x%llx\n",
2455+
pos->offset, pos->data);
2456+
kfree(pos);
2457+
}
24572458
intel_vgpu_destroy_mm(vgpu->gtt.ggtt_mm);
24582459
vgpu->gtt.ggtt_mm = NULL;
24592460
}

drivers/gpu/drm/i915/gvt/gtt.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ enum intel_gvt_mm_type {
132132

133133
#define GVT_RING_CTX_NR_PDPS GEN8_3LVL_PDPES
134134

135+
struct intel_gvt_partial_pte {
136+
unsigned long offset;
137+
u64 data;
138+
struct list_head list;
139+
};
140+
135141
struct intel_vgpu_mm {
136142
enum intel_gvt_mm_type type;
137143
struct intel_vgpu *vgpu;
@@ -156,8 +162,7 @@ struct intel_vgpu_mm {
156162
} ppgtt_mm;
157163
struct {
158164
void *virtual_ggtt;
159-
unsigned long last_partial_off;
160-
u64 last_partial_data;
165+
struct list_head partial_pte_list;
161166
} ggtt_mm;
162167
};
163168
};

drivers/gpu/drm/i915/gvt/handlers.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,7 @@ static int bxt_gt_disp_pwron_write(struct intel_vgpu *vgpu,
16091609
return 0;
16101610
}
16111611

1612-
static int bxt_edp_psr_imr_iir_write(struct intel_vgpu *vgpu,
1612+
static int edp_psr_imr_iir_write(struct intel_vgpu *vgpu,
16131613
unsigned int offset, void *p_data, unsigned int bytes)
16141614
{
16151615
vgpu_vreg(vgpu, offset) = 0;
@@ -2607,6 +2607,9 @@ static int init_generic_mmio_info(struct intel_gvt *gvt)
26072607
MMIO_DFH(_MMIO(0x1a178), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
26082608
MMIO_DFH(_MMIO(0x1a17c), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
26092609
MMIO_DFH(_MMIO(0x2217c), D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
2610+
2611+
MMIO_DH(EDP_PSR_IMR, D_BDW_PLUS, NULL, edp_psr_imr_iir_write);
2612+
MMIO_DH(EDP_PSR_IIR, D_BDW_PLUS, NULL, edp_psr_imr_iir_write);
26102613
return 0;
26112614
}
26122615

@@ -3205,9 +3208,6 @@ static int init_bxt_mmio_info(struct intel_gvt *gvt)
32053208
MMIO_D(HSW_TVIDEO_DIP_GCP(TRANSCODER_B), D_BXT);
32063209
MMIO_D(HSW_TVIDEO_DIP_GCP(TRANSCODER_C), D_BXT);
32073210

3208-
MMIO_DH(EDP_PSR_IMR, D_BXT, NULL, bxt_edp_psr_imr_iir_write);
3209-
MMIO_DH(EDP_PSR_IIR, D_BXT, NULL, bxt_edp_psr_imr_iir_write);
3210-
32113211
MMIO_D(RC6_CTX_BASE, D_BXT);
32123212

32133213
MMIO_D(GEN8_PUSHBUS_CONTROL, D_BXT);

drivers/gpu/drm/i915/gvt/mmio_context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static struct engine_mmio gen9_engine_mmio_list[] __cacheline_aligned = {
131131
{RCS, GAMT_CHKN_BIT_REG, 0x0, false}, /* 0x4ab8 */
132132

133133
{RCS, GEN9_GAMT_ECO_REG_RW_IA, 0x0, false}, /* 0x4ab0 */
134-
{RCS, GEN9_CSFE_CHICKEN1_RCS, 0x0, false}, /* 0x20d4 */
134+
{RCS, GEN9_CSFE_CHICKEN1_RCS, 0xffff, false}, /* 0x20d4 */
135135

136136
{RCS, GEN8_GARBCNTL, 0x0, false}, /* 0xb004 */
137137
{RCS, GEN7_FF_THREAD_MODE, 0x0, false}, /* 0x20a0 */

0 commit comments

Comments
 (0)