From 2dfa5c966f276954b580289835cf5ff636ee1d96 Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 7 Dec 2017 17:08:40 -0500 Subject: [PATCH] P4 to Git Change 1491909 by gandryey@gera-w8 on 2017/12/07 16:33:58 SWDEV-79445 - OCL generic changes and code clean-up - Add device validation call for LiquidFlash library before usage. Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_lqdflash_amd.cpp#23 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#294 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/pro/prodevice.hpp#4 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/pro/prodriver.hpp#2 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#77 edit --- opencl/api/opencl/amdocl/cl_lqdflash_amd.cpp | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/opencl/api/opencl/amdocl/cl_lqdflash_amd.cpp b/opencl/api/opencl/amdocl/cl_lqdflash_amd.cpp index a18eaf9651..38e498b8f3 100644 --- a/opencl/api/opencl/amdocl/cl_lqdflash_amd.cpp +++ b/opencl/api/opencl/amdocl/cl_lqdflash_amd.cpp @@ -112,6 +112,28 @@ bool LiquidFlashFile::transferBlock(bool writeBuffer, void* srcDst, uint64_t buf RUNTIME_ENTRY_RET(cl_file_amd, clCreateSsgFileObjectAMD, (cl_context context, cl_file_flags_amd flags, const wchar_t* file_name, cl_int* errcode_ret)) { +#if defined WITH_LIQUID_FLASH && defined ATI_OS_LINUX + if (!is_valid(context)) { + *not_null(errcode_ret) = CL_INVALID_CONTEXT; + LogWarning("invalid parameter \"context\""); + return (cl_file_amd)0; + } + + const std::vector& devices = as_amd(context)->devices(); + bool supportPass = false; + for (auto& dev : devices) { + if (lf_success == lfCheckExtensionSupportForDevice(dev->info().pcieDeviceId_, + dev->info().pcieRevisionId_)) { + supportPass = true; + break; + } + } + if (!supportPass) { + *not_null(errcode_ret) = CL_INVALID_DEVICE; + LogWarning("SSG isn't supported"); + return (cl_file_amd)0; + } +#endif amd::LiquidFlashFile* file = new amd::LiquidFlashFile(file_name, flags); if (file == NULL) {