All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charles Chiou <ch1102chiou@gmail.com>
To: JBottomley@parallels.com, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org
Subject: [V2 PATCH 4/4] scsi:stex.c Add S3/S4 support
Date: Wed, 12 Nov 2014 11:41:37 +0800	[thread overview]
Message-ID: <5462D6F1.7050006@gmail.com> (raw)

 From d0bc6b814e5a16bea639bbdfad992a5593bf3420 Mon Sep 17 00:00:00 2001
From: Charles Chiou <charles.chiou@tw.promise.com>
Date: Fri, 7 Nov 2014 10:15:18 +0800
Subject: [PATCH 4/4] scsi:stex.c Add S3/S4 support

1. Add S3/S4 support, add .suspend and .resume function in pci_driver.

2. Pegasus take some to init, I create one thread to finish handshake
    to make OS can start faster.

3. According to (2), OS might send command to driver before handshake.
    Return SCSI_MLQUEUE_HOST_BUSY.

Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>

---
  drivers/scsi/stex.c | 57 
++++++++++++++++++++++++++++++++++++++++++++++++++++-
  1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 7a66a931..1e0b37e 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -369,6 +369,10 @@ static const char console_inq_page[] =
  	0x0C,0x20,0x20,0x20,0x20,0x20,0x20,0x20
  };

+struct hba_handshake_workstruct {
+	struct st_hba *hba;
+	struct work_struct handshake_work;
+};
  MODULE_AUTHOR("Ed Lin");
  MODULE_DESCRIPTION("Promise Technology SuperTrak EX Controllers");
  MODULE_LICENSE("GPL");
@@ -630,7 +634,7 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void 
(*done)(struct scsi_cmnd *))
  		done(cmd);
  		return 0;
  	}
-	if (unlikely(hba->mu_status == MU_STATE_RESETTING))
+	if (unlikely(hba->mu_status != MU_STATE_STARTED))
  		return SCSI_MLQUEUE_HOST_BUSY;

  	switch (cmd->cmnd[0]) {
@@ -1396,6 +1400,17 @@ static void stex_reset_work(struct work_struct *work)

  	stex_do_reset(hba);
  }
+static void resume_handshake(struct work_struct *work)
+{
+	struct st_hba *hba;
+	struct hba_handshake_workstruct *hswork;
+
+	hswork = container_of(work,
+		struct hba_handshake_workstruct,
+		handshake_work);
+	hba = hswork->hba;
+	stex_handshake(hba);
+}

  static int stex_biosparam(struct scsi_device *sdev,
  	struct block_device *bdev, sector_t capacity, int geom[])
@@ -1869,6 +1884,44 @@ static void stex_shutdown(struct pci_dev *pdev)
  	}
  }

+static int stex_choice_sleep_MIC(pm_message_t state)
+{
+	switch (state.event) {
+	case PM_EVENT_SUSPEND:
+		return ST_S3;
+	case PM_EVENT_FREEZE:
+	case PM_EVENT_HIBERNATE:
+		return ST_S4;
+	default:
+		return ST_S4;
+	}
+}
+
+static int stex_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	struct st_hba *hba = pci_get_drvdata(pdev);
+
+	if (hba->cardtype == st_yel && hba->yellowstone == 0)
+		stex_hba_stop(hba, stex_choice_sleep_MIC(state));
+	else
+		stex_hba_stop(hba, ST_IGNORED);
+	return 0;
+}
+
+
+static int stex_resume(struct pci_dev *pdev)
+{
+	struct st_hba *hba = pci_get_drvdata(pdev);
+	struct hba_handshake_workstruct *hswork;
+	int sts;
+
+
+	hswork = kzalloc(sizeof(struct hba_handshake_workstruct), GFP_KERNEL);
+	INIT_WORK(&hswork->handshake_work, resume_handshake);
+	hswork->hba = hba;
+	sts = schedule_work(&hswork->handshake_work);
+	return 0;
+}
  MODULE_DEVICE_TABLE(pci, stex_pci_tbl);

  static struct pci_driver stex_pci_driver = {
@@ -1877,6 +1930,8 @@ static struct pci_driver stex_pci_driver = {
  	.probe		= stex_probe,
  	.remove		= stex_remove,
  	.shutdown	= stex_shutdown,
+	.suspend	= stex_suspend,
+	.resume	= stex_resume,
  };

  static struct notifier_block stex_reboot_notifier = {
-- 
1.9.1


                 reply	other threads:[~2014-11-12  3:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=5462D6F1.7050006@gmail.com \
    --to=ch1102chiou@gmail.com \
    --cc=JBottomley@parallels.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.