[PATCH 2/3] drm/xe/pf: Add reclaim annotation to the PF master mutex

Michal Wajdeczko michal.wajdeczko at intel.com
Wed Jan 22 21:49:54 UTC 2025


We need to avoid making allocations with PF master mutex held
as we are doing VFs reprovisioning during reset/resume steps.
Add annotation around PF master mutex to catch undesired uses.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: Thomas Hellström <thomas.hellstrom at linux.intel.com>
---
 drivers/gpu/drm/xe/xe_sriov_pf.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_sriov_pf.c b/drivers/gpu/drm/xe/xe_sriov_pf.c
index 0f721ae17b26..2286a08657b0 100644
--- a/drivers/gpu/drm/xe/xe_sriov_pf.c
+++ b/drivers/gpu/drm/xe/xe_sriov_pf.c
@@ -10,6 +10,7 @@
 #include "xe_module.h"
 #include "xe_sriov.h"
 #include "xe_sriov_pf.h"
+#include "xe_sriov_pf_helpers.h"
 #include "xe_sriov_printk.h"
 
 static unsigned int wanted_max_vfs(struct xe_device *xe)
@@ -37,6 +38,13 @@ static bool pf_continue_as_native(struct xe_device *xe, const char *why)
 	return false;
 }
 
+static void pf_primelockdep(struct xe_device *xe)
+{
+	fs_reclaim_acquire(GFP_KERNEL);
+	might_lock(xe_sriov_pf_master_mutex(xe));
+	fs_reclaim_release(GFP_KERNEL);
+}
+
 /**
  * xe_sriov_pf_readiness - Check if PF functionality can be enabled.
  * @xe: the &xe_device to check
@@ -80,9 +88,18 @@ bool xe_sriov_pf_readiness(struct xe_device *xe)
  */
 int xe_sriov_pf_init_early(struct xe_device *xe)
 {
+	int err;
+
 	xe_assert(xe, IS_SRIOV_PF(xe));
 
-	return drmm_mutex_init(&xe->drm, &xe->sriov.pf.master_lock);
+	err = drmm_mutex_init(&xe->drm, &xe->sriov.pf.master_lock);
+	if (err)
+		return err;
+
+	if (IS_ENABLED(CONFIG_LOCKDEP))
+		pf_primelockdep(xe);
+
+	return 0;
 }
 
 /**
-- 
2.47.1



More information about the Intel-xe mailing list