]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe/rtp: Ensure locking/ref counting for OA whitelists
authorAshutosh Dixit <ashutosh.dixit@intel.com>
Mon, 15 Jun 2026 22:42:27 +0000 (15:42 -0700)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Thu, 2 Jul 2026 10:29:43 +0000 (12:29 +0200)
Since multiple OA streams might be open in parallel on a gt, ensure that
proper locking is in place. Also ensure that OA registers are whitelisted
when the first OA stream is open and de-whitelisted after the last OA
stream is closed.

Fixes: 828a8eaf37c3 ("drm/xe/oa: Add MMIO trigger support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20260615224227.34880-10-ashutosh.dixit@intel.com
(cherry picked from commit 645f1a2589bd4782e25490e5ecc05b7043c36cbf)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
drivers/gpu/drm/xe/xe_oa_types.h
drivers/gpu/drm/xe/xe_reg_whitelist.c

index 3d9ec8490899c1305017e4e959d3b4cf72149775..e876e9be92ba5805fb05c5924e2910581ff86431 100644 (file)
@@ -126,6 +126,9 @@ struct xe_oa_gt {
 
        /** @oa_unit: array of oa_units */
        struct xe_oa_unit *oa_unit;
+
+       /** @whitelist_count: number of open streams for which oa registers are whitelisted */
+       u32 whitelist_count;
 };
 
 /**
index b2e7aabd19d79c45cf003af87a3a43a6ad36b503..3d9e3daab01a75e03ae4bcb2028091184616b5ee 100644 (file)
@@ -255,6 +255,10 @@ void xe_reg_whitelist_oa_regs(struct xe_gt *gt)
        struct xe_hw_engine *hwe;
        enum xe_hw_engine_id id;
 
+       lockdep_assert_held(&gt->oa.gt_lock);
+       if (gt->oa.whitelist_count++)
+               return;
+
        for_each_hw_engine(hwe, gt, id)
                __whitelist_oa_regs(hwe, true);
 }
@@ -270,6 +274,11 @@ void xe_reg_dewhitelist_oa_regs(struct xe_gt *gt)
        struct xe_hw_engine *hwe;
        enum xe_hw_engine_id id;
 
+       lockdep_assert_held(&gt->oa.gt_lock);
+       xe_assert(gt_to_xe(gt), gt->oa.whitelist_count);
+       if (--gt->oa.whitelist_count)
+               return;
+
        for_each_hw_engine(hwe, gt, id)
                __whitelist_oa_regs(hwe, false);
 }