From 6b103f1bf6bf3747a85d28cfe1a17ce203ddd53f Mon Sep 17 00:00:00 2001
From: foreman
Date: Tue, 5 Sep 2017 18:03:48 -0400
Subject: [PATCH] P4 to Git Change 1455453 by gandryey@gera-w8 on 2017/09/05
17:49:48
SWDEV-131493 - [CQE OCL][Vega10][QR][DTB-Blocker] Soft Hang is observed while running 'Mipmaps-clCopyImage' tests of WF Conformance due to Faulty CL# 1451293
Multiple runtime locks could conflict each other:
- Remove PAL lock from the resource creation/destruction. PAL should be thread safe for those operations.
- Avoid queue execution lock for a mipmap view destruction in submitUnmapMemory
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#34 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#55 edit
---
rocclr/runtime/device/pal/palresource.cpp | 17 ++++++-----------
rocclr/runtime/device/pal/palvirtual.cpp | 11 ++++++++---
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/rocclr/runtime/device/pal/palresource.cpp b/rocclr/runtime/device/pal/palresource.cpp
index 15bab952b6..6c5e85fa83 100644
--- a/rocclr/runtime/device/pal/palresource.cpp
+++ b/rocclr/runtime/device/pal/palresource.cpp
@@ -168,15 +168,12 @@ GpuMemoryReference::~GpuMemoryReference() {
device_.vgpus()[0]->releaseMemory(this, &events_[0]);
}
- {
- amd::ScopedLock lk(device_.lockPAL());
- if (cpuAddress_ != nullptr) {
- iMem()->Unmap();
- }
- if (0 != iMem()) {
- iMem()->Destroy();
- gpuMem_ = nullptr;
- }
+ if (cpuAddress_ != nullptr) {
+ iMem()->Unmap();
+ }
+ if (0 != iMem()) {
+ iMem()->Destroy();
+ gpuMem_ = nullptr;
}
device_.removeResource(this);
}
@@ -415,8 +412,6 @@ bool Resource::create(MemoryType memType, CreateParams* params) {
// This is a thread safe operation
const_cast(dev()).initializeHeapResources();
- amd::ScopedLock lk(dev().lockPAL());
-
if (memType == Shader) {
if (dev().settings().svmFineGrainSystem_) {
desc_.isAllocExecute_ = true;
diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/runtime/device/pal/palvirtual.cpp
index 0f4097a5b8..33a65eaf5a 100644
--- a/rocclr/runtime/device/pal/palvirtual.cpp
+++ b/rocclr/runtime/device/pal/palvirtual.cpp
@@ -1478,12 +1478,14 @@ void VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd) {
}
void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) {
+ bool unmapMip = false;
+ amd::Image* amdImage;
+{
// Make sure VirtualGPU has an exclusive access to the resources
amd::ScopedLock lock(execution());
pal::Memory* memory = dev().getGpuMemory(&vcmd.memory());
amd::Memory* owner = memory->owner();
- bool unmapMip = false;
const device::Memory::WriteMapInfo* writeMapInfo = memory->writeMapInfo(vcmd.mapPtr());
if (nullptr == writeMapInfo) {
LogError("Unmap without map call");
@@ -1492,7 +1494,7 @@ void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) {
profilingBegin(vcmd, true);
// Check if image is a mipmap and assign a saved view
- amd::Image* amdImage = owner->asImage();
+ amdImage = owner->asImage();
if ((amdImage != nullptr) && (amdImage->getMipLevels() > 1) &&
(writeMapInfo->baseMip_ != nullptr)) {
// Assign mip level view
@@ -1571,11 +1573,14 @@ void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) {
// Clear unmap flags
memory->clearUnmapInfo(vcmd.mapPtr());
+ profilingEnd(vcmd);
+}
// Release a view for a mipmap map
if (unmapMip) {
+ // Memory release should be outside of the execution lock,
+ // because mapMemory_ isn't marked for a specifc GPU
amdImage->release();
}
- profilingEnd(vcmd);
}
bool VirtualGPU::fillMemory(cl_command_type type, amd::Memory* amdMemory, const void* pattern,