drm/i915: Enable guest i915 48bit full ppgtt functionality
PATCH v7 1/2 drm/i915: Enable guest i915 48bit full ppgtt functionality
From: Tina Zhang <[email protected]>
Enable the guest i915 48bit full ppgtt functionality when host can provide the capability. vgt_caps is introduced to guest i915 driver to get the vgpu capabilities from the device model. VGT_CAPS_FULL_PPGTT_48BIT is one of the capabilities type which let guest i915 dirver know that the guest 48bit i915 full ppgtt is supported by device model.
Notice that the minor version of pvinfo isn't bumped because of this vgt_caps introduction, due to older guest would be broken by simply increasing the pvinfo version. Although the pvinfo minor version doesn't increase, the compatibility won't be blocked. The compatibility is ensured by checking the value of caps field in pvinfo. Zero means no full ppgtt support and BIT(2) means this feature is provided.
Changes since v1:
- Use u32 instead of uint32_t (Joonas)
- Move VGT_CAPS_FULL_PPGTT introduction to this patch and use #define instead of enum (Joonas)
- Rewrite the vgpu full ppgtt capability checking logic. (Joonas)
- Some coding style refine. (Joonas)
Changes since v2:
- Divide the whole patch set into two separate patch series, with one patch in i915 side to check guest i915 full ppgtt capability and enable it when this capability is supported by the device model, and the other one in gvt side which fixs the blocking issue and enables the device model to provide the capability to guest. And this patch focuses on guest i915 side. (Joonas)
- Change the title from "introduce vgt_caps to pvinfo" to "Enable guest i915 full ppgtt functionality". (Tina)
Change since v3:
- Add some comments about pvinfo caps and version. (Joonas)
Change since v4:
- Tested by Tina Zhang.
Change since v5:
- Add limitation about supporting 32bit full ppgtt.
Change since v6:
- Cleanup and fix previous 32bit ppgtt setting check and favor to enable 48bit ppgtt if host gvt-g provides support. (Zhenyu)
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_gtt.c | 13 +++++++++---- drivers/gpu/drm/i915/i915_pvinfo.h | 8 +++++++- drivers/gpu/drm/i915/i915_vgpu.c | 7 +++++++ drivers/gpu/drm/i915/i915_vgpu.h | 3 +++ 5 files changed, 27 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1878,6 +1878,7 @@ struct i915_workarounds {struct i915_virtual_gpu {bool active; +u32 caps; };/* used in computing the new watermarks state */
drivers/gpu/drm/i915/i915_gem_gtt.c +9 -4
@@ -141,14 +141,19 @@ int intel_sanitize_enable_ppgtt(struct drm_i915_private *dev_priv, has_aliasing_ppgtt = dev_priv->info.has_aliasing_ppgtt; has_full_ppgtt = dev_priv->info.has_full_ppgtt; - has_full_48bit_ppgtt = dev_priv->info.has_full_48bit_ppgtt;if (intel_vgpu_active (dev_priv)) { -/* emulation is too hard */ - has_full_ppgtt = false; - has_full_48bit_ppgtt = false; + has_full_ppgtt =intel_vgpu_has_full_ppgtt (dev_priv); +/* GVT-g has no support for 32bit ppgtt */ +if (enable_ppgtt ==2 && has_full_ppgtt) { +DRM_DEBUG_DRIVER ("Force 48bit ppgtt for vGPU\n" ); + enable_ppgtt =3 ; + } } + has_full_48bit_ppgtt = has_full_ppgtt && + dev_priv->info.has_full_48bit_ppgtt; +if (!has_aliasing_ppgtt)return 0 ;
drivers/gpu/drm/i915/i915_pvinfo.h +7 -1
@@ -49,12 +49,18 @@ enum vgt_g2v_type { VGT_G2V_MAX, }; +/* +* VGT capabilities type +*/ +#define VGT_CAPS_FULL_PPGTT_48BIT BIT(2) +struct vgt_if {u64 magic;/* VGT_MAGIC */ u16 version_major;u16 version_minor;u32 vgt_id;/* ID of vGT instance */ -u32 rsv1[12 ];/* pad to offset 0x40 */ +u32 vgt_caps;/* VGT capabilities */ +u32 rsv1[11 ];/* pad to offset 0x40 */ /* * Data structure to describe the balooning info of resources. * Each VM can only have one portion of continuous area for now.
drivers/gpu/drm/i915/i915_vgpu.c +7 -0
@@ -75,10 +75,17 @@ void i915_check_vgpu(struct drm_i915_private *dev_priv)return ; } + dev_priv->vgpu.caps =__raw_i915_read32 (dev_priv,vgtif_reg (vgt_caps)); + dev_priv->vgpu.active = true;DRM_INFO ("Virtual GPU for Intel GVT-g detected.\n" ); } +bool intel_vgpu_has_full_ppgtt (struct drm_i915_private *dev_priv) +{ +return dev_priv->vgpu.caps &VGT_CAPS_FULL_PPGTT_48BIT ; +} +struct _balloon_info_ {/* * There are up to 2 regions per mappable/unmappable graphic
drivers/gpu/drm/i915/i915_vgpu.h +3 -0
@@ -27,6 +27,9 @@#include "i915_pvinfo.h" void i915_check_vgpu (struct drm_i915_private *dev_priv); + +bool intel_vgpu_has_full_ppgtt (struct drm_i915_private *dev_priv); +int intel_vgt_balloon (struct drm_i915_private *dev_priv);void intel_vgt_deballoon (struct drm_i915_private *dev_priv);
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v7 2/2 drm/i915/gvt: Fix guest i915 48bit full ppgtt blocking issue
From: Tina Zhang <[email protected]>
Guest i915 48bit full ppgtt functionality was blocking by an issue, which would lead to gpu hardware hang. Guest i915 driver may update the ppgtt table just before this workload is going to be submitted to the hardware by device model. This case wasn't handled well by device model before, due to the small time window between removing old ppgtt entry and adding the new one. Errors occur when the workload is executed by hardware during that small time window. This patch is to remove this time window by adding the new ppgtt entry first and then remove the old one.
Changes in v2:
- Move VGT_CAPS_FULL_PPGTT introduction to patch 2/4. (Joonas)
Changes since v2:
- Divide the whole patch set into two separate patch series, with one patch in i915 side to check guest i915 full ppgtt capability and enable it when this capability is supported by the device model, and the other one in gvt side which fixs the blocking issue and enables the device model to provide the capability to guest. And this patch focuses on gvt side. (Joonas)
- Change the title from "reorder the shadow ppgtt update process by adding entry first" to "Fix guest i915 full ppgtt blocking issue". (Tina)
Changes since v3:
- Rebase to the latest branch.
Changes since v4:
- Tested by Tina Zhang.
Changes since v5:
- Rebase to the latest branch.
--- drivers/gpu/drm/i915/gvt/gtt.c | 45 +++++++++++++++++++++++++---------------- drivers/gpu/drm/i915/gvt/vgpu.c | 1 + 2 files changed, 29 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/gvt/gtt.c +28 -17
@@ -979,29 +979,26 @@ static int ppgtt_populate_shadow_page(struct intel_vgpu_ppgtt_spt *spt) }static int ppgtt_handle_guest_entry_removal (struct intel_vgpu_guest_page *gpt, -unsigned long index) +struct intel_gvt_gtt_entry *se,unsigned long index) {struct intel_vgpu_ppgtt_spt *spt =guest_page_to_ppgtt_spt (gpt);struct intel_vgpu_shadow_page *sp = &spt->shadow_page;struct intel_vgpu *vgpu = spt->vgpu;struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; -struct intel_gvt_gtt_entry e;int ret; -ppgtt_get_shadow_entry (spt, &e, index); - -trace_gpt_change (spt->vgpu->id,"remove" , spt, sp->type, e.val64, +trace_gpt_change (spt->vgpu->id,"remove" , spt, sp->type, se->val64, index); -if (!ops->test_present (&e)) +if (!ops->test_present (se))return 0 ; -if (ops->get_pfn (&e) == vgpu->gtt.scratch_pt[sp->type].page_mfn) +if (ops->get_pfn (se) == vgpu->gtt.scratch_pt[sp->type].page_mfn)return 0 ; -if (gtt_type_is_pt (get_next_pt_type (e.type))) { +if (gtt_type_is_pt (get_next_pt_type (se->type))) {struct intel_vgpu_ppgtt_spt *s = -ppgtt_find_shadow_page (vgpu, ops->get_pfn (&e)); +ppgtt_find_shadow_page (vgpu, ops->get_pfn (se));if (!s) {gvt_vgpu_err ("fail to find guest page\n" ); ret = -ENXIO ;
@@ -1011,12 +1008,10 @@ static int ppgtt_handle_guest_entry_removal(struct intel_vgpu_guest_page *gpt,if (ret) goto fail; } - ops->set_pfn (&e, vgpu->gtt.scratch_pt[sp->type].page_mfn); -ppgtt_set_shadow_entry (spt, &e, index);return 0 ; fail:gvt_vgpu_err ("fail: shadow page %p guest entry 0x%llx type %d\n" , - spt, e.val64, e.type); + spt, se->val64, se->type);return ret; }
@@ -1236,22 +1231,37 @@ static int ppgtt_handle_guest_write_page_table( {struct intel_vgpu_ppgtt_spt *spt =guest_page_to_ppgtt_spt (gpt);struct intel_vgpu *vgpu = spt->vgpu; +int type = spt->shadow_page.type;struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +struct intel_gvt_gtt_entry se;int ret;int new_present; new_present = ops->test_present (we); - ret =ppgtt_handle_guest_entry_removal (gpt, index); -if (ret) - goto fail; +/* +* Adding the new entry first and then removing the old one, that can +* guarantee the ppgtt table is validated during the window between +* adding and removal. +*/ +ppgtt_get_shadow_entry (spt, &se, index);if (new_present) { ret =ppgtt_handle_guest_entry_add (gpt, we, index);if (ret) goto fail; } + + ret =ppgtt_handle_guest_entry_removal (gpt, &se, index); +if (ret) + goto fail; + +if (!new_present) { + ops->set_pfn (&se, vgpu->gtt.scratch_pt[type].page_mfn); +ppgtt_set_shadow_entry (spt, &se, index); + } +return 0 ; fail: gvt_vgpu_err("fail: shadow page %p guest entry 0x%llx type %d.\n",
@@ -1323,7 +1333,7 @@ static int ppgtt_handle_guest_write_page_table_bytes(void *gp,struct intel_vgpu *vgpu = spt->vgpu;struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;const struct intel_gvt_device_info *info = &vgpu->gvt->device_info; -struct intel_gvt_gtt_entry we; +struct intel_gvt_gtt_entry we, se;unsigned long index;int ret;
@@ -1339,7 +1349,8 @@ static int ppgtt_handle_guest_write_page_table_bytes(void *gp,return ret; }else {if (!test_bit (index, spt->post_shadow_bitmap)) { - ret =ppgtt_handle_guest_entry_removal (gpt, index); +ppgtt_get_shadow_entry (spt, &se, index); + ret =ppgtt_handle_guest_entry_removal (gpt, &se, index);if (ret)return ret; }
drivers/gpu/drm/i915/gvt/vgpu.c +1 -0
@@ -43,6 +43,7 @@ void populate_pvinfo_page(struct intel_vgpu *vgpu)vgpu_vreg (vgpu,vgtif_reg (version_minor)) =0 ;vgpu_vreg (vgpu,vgtif_reg (display_ready)) =0 ;vgpu_vreg (vgpu,vgtif_reg (vgt_id)) = vgpu->id; +vgpu_vreg (vgpu,vgtif_reg (vgt_caps)) =VGT_CAPS_FULL_PPGTT_48BIT ;vgpu_vreg (vgpu,vgtif_reg (avail_rs.mappable_gmadr.base)) =vgpu_aperture_gmadr_base (vgpu); vgpu_vreg(vgpu, vgtif_reg(avail_rs.mappable_gmadr.size)) =
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · Zhenyu Wang
From: Tina Zhang <[email protected]>
Enable the guest i915 48bit full ppgtt functionality when host can provide the capability.
vgt_capsis introduced to guest i915 driver to get the vgpu capabilities from the device model.VGT_CAPS_FULL_PPGTT_48BITis one of the capabilities type which let guest i915 dirver know that the guest 48bit i915 full ppgtt is supported by device model.
Quoted 7 lines
Notice that the minor version of pvinfo isn't bumped because of this
vgt_capsintroduction, due to older guest would be broken by simply increasing the pvinfo version. Although the pvinfo minor version doesn't increase, the compatibility won't be blocked. The compatibility is ensured by checking the value of caps field in pvinfo. Zero means no full ppgtt support and BIT(2) means this feature is provided.
Note: as agreed with Joonas if i915 change is reviewed ok, this series will be merged through gvt tree for dependence.
Signature · 3 lines
Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [v7,1/2] drm/i915: Enable guest i915 48bit full ppgtt functionality
In reply to Zhenyu Wang== Series Details ==
== Series Details ==
Series: series starting with [v7,1/2] drm/i915: Enable guest i915 48bit full ppgtt functionality
URL : https://patchwork.freedesktop.org/series/26980/
State : success
== Summary ==
Series 26980v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/26980/revisions/1/mbox/
Test gem_exec_flush:
Subgroup basic-batch-kernel-default-uc:
pass -> FAIL (fi-snb-2600) fdo#100007
Test gem_exec_suspend:
Subgroup basic-s4-devices:
dmesg-warn -> PASS (fi-kbl-7560u) fdo#100125 +1
Test kms_pipe_crc_basic:
Subgroup hang-read-crc-pipe-a:
dmesg-warn -> PASS (fi-pnv-d510) fdo#101597fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007
fdo#100125 https://bugs.freedesktop.org/show_bug.cgi?id=100125
fdo#101597 https://bugs.freedesktop.org/show_bug.cgi?id=101597
fi-bdw-5557u total:279 pass:268 dwarn:0 dfail:0 fail:0 skip:11 time:447s fi-bdw-gvtdvm total:279 pass:265 dwarn:0 dfail:0 fail:0 skip:14 time:432s fi-blb-e6850 total:279 pass:224 dwarn:1 dfail:0 fail:0 skip:54 time:358s fi-bsw-n3050 total:279 pass:243 dwarn:0 dfail:0 fail:0 skip:36 time:523s fi-bxt-j4205 total:279 pass:260 dwarn:0 dfail:0 fail:0 skip:19 time:505s fi-byt-j1900 total:279 pass:254 dwarn:1 dfail:0 fail:0 skip:24 time:486s fi-byt-n2820 total:279 pass:250 dwarn:1 dfail:0 fail:0 skip:28 time:485s fi-glk-2a total:279 pass:260 dwarn:0 dfail:0 fail:0 skip:19 time:601s fi-hsw-4770 total:279 pass:263 dwarn:0 dfail:0 fail:0 skip:16 time:431s fi-hsw-4770r total:279 pass:263 dwarn:0 dfail:0 fail:0 skip:16 time:414s fi-ilk-650 total:279 pass:229 dwarn:0 dfail:0 fail:0 skip:50 time:423s fi-ivb-3520m total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:501s fi-ivb-3770 total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:474s fi-kbl-7500u total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:464s fi-kbl-7560u total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:579s fi-kbl-r total:279 pass:260 dwarn:1 dfail:0 fail:0 skip:18 time:584s fi-pnv-d510 total:279 pass:223 dwarn:1 dfail:0 fail:0 skip:55 time:564s fi-skl-6260u total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:461s fi-skl-6700hq total:279 pass:262 dwarn:0 dfail:0 fail:0 skip:17 time:586s fi-skl-6700k total:279 pass:257 dwarn:4 dfail:0 fail:0 skip:18 time:466s fi-skl-6770hq total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:476s fi-skl-gvtdvm total:279 pass:266 dwarn:0 dfail:0 fail:0 skip:13 time:443s fi-snb-2520m total:279 pass:251 dwarn:0 dfail:0 fail:0 skip:28 time:539s fi-snb-2600 total:279 pass:249 dwarn:0 dfail:0 fail:1 skip:29 time:406s
11125fb7b775223081da697898a92119cb017538 drm-tip: 2017y-07m-06d-23h-19m-02s UTC integration manifest 4ef7bf7 drm/i915/gvt: Fix guest i915 48bit full ppgtt blocking issue
d770cdf drm/i915: Enable guest i915 48bit full ppgtt functionality
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_5139/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx