summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_guc_relay.c
diff options
context:
space:
mode:
authorMichal Wajdeczko <michal.wajdeczko@intel.com>2024-01-05 01:20:30 +0300
committerMichal Wajdeczko <michal.wajdeczko@intel.com>2024-01-05 18:25:54 +0300
commit927b042a8daf2c773fd1802b388e22ca6087235c (patch)
tree5352b53e6f34c711a11e3f1d0e4c8a10391f6f3e /drivers/gpu/drm/xe/xe_guc_relay.c
parent4469eae6bc52b3746b39941f90b9213bcef0255a (diff)
downloadlinux-927b042a8daf2c773fd1802b388e22ca6087235c.tar.xz
drm/xe/kunit: Add GuC Relay kunit tests
Add few tests to make sure that some negative and normal use scenarios of the GuC Relay are implemented correctly. Reviewed-by: Piotr PiĆ³rkowski <piotr.piorkowski@intel.com> Link: https://lore.kernel.org/r/20240104222031.277-10-michal.wajdeczko@intel.com Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Diffstat (limited to 'drivers/gpu/drm/xe/xe_guc_relay.c')
-rw-r--r--drivers/gpu/drm/xe/xe_guc_relay.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/gpu/drm/xe/xe_guc_relay.c b/drivers/gpu/drm/xe/xe_guc_relay.c
index 0e7383256408..b772088979bd 100644
--- a/drivers/gpu/drm/xe/xe_guc_relay.c
+++ b/drivers/gpu/drm/xe/xe_guc_relay.c
@@ -8,6 +8,8 @@
#include <drm/drm_managed.h>
+#include <kunit/static_stub.h>
+
#include "abi/guc_actions_sriov_abi.h"
#include "abi/guc_relay_actions_abi.h"
#include "abi/guc_relay_communication_abi.h"
@@ -60,6 +62,7 @@ static int relay_get_totalvfs(struct xe_guc_relay *relay)
struct xe_device *xe = relay_to_xe(relay);
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+ KUNIT_STATIC_STUB_REDIRECT(relay_get_totalvfs, relay);
return IS_SRIOV_VF(xe) ? 0 : pci_sriov_get_totalvfs(pdev);
}
@@ -392,6 +395,11 @@ static u32 prepare_error_reply(u32 *msg, u32 error, u32 hint)
return GUC_HXG_FAILURE_MSG_LEN;
}
+static void relay_testonly_nop(struct xe_guc_relay *relay)
+{
+ KUNIT_STATIC_STUB_REDIRECT(relay_testonly_nop, relay);
+}
+
static int relay_send_message_and_wait(struct xe_guc_relay *relay,
struct relay_transaction *txn,
u32 *buf, u32 buf_size)
@@ -434,8 +442,10 @@ wait:
reinit_completion(&txn->done);
if (txn->reply == -EAGAIN)
goto resend;
- if (txn->reply == -EBUSY)
+ if (txn->reply == -EBUSY) {
+ relay_testonly_nop(relay);
goto wait;
+ }
if (txn->reply > 0)
ret = from_relay_error(txn->reply);
else
@@ -751,6 +761,7 @@ static bool relay_needs_worker(struct xe_guc_relay *relay)
static void relay_kick_worker(struct xe_guc_relay *relay)
{
+ KUNIT_STATIC_STUB_REDIRECT(relay_kick_worker, relay);
queue_work(relay_to_xe(relay)->sriov.wq, &relay->worker);
}
@@ -849,7 +860,7 @@ int xe_guc_relay_process_guc2vf(struct xe_guc_relay *relay, const u32 *msg, u32
relay_assert(relay, FIELD_GET(GUC_HXG_EVENT_MSG_0_ACTION, msg[0]) ==
XE_GUC_ACTION_GUC2VF_RELAY_FROM_PF);
- if (unlikely(!IS_SRIOV_VF(relay_to_xe(relay))))
+ if (unlikely(!IS_SRIOV_VF(relay_to_xe(relay)) && !kunit_get_current_test()))
return -EPERM;
if (unlikely(!relay_is_ready(relay)))
@@ -895,7 +906,7 @@ int xe_guc_relay_process_guc2pf(struct xe_guc_relay *relay, const u32 *msg, u32
relay_assert(relay, FIELD_GET(GUC_HXG_EVENT_MSG_0_ACTION, msg[0]) ==
XE_GUC_ACTION_GUC2PF_RELAY_FROM_VF);
- if (unlikely(!IS_SRIOV_PF(relay_to_xe(relay))))
+ if (unlikely(!IS_SRIOV_PF(relay_to_xe(relay)) && !kunit_get_current_test()))
return -EPERM;
if (unlikely(!relay_is_ready(relay)))
@@ -923,3 +934,7 @@ int xe_guc_relay_process_guc2pf(struct xe_guc_relay *relay, const u32 *msg, u32
return err;
}
#endif
+
+#if IS_BUILTIN(CONFIG_DRM_XE_KUNIT_TEST)
+#include "tests/xe_guc_relay_test.c"
+#endif