Skip to contentSkip to conversation

PSP cleanup

PATCH In review Evan Quan 3 participants 14 messages Jan 2, 2019 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Evan Quan

author
#0 lore raw

cover PSP cleanup

*** BLURB HERE ***

Evan Quan (9):
drm/amdgpu: separate the PSP ring related APIs drm/amdgpu: separate commonly used PSP APIs
drm/amdgpu: separate the xgmi related APIs
drm/amdgpu: separate the tmr related APIs
drm/amdgpu: separate the asd related APIs
drm/amdgpu: drop useless PSP APIs and structures drm/amdgpu: check PSP support before adding the ip block drm/amdgpu: make PSP sub modules(ASD/XGMI/TMR) support configurable drm/amdgpu: move psp_funcs related to a more proper place

 drivers/gpu/drm/amd/amdgpu/Makefile     |   7 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 504 +++-------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  93 +---
 drivers/gpu/drm/amd/amdgpu/psp_asd.c    |  86 ++++
 drivers/gpu/drm/amd/amdgpu/psp_asd.h    |  32 ++
 drivers/gpu/drm/amd/amdgpu/psp_cmn.c    | 289 +++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_cmn.h    |  84 ++++
 drivers/gpu/drm/amd/amdgpu/psp_funcs.h  |  98 +++++
 drivers/gpu/drm/amd/amdgpu/psp_ring.c   | 354 ++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_ring.h   |  43 ++
 drivers/gpu/drm/amd/amdgpu/psp_tmr.c    |  84 ++++
 drivers/gpu/drm/amd/amdgpu/psp_tmr.h    |  32 ++
 drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 381 +----------------
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 539 +-----------------------
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 480 +--------------------
 drivers/gpu/drm/amd/amdgpu/psp_xgmi.c   | 207 +++++++++
 drivers/gpu/drm/amd/amdgpu/psp_xgmi.h   |  33 ++
 drivers/gpu/drm/amd/amdgpu/soc15.c      |  13 +-
 18 files changed, 1493 insertions(+), 1866 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.h
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.h
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_funcs.h
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.h
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.h
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.h
Signature · 6 lines
2.20.1

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#2 lore raw

PATCH 1/9 drm/amdgpu: separate the PSP ring related APIs

So that they can be shared among different PSP generations. And there is no need to have one copy for each PSP generation.

Change-Id I7a97f410ef5993b25f0ec3cfac4a293073d697c3
---
 drivers/gpu/drm/amd/amdgpu/Makefile     |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c |  71 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  16 +-
 drivers/gpu/drm/amd/amdgpu/psp_ring.c   | 353 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_ring.h   |  43 +++
 drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 247 +----------------
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 278 +------------------
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 231 +---------------
 8 files changed, 444 insertions(+), 798 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.h
drivers/gpu/drm/amd/amdgpu/Makefile +2 -1
index 007478905c7b..bdcf0d4338f8 100644
@@ -90,7 +90,8 @@ amdgpu-y += \
 	amdgpu_psp.o \
 	psp_v3_1.o \
 	psp_v10_0.o \
-	psp_v11_0.o
+	psp_v11_0.o \
+	psp_ring.o
 
 # add SMC block
 amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +21 -50

119 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +3 -13
index 3ee573b4016e..c94fa444f8b7 100644
@@ -74,10 +74,9 @@ struct psp_funcs
 			    enum psp_ring_type ring_type);
 	int (*ring_destroy)(struct psp_context *psp,
 			    enum psp_ring_type ring_type);
-	int (*cmd_submit)(struct psp_context *psp,
-			  struct amdgpu_firmware_info *ucode,
-			  uint64_t cmd_buf_mc_addr, uint64_t fence_mc_addr,
-			  int index);
+	int (*submit_cmd_buf)(struct psp_context *psp,
+	                   struct amdgpu_firmware_info *ucode,
+	                   struct psp_gfx_cmd_resp *cmd, uint64_t fence_mc_addr);
 	bool (*compare_sram_data)(struct psp_context *psp,
 				  struct amdgpu_firmware_info *ucode,
 				  enum AMDGPU_UCODE_ID ucode_type);
@@ -176,13 +175,6 @@ struct psp_xgmi_topology_info {
 	struct psp_xgmi_node_info	nodes[AMDGPU_XGMI_MAX_CONNECTED_NODES];
 };
 
-#define psp_prep_cmd_buf(ucode, type) (psp)->funcs->prep_cmd_buf((ucode), (type))
-#define psp_ring_init(psp, type) (psp)->funcs->ring_init((psp), (type))
-#define psp_ring_create(psp, type) (psp)->funcs->ring_create((psp), (type))
-#define psp_ring_stop(psp, type) (psp)->funcs->ring_stop((psp), (type))
-#define psp_ring_destroy(psp, type) ((psp)->funcs->ring_destroy((psp), (type)))
-#define psp_cmd_submit(psp, ucode, cmd_mc, fence_mc, index) \
-		(psp)->funcs->cmd_submit((psp), (ucode), (cmd_mc), (fence_mc), (index))
 #define psp_compare_sram_data(psp, ucode, type) \
 		(psp)->funcs->compare_sram_data((psp), (ucode), (type))
 #define psp_init_microcode(psp) \
@@ -193,8 +185,6 @@ struct psp_xgmi_topology_info {
 		((psp)->funcs->bootloader_load_sos ? (psp)->funcs->bootloader_load_sos((psp)) : 0)
 #define psp_smu_reload_quirk(psp) \
 		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
-#define psp_support_vmr_ring(psp) \
-		((psp)->funcs->support_vmr_ring ? (psp)->funcs->support_vmr_ring((psp)) : false)
 #define psp_mode1_reset(psp) \
 		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
 #define psp_xgmi_get_node_id(psp, node_id) \
drivers/gpu/drm/amd/amdgpu/psp_ring.c new file +353 -0

353 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_ring.h new file +43 -0

43 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_v10_0.c +7 -240

270 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +8 -270

308 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +7 -224

255 lines not on this page · raw message

Signature · 6 lines
2.20.1

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

PATCH 2/9 drm/amdgpu: separate commonly used PSP APIs

In reply to a message not in the archive

So that they can be shared in PSP widely.

Change-Id Icec5d23db2c1f8241f6bdff371e6cde65ffdb101
---
 drivers/gpu/drm/amd/amdgpu/Makefile     |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c |  36 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  16 --
 drivers/gpu/drm/amd/amdgpu/psp_cmn.c    | 289 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_cmn.h    |  41 ++++
 drivers/gpu/drm/amd/amdgpu/psp_ring.c   |   9 +-
 drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 126 +----------
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 250 +-------------------
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 243 +-------------------
 9 files changed, 366 insertions(+), 647 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.h
drivers/gpu/drm/amd/amdgpu/Makefile +2 -1
index bdcf0d4338f8..fe27d6038da9 100644
@@ -91,7 +91,8 @@ amdgpu-y += \
 	psp_v3_1.o \
 	psp_v10_0.o \
 	psp_v11_0.o \
-	psp_ring.o
+	psp_ring.o \
+	psp_cmn.o
 
 # add SMC block
 amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +14 -22
index 38398f0c10c9..d1ccc6ea7607 100644
@@ -47,6 +47,20 @@
 		(psp)->funcs->submit_cmd_buf((psp), (ucode), (cmd), (fence_mc))
 #define psp_support_vmr_ring(psp) \
 		((psp)->funcs->support_vmr_ring ? (psp)->funcs->support_vmr_ring((psp)) : false)
+#define psp_compare_sram_data(psp, ucode, type) \
+		(psp)->funcs->compare_sram_data((psp), (ucode), (type))
+#define psp_init_microcode(psp) \
+		((psp)->funcs->init_microcode ? (psp)->funcs->init_microcode((psp)) : 0)
+#define psp_bootloader_load_sysdrv(psp) \
+		((psp)->funcs->bootloader_load_sysdrv ? (psp)->funcs->bootloader_load_sysdrv((psp)) : 0)
+#define psp_bootloader_load_sos(psp) \
+		((psp)->funcs->bootloader_load_sos ? (psp)->funcs->bootloader_load_sos((psp)) : 0)
+#define psp_smu_reload_quirk(psp) \
+		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
+#define psp_mode1_reset(psp) \
+		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
+#define amdgpu_psp_check_fw_loading_status(adev, i) \
+		(adev)->firmware.funcs->check_fw_loading_status((adev), (i))
 
 static void psp_set_funcs(struct amdgpu_device *adev);
 
@@ -110,28 +124,6 @@ static int psp_sw_fini(void *handle)
 	return 0;
 }
 
-int psp_wait_for(struct psp_context *psp, uint32_t reg_index,
-		 uint32_t reg_val, uint32_t mask, bool check_changed)
-{
-	uint32_t val;
-	int i;
-	struct amdgpu_device *adev = psp->adev;
-
-	for (i = 0; i < adev->usec_timeout; i++) {
-		val = RREG32(reg_index);
-		if (check_changed) {
-			if (val != reg_val)
-				return 0;
-		} else {
-			if ((val & mask) == reg_val)
-				return 0;
-		}
-		udelay(1);
-	}
-
-	return -ETIME;
-}
-
 static void psp_prep_tmr_cmd_buf(struct psp_context *psp,
 				 struct psp_gfx_cmd_resp *cmd,
 				 uint64_t tmr_mc, uint32_t size)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -16
index c94fa444f8b7..f4438a5077b6 100644
@@ -175,18 +175,6 @@ struct psp_xgmi_topology_info {
 	struct psp_xgmi_node_info	nodes[AMDGPU_XGMI_MAX_CONNECTED_NODES];
 };
 
-#define psp_compare_sram_data(psp, ucode, type) \
-		(psp)->funcs->compare_sram_data((psp), (ucode), (type))
-#define psp_init_microcode(psp) \
-		((psp)->funcs->init_microcode ? (psp)->funcs->init_microcode((psp)) : 0)
-#define psp_bootloader_load_sysdrv(psp) \
-		((psp)->funcs->bootloader_load_sysdrv ? (psp)->funcs->bootloader_load_sysdrv((psp)) : 0)
-#define psp_bootloader_load_sos(psp) \
-		((psp)->funcs->bootloader_load_sos ? (psp)->funcs->bootloader_load_sos((psp)) : 0)
-#define psp_smu_reload_quirk(psp) \
-		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
-#define psp_mode1_reset(psp) \
-		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
 #define psp_xgmi_get_node_id(psp, node_id) \
 		((psp)->funcs->xgmi_get_node_id ? (psp)->funcs->xgmi_get_node_id((psp), (node_id)) : -EINVAL)
 #define psp_xgmi_get_hive_id(psp, hive_id) \
@@ -198,13 +186,9 @@ struct psp_xgmi_topology_info {
 		((psp)->funcs->xgmi_set_topology_info ?	 \
 		(psp)->funcs->xgmi_set_topology_info((psp), (num_device), (topology)) : -EINVAL)
 
-#define amdgpu_psp_check_fw_loading_status(adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i))
-
 extern const struct amd_ip_funcs psp_ip_funcs;
 
 extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
-extern int psp_wait_for(struct psp_context *psp, uint32_t reg_index,
-			uint32_t field_val, uint32_t mask, bool check_changed);
 
 extern const struct amdgpu_ip_block_version psp_v10_0_ip_block;
 
drivers/gpu/drm/amd/amdgpu/psp_cmn.c new file +289 -0

289 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_cmn.h new file +41 -0

41 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_ring.c +5 -4
index c2f1ade51758..fa59e57fb11e 100644
@@ -24,6 +24,7 @@
 #include "soc15_common.h"
 #include "mp/mp_11_0_offset.h"
 #include "mp/mp_11_0_sh_mask.h"
+#include "psp_cmn.h"
 
 int psp_ring_init_ring(struct psp_context *psp,
 			      enum psp_ring_type ring_type)
@@ -87,7 +88,7 @@ int psp_ring_create_ring(struct psp_context *psp,
 		mdelay(20);
 
 		/* Wait for response flag (bit 31) in C2PMSG_101 */
-		ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_101),
+		ret = psp_cmn_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_101),
 				   0x80000000, 0x8000FFFF, false);
 
 	} else {
@@ -109,7 +110,7 @@ int psp_ring_create_ring(struct psp_context *psp,
 		mdelay(20);
 
 		/* Wait for response flag (bit 31) in C2PMSG_64 */
-		ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64),
+		ret = psp_cmn_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64),
 				   0x80000000, 0x8000FFFF, false);
 	}
 
@@ -135,10 +136,10 @@ int psp_ring_stop_ring(struct psp_context *psp,
 
 	/* Wait for response flag (bit 31) */
 	if (psp_ring_support_vmr(psp))
-		ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_101),
+		ret = psp_cmn_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_101),
 				   0x80000000, 0x80000000, false);
 	else
-		ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64),
+		ret = psp_cmn_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64),
 				   0x80000000, 0x80000000, false);
 
 	return ret;
drivers/gpu/drm/amd/amdgpu/psp_v10_0.c +2 -124

144 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +5 -245

274 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +8 -235

287 lines not on this page · raw message

Signature · 6 lines
2.20.1

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

PATCH 3/9 drm/amdgpu: separate the xgmi related APIs

In reply to a message not in the archive

As they are logic independently from other APIs of amdgpu_psp.c.

Change-Id Idb9d81e15ad4d37e93b95682a07194a94c4849d6
---
 drivers/gpu/drm/amd/amdgpu/Makefile     |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 182 +--------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |   1 -
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  |   1 +
 drivers/gpu/drm/amd/amdgpu/psp_xgmi.c   | 207 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_xgmi.h   |  33 ++++
 6 files changed, 244 insertions(+), 183 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.h
drivers/gpu/drm/amd/amdgpu/Makefile +2 -1
index fe27d6038da9..30a705db0ef5 100644
@@ -92,7 +92,8 @@ amdgpu-y += \
 	psp_v10_0.o \
 	psp_v11_0.o \
 	psp_ring.o \
-	psp_cmn.o
+	psp_cmn.o \
+	psp_xgmi.o
 
 # add SMC block
 amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -181

194 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -1
index f4438a5077b6..d65691b988fa 100644
@@ -193,7 +193,6 @@ extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
 extern const struct amdgpu_ip_block_version psp_v10_0_ip_block;
 
 int psp_gpu_reset(struct amdgpu_device *adev);
-int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
 extern const struct amdgpu_ip_block_version psp_v11_0_ip_block;
 
 #endif
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +1 -0
index 1dc62ec4e64b..b5c6057dd6ed 100644
@@ -34,6 +34,7 @@
 #include "nbio/nbio_7_4_offset.h"
 #include "psp_ring.h"
 #include "psp_cmn.h"
+#include "psp_xgmi.h"
 
 MODULE_FIRMWARE("amdgpu/vega20_sos.bin");
 MODULE_FIRMWARE("amdgpu/vega20_asd.bin");
drivers/gpu/drm/amd/amdgpu/psp_xgmi.c new file +207 -0

207 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_xgmi.h new file +33 -0
new file mode 100644
index 000000000000..fb56cbf22c66
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2018 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __PSP_XGMI_H
+#define __PSP_XGMI_H
+
+#include "amdgpu_psp.h"
+
+int psp_xgmi_initialize(struct psp_context *psp);
+int psp_xgmi_terminate(struct psp_context *psp);
+int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
+
+#endif
Signature · 6 lines
2.20.1

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

PATCH 4/9 drm/amdgpu: separate the tmr related APIs

In reply to a message not in the archive

As they are logic independently from other APIs of amdgpu_psp.c.

Change-Id I3c8014caca8250bef6439e857bea1b64b6c1930a
---
 drivers/gpu/drm/amd/amdgpu/Makefile     |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 60 +-----------------
 drivers/gpu/drm/amd/amdgpu/psp_tmr.c    | 84 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_tmr.h    | 32 ++++++++++
 4 files changed, 119 insertions(+), 60 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.h
drivers/gpu/drm/amd/amdgpu/Makefile +2 -1
index 30a705db0ef5..99895c6fcd95 100644
@@ -93,7 +93,8 @@ amdgpu-y += \
 	psp_v11_0.o \
 	psp_ring.o \
 	psp_cmn.o \
-	psp_xgmi.o
+	psp_xgmi.o \
+	psp_tmr.o
 
 # add SMC block
 amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -59

72 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_tmr.c new file +84 -0

84 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_tmr.h new file +32 -0
new file mode 100644
index 000000000000..35328dd122c6
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2018 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __PSP_TMR_H
+#define __PSP_TMR_H
+
+#include "amdgpu_psp.h"
+
+int psp_tmr_init(struct psp_context *psp);
+int psp_tmr_load(struct psp_context *psp);
+
+#endif
Signature · 6 lines
2.20.1

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

PATCH 5/9 drm/amdgpu: separate the asd related APIs

In reply to a message not in the archive

As they are logic independently from other APIs of amdgpu_psp.c.

Change-Id If10aa695214f8df0744a67ee9eb0524d2c5a1ec1
---
 drivers/gpu/drm/amd/amdgpu/Makefile     |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 62 +-----------------
 drivers/gpu/drm/amd/amdgpu/psp_asd.c    | 86 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_asd.h    | 32 +++++++++
 4 files changed, 121 insertions(+), 62 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.h
drivers/gpu/drm/amd/amdgpu/Makefile +2 -1
index 99895c6fcd95..ebef9d2cdd61 100644
@@ -94,7 +94,8 @@ amdgpu-y += \
 	psp_ring.o \
 	psp_cmn.o \
 	psp_xgmi.o \
-	psp_tmr.o
+	psp_tmr.o \
+	psp_asd.o
 
 # add SMC block
 amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -61

74 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_asd.c new file +86 -0

86 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_asd.h new file +32 -0
new file mode 100644
index 000000000000..8858488f4beb
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2018 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __PSP_ASD_H
+#define __PSP_ASD_H
+
+#include "amdgpu_psp.h"
+
+int psp_asd_init(struct psp_context *psp);
+int psp_asd_load(struct psp_context *psp);
+
+#endif
Signature · 6 lines
2.20.1

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

PATCH 6/9 drm/amdgpu: drop useless PSP APIs and structures

In reply to a message not in the archive

Drop those useless APIs and structures.

Change-Id I1350c0e7ec0b990a1178a0ce92f61e56dc8851b5
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 66 +++++++++----------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  5 --
 2 files changed, 22 insertions(+), 49 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +22 -44
index 2528fbcad275..f1ffe04b8c0f 100644
@@ -62,19 +62,6 @@
 		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
 #define psp_mode1_reset(psp) \
 		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
-#define amdgpu_psp_check_fw_loading_status(adev, i) \
-		(adev)->firmware.funcs->check_fw_loading_status((adev), (i))
-
-static void psp_set_funcs(struct amdgpu_device *adev);
-
-static int psp_early_init(void *handle)
-{
-	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
-	psp_set_funcs(adev);
-
-	return 0;
-}
 
 static int psp_sw_init(void *handle)
 {
@@ -166,6 +153,26 @@ static int psp_hw_start(struct psp_context *psp)
 	return 0;
 }
 
+static bool psp_check_fw_loading_status(struct amdgpu_device *adev,
+					enum AMDGPU_UCODE_ID ucode_type)
+{
+	struct amdgpu_firmware_info *ucode = NULL;
+
+	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
+		DRM_INFO("firmware is not loaded by PSP\n");
+		return true;
+	}
+
+	if (!adev->firmware.fw_size)
+		return false;
+
+	ucode = &adev->firmware.ucode[ucode_type];
+	if (!ucode->fw || !ucode->ucode_size)
+		return false;
+
+	return psp_compare_sram_data(&adev->psp, ucode, ucode_type);
+}
+
 static int psp_np_fw_load(struct psp_context *psp)
 {
 	int i, ret;
@@ -198,7 +205,7 @@ static int psp_np_fw_load(struct psp_context *psp)
 
 #if 0
 		/* check if firmware loaded sucessfully */
-		if (!amdgpu_psp_check_fw_loading_status(adev, i))
+		if (!psp_check_fw_loading_status(adev, i))
 			return -EINVAL;
 #endif
 	}
@@ -413,25 +420,6 @@ int psp_gpu_reset(struct amdgpu_device *adev)
 	return psp_mode1_reset(&adev->psp);
 }
 
-static bool psp_check_fw_loading_status(struct amdgpu_device *adev,
-					enum AMDGPU_UCODE_ID ucode_type)
-{
-	struct amdgpu_firmware_info *ucode = NULL;
-
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
-		DRM_INFO("firmware is not loaded by PSP\n");
-		return true;
-	}
-
-	if (!adev->firmware.fw_size)
-		return false;
-
-	ucode = &adev->firmware.ucode[ucode_type];
-	if (!ucode->fw || !ucode->ucode_size)
-		return false;
-
-	return psp_compare_sram_data(&adev->psp, ucode, ucode_type);
-}
 
 static int psp_set_clockgating_state(void *handle,
 				     enum amd_clockgating_state state)
@@ -447,7 +435,7 @@ static int psp_set_powergating_state(void *handle,
 
 const struct amd_ip_funcs psp_ip_funcs = {
 	.name = "psp",
-	.early_init = psp_early_init,
+	.early_init = NULL,
 	.late_init = NULL,
 	.sw_init = psp_sw_init,
 	.sw_fini = psp_sw_fini,
@@ -463,16 +451,6 @@ const struct amd_ip_funcs psp_ip_funcs = {
 	.set_powergating_state = psp_set_powergating_state,
 };
 
-static const struct amdgpu_psp_funcs psp_funcs = {
-	.check_fw_loading_status = psp_check_fw_loading_status,
-};
-
-static void psp_set_funcs(struct amdgpu_device *adev)
-{
-	if (NULL == adev->firmware.funcs)
-		adev->firmware.funcs = &psp_funcs;
-}
-
 const struct amdgpu_ip_block_version psp_v3_1_ip_block =
 {
 	.type = AMD_IP_BLOCK_TYPE_PSP,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -5
index d65691b988fa..16900d4c8034 100644
@@ -157,11 +157,6 @@ struct psp_context
 	struct psp_xgmi_context		xgmi_context;
 };
 
-struct amdgpu_psp_funcs {
-	bool (*check_fw_loading_status)(struct amdgpu_device *adev,
-					enum AMDGPU_UCODE_ID);
-};
-
 #define AMDGPU_XGMI_MAX_CONNECTED_NODES		64
 struct psp_xgmi_node_info {
 	uint64_t				node_id;
Signature · 6 lines
2.20.1

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

PATCH 7/9 drm/amdgpu: check PSP support before adding the ip block

In reply to a message not in the archive

So that we do not need to check this in every internal function.

Change-Id I5f2665cf60a57b6ae8d04a645f633daf377ae28c
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 24 ------------------------
 drivers/gpu/drm/amd/amdgpu/soc15.c      | 13 ++++++++-----
 2 files changed, 8 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -24
index f1ffe04b8c0f..bf51686bdd0f 100644
@@ -86,9 +86,6 @@ static int psp_sw_init(void *handle)
 
 	psp->adev = adev;
 
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
-		return 0;
-
 	ret = psp_init_microcode(psp);
 	if (ret) {
 		DRM_ERROR("Failed to load psp firmware!\n");
@@ -102,9 +99,6 @@ static int psp_sw_fini(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
-		return 0;
-
 	release_firmware(adev->psp.sos_fw);
 	adev->psp.sos_fw = NULL;
 	release_firmware(adev->psp.asd_fw);
@@ -158,11 +152,6 @@ static bool psp_check_fw_loading_status(struct amdgpu_device *adev,
 {
 	struct amdgpu_firmware_info *ucode = NULL;
 
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
-		DRM_INFO("firmware is not loaded by PSP\n");
-		return true;
-	}
-
 	if (!adev->firmware.fw_size)
 		return false;
 
@@ -296,10 +285,6 @@ static int psp_hw_init(void *handle)
 	int ret;
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
-		return 0;
-
 	mutex_lock(&adev->firmware.mutex);
 	/*
 	 * This sequence is just used on hw_init only once, no need on
@@ -329,9 +314,6 @@ static int psp_hw_fini(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	struct psp_context *psp = &adev->psp;
 
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
-		return 0;
-
 	if (adev->gmc.xgmi.num_physical_nodes > 1 &&
 	    psp->xgmi_context.initialized == 1)
                 psp_xgmi_terminate(psp);
@@ -360,9 +342,6 @@ static int psp_suspend(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	struct psp_context *psp = &adev->psp;
 
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
-		return 0;
-
 	if (adev->gmc.xgmi.num_physical_nodes > 1 &&
 	    psp->xgmi_context.initialized == 1) {
 		ret = psp_xgmi_terminate(psp);
@@ -387,9 +366,6 @@ static int psp_resume(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	struct psp_context *psp = &adev->psp;
 
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
-		return 0;
-
 	DRM_INFO("PSP is resuming...\n");
 
 	mutex_lock(&adev->firmware.mutex);
drivers/gpu/drm/amd/amdgpu/soc15.c +8 -5
index d5b3f821b8f0..9f162a8a7d9b 100644
@@ -535,10 +535,12 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
 		amdgpu_device_ip_block_add(adev, &vega10_common_ip_block);
 		amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block);
-		if (adev->asic_type == CHIP_VEGA20)
-			amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);
-		else
-			amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block);
+		if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
+			if (adev->asic_type == CHIP_VEGA20)
+				amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);
+			else
+				amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block);
+		}
 		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
 		if (!amdgpu_sriov_vf(adev))
@@ -560,7 +562,8 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)
 		amdgpu_device_ip_block_add(adev, &vega10_common_ip_block);
 		amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block);
-		amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block);
+		if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP))
+			amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
 		amdgpu_device_ip_block_add(adev, &pp_smu_ip_block);
Signature · 6 lines
2.20.1

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

PATCH 8/9 drm/amdgpu: make PSP sub modules(ASD/XGMI/TMR) support configurable

In reply to a message not in the archive

As not every generation can support all these PSP sub modules.

Change-Id I866884e6453a37ff844427eb2d6fd56a91058ebe
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 41 +++++++++++++++++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 14 ++++++++-
 drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  |  6 ++++
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  |  8 +++++
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   |  6 ++++
 5 files changed, 64 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +31 -10
index bf51686bdd0f..ecfbf618652a 100644
@@ -32,9 +32,6 @@
 #include "psp_v3_1.h"
 #include "psp_v10_0.h"
 #include "psp_v11_0.h"
-#include "psp_xgmi.h"
-#include "psp_tmr.h"
-#include "psp_asd.h"
 
 #define psp_ring_init(psp, type) \
 		(psp)->funcs->ring_init((psp), (type))
@@ -50,6 +47,30 @@
 		(psp)->funcs->submit_cmd_buf((psp), (ucode), (cmd), (fence_mc))
 #define psp_support_vmr_ring(psp) \
 		((psp)->funcs->support_vmr_ring ? (psp)->funcs->support_vmr_ring((psp)) : false)
+#define psp_init_asd(psp) \
+		((psp)->funcs->asd_init ? (psp)->funcs->asd_init((psp)) : 0)
+#define psp_load_asd(psp) \
+		((psp)->funcs->asd_load ? (psp)->funcs->asd_load((psp)) : 0)
+#define psp_unload_asd(psp) \
+		((psp)->funcs->asd_unload ? (psp)->funcs->asd_unload((psp)) : 0)
+#define psp_destory_asd(psp) \
+		((psp)->funcs->asd_destory ? (psp)->funcs->asd_destory((psp)) : 0)
+#define psp_init_tmr(psp) \
+		((psp)->funcs->tmr_init ? (psp)->funcs->tmr_init((psp)) : 0)
+#define psp_load_tmr(psp) \
+		((psp)->funcs->tmr_load ? (psp)->funcs->tmr_load((psp)) : 0)
+#define psp_unload_tmr(psp) \
+		((psp)->funcs->tmr_unload ? (psp)->funcs->tmr_unload((psp)) : 0)
+#define psp_destory_tmr(psp) \
+		((psp)->funcs->tmr_destory ? (psp)->funcs->tmr_destory((psp)) : 0)
+#define psp_init_xgmi(psp) \
+		((psp)->funcs->xgmi_init ? (psp)->funcs->xgmi_init((psp)) : 0)
+#define psp_load_xgmi(psp) \
+		((psp)->funcs->xgmi_load ? (psp)->funcs->xgmi_load((psp)) : 0)
+#define psp_unload_xgmi(psp) \
+		((psp)->funcs->xgmi_unload ? (psp)->funcs->xgmi_unload((psp)) : 0)
+#define psp_destory_xgmi(psp) \
+		((psp)->funcs->xgmi_destory ? (psp)->funcs->xgmi_destory((psp)) : 0)
 #define psp_compare_sram_data(psp, ucode, type) \
 		(psp)->funcs->compare_sram_data((psp), (ucode), (type))
 #define psp_init_microcode(psp) \
@@ -127,16 +148,16 @@ static int psp_hw_start(struct psp_context *psp)
 	if (ret)
 		return ret;
 
-	ret = psp_tmr_load(psp);
+	ret = psp_load_tmr(psp);
 	if (ret)
 		return ret;
 
-	ret = psp_asd_load(psp);
+	ret = psp_load_asd(psp);
 	if (ret)
 		return ret;
 
 	if (adev->gmc.xgmi.num_physical_nodes > 1) {
-		ret = psp_xgmi_initialize(psp);
+		ret = psp_init_xgmi(psp);
 		/* Warning the XGMI seesion initialize failure
 		 * Instead of stop driver initialization
 		 */
@@ -245,11 +266,11 @@ static int psp_load_fw(struct amdgpu_device *adev)
 	if (ret)
 		goto failed_mem;
 
-	ret = psp_tmr_init(psp);
+	ret = psp_init_tmr(psp);
 	if (ret)
 		goto failed_mem;
 
-	ret = psp_asd_init(psp);
+	ret = psp_init_asd(psp);
 	if (ret)
 		goto failed_mem;
 
@@ -316,7 +337,7 @@ static int psp_hw_fini(void *handle)
 
 	if (adev->gmc.xgmi.num_physical_nodes > 1 &&
 	    psp->xgmi_context.initialized == 1)
-                psp_xgmi_terminate(psp);
+                psp_destory_xgmi(psp);
 
 	psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
@@ -344,7 +365,7 @@ static int psp_suspend(void *handle)
 
 	if (adev->gmc.xgmi.num_physical_nodes > 1 &&
 	    psp->xgmi_context.initialized == 1) {
-		ret = psp_xgmi_terminate(psp);
+		ret = psp_destory_xgmi(psp);
 		if (ret) {
 			DRM_ERROR("Failed to terminate xgmi ta\n");
 			return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +13 -1
index 16900d4c8034..4cc7fd3224f4 100644
@@ -77,6 +77,19 @@ struct psp_funcs
 	int (*submit_cmd_buf)(struct psp_context *psp,
 	                   struct amdgpu_firmware_info *ucode,
 	                   struct psp_gfx_cmd_resp *cmd, uint64_t fence_mc_addr);
+	bool (*support_vmr_ring)(struct psp_context *psp);
+	int (*asd_init)(struct psp_context *psp);
+	int (*asd_load)(struct psp_context *psp);
+	int (*asd_unload)(struct psp_context *psp);
+	int (*asd_destory)(struct psp_context *psp);
+	int (*tmr_init)(struct psp_context *psp);
+	int (*tmr_load)(struct psp_context *psp);
+	int (*tmr_unload)(struct psp_context *psp);
+	int (*tmr_destory)(struct psp_context *psp);
+	int (*xgmi_init)(struct psp_context *psp);
+	int (*xgmi_load)(struct psp_context *psp);
+	int (*xgmi_unload)(struct psp_context *psp);
+	int (*xgmi_destory)(struct psp_context *psp);
 	bool (*compare_sram_data)(struct psp_context *psp,
 				  struct amdgpu_firmware_info *ucode,
 				  enum AMDGPU_UCODE_ID ucode_type);
@@ -88,7 +101,6 @@ struct psp_funcs
 				      struct psp_xgmi_topology_info *topology);
 	int (*xgmi_set_topology_info)(struct psp_context *psp, int number_devices,
 				      struct psp_xgmi_topology_info *topology);
-	bool (*support_vmr_ring)(struct psp_context *psp);
 };
 
 struct psp_xgmi_context {
drivers/gpu/drm/amd/amdgpu/psp_v10_0.c +6 -0
index 87d9560a52ce..a469ff952045 100644
@@ -35,6 +35,8 @@
 #include "sdma0/sdma0_4_1_offset.h"
 #include "psp_ring.h"
 #include "psp_cmn.h"
+#include "psp_asd.h"
+#include "psp_tmr.h"
 
 MODULE_FIRMWARE("amdgpu/raven_asd.bin");
 MODULE_FIRMWARE("amdgpu/picasso_asd.bin");
@@ -105,6 +107,10 @@ static const struct psp_funcs psp_v10_0_funcs = {
 	.ring_destroy = psp_ring_destroy_ring,
 	.prep_cmd_buf = psp_ring_prep_cmd_buf,
 	.submit_cmd_buf = psp_ring_submit_cmd_buf,
+	.asd_init = psp_asd_init,
+	.asd_load = psp_asd_load,
+	.tmr_init = psp_tmr_init,
+	.tmr_load = psp_tmr_load,
 	.compare_sram_data = psp_cmn_compare_sram_data,
 	.mode1_reset = psp_v10_0_mode1_reset,
 };
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +8 -0
index b5c6057dd6ed..68ce4ccceec7 100644
@@ -35,6 +35,8 @@
 #include "psp_ring.h"
 #include "psp_cmn.h"
 #include "psp_xgmi.h"
+#include "psp_asd.h"
+#include "psp_tmr.h"
 
 MODULE_FIRMWARE("amdgpu/vega20_sos.bin");
 MODULE_FIRMWARE("amdgpu/vega20_asd.bin");
@@ -257,6 +259,12 @@ static const struct psp_funcs psp_v11_0_funcs = {
 	.prep_cmd_buf = psp_ring_prep_cmd_buf,
 	.submit_cmd_buf = psp_ring_submit_cmd_buf,
 	.support_vmr_ring = psp_ring_support_vmr,
+	.asd_init = psp_asd_init,
+	.asd_load = psp_asd_load,
+	.tmr_init = psp_tmr_init,
+	.tmr_load = psp_tmr_load,
+	.xgmi_init = psp_xgmi_initialize,
+	.xgmi_destory = psp_xgmi_terminate,
 	.bootloader_load_sysdrv = psp_cmn_bootloader_load_sysdrv,
 	.bootloader_load_sos = psp_cmn_bootloader_load_sos,
 	.compare_sram_data = psp_cmn_compare_sram_data,
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +6 -0
index a013c3ae114b..8bcbc6bb9333 100644
@@ -38,6 +38,8 @@
 #include "nbio/nbio_6_1_offset.h"
 #include "psp_ring.h"
 #include "psp_cmn.h"
+#include "psp_asd.h"
+#include "psp_tmr.h"
 
 MODULE_FIRMWARE("amdgpu/vega10_sos.bin");
 MODULE_FIRMWARE("amdgpu/vega10_asd.bin");
@@ -175,6 +177,10 @@ static const struct psp_funcs psp_v3_1_funcs = {
 	.ring_destroy = psp_ring_destroy_ring,
 	.prep_cmd_buf = psp_ring_prep_cmd_buf,
 	.submit_cmd_buf = psp_ring_submit_cmd_buf,
+	.asd_init = psp_asd_init,
+	.asd_load = psp_asd_load,
+	.tmr_init = psp_tmr_init,
+	.tmr_load = psp_tmr_load,
 	.bootloader_load_sysdrv = psp_cmn_bootloader_load_sysdrv,
 	.bootloader_load_sos = psp_v3_1_bootloader_load_sos,
 	.compare_sram_data = psp_cmn_compare_sram_data,
Signature · 6 lines
2.20.1

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

PATCH 9/9 drm/amdgpu: move psp_funcs related to a more proper place

In reply to a message not in the archive

As there is no need to expose these through amdgpu_psp.h. So, it's better to make them PSP internal used only.

Change-Id I571be7aae8807f11a6d594be7762306b56403f82
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 96 +++++++++++-------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 73 +++---------------
 drivers/gpu/drm/amd/amdgpu/psp_cmn.h    | 43 +++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_funcs.h  | 98 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   |  2 +-
 7 files changed, 197 insertions(+), 119 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_funcs.h
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +44 -52
index ecfbf618652a..3b46334fa849 100644
@@ -32,57 +32,8 @@
 #include "psp_v3_1.h"
 #include "psp_v10_0.h"
 #include "psp_v11_0.h"
-
-#define psp_ring_init(psp, type) \
-		(psp)->funcs->ring_init((psp), (type))
-#define psp_ring_create(psp, type) \
-		(psp)->funcs->ring_create((psp), (type))
-#define psp_ring_stop(psp, type) \
-		(psp)->funcs->ring_stop((psp), (type))
-#define psp_ring_destroy(psp, type) \
-		((psp)->funcs->ring_destroy((psp), (type)))
-#define psp_prep_cmd_buf(ucode, cmd) \
-		(psp)->funcs->prep_cmd_buf((ucode), (cmd))
-#define psp_submit_cmd_buf(psp, ucode, cmd, fence_mc) \
-		(psp)->funcs->submit_cmd_buf((psp), (ucode), (cmd), (fence_mc))
-#define psp_support_vmr_ring(psp) \
-		((psp)->funcs->support_vmr_ring ? (psp)->funcs->support_vmr_ring((psp)) : false)
-#define psp_init_asd(psp) \
-		((psp)->funcs->asd_init ? (psp)->funcs->asd_init((psp)) : 0)
-#define psp_load_asd(psp) \
-		((psp)->funcs->asd_load ? (psp)->funcs->asd_load((psp)) : 0)
-#define psp_unload_asd(psp) \
-		((psp)->funcs->asd_unload ? (psp)->funcs->asd_unload((psp)) : 0)
-#define psp_destory_asd(psp) \
-		((psp)->funcs->asd_destory ? (psp)->funcs->asd_destory((psp)) : 0)
-#define psp_init_tmr(psp) \
-		((psp)->funcs->tmr_init ? (psp)->funcs->tmr_init((psp)) : 0)
-#define psp_load_tmr(psp) \
-		((psp)->funcs->tmr_load ? (psp)->funcs->tmr_load((psp)) : 0)
-#define psp_unload_tmr(psp) \
-		((psp)->funcs->tmr_unload ? (psp)->funcs->tmr_unload((psp)) : 0)
-#define psp_destory_tmr(psp) \
-		((psp)->funcs->tmr_destory ? (psp)->funcs->tmr_destory((psp)) : 0)
-#define psp_init_xgmi(psp) \
-		((psp)->funcs->xgmi_init ? (psp)->funcs->xgmi_init((psp)) : 0)
-#define psp_load_xgmi(psp) \
-		((psp)->funcs->xgmi_load ? (psp)->funcs->xgmi_load((psp)) : 0)
-#define psp_unload_xgmi(psp) \
-		((psp)->funcs->xgmi_unload ? (psp)->funcs->xgmi_unload((psp)) : 0)
-#define psp_destory_xgmi(psp) \
-		((psp)->funcs->xgmi_destory ? (psp)->funcs->xgmi_destory((psp)) : 0)
-#define psp_compare_sram_data(psp, ucode, type) \
-		(psp)->funcs->compare_sram_data((psp), (ucode), (type))
-#define psp_init_microcode(psp) \
-		((psp)->funcs->init_microcode ? (psp)->funcs->init_microcode((psp)) : 0)
-#define psp_bootloader_load_sysdrv(psp) \
-		((psp)->funcs->bootloader_load_sysdrv ? (psp)->funcs->bootloader_load_sysdrv((psp)) : 0)
-#define psp_bootloader_load_sos(psp) \
-		((psp)->funcs->bootloader_load_sos ? (psp)->funcs->bootloader_load_sos((psp)) : 0)
-#define psp_smu_reload_quirk(psp) \
-		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
-#define psp_mode1_reset(psp) \
-		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
+#include "psp_cmn.h"
+#include "psp_funcs.h"
 
 static int psp_sw_init(void *handle)
 {
@@ -417,7 +368,6 @@ int psp_gpu_reset(struct amdgpu_device *adev)
 	return psp_mode1_reset(&adev->psp);
 }
 
-
 static int psp_set_clockgating_state(void *handle,
 				     enum amd_clockgating_state state)
 {
@@ -430,6 +380,48 @@ static int psp_set_powergating_state(void *handle,
 	return 0;
 }
 
+int psp_xgmi_get_topology_info(struct psp_context *psp,
+		int number_devices, struct psp_xgmi_topology_info *topology)
+{
+	const struct psp_funcs *funcs = (const struct psp_funcs *)(psp->priv);
+
+	if (!funcs->xgmi_get_topology_info)
+		return -EINVAL;
+
+	return funcs->xgmi_get_topology_info(psp, number_devices, topology);
+}
+
+int psp_xgmi_set_topology_info(struct psp_context *psp,
+		int number_devices, struct psp_xgmi_topology_info *topology)
+{
+	const struct psp_funcs *funcs = (const struct psp_funcs *)(psp->priv);
+
+	if (!funcs->xgmi_set_topology_info)
+		return -EINVAL;
+
+	return funcs->xgmi_set_topology_info(psp, number_devices, topology);
+}
+
+int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id)
+{
+	const struct psp_funcs *funcs = (const struct psp_funcs *)(psp->priv);
+
+	if (!funcs->xgmi_get_hive_id)
+		return -EINVAL;
+
+	return funcs->xgmi_get_hive_id(psp, hive_id);
+}
+
+int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id)
+{
+	const struct psp_funcs *funcs = (const struct psp_funcs *)(psp->priv);
+
+	if (!funcs->xgmi_get_node_id)
+		return -EINVAL;
+
+	return funcs->xgmi_get_node_id(psp, node_id);
+}
+
 const struct amd_ip_funcs psp_ip_funcs = {
 	.name = "psp",
 	.early_init = NULL,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +9 -64

106 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_cmn.h +43 -0

49 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_funcs.h new file +98 -0

98 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/psp_v10_0.c +1 -1
index a469ff952045..7588b73af4a3 100644
@@ -117,5 +117,5 @@ static const struct psp_funcs psp_v10_0_funcs = {
 
 void psp_v10_0_set_psp_funcs(struct psp_context *psp)
 {
-	psp->funcs = &psp_v10_0_funcs;
+	psp->priv = (const void *)&psp_v10_0_funcs;
 }
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +1 -1
index 68ce4ccceec7..c963dcc63d71 100644
@@ -277,5 +277,5 @@ static const struct psp_funcs psp_v11_0_funcs = {
 
 void psp_v11_0_set_psp_funcs(struct psp_context *psp)
 {
-	psp->funcs = &psp_v11_0_funcs;
+	psp->priv = (const void *)&psp_v11_0_funcs;
 }
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +1 -1
index 8bcbc6bb9333..39beb8d589b9 100644
@@ -190,5 +190,5 @@ static const struct psp_funcs psp_v3_1_funcs = {
 
 void psp_v3_1_set_psp_funcs(struct psp_context *psp)
 {
-	psp->funcs = &psp_v3_1_funcs;
+	psp->priv = (const void *)&psp_v3_1_funcs;
 }
Signature · 6 lines
2.20.1

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

The general idea looks good, but can we change the file and symbol naming a bit?

So far we have named all non-ip version related functions amdgpu_* and ip related functions ip_version.

E.g. following this xgmi functions should go into amdgpu_xgmi.c and not psp_xgmi.c

Christian.

Am 02.01.19 um 10:21 schrieb Evan Quan:

Quoted 32 lines

*** BLURB HERE ***

Evan Quan (9):
drm/amdgpu: separate the PSP ring related APIs drm/amdgpu: separate commonly used PSP APIs
drm/amdgpu: separate the xgmi related APIs
drm/amdgpu: separate the tmr related APIs
drm/amdgpu: separate the asd related APIs
drm/amdgpu: drop useless PSP APIs and structures drm/amdgpu: check PSP support before adding the ip block drm/amdgpu: make PSP sub modules(ASD/XGMI/TMR) support configurable drm/amdgpu: move psp_funcs related to a more proper place

  drivers/gpu/drm/amd/amdgpu/Makefile     |   7 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 504 +++-------------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  93 +---
  drivers/gpu/drm/amd/amdgpu/psp_asd.c    |  86 ++++
  drivers/gpu/drm/amd/amdgpu/psp_asd.h    |  32 ++
  drivers/gpu/drm/amd/amdgpu/psp_cmn.c    | 289 +++++++++++++
  drivers/gpu/drm/amd/amdgpu/psp_cmn.h    |  84 ++++
  drivers/gpu/drm/amd/amdgpu/psp_funcs.h  |  98 +++++
  drivers/gpu/drm/amd/amdgpu/psp_ring.c   | 354 ++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/psp_ring.h   |  43 ++
  drivers/gpu/drm/amd/amdgpu/psp_tmr.c    |  84 ++++
  drivers/gpu/drm/amd/amdgpu/psp_tmr.h    |  32 ++
  drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 381 +----------------
  drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 539 +-----------------------
  drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 480 +--------------------
  drivers/gpu/drm/amd/amdgpu/psp_xgmi.c   | 207 +++++++++
  drivers/gpu/drm/amd/amdgpu/psp_xgmi.h   |  33 ++
  drivers/gpu/drm/amd/amdgpu/soc15.c      |  13 +-
  18 files changed, 1493 insertions(+), 1866 deletions(-)
Quoted 12 lines

create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_funcs.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.h

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

A message that is not in the archive (sent off-list or not yet received): 070000a9-9abf-1c23-9294-03e8ff6041dd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#13 lore raw

I'd prefer to keep the old structures: common interfaces in amdgpu_psp.c/.h, and IP specific ones in IP specific file.

No matter it's something related to ASD,TMR, or XGMI.etc, all of these are just communication/handshake jobs between driver and psp fw. Driver plays messenger role with several psp cmd that are shared among ASIC generations. a unified amdgpu_psp.c file is good enough to hold all the common stuffs.

Regards,
Hawking

________________________________
From: Christian K?nig <[email protected]>
Sent: Wednesday, January 2, 2019 6:01:56 PM
To: Quan, Evan; [email protected]
Cc: Deucher, Alexander; Xu, Feifei; Huang, Ray; Zhang, Hawking
Subject: Re: [PATCH 0/9] PSP cleanup

The general idea looks good, but can we change the file and symbol naming a bit?

So far we have named all non-ip version related functions amdgpu_* and ip related functions ip_version.

E.g. following this xgmi functions should go into amdgpu_xgmi.c and not psp_xgmi.c

Christian.

Am 02.01.19 um 10:21 schrieb Evan Quan:

Quoted 32 lines

*** BLURB HERE ***

Evan Quan (9):
drm/amdgpu: separate the PSP ring related APIs drm/amdgpu: separate commonly used PSP APIs
drm/amdgpu: separate the xgmi related APIs
drm/amdgpu: separate the tmr related APIs
drm/amdgpu: separate the asd related APIs
drm/amdgpu: drop useless PSP APIs and structures drm/amdgpu: check PSP support before adding the ip block drm/amdgpu: make PSP sub modules(ASD/XGMI/TMR) support configurable drm/amdgpu: move psp_funcs related to a more proper place

  drivers/gpu/drm/amd/amdgpu/Makefile     |   7 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 504 +++-------------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  93 +---
  drivers/gpu/drm/amd/amdgpu/psp_asd.c    |  86 ++++
  drivers/gpu/drm/amd/amdgpu/psp_asd.h    |  32 ++
  drivers/gpu/drm/amd/amdgpu/psp_cmn.c    | 289 +++++++++++++
  drivers/gpu/drm/amd/amdgpu/psp_cmn.h    |  84 ++++
  drivers/gpu/drm/amd/amdgpu/psp_funcs.h  |  98 +++++
  drivers/gpu/drm/amd/amdgpu/psp_ring.c   | 354 ++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/psp_ring.h   |  43 ++
  drivers/gpu/drm/amd/amdgpu/psp_tmr.c    |  84 ++++
  drivers/gpu/drm/amd/amdgpu/psp_tmr.h    |  32 ++
  drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 381 +----------------
  drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 539 +-----------------------
  drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 480 +--------------------
  drivers/gpu/drm/amd/amdgpu/psp_xgmi.c   | 207 +++++++++
  drivers/gpu/drm/amd/amdgpu/psp_xgmi.h   |  33 ++
  drivers/gpu/drm/amd/amdgpu/soc15.c      |  13 +-
  18 files changed, 1493 insertions(+), 1866 deletions(-)
Quoted 12 lines

create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_funcs.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.h

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

A message that is not in the archive (sent off-list or not yet received): BYAPR12MB2632A5BB82C2FCE97AF9E7ECFC8C0-ZGDeBxoHBPk+ukJnzp2+RQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#15 lore raw
Quoted 2 lines

I'd prefer to keep the old structures: common interfaces in amdgpu_psp.c/.h, and IP specific ones in IP specific file.

That works for me as well.

Key take away from the change overview is this:

Quoted 3 lines
Quoted 3 lines

   drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 381 +---------------- drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 539 +----------------------- drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 480 +--------------------

That looks like we can move a good bunch of the per IP specific code into the common interface. And that is something I really like to see.

No strong opinion if the common code should go into amdgpu_psp.c/h, amdgpu_xgmi.c/h or amdgpu_psp_xgmi.c/h.

The only restriction I have is that we should just stick with the existing naming convention.

Christian.

Am 02.01.19 um 11:21 schrieb Zhang, Hawking:

Quoted 74 lines

I'd prefer to keep the old structures: common interfaces in amdgpu_psp.c/.h, and IP specific ones in IP specific file.

No matter it's something related to ASD,TMR, or XGMI.etc, all of these are just communication/handshake jobs between driver and psp fw. Driver plays messenger role with several psp cmd that are shared among ASIC generations. a unified amdgpu_psp.c file is good enough to hold all the common stuffs.

Regards,
Hawking

------------------------------------------------------------------------
*From:* Christian König <[email protected]> *Sent:* Wednesday, January 2, 2019 6:01:56 PM
*To:* Quan, Evan; [email protected] *Cc:* Deucher, Alexander; Xu, Feifei; Huang, Ray; Zhang, Hawking *Subject:* Re: [PATCH 0/9] PSP cleanup
The general idea looks good, but can we change the file and symbol
naming a bit?

So far we have named all non-ip version related functions amdgpu_* and ip related functions ip_version.

E.g. following this xgmi functions should go into amdgpu_xgmi.c and not psp_xgmi.c

Christian.

Am 02.01.19 um 10:21 schrieb Evan Quan:

Quoted 32 lines

*** BLURB HERE ***

Evan Quan (9):
    drm/amdgpu: separate the PSP ring related APIs drm/amdgpu: separate commonly used PSP APIs
    drm/amdgpu: separate the xgmi related APIs
    drm/amdgpu: separate the tmr related APIs
    drm/amdgpu: separate the asd related APIs
    drm/amdgpu: drop useless PSP APIs and structures drm/amdgpu: check PSP support before adding the ip block drm/amdgpu: make PSP sub modules(ASD/XGMI/TMR) support configurable drm/amdgpu: move psp_funcs related to a more proper place

   drivers/gpu/drm/amd/amdgpu/Makefile     |   7 +- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 504 +++------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  93 +---

   drivers/gpu/drm/amd/amdgpu/psp_asd.c    |  86 ++++
   drivers/gpu/drm/amd/amdgpu/psp_asd.h    |  32 ++
   drivers/gpu/drm/amd/amdgpu/psp_cmn.c    | 289 +++++++++++++
   drivers/gpu/drm/amd/amdgpu/psp_cmn.h    |  84 ++++

   drivers/gpu/drm/amd/amdgpu/psp_funcs.h  |  98 +++++ drivers/gpu/drm/amd/amdgpu/psp_ring.c   | 354 ++++++++++++++++ drivers/gpu/drm/amd/amdgpu/psp_ring.h   |  43 ++ drivers/gpu/drm/amd/amdgpu/psp_tmr.c    |  84 ++++ drivers/gpu/drm/amd/amdgpu/psp_tmr.h    |  32 ++ drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 381 +---------------- drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 539 +-----------------------

   drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 480 +--------------------
   drivers/gpu/drm/amd/amdgpu/psp_xgmi.c   | 207 +++++++++
   drivers/gpu/drm/amd/amdgpu/psp_xgmi.h   |  33 ++
   drivers/gpu/drm/amd/amdgpu/soc15.c      |  13 +-
   18 files changed, 1493 insertions(+), 1866 deletions(-)
Quoted 12 lines

   create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_funcs.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.h

Quoted 4 lines

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): e458fa2c-b541-e757-6a7e-34fbc2e3b8fc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#17 lore raw

Yep, We are in progress to move IP specific code into common interfaces. For instance, psp_vXX_get_fw_type/psp_vXX_prep_cmd_buf should be common interfaces, instead of IP specific ones. We’ll see that soon.

And I agree with you that we should stick with the existing naming style. And that’s why I have concern we created some unnecessary files like psp_asd.c/psp_tmr.c/psp_xgmi.c/psp_cmn.c.etc. All of these are just play with common psp gfx cmd. The interfaces are limited and actually do similar jobs.

For ASD, it is common for all the ASICs since from vega10. Although not all the ASICs really used ASD fw, the fact is we’ve already upstreamed ASD fw for vega series and onwards. Therefore, below interfaces seems unnecessary. +psp_load_asd(psp) \
+ ((psp)->funcs->asd_load ? (psp)->funcs->asd_load((psp)) : 0) #define
+psp_unload_asd(psp) \
+ ((psp)->funcs->asd_unload ? (psp)->funcs->asd_unload((psp)) : 0)
+#define psp_destory_asd(psp) \
+ ((psp)->funcs->asd_destory ? (psp)->funcs->asd_destory((psp)) : 0)

Similar case for TMR. Therefore below interfaces seems unnecessary. +#define psp_init_tmr(psp) \
+ ((psp)->funcs->tmr_init ? (psp)->funcs->tmr_init((psp)) : 0) #define
+psp_load_tmr(psp) \
+ ((psp)->funcs->tmr_load ? (psp)->funcs->tmr_load((psp)) : 0) #define
+psp_unload_tmr(psp) \
+ ((psp)->funcs->tmr_unload ? (psp)->funcs->tmr_unload((psp)) : 0)
+#define psp_destory_tmr(psp) \
+ ((psp)->funcs->tmr_destory ? (psp)->funcs->tmr_destory((psp)) : 0)

For XGMI, we can use either the “supported” flags in amdgpu_xgmi or num_physical_nodes to decide whether to load the TA or not. Therefore, below interfaces seems unnecessary. +#define psp_init_xgmi(psp) \
+ ((psp)->funcs->xgmi_init ? (psp)->funcs->xgmi_init((psp)) : 0)
+#define psp_load_xgmi(psp) \
+ ((psp)->funcs->xgmi_load ? (psp)->funcs->xgmi_load((psp)) : 0)
+#define psp_unload_xgmi(psp) \
+ ((psp)->funcs->xgmi_unload ? (psp)->funcs->xgmi_unload((psp)) : 0)
+#define psp_destory_xgmi(psp) \
+ ((psp)->funcs->xgmi_destory ? (psp)->funcs->xgmi_destory((psp)) : 0)

For the upcoming functionalities that need to play with TA ucode, they share exactly the same TA cmd with xgmi. Do we really need to separate them into different psp_xxx source files?

In sum, I’d prefer to stick with the old structures: common interfaces in amdgpu_psp.c/.h, and IP specific ones in IP specific file.

Regards,
Hawking
From: Christian König <[email protected]>
Sent: 2019年1月2日 20:00
To: Zhang, Hawking <[email protected]>; Quan, Evan <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Xu, Feifei <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH 0/9] PSP cleanup

I'd prefer to keep the old structures: common interfaces in amdgpu_psp.c/.h, and IP specific ones in IP specific file. That works for me as well.

Key take away from the change overview is this:

Quoted 3 lines
  drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 381 +----------------
  drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 539 +-----------------------
  drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 480 +--------------------

That looks like we can move a good bunch of the per IP specific code into the common interface. And that is something I really like to see.

No strong opinion if the common code should go into amdgpu_psp.c/h, amdgpu_xgmi.c/h or amdgpu_psp_xgmi.c/h.

The only restriction I have is that we should just stick with the existing naming convention.

Christian.

Am 02.01.19 um 11:21 schrieb Zhang, Hawking:

I'd prefer to keep the old structures: common interfaces in amdgpu_psp.c/.h, and IP specific ones in IP specific file.

No matter it's something related to ASD,TMR, or XGMI.etc, all of these are just communication/handshake jobs between driver and psp fw. Driver plays messenger role with several psp cmd that are shared among ASIC generations. a unified amdgpu_psp.c file is good enough to hold all the common stuffs.

Regards,
Hawking
[X]
From: Christian König <[email protected]><mailto:[email protected]>
Sent: Wednesday, January 2, 2019 6:01:56 PM
To: Quan, Evan; [email protected]<mailto:[email protected]>
Cc: Deucher, Alexander; Xu, Feifei; Huang, Ray; Zhang, Hawking
Subject: Re: [PATCH 0/9] PSP cleanup

The general idea looks good, but can we change the file and symbol naming a bit?

So far we have named all non-ip version related functions amdgpu_* and ip related functions ip_version.

E.g. following this xgmi functions should go into amdgpu_xgmi.c and not psp_xgmi.c

Christian.

Am 02.01.19 um 10:21 schrieb Evan Quan:

Quoted 32 lines

*** BLURB HERE ***

Evan Quan (9):
drm/amdgpu: separate the PSP ring related APIs drm/amdgpu: separate commonly used PSP APIs
drm/amdgpu: separate the xgmi related APIs
drm/amdgpu: separate the tmr related APIs
drm/amdgpu: separate the asd related APIs
drm/amdgpu: drop useless PSP APIs and structures drm/amdgpu: check PSP support before adding the ip block drm/amdgpu: make PSP sub modules(ASD/XGMI/TMR) support configurable drm/amdgpu: move psp_funcs related to a more proper place

  drivers/gpu/drm/amd/amdgpu/Makefile     |   7 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 504 +++-------------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  93 +---
  drivers/gpu/drm/amd/amdgpu/psp_asd.c    |  86 ++++
  drivers/gpu/drm/amd/amdgpu/psp_asd.h    |  32 ++
  drivers/gpu/drm/amd/amdgpu/psp_cmn.c    | 289 +++++++++++++
  drivers/gpu/drm/amd/amdgpu/psp_cmn.h    |  84 ++++
  drivers/gpu/drm/amd/amdgpu/psp_funcs.h  |  98 +++++
  drivers/gpu/drm/amd/amdgpu/psp_ring.c   | 354 ++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/psp_ring.h   |  43 ++
  drivers/gpu/drm/amd/amdgpu/psp_tmr.c    |  84 ++++
  drivers/gpu/drm/amd/amdgpu/psp_tmr.h    |  32 ++
  drivers/gpu/drm/amd/amdgpu/psp_v10_0.c  | 381 +----------------
  drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 539 +-----------------------
  drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 480 +--------------------
  drivers/gpu/drm/amd/amdgpu/psp_xgmi.c   | 207 +++++++++
  drivers/gpu/drm/amd/amdgpu/psp_xgmi.h   |  33 ++
  drivers/gpu/drm/amd/amdgpu/soc15.c      |  13 +-
  18 files changed, 1493 insertions(+), 1866 deletions(-)
Quoted 12 lines

create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_asd.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_cmn.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_funcs.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_ring.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_tmr.h create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.c create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_xgmi.h

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

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