All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 4/9] drm/amdgpu: stop implementing init_mem_type
Date: Thu, 23 Jul 2020 17:17:05 +0200	[thread overview]
Message-ID: <20200723151710.3591-5-christian.koenig@amd.com> (raw)
In-Reply-To: <20200723151710.3591-1-christian.koenig@amd.com>

Instead just initialize the memory type parameters
before calling ttm_bo_init_mm.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 96 +++++++++++--------------
 1 file changed, 43 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 406bcb03df48..98a77fc4a90c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -62,55 +62,49 @@
 
 #define AMDGPU_TTM_VRAM_MAX_DW_READ	(size_t)128
 
-
-/**
- * amdgpu_init_mem_type - Initialize a memory manager for a specific type of
- * memory request.
- *
- * @bdev: The TTM BO device object (contains a reference to amdgpu_device)
- * @type: The type of memory requested
- * @man: The memory type manager for each domain
- *
- * This is called by ttm_bo_init_mm() when a buffer object is being
- * initialized.
- */
 static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
 				struct ttm_mem_type_manager *man)
 {
-	struct amdgpu_device *adev;
+	return 0;
+}
 
-	adev = amdgpu_ttm_adev(bdev);
+static int amdgpu_ttm_init_vram(struct amdgpu_device *adev)
+{
 
-	switch (type) {
-	case TTM_PL_SYSTEM:
-		/* System memory */
-		break;
-	case TTM_PL_TT:
-		/* GTT memory  */
-		man->use_tt = true;
-		man->func = &amdgpu_gtt_mgr_func;
-		man->available_caching = TTM_PL_MASK_CACHING;
-		man->default_caching = TTM_PL_FLAG_CACHED;
-		break;
-	case TTM_PL_VRAM:
-		/* "On-card" video ram */
-		man->func = &amdgpu_vram_mgr_func;
-		man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
-		man->default_caching = TTM_PL_FLAG_WC;
-		break;
-	case AMDGPU_PL_GDS:
-	case AMDGPU_PL_GWS:
-	case AMDGPU_PL_OA:
-		/* On-chip GDS memory*/
-		man->func = &ttm_bo_manager_func;
-		man->available_caching = TTM_PL_FLAG_UNCACHED;
-		man->default_caching = TTM_PL_FLAG_UNCACHED;
-		break;
-	default:
-		DRM_ERROR("Unsupported memory type %u\n", (unsigned)type);
-		return -EINVAL;
-	}
-	return 0;
+	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
+
+	man->func = &amdgpu_vram_mgr_func;
+	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
+	man->default_caching = TTM_PL_FLAG_WC;
+
+	return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM,
+			      adev->gmc.real_vram_size >> PAGE_SHIFT);
+}
+
+static int amdgpu_ttm_init_gtt(struct amdgpu_device *adev, uint64_t gtt_size)
+{
+	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
+
+	man->use_tt = true;
+	man->func = &amdgpu_gtt_mgr_func;
+	man->available_caching = TTM_PL_MASK_CACHING;
+	man->default_caching = TTM_PL_FLAG_CACHED;
+
+	return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT,
+			      gtt_size >> PAGE_SHIFT);
+}
+
+static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
+				   unsigned int type,
+				   uint64_t size)
+{
+	struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type];
+
+	man->func = &ttm_bo_manager_func;
+	man->available_caching = TTM_PL_FLAG_UNCACHED;
+	man->default_caching = TTM_PL_FLAG_UNCACHED;
+
+	return ttm_bo_init_mm(&adev->mman.bdev, type, size);
 }
 
 /**
@@ -1896,8 +1890,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 	adev->mman.bdev.no_retry = true;
 
 	/* Initialize VRAM pool with all of VRAM divided into pages */
-	r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM,
-				adev->gmc.real_vram_size >> PAGE_SHIFT);
+	r = amdgpu_ttm_init_vram(adev);
 	if (r) {
 		DRM_ERROR("Failed initializing VRAM heap.\n");
 		return r;
@@ -1978,7 +1971,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 		gtt_size = (uint64_t)amdgpu_gtt_size << 20;
 
 	/* Initialize GTT memory pool */
-	r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, gtt_size >> PAGE_SHIFT);
+	r = amdgpu_ttm_init_gtt(adev, gtt_size);
 	if (r) {
 		DRM_ERROR("Failed initializing GTT heap.\n");
 		return r;
@@ -1987,22 +1980,19 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 		 (unsigned)(gtt_size / (1024 * 1024)));
 
 	/* Initialize various on-chip memory pools */
-	r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS,
-			   adev->gds.gds_size);
+	r = amdgpu_ttm_init_on_chip(adev, AMDGPU_PL_GDS, adev->gds.gds_size);
 	if (r) {
 		DRM_ERROR("Failed initializing GDS heap.\n");
 		return r;
 	}
 
-	r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS,
-			   adev->gds.gws_size);
+	r = amdgpu_ttm_init_on_chip(adev, AMDGPU_PL_GWS, adev->gds.gws_size);
 	if (r) {
 		DRM_ERROR("Failed initializing gws heap.\n");
 		return r;
 	}
 
-	r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA,
-			   adev->gds.oa_size);
+	r = amdgpu_ttm_init_on_chip(adev, AMDGPU_PL_OA, adev->gds.oa_size);
 	if (r) {
 		DRM_ERROR("Failed initializing oa heap.\n");
 		return r;
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-07-23 15:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 15:17 More TTM cleanups Christian König
2020-07-23 15:17 ` [PATCH 1/9] drm/ttm: initialize the system domain with defaults Christian König
2020-07-24  6:43   ` Thomas Zimmermann
2020-07-29  6:21     ` Dave Airlie
2020-07-29  6:23       ` Dave Airlie
2020-07-29  9:47         ` Christian König
2020-07-23 15:17 ` [PATCH 2/9] drm/ttm: remove TTM_MEMTYPE_FLAG_FIXED Christian König
2020-07-24  6:50   ` Thomas Zimmermann
2020-07-24  7:27     ` Christian König
2020-07-23 15:17 ` [PATCH 3/9] drm/radeon: stop implementing init_mem_type Christian König
2020-07-23 15:17 ` Christian König [this message]
2020-07-23 15:17 ` [PATCH 5/9] drm/vmwgfx: " Christian König
2020-07-23 15:17 ` [PATCH 6/9] drm/nouveau: " Christian König
2020-07-23 15:17 ` [PATCH 7/9] drm/qxl: " Christian König
2020-07-23 15:17 ` [PATCH 8/9] drm/vram-helper: " Christian König
2020-07-24  6:51   ` Thomas Zimmermann
2020-07-23 15:17 ` [PATCH 9/9] drm/ttm: remove the init_mem_type callback Christian König
2020-07-23 20:31   ` Alex Deucher
2020-07-24  6:51   ` Thomas Zimmermann
2020-07-30  9:00 [PATCH 1/9] drm/ttm: initialize the system domain with defaults v2 Christian König
2020-07-30  9:00 ` [PATCH 4/9] drm/amdgpu: stop implementing init_mem_type Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200723151710.3591-5-christian.koenig@amd.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.