SWDEV-552846 - Unpin memory for hip before exit the copy (#851)

This commit is contained in:
German Andryeyev
2025-09-04 10:34:01 -04:00
committed by GitHub
orang tua 7bf7110ae8
melakukan 7a1a6682e2
2 mengubah file dengan 18 tambahan dan 2 penghapusan
@@ -748,9 +748,11 @@ bool DmaBlitManager::hsaCopyStagedOrPinned(const_address hostSrc, address hostDs
firstTx = false;
}
// @note: HIP requires a blocking wait on D2H with the pageable system memory
if (amd::IS_HIP && !hostToDev) {
// @note: HIP requires to unpin all memory after operation, due to an optimization with
// direct HSA signal check HIP avoids the command completion wait
if (amd::IS_HIP && (gpu().command() != nullptr) && gpu().command()->IsMemoryPinned()) {
gpu().Barriers().WaitCurrent();
gpu().command()->ReleasePinnedMemory();
}
if (!status) {
@@ -388,6 +388,12 @@ class Command : public Event {
//! Release the resources associated with this event.
virtual void releaseResources();
//! Empty function for pinned memory check
virtual bool IsMemoryPinned() const { return false; }
//! Empty function for release of pinned memory
virtual void ReleasePinnedMemory() {}
//! Empty function for adding pinned memory
virtual void AddPinnedMemory(Memory* pinned) {}
@@ -500,10 +506,18 @@ class OneMemoryArgCommand : public Command {
memory_->release();
DEBUG_ONLY(memory_ = NULL);
Command::releaseResources();
ReleasePinnedMemory();
}
//! Release all pinned memory for this command
virtual void ReleasePinnedMemory() {
for (auto it : pinned_memory_) {
it->release();
}
pinned_memory_.clear();
}
//! Release all pinned memory for this command
virtual bool IsMemoryPinned() const { return !pinned_memory_.empty(); }
//! Adds pinned memory, used in this command for later release
virtual void AddPinnedMemory(Memory* pinned) override { pinned_memory_.push_back(pinned); }