]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Derive admin-only PF mode from xe_device state
authorSatyanarayana K V P <satyanarayana.k.v.p@intel.com>
Mon, 13 Apr 2026 09:56:38 +0000 (09:56 +0000)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 14 Apr 2026 10:38:16 +0000 (12:38 +0200)
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
drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c
drivers/gpu/drm/xe/xe_device.c
drivers/gpu/drm/xe/xe_sriov_pf.c
drivers/gpu/drm/xe/xe_sriov_pf_helpers.h
drivers/gpu/drm/xe/xe_sriov_pf_types.h

index efa8963ec2488172ee610d5067e67143e295b88d..e6eaa94d4d30fb088dea16685df3cd7783065a6e 100644 (file)
 #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)
index ceddda10f78fe581051c875a47fe77bd85313691..4b45b617a03967ee6b8ddaf07dbed5e04507e191 100644 (file)
@@ -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
index 47a6e0fd66e0ffdbc69eddadeb65643a756a194a..33bd754d138fa64609cce1ea05d2e09fde5f9963 100644 (file)
 #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;
 
index 0fcc6cec4afc428893d6d68af4e6694370a83194..19f6f8331c8df6696e5e241d6a097eb9a63a369e 100644 (file)
@@ -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)
index 080cf10512f4b402aa58df982de2190ef9360b75..b0253e1ae5da4ab20b8318c648d1cd453fa40b93 100644 (file)
@@ -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;