]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: Use cached partition mode, if valid
authorLijo Lazar <lijo.lazar@amd.com>
Sat, 5 Jul 2025 03:15:08 +0000 (08:45 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 15 Jul 2025 18:07:17 +0000 (14:07 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c

index c8fcafeb686450fa14e74f5df70e961d74ac9b94..c417f868922077bcbe4fcff12fab1e3a15ac3289 100644 (file)
@@ -218,15 +218,27 @@ int amdgpu_xcp_restore_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr)
        return __amdgpu_xcp_switch_partition_mode(xcp_mgr, xcp_mgr->mode);
 }
 
-int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)
+static bool __amdgpu_xcp_is_cached_mode_valid(struct amdgpu_xcp_mgr *xcp_mgr)
 {
-       int mode;
+       if (!xcp_mgr->funcs || !xcp_mgr->funcs->query_partition_mode)
+               return true;
 
        if (!amdgpu_sriov_vf(xcp_mgr->adev) &&
            xcp_mgr->mode == AMDGPU_XCP_MODE_NONE)
-               return xcp_mgr->mode;
+               return true;
 
-       if (!xcp_mgr->funcs || !xcp_mgr->funcs->query_partition_mode)
+       if (xcp_mgr->mode != AMDGPU_XCP_MODE_NONE &&
+           xcp_mgr->mode != AMDGPU_XCP_MODE_TRANS)
+               return true;
+
+       return false;
+}
+
+int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)
+{
+       int mode;
+
+       if (__amdgpu_xcp_is_cached_mode_valid(xcp_mgr))
                return xcp_mgr->mode;
 
        if (!(flags & AMDGPU_XCP_FL_LOCKED))