Skip to contentSkip to conversation

drm/amdgpu/gmc: move invaliation bitmap setup to common code

PATCH In review Alex Deucher 3 participants 6 messages Jan 6, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu/gmc: move invaliation bitmap setup to common code

So it can be shared with newer GMC versions.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 40 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  1 +
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 32 +-------------------
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h   | 10 -------
 4 files changed, 42 insertions(+), 41 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +40 -0
index bbcd11ac5bbb..d6901b274790 100644
@@ -333,3 +333,43 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)
 	amdgpu_mmhub_ras_fini(adev);
 	amdgpu_xgmi_ras_fini(adev);
 }
+
+	/*
+	 * The latest engine allocation on gfx9 is:
+	 * Engine 2, 3: firmware
+	 * Engine 0, 1, 4~16: amdgpu ring,
+	 *                    subject to change when ring number changes
+	 * Engine 17: Gart flushes
+	 */
+#define GFXHUB_FREE_VM_INV_ENGS_BITMAP		0x1FFF3
+#define MMHUB_FREE_VM_INV_ENGS_BITMAP		0x1FFF3
+
+int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev)
+{
+	struct amdgpu_ring *ring;
+	unsigned vm_inv_engs[AMDGPU_MAX_VMHUBS] =
+		{GFXHUB_FREE_VM_INV_ENGS_BITMAP, MMHUB_FREE_VM_INV_ENGS_BITMAP,
+		GFXHUB_FREE_VM_INV_ENGS_BITMAP};
+	unsigned i;
+	unsigned vmhub, inv_eng;
+
+	for (i = 0; i < adev->num_rings; ++i) {
+		ring = adev->rings[i];
+		vmhub = ring->funcs->vmhub;
+
+		inv_eng = ffs(vm_inv_engs[vmhub]);
+		if (!inv_eng) {
+			dev_err(adev->dev, "no VM inv eng for ring %s\n",
+				ring->name);
+			return -EINVAL;
+		}
+
+		ring->vm_inv_eng = inv_eng - 1;
+		vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng);
+
+		dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n",
+			 ring->name, ring->vm_inv_eng, ring->funcs->vmhub);
+	}
+
+	return 0;
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
index b499a3de8bb6..c91dd602d5f1 100644
@@ -267,5 +267,6 @@ bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr,
 			      uint16_t pasid, uint64_t timestamp);
 int amdgpu_gmc_ras_late_init(struct amdgpu_device *adev);
 void amdgpu_gmc_ras_fini(struct amdgpu_device *adev);
+int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev);
 
 #endif
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -31
index 68f9a1fa6dc1..e3bbeab28152 100644
@@ -795,36 +795,6 @@ static bool gmc_v9_0_keep_stolen_memory(struct amdgpu_device *adev)
 	}
 }
 
-static int gmc_v9_0_allocate_vm_inv_eng(struct amdgpu_device *adev)
-{
-	struct amdgpu_ring *ring;
-	unsigned vm_inv_engs[AMDGPU_MAX_VMHUBS] =
-		{GFXHUB_FREE_VM_INV_ENGS_BITMAP, MMHUB_FREE_VM_INV_ENGS_BITMAP,
-		GFXHUB_FREE_VM_INV_ENGS_BITMAP};
-	unsigned i;
-	unsigned vmhub, inv_eng;
-
-	for (i = 0; i < adev->num_rings; ++i) {
-		ring = adev->rings[i];
-		vmhub = ring->funcs->vmhub;
-
-		inv_eng = ffs(vm_inv_engs[vmhub]);
-		if (!inv_eng) {
-			dev_err(adev->dev, "no VM inv eng for ring %s\n",
-				ring->name);
-			return -EINVAL;
-		}
-
-		ring->vm_inv_eng = inv_eng - 1;
-		vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng);
-
-		dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n",
-			 ring->name, ring->vm_inv_eng, ring->funcs->vmhub);
-	}
-
-	return 0;
-}
-
 static int gmc_v9_0_late_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -833,7 +803,7 @@ static int gmc_v9_0_late_init(void *handle)
 	if (!gmc_v9_0_keep_stolen_memory(adev))
 		amdgpu_bo_late_init(adev);
 
-	r = gmc_v9_0_allocate_vm_inv_eng(adev);
+	r = amdgpu_gmc_allocate_vm_inv_eng(adev);
 	if (r)
 		return r;
 	/* Check if ecc is available */
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h +0 -10
index 49e8be761214..e0585e8c6c1b 100644
@@ -24,16 +24,6 @@
 #ifndef __GMC_V9_0_H__
 #define __GMC_V9_0_H__
 
-	/*
-	 * The latest engine allocation on gfx9 is:
-	 * Engine 2, 3: firmware
-	 * Engine 0, 1, 4~16: amdgpu ring,
-	 *                    subject to change when ring number changes
-	 * Engine 17: Gart flushes
-	 */
-#define GFXHUB_FREE_VM_INV_ENGS_BITMAP		0x1FFF3
-#define MMHUB_FREE_VM_INV_ENGS_BITMAP		0x1FFF3
-
 extern const struct amd_ip_funcs gmc_v9_0_ip_funcs;
 extern const struct amdgpu_ip_block_version gmc_v9_0_ip_block;
 #endif
Signature · 6 lines
2.24.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

PATCH 2/2 drm/amdgpu/gmc10: use common invalidation engine helper

Rather than open coding it. This also changes the free masks to better reflect the usage by other components.

---

We always started at invalidation engine 4 on gmc10. Was there a reason for that? I would have figured it would follow the same model as older asics. I can make this more flexiable if so.

 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 19 ++++---------------
 2 files changed, 5 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +1 -1
index d6901b274790..5884ab590486 100644
@@ -335,7 +335,7 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)
 }
 
 	/*
-	 * The latest engine allocation on gfx9 is:
+	 * The latest engine allocation on gfx9/10 is:
 	 * Engine 2, 3: firmware
 	 * Engine 0, 1, 4~16: amdgpu ring,
 	 *                    subject to change when ring number changes
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -15
index f5725336a5f2..da9765ff45d6 100644
@@ -564,22 +564,11 @@ static int gmc_v10_0_early_init(void *handle)
 static int gmc_v10_0_late_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	unsigned vm_inv_eng[AMDGPU_MAX_VMHUBS] = { 4, 4 };
-	unsigned i;
-
-	for(i = 0; i < adev->num_rings; ++i) {
-		struct amdgpu_ring *ring = adev->rings[i];
-		unsigned vmhub = ring->funcs->vmhub;
-
-		ring->vm_inv_eng = vm_inv_eng[vmhub]++;
-		dev_info(adev->dev, "ring %u(%s) uses VM inv eng %u on hub %u\n",
-			 ring->idx, ring->name, ring->vm_inv_eng,
-			 ring->funcs->vmhub);
-	}
+	int r;
 
-	/* Engine 17 is used for GART flushes */
-	for(i = 0; i < AMDGPU_MAX_VMHUBS; ++i)
-		BUG_ON(vm_inv_eng[i] > 17);
+	r = amdgpu_gmc_allocate_vm_inv_eng(adev);
+	if (r)
+		return r;
 
 	return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0);
 }
Signature · 6 lines
2.24.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amdgpu/gmc10: use common invalidation engine helper

This patch is

I don't really know why the mask was different on GFXv10. I suspect it was laziness/simplicity of not having the gap at engines 2,3. If we don't have as many rings on GFXv10 ASICs we probably don't need engines 0,1.

Regards,
  Felix

Quoted 49 lines · Alex Deucher

Rather than open coding it. This also changes the free masks to better reflect the usage by other components.

---

We always started at invalidation engine 4 on gmc10. Was there a reason for that? I would have figured it would follow the same model as older asics. I can make this more flexiable if so.

  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c |  2 +-
  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 19 ++++---------------
  2 files changed, 5 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +1 -1
index d6901b274790..5884ab590486 100644
@@ -335,7 +335,7 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)
  }
 
  	/*
-	 * The latest engine allocation on gfx9 is:
+	 * The latest engine allocation on gfx9/10 is:
  	 * Engine 2, 3: firmware
  	 * Engine 0, 1, 4~16: amdgpu ring,
  	 *                    subject to change when ring number changes
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -12
index f5725336a5f2..da9765ff45d6 100644
@@ -564,22 +564,11 @@ static int gmc_v10_0_early_init(void *handle)
  static int gmc_v10_0_late_init(void *handle)
  {
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	unsigned vm_inv_eng[AMDGPU_MAX_VMHUBS] = { 4, 4 };
-	unsigned i;
-
-	for(i = 0; i < adev->num_rings; ++i) {
-		struct amdgpu_ring *ring = adev->rings[i];
-		unsigned vmhub = ring->funcs->vmhub;
-
-		ring->vm_inv_eng = vm_inv_eng[vmhub]++;
-		dev_info(adev->dev, "ring %u(%s) uses VM inv eng %u on hub %u\n",
-			 ring->idx, ring->name, ring->vm_inv_eng,
-			 ring->funcs->vmhub);
-	}
+	int r;

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static int gmc_v10_0_early_init(void *handle) · line 574

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +3 -3
 
-	/* Engine 17 is used for GART flushes */
-	for(i = 0; i < AMDGPU_MAX_VMHUBS; ++i)
-		BUG_ON(vm_inv_eng[i] > 17);
+	r = amdgpu_gmc_allocate_vm_inv_eng(adev);
+	if (r)
+		return r;
 
  	return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0);
  }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw

Re: [PATCH 2/2] drm/amdgpu/gmc10: use common invalidation engine helper

No idea either why that was done.

Anyway patch is Acked-by: Christian König <[email protected]>.

Regards,
Christian.

Am 06.01.20 um 20:16 schrieb Felix Kuehling:

Quoted 63 lines

This patch is

I don't really know why the mask was different on GFXv10. I suspect it was laziness/simplicity of not having the gap at engines 2,3. If we don't have as many rings on GFXv10 ASICs we probably don't need engines 0,1.

Regards,
  Felix

Quoted 53 lines · Alex Deucher

Rather than open coding it.  This also changes the free masks to better reflect the usage by other components.

---

We always started at invalidation engine 4 on gmc10.  Was there a reason for that?  I would have figured it would follow the same model as older asics.  I can make this more flexiable if so.

  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c |  2 +- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 19 ++++---------------

  2 files changed, 5 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +1 -1
index d6901b274790..5884ab590486 100644
@@ -335,7 +335,7 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)
   }
         /*
-     * The latest engine allocation on gfx9 is:
+     * The latest engine allocation on gfx9/10 is:
        * Engine 2, 3: firmware
        * Engine 0, 1, 4~16: amdgpu ring,
        *                    subject to change when ring number changes
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -12
index f5725336a5f2..da9765ff45d6 100644
@@ -564,22 +564,11 @@ static int gmc_v10_0_early_init(void *handle)
   static int gmc_v10_0_late_init(void *handle)
   {
       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-    unsigned vm_inv_eng[AMDGPU_MAX_VMHUBS] = { 4, 4 };
-    unsigned i;
-
-    for(i = 0; i < adev->num_rings; ++i) {
-        struct amdgpu_ring *ring = adev->rings[i];
-        unsigned vmhub = ring->funcs->vmhub;
-
-        ring->vm_inv_eng = vm_inv_eng[vmhub]++;
-        dev_info(adev->dev, "ring %u(%s) uses VM inv eng %u on hub 
 %u\n",
-             ring->idx, ring->name, ring->vm_inv_eng,
-             ring->funcs->vmhub);
-    }
+    int r;

  -    /* Engine 17 is used for GART flushes */
-    for(i = 0; i < AMDGPU_MAX_VMHUBS; ++i)
-        BUG_ON(vm_inv_eng[i] > 17);
+    r = amdgpu_gmc_allocate_vm_inv_eng(adev);

Quoted 8 lines
Quoted 4 lines

+    if (r)
+        return r;
        return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0); }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by on v1 1/2
#4 lore raw
In reply to Alex Deucher
Quoted 3 lines · Alex Deucher

So it can be shared with newer GMC versions.

Quoted 127 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 40 +++++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  1 +
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 32 +-------------------
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h   | 10 -------
  4 files changed, 42 insertions(+), 41 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +40 -0
index bbcd11ac5bbb..d6901b274790 100644
@@ -333,3 +333,43 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device *adev)
  	amdgpu_mmhub_ras_fini(adev);
  	amdgpu_xgmi_ras_fini(adev);
  }
+
+	/*
+	 * The latest engine allocation on gfx9 is:
+	 * Engine 2, 3: firmware
+	 * Engine 0, 1, 4~16: amdgpu ring,
+	 *                    subject to change when ring number changes
+	 * Engine 17: Gart flushes
+	 */
+#define GFXHUB_FREE_VM_INV_ENGS_BITMAP		0x1FFF3
+#define MMHUB_FREE_VM_INV_ENGS_BITMAP		0x1FFF3
+
+int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev)
+{
+	struct amdgpu_ring *ring;
+	unsigned vm_inv_engs[AMDGPU_MAX_VMHUBS] =
+		{GFXHUB_FREE_VM_INV_ENGS_BITMAP, MMHUB_FREE_VM_INV_ENGS_BITMAP,
+		GFXHUB_FREE_VM_INV_ENGS_BITMAP};
+	unsigned i;
+	unsigned vmhub, inv_eng;
+
+	for (i = 0; i < adev->num_rings; ++i) {
+		ring = adev->rings[i];
+		vmhub = ring->funcs->vmhub;
+
+		inv_eng = ffs(vm_inv_engs[vmhub]);
+		if (!inv_eng) {
+			dev_err(adev->dev, "no VM inv eng for ring %s\n",
+				ring->name);
+			return -EINVAL;
+		}
+
+		ring->vm_inv_eng = inv_eng - 1;
+		vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng);
+
+		dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n",
+			 ring->name, ring->vm_inv_eng, ring->funcs->vmhub);
+	}
+
+	return 0;
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
index b499a3de8bb6..c91dd602d5f1 100644
@@ -267,5 +267,6 @@ bool amdgpu_gmc_filter_faults(struct amdgpu_device *adev, uint64_t addr,
  			      uint16_t pasid, uint64_t timestamp);
  int amdgpu_gmc_ras_late_init(struct amdgpu_device *adev);
  void amdgpu_gmc_ras_fini(struct amdgpu_device *adev);
+int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev);
 
  #endif
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -31
index 68f9a1fa6dc1..e3bbeab28152 100644
@@ -795,36 +795,6 @@ static bool gmc_v9_0_keep_stolen_memory(struct amdgpu_device *adev)
  	}
  }
 
-static int gmc_v9_0_allocate_vm_inv_eng(struct amdgpu_device *adev)
-{
-	struct amdgpu_ring *ring;
-	unsigned vm_inv_engs[AMDGPU_MAX_VMHUBS] =
-		{GFXHUB_FREE_VM_INV_ENGS_BITMAP, MMHUB_FREE_VM_INV_ENGS_BITMAP,
-		GFXHUB_FREE_VM_INV_ENGS_BITMAP};
-	unsigned i;
-	unsigned vmhub, inv_eng;
-
-	for (i = 0; i < adev->num_rings; ++i) {
-		ring = adev->rings[i];
-		vmhub = ring->funcs->vmhub;
-
-		inv_eng = ffs(vm_inv_engs[vmhub]);
-		if (!inv_eng) {
-			dev_err(adev->dev, "no VM inv eng for ring %s\n",
-				ring->name);
-			return -EINVAL;
-		}
-
-		ring->vm_inv_eng = inv_eng - 1;
-		vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng);
-
-		dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n",
-			 ring->name, ring->vm_inv_eng, ring->funcs->vmhub);
-	}
-
-	return 0;
-}
-
  static int gmc_v9_0_late_init(void *handle)
  {
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -833,7 +803,7 @@ static int gmc_v9_0_late_init(void *handle)
  	if (!gmc_v9_0_keep_stolen_memory(adev))
  		amdgpu_bo_late_init(adev);
 
-	r = gmc_v9_0_allocate_vm_inv_eng(adev);
+	r = amdgpu_gmc_allocate_vm_inv_eng(adev);
  	if (r)
  		return r;
  	/* Check if ecc is available */
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h +0 -3
index 49e8be761214..e0585e8c6c1b 100644
@@ -24,16 +24,6 @@
  #ifndef __GMC_V9_0_H__
  #define __GMC_V9_0_H__
 
-	/*
-	 * The latest engine allocation on gfx9 is:
-	 * Engine 2, 3: firmware

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h line 29

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h +0 -7
-	 * Engine 0, 1, 4~16: amdgpu ring,
-	 *                    subject to change when ring number changes
-	 * Engine 17: Gart flushes
-	 */
-#define GFXHUB_FREE_VM_INV_ENGS_BITMAP		0x1FFF3
-#define MMHUB_FREE_VM_INV_ENGS_BITMAP		0x1FFF3
-
  extern const struct amd_ip_funcs gmc_v9_0_ip_funcs;
  extern const struct amdgpu_ip_block_version gmc_v9_0_ip_block;
  #endif

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by
#5 lore raw

Am 06.01.20 um 20:16 schrieb Felix Kuehling:

Quoted 6 lines · Alex Deucher
Quoted 3 lines

So it can be shared with newer GMC versions.

Quoted 134 lines
Quoted 134 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 40 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h |  1 + drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 32 +------------------- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h   | 10 -------

  4 files changed, 42 insertions(+), 41 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
index bbcd11ac5bbb..d6901b274790 100644
@@ -333,3 +333,43 @@ void amdgpu_gmc_ras_fini(struct amdgpu_device 
 *adev)
       amdgpu_mmhub_ras_fini(adev);
       amdgpu_xgmi_ras_fini(adev);

  }

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +40 -0
+
+    /*
+     * The latest engine allocation on gfx9 is:
+     * Engine 2, 3: firmware
+     * Engine 0, 1, 4~16: amdgpu ring,
+     *                    subject to change when ring number changes
+     * Engine 17: Gart flushes
+     */
+#define GFXHUB_FREE_VM_INV_ENGS_BITMAP        0x1FFF3
+#define MMHUB_FREE_VM_INV_ENGS_BITMAP        0x1FFF3
+
+int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev)
+{
+    struct amdgpu_ring *ring;
+    unsigned vm_inv_engs[AMDGPU_MAX_VMHUBS] =
+        {GFXHUB_FREE_VM_INV_ENGS_BITMAP, MMHUB_FREE_VM_INV_ENGS_BITMAP,
+        GFXHUB_FREE_VM_INV_ENGS_BITMAP};
+    unsigned i;
+    unsigned vmhub, inv_eng;
+
+    for (i = 0; i < adev->num_rings; ++i) {
+        ring = adev->rings[i];
+        vmhub = ring->funcs->vmhub;
+
+        inv_eng = ffs(vm_inv_engs[vmhub]);
+        if (!inv_eng) {
+            dev_err(adev->dev, "no VM inv eng for ring %s\n",
+                ring->name);
+            return -EINVAL;
+        }
+
+        ring->vm_inv_eng = inv_eng - 1;
+        vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng);
+
+        dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n",
+             ring->name, ring->vm_inv_eng, ring->funcs->vmhub);
+    }
+
+    return 0;
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
index b499a3de8bb6..c91dd602d5f1 100644
@@ -267,5 +267,6 @@ bool amdgpu_gmc_filter_faults(struct 
 amdgpu_device *adev, uint64_t addr,
                     uint16_t pasid, uint64_t timestamp);
   int amdgpu_gmc_ras_late_init(struct amdgpu_device *adev);
   void amdgpu_gmc_ras_fini(struct amdgpu_device *adev);
+int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev);
     #endif
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -29
index 68f9a1fa6dc1..e3bbeab28152 100644
@@ -795,36 +795,6 @@ static bool gmc_v9_0_keep_stolen_memory(struct 
 amdgpu_device *adev)
       }
   }
   -static int gmc_v9_0_allocate_vm_inv_eng(struct amdgpu_device *adev)
-{
-    struct amdgpu_ring *ring;
-    unsigned vm_inv_engs[AMDGPU_MAX_VMHUBS] =
-        {GFXHUB_FREE_VM_INV_ENGS_BITMAP, MMHUB_FREE_VM_INV_ENGS_BITMAP,
-        GFXHUB_FREE_VM_INV_ENGS_BITMAP};
-    unsigned i;
-    unsigned vmhub, inv_eng;
-
-    for (i = 0; i < adev->num_rings; ++i) {
-        ring = adev->rings[i];
-        vmhub = ring->funcs->vmhub;
-
-        inv_eng = ffs(vm_inv_engs[vmhub]);
-        if (!inv_eng) {
-            dev_err(adev->dev, "no VM inv eng for ring %s\n",
-                ring->name);
-            return -EINVAL;
-        }
-
-        ring->vm_inv_eng = inv_eng - 1;
-        vm_inv_engs[vmhub] &= ~(1 << ring->vm_inv_eng);
-
-        dev_info(adev->dev, "ring %s uses VM inv eng %u on hub %u\n",
-             ring->name, ring->vm_inv_eng, ring->funcs->vmhub);
-    }
-
-    return 0;
-}
-
   static int gmc_v9_0_late_init(void *handle)
   {

      struct amdgpu_device *adev = (struct amdgpu_device *)handle;

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
@@ -833,7 +803,7 @@ static int gmc_v9_0_late_init(void *handle)
       if (!gmc_v9_0_keep_stolen_memory(adev))
           amdgpu_bo_late_init(adev);
   -    r = gmc_v9_0_allocate_vm_inv_eng(adev);
+    r = amdgpu_gmc_allocate_vm_inv_eng(adev);
       if (r)
           return r;
       /* Check if ecc is available */
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h +0 -0
index 49e8be761214..e0585e8c6c1b 100644
@@ -24,16 +24,6 @@
   #ifndef __GMC_V9_0_H__
   #define __GMC_V9_0_H__

  -    /*
-     * The latest engine allocation on gfx9 is:
-     * Engine 2, 3: firmware
-     * Engine 0, 1, 4~16: amdgpu ring,
-     *                    subject to change when ring number changes -     * Engine 17: Gart flushes
-     */

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.h +0 -2
-#define GFXHUB_FREE_VM_INV_ENGS_BITMAP        0x1FFF3
-#define MMHUB_FREE_VM_INV_ENGS_BITMAP        0x1FFF3
Quoted 8 lines
Quoted 4 lines

-
  extern const struct amd_ip_funcs gmc_v9_0_ip_funcs; extern const struct amdgpu_ip_block_version gmc_v9_0_ip_block; #endif

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx