[PATCH v5 6/6] [DEBUG] fix ENOSPC and ENODEV corner cases
Robert Beckett
bob.beckett at collabora.com
Fri Feb 4 17:29:32 UTC 2022
---
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 25 ++++++++-----------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index 9afea008192d..0e1706d17825 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -1076,10 +1076,15 @@ static int misaligned_case(struct i915_address_space *vm, struct intel_memory_re
struct i915_vma *vma;
int err = 0;
u64 expected_vma_size, expected_node_size;
+ bool is_stolen = mr->type == INTEL_MEMORY_STOLEN_SYSTEM || mr->type == INTEL_MEMORY_STOLEN_LOCAL;
obj = i915_gem_object_create_region(mr, size, 0, 0);
- if (IS_ERR(obj))
+ if (IS_ERR(obj)) {
+ /* if iGVT-g or DMAR is active, stolen mem will be uninitialized */
+ if (PTR_ERR(obj) == -ENODEV && is_stolen)
+ return 0;
return PTR_ERR(obj);
+ }
vma = i915_vma_instance(obj, vm, NULL);
if (IS_ERR(vma)) {
@@ -1145,8 +1150,12 @@ static int misaligned_pin(struct i915_address_space *vm,
for_each_memory_region(mr, vm->i915, id) {
u64 min_alignment = i915_vm_min_alignment(vm, (enum intel_memory_type)id);
u64 size = min_alignment;
- u64 addr = round_up(hole_start + (hole_size / 2), min_alignment);
+ u64 addr = round_down(hole_start + (hole_size / 2), min_alignment);
+ /* avoid -ENOSPC on very small hole setups */
+ if (hole_size < 3 * min_alignment)
+ continue;
+
/* we can't test < 4k alignment due to flags being encoded in lower bits */
if (min_alignment != I915_GTT_PAGE_SIZE_4K) {
err = misaligned_case(vm, mr, addr + (min_alignment / 2), size, flags);
@@ -1159,23 +1168,11 @@ static int misaligned_pin(struct i915_address_space *vm,
/* test for vma->size expansion to min page size */
err = misaligned_case(vm, mr, addr, PAGE_SIZE, flags);
- if (min_alignment > hole_size) {
- if (!err)
- err = -EBADSLT;
- else if (err == -ENOSPC)
- err = 0;
- }
if (err)
return err;
/* test for intermediate size not expanding vma->size for large alignments */
err = misaligned_case(vm, mr, addr, size / 2, flags);
- if (min_alignment > hole_size) {
- if (!err)
- err = -EBADSLT;
- else if (err == -ENOSPC)
- err = 0;
- }
if (err)
return err;
}
--
2.25.1
More information about the Intel-gfx-trybot
mailing list