Skip to content

Commit 0790e63

Browse files
committed
Merge tag 'drm-intel-fixes-2020-08-20' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes
drm/i915 fixes for v5.9-rc2: - GVT fixes - Fix device parameter usage for selftest mock i915 device - Fix LPSP capability debugfs NULL dereference - Fix buddy register pagemask table - Fix intel_atomic_check() non-negative return value - Fix selftests passing a random 0 into ilog2() - Fix TGL power well enable/disable ordering - Switch to PMU module refcounting Signed-off-by: Dave Airlie <[email protected]> From: Jani Nikula <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents ba9086a + 4a4064a commit 0790e63

File tree

11 files changed

+75
-27
lines changed

11 files changed

+75
-27
lines changed

drivers/gpu/drm/i915/display/intel_display.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14930,7 +14930,7 @@ static int intel_atomic_check(struct drm_device *dev,
1493014930
if (any_ms && !check_digital_port_conflicts(state)) {
1493114931
drm_dbg_kms(&dev_priv->drm,
1493214932
"rejecting conflicting digital port configuration\n");
14933-
ret = EINVAL;
14933+
ret = -EINVAL;
1493414934
goto fail;
1493514935
}
1493614936

drivers/gpu/drm/i915/display/intel_display_debugfs.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,9 +2044,12 @@ DEFINE_SHOW_ATTRIBUTE(i915_hdcp_sink_capability);
20442044
static int i915_lpsp_capability_show(struct seq_file *m, void *data)
20452045
{
20462046
struct drm_connector *connector = m->private;
2047-
struct intel_encoder *encoder =
2048-
intel_attached_encoder(to_intel_connector(connector));
20492047
struct drm_i915_private *i915 = to_i915(connector->dev);
2048+
struct intel_encoder *encoder;
2049+
2050+
encoder = intel_attached_encoder(to_intel_connector(connector));
2051+
if (!encoder)
2052+
return -ENODEV;
20502053

20512054
if (connector->status != connector_status_connected)
20522055
return -ENODEV;

drivers/gpu/drm/i915/display/intel_display_power.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,6 +4146,12 @@ static const struct i915_power_well_desc tgl_power_wells[] = {
41464146
.hsw.idx = TGL_PW_CTL_IDX_DDI_TC6,
41474147
},
41484148
},
4149+
{
4150+
.name = "TC cold off",
4151+
.domains = TGL_TC_COLD_OFF_POWER_DOMAINS,
4152+
.ops = &tgl_tc_cold_off_ops,
4153+
.id = DISP_PW_ID_NONE,
4154+
},
41494155
{
41504156
.name = "AUX A",
41514157
.domains = TGL_AUX_A_IO_POWER_DOMAINS,
@@ -4332,12 +4338,6 @@ static const struct i915_power_well_desc tgl_power_wells[] = {
43324338
.hsw.irq_pipe_mask = BIT(PIPE_D),
43334339
},
43344340
},
4335-
{
4336-
.name = "TC cold off",
4337-
.domains = TGL_TC_COLD_OFF_POWER_DOMAINS,
4338-
.ops = &tgl_tc_cold_off_ops,
4339-
.id = DISP_PW_ID_NONE,
4340-
},
43414341
};
43424342

43434343
static const struct i915_power_well_desc rkl_power_wells[] = {
@@ -5240,10 +5240,10 @@ struct buddy_page_mask {
52405240
};
52415241

52425242
static const struct buddy_page_mask tgl_buddy_page_masks[] = {
5243-
{ .num_channels = 1, .type = INTEL_DRAM_LPDDR4, .page_mask = 0xE },
52445243
{ .num_channels = 1, .type = INTEL_DRAM_DDR4, .page_mask = 0xF },
52455244
{ .num_channels = 2, .type = INTEL_DRAM_LPDDR4, .page_mask = 0x1C },
52465245
{ .num_channels = 2, .type = INTEL_DRAM_DDR4, .page_mask = 0x1F },
5246+
{ .num_channels = 4, .type = INTEL_DRAM_LPDDR4, .page_mask = 0x38 },
52475247
{}
52485248
};
52495249

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static void vgpu_pci_cfg_mem_write(struct intel_vgpu *vgpu, unsigned int off,
7070
{
7171
u8 *cfg_base = vgpu_cfg_space(vgpu);
7272
u8 mask, new, old;
73+
pci_power_t pwr;
7374
int i = 0;
7475

7576
for (; i < bytes && (off + i < sizeof(pci_cfg_space_rw_bmp)); i++) {
@@ -91,6 +92,15 @@ static void vgpu_pci_cfg_mem_write(struct intel_vgpu *vgpu, unsigned int off,
9192
/* For other configuration space directly copy as it is. */
9293
if (i < bytes)
9394
memcpy(cfg_base + off + i, src + i, bytes - i);
95+
96+
if (off == vgpu->cfg_space.pmcsr_off && vgpu->cfg_space.pmcsr_off) {
97+
pwr = (pci_power_t __force)(*(u16*)(&vgpu_cfg_space(vgpu)[off])
98+
& PCI_PM_CTRL_STATE_MASK);
99+
if (pwr == PCI_D3hot)
100+
vgpu->d3_entered = true;
101+
gvt_dbg_core("vgpu-%d power status changed to %d\n",
102+
vgpu->id, pwr);
103+
}
94104
}
95105

96106
/**
@@ -366,6 +376,7 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
366376
struct intel_gvt *gvt = vgpu->gvt;
367377
const struct intel_gvt_device_info *info = &gvt->device_info;
368378
u16 *gmch_ctl;
379+
u8 next;
369380

370381
memcpy(vgpu_cfg_space(vgpu), gvt->firmware.cfg_space,
371382
info->cfg_space_size);
@@ -401,6 +412,19 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
401412
pci_resource_len(gvt->gt->i915->drm.pdev, 2);
402413

403414
memset(vgpu_cfg_space(vgpu) + PCI_ROM_ADDRESS, 0, 4);
415+
416+
/* PM Support */
417+
vgpu->cfg_space.pmcsr_off = 0;
418+
if (vgpu_cfg_space(vgpu)[PCI_STATUS] & PCI_STATUS_CAP_LIST) {
419+
next = vgpu_cfg_space(vgpu)[PCI_CAPABILITY_LIST];
420+
do {
421+
if (vgpu_cfg_space(vgpu)[next + PCI_CAP_LIST_ID] == PCI_CAP_ID_PM) {
422+
vgpu->cfg_space.pmcsr_off = next + PCI_PM_CTRL;
423+
break;
424+
}
425+
next = vgpu_cfg_space(vgpu)[next + PCI_CAP_LIST_NEXT];
426+
} while (next);
427+
}
404428
}
405429

406430
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2501,7 +2501,7 @@ int intel_vgpu_init_gtt(struct intel_vgpu *vgpu)
25012501
return create_scratch_page_tree(vgpu);
25022502
}
25032503

2504-
static void intel_vgpu_destroy_all_ppgtt_mm(struct intel_vgpu *vgpu)
2504+
void intel_vgpu_destroy_all_ppgtt_mm(struct intel_vgpu *vgpu)
25052505
{
25062506
struct list_head *pos, *n;
25072507
struct intel_vgpu_mm *mm;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,6 @@ int intel_vgpu_emulate_ggtt_mmio_read(struct intel_vgpu *vgpu,
279279
int intel_vgpu_emulate_ggtt_mmio_write(struct intel_vgpu *vgpu,
280280
unsigned int off, void *p_data, unsigned int bytes);
281281

282+
void intel_vgpu_destroy_all_ppgtt_mm(struct intel_vgpu *vgpu);
283+
282284
#endif /* _GVT_GTT_H_ */

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct intel_vgpu_pci_bar {
106106
struct intel_vgpu_cfg_space {
107107
unsigned char virtual_cfg_space[PCI_CFG_SPACE_EXP_SIZE];
108108
struct intel_vgpu_pci_bar bar[INTEL_GVT_MAX_BAR_NUM];
109+
u32 pmcsr_off;
109110
};
110111

111112
#define vgpu_cfg_space(vgpu) ((vgpu)->cfg_space.virtual_cfg_space)
@@ -198,6 +199,8 @@ struct intel_vgpu {
198199
struct intel_vgpu_submission submission;
199200
struct radix_tree_root page_track_tree;
200201
u32 hws_pga[I915_NUM_ENGINES];
202+
/* Set on PCI_D3, reset on DMLR, not reflecting the actual PM state */
203+
bool d3_entered;
201204

202205
struct dentry *debugfs;
203206

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ void intel_gvt_release_vgpu(struct intel_vgpu *vgpu)
257257
intel_gvt_deactivate_vgpu(vgpu);
258258

259259
mutex_lock(&vgpu->vgpu_lock);
260+
vgpu->d3_entered = false;
260261
intel_vgpu_clean_workloads(vgpu, ALL_ENGINES);
261262
intel_vgpu_dmabuf_cleanup(vgpu);
262263
mutex_unlock(&vgpu->vgpu_lock);
@@ -393,6 +394,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
393394
INIT_RADIX_TREE(&vgpu->page_track_tree, GFP_KERNEL);
394395
idr_init(&vgpu->object_idr);
395396
intel_vgpu_init_cfg_space(vgpu, param->primary);
397+
vgpu->d3_entered = false;
396398

397399
ret = intel_vgpu_init_mmio(vgpu);
398400
if (ret)
@@ -557,10 +559,15 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
557559
/* full GPU reset or device model level reset */
558560
if (engine_mask == ALL_ENGINES || dmlr) {
559561
intel_vgpu_select_submission_ops(vgpu, ALL_ENGINES, 0);
560-
intel_vgpu_invalidate_ppgtt(vgpu);
562+
if (engine_mask == ALL_ENGINES)
563+
intel_vgpu_invalidate_ppgtt(vgpu);
561564
/*fence will not be reset during virtual reset */
562565
if (dmlr) {
563-
intel_vgpu_reset_gtt(vgpu);
566+
if(!vgpu->d3_entered) {
567+
intel_vgpu_invalidate_ppgtt(vgpu);
568+
intel_vgpu_destroy_all_ppgtt_mm(vgpu);
569+
}
570+
intel_vgpu_reset_ggtt(vgpu, true);
564571
intel_vgpu_reset_resource(vgpu);
565572
}
566573

@@ -572,7 +579,14 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
572579
intel_vgpu_reset_cfg_space(vgpu);
573580
/* only reset the failsafe mode when dmlr reset */
574581
vgpu->failsafe = false;
575-
vgpu->pv_notified = false;
582+
/*
583+
* PCI_D0 is set before dmlr, so reset d3_entered here
584+
* after done using.
585+
*/
586+
if(vgpu->d3_entered)
587+
vgpu->d3_entered = false;
588+
else
589+
vgpu->pv_notified = false;
576590
}
577591
}
578592

drivers/gpu/drm/i915/i915_pmu.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,6 @@ static void i915_pmu_event_destroy(struct perf_event *event)
445445
container_of(event->pmu, typeof(*i915), pmu.base);
446446

447447
drm_WARN_ON(&i915->drm, event->parent);
448-
449-
module_put(THIS_MODULE);
450448
}
451449

452450
static int
@@ -538,10 +536,8 @@ static int i915_pmu_event_init(struct perf_event *event)
538536
if (ret)
539537
return ret;
540538

541-
if (!event->parent) {
542-
__module_get(THIS_MODULE);
539+
if (!event->parent)
543540
event->destroy = i915_pmu_event_destroy;
544-
}
545541

546542
return 0;
547543
}
@@ -1130,6 +1126,7 @@ void i915_pmu_register(struct drm_i915_private *i915)
11301126
if (!pmu->base.attr_groups)
11311127
goto err_attr;
11321128

1129+
pmu->base.module = THIS_MODULE;
11331130
pmu->base.task_ctx_nr = perf_invalid_context;
11341131
pmu->base.event_init = i915_pmu_event_init;
11351132
pmu->base.add = i915_pmu_event_add;

drivers/gpu/drm/i915/selftests/i915_buddy.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include "../i915_selftest.h"
99
#include "i915_random.h"
1010

11-
#define SZ_8G (1ULL << 33)
12-
1311
static void __igt_dump_block(struct i915_buddy_mm *mm,
1412
struct i915_buddy_block *block,
1513
bool buddy)
@@ -281,18 +279,22 @@ static int igt_check_mm(struct i915_buddy_mm *mm)
281279
static void igt_mm_config(u64 *size, u64 *chunk_size)
282280
{
283281
I915_RND_STATE(prng);
284-
u64 s, ms;
282+
u32 s, ms;
285283

286284
/* Nothing fancy, just try to get an interesting bit pattern */
287285

288286
prandom_seed_state(&prng, i915_selftest.random_seed);
289287

290-
s = i915_prandom_u64_state(&prng) & (SZ_8G - 1);
291-
ms = BIT_ULL(12 + (prandom_u32_state(&prng) % ilog2(s >> 12)));
292-
s = max(s & -ms, ms);
288+
/* Let size be a random number of pages up to 8 GB (2M pages) */
289+
s = 1 + i915_prandom_u32_max_state((BIT(33 - 12)) - 1, &prng);
290+
/* Let the chunk size be a random power of 2 less than size */
291+
ms = BIT(i915_prandom_u32_max_state(ilog2(s), &prng));
292+
/* Round size down to the chunk size */
293+
s &= -ms;
293294

294-
*chunk_size = ms;
295-
*size = s;
295+
/* Convert from pages to bytes */
296+
*chunk_size = (u64)ms << 12;
297+
*size = (u64)s << 12;
296298
}
297299

298300
static int igt_buddy_alloc_smoke(void *arg)

0 commit comments

Comments
 (0)