#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)
#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"
*/
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
#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));
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;
#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"
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)
* @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;