drm/i915/region: fix max size calculation
Subsystems (2)
PATCH 1/1 drm/i915/region: fix max size calculation
We are incorrectly limiting the max allocation size as per the mm max_order, which is effectively the largest power-of-two that we can fit in the region size. However, it's normal to setup the region or allocator with a non-power-of-two size(for example 3G), which we should already handle correctly, except it seems for the early too-big-check.
--- drivers/gpu/drm/i915/intel_memory_region.c | 2 +- .../drm/i915/selftests/intel_memory_region.c | 50 +++++++++++++++++++ drivers/gpu/drm/i915/selftests/mock_region.c | 2 +- 3 files changed, 52 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_memory_region.c +1 -1
@@ -87,7 +87,7 @@ __intel_memory_region_get_pages_buddy(struct intel_memory_region *mem, min_order =ilog2 (size) -ilog2 (mem->mm.chunk_size); } -if (size >BIT (mem->mm.max_order) * mem->mm.chunk_size) +if (size > mem->mm.size)return -E2BIG ; n_pages = size >>ilog2 (mem->mm.chunk_size);
drivers/gpu/drm/i915/selftests/intel_memory_region.c +50 -0
62 lines not on this page · raw message
drivers/gpu/drm/i915/selftests/mock_region.c +1 -1
@@ -24,7 +24,7 @@ mock_object_create(struct intel_memory_region *mem,struct drm_i915_private *i915 = mem->i915;struct drm_i915_gem_object *obj; -if (size >BIT (mem->mm.max_order) * mem->mm.chunk_size) +if (size > mem->mm.size)return ERR_PTR (-E2BIG ); obj =i915_gem_object_alloc ();
Signature · 6 lines
2.26.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Matthew Auld (2020-10-21 10:49:57)
Quoted 68 lines
We are incorrectly limiting the max allocation size as per the mm
max_order, which is effectively the largest power-of-two that we can fit in the region size. However, it's normal to setup the region or allocator with a non-power-of-two size(for example 3G), which we should already handle correctly, except it seems for the early too-big-check.Fixes b908be543e44 ("drm/i915: support creating LMEM objects")Signed-off-by Matthew Auld <[email protected]>Cc Chris Wilson <[email protected]>Cc CQ Tang <[email protected]>--- drivers/gpu/drm/i915/intel_memory_region.c | 2 +- .../drm/i915/selftests/intel_memory_region.c | 50 +++++++++++++++++++ drivers/gpu/drm/i915/selftests/mock_region.c | 2 +- 3 files changed, 52 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_memory_region.c +1
-1@@ -87,7 +87,7 @@ __intel_memory_region_get_pages_buddy(struct intel_memory_region *mem, min_order =ilog2 (size) -ilog2 (mem->mm.chunk_size); } -if (size >BIT (mem->mm.max_order) * mem->mm.chunk_size) +if (size > mem->mm.size)return -E2BIG ; n_pages = size >>ilog2 (mem->mm.chunk_size);drivers/gpu/drm/i915/selftests/intel_memory_region.c +31
-0@@ -261,6 +261,55 @@ static int igt_mock_contiguous(void *arg)return err; } +static int igt_mock_splintered_region (void *arg) +{ +struct intel_memory_region *mem = arg; +struct drm_i915_private *i915 = mem->i915; +struct drm_i915_gem_object *obj; +unsigned int expected_order; +LIST_HEAD (objects); +u64 size; +int err =0 ; + +/* +* Sanity check we can still allocate everything even if the +* mm.max_order != mm.size. i.e our starting address space size is not a +* power-of-two. +*/ + + size = (SZ_4G -1 ) &PAGE_MASK ; + mem =mock_region_create (i915,0 , size,PAGE_SIZE ,0 ); +if (IS_ERR (mem)) +return PTR_ERR (mem); + +if (mem->mm.size != size) { +pr_err ("%s size mismatch(%llu != %llu)\n" , + __func__, mem->mm.size, size); + err = -EINVAL ; + goto out_put; + } + + expected_order =get_order (rounddown_pow_of_two (size)); +if (mem->mm.max_order != expected_order) { + pr_err("%s order mismatch(%u != %u)\n",
drivers/gpu/drm/i915/selftests/intel_memory_region.c static int igt_mock_contiguous(void *arg) · line 304
Quoted 10 lines
drivers/gpu/drm/i915/selftests/intel_memory_region.c +10
-0+ __func__, mem->mm.max_order, expected_order); + err = -EINVAL ; + goto out_put; + } + + obj =igt_object_create (mem, &objects, size,0 ); +if (IS_ERR (obj)) { + err =PTR_ERR (obj); + goto out_close; + }
A second pass to see if we correctly reject an attempt to allocate a contiguous object larger than max chunk size (but still within mem_size)?
+1 for splintered!
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/region: fix max size calculation
In reply to Matthew Auld== Series Details ==
== Series Details ==
Series: drm/i915/region: fix max size calculation
URL : https://patchwork.freedesktop.org/series/82909/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_9175 -> Patchwork_18749
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18749/index.html
Known issues
------------
Here are the changes found in Patchwork_18749 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@core_hotunplug@unbind-rebind:
- fi-blb-e6850: [PASS][1] -> [INCOMPLETE][2] ([i915#2540])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9175/fi-blb-e6850/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18749/fi-blb-e6850/igt@[email protected]
- fi-icl-y: [PASS][3] -> [DMESG-WARN][4] ([i915#1982])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9175/fi-icl-y/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18749/fi-icl-y/igt@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-icl-u2: [PASS][5] -> [DMESG-WARN][6] ([i915#1982])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9175/fi-icl-u2/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18749/fi-icl-u2/igt@[email protected]
* igt@vgem_basic@unload:
- fi-skl-guc: [PASS][7] -> [DMESG-WARN][8] ([i915#2203])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9175/fi-skl-guc/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18749/fi-skl-guc/igt@[email protected]
#### Possible fixes ####
* igt@i915_selftest@live@gt_heartbeat:
- fi-tgl-u2: [INCOMPLETE][9] ([i915#2557]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9175/fi-tgl-u2/igt@i915_selftest@live@gt_heartbeat.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18749/fi-tgl-u2/igt@i915_selftest@live@gt_heartbeat.html
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-bsw-kefka: [DMESG-WARN][11] ([i915#1982]) -> [PASS][12] +1 similar issue
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9175/fi-bsw-kefka/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18749/fi-bsw-kefka/igt@[email protected]
#### Warnings ####
* igt@core_hotunplug@unbind-rebind:
- fi-icl-u2: [DMESG-WARN][13] ([i915#1982] / [i915#289]) -> [DMESG-WARN][14] ([i915#289])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9175/fi-icl-u2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18749/fi-icl-u2/igt@[email protected]
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2203]: https://gitlab.freedesktop.org/drm/intel/issues/2203
[i915#2540]: https://gitlab.freedesktop.org/drm/intel/issues/2540
[i915#2557]: https://gitlab.freedesktop.org/drm/intel/issues/2557
[i915#289]: https://gitlab.freedesktop.org/drm/intel/issues/289
Participating hosts (46 -> 39)
------------------------------
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_9175 -> Patchwork_18749
CI-20190529: 20190529
CI_DRM_9175: 39db87924cbebbf2be2ef849d5be1c761d7865a2 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5822: b4bcf05cb9839037128905deda7146434155cc41 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_18749: 9787b185affa7ef9ad06885f25df647f560626dc @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
9787b185affa drm/i915/region: fix max size calculation
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18749/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx