Re: [PATCH v2] drm/amdgpu: Fix size validation for non-exclusive domains

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 12.12.22 um 18:48 schrieb Luben Tuikov:
Fix amdgpu_bo_validate_size() to check whether the TTM domain manager for the
requested memory exists, and to allow for non-exclusive domain allocations, as
there would be if the domain is a mask, e.g. AMDGPU_GEM_DOMAIN_VRAM |
AMDGPU_GEM_DOMAIN_GTT.

Cc: Alex Deucher <Alexander.Deucher@xxxxxxx>
Cc: Christian König <christian.koenig@xxxxxxx>
Signed-off-by: Luben Tuikov <luben.tuikov@xxxxxxx>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19 +++++++------------
  1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index fd3ab4b5e5bb1f..e0f103f0ec2178 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -448,31 +448,26 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
/*
  	 * If GTT is part of requested domains the check must succeed to
-	 * allow fall back to GTT
+	 * allow fall back to GTT.
+	 *
+	 * Note that allocations can request from either domain. For
+	 * this reason, check either in non-exclusive way, and if
+	 * neither satisfies, fail the validation.

That's not correct, the original logic was completely intentional.

If both VRAM and GTT are specified it's valid if the size fits only into GTT.

Regards,
Christian.

  	 */
  	if (domain & AMDGPU_GEM_DOMAIN_GTT) {
  		man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
-
-		if (size < man->size)
+		if (man && size < man->size)
  			return true;
-		else
-			goto fail;
  	}
if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
  		man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
-
-		if (size < man->size)
+		if (man && size < man->size)
  			return true;
-		else
-			goto fail;
  	}
-
  	/* TODO add more domains checks, such as AMDGPU_GEM_DOMAIN_CPU */
-	return true;
-fail:
  	DRM_DEBUG("BO size %lu > total memory in domain: %llu\n", size,
  		  man->size);
  	return false;

base-commit: 20e03e7f6e8efd42168db6d3fe044b804e0ede8f




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux