We are currently developing software for a two camera system using the Leopard Imaging IMX274 and the Leopard Imaging three camera expansion board mounted on a TX2 development board running the 28.2 OS. Our application accepts streams from the two cameras, combines them into a single frame, which it then sends to the hardware encoder. This code was working prior to the upgrade to the 28.0 version. We see a pthread mutex lock after three frames are received from the camera. By gradually removing bits of the program, we have traced the problem to the cuGraphicsEGLRegisterImage call used to map an EGLImageKHR into cuda space. The mutex lock assertion happens once this call is added to the processing. All further accesses to the resulting CUeglFrame have been commented out, so it is just this call that is triggering the failure. Code stub is shown below.
bool ColorConsumerThread::createMagImage(void * psink, CUeglFrame * sourceframe, float mag, float aimxpix, float aimypix, int * strides)
{
CUDA_RESOURCE_DESC cudaResDesc;
CUDA_TEXTURE_DESC cudaTexDesc;
CUgraphicsResource zoomResource = NULL;
CUresult cuResult;
const char * errorString;
EGLImageKHR * sinkframe = (EGLImageKHR *)psink;
float uvx, uvy; // center of U and V planes for 4:2:0 image
int ystride, uvstride;
uvx = (2.0f * aimxpix - 1.0f)/4.0f;
uvy = (2.0f * aimypix - 1.0f)/4.0f;
ystride = *strides;
uvstride = *(strides+1);
// Register the output frame with cuda, so it can be used as a destination buffer for the
// magnified frame.
cuResult = cuGraphicsEGLRegisterImage(&zoomResource, *sinkframe, CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE);
if (cuResult != CUDA_SUCCESS)
{
cuGetErrorString(cuResult, &errorString);
fprintf(stderr, "Error: unable to register zoom buffer as graphics resource %s\n", errorString);
return false;
}
CUeglFrame zoomEglFrame;
cuResult = cuGraphicsResourceGetMappedEglFrame(&zoomEglFrame, zoomResource, 0, 0);
if (cuResult != CUDA_SUCCESS)
{
cuGetErrorString(cuResult, &errorString);
fprintf(stderr, "Error: unable to get zoom frame in cuda EGL format %s\n", errorString);
return false;
}
fprintf(stdout, "frame size : %d x %d with format %d and %d planes \n", zoomEglFrame.width, zoomEglFrame.height, zoomEglFrame.eglColorFormat, zoomEglFrame.planeCount);
:
:
The status information from the run is as follows:
nvidia@tegra-ubuntu:~/workspace/ScopeTestbug$ ./scope_test 1
Default status: zoom 1.000000
NvPclHwGetModuleList: No module data found
NvPclHwGetModuleList: No module data found
OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
LoadOverridesFile: looking for override file [/Calib/camera_override.isp] 1/16LoadOverridesFile: looking for override file [/data/nvcam/settings/camera_overrides.isp] 2/16LoadOverridesFile: looking for override file [/opt/nvidia/nvcam/settings/camera_overrides.isp] 3/16LoadOverridesFile: looking for override file [/var/nvidia/nvcam/settings/camera_overrides.isp] 4/16---- imager: Found override file [/var/nvidia/nvcam/settings/camera_overrides.isp]. ----
LoadOverridesFile: looking for override file [/Calib/camera_override.isp] 1/16LoadOverridesFile: looking for override file [/data/nvcam/settings/camera_overrides.isp] 2/16LoadOverridesFile: looking for override file [/opt/nvidia/nvcam/settings/camera_overrides.isp] 3/16LoadOverridesFile: looking for override file [/var/nvidia/nvcam/settings/camera_overrides.isp] 4/16---- imager: Found override file [/var/nvidia/nvcam/settings/camera_overrides.isp]. ----
LoadOverridesFile: looking for override file [/Calib/camera_override.isp] 1/16LoadOverridesFile: looking for override file [/data/nvcam/settings/camera_overrides.isp] 2/16LoadOverridesFile: looking for override file [/opt/nvidia/nvcam/settings/camera_overrides.isp] 3/16LoadOverridesFile: looking for override file [/var/nvidia/nvcam/settings/camera_overrides.isp] 4/16---- imager: Found override file [/var/nvidia/nvcam/settings/camera_overrides.isp]. ----
Argus Version: 0.96.2 (single-process)
number of AE regions for far camera 64
Color Consumer thread ID 547537396192
cuda consumer connected to far color stream
Failed to query video capabilities: Inappropriate ioctl for device
NvMMLiteOpen : Block : BlockType = 4
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
Success: created Video encoder
Created NvBuffer 0 with fd 1828717628
Created NvBuffer 1 with fd 1828717629
Created NvBuffer 2 with fd 1828717630
Created NvBuffer 3 with fd 1828717631
Created NvBuffer 4 with fd 1828717634
Created NvBuffer 5 with fd 1828718022
Waiting until producers are connected…
Producers are connected, continuing…
===== MSENC blits (mode: 1) into tiled surfaces =====
Dequeued buffer with fd 1828717628
SCF: Error InvalidState: NonFatal ISO BW requested not set. Requested = 2147483647 Set = 4687500 (in src/services/power/PowerServiceCore.cpp, function setCameraBw(), line 653)
frame number 1
frame size : 1280 x 720 with format 0 and 3 planes
stream size : 3840 x 2160 with center 1919.50 x 1079.50 and magnification 0.415146
Dequeued buffer with fd 1828717629
frame number 2
frame size : 1280 x 720 with format 0 and 3 planes
stream size : 3840 x 2160 with center 1919.50 x 1079.50 and magnification 0.415146
Dequeued buffer with fd 1828717630
frame number 3
scope_test: pthread_mutex_lock.c:349: __pthread_mutex_lock_full: Assertion `INTERNAL_SYSCALL_ERRNO (e, __err) != EDEADLK || (kind != PTHREAD_MUTEX_ERRORCHECK_NP && kind != PTHREAD_MUTEX_RECURSIVE_NP)’ failed.
Aborted (core dumped)
nvidia@tegra-ubuntu:~/workspace/ScopeTestbug$
We can provide a reduced code sample that triggers the error, if you can let us know where to send it. We do ITAR restricted work, so can not publish the code on the forum.
Thank-you for your assistance.