drm/amdgpu: Disable compute partition switch under SRIOV
Subsystems (2)
PATCH v2 1/2 drm/amdgpu: Disable compute partition switch under SRIOV
Do not allow the compute partition mode switch from the guest driver but still allow the query for current_compute_partition.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +5 -0
@@ -1292,6 +1292,11 @@ static ssize_t amdgpu_gfx_set_compute_partition(struct device *dev,enum amdgpu_gfx_partition mode;int ret =0 , num_xcc; +/* Under SRIOV, this is allowed only via the host driver but not from +* within the VF */ +if (amdgpu_sriov_vf (adev)) +return -EPERM ; + num_xcc =NUM_XCC (adev->gfx.xcc_mask);if (num_xcc %2 !=0 )return -EINVAL ;
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +2 -7
@@ -936,11 +936,7 @@ static int gfx_v9_4_3_sw_init(void *handle)if (r)return r; - -if (!amdgpu_sriov_vf (adev)) - r =amdgpu_gfx_sysfs_init (adev); - -return r; +return amdgpu_gfx_sysfs_init (adev); }static int gfx_v9_4_3_sw_fini (void *handle)
@@ -961,8 +957,7 @@ static int gfx_v9_4_3_sw_fini(void *handle)gfx_v9_4_3_mec_fini (adev);amdgpu_bo_unref (&adev->gfx.rlc.clear_state_obj);gfx_v9_4_3_free_microcode (adev); -if (!amdgpu_sriov_vf (adev)) -amdgpu_gfx_sysfs_fini (adev); +amdgpu_gfx_sysfs_fini (adev);return 0 ; }
Signature · 1 line
2.34.1
PATCH v2 2/2 drm/amdgpu: Don't warn for compute mode switch under SRIOV
Under SRIOV environment, the compute partition mode is setup by the host driver so state machine cached copy might be different when doing the transition for the first time.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +2 -1
@@ -228,7 +228,8 @@ 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); -if (xcp_mgr->mode !=AMDGPU_XCP_MODE_TRANS && mode != xcp_mgr->mode) +if (xcp_mgr->mode !=AMDGPU_XCP_MODE_TRANS && mode != xcp_mgr->mode + && !amdgpu_sriov_vf (xcp_mgr->adev)) dev_WARN( xcp_mgr->adev->dev, "Cached partition mode %d not matching with device mode %d",
Signature · 1 line
2.34.1
Re: [Patch v2 2/2] drm/amdgpu: Don't warn for compute mode switch under SRIOV
Quoted 14 lines · Rajneesh Bhardwaj
Under SRIOV environment, the compute partition mode is setup by the host driver so state machine cached copy might be different when doing the transition for the first time.
Signed-off-by Rajneesh Bhardwaj <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags) · line 232
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +2
-1@@ -228,7 +228,8 @@ 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); -if (xcp_mgr->mode !=AMDGPU_XCP_MODE_TRANS && mode != xcp_mgr->mode) +if (xcp_mgr->mode !=AMDGPU_XCP_MODE_TRANS && mode != xcp_mgr->mode + && !amdgpu_sriov_vf (xcp_mgr->adev))
This indicates a fundamental problem in host-guest mode and host is doing a switch without guest's knowledge. This needs to be fixed differently.
Thanks,
Lijo
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +0
-0dev_WARN( xcp_mgr->adev->dev, "Cached partition mode %d not matching with device mode %d",
Quoted 14 lines · Rajneesh Bhardwaj
Do not allow the compute partition mode switch from the guest driver but still allow the query for
current_compute_partition.Signed-off-by Rajneesh Bhardwaj <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c static ssize_t amdgpu_gfx_set_compute_partition(struct device *dev, · line 1299
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +5
-0@@ -1292,6 +1292,11 @@ static ssize_t amdgpu_gfx_set_compute_partition(struct device *dev,enum amdgpu_gfx_partition mode;int ret =0 , num_xcc; +/* Under SRIOV, this is allowed only via the host driver but not from +* within the VF */ +if (amdgpu_sriov_vf (adev)) +return -EPERM ; +
This is not the way to do this. It needs to disable switch partition callback in xcp_mgr for VF mode. That's the one which will be checked for making the sysfs node read/write vs read-only.
Thanks,
Lijo
Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0num_xcc =NUM_XCC (adev->gfx.xcc_mask);if (num_xcc %2 !=0 )return -EINVAL ;drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +2
-7@@ -936,11 +936,7 @@ static int gfx_v9_4_3_sw_init(void *handle)if (r)return r; - -if (!amdgpu_sriov_vf (adev)) - r =amdgpu_gfx_sysfs_init (adev); - -return r; +return amdgpu_gfx_sysfs_init (adev); }static int gfx_v9_4_3_sw_fini (void *handle)@@ -961,8 +957,7 @@ static int gfx_v9_4_3_sw_fini(void *handle)gfx_v9_4_3_mec_fini (adev);amdgpu_bo_unref (&adev->gfx.rlc.clear_state_obj);gfx_v9_4_3_free_microcode (adev); -if (!amdgpu_sriov_vf (adev)) -amdgpu_gfx_sysfs_fini (adev); +amdgpu_gfx_sysfs_fini (adev);return 0 ; }