Skip to content

Commit 1ca20f3

Browse files
Hang Yuanzhenyw
authored andcommitted
drm/i915/gvt: add hotplug emulation
Add function to emulate hotplug interrupt for SKL/KBL platforms Signed-off-by: Hang Yuan <hang.yuan@linux.intel.com> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
1 parent 4922078 commit 1ca20f3

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,36 @@ void intel_gvt_emulate_vblank(struct intel_gvt *gvt)
445445
mutex_unlock(&gvt->lock);
446446
}
447447

448+
/**
449+
* intel_vgpu_emulate_hotplug - trigger hotplug event for vGPU
450+
* @vgpu: a vGPU
451+
* @conncted: link state
452+
*
453+
* This function is used to trigger hotplug interrupt for vGPU
454+
*
455+
*/
456+
void intel_vgpu_emulate_hotplug(struct intel_vgpu *vgpu, bool connected)
457+
{
458+
struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
459+
460+
/* TODO: add more platforms support */
461+
if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
462+
if (connected) {
463+
vgpu_vreg_t(vgpu, SFUSE_STRAP) |=
464+
SFUSE_STRAP_DDID_DETECTED;
465+
vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTD_HOTPLUG_CPT;
466+
} else {
467+
vgpu_vreg_t(vgpu, SFUSE_STRAP) &=
468+
~SFUSE_STRAP_DDID_DETECTED;
469+
vgpu_vreg_t(vgpu, SDEISR) &= ~SDE_PORTD_HOTPLUG_CPT;
470+
}
471+
vgpu_vreg_t(vgpu, SDEIIR) |= SDE_PORTD_HOTPLUG_CPT;
472+
vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
473+
PORTD_HOTPLUG_STATUS_MASK;
474+
intel_vgpu_trigger_virtual_event(vgpu, DP_D_HOTPLUG);
475+
}
476+
}
477+
448478
/**
449479
* intel_vgpu_clean_display - clean vGPU virtual display emulation
450480
* @vgpu: a vGPU

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ static const struct intel_gvt_ops intel_gvt_ops = {
185185
.vgpu_query_plane = intel_vgpu_query_plane,
186186
.vgpu_get_dmabuf = intel_vgpu_get_dmabuf,
187187
.write_protect_handler = intel_vgpu_page_track_handler,
188+
.emulate_hotplug = intel_vgpu_emulate_hotplug,
188189
};
189190

190191
static void init_device_info(struct intel_gvt *gvt)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ int intel_vgpu_emulate_cfg_read(struct intel_vgpu *vgpu, unsigned int offset,
536536
int intel_vgpu_emulate_cfg_write(struct intel_vgpu *vgpu, unsigned int offset,
537537
void *p_data, unsigned int bytes);
538538

539+
void intel_vgpu_emulate_hotplug(struct intel_vgpu *vgpu, bool connected);
540+
539541
static inline u64 intel_vgpu_get_bar_gpa(struct intel_vgpu *vgpu, int bar)
540542
{
541543
/* We are 64bit bar. */
@@ -577,6 +579,7 @@ struct intel_gvt_ops {
577579
int (*vgpu_get_dmabuf)(struct intel_vgpu *vgpu, unsigned int);
578580
int (*write_protect_handler)(struct intel_vgpu *, u64, void *,
579581
unsigned int);
582+
void (*emulate_hotplug)(struct intel_vgpu *vgpu, bool connected);
580583
};
581584

582585

0 commit comments

Comments
 (0)