[R28.2] failed to load nvhost_nvenc050.fw with error -4

hello:

When my multi-media api program starts, there is a chance that the following print will appear and it will not work properly.It will have a kernel syncpoint error

falcon 544c0000.nvenc: firmware, attempted to load /lib/firmware/tegra21x/nvhost_nvenc050.fw, but failed with error -4
falcon 544c0000.nvenc: Direct firmware load for tegra21x/nvhost_nvenc050.fw failed with error -4
falcon 544c0000.nvenc: Falling back to user helper
falcon 544c0000.nvenc: failed to get firmware
falcon 544c0000.nvenc: failed to get firmware
falcon 544c0000.nvenc: nvhost_flcn_init_sw: failed
bilities: Inappropriate ioctl for device
smmu_dump_pagetable(): fault_address=0x0000000000000000 pa=0xffffffffffffffff bytes=ffffffffffffffff #pte=0 in L2
mc-err: (11) csr_nvencsrd: EMEM decode error on PDE or PTE entry
mc-err:   status = 0x6000001c; addr = 0x00000000
mc-err:   secure: no, access-type: read, SMMU fault: nr-nw-s
mc-err: (11) csr_nvencsrd: EMEM decode error on PDE or PTE entry

I started a multi-channel encoder\decoder thread in my process, but added a thread lock when initializing the encoder/decoder device.

What is the cause of the problem and how to avoid it ?

Thanks a lot !

The error looks to be

#define EINTR            4      /* Interrupted system call */

Maybe you can try to create second NvVideoEncoder after the first-created NvVideoencoder has received one encoded frame?

Hi DaneLLL:

Thank you for your reply.

When the mmapi NvVideoEncoder modules loads the firmware?is that when the NvVideoEncoder created, or is that when the VideoEncoder first frame is encoded?
I wrote a small program, just create, destroy a NvVideoEncoder, execute this small program, and then run my program, there is no longer the error of loading firmware failure

Hi,
It loads the firmware at the first time NvVideoEncoder::createVideoEncoder() is called. Once it is loaded, the afterward createVideoEncoder() skips the step of loading firmware.

Your solution looks good to avoid the race condition.