ikvm_manager.cpp: fix a deadlock issue

There is a deadlock in the case that the screen resolution is altered.
The probability of deadlock will increase as the frame rate increases.
The deadlock is likely to be reproduced when the frame rate is set to
above 30fps. The scenario of deadlock is described as below.

mainThread                                             serverThread
                                                             |
                                                       setServerDone
                                                             |
setVideoDone <----------switch to mainThread <----set serverDone to true
   |
waitServer
   |
serverDone is set to FALSE
   |
screen resolution has been changed
   |
videoDone is set to FALSE
   |
waitServer(A, wait serverThread to set serverDone to TRUE, \
   |                                           block mainthread)
   |
   ----------switch to serverThread-------------------> waitVideo
                                                            |
                                                            |
   (B, wait mainthread to set videoDone to TRUE, block serverThread)

A)The main thread is blocked for waiting serverThread to set serverDone,
at the meantime, B)The serverThread is blocked for waiting main thread
to set videoDone. So a deadlock is generated.

The patch delays to set videoDone to false after the mainThread is
blocked for waiting serverDone, then the value of the videoDone
maintains true. So the serverThread is unblocked as the videoDone is
true. After serverThread finishes executing setServerDone, mainThread
is unblocked and continues executing.

Change-Id: If30d2cd5c493a909397fde43d1cf538cc28f3df2
Signed-off-by: Min Wang <wangmin@phytium.com.cn>
1 file changed
tree: caea6be0a67f6b4409f23f7fb3ab2356a0e9938d
  1. subprojects/
  2. .clang-format
  3. .gitignore
  4. create_usbhid.sh
  5. ikvm_args.cpp
  6. ikvm_args.hpp
  7. ikvm_input.cpp
  8. ikvm_input.hpp
  9. ikvm_manager.cpp
  10. ikvm_manager.hpp
  11. ikvm_server.cpp
  12. ikvm_server.hpp
  13. ikvm_video.cpp
  14. ikvm_video.hpp
  15. LICENSE
  16. meson.build
  17. obmc-ikvm.cpp
  18. OWNERS
  19. README.md
  20. scancodes.hpp
  21. start-ipkvm.service
README.md

OpenBMC IpKVM Server

The obmc-ikvm application is a VNC server that provides access to the host graphics output. The application interfaces with the video device on the BMC that captures the host graphics, and then serves that video data on the RFB (remote framebuffer, also known as VNC) protocol. The application also interfaces with the BMC USB gadget device to pass HID events from the BMC to the host, allowing the user to interact with the host system.

Usage

Once the host is running and an appropriate HID gadget device is instantiated on the BMC, the application can be started with the following command: obmc-ikvm -v <video device path> -i <HID gadget device path>

For example:

obmc-ikvm -v /dev/video0 -i /dev/hidg0