public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sumant Patro <sumantp@lsil.com>
To: James.Bottomley@SteelEye.com, linux-scsi@vger.kernel.org
Cc: akpm@osdl.org, hch@lst.de, linux-kernel@vger.kernel.org,
	Neela.Kolli@lsil.com, Bo.Yang@lsil.com
Subject: [Patch 4/7] megaraid_sas: adds reboot handler
Date: Wed, 20 Sep 2006 19:02:51 -0700	[thread overview]
Message-ID: <1158804171.4171.51.camel@dumbo> (raw)

[-- Attachment #1: Type: text/plain, Size: 2082 bytes --]

This patch adds handler to get reboot notification and fires flush command from 
the reboot notification handler. 

Signed-off-by: Sumant Patro <Sumant.Patro@lsil.com>


diff -uprN linux-2.6orig/drivers/scsi/megaraid/megaraid_sas.c linux-2.6new/drivers/scsi/megaraid/megaraid_sas.c
--- linux-2.6orig/drivers/scsi/megaraid/megaraid_sas.c 2006-09-20 11:04:34.000000000 -0700
+++ linux-2.6new/drivers/scsi/megaraid/megaraid_sas.c 2006-09-20 11:05:52.000000000 -0700
@@ -36,6 +36,8 @@
 #include <linux/fs.h>
 #include <linux/compat.h>
 #include <linux/mutex.h>
+#include <linux/reboot.h>
+#include <linux/notifier.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -2351,6 +2353,36 @@ static void megasas_flush_cache(struct m
 }
 
 /**
+ * megasas_reboot_notify- Flush adapter cache
+ * @this:   Our notifier block
+ * @code:   The event notified
+ * @unused:   Unused
+ */
+static int
+megasas_reboot_notify (struct notifier_block *this, unsigned long code,
+  void *unused)
+{
+	struct megasas_instance *instance;
+	int i;
+
+	for (i = 0; i < megasas_mgmt_info.max_index; i++) {
+		instance = megasas_mgmt_info.instance[i];
+		if (instance) {
+			megasas_flush_cache(instance);
+		}
+	}
+
+	return NOTIFY_DONE;
+}
+
+/**
+ * notifier block to get notification on system halt/reboot/shutdown/power off
+ */
+static struct notifier_block megasas_notifier = {
+	.notifier_call = megasas_reboot_notify
+};
+
+/**
  * megasas_shutdown_controller -	Instructs FW to shutdown the controller
  * @instance:				Adapter soft state
  */
@@ -2903,6 +2935,10 @@ static int __init megasas_init(void)
 	driver_create_file(&megasas_pci_driver.driver,
 			   &driver_attr_release_date);
 
+	if(register_reboot_notifier(&megasas_notifier)) {
+		printk("megasas: reboot notify routine registration failed!!\n");
+	}
+
 	return rval;
 }
 
@@ -2917,6 +2953,7 @@ static void __exit megasas_exit(void)
 
  pci_unregister_driver(&megasas_pci_driver);
  unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl");
+ unregister_reboot_notifier(&megasas_notifier);
 }
 
 module_init(megasas_init);


[-- Attachment #2: reboot_noti-p4.patch --]
[-- Type: text/x-patch, Size: 1911 bytes --]

diff -uprN linux-2.6orig/drivers/scsi/megaraid/megaraid_sas.c linux-2.6new/drivers/scsi/megaraid/megaraid_sas.c
--- linux-2.6orig/drivers/scsi/megaraid/megaraid_sas.c	2006-09-20 11:04:34.000000000 -0700
+++ linux-2.6new/drivers/scsi/megaraid/megaraid_sas.c	2006-09-20 11:05:52.000000000 -0700
@@ -36,6 +36,8 @@
 #include <linux/fs.h>
 #include <linux/compat.h>
 #include <linux/mutex.h>
+#include <linux/reboot.h>
+#include <linux/notifier.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -2351,6 +2353,36 @@ static void megasas_flush_cache(struct m
 }
 
 /**
+ * megasas_reboot_notify-	Flush adapter cache
+ * @this:			Our notifier block
+ * @code:			The event notified
+ * @unused:			Unused
+ */
+static int
+megasas_reboot_notify (struct notifier_block *this, unsigned long code,
+		void *unused)
+{
+	struct megasas_instance *instance;
+	int i;
+
+	for (i = 0; i < megasas_mgmt_info.max_index; i++) {
+		instance = megasas_mgmt_info.instance[i];
+		if (instance) {
+			megasas_flush_cache(instance);
+		}
+	}
+
+	return NOTIFY_DONE;
+}
+
+/**
+ * notifier block to get notification on system halt/reboot/shutdown/power off
+ */
+static struct notifier_block megasas_notifier = {
+	.notifier_call = megasas_reboot_notify
+};
+
+/**
  * megasas_shutdown_controller -	Instructs FW to shutdown the controller
  * @instance:				Adapter soft state
  */
@@ -2903,6 +2935,10 @@ static int __init megasas_init(void)
 	driver_create_file(&megasas_pci_driver.driver,
 			   &driver_attr_release_date);
 
+	if(register_reboot_notifier(&megasas_notifier)) {
+		printk("megasas: reboot notify routine registration failed!!\n");
+	}
+
 	return rval;
 }
 
@@ -2917,6 +2953,7 @@ static void __exit megasas_exit(void)
 
 	pci_unregister_driver(&megasas_pci_driver);
 	unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl");
+	unregister_reboot_notifier(&megasas_notifier);
 }
 
 module_init(megasas_init);

             reply	other threads:[~2006-09-21  1:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-21  2:02 Sumant Patro [this message]
2006-09-21 11:44 ` [Patch 4/7] megaraid_sas: adds reboot handler Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2006-09-21 21:36 Patro, Sumant

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=1158804171.4171.51.camel@dumbo \
    --to=sumantp@lsil.com \
    --cc=Bo.Yang@lsil.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=Neela.Kolli@lsil.com \
    --cc=akpm@osdl.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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