Commit 68b759a7 authored by Shannon Nelson's avatar Shannon Nelson Committed by David S. Miller

ionic: fix fw_status read

The fw_status field is only 8 bits, so fix the read.  Also,
we only want to look at the one status bit, to allow for future
use of the other bits, and watch for a bad PCI read.

Fixes: 97ca4865 ("ionic: add heartbeat check")
Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 98bda63e
...@@ -103,7 +103,7 @@ int ionic_heartbeat_check(struct ionic *ionic) ...@@ -103,7 +103,7 @@ int ionic_heartbeat_check(struct ionic *ionic)
{ {
struct ionic_dev *idev = &ionic->idev; struct ionic_dev *idev = &ionic->idev;
unsigned long hb_time; unsigned long hb_time;
u32 fw_status; u8 fw_status;
u32 hb; u32 hb;
/* wait a little more than one second before testing again */ /* wait a little more than one second before testing again */
...@@ -111,9 +111,12 @@ int ionic_heartbeat_check(struct ionic *ionic) ...@@ -111,9 +111,12 @@ int ionic_heartbeat_check(struct ionic *ionic)
if (time_before(hb_time, (idev->last_hb_time + ionic->watchdog_period))) if (time_before(hb_time, (idev->last_hb_time + ionic->watchdog_period)))
return 0; return 0;
/* firmware is useful only if fw_status is non-zero */ /* firmware is useful only if the running bit is set and
fw_status = ioread32(&idev->dev_info_regs->fw_status); * fw_status != 0xff (bad PCI read)
if (!fw_status) */
fw_status = ioread8(&idev->dev_info_regs->fw_status);
if (fw_status == 0xff ||
!(fw_status & IONIC_FW_STS_F_RUNNING))
return -ENXIO; return -ENXIO;
/* early FW has no heartbeat, else FW will return non-zero */ /* early FW has no heartbeat, else FW will return non-zero */
......
...@@ -2445,6 +2445,7 @@ union ionic_dev_info_regs { ...@@ -2445,6 +2445,7 @@ union ionic_dev_info_regs {
u8 version; u8 version;
u8 asic_type; u8 asic_type;
u8 asic_rev; u8 asic_rev;
#define IONIC_FW_STS_F_RUNNING 0x1
u8 fw_status; u8 fw_status;
u32 fw_heartbeat; u32 fw_heartbeat;
char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN]; char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment