zkey: Also check for deconfigured and check-stopped cards

When checking if a card or an APQN is online, not only check the 'online'
sysfs attribute, but also check the 'config' and 'chkstop' attribute.
Cards and APQNs in check-stopped or deconfigured state can still be reported
as online via the sysfs attribute, although they are not available to be
used for zkey.

In case the 2 additional sysfs attributes are not available in sysfs, then
don't fail, but rely on the 'online' attribute only.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2023-10-25 15:38:56 +02:00
committed by Jan Höppner
parent 8a783b81a4
commit 54937495e2

View File

@@ -49,7 +49,7 @@
*/
int sysfs_is_card_online(unsigned int card, enum card_type cardtype)
{
long int online;
long int online, config, chkstop;
char *dev_path;
char type[20];
int rc = 1;
@@ -67,6 +67,16 @@ int sysfs_is_card_online(unsigned int card, enum card_type cardtype)
rc = 0;
goto out;
}
if (util_file_read_l(&config, 10, "%s/config", dev_path) == 0 &&
config == 0) {
rc = 0;
goto out;
}
if (util_file_read_l(&chkstop, 10, "%s/chkstop", dev_path) == 0 &&
chkstop != 0) {
rc = 0;
goto out;
}
if (util_file_read_line(type, sizeof(type), "%s/type", dev_path) != 0) {
rc = 0;
goto out;
@@ -111,7 +121,7 @@ out:
int sysfs_is_apqn_online(unsigned int card, unsigned int domain,
enum card_type cardtype)
{
long int online;
long int online, config, chkstop;
char *dev_path;
int rc = 1;
@@ -133,6 +143,16 @@ int sysfs_is_apqn_online(unsigned int card, unsigned int domain,
rc = 0;
goto out;
}
if (util_file_read_l(&config, 10, "%s/config", dev_path) == 0 &&
config == 0) {
rc = 0;
goto out;
}
if (util_file_read_l(&chkstop, 10, "%s/chkstop", dev_path) == 0 &&
chkstop != 0) {
rc = 0;
goto out;
}
out:
free(dev_path);