Skip to contentSkip to conversation

release exclusive mode after hw init if no kfd

PATCH New Pixel Ding 1 participant 4 messages Nov 1, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Pixel Ding

author
#0 lore raw

Hi Oded,

Please review.

[PATCH 1/2] drm/amdkfd: initialise kgd field inside kfd device_init As you suggested, move kgd assignment to device_init

[PATCH 2/2] drm/amdgpu: release exclusive mode after hw_init if no We still need this change because pdev is passed in.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#2 lore raw

PATCH 1/2 drm/amdkfd: initialise kgd field inside kfd device_init

In reply to a message not in the archive

From: pding <[email protected]>

kgd field is dependent on kgd device_init. Move the assignment to kfd device_init.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c      | 6 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c         | 8 ++++----
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h           | 6 +++---
 drivers/gpu/drm/amd/include/kgd_kfd_interface.h | 4 ++--
 drivers/gpu/drm/radeon/radeon_kfd.c             | 6 +++---
 5 files changed, 15 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +3 -3
index c70cda0..5b10ce9 100644
@@ -89,8 +89,7 @@ void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev)
 		return;
 	}
 
-	adev->kfd = kgd2kfd->probe((struct kgd_dev *)adev,
-				   adev->pdev, kfd2kgd);
+	adev->kfd = kgd2kfd->probe(adev->pdev, kfd2kgd);
 }
 
 void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
@@ -131,7 +130,8 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
 				&gpu_resources.doorbell_aperture_size,
 				&gpu_resources.doorbell_start_offset);
 
-		kgd2kfd->device_init(adev->kfd, &gpu_resources);
+		kgd2kfd->device_init(adev->kfd, (struct kgd_dev *)adev,
+				     &gpu_resources);
 	}
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_device.c +4 -4
index 5df12b2..b95fc61 100644
@@ -109,8 +109,8 @@ static const struct kfd_device_info *lookup_device_info(unsigned short did)
 	return NULL;
 }
 
-struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,
-	struct pci_dev *pdev, const struct kfd2kgd_calls *f2g)
+struct kfd_dev *kgd2kfd_probe(struct pci_dev *pdev,
+			      const struct kfd2kgd_calls *f2g)
 {
 	struct kfd_dev *kfd;
 
@@ -126,7 +126,6 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,
 	if (!kfd)
 		return NULL;
 
-	kfd->kgd = kgd;
 	kfd->device_info = device_info;
 	kfd->pdev = pdev;
 	kfd->init_complete = false;
@@ -217,11 +216,12 @@ static int iommu_invalid_ppr_cb(struct pci_dev *pdev, int pasid,
 	return AMD_IOMMU_INV_PRI_RSP_INVALID;
 }
 
-bool kgd2kfd_device_init(struct kfd_dev *kfd,
+bool kgd2kfd_device_init(struct kfd_dev *kfd, struct kgd_dev *kgd,
 			 const struct kgd2kfd_shared_resources *gpu_resources)
 {
 	unsigned int size;
 
+	kfd->kgd = kgd;
 	kfd->shared_resources = *gpu_resources;
 
 	/* calculate max size of mqds needed for queues */
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +3 -3
index 4cb90f5..cf97e7f 100644
@@ -200,9 +200,9 @@ struct kfd_dev {
 
 /* KGD2KFD callbacks */
 void kgd2kfd_exit(void);
-struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,
-			struct pci_dev *pdev, const struct kfd2kgd_calls *f2g);
-bool kgd2kfd_device_init(struct kfd_dev *kfd,
+struct kfd_dev *kgd2kfd_probe(struct pci_dev *pdev,
+			      const struct kfd2kgd_calls *f2g);
+bool kgd2kfd_device_init(struct kfd_dev *kfd, struct kgd_dev *kgd,
 			const struct kgd2kfd_shared_resources *gpu_resources);
 void kgd2kfd_device_exit(struct kfd_dev *kfd);
 
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +2 -2
index f516fd1..f9ca238 100644
@@ -248,9 +248,9 @@ struct kfd2kgd_calls {
  */
 struct kgd2kfd_calls {
 	void (*exit)(void);
-	struct kfd_dev* (*probe)(struct kgd_dev *kgd, struct pci_dev *pdev,
+	struct kfd_dev* (*probe)(struct pci_dev *pdev,
 		const struct kfd2kgd_calls *f2g);
-	bool (*device_init)(struct kfd_dev *kfd,
+	bool (*device_init)(struct kfd_dev *kfd, struct kgd_dev *kgd,
 			const struct kgd2kfd_shared_resources *gpu_resources);
 	void (*device_exit)(struct kfd_dev *kfd);
 	void (*interrupt)(struct kfd_dev *kfd, const void *ih_ring_entry);
drivers/gpu/drm/radeon/radeon_kfd.c +3 -3
index 385b4d7..083deb1 100644
@@ -181,8 +181,7 @@ void radeon_kfd_fini(void)
 void radeon_kfd_device_probe(struct radeon_device *rdev)
 {
 	if (kgd2kfd)
-		rdev->kfd = kgd2kfd->probe((struct kgd_dev *)rdev,
-			rdev->pdev, &kfd2kgd);
+		rdev->kfd = kgd2kfd->probe(rdev->pdev, &kfd2kgd);
 }
 
 void radeon_kfd_device_init(struct radeon_device *rdev)
@@ -214,7 +213,8 @@ void radeon_kfd_device_init(struct radeon_device *rdev)
 				&gpu_resources.doorbell_aperture_size,
 				&gpu_resources.doorbell_start_offset);
 
-		kgd2kfd->device_init(rdev->kfd, &gpu_resources);
+		kgd2kfd->device_init(rdev->kfd, (struct kgd_dev *)rdev,
+				     &gpu_resources);
 	}
 }
 
Signature · 6 lines
2.9.5

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

PATCH 2/2 drm/amdgpu: release exclusive mode after hw_init if no kfd (v2)

In reply to a message not in the archive

From: pding <[email protected]>

Move kfd probe prior to device init. Release exclusive mode after hw_init if kfd is not enabled.

v2:
- pass pdev param

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 5 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 5 +++--
 4 files changed, 11 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +3 -2
index 5b10ce9..83d18c8 100644
@@ -68,7 +68,8 @@ void amdgpu_amdkfd_fini(void)
 	}
 }
 
-void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev)
+void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev,
+				struct pci_dev *pdev)
 {
 	const struct kfd2kgd_calls *kfd2kgd;
 
@@ -89,7 +90,7 @@ void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev)
 		return;
 	}
 
-	adev->kfd = kgd2kfd->probe(adev->pdev, kfd2kgd);
+	adev->kfd = kgd2kfd->probe(pdev, kfd2kgd);
 }
 
 void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +2 -1
index 8d689ab..707c892 100644
@@ -44,7 +44,8 @@ void amdgpu_amdkfd_suspend(struct amdgpu_device *adev);
 int amdgpu_amdkfd_resume(struct amdgpu_device *adev);
 void amdgpu_amdkfd_interrupt(struct amdgpu_device *adev,
 			const void *ih_ring_entry);
-void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev);
+void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev,
+				struct pci_dev *pdev);
 void amdgpu_amdkfd_device_init(struct amdgpu_device *adev);
 void amdgpu_amdkfd_device_fini(struct amdgpu_device *adev);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 068b56a..ef01aa3 100644
@@ -1716,6 +1716,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
 		adev->ip_blocks[i].status.hw = true;
 	}
 
+	if (amdgpu_sriov_vf(adev) && !adev->kfd)
+		amdgpu_virt_release_full_gpu(adev, true);
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3 -2
index 3e9760d..f872052 100644
@@ -138,6 +138,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
 	    !pci_is_thunderbolt_attached(dev->pdev))
 		flags |= AMD_IS_PX;
 
+	amdgpu_amdkfd_device_probe(adev, dev->pdev);
+
 	/* amdgpu_device_init should report only fatal error
 	 * like memory allocation failure or iomapping failure,
 	 * or memory manager initialization failure, it must
@@ -170,7 +172,6 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
 				"Error during ACPI methods call\n");
 	}
 
-	amdgpu_amdkfd_device_probe(adev);
 	amdgpu_amdkfd_device_init(adev);
 
 	if (amdgpu_device_is_px(dev)) {
@@ -182,7 +183,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
 		pm_runtime_put_autosuspend(dev->dev);
 	}
 
-	if (amdgpu_sriov_vf(adev))
+	if (amdgpu_sriov_vf(adev) && adev->kfd)
 		amdgpu_virt_release_full_gpu(adev, true);
 
 out:
Signature · 6 lines
2.9.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw
In reply to a message not in the archive

Hi Oded,

Please ignore them so far. I need to consider more like that the probe is included in retry init logics. —
Sincerely Yours,
Pixel

Quoted 7 lines · amd-gfx on behalf of Pixel Ding

Hi Oded,

Please review.

[PATCH 1/2] drm/amdkfd: initialise kgd field inside kfd device_init As you suggested, move kgd assignment to device_init

Quoted 6 lines

[PATCH 2/2] drm/amdgpu: release exclusive mode after hw_init if no We still need this change because pdev is passed in.
_______________________________________________
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