[SCSI] ibmvscsi: Add suspend/resume support
authorBrian King <brking@linux.vnet.ibm.com>
Sun, 21 Feb 2010 16:37:57 +0000 (10:37 -0600)
committerJames Bottomley <James.Bottomley@suse.de>
Wed, 3 Mar 2010 13:02:41 +0000 (18:32 +0530)
Adds support for resuming from suspend for IBM VSCSI devices. We may have
lost an interrupt over the suspend, so we just kick the interrupt handler
to process anything that is outstanding. We expect to find a transport event
indicating we need to reestablish our CRQ.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/ibmvscsi/ibmvscsi.c
drivers/scsi/ibmvscsi/ibmvscsi.h
drivers/scsi/ibmvscsi/iseries_vscsi.c
drivers/scsi/ibmvscsi/rpa_vscsi.c

index e3a18e0ef276511e33061eb86b8cfb5f8f763241..dc1bcbe3b1765789a09439d3cd2f6bbe34c34aa8 100644 (file)
@@ -71,6 +71,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/of.h>
+#include <linux/pm.h>
 #include <asm/firmware.h>
 #include <asm/vio.h>
 #include <scsi/scsi.h>
@@ -1990,6 +1991,19 @@ static int ibmvscsi_remove(struct vio_dev *vdev)
        return 0;
 }
 
+/**
+ * ibmvscsi_resume: Resume from suspend
+ * @dev:       device struct
+ *
+ * We may have lost an interrupt across suspend/resume, so kick the
+ * interrupt handler
+ */
+static int ibmvscsi_resume(struct device *dev)
+{
+       struct ibmvscsi_host_data *hostdata = dev_get_drvdata(dev);
+       return ibmvscsi_ops->resume(hostdata);
+}
+
 /**
  * ibmvscsi_device_table: Used by vio.c to match devices in the device tree we 
  * support.
@@ -2000,6 +2014,10 @@ static struct vio_device_id ibmvscsi_device_table[] __devinitdata = {
 };
 MODULE_DEVICE_TABLE(vio, ibmvscsi_device_table);
 
+static struct dev_pm_ops ibmvscsi_pm_ops = {
+       .resume = ibmvscsi_resume
+};
+
 static struct vio_driver ibmvscsi_driver = {
        .id_table = ibmvscsi_device_table,
        .probe = ibmvscsi_probe,
@@ -2008,6 +2026,7 @@ static struct vio_driver ibmvscsi_driver = {
        .driver = {
                .name = "ibmvscsi",
                .owner = THIS_MODULE,
+               .pm = &ibmvscsi_pm_ops,
        }
 };
 
index 76425303def0c0265b89db3ea656132cf7b756c8..9cb7c6a773e1a1f7a7550c67b9fa49213bacf6a1 100644 (file)
@@ -120,6 +120,7 @@ struct ibmvscsi_ops {
                                  struct ibmvscsi_host_data *hostdata);
        int (*send_crq)(struct ibmvscsi_host_data *hostdata,
                       u64 word1, u64 word2);
+       int (*resume) (struct ibmvscsi_host_data *hostdata);
 };
 
 extern struct ibmvscsi_ops iseriesvscsi_ops;
index 0775fdee5fa80cc4f9609167c8fc2e1769596d30..f4776451a7546fa015dbbe3452870858e5a28a8c 100644 (file)
@@ -158,10 +158,16 @@ static int iseriesvscsi_send_crq(struct ibmvscsi_host_data *hostdata,
                                             0);
 }
 
+static int iseriesvscsi_resume(struct ibmvscsi_host_data *hostdata)
+{
+       return 0;
+}
+
 struct ibmvscsi_ops iseriesvscsi_ops = {
        .init_crq_queue = iseriesvscsi_init_crq_queue,
        .release_crq_queue = iseriesvscsi_release_crq_queue,
        .reset_crq_queue = iseriesvscsi_reset_crq_queue,
        .reenable_crq_queue = iseriesvscsi_reenable_crq_queue,
        .send_crq = iseriesvscsi_send_crq,
+       .resume = iseriesvscsi_resume,
 };
index 462a8574dad96ffa6020c9aa27886c545b8a7988..63a30cbbf9de5396629b9e061fc9438b88ea56b0 100644 (file)
@@ -334,10 +334,23 @@ static int rpavscsi_reenable_crq_queue(struct crq_queue *queue,
        return rc;
 }
 
+/**
+ * rpavscsi_resume: - resume after suspend
+ * @hostdata:  ibmvscsi_host_data of host
+ *
+ */
+static int rpavscsi_resume(struct ibmvscsi_host_data *hostdata)
+{
+       vio_disable_interrupts(to_vio_dev(hostdata->dev));
+       tasklet_schedule(&hostdata->srp_task);
+       return 0;
+}
+
 struct ibmvscsi_ops rpavscsi_ops = {
        .init_crq_queue = rpavscsi_init_crq_queue,
        .release_crq_queue = rpavscsi_release_crq_queue,
        .reset_crq_queue = rpavscsi_reset_crq_queue,
        .reenable_crq_queue = rpavscsi_reenable_crq_queue,
        .send_crq = rpavscsi_send_crq,
+       .resume = rpavscsi_resume,
 };