From: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
To: james.bottomley@hansenpartnership.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
stephenmcameron@gmail.com, thenzl@redhat.com,
akpm@linux-foundation.org, mikem@beardog.cce.hp.com
Subject: [PATCH] hpsa: add heartbeat sysfs host attribute
Date: Fri, 12 Aug 2011 13:03:14 -0500 [thread overview]
Message-ID: <20110812180314.21808.59261.stgit@beardog.cce.hp.com> (raw)
From: Stephen M. Cameron <scameron@beardog.cce.hp.com>
The cciss driver had a CCISS_HEARTBEAT ioctl which
was not implemented in hpsa. This ioctl returned a
counter from a register on the Smart Array which the
firmware would periodically update. It can be used
to detect certain kinds of faults (e.g. controller
lockup) by noticing when the value remains constant
for more than a second or two.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
Documentation/scsi/hpsa.txt | 8 ++++++++
drivers/scsi/hpsa.c | 18 ++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/Documentation/scsi/hpsa.txt b/Documentation/scsi/hpsa.txt
index 891435a..0dac1e0 100644
--- a/Documentation/scsi/hpsa.txt
+++ b/Documentation/scsi/hpsa.txt
@@ -47,6 +47,7 @@ HPSA specific entries in /sys
/sys/class/scsi_host/host*/firmware_revision
/sys/class/scsi_host/host*/resettable
/sys/class/scsi_host/host*/transport_mode
+ /sys/class/scsi_host/host*/heartbeat
the host "rescan" attribute is a write only attribute. Writing to this
attribute will cause the driver to scan for new, changed, or removed devices
@@ -78,6 +79,13 @@ HPSA specific entries in /sys
kexec tools to warn the user if they attempt to designate a device which is
unable to honor the reset_devices kernel parameter as a dump device.
+ The "heartbeat" read-only attribute returns the value of a heartbeat
+ counter register on a Smart Array controller as a 32 bit unsigned
+ hexadecimal integer (e.g: "0x12345678"). The value should change
+ periodically, not less than once per second. If this value fails to
+ change for a period longer than one second, it means something has
+ gone wrong (e.g. Smart Array controller firmware has locked up.)
+
HPSA specific disk attributes:
------------------------------
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index b200b73..ce6bde4 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -340,6 +340,21 @@ static ssize_t host_show_resettable(struct device *dev,
return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id));
}
+static ssize_t host_show_heartbeat(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ctlr_info *h;
+ struct Scsi_Host *shost = class_to_shost(dev);
+ u32 heartbeat;
+ unsigned long flags;
+
+ h = shost_to_hba(shost);
+ spin_lock_irqsave(&h->lock, flags);
+ heartbeat = readl(&h->cfgtable->HeartBeat);
+ spin_unlock_irqrestore(&h->lock, flags);
+ return snprintf(buf, 20, "0x%08x\n", heartbeat);
+}
+
static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
{
return (scsi3addr[3] & 0xC0) == 0x40;
@@ -448,6 +463,8 @@ static DEVICE_ATTR(transport_mode, S_IRUGO,
host_show_transport_mode, NULL);
static DEVICE_ATTR(resettable, S_IRUGO,
host_show_resettable, NULL);
+static DEVICE_ATTR(heartbeat, S_IRUGO,
+ host_show_heartbeat, NULL);
static struct device_attribute *hpsa_sdev_attrs[] = {
&dev_attr_raid_level,
@@ -462,6 +479,7 @@ static struct device_attribute *hpsa_shost_attrs[] = {
&dev_attr_commands_outstanding,
&dev_attr_transport_mode,
&dev_attr_resettable,
+ &dev_attr_heartbeat,
NULL,
};
next reply other threads:[~2011-08-12 18:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-12 18:03 Stephen M. Cameron [this message]
2011-08-13 2:01 ` [PATCH] hpsa: add heartbeat sysfs host attribute Greg KH
2011-08-15 14:40 ` scameron
2011-08-15 15:04 ` scameron
2011-08-15 15:45 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110812180314.21808.59261.stgit@beardog.cce.hp.com \
--to=scameron@beardog.cce.hp.com \
--cc=akpm@linux-foundation.org \
--cc=james.bottomley@hansenpartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mikem@beardog.cce.hp.com \
--cc=stephenmcameron@gmail.com \
--cc=thenzl@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox