Skip to content

Commit

Permalink
ipmi:ssif: Improve detecting during probing
Browse files Browse the repository at this point in the history
If an IPMI SSIF device is probed and there is something there, but
probably not an actual BMC, the code would just issue a lot of errors
before it failed.  We kind of need these errors to help with certain
issues, and some of the failure reports are non-fatal.

However, a get device id command should alway work.  If that fails,
nothing else is going to work and it's a pretty good indication that
there's no valid BMC there.  So issue and check that command and bail
if it fails.

Reported-by: Ivan T. Ivanov <iivanov@suse.de>
Signed-off-by: Corey Minyard <corey@minyard.net>
  • Loading branch information
Corey Minyard committed Aug 21, 2024
1 parent 0e38f7e commit 88f65f9
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion drivers/char/ipmi/ipmi_ssif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,20 @@ static int ssif_detect(struct i2c_client *client, struct i2c_board_info *info)
rv = do_cmd(client, 2, msg, &len, resp);
if (rv)
rv = -ENODEV;
else
else {
if (len < 3) {
rv = -ENODEV;
} else {
struct ipmi_device_id id;

rv = ipmi_demangle_device_id(resp[0] >> 2, resp[1],
resp + 2, len - 2, &id);
if (rv)
rv = -ENODEV; /* Error means a BMC probably isn't there. */
}
if (!rv && info)
strscpy(info->type, DEVICE_NAME, I2C_NAME_SIZE);
}
kfree(resp);
return rv;
}
Expand Down Expand Up @@ -1704,6 +1716,16 @@ static int ssif_probe(struct i2c_client *client)
ipmi_addr_src_to_str(ssif_info->addr_source),
client->addr, client->adapter->name, slave_addr);

/*
* Send a get device id command and validate its response to
* make sure a valid BMC is there.
*/
rv = ssif_detect(client, NULL);
if (rv) {
dev_err(&client->dev, "Not present\n");
goto out;
}

/* Now check for system interface capabilities */
msg[0] = IPMI_NETFN_APP_REQUEST << 2;
msg[1] = IPMI_GET_SYSTEM_INTERFACE_CAPABILITIES_CMD;
Expand Down

0 comments on commit 88f65f9

Please sign in to comment.