drm/amdgpu: Add flags for partition mode query
It's not required to take lock on all cases while querying partition mode. Querying partition mode during KFD init process doesn't need to take a lock. Init process after a switch will already be happening under lock. Control the behaviour by adding flags to xcp_query_partition_mode. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
@@ -1177,7 +1177,8 @@ static ssize_t amdgpu_gfx_get_current_compute_partition(struct device *dev,
|
||||
int mode;
|
||||
char *partition_mode;
|
||||
|
||||
mode = amdgpu_xcp_query_partition_mode(adev->xcp_mgr);
|
||||
mode = amdgpu_xcp_query_partition_mode(adev->xcp_mgr,
|
||||
AMDGPU_XCP_FL_NONE);
|
||||
|
||||
switch (mode) {
|
||||
case AMDGPU_SPX_PARTITION_MODE:
|
||||
|
||||
@@ -170,7 +170,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr)
|
||||
int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)
|
||||
{
|
||||
int mode;
|
||||
|
||||
@@ -180,7 +180,8 @@ int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr)
|
||||
if (!xcp_mgr->funcs || !xcp_mgr->funcs->query_partition_mode)
|
||||
return xcp_mgr->mode;
|
||||
|
||||
mutex_lock(&xcp_mgr->xcp_lock);
|
||||
if (!(flags & AMDGPU_XCP_FL_LOCKED))
|
||||
mutex_lock(&xcp_mgr->xcp_lock);
|
||||
mode = xcp_mgr->funcs->query_partition_mode(xcp_mgr);
|
||||
if (mode != xcp_mgr->mode)
|
||||
dev_WARN(
|
||||
@@ -188,7 +189,8 @@ int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr)
|
||||
"Cached partition mode %d not matching with device mode %d",
|
||||
xcp_mgr->mode, mode);
|
||||
|
||||
mutex_unlock(&xcp_mgr->xcp_lock);
|
||||
if (!(flags & AMDGPU_XCP_FL_LOCKED))
|
||||
mutex_unlock(&xcp_mgr->xcp_lock);
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
|
||||
#define AMDGPU_XCP_MODE_NONE -1
|
||||
|
||||
#define AMDGPU_XCP_FL_NONE 0
|
||||
#define AMDGPU_XCP_FL_LOCKED (1 << 0)
|
||||
|
||||
enum AMDGPU_XCP_IP_BLOCK {
|
||||
AMDGPU_XCP_GFXHUB,
|
||||
AMDGPU_XCP_GFX,
|
||||
@@ -99,7 +102,7 @@ int amdgpu_xcp_resume(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id);
|
||||
|
||||
int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode,
|
||||
int init_xcps, struct amdgpu_xcp_mgr_funcs *xcp_funcs);
|
||||
int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr);
|
||||
int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags);
|
||||
int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode);
|
||||
int amdgpu_xcp_get_partition(struct amdgpu_xcp_mgr *xcp_mgr,
|
||||
enum AMDGPU_XCP_IP_BLOCK ip, int instance);
|
||||
|
||||
@@ -1940,7 +1940,9 @@ static int gfx_v9_4_3_cp_resume(struct amdgpu_device *adev)
|
||||
{
|
||||
int r, i, num_xcc;
|
||||
|
||||
if (amdgpu_xcp_query_partition_mode(adev->xcp_mgr) == AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE)
|
||||
if (amdgpu_xcp_query_partition_mode(adev->xcp_mgr,
|
||||
AMDGPU_XCP_FL_NONE) ==
|
||||
AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE)
|
||||
amdgpu_xcp_switch_partition_mode(adev->xcp_mgr, amdgpu_user_partt_mode);
|
||||
|
||||
num_xcc = NUM_XCC(adev->gfx.xcc_mask);
|
||||
|
||||
@@ -645,7 +645,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
|
||||
* If the VMID range changes for GFX9.4.3, then this code MUST be
|
||||
* revisited.
|
||||
*/
|
||||
partition_mode = amdgpu_xcp_query_partition_mode(kfd->adev->xcp_mgr);
|
||||
partition_mode = amdgpu_xcp_query_partition_mode(kfd->adev->xcp_mgr, AMDGPU_XCP_FL_LOCKED);
|
||||
if (KFD_GC_VERSION(kfd) == IP_VERSION(9, 4, 3) &&
|
||||
partition_mode == AMDGPU_CPX_PARTITION_MODE &&
|
||||
kfd->num_nodes != 1) {
|
||||
|
||||
Reference in New Issue
Block a user