drm/i915/gvt: Factor out intel_vgpu_{get, put}_ppgtt_mm interface
Factor out these two interfaces so we can kill some duplicated code in scheduler.c. v2: - rename to intel_vgpu_{get,put}_ppgtt_mm - refine handle_g2v_notification Signed-off-by: Changbin Du <changbin.du@intel.com> Reviewed-by: Zhi Wang <zhi.a.wang@intel.com> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
This commit is contained in:
parent
a143cef7db
commit
e6e9c46fd2
|
@ -2292,19 +2292,17 @@ struct intel_vgpu_mm *intel_vgpu_find_ppgtt_mm(struct intel_vgpu *vgpu,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* intel_vgpu_g2v_create_ppgtt_mm - create a PPGTT mm object from
|
* intel_vgpu_get_ppgtt_mm - get or create a PPGTT mm object.
|
||||||
* g2v notification
|
|
||||||
* @vgpu: a vGPU
|
* @vgpu: a vGPU
|
||||||
* @root_entry_type: ppgtt root entry type
|
* @root_entry_type: ppgtt root entry type
|
||||||
* @pdps: guest pdps
|
* @pdps: guest pdps
|
||||||
*
|
*
|
||||||
* This function is used to create a PPGTT mm object from a guest to GVT-g
|
* This function is used to find or create a PPGTT mm object from a guest.
|
||||||
* notification.
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* Zero on success, negative error code if failed.
|
* Zero on success, negative error code if failed.
|
||||||
*/
|
*/
|
||||||
int intel_vgpu_g2v_create_ppgtt_mm(struct intel_vgpu *vgpu,
|
struct intel_vgpu_mm *intel_vgpu_get_ppgtt_mm(struct intel_vgpu *vgpu,
|
||||||
intel_gvt_gtt_type_t root_entry_type, u64 pdps[])
|
intel_gvt_gtt_type_t root_entry_type, u64 pdps[])
|
||||||
{
|
{
|
||||||
struct intel_vgpu_mm *mm;
|
struct intel_vgpu_mm *mm;
|
||||||
|
@ -2314,28 +2312,23 @@ int intel_vgpu_g2v_create_ppgtt_mm(struct intel_vgpu *vgpu,
|
||||||
intel_vgpu_mm_get(mm);
|
intel_vgpu_mm_get(mm);
|
||||||
} else {
|
} else {
|
||||||
mm = intel_vgpu_create_ppgtt_mm(vgpu, root_entry_type, pdps);
|
mm = intel_vgpu_create_ppgtt_mm(vgpu, root_entry_type, pdps);
|
||||||
if (IS_ERR(mm)) {
|
if (IS_ERR(mm))
|
||||||
gvt_vgpu_err("fail to create mm\n");
|
gvt_vgpu_err("fail to create mm\n");
|
||||||
return PTR_ERR(mm);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* intel_vgpu_g2v_destroy_ppgtt_mm - destroy a PPGTT mm object from
|
* intel_vgpu_put_ppgtt_mm - find and put a PPGTT mm object.
|
||||||
* g2v notification
|
|
||||||
* @vgpu: a vGPU
|
* @vgpu: a vGPU
|
||||||
* @pdps: guest pdps
|
* @pdps: guest pdps
|
||||||
*
|
*
|
||||||
* This function is used to create a PPGTT mm object from a guest to GVT-g
|
* This function is used to find a PPGTT mm object from a guest and destroy it.
|
||||||
* notification.
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* Zero on success, negative error code if failed.
|
* Zero on success, negative error code if failed.
|
||||||
*/
|
*/
|
||||||
int intel_vgpu_g2v_destroy_ppgtt_mm(struct intel_vgpu *vgpu,
|
int intel_vgpu_put_ppgtt_mm(struct intel_vgpu *vgpu, u64 pdps[])
|
||||||
u64 pdps[])
|
|
||||||
{
|
{
|
||||||
struct intel_vgpu_mm *mm;
|
struct intel_vgpu_mm *mm;
|
||||||
|
|
||||||
|
|
|
@ -275,10 +275,10 @@ unsigned long intel_vgpu_gma_to_gpa(struct intel_vgpu_mm *mm,
|
||||||
struct intel_vgpu_mm *intel_vgpu_find_ppgtt_mm(struct intel_vgpu *vgpu,
|
struct intel_vgpu_mm *intel_vgpu_find_ppgtt_mm(struct intel_vgpu *vgpu,
|
||||||
u64 pdps[]);
|
u64 pdps[]);
|
||||||
|
|
||||||
int intel_vgpu_g2v_create_ppgtt_mm(struct intel_vgpu *vgpu,
|
struct intel_vgpu_mm *intel_vgpu_get_ppgtt_mm(struct intel_vgpu *vgpu,
|
||||||
intel_gvt_gtt_type_t root_entry_type, u64 pdps[]);
|
intel_gvt_gtt_type_t root_entry_type, u64 pdps[]);
|
||||||
|
|
||||||
int intel_vgpu_g2v_destroy_ppgtt_mm(struct intel_vgpu *vgpu, u64 pdps[]);
|
int intel_vgpu_put_ppgtt_mm(struct intel_vgpu *vgpu, u64 pdps[]);
|
||||||
|
|
||||||
int intel_vgpu_emulate_ggtt_mmio_read(struct intel_vgpu *vgpu,
|
int intel_vgpu_emulate_ggtt_mmio_read(struct intel_vgpu *vgpu,
|
||||||
unsigned int off, void *p_data, unsigned int bytes);
|
unsigned int off, void *p_data, unsigned int bytes);
|
||||||
|
|
|
@ -1139,28 +1139,21 @@ static int pvinfo_mmio_read(struct intel_vgpu *vgpu, unsigned int offset,
|
||||||
|
|
||||||
static int handle_g2v_notification(struct intel_vgpu *vgpu, int notification)
|
static int handle_g2v_notification(struct intel_vgpu *vgpu, int notification)
|
||||||
{
|
{
|
||||||
|
intel_gvt_gtt_type_t root_entry_type = GTT_TYPE_PPGTT_ROOT_L4_ENTRY;
|
||||||
|
struct intel_vgpu_mm *mm;
|
||||||
u64 *pdps;
|
u64 *pdps;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
pdps = (u64 *)&vgpu_vreg64_t(vgpu, vgtif_reg(pdp[0]));
|
pdps = (u64 *)&vgpu_vreg64_t(vgpu, vgtif_reg(pdp[0]));
|
||||||
|
|
||||||
switch (notification) {
|
switch (notification) {
|
||||||
case VGT_G2V_PPGTT_L3_PAGE_TABLE_CREATE:
|
case VGT_G2V_PPGTT_L3_PAGE_TABLE_CREATE:
|
||||||
ret = intel_vgpu_g2v_create_ppgtt_mm(vgpu,
|
root_entry_type = GTT_TYPE_PPGTT_ROOT_L3_ENTRY;
|
||||||
GTT_TYPE_PPGTT_ROOT_L3_ENTRY,
|
|
||||||
pdps);
|
|
||||||
break;
|
|
||||||
case VGT_G2V_PPGTT_L3_PAGE_TABLE_DESTROY:
|
|
||||||
ret = intel_vgpu_g2v_destroy_ppgtt_mm(vgpu, pdps);
|
|
||||||
break;
|
|
||||||
case VGT_G2V_PPGTT_L4_PAGE_TABLE_CREATE:
|
case VGT_G2V_PPGTT_L4_PAGE_TABLE_CREATE:
|
||||||
ret = intel_vgpu_g2v_create_ppgtt_mm(vgpu,
|
mm = intel_vgpu_get_ppgtt_mm(vgpu, root_entry_type, pdps);
|
||||||
GTT_TYPE_PPGTT_ROOT_L4_ENTRY,
|
return PTR_ERR_OR_ZERO(mm);
|
||||||
pdps);
|
case VGT_G2V_PPGTT_L3_PAGE_TABLE_DESTROY:
|
||||||
break;
|
|
||||||
case VGT_G2V_PPGTT_L4_PAGE_TABLE_DESTROY:
|
case VGT_G2V_PPGTT_L4_PAGE_TABLE_DESTROY:
|
||||||
ret = intel_vgpu_g2v_destroy_ppgtt_mm(vgpu, pdps);
|
return intel_vgpu_put_ppgtt_mm(vgpu, pdps);
|
||||||
break;
|
|
||||||
case VGT_G2V_EXECLIST_CONTEXT_CREATE:
|
case VGT_G2V_EXECLIST_CONTEXT_CREATE:
|
||||||
case VGT_G2V_EXECLIST_CONTEXT_DESTROY:
|
case VGT_G2V_EXECLIST_CONTEXT_DESTROY:
|
||||||
case 1: /* Remove this in guest driver. */
|
case 1: /* Remove this in guest driver. */
|
||||||
|
@ -1168,7 +1161,7 @@ static int handle_g2v_notification(struct intel_vgpu *vgpu, int notification)
|
||||||
default:
|
default:
|
||||||
gvt_vgpu_err("Invalid PV notification %d\n", notification);
|
gvt_vgpu_err("Invalid PV notification %d\n", notification);
|
||||||
}
|
}
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int send_display_ready_uevent(struct intel_vgpu *vgpu, int ready)
|
static int send_display_ready_uevent(struct intel_vgpu *vgpu, int ready)
|
||||||
|
|
|
@ -1198,18 +1198,10 @@ static int prepare_mm(struct intel_vgpu_workload *workload)
|
||||||
|
|
||||||
read_guest_pdps(workload->vgpu, workload->ring_context_gpa, (void *)pdps);
|
read_guest_pdps(workload->vgpu, workload->ring_context_gpa, (void *)pdps);
|
||||||
|
|
||||||
mm = intel_vgpu_find_ppgtt_mm(workload->vgpu, pdps);
|
mm = intel_vgpu_get_ppgtt_mm(workload->vgpu, root_entry_type, pdps);
|
||||||
if (mm) {
|
if (IS_ERR(mm))
|
||||||
intel_vgpu_mm_get(mm);
|
return PTR_ERR(mm);
|
||||||
} else {
|
|
||||||
|
|
||||||
mm = intel_vgpu_create_ppgtt_mm(workload->vgpu, root_entry_type,
|
|
||||||
pdps);
|
|
||||||
if (IS_ERR(mm)) {
|
|
||||||
gvt_vgpu_err("fail to create mm object.\n");
|
|
||||||
return PTR_ERR(mm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
workload->shadow_mm = mm;
|
workload->shadow_mm = mm;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue