LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [Patch 2/2] cciss: add reboot notifier support to driver
@ 2007-02-21 21:12 Mike Miller (OS Dev)
2007-02-22 3:17 ` Andrew Morton
2007-02-22 3:33 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Mike Miller (OS Dev) @ 2007-02-21 21:12 UTC (permalink / raw)
To: jens.axboe, akpm; +Cc: linux-kernel, linux-scsi, gregkh
Patch 2/2
This patch adds reboot_notifier support to cciss. Changes in firmware make this patch
essential. Without this patch there may be valid data left in the controller's battery
backed write cache (BBWC) on shutdown. We found out the hard way that the kernel does
not call our cleanup routines on shutdown or reboot. It seems that only rmmod calls
the cleanup.
Please consider this for inclusion.
Signed-off-by: Mike Miller <mike.miller@hp.com
------------------------------------------------------------------------------------------
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 916aab0..1995b8c 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -45,6 +45,7 @@ #include <linux/dma-mapping.h>
#include <linux/blkdev.h>
#include <linux/genhd.h>
#include <linux/completion.h>
+#include <linux/reboot.h>
#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
#define DRIVER_NAME "HP CISS Driver (v 3.6.14)"
@@ -132,6 +133,7 @@ #define MAX_CTLR 32
#define MAX_CTLR_ORIG 8
static ctlr_info_t *hba[MAX_CTLR];
+static int notify_count=0;
static void do_cciss_request(request_queue_t *q);
static irqreturn_t do_cciss_intr(int irq, void *dev_id);
@@ -142,6 +144,8 @@ static int cciss_ioctl(struct inode *ino
static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo);
static int cciss_revalidate(struct gendisk *disk);
+static int cciss_notify_reboot(struct notifier_block *this,
+ unsigned long code, void *x);
static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk);
static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
int clear_all);
@@ -193,6 +197,36 @@ #endif
.revalidate_disk = cciss_revalidate,
};
+static struct notifier_block cciss_notifier = {
+ .notifier_call = cciss_notify_reboot,
+};
+
+static int cciss_notify_reboot(struct notifier_block *this,
+ unsigned long code, void *x)
+{
+ int i, return_code;
+ char flush_buf[4];
+
+ if ((code == SYS_DOWN) || (code == SYS_HALT) ||
+ (code == SYS_POWER_OFF)) {
+ printk(KERN_INFO "cciss: stopping all cciss devices.\n");
+ /* double check that all controller entrys have been removed */
+ for (i = 0; i < MAX_CTLR; i++) {
+ if (hba[i] != NULL) {
+ printk(KERN_WARNING "cciss: removing "
+ "controller %d\n", i);
+ /* flush data in battery backed cache to disks */
+ memset(flush_buf, 0, 4);
+ return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL, TYPE_CMD);
+ if(return_code != IO_OK) {
+ printk(KERN_WARNING "Error Flushing cache on "
+ " controller %d\n", i);
+ }
+ }
+ }
+ }
+ return NOTIFY_DONE;
+}
/*
* Enqueuing and dequeuing functions for cmdlists.
*/
@@ -3293,6 +3327,12 @@ #endif
((hba[i]->nr_cmds + BITS_PER_LONG -
1) / BITS_PER_LONG) * sizeof(unsigned long));
+ if (notify_count == 0) {
+ register_reboot_notifier(&cciss_notifier);
+ notify_count=1;
+ }
+
+
#ifdef CCISS_DEBUG
printk(KERN_DEBUG "Scanning for drives on controller cciss%d\n", i);
#endif /* CCISS_DEBUG */
@@ -3500,6 +3540,7 @@ static void __exit cciss_cleanup(void)
int i;
pci_unregister_driver(&cciss_pci_driver);
+ unregister_reboot_notifier(&cciss_notifier);
/* double check that all controller entrys have been removed */
for (i = 0; i < MAX_CTLR; i++) {
if (hba[i] != NULL) {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Patch 2/2] cciss: add reboot notifier support to driver
2007-02-21 21:12 [Patch 2/2] cciss: add reboot notifier support to driver Mike Miller (OS Dev)
@ 2007-02-22 3:17 ` Andrew Morton
2007-02-22 3:33 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2007-02-22 3:17 UTC (permalink / raw)
To: mike.miller
Cc: Mike Miller (OS Dev), jens.axboe, linux-kernel, linux-scsi, gregkh
On Wed, 21 Feb 2007 15:12:51 -0600 "Mike Miller (OS Dev)" <mikem@beardog.cca.cpqcorp.net> wrote:
> @@ -3293,6 +3327,12 @@ #endif
> ((hba[i]->nr_cmds + BITS_PER_LONG -
> 1) / BITS_PER_LONG) * sizeof(unsigned long));
>
> + if (notify_count == 0) {
> + register_reboot_notifier(&cciss_notifier);
> + notify_count=1;
> + }
> +
> +
> #ifdef CCISS_DEBUG
> printk(KERN_DEBUG "Scanning for drives on controller cciss%d\n", i);
> #endif /* CCISS_DEBUG */
> @@ -3500,6 +3540,7 @@ static void __exit cciss_cleanup(void)
> int i;
>
> pci_unregister_driver(&cciss_pci_driver);
> + unregister_reboot_notifier(&cciss_notifier);
Should we check that it was registered before going and unregistering
it? ie: do `modprobe cciss' on a machine which has no cciss hardware,
then do rmmod...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch 2/2] cciss: add reboot notifier support to driver
2007-02-21 21:12 [Patch 2/2] cciss: add reboot notifier support to driver Mike Miller (OS Dev)
2007-02-22 3:17 ` Andrew Morton
@ 2007-02-22 3:33 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2007-02-22 3:33 UTC (permalink / raw)
To: mike.miller; +Cc: jens.axboe, akpm, linux-kernel, linux-scsi, gregkh
On Wed, Feb 21, 2007 at 03:12:51PM -0600, Mike Miller (OS Dev) wrote:
> Patch 2/2
>
> This patch adds reboot_notifier support to cciss. Changes in firmware make this patch
> essential. Without this patch there may be valid data left in the controller's battery
> backed write cache (BBWC) on shutdown. We found out the hard way that the kernel does
> not call our cleanup routines on shutdown or reboot. It seems that only rmmod calls
> the cleanup.
> Please consider this for inclusion.
>
NAK. This should be using the shutdown method in struct pci_driver instead.
I really wish we wouldn't export the reboot_notifier so people don't repeat
this mistake over and over again..
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-02-22 3:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-21 21:12 [Patch 2/2] cciss: add reboot notifier support to driver Mike Miller (OS Dev)
2007-02-22 3:17 ` Andrew Morton
2007-02-22 3:33 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).