All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/29] drm/amdgpu: support partition drm devices
@ 2023-05-10 21:23 Alex Deucher
  2023-05-10 21:23 ` [PATCH 02/29] drm/amdgpu: find partition ID when open device Alex Deucher
                   ` (27 more replies)
  0 siblings, 28 replies; 51+ messages in thread
From: Alex Deucher @ 2023-05-10 21:23 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Philip Yang, James Zhu, Christian König

From: James Zhu <James.Zhu@amd.com>

Support partition drm devices on GC_HWIP IP_VERSION(9, 4, 3).

This is a temporary solution and will be superceded.

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: James Zhu <James.Zhu@amd.com>
Reviewed-and-tested-by: Philip Yang<Philip.Yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 32 ++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h    |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c    | 59 +++++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h    |  5 ++
 6 files changed, 99 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index bed6d1d09ac2..45c6522ee854 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -108,6 +108,7 @@
 #include "amdgpu_fdinfo.h"
 #include "amdgpu_mca.h"
 #include "amdgpu_ras.h"
+#include "amdgpu_xcp.h"
 
 #define MAX_GPU_INSTANCE		64
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index c2136accd523..40c5845c78df 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -6062,6 +6062,7 @@ void amdgpu_device_halt(struct amdgpu_device *adev)
 	struct pci_dev *pdev = adev->pdev;
 	struct drm_device *ddev = adev_to_drm(adev);
 
+	amdgpu_xcp_dev_unplug(adev);
 	drm_dev_unplug(ddev);
 
 	amdgpu_irq_disable_all(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 562e65ab48fa..4589cb2255a2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2194,6 +2194,10 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 		goto err_pci;
 	}
 
+	ret = amdgpu_xcp_dev_register(adev, ent);
+	if (ret)
+		goto err_pci;
+
 	/*
 	 * 1. don't init fbdev on hw without DCE
 	 * 2. don't init fbdev if there are no connectors
@@ -2266,6 +2270,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 	struct drm_device *dev = pci_get_drvdata(pdev);
 	struct amdgpu_device *adev = drm_to_adev(dev);
 
+	amdgpu_xcp_dev_unplug(adev);
 	drm_dev_unplug(dev);
 
 	if (adev->pm.rpm_mode != AMDGPU_RUNPM_NONE) {
@@ -2849,6 +2854,33 @@ static const struct drm_driver amdgpu_kms_driver = {
 	.patchlevel = KMS_DRIVER_PATCHLEVEL,
 };
 
+const struct drm_driver amdgpu_partition_driver = {
+	.driver_features =
+	    DRIVER_GEM | DRIVER_RENDER | DRIVER_SYNCOBJ |
+	    DRIVER_SYNCOBJ_TIMELINE,
+	.open = amdgpu_driver_open_kms,
+	.postclose = amdgpu_driver_postclose_kms,
+	.lastclose = amdgpu_driver_lastclose_kms,
+	.ioctls = amdgpu_ioctls_kms,
+	.num_ioctls = ARRAY_SIZE(amdgpu_ioctls_kms),
+	.dumb_create = amdgpu_mode_dumb_create,
+	.dumb_map_offset = amdgpu_mode_dumb_mmap,
+	.fops = &amdgpu_driver_kms_fops,
+	.release = &amdgpu_driver_release_kms,
+
+	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+	.gem_prime_import = amdgpu_gem_prime_import,
+	.gem_prime_mmap = drm_gem_prime_mmap,
+
+	.name = DRIVER_NAME,
+	.desc = DRIVER_DESC,
+	.date = DRIVER_DATE,
+	.major = KMS_DRIVER_MAJOR,
+	.minor = KMS_DRIVER_MINOR,
+	.patchlevel = KMS_DRIVER_PATCHLEVEL,
+};
+
 static struct pci_error_handlers amdgpu_pci_err_handler = {
 	.error_detected	= amdgpu_pci_error_detected,
 	.mmio_enabled	= amdgpu_pci_mmio_enabled,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h
index 8178323e4bef..5bc2cb661af7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.h
@@ -42,6 +42,8 @@
 #define DRIVER_DESC		"AMD GPU"
 #define DRIVER_DATE		"20150101"
 
+extern const struct drm_driver amdgpu_partition_driver;
+
 long amdgpu_drm_ioctl(struct file *filp,
 		      unsigned int cmd, unsigned long arg);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
index bca226cc4e0b..8b28b18e4291 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
@@ -22,6 +22,9 @@
  */
 #include "amdgpu.h"
 #include "amdgpu_xcp.h"
+#include "amdgpu_drv.h"
+
+#include <drm/drm_drv.h>
 
 static int __amdgpu_xcp_run(struct amdgpu_xcp_mgr *xcp_mgr,
 			    struct amdgpu_xcp_ip *xcp_ip, int xcp_state)
@@ -217,6 +220,31 @@ int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)
 	return mode;
 }
 
+static int amdgpu_xcp_dev_alloc(struct amdgpu_device *adev)
+{
+	struct drm_device *p_ddev;
+	struct pci_dev *pdev;
+	struct drm_device *ddev;
+	int i;
+
+	pdev = adev->pdev;
+	ddev = adev_to_drm(adev);
+
+	for (i = 0; i < MAX_XCP; i++) {
+		p_ddev = drm_dev_alloc(&amdgpu_partition_driver,
+			&pci_upstream_bridge(pdev)->dev);
+		if (IS_ERR(p_ddev))
+			return PTR_ERR(p_ddev);
+
+		/* Redirect all IOCTLs to the primary device */
+		p_ddev->render->dev = ddev;
+		p_ddev->vma_offset_manager = ddev->vma_offset_manager;
+		adev->xcp_mgr->xcp[i].ddev = p_ddev;
+	}
+
+	return 0;
+}
+
 int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode,
 			int init_num_xcps,
 			struct amdgpu_xcp_mgr_funcs *xcp_funcs)
@@ -242,7 +270,7 @@ int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode,
 
 	adev->xcp_mgr = xcp_mgr;
 
-	return 0;
+	return amdgpu_xcp_dev_alloc(adev);
 }
 
 int amdgpu_xcp_get_partition(struct amdgpu_xcp_mgr *xcp_mgr,
@@ -278,3 +306,32 @@ int amdgpu_xcp_get_inst_details(struct amdgpu_xcp *xcp,
 
 	return 0;
 }
+
+int amdgpu_xcp_dev_register(struct amdgpu_device *adev,
+			const struct pci_device_id *ent)
+{
+	int i, ret;
+
+	if (!adev->xcp_mgr)
+		return 0;
+
+	for (i = 0; i < MAX_XCP; i++) {
+		ret = drm_dev_register(adev->xcp_mgr->xcp[i].ddev, ent->driver_data);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+void amdgpu_xcp_dev_unplug(struct amdgpu_device *adev)
+{
+	int i;
+
+	if (!adev->xcp_mgr)
+		return;
+
+	for (i = 0; i < MAX_XCP; i++)
+		drm_dev_unplug(adev->xcp_mgr->xcp[i].ddev);
+}
+
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h
index e1319b887bf3..dad0b98d1ae7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h
@@ -70,6 +70,7 @@ struct amdgpu_xcp {
 	uint8_t id;
 	uint8_t mem_id;
 	bool valid;
+	struct drm_device *ddev;
 };
 
 struct amdgpu_xcp_mgr {
@@ -115,6 +116,10 @@ int amdgpu_xcp_get_inst_details(struct amdgpu_xcp *xcp,
 				enum AMDGPU_XCP_IP_BLOCK ip,
 				uint32_t *inst_mask);
 
+int amdgpu_xcp_dev_register(struct amdgpu_device *adev,
+				const struct pci_device_id *ent);
+void amdgpu_xcp_dev_unplug(struct amdgpu_device *adev);
+
 static inline int amdgpu_xcp_get_num_xcp(struct amdgpu_xcp_mgr *xcp_mgr)
 {
 	if (!xcp_mgr)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2023-08-11 15:54 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-10 21:23 [PATCH 01/29] drm/amdgpu: support partition drm devices Alex Deucher
2023-05-10 21:23 ` [PATCH 02/29] drm/amdgpu: find partition ID when open device Alex Deucher
2023-05-10 21:23 ` [PATCH 03/29] drm/amdgpu: add partition ID track in ring Alex Deucher
2023-05-10 21:23 ` [PATCH 04/29] drm/amdgpu: update header to support partition scheduling Alex Deucher
2023-05-10 21:23 ` [PATCH 05/29] drm/amdgpu: add partition scheduler list update Alex Deucher
2023-05-10 21:23 ` [PATCH 06/29] drm/amdgpu: keep amdgpu_ctx_mgr in ctx structure Alex Deucher
2023-05-19 12:16   ` Mike Lothian
2023-05-19 13:36     ` Alex Deucher
2023-05-10 21:23 ` [PATCH 07/29] drm/amdgpu: add partition schedule for GC(9, 4, 3) Alex Deucher
2023-05-10 21:23 ` [PATCH 08/29] drm/amdgpu: run partition schedule if it is supported Alex Deucher
2023-05-10 21:23 ` [PATCH 09/29] drm/amdgpu: update ref_cnt before ctx free Alex Deucher
2023-05-10 21:23 ` [PATCH 10/29] drm/amdgpu: Add xcp manager num_xcp_per_mem_partition Alex Deucher
2023-05-10 21:23 ` [PATCH 11/29] drm/amdkfd: Store drm node minor number for kfd nodes Alex Deucher
2023-05-10 21:23 ` [PATCH 12/29] drm/amdgpu: Add memory partition id to amdgpu_vm Alex Deucher
2023-05-10 21:23 ` [PATCH 13/29] drm/amdkfd: Show KFD node memory partition info Alex Deucher
2023-05-10 21:23 ` [PATCH 14/29] drm/amdgpu: Add memory partition mem_id to amdgpu_bo Alex Deucher
2023-05-10 21:23 ` [PATCH 15/29] drm/amdkfd: Alloc memory of GPU support memory partition Alex Deucher
2023-05-10 21:23 ` [PATCH 16/29] drm/amdkfd: SVM range allocation " Alex Deucher
2023-05-10 21:23 ` [PATCH 17/29] drm/amdgpu: dGPU mode placement " Alex Deucher
2023-05-10 21:23 ` [PATCH 18/29] drm/amdkfd: Update MTYPE for far " Alex Deucher
2023-05-10 21:23 ` [PATCH 19/29] drm/amdgpu: Alloc page table on correct " Alex Deucher
2023-05-10 21:23 ` [PATCH 20/29] drm/amdgpu: dGPU mode set VRAM range lpfn as exclusive Alex Deucher
2023-05-10 21:23 ` [PATCH 21/29] drm/amdkfd: Store xcp partition id to amdgpu bo Alex Deucher
2023-05-10 21:23 ` [PATCH 22/29] drm/amdgpu: KFD graphics interop support compute partition Alex Deucher
2023-05-10 21:23 ` [PATCH 23/29] drm/amdgpu: use xcp partition ID for amdgpu_gem Alex Deucher
2023-05-10 21:23 ` [PATCH 24/29] drm/amdkfd: Move local_mem_info to kfd_node Alex Deucher
2023-05-10 21:23 ` [PATCH 25/29] drm/amdkfd: Fix memory reporting on GFX 9.4.3 Alex Deucher
2023-05-10 21:23 ` [PATCH 26/29] drm/amdkfd: APU mode set max svm range pages Alex Deucher
2023-05-10 21:23 ` [PATCH 27/29] drm/amdgpu: route ioctls on primary node of XCPs to primary device Alex Deucher
2023-05-10 21:23 ` [PATCH 28/29] drm/amdkfd: Refactor migrate init to support partition switch Alex Deucher
2023-07-17 13:09   ` Michel Dänzer
2023-07-19 16:17     ` Linux regression tracking #adding (Thorsten Leemhuis)
2023-08-11  9:02       ` Linux regression tracking #update (Thorsten Leemhuis)
2023-08-11 15:54         ` Michel Dänzer
2023-07-20 10:46     ` Michel Dänzer
2023-07-20 20:48       ` Philip Yang
2023-07-21  8:55         ` Michel Dänzer
2023-07-21 10:09           ` Michel Dänzer
2023-07-21 13:30           ` Philip Yang
2023-07-24 20:04             ` Philip Yang
2023-07-25  8:09               ` Michel Dänzer
2023-07-27  6:10               ` Zhang, Jesse(Jie)
2023-07-28  1:38                 ` Zhang, Jesse(Jie)
2023-07-28  9:30                   ` Michel Dänzer
2023-07-28 14:25                     ` Michel Dänzer
2023-07-28 16:43                       ` Alex Deucher
2023-07-28 17:18                         ` Michel Dänzer
2023-07-28 17:20                           ` Alex Deucher
2023-08-07 16:04                             ` Michel Dänzer
2023-08-07 22:08                               ` Alex Deucher
2023-05-10 21:23 ` [PATCH 29/29] drm/amdgpu: Correct get_xcp_mem_id calculation Alex Deucher

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.