summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddie James <eajames@linux.ibm.com>2019-08-09 15:41:37 -0500
committerEddie James <eajames@linux.ibm.com>2019-08-09 15:41:37 -0500
commit23135dd97ec828e2abeacce06d472bb45bc358d5 (patch)
tree67fb9dddfa4c4145b9c3f72f834d174c1e174fab
parent133bfa2d5b1b3af0b8e819b4cd210a0e1ac0445c (diff)
downloadobmc-ikvm-23135dd97ec828e2abeacce06d472bb45bc358d5.tar.gz
obmc-ikvm-23135dd97ec828e2abeacce06d472bb45bc358d5.zip
eliminate excessive journal errors
When the USB gadget is shut down, the application needs to avoid writes to it in order to avoid lots of errors in the kernel log. Close the file handle and re-open it when timings are detected again. Also, prevent logging the failed timings query more than once. Change-Id: Ic126828fe26ef44ebb0a5cb65cc47b23bb84f7f3 Signed-off-by: Eddie James <eajames@linux.ibm.com>
-rw-r--r--ikvm_input.cpp46
-rw-r--r--ikvm_input.hpp2
-rw-r--r--ikvm_video.cpp18
-rw-r--r--ikvm_video.hpp2
4 files changed, 64 insertions, 4 deletions
diff --git a/ikvm_input.cpp b/ikvm_input.cpp
index 202b761..30deea6 100644
--- a/ikvm_input.cpp
+++ b/ikvm_input.cpp
@@ -156,6 +156,36 @@ void Input::pointerEvent(int buttonMask, int x, int y, rfbClientPtr cl)
rfbDefaultPtrAddEvent(buttonMask, x, y, cl);
}
+void Input::restart()
+{
+ if (!keyboardPath.empty() && keyboardFd < 0)
+ {
+ keyboardFd = open(keyboardPath.c_str(), O_RDWR | O_CLOEXEC);
+ if (keyboardFd < 0)
+ {
+ log<level::ERR>("Failed to open input device",
+ entry("PATH=%s", keyboardPath.c_str()),
+ entry("ERROR=%s", strerror(errno)));
+ }
+
+ sendKeyboard = false;
+ }
+
+ if (!pointerPath.empty() && pointerFd < 0)
+ {
+ pointerFd = open(pointerPath.c_str(), O_RDWR | O_CLOEXEC | O_NONBLOCK);
+ if (pointerFd < 0)
+ {
+ log<level::ERR>("Failed to open input device",
+ entry("PATH=%s", pointerPath.c_str()),
+ entry("ERROR=%s", strerror(errno)));
+ }
+
+ pointerError = false;
+ sendPointer = false;
+ }
+}
+
void Input::sendWakeupPacket()
{
uint8_t wakeupReport[KEY_REPORT_LENGTH] = {0};
@@ -209,6 +239,12 @@ void Input::sendReport()
{
log<level::ERR>("Failed to write keyboard report",
entry("ERROR=%s", strerror(errno)));
+
+ if (errno == ESHUTDOWN)
+ {
+ close(keyboardFd);
+ keyboardFd = -1;
+ }
}
sendKeyboard = false;
@@ -225,6 +261,16 @@ void Input::sendReport()
entry("ERROR=%s", strerror(errno)));
pointerError = true;
}
+
+ if (errno == ESHUTDOWN)
+ {
+ close(pointerFd);
+ pointerFd = -1;
+ }
+ }
+ else
+ {
+ pointerError = false;
}
sendPointer = false;
diff --git a/ikvm_input.hpp b/ikvm_input.hpp
index 394591c..99170ba 100644
--- a/ikvm_input.hpp
+++ b/ikvm_input.hpp
@@ -48,6 +48,8 @@ class Input
*/
static void pointerEvent(int buttonMask, int x, int y, rfbClientPtr cl);
+ /* @brief Re-opens USB device in case the endpoint shutdown */
+ void restart();
/* @brief Sends a wakeup data packet to the USB input device */
void sendWakeupPacket();
/* @brief Sends an HID report to the USB input device */
diff --git a/ikvm_video.cpp b/ikvm_video.cpp
index 39947c6..6a5aa6c 100644
--- a/ikvm_video.cpp
+++ b/ikvm_video.cpp
@@ -31,8 +31,8 @@ using namespace sdbusplus::xyz::openbmc_project::Common::File::Error;
using namespace sdbusplus::xyz::openbmc_project::Common::Device::Error;
Video::Video(const std::string& p, Input& input, int fr) :
- resizeAfterOpen(false), fd(-1), frameRate(fr), lastFrameIndex(-1),
- height(600), width(800), input(input), path(p)
+ resizeAfterOpen(false), timingsError(false), fd(-1), frameRate(fr),
+ lastFrameIndex(-1), height(600), width(800), input(input), path(p)
{
}
@@ -153,11 +153,21 @@ bool Video::needsResize()
rc = ioctl(fd, VIDIOC_QUERY_DV_TIMINGS, &timings);
if (rc < 0)
{
- log<level::ERR>("Failed to query timings",
- entry("ERROR=%s", strerror(errno)));
+ if (!timingsError)
+ {
+ log<level::ERR>("Failed to query timings",
+ entry("ERROR=%s", strerror(errno)));
+ timingsError = true;
+ }
+
restart();
return false;
}
+ else if (timingsError)
+ {
+ timingsError = false;
+ input.restart();
+ }
if (timings.bt.width != width || timings.bt.height != height)
{
diff --git a/ikvm_video.hpp b/ikvm_video.hpp
index faaa57d..fb8c5da 100644
--- a/ikvm_video.hpp
+++ b/ikvm_video.hpp
@@ -129,6 +129,8 @@ class Video
* the open operation
*/
bool resizeAfterOpen;
+ /* @brief Indicates whether or not timings query was last sucessful */
+ bool timingsError;
/* @brief File descriptor for the V4L2 video device */
int fd;
/* @brief Desired frame rate of video stream in frames per second */
OpenPOWER on IntegriCloud