drm/i915: Fix a typo in vgt_balloon_space()
Subsystems (2)
PATCH 1/1 drm/i915: Fix a typo in vgt_balloon_space()
From: Zhenyu Wang <[email protected]>
Commit 625d988acc28 ("drm/i915: Extract reserving space in the GTT to a helper") introduces this typo which can cause a driver loading failure in Linux GVT-g guest.
--- drivers/gpu/drm/i915/i915_vgpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_vgpu.c +1 -1
@@ -122,7 +122,7 @@ static int vgt_balloon_space(struct i915_ggtt *ggtt, {unsigned long size = end - start; -if (start <= end) +if (start >= end)return -EINVAL ; DRM_INFO("balloon space: range [ 0x%lx - 0x%lx ] %lu KiB.\n",
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: Re-enable preallocated top level PDPs support
After PPGTT page table is able to be shrinken, the preallocated PDPs and PDE pages can be freed even they are preallocated under 3-level PPGTT mode. This patch re-enables preallocated top level PDPs and PDE pages like before.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 10 +++++++++- drivers/gpu/drm/i915/i915_gem_gtt.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +9 -1
@@ -793,12 +793,18 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,struct i915_hw_ppgtt *ppgtt =i915_vm_to_ppgtt (vm);struct i915_page_directory *pd;uint64_t pdpe; +bool pd_is_empty;gen8_for_each_pdpe (pd, pdp, start, length, pdpe) {if (WARN_ON (!pdp->page_directory[pdpe]))break ; -if (gen8_ppgtt_clear_pd (vm, pd, start, length)) { + pd_is_empty =gen8_ppgtt_clear_pd (vm, pd, start, length); +/* Do not free pd pages if pdps are preallocated. */ +if (ppgtt->preallocate_top_level_pdps) +continue ; + +if (pd_is_empty) {__clear_bit (pdpe, pdp->used_pdpes);gen8_setup_pdpe (ppgtt, pdp, vm->scratch_pd, pdpe);free_pd (vm->i915, pd);
@@ -1545,6 +1551,8 @@ static int gen8_preallocate_top_level_pdps(struct i915_hw_ppgtt *ppgtt)free_gen8_temp_bitmaps (new_page_dirs, new_page_tables); + ppgtt->preallocate_top_level_pdps = true; +return ret; }
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -0
@@ -349,6 +349,7 @@ struct i915_hw_ppgtt {struct kref ref;struct drm_mm_node node;unsigned long pd_dirty_rings; +bool preallocate_top_level_pdps;union {struct i915_pml4 pml4;/* GEN8+ & 48b PPGTT */ struct i915_page_directory_pointer pdp;/* GEN8+ */
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -1488,7 +1488,7 @@ static int gen8_emit_bb_start(struct drm_i915_gem_request *req,if (req->ctx->ppgtt && (intel_engine_flag (req->engine) & req->ctx->ppgtt->pd_dirty_rings)) {if (!USES_FULL_48BIT_PPGTT (req->i915) && - !intel_vgpu_active (req->i915)) { + !req->ctx->ppgtt->preallocate_top_level_pdps) { ret =intel_logical_ring_emit_pdps (req);if (ret)return ret;
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm/i915: Re-enable preallocated top level PDPs support
Quoted 24 lines · Zhi Wang
After PPGTT page table is able to be shrinken, the preallocated PDPs and PDE pages can be freed even they are preallocated under 3-level PPGTT mode. This patch re-enables preallocated top level PDPs and PDE pages like before.
Cc Michał Winiarski <[email protected]>Cc Michel Thierry <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Cc Zhenyu Wang <[email protected]>Cc Zhiyuan Lv <[email protected]>Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 10 +++++++++- drivers/gpu/drm/i915/i915_gem_gtt.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0@@ -793,12 +793,18 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,struct i915_hw_ppgtt *ppgtt =i915_vm_to_ppgtt (vm);
drivers/gpu/drm/i915/i915_gem_gtt.c static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm, · line 802
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2
-1struct i915_page_directory *pd;uint64_t pdpe; +bool pd_is_empty;gen8_for_each_pdpe (pd, pdp, start, length, pdpe) {if (WARN_ON (!pdp->page_directory[pdpe]))break ; -if (gen8_ppgtt_clear_pd (vm, pd, start, length)) { + pd_is_empty =gen8_ppgtt_clear_pd (vm, pd, start, length);
Why the extra pd_is_empty variable?
Just adding if (preallocate) continue; here is more readable imho.
We should also assert that we're not in 4-level paging mode when shrinking is skipped.
With those changes:
-Michał
Quoted 45 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +7
-0+/* Do not free pd pages if pdps are preallocated. */ +if (ppgtt->preallocate_top_level_pdps) +continue ; + +if (pd_is_empty) {__clear_bit (pdpe, pdp->used_pdpes);gen8_setup_pdpe (ppgtt, pdp, vm->scratch_pd, pdpe);free_pd (vm->i915, pd);@@ -1545,6 +1551,8 @@ static int gen8_preallocate_top_level_pdps(struct i915_hw_ppgtt *ppgtt)free_gen8_temp_bitmaps (new_page_dirs, new_page_tables); + ppgtt->preallocate_top_level_pdps = true; +return ret; }drivers/gpu/drm/i915/i915_gem_gtt.h +1
-0@@ -349,6 +349,7 @@ struct i915_hw_ppgtt {struct kref ref;struct drm_mm_node node;unsigned long pd_dirty_rings; +bool preallocate_top_level_pdps;union {struct i915_pml4 pml4;/* GEN8+ & 48b PPGTT */ struct i915_page_directory_pointer pdp;/* GEN8+ */ drivers/gpu/drm/i915/intel_lrc.c +1
-1@@ -1488,7 +1488,7 @@ static int gen8_emit_bb_start(struct drm_i915_gem_request *req,if (req->ctx->ppgtt && (intel_engine_flag (req->engine) & req->ctx->ppgtt->pd_dirty_rings)) {if (!USES_FULL_48BIT_PPGTT (req->i915) && - !intel_vgpu_active (req->i915)) { + !req->ctx->ppgtt->preallocate_top_level_pdps) { ret =intel_logical_ring_emit_pdps (req);if (ret)return ret;Signature · 1 line
1.9.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm/i915: Re-enable preallocated top level PDPs support
Quoted 33 lines · Michał Winiarski
Quoted 32 lines · Zhi Wang
After PPGTT page table is able to be shrinken, the preallocated PDPs and PDE pages can be freed even they are preallocated under 3-level PPGTT mode. This patch re-enables preallocated top level PDPs and PDE pages like before.
Cc Michał Winiarski <[email protected]>Cc Michel Thierry <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Cc Zhenyu Wang <[email protected]>Cc Zhiyuan Lv <[email protected]>Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 10 +++++++++- drivers/gpu/drm/i915/i915_gem_gtt.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_gem_gtt.c +1
-0@@ -793,12 +793,18 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,struct i915_hw_ppgtt *ppgtt =i915_vm_to_ppgtt (vm);struct i915_page_directory *pd;uint64_t pdpe; +bool pd_is_empty;gen8_for_each_pdpe (pd, pdp, start, length, pdpe) {if (WARN_ON (!pdp->page_directory[pdpe]))break ;
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.c static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm, · line 802
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1
-1-if (gen8_ppgtt_clear_pd (vm, pd, start, length)) { + pd_is_empty =gen8_ppgtt_clear_pd (vm, pd, start, length);Why the extra
pd_is_emptyvariable?
Just adding if (preallocate) continue; here is more readable imho.We should also assert that we're not in 4-level paging mode when shrinking is skipped.
I've restructured this so that we only shrink from clear_range_4lvl. Having written the tests to exercise your code and put it to use.
Michał can you look at the ppgtt selftests can see if you can think of any other way we might be able to exercise the alloc/insert/clear? -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Wang, Zhi A
Reviewed-by Michał WiniarskiRe: [PATCH] drm/i915: Re-enable preallocated top level PDPs support
In reply to Michał WiniarskiHi Guys:
Please don't merge this patch at this time as I found another problem about alias PPGTT.
It seems the alias PPGTT on GEN8+ is also broken under native i915. The first allocate_va_range() in alias PPGTT initialization path will allocate all the page tables and the next clear_range() will shrink the allocated page table. It's OK at this time, but when doing VMA binding, alias_ppgtt_bind_vma() will directly insert PTE entries without calling a allocate_va_range() to create the page table first. This causes an OOPS on my machine.
It looks like we have two options:
1. Let the alias PPGTT page table also be shrinkable.
2. Follow the previous approach, don't shrink the alias PPGTT page table(Probably add some hack in clear_range() path.
-----Original Message-----
From: Winiarski, Michal
Sent: Thursday, January 19, 2017 7:53 PM
To: Wang, Zhi A <[email protected]>
Cc: [email protected]; Thierry, Michel <[email protected]>; Joonas Lahtinen <[email protected]>; Chris Wilson <[email protected]>; Zhenyu Wang <[email protected]>; Lv, Zhiyuan <[email protected]>
Subject: Re: [PATCH] drm/i915: Re-enable preallocated top level PDPs support
Quoted 25 lines · Zhi Wang
After PPGTT page table is able to be shrinken, the preallocated PDPs and PDE pages can be freed even they are preallocated under 3-level PPGTT mode. This patch re-enables preallocated top level PDPs and PDE pages like before.
Cc Michał Winiarski <[email protected]>Cc Michel Thierry <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Cc Zhenyu Wang <[email protected]>Cc Zhiyuan Lv <[email protected]>Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 10 +++++++++- drivers/gpu/drm/i915/i915_gem_gtt.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0@@ -793,12 +793,18 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,struct i915_hw_ppgtt *ppgtt =i915_vm_to_ppgtt (vm);
drivers/gpu/drm/i915/i915_gem_gtt.c static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm, · line 802
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2
-1struct i915_page_directory *pd;uint64_t pdpe; +bool pd_is_empty;gen8_for_each_pdpe (pd, pdp, start, length, pdpe) {if (WARN_ON (!pdp->page_directory[pdpe]))break ; -if (gen8_ppgtt_clear_pd (vm, pd, start, length)) { + pd_is_empty =gen8_ppgtt_clear_pd (vm, pd, start, length);
Why the extra pd_is_empty variable?
Just adding if (preallocate) continue; here is more readable imho.
We should also assert that we're not in 4-level paging mode when shrinking is skipped.
With those changes:
-Michał
Quoted 46 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +7
-0+/* Do not free pd pages if pdps are preallocated. */ +if (ppgtt->preallocate_top_level_pdps) +continue ; + +if (pd_is_empty) {__clear_bit (pdpe, pdp->used_pdpes);gen8_setup_pdpe (ppgtt, pdp, vm->scratch_pd, pdpe);free_pd (vm->i915, pd);@@ -1545,6 +1551,8 @@ static int gen8_preallocate_top_level_pdps(struct i915_hw_ppgtt *ppgtt)free_gen8_temp_bitmaps (new_page_dirs, new_page_tables); + ppgtt->preallocate_top_level_pdps = true; +return ret; }drivers/gpu/drm/i915/i915_gem_gtt.h +1
-0@@ -349,6 +349,7 @@ struct i915_hw_ppgtt {struct kref ref;struct drm_mm_node node;unsigned long pd_dirty_rings; +bool preallocate_top_level_pdps;union {struct i915_pml4 pml4;/* GEN8+ & 48b PPGTT */ struct i915_page_directory_pointer pdp;/* GEN8+ */ drivers/gpu/drm/i915/intel_lrc.c +1
-2@@ -1488,7 +1488,7 @@ static int gen8_emit_bb_start(struct drm_i915_gem_request *req,if (req->ctx->ppgtt && (intel_engine_flag (req->engine) & req->ctx->ppgtt->pd_dirty_rings)) {if (!USES_FULL_48BIT_PPGTT (req->i915) && - !intel_vgpu_active (req->i915)) { + !req->ctx->ppgtt->preallocate_top_level_pdps) { ret =intel_logical_ring_emit_pdps (req);if (ret)return ret; --
Quoted 2 lines
1.9.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula
maintainerQuoted 5 lines · Zhi Wang
From: Zhenyu Wang <[email protected]>
Commit
625d988acc28("drm/i915: Extract reserving space in the GTT to a helper") introduces this typo which can cause a driver loading failure in Linux GVT-g guest.
The proper format for fixes is:
Quoted 22 lines
Cc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Cc Zhiyuan Lv <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_vgpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/i915_vgpu.c +1
-1@@ -122,7 +122,7 @@ static int vgt_balloon_space(struct i915_ggtt *ggtt, {unsigned long size = end - start; -if (start <= end) +if (start >= end)return -EINVAL ; DRM_INFO("balloon space: range [ 0x%lx - 0x%lx ] %lu KiB.\n",
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 10 lines · Jani Nikula
Quoted 5 lines · Zhi Wang
From: Zhenyu Wang <[email protected]>
Commit
625d988acc28("drm/i915: Extract reserving space in the GTT to a helper") introduces this typo which can cause a driver loading failure in Linux GVT-g guest.The proper format for fixes is:
Fixes 625d988acc28 ("drm/i915: Extract reserving space in the GTT to a helper")
Pushed the fix for my obvious oops.
Need to spend some more time looking at the pdp fix - it certainly differs from the patches I have to fixup the same paths. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Thanks, Will update it in V2 :P
于 01/17/17 22:27, Jani Nikula:
Quoted 28 lines · Zhi Wang
Quoted 5 lines
From: Zhenyu Wang <[email protected]>
Commit
625d988acc28("drm/i915: Extract reserving space in the GTT to a helper") introduces this typo which can cause a driver loading failure in Linux GVT-g guest.The proper format for fixes is:
Fixes 625d988acc28 ("drm/i915: Extract reserving space in the GTT to a helper")Quoted 17 lines
Cc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Cc Zhiyuan Lv <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_vgpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/i915_vgpu.c +0
-0@@ -122,7 +122,7 @@ static int vgt_balloon_space(struct i915_ggtt *ggtt, {unsigned long size = end - start;
Quoted 6 lines
drivers/gpu/drm/i915/i915_vgpu.c static int vgt_balloon_space(struct i915_ggtt *ggtt, · line 128
Quoted 5 lines
drivers/gpu/drm/i915/i915_vgpu.c +1
-1-if (start <= end) +if (start >= end)return -EINVAL ; DRM_INFO("balloon space: range [ 0x%lx - 0x%lx ] %lu KiB.\n",
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 20 lines · Zhi Wang
From: Zhenyu Wang <[email protected]>
Commit
625d988acc28("drm/i915: Extract reserving space in the GTT to a helper") introduces this typo which can cause a driver loading failure in Linux GVT-g guest.Cc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Cc Zhiyuan Lv <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_vgpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/i915_vgpu.c +0
-0
drivers/gpu/drm/i915/i915_vgpu.c static int vgt_balloon_space(struct i915_ggtt *ggtt, · line 126
Quoted 6 lines
drivers/gpu/drm/i915/i915_vgpu.c +1
-1@@ -122,7 +122,7 @@ static int vgt_balloon_space(struct i915_ggtt *ggtt, {unsigned long size = end - start; -if (start <= end) +if (start >= end)return -EINVAL ;
Oops. Sorry,
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
It doesn't matter now:P
于 01/17/17 22:37, Chris Wilson:
Quoted 24 lines · Zhi Wang
Quoted 23 lines
From: Zhenyu Wang <[email protected]>
Commit
625d988acc28("drm/i915: Extract reserving space in the GTT to a helper") introduces this typo which can cause a driver loading failure in Linux GVT-g guest.Cc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Cc Zhiyuan Lv <[email protected]>Signed-off-by Zhenyu Wang <[email protected]>Signed-off-by Zhi Wang <[email protected]>--- drivers/gpu/drm/i915/i915_vgpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/i915_vgpu.c +0
-0@@ -122,7 +122,7 @@ static int vgt_balloon_space(struct i915_ggtt *ggtt, {unsigned long size = end - start;
Quoted 8 lines
drivers/gpu/drm/i915/i915_vgpu.c static int vgt_balloon_space(struct i915_ggtt *ggtt, · line 126
Quoted 3 lines
drivers/gpu/drm/i915/i915_vgpu.c +1
-1-if (start <= end) +if (start >= end)return -EINVAL ;Oops. Sorry,
Reviewed-by Chris Wilson <[email protected]>-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: Fix a typo in vgt_balloon_space() (rev2)
In reply to Zhi Wang== Series Details ==
== Series Details ==
Series: drm/i915: Fix a typo in vgt_balloon_space() (rev2)
URL : https://patchwork.freedesktop.org/series/18123/
State : success
== Summary ==
Series 18123v2 drm/i915: Fix a typo in vgt_balloon_space()
https://patchwork.freedesktop.org/api/1.0/series/18123/revisions/2/mbox/
fi-bdw-5557u total:246 pass:232 dwarn:0 dfail:0 fail:0 skip:14 fi-bsw-n3050 total:246 pass:207 dwarn:0 dfail:0 fail:0 skip:39 fi-bxt-j4205 total:246 pass:224 dwarn:0 dfail:0 fail:0 skip:22 fi-bxt-t5700 total:82 pass:69 dwarn:0 dfail:0 fail:0 skip:12 fi-byt-j1900 total:246 pass:219 dwarn:0 dfail:0 fail:0 skip:27 fi-byt-n2820 total:246 pass:215 dwarn:0 dfail:0 fail:0 skip:31 fi-hsw-4770 total:246 pass:227 dwarn:0 dfail:0 fail:0 skip:19 fi-hsw-4770r total:246 pass:227 dwarn:0 dfail:0 fail:0 skip:19 fi-ivb-3520m total:246 pass:225 dwarn:0 dfail:0 fail:0 skip:21 fi-ivb-3770 total:246 pass:225 dwarn:0 dfail:0 fail:0 skip:21 fi-kbl-7500u total:246 pass:225 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6260u total:246 pass:233 dwarn:0 dfail:0 fail:0 skip:13 fi-skl-6700hq total:246 pass:226 dwarn:0 dfail:0 fail:0 skip:20 fi-skl-6700k total:246 pass:222 dwarn:3 dfail:0 fail:0 skip:21 fi-skl-6770hq total:246 pass:233 dwarn:0 dfail:0 fail:0 skip:13 fi-snb-2520m total:246 pass:215 dwarn:0 dfail:0 fail:0 skip:31 fi-snb-2600 total:246 pass:214 dwarn:0 dfail:0 fail:0 skip:32
ce0b007247ca4914620056ece367b90adc95fa2f drm-tip: 2017y-01m-17d-12h-37m-22s UTC integration manifest 5aad44c drm/i915: Re-enable preallocated top level PDPs support
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3532/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx