drm/amdgpu: Initialize VF partition mode
Subsystems (2)
PATCH 1/1 drm/amdgpu: Initialize VF partition mode
For SOCs with GFX v9.4.3, a VF may have multiple compute partitions. Fetch the partition information during init and initialize partition nodes. There is no support to switch partition mode in VF mode, hence disable the same.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 12 ++++-- drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c | 50 +++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 37 +++++++++++++--- 4 files changed, 88 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
@@ -297,6 +297,7 @@ struct amdgpu_gfx_funcs {int (*switch_partition_mode)(struct amdgpu_device *adev,int num_xccs_per_xcp);int (*ih_node_to_logical_xcc)(struct amdgpu_device *adev,int ih_node); +int (*get_xccs_per_xcp)(struct amdgpu_device *adev); };struct sq_work {
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +9 -3
@@ -219,7 +219,8 @@ int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags) {int mode; -if (xcp_mgr->mode ==AMDGPU_XCP_MODE_NONE ) +if (!amdgpu_sriov_vf (xcp_mgr->adev) && + xcp_mgr->mode ==AMDGPU_XCP_MODE_NONE )return xcp_mgr->mode;if (!xcp_mgr->funcs || !xcp_mgr->funcs->query_partition_mode)
@@ -228,6 +229,12 @@ int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)if (!(flags &AMDGPU_XCP_FL_LOCKED ))mutex_lock (&xcp_mgr->xcp_lock); mode = xcp_mgr->funcs->query_partition_mode (xcp_mgr); + +/* First time query for VF, set the mode here */ +if (amdgpu_sriov_vf (xcp_mgr->adev) && + xcp_mgr->mode ==AMDGPU_XCP_MODE_NONE ) + xcp_mgr->mode = mode; +if (xcp_mgr->mode !=AMDGPU_XCP_MODE_TRANS && mode != xcp_mgr->mode) dev_WARN( xcp_mgr->adev->dev,
@@ -282,8 +289,7 @@ int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode, {struct amdgpu_xcp_mgr *xcp_mgr; -if (!xcp_funcs || !xcp_funcs->switch_partition_mode || - !xcp_funcs->get_ip_details) +if (!xcp_funcs || !xcp_funcs->get_ip_details)return -EINVAL ; xcp_mgr =kzalloc (sizeof (*xcp_mgr),GFP_KERNEL );
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +48 -2
67 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +30 -7
@@ -652,6 +652,15 @@ static void gfx_v9_4_3_select_me_pipe_q(struct amdgpu_device *adev,soc15_grbm_select (adev, me, pipe, q, vm,GET_INST (GC , xcc_id)); } +static int gfx_v9_4_3_get_xccs_per_xcp (struct amdgpu_device *adev) +{ +u32 xcp_ctl; + +/* Value is expected to be the same on all, fetch from first instance */ + xcp_ctl =RREG32_SOC15 (GC ,GET_INST (GC ,0 ), regCP_HYP_XCP_CTL); + +return REG_GET_FIELD (xcp_ctl,CP_HYP_XCP_CTL ,NUM_XCC_IN_XCP ); +}static int gfx_v9_4_3_switch_compute_partition (struct amdgpu_device *adev,int num_xccs_per_xcp)
@@ -706,6 +715,7 @@ static const struct amdgpu_gfx_funcs gfx_v9_4_3_gfx_funcs = { .select_me_pipe_q = &gfx_v9_4_3_select_me_pipe_q, .switch_partition_mode = &gfx_v9_4_3_switch_compute_partition, .ih_node_to_logical_xcc = &gfx_v9_4_3_ih_to_xcc_inst, + .get_xccs_per_xcp = &gfx_v9_4_3_get_xccs_per_xcp, }; static int gfx_v9_4_3_aca_bank_parser(struct aca_handle *handle,
@@ -2050,18 +2060,31 @@ static int gfx_v9_4_3_xcc_cp_resume(struct amdgpu_device *adev, int xcc_id)static int gfx_v9_4_3_cp_resume (struct amdgpu_device *adev) { -int r =0 , i, num_xcc; +int r =0 , i, num_xcc, num_xcp, num_xcc_per_xcp; + + num_xcc =NUM_XCC (adev->gfx.xcc_mask); +if (amdgpu_sriov_vf (adev)) { +enum amdgpu_gfx_partition mode; -if (amdgpu_xcp_query_partition_mode (adev->xcp_mgr, -AMDGPU_XCP_FL_NONE ) == -AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE ) - r =amdgpu_xcp_switch_partition_mode (adev->xcp_mgr, - amdgpu_user_partt_mode); + mode =amdgpu_xcp_query_partition_mode (adev->xcp_mgr, +AMDGPU_XCP_FL_NONE ); +if (mode ==AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE ) +return -EINVAL ; + num_xcc_per_xcp =gfx_v9_4_3_get_xccs_per_xcp (adev); + adev->gfx.num_xcc_per_xcp = num_xcc_per_xcp; + num_xcp = num_xcc / num_xcc_per_xcp; + r =amdgpu_xcp_init (adev->xcp_mgr, num_xcp, mode); + }else { +if (amdgpu_xcp_query_partition_mode (adev->xcp_mgr, +AMDGPU_XCP_FL_NONE ) == +AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE ) + r =amdgpu_xcp_switch_partition_mode ( + adev->xcp_mgr, amdgpu_user_partt_mode); + }if (r)return r; - num_xcc =NUM_XCC (adev->gfx.xcc_mask);for (i =0 ; i < num_xcc; i++) { r =gfx_v9_4_3_xcc_cp_resume (adev, i);if (r)
Signature · 1 line
2.25.1
[AMD Official Use Only - AMD Internal Distribution Only]
Regards,
Hawking
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, July 9, 2024 13:17
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Thadvai, Satya <[email protected]>; Chang, HaiJun <[email protected]>; Shi, Lianjie <[email protected]>
Subject: [PATCH] drm/amdgpu: Initialize VF partition mode
For SOCs with GFX v9.4.3, a VF may have multiple compute partitions.
Fetch the partition information during init and initialize partition nodes. There is no support to switch partition mode in VF mode, hence disable the same.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 12 ++++-- drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c | 50 +++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 37 +++++++++++++--- 4 files changed, 88 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
@@ -297,6 +297,7 @@ struct amdgpu_gfx_funcs {int (*switch_partition_mode)(struct amdgpu_device *adev,int num_xccs_per_xcp);int (*ih_node_to_logical_xcc)(struct amdgpu_device *adev,int ih_node); +int (*get_xccs_per_xcp)(struct amdgpu_device *adev); };struct sq_work {
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +9 -3
@@ -219,7 +219,8 @@ int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags) {int mode; -if (xcp_mgr->mode ==AMDGPU_XCP_MODE_NONE ) +if (!amdgpu_sriov_vf (xcp_mgr->adev) && + xcp_mgr->mode ==AMDGPU_XCP_MODE_NONE )return xcp_mgr->mode;if (!xcp_mgr->funcs || !xcp_mgr->funcs->query_partition_mode)
@@ -228,6 +229,12 @@ int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)if (!(flags &AMDGPU_XCP_FL_LOCKED ))mutex_lock (&xcp_mgr->xcp_lock); mode = xcp_mgr->funcs->query_partition_mode (xcp_mgr); + +/* First time query for VF, set the mode here */ +if (amdgpu_sriov_vf (xcp_mgr->adev) && + xcp_mgr->mode ==AMDGPU_XCP_MODE_NONE ) + xcp_mgr->mode = mode; +if (xcp_mgr->mode !=AMDGPU_XCP_MODE_TRANS && mode != xcp_mgr->mode) dev_WARN( xcp_mgr->adev->dev,
@@ -282,8 +289,7 @@ int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode, {struct amdgpu_xcp_mgr *xcp_mgr; -if (!xcp_funcs || !xcp_funcs->switch_partition_mode || - !xcp_funcs->get_ip_details) +if (!xcp_funcs || !xcp_funcs->get_ip_details)return -EINVAL ; xcp_mgr = kzalloc(sizeof(*xcp_mgr), GFP_KERNEL); diff --git a/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c b/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
index 2c9a0aa41e2d..228fd4dd32f1 100644
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +47 -2
64 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +8 -0
@@ -652,6 +652,15 @@ static void gfx_v9_4_3_select_me_pipe_q(struct amdgpu_device *adev,soc15_grbm_select (adev, me, pipe, q, vm,GET_INST (GC , xcc_id)); } +static int gfx_v9_4_3_get_xccs_per_xcp (struct amdgpu_device *adev) { +u32 xcp_ctl; + +/* Value is expected to be the same on all, fetch from first instance */ + xcp_ctl =RREG32_SOC15 (GC ,GET_INST (GC ,0 ), regCP_HYP_XCP_CTL); + +return REG_GET_FIELD (xcp_ctl,CP_HYP_XCP_CTL ,NUM_XCC_IN_XCP ); }static int gfx_v9_4_3_switch_compute_partition (struct amdgpu_device *adev,int num_xccs_per_xcp)
@@ -706,6 +715,7 @@ static const struct amdgpu_gfx_funcs gfx_v9_4_3_gfx_funcs = { .select_me_pipe_q = &gfx_v9_4_3_select_me_pipe_q, .switch_partition_mode = &gfx_v9_4_3_switch_compute_partition, .ih_node_to_logical_xcc = &gfx_v9_4_3_ih_to_xcc_inst, + .get_xccs_per_xcp = &gfx_v9_4_3_get_xccs_per_xcp, }; static int gfx_v9_4_3_aca_bank_parser(struct aca_handle *handle, @@ -2050,18 +2060,31 @@ static int gfx_v9_4_3_xcc_cp_resume(struct amdgpu_device *adev, int xcc_id)
static int gfx_v9_4_3_cp_resume(struct amdgpu_device *adev) {
- int r = 0, i, num_xcc;
+ int r = 0, i, num_xcc, num_xcp, num_xcc_per_xcp;
+
+ num_xcc = NUM_XCC(adev->gfx.xcc_mask);
+ if (amdgpu_sriov_vf(adev)) {
+ enum amdgpu_gfx_partition mode;
- if (amdgpu_xcp_query_partition_mode(adev->xcp_mgr,
- AMDGPU_XCP_FL_NONE) ==
- AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE)
- r = amdgpu_xcp_switch_partition_mode(adev->xcp_mgr,
- amdgpu_user_partt_mode);
+ mode = amdgpu_xcp_query_partition_mode(adev->xcp_mgr,
+ AMDGPU_XCP_FL_NONE);
+ if (mode == AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE)
+ return -EINVAL;
+ num_xcc_per_xcp = gfx_v9_4_3_get_xccs_per_xcp(adev); + adev->gfx.num_xcc_per_xcp = num_xcc_per_xcp; + num_xcp = num_xcc / num_xcc_per_xcp; + r = amdgpu_xcp_init(adev->xcp_mgr, num_xcp, mode);
+ } else {
+ if (amdgpu_xcp_query_partition_mode(adev->xcp_mgr,
+ AMDGPU_XCP_FL_NONE) ==
+ AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE)
+ r = amdgpu_xcp_switch_partition_mode(
+ adev->xcp_mgr, amdgpu_user_partt_mode);
+ }
if (r)
return r;- num_xcc = NUM_XCC(adev->gfx.xcc_mask);
for (i = 0; i < num_xcc; i++) {
r = gfx_v9_4_3_xcc_cp_resume(adev, i);
if (r)--
2.25.1