]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
s390/cio: Fix CHPID "configure" attribute caching
authorPeter Oberparleiter <oberpar@linux.ibm.com>
Fri, 31 Jan 2025 11:02:55 +0000 (12:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:30:50 +0000 (14:30 +0200)
[ Upstream commit 32ae4a2992529e2c7934e422035fad1d9b0f1fb5 ]

In some environments, the SCLP firmware interface used to query a
CHPID's configured state is not supported. On these environments,
rapidly reading the corresponding sysfs attribute produces inconsistent
results:

  $ cat /sys/devices/css0/chp0.00/configure
  cat: /sys/devices/css0/chp0.00/configure: Operation not supported
  $ cat /sys/devices/css0/chp0.00/configure
  3

This occurs for example when Linux is run as a KVM guest. The
inconsistency is a result of CIO using cached results for generating
the value of the "configure" attribute while failing to handle the
situation where no data was returned by SCLP.

Fix this by not updating the cache-expiration timestamp when SCLP
returns no data. With the fix applied, the system response is
consistent:

  $ cat /sys/devices/css0/chp0.00/configure
  cat: /sys/devices/css0/chp0.00/configure: Operation not supported
  $ cat /sys/devices/css0/chp0.00/configure
  cat: /sys/devices/css0/chp0.00/configure: Operation not supported

Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Tested-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/s390/cio/chp.c

index 93e22785a0e092c60a9b0e245a599da376823dba..0b84ced33b3cab5c2c1b393009e4b00421b1dae5 100644 (file)
@@ -646,7 +646,8 @@ static int info_update(void)
        if (time_after(jiffies, chp_info_expires)) {
                /* Data is too old, update. */
                rc = sclp_chp_read_info(&chp_info);
-               chp_info_expires = jiffies + CHP_INFO_UPDATE_INTERVAL ;
+               if (!rc)
+                       chp_info_expires = jiffies + CHP_INFO_UPDATE_INTERVAL;
        }
        mutex_unlock(&info_lock);