fix: lock csr before locking residency controller in trim to budget path

Lock on csr is needed before lock on residency controller to prevent
incorrect lock order. Csr may be locked in waitOnCpu called from trimToBudget,
which may lead to deadlocks

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka
2025-03-28 14:47:10 +00:00
committed by Compute-Runtime-Automation
parent 4f308b2ea9
commit a5e19330e9
3 changed files with 14 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -11,6 +11,7 @@
namespace NEO {
class MockWddmResidencyController : public WddmResidencyController {
public:
using WddmResidencyController::csr;
using WddmResidencyController::lastTrimFenceValue;
using WddmResidencyController::lock;
using WddmResidencyController::trimCallbackHandle;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2024 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -748,6 +748,15 @@ TEST_F(WddmResidencyControllerLockTest, givenTrimToBudgetWhenTrimmingResidencyTh
EXPECT_EQ(1u, residencyController->acquireLockCallCount);
}
HWTEST_F(WddmResidencyControllerLockTest, givenTrimToBudgetWhenTrimmingToBudgetThenLockCsr) {
D3DKMT_TRIMNOTIFICATION trimNotification = {0};
trimNotification.Flags.TrimToBudget = 1;
trimNotification.NumBytesToTrim = 0;
residencyController->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim);
EXPECT_EQ(1u, static_cast<UltCommandStreamReceiver<FamilyType> *>(residencyController->csr)->recursiveLockCounter);
}
TEST_F(WddmResidencyControllerLockTest, givenPeriodicTrimAndTrimToBudgetWhenTrimmingResidencyThenLockTwice) {
D3DKMT_TRIMNOTIFICATION trimNotification = {0};
trimNotification.Flags.PeriodicTrim = 1;