[PATCH v4 8/8] drm/xe/pf: Enable per-function per-engine-class activity stats

Riana Tauro riana.tauro at intel.com
Wed Jan 29 10:16:51 UTC 2025


Enable per-function per-engine-class activity stats when
sriov_numvfs are set and disable when sriov_numvfs
are set to 0.

Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
Signed-off-by: Riana Tauro <riana.tauro at intel.com>
---
 drivers/gpu/drm/xe/xe_pci_sriov.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
index aaceee748287..fd0c1284deff 100644
--- a/drivers/gpu/drm/xe/xe_pci_sriov.c
+++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
@@ -7,6 +7,7 @@
 #include "xe_device.h"
 #include "xe_gt_sriov_pf_config.h"
 #include "xe_gt_sriov_pf_control.h"
+#include "xe_guc_engine_activity.h"
 #include "xe_pci_sriov.h"
 #include "xe_pm.h"
 #include "xe_sriov.h"
@@ -62,6 +63,18 @@ static void pf_reset_vfs(struct xe_device *xe, unsigned int num_vfs)
 			xe_gt_sriov_pf_control_trigger_flr(gt, n);
 }
 
+static int pf_engine_activity_stats(struct xe_device *xe, unsigned int num_vfs, bool enable)
+{
+	struct xe_gt *gt;
+	unsigned int id;
+	int ret = 0;
+
+	for_each_gt(gt, xe, id)
+		ret  = xe_guc_engine_activity_function_stats(&gt->uc.guc, num_vfs, enable);
+
+	return ret;
+}
+
 static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
 {
 	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
@@ -94,6 +107,11 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
 
 	xe_sriov_info(xe, "Enabled %u of %u VF%s\n",
 		      num_vfs, total_vfs, str_plural(total_vfs));
+
+	err = pf_engine_activity_stats(xe, num_vfs, true);
+	if (err < 0)
+		xe_sriov_warn(xe, "Failed to enable function activity stats\n");
+
 	return num_vfs;
 
 failed:
@@ -110,6 +128,7 @@ static int pf_disable_vfs(struct xe_device *xe)
 	struct device *dev = xe->drm.dev;
 	struct pci_dev *pdev = to_pci_dev(dev);
 	u16 num_vfs = pci_num_vf(pdev);
+	int err;
 
 	xe_assert(xe, IS_SRIOV_PF(xe));
 	xe_sriov_dbg(xe, "disabling %u VF%s\n", num_vfs, str_plural(num_vfs));
@@ -117,6 +136,10 @@ static int pf_disable_vfs(struct xe_device *xe)
 	if (!num_vfs)
 		return 0;
 
+	err = pf_engine_activity_stats(xe, num_vfs, false);
+	if (err < 0)
+		xe_sriov_warn(xe, "Failed to disable function activity stats\n");
+
 	pci_disable_sriov(pdev);
 
 	pf_reset_vfs(xe, num_vfs);
-- 
2.47.1



More information about the Intel-xe mailing list