Skip to content

Commit 8ff4a4b

Browse files
Lijo Lazaralexdeucher
authored andcommitted
drm/amdgpu: Use cached partition mode, if valid
For current partition mode queries, return the mode cached in partition manager whenever it's valid. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 7e11e01 commit 8ff4a4b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,27 @@ int amdgpu_xcp_restore_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr)
218218
return __amdgpu_xcp_switch_partition_mode(xcp_mgr, xcp_mgr->mode);
219219
}
220220

221-
int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)
221+
static bool __amdgpu_xcp_is_cached_mode_valid(struct amdgpu_xcp_mgr *xcp_mgr)
222222
{
223-
int mode;
223+
if (!xcp_mgr->funcs || !xcp_mgr->funcs->query_partition_mode)
224+
return true;
224225

225226
if (!amdgpu_sriov_vf(xcp_mgr->adev) &&
226227
xcp_mgr->mode == AMDGPU_XCP_MODE_NONE)
227-
return xcp_mgr->mode;
228+
return true;
228229

229-
if (!xcp_mgr->funcs || !xcp_mgr->funcs->query_partition_mode)
230+
if (xcp_mgr->mode != AMDGPU_XCP_MODE_NONE &&
231+
xcp_mgr->mode != AMDGPU_XCP_MODE_TRANS)
232+
return true;
233+
234+
return false;
235+
}
236+
237+
int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)
238+
{
239+
int mode;
240+
241+
if (__amdgpu_xcp_is_cached_mode_valid(xcp_mgr))
230242
return xcp_mgr->mode;
231243

232244
if (!(flags & AMDGPU_XCP_FL_LOCKED))

0 commit comments

Comments
 (0)