diff mbox series

drm/i915/gt: limit lmem allocation size to succeed on SmallBars

Message ID 20230601144450.792228-1-andrzej.hajda@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/gt: limit lmem allocation size to succeed on SmallBars | expand

Commit Message

Andrzej Hajda June 1, 2023, 2:44 p.m. UTC
In case system is short on mappable memory (256MB on SmallBar) allocation
of two 1GB buffers will fail.

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8300
Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
 drivers/gpu/drm/i915/gt/selftest_tlb.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Andi Shyti June 2, 2023, 9:07 a.m. UTC | #1
Hi Andrzej,

On Thu, Jun 01, 2023 at 04:44:50PM +0200, Andrzej Hajda wrote:
> In case system is short on mappable memory (256MB on SmallBar) allocation
> of two 1GB buffers will fail.
> 
> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8300
> Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
> ---
>  drivers/gpu/drm/i915/gt/selftest_tlb.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/selftest_tlb.c b/drivers/gpu/drm/i915/gt/selftest_tlb.c
> index 4493c8518e91b2..3bd6b540257b46 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_tlb.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_tlb.c
> @@ -190,11 +190,18 @@ pte_tlbinv(struct intel_context *ce,
>  
>  static struct drm_i915_gem_object *create_lmem(struct intel_gt *gt)
>  {
> +	struct intel_memory_region *mr = gt->i915->mm.regions[INTEL_REGION_LMEM_0];
> +	resource_size_t size = SZ_1G;
> +
>  	/*
>  	 * Allocation of largest possible page size allows to test all types
> -	 * of pages.
> +	 * of pages. To succeed with both allocations, especially in case of Small
> +	 * BAR, try to allocate no more than quarter of mappable memory.
>  	 */
> -	return i915_gem_object_create_lmem(gt->i915, SZ_1G, I915_BO_ALLOC_CONTIGUOUS);
> +	if (mr && size > mr->io_size / 4)
> +		size = mr->io_size / 4;
> +
> +	return i915_gem_object_create_lmem(gt->i915, size, I915_BO_ALLOC_CONTIGUOUS);

makes sense to me.

Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> 

Thanks,
Andi
Andrzej Hajda June 5, 2023, 9:06 a.m. UTC | #2
On 02.06.2023 11:07, Andi Shyti wrote:
> Hi Andrzej,
> 
> On Thu, Jun 01, 2023 at 04:44:50PM +0200, Andrzej Hajda wrote:
>> In case system is short on mappable memory (256MB on SmallBar) allocation
>> of two 1GB buffers will fail.
>>
>> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8300
>> Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
>> ---
>>   drivers/gpu/drm/i915/gt/selftest_tlb.c | 11 +++++++++--
>>   1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/selftest_tlb.c b/drivers/gpu/drm/i915/gt/selftest_tlb.c
>> index 4493c8518e91b2..3bd6b540257b46 100644
>> --- a/drivers/gpu/drm/i915/gt/selftest_tlb.c
>> +++ b/drivers/gpu/drm/i915/gt/selftest_tlb.c
>> @@ -190,11 +190,18 @@ pte_tlbinv(struct intel_context *ce,
>>   
>>   static struct drm_i915_gem_object *create_lmem(struct intel_gt *gt)
>>   {
>> +	struct intel_memory_region *mr = gt->i915->mm.regions[INTEL_REGION_LMEM_0];
>> +	resource_size_t size = SZ_1G;
>> +
>>   	/*
>>   	 * Allocation of largest possible page size allows to test all types
>> -	 * of pages.
>> +	 * of pages. To succeed with both allocations, especially in case of Small
>> +	 * BAR, try to allocate no more than quarter of mappable memory.
>>   	 */
>> -	return i915_gem_object_create_lmem(gt->i915, SZ_1G, I915_BO_ALLOC_CONTIGUOUS);
>> +	if (mr && size > mr->io_size / 4)
>> +		size = mr->io_size / 4;
>> +
>> +	return i915_gem_object_create_lmem(gt->i915, size, I915_BO_ALLOC_CONTIGUOUS);
> 
> makes sense to me.
> 
> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>

Thx, patch merged.

Regards
Andrzej


> 
> Thanks,
> Andi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/selftest_tlb.c b/drivers/gpu/drm/i915/gt/selftest_tlb.c
index 4493c8518e91b2..3bd6b540257b46 100644
--- a/drivers/gpu/drm/i915/gt/selftest_tlb.c
+++ b/drivers/gpu/drm/i915/gt/selftest_tlb.c
@@ -190,11 +190,18 @@  pte_tlbinv(struct intel_context *ce,
 
 static struct drm_i915_gem_object *create_lmem(struct intel_gt *gt)
 {
+	struct intel_memory_region *mr = gt->i915->mm.regions[INTEL_REGION_LMEM_0];
+	resource_size_t size = SZ_1G;
+
 	/*
 	 * Allocation of largest possible page size allows to test all types
-	 * of pages.
+	 * of pages. To succeed with both allocations, especially in case of Small
+	 * BAR, try to allocate no more than quarter of mappable memory.
 	 */
-	return i915_gem_object_create_lmem(gt->i915, SZ_1G, I915_BO_ALLOC_CONTIGUOUS);
+	if (mr && size > mr->io_size / 4)
+		size = mr->io_size / 4;
+
+	return i915_gem_object_create_lmem(gt->i915, size, I915_BO_ALLOC_CONTIGUOUS);
 }
 
 static struct drm_i915_gem_object *create_smem(struct intel_gt *gt)