summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatyanarayana K V P <satyanarayana.k.v.p@intel.com>2026-04-13 12:56:38 +0300
committerMichal Wajdeczko <michal.wajdeczko@intel.com>2026-04-14 13:38:16 +0300
commit3e3fbb5ee3092015db2dc9843a605896b2cca97b (patch)
tree46d24d12d8e63ca6b32be7ba6fb66b94465db65a
parentd88c4bac8c2accbf84a6994a28ee43fee8157703 (diff)
downloadlinux-3e3fbb5ee3092015db2dc9843a605896b2cca97b.tar.xz
drm/xe/pf: Derive admin-only PF mode from xe_device state
Stop tracking admin-only PF mode in a separate `xe->sriov.pf.admin_only` field and use `xe_device_is_admin_only(xe)` as the single source of admin mode. Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com> Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Link: https://patch.msgid.link/20260413095637.2871287-2-satyanarayana.k.v.p@intel.com
-rw-r--r--drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c21
-rw-r--r--drivers/gpu/drm/xe/xe_device.c2
-rw-r--r--drivers/gpu/drm/xe/xe_sriov_pf.c6
-rw-r--r--drivers/gpu/drm/xe/xe_sriov_pf_helpers.h3
-rw-r--r--drivers/gpu/drm/xe/xe_sriov_pf_types.h3
5 files changed, 23 insertions, 12 deletions
diff --git a/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c b/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c
index efa8963ec248..e6eaa94d4d30 100644
--- a/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c
+++ b/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c
@@ -13,11 +13,28 @@
#define TEST_MAX_VFS 63
#define TEST_VRAM 0x7a800000ull /* random size that works on 32-bit */
+static bool xe_device_is_admin_only_stub_enable(const struct xe_device *xe)
+{
+ return true;
+}
+
+static bool xe_device_is_admin_only_stub_disable(const struct xe_device *xe)
+{
+ return false;
+}
+
static void pf_set_admin_mode(struct xe_device *xe, bool enable)
{
- /* should match logic of xe_sriov_pf_admin_only() */
- xe->sriov.pf.admin_only = enable;
+ typeof(xe_device_is_admin_only) *stub = enable ?
+ xe_device_is_admin_only_stub_enable :
+ xe_device_is_admin_only_stub_disable;
+
+ kunit_activate_static_stub(kunit_get_current_test(),
+ xe_device_is_admin_only,
+ *stub);
+
KUNIT_EXPECT_EQ(kunit_get_current_test(), enable, xe_sriov_pf_admin_only(xe));
+ KUNIT_EXPECT_EQ(kunit_get_current_test(), enable, xe_device_is_admin_only(xe));
}
static void pf_set_usable_vram(struct xe_device *xe, u64 usable)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index ceddda10f78f..4b45b617a039 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -17,6 +17,7 @@
#include <drm/drm_managed.h>
#include <drm/drm_pagemap_util.h>
#include <drm/drm_print.h>
+#include <kunit/static_stub.h>
#include <uapi/drm/xe_drm.h>
#include "display/xe_display.h"
@@ -445,6 +446,7 @@ static struct drm_driver admin_only_driver = {
*/
bool xe_device_is_admin_only(const struct xe_device *xe)
{
+ KUNIT_STATIC_STUB_REDIRECT(xe_device_is_admin_only, xe);
return xe->drm.driver == &admin_only_driver;
}
#endif
diff --git a/drivers/gpu/drm/xe/xe_sriov_pf.c b/drivers/gpu/drm/xe/xe_sriov_pf.c
index 47a6e0fd66e0..33bd754d138f 100644
--- a/drivers/gpu/drm/xe/xe_sriov_pf.c
+++ b/drivers/gpu/drm/xe/xe_sriov_pf.c
@@ -20,11 +20,6 @@
#include "xe_sriov_pf_sysfs.h"
#include "xe_sriov_printk.h"
-static bool wanted_admin_only(struct xe_device *xe)
-{
- return xe_configfs_admin_only_pf(to_pci_dev(xe->drm.dev));
-}
-
static unsigned int wanted_max_vfs(struct xe_device *xe)
{
return xe_configfs_get_max_vfs(to_pci_dev(xe->drm.dev));
@@ -79,7 +74,6 @@ bool xe_sriov_pf_readiness(struct xe_device *xe)
pf_reduce_totalvfs(xe, newlimit);
- xe->sriov.pf.admin_only = wanted_admin_only(xe);
xe->sriov.pf.device_total_vfs = totalvfs;
xe->sriov.pf.driver_max_vfs = newlimit;
diff --git a/drivers/gpu/drm/xe/xe_sriov_pf_helpers.h b/drivers/gpu/drm/xe/xe_sriov_pf_helpers.h
index 0fcc6cec4afc..19f6f8331c8d 100644
--- a/drivers/gpu/drm/xe/xe_sriov_pf_helpers.h
+++ b/drivers/gpu/drm/xe/xe_sriov_pf_helpers.h
@@ -7,6 +7,7 @@
#define _XE_SRIOV_PF_HELPERS_H_
#include "xe_assert.h"
+#include "xe_device.h"
#include "xe_device_types.h"
#include "xe_sriov.h"
#include "xe_sriov_types.h"
@@ -57,7 +58,7 @@ static inline unsigned int xe_sriov_pf_num_vfs(const struct xe_device *xe)
static inline bool xe_sriov_pf_admin_only(const struct xe_device *xe)
{
xe_assert(xe, IS_SRIOV_PF(xe));
- return xe->sriov.pf.admin_only;
+ return xe_device_is_admin_only(xe);
}
static inline struct mutex *xe_sriov_pf_master_mutex(struct xe_device *xe)
diff --git a/drivers/gpu/drm/xe/xe_sriov_pf_types.h b/drivers/gpu/drm/xe/xe_sriov_pf_types.h
index 080cf10512f4..b0253e1ae5da 100644
--- a/drivers/gpu/drm/xe/xe_sriov_pf_types.h
+++ b/drivers/gpu/drm/xe/xe_sriov_pf_types.h
@@ -36,9 +36,6 @@ struct xe_sriov_metadata {
* @XE_SRIOV_MODE_PF mode.
*/
struct xe_device_pf {
- /** @admin_only: PF functionality focused on VFs management only. */
- bool admin_only;
-
/** @device_total_vfs: Maximum number of VFs supported by the device. */
u16 device_total_vfs;