diff mbox series

fsi: sbefifo: Add sysfs file indicating a timeout error

Message ID 20210920190031.22168-1-eajames@linux.ibm.com
State New
Headers show
Series fsi: sbefifo: Add sysfs file indicating a timeout error | expand

Commit Message

Eddie James Sept. 20, 2021, 7 p.m. UTC
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.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/fsi/fsi-sbefifo.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Joel Stanley Oct. 15, 2021, 5:08 a.m. UTC | #1
On Mon, 20 Sept 2021 at 19:00, Eddie James <eajames@linux.ibm.com> wrote:
>
> 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.

Should this have some documentation too?

What userspace uses this?

Looks good to me otherwise.

Reviewed-by: Joel Stanley <joel@jms.id.au>

>
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> ---
>  drivers/fsi/fsi-sbefifo.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
> index 84cb965bfed5..b414ab4431ef 100644
> --- a/drivers/fsi/fsi-sbefifo.c
> +++ b/drivers/fsi/fsi-sbefifo.c
> @@ -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);
> --
> 2.27.0
>
Eddie James Oct. 19, 2021, 8:24 p.m. UTC | #2
On 10/15/21 12:08 AM, Joel Stanley wrote:
> On Mon, 20 Sept 2021 at 19:00, Eddie James <eajames@linux.ibm.com> wrote:
>> 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.
> Should this have some documentation too?


Yes, will add in v2.


>
> What userspace uses this?


At the moment, the openpower-occ-control application.


>
> Looks good to me otherwise.
>
> Reviewed-by: Joel Stanley <joel@jms.id.au>


Thanks!

Eddie


>
>> Signed-off-by: Eddie James <eajames@linux.ibm.com>
>> ---
>>   drivers/fsi/fsi-sbefifo.c | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
>> index 84cb965bfed5..b414ab4431ef 100644
>> --- a/drivers/fsi/fsi-sbefifo.c
>> +++ b/drivers/fsi/fsi-sbefifo.c
>> @@ -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);
>> --
>> 2.27.0
>>
diff mbox series

Patch

diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
index 84cb965bfed5..b414ab4431ef 100644
--- a/drivers/fsi/fsi-sbefifo.c
+++ b/drivers/fsi/fsi-sbefifo.c
@@ -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);