Skip to contentSkip to conversation

fsi: sbefifo: Add sysfs file indicating a timeout error

PATCH New Eddie James 1 participant 3 messages Oct 19, 2021 FSI

lore
Share & tools
lore

Eddie James

author maintainer
#0 lore raw

v2 cover fsi: sbefifo: Add sysfs file indicating a timeout error

Add a sysfs file in the SBEFIFO device driver to indicate a timeout error, and notify pollers when a timeout occurs. Document the file in the testing directory.

Changes since v1:
- Add the documentation

Eddie James (2):
docs: ABI: testing: Document the SBEFIFO timeout interface
fsi: sbefifo: Add sysfs file indicating a timeout error

 .../ABI/testing/sysfs-bus-fsi-devices-sbefifo    | 10 ++++++++++
 drivers/fsi/fsi-sbefifo.c                        | 16 ++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsi-devices-sbefifo
Signature · 1 line
2.27.0
author maintainer
#2 lore raw

PATCH v2 2/2 fsi: sbefifo: Add sysfs file indicating a timeout error

The SBEFIFO timeout error requires special handling in userspace to do recovery operations. Add a sysfs file to indicate a timeout error, and notify pollers when a timeout occurs.

---
 drivers/fsi/fsi-sbefifo.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/fsi/fsi-sbefifo.c +16 -0
index 84cb965bfed5..b414ab4431ef 100644
@@ -124,6 +124,7 @@ struct sbefifo {
 	bool			broken;
 	bool			dead;
 	bool			async_ffdc;
+	bool			timed_out;
 };
 
 struct sbefifo_user {
@@ -136,6 +137,14 @@ struct sbefifo_user {
 
 static DEFINE_MUTEX(sbefifo_ffdc_mutex);
 
+static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
+			    char *buf)
+{
+	struct sbefifo *sbefifo = container_of(dev, struct sbefifo, dev);
+
+	return sysfs_emit(buf, "%d\n", sbefifo->timed_out ? 1 : 0);
+}
+static DEVICE_ATTR_RO(timeout);
 
 static void __sbefifo_dump_ffdc(struct device *dev, const __be32 *ffdc,
 				size_t ffdc_sz, bool internal)
@@ -462,11 +471,14 @@ static int sbefifo_wait(struct sbefifo *sbefifo, bool up,
 			break;
 	}
 	if (!ready) {
+		sysfs_notify(&sbefifo->dev.kobj, NULL, dev_attr_timeout.attr.name);
+		sbefifo->timed_out = true;
 		dev_err(dev, "%s FIFO Timeout ! status=%08x\n", up ? "UP" : "DOWN", sts);
 		return -ETIMEDOUT;
 	}
 	dev_vdbg(dev, "End of wait status: %08x\n", sts);
 
+	sbefifo->timed_out = false;
 	*status = sts;
 
 	return 0;
@@ -993,6 +1005,8 @@ static int sbefifo_probe(struct device *dev)
 				 child_name);
 	}
 
+	device_create_file(&sbefifo->dev, &dev_attr_timeout);
+
 	return 0;
  err_free_minor:
 	fsi_free_minor(sbefifo->dev.devt);
@@ -1018,6 +1032,8 @@ static int sbefifo_remove(struct device *dev)
 
 	dev_dbg(dev, "Removing sbefifo device...\n");
 
+	device_remove_file(&sbefifo->dev, &dev_attr_timeout);
+
 	mutex_lock(&sbefifo->lock);
 	sbefifo->dead = true;
 	mutex_unlock(&sbefifo->lock);
Signature · 1 line
2.27.0
author maintainer
#1 lore raw

PATCH v2 1/2 docs: ABI: testing: Document the SBEFIFO timeout interface

In reply to Eddie James

Add documentation for the new sysfs entry that indicates whether or not the SBE has timed out.

---
 .../ABI/testing/sysfs-bus-fsi-devices-sbefifo          | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsi-devices-sbefifo
Documentation/ABI/testing/sysfs-bus-fsi-devices-sbefifo new file +10 -0
new file mode 100644
index 000000000000..531fe9d6b40a
@@ -0,0 +1,10 @@
+What:		/sys/bus/fsi/devices/XX.XX.00:06/sbefifoX/timeout
+KernelVersion:	5.15
+Contact:	[email protected]
+Description:
+		Indicates whether or not this SBE device has experienced a
+		timeout; i.e. the SBE did not respond within the time allotted
+		by the driver. A value of 1 indicates that a timeout has
+		ocurred and no transfers have completed since the timeout. A
+		value of 0 indicates that no timeout has ocurred, or if one
+		has, more recent transfers have completed successful.
Signature · 1 line
2.27.0