[Pdbg] [PATCH v2 2/3] libsbefifo: Add long read timeout API
Joel Stanley
joel at jms.id.au
Wed Feb 23 16:34:45 AEDT 2022
From: Amitay Isaacs <amitay at ozlabs.org>
Add a function to set the long read timeout on a sbefifo context, and to
reset it afterwards.
This will be used by chip-ops that require a long timeout.
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
Signed-off-by: Joel Stanley <joel at jms.id.au>
---
v2: Split out setting of long timeout from patch
Correct ioctl unimplemented errno
libsbefifo/sbefifo_private.h | 2 ++
libsbefifo/connect.c | 41 ++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h
index 3c5ebcefb288..373f7f3c90ed 100644
--- a/libsbefifo/sbefifo_private.h
+++ b/libsbefifo/sbefifo_private.h
@@ -83,6 +83,8 @@ struct sbefifo_context {
uint32_t ffdc_len;
};
+int sbefifo_set_long_timeout(struct sbefifo_context *sctx);
+int sbefifo_reset_timeout(struct sbefifo_context *sctx);
void sbefifo_debug(const char *fmt, ...);
void sbefifo_ffdc_clear(struct sbefifo_context *sctx);
diff --git a/libsbefifo/connect.c b/libsbefifo/connect.c
index 1d23af5ec896..27e8976cb2dc 100644
--- a/libsbefifo/connect.c
+++ b/libsbefifo/connect.c
@@ -21,6 +21,17 @@
#include <errno.h>
#include <stdarg.h>
#include <stdbool.h>
+#include <sys/ioctl.h>
+
+#ifdef HAVE_LINUX_FSI_H
+#include <linux/fsi.h>
+#else
+#include <linux/ioctl.h>
+#endif /* HAVE_LINUX_FSI_H */
+
+#ifndef FSI_SBEFIFO_READ_TIMEOUT
+#define FSI_SBEFIFO_READ_TIMEOUT _IOW('s', 0x00, unsigned int)
+#endif
#include "libsbefifo.h"
#include "sbefifo_private.h"
@@ -106,6 +117,36 @@ int sbefifo_proc(struct sbefifo_context *sctx)
return sctx->proc;
}
+int sbefifo_set_long_timeout(struct sbefifo_context *sctx)
+{
+ unsigned int long_timeout = 30;
+ int rc;
+
+ LOG("long_timeout: %u sec\n", long_timeout);
+ rc = ioctl(sctx->fd, FSI_SBEFIFO_READ_TIMEOUT, &long_timeout);
+ if (rc == -1 && errno == ENOTTY) {
+ /* Do not fail if kernel does not implement ioctl */
+ rc = 0;
+ }
+
+ return rc;
+}
+
+int sbefifo_reset_timeout(struct sbefifo_context *sctx)
+{
+ unsigned int timeout = 0;
+ int rc;
+
+ LOG("reset_timeout\n");
+ rc = ioctl(sctx->fd, FSI_SBEFIFO_READ_TIMEOUT, &timeout);
+ if (rc == -1 && errno == ENOTTY) {
+ /* Do not fail if kernel does not implement ioctl */
+ rc = 0;
+ }
+
+ return rc;
+}
+
void sbefifo_debug(const char *fmt, ...)
{
va_list ap;
--
2.34.1
More information about the Pdbg
mailing list