All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] scsi:stex.c Add S3/S4 support
@ 2015-09-03 12:39 Charles Chiou
  2015-09-03 14:03 ` Johannes Thumshirn
  0 siblings, 1 reply; 8+ messages in thread
From: Charles Chiou @ 2015-09-03 12:39 UTC (permalink / raw)
  To: Charles Chiou, Christoph Hellwig, JBottomley, Oliver Neukum
  Cc: grace.chang, linus.chen, victor.p, linux-scsi, linux-kernel


 From f442518879f8f41d103b684046d912eca13844e7 Mon Sep 17 00:00:00 2001
From: Charles <charles.chiou@tw.promise.com>
Date: Wed, 2 Sep 2015 20:54:45 +0800
Subject: [PATCH 3/3] scsi:stex.c Add S3/S4 support

Add S3/S4 support, add .suspend and .resume function in pci_driver.
In .suspend handler, driver send S3/S4 signal to the device.

V2: Remove blank lines

Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>
---
  drivers/scsi/stex.c | 59 
++++++++++++++++++++++++++++++++++++++++++++++++++---
  1 file changed, 56 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 4ef0c80..c96a86d 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -166,6 +166,13 @@ enum {

  	ST_ADDITIONAL_MEM			= 0x200000,
  	ST_ADDITIONAL_MEM_MIN			= 0x80000,
+	PMIC_SHUTDOWN				= 0x0D,
+	PMIC_REUMSE					= 0x10,
+	ST_IGNORED					= -1,
+	ST_S3						= 3,
+	ST_S4						= 4,
+	ST_S5						= 5,
+	ST_S6						= 6,
  };

  struct st_sgitem {
@@ -1733,7 +1740,7 @@ out_disable:
  	return err;
  }

-static void stex_hba_stop(struct st_hba *hba)
+static void stex_hba_stop(struct st_hba *hba, int st_sleep_mic)
  {
  	struct req_msg *req;
  	struct st_msg_header *msg_h;
@@ -1749,11 +1756,18 @@ static void stex_hba_stop(struct st_hba *hba)
  	} else
  		memset(req, 0, hba->rq_size);

-	if (hba->cardtype == st_yosemite || hba->cardtype == st_yel) {
+	if ((hba->cardtype == st_yosemite || hba->cardtype == st_yel)
+		&& st_sleep_mic == ST_IGNORED) {
  		req->cdb[0] = MGT_CMD;
  		req->cdb[1] = MGT_CMD_SIGNATURE;
  		req->cdb[2] = CTLR_CONFIG_CMD;
  		req->cdb[3] = CTLR_SHUTDOWN;
+	} else if (hba->cardtype == st_yel && st_sleep_mic != ST_IGNORED) {
+		req->cdb[0] = MGT_CMD;
+		req->cdb[1] = MGT_CMD_SIGNATURE;
+		req->cdb[2] = CTLR_CONFIG_CMD;
+		req->cdb[3] = PMIC_SHUTDOWN;
+		req->cdb[4] = st_sleep_mic;
  	} else {
  		req->cdb[0] = CONTROLLER_CMD;
  		req->cdb[1] = CTLR_POWER_STATE_CHANGE;
@@ -1773,10 +1787,12 @@ static void stex_hba_stop(struct st_hba *hba)
  	while (hba->ccb[tag].req_type & PASSTHRU_REQ_TYPE) {
  		if (time_after(jiffies, before + ST_INTERNAL_TIMEOUT * HZ)) {
  			hba->ccb[tag].req_type = 0;
+			hba->mu_status = MU_STATE_STOP;
  			return;
  		}
  		msleep(1);
  	}
+	hba->mu_status = MU_STATE_STOP;
  }

  static void stex_hba_free(struct st_hba *hba)
@@ -1816,9 +1832,44 @@ static void stex_shutdown(struct pci_dev *pdev)
  {
  	struct st_hba *hba = pci_get_drvdata(pdev);

-	stex_hba_stop(hba);
+	if (hba->supports_pm == 0)
+		stex_hba_stop(hba, ST_IGNORED);
+	else
+		stex_hba_stop(hba, ST_S5);
+}
+
+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->supports_pm == 1)
+		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);
+
+	hba->mu_status = MU_STATE_STARTING;
+	stex_handshake(hba);
+	return 0;
+}
  MODULE_DEVICE_TABLE(pci, stex_pci_tbl);

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

  static int __init stex_init(void)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] scsi:stex.c Add S3/S4 support
  2015-09-03 12:39 [PATCH 3/3] scsi:stex.c Add S3/S4 support Charles Chiou
@ 2015-09-03 14:03 ` Johannes Thumshirn
  2016-01-29 11:23   ` Charles Chiou
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2015-09-03 14:03 UTC (permalink / raw)
  To: Charles Chiou
  Cc: Christoph Hellwig, JBottomley, Oliver Neukum, grace.chang,
	linus.chen, victor.p, linux-scsi, linux-kernel

Charles Chiou <ch1102chiou@gmail.com> writes:

> From f442518879f8f41d103b684046d912eca13844e7 Mon Sep 17 00:00:00 2001
> From: Charles <charles.chiou@tw.promise.com>
> Date: Wed, 2 Sep 2015 20:54:45 +0800
> Subject: [PATCH 3/3] scsi:stex.c Add S3/S4 support
>
> Add S3/S4 support, add .suspend and .resume function in pci_driver.
> In .suspend handler, driver send S3/S4 signal to the device.
>
> V2: Remove blank lines
>
> Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>
> ---
>  drivers/scsi/stex.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 56 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index 4ef0c80..c96a86d 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -166,6 +166,13 @@ enum {
>
>  	ST_ADDITIONAL_MEM			= 0x200000,
>  	ST_ADDITIONAL_MEM_MIN			= 0x80000,
> +	PMIC_SHUTDOWN				= 0x0D,
> +	PMIC_REUMSE					= 0x10,
> +	ST_IGNORED					= -1,
> +	ST_S3						= 3,
> +	ST_S4						= 4,
> +	ST_S5						= 5,
> +	ST_S6						= 6,
>  };
>
>  struct st_sgitem {
> @@ -1733,7 +1740,7 @@ out_disable:
>  	return err;
>  }
>
> -static void stex_hba_stop(struct st_hba *hba)
> +static void stex_hba_stop(struct st_hba *hba, int st_sleep_mic)
>  {
>  	struct req_msg *req;
>  	struct st_msg_header *msg_h;
> @@ -1749,11 +1756,18 @@ static void stex_hba_stop(struct st_hba *hba)
>  	} else
>  		memset(req, 0, hba->rq_size);
>
> -	if (hba->cardtype == st_yosemite || hba->cardtype == st_yel) {
> +	if ((hba->cardtype == st_yosemite || hba->cardtype == st_yel)
> +		&& st_sleep_mic == ST_IGNORED) {
>  		req->cdb[0] = MGT_CMD;
>  		req->cdb[1] = MGT_CMD_SIGNATURE;
>  		req->cdb[2] = CTLR_CONFIG_CMD;
>  		req->cdb[3] = CTLR_SHUTDOWN;
> +	} else if (hba->cardtype == st_yel && st_sleep_mic != ST_IGNORED) {
> +		req->cdb[0] = MGT_CMD;
> +		req->cdb[1] = MGT_CMD_SIGNATURE;
> +		req->cdb[2] = CTLR_CONFIG_CMD;
> +		req->cdb[3] = PMIC_SHUTDOWN;
> +		req->cdb[4] = st_sleep_mic;
>  	} else {
>  		req->cdb[0] = CONTROLLER_CMD;
>  		req->cdb[1] = CTLR_POWER_STATE_CHANGE;
> @@ -1773,10 +1787,12 @@ static void stex_hba_stop(struct st_hba *hba)
>  	while (hba->ccb[tag].req_type & PASSTHRU_REQ_TYPE) {
>  		if (time_after(jiffies, before + ST_INTERNAL_TIMEOUT * HZ)) {
>  			hba->ccb[tag].req_type = 0;
> +			hba->mu_status = MU_STATE_STOP;
>  			return;
>  		}
>  		msleep(1);
>  	}
> +	hba->mu_status = MU_STATE_STOP;
>  }
>
>  static void stex_hba_free(struct st_hba *hba)
> @@ -1816,9 +1832,44 @@ static void stex_shutdown(struct pci_dev *pdev)
>  {
>  	struct st_hba *hba = pci_get_drvdata(pdev);
>
> -	stex_hba_stop(hba);
> +	if (hba->supports_pm == 0)
> +		stex_hba_stop(hba, ST_IGNORED);
> +	else
> +		stex_hba_stop(hba, ST_S5);
> +}
> +
> +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->supports_pm == 1)
> +		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);
> +
> +	hba->mu_status = MU_STATE_STARTING;
> +	stex_handshake(hba);
> +	return 0;
> +}
>  MODULE_DEVICE_TABLE(pci, stex_pci_tbl);
>
>  static struct pci_driver stex_pci_driver = {
> @@ -1827,6 +1878,8 @@ static struct pci_driver stex_pci_driver = {
>  	.probe		= stex_probe,
>  	.remove		= stex_remove,
>  	.shutdown	= stex_shutdown,
> +	.suspend	= stex_suspend,
> +	.resume		= stex_resume,
>  };
>
>  static int __init stex_init(void)

Looks OK from my side
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

-- 
Johannes Thumshirn                                           Storage
jthumshirn@suse.de                                 +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] scsi:stex.c Add S3/S4 support
  2015-09-03 14:03 ` Johannes Thumshirn
@ 2016-01-29 11:23   ` Charles Chiou
  2016-02-04 11:22     ` [Resend PATCH " Charles Chiou
  0 siblings, 1 reply; 8+ messages in thread
From: Charles Chiou @ 2016-01-29 11:23 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, JBottomley, Oliver Neukum, grace.chang,
	linus.chen, victor.p, linux-scsi, linux-kernel

Hi all, Ping?
Does this patch has others issues need to fix? Thank you.
Charles

On 09/03/2015 10:03 PM, Johannes Thumshirn wrote:
> Charles Chiou <ch1102chiou@gmail.com> writes:
>
>>  From f442518879f8f41d103b684046d912eca13844e7 Mon Sep 17 00:00:00 2001
>> From: Charles <charles.chiou@tw.promise.com>
>> Date: Wed, 2 Sep 2015 20:54:45 +0800
>> Subject: [PATCH 3/3] scsi:stex.c Add S3/S4 support
>>
>> Add S3/S4 support, add .suspend and .resume function in pci_driver.
>> In .suspend handler, driver send S3/S4 signal to the device.
>>
>> V2: Remove blank lines
>>
>> Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>
>> ---
>>   drivers/scsi/stex.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++---
>>   1 file changed, 56 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
>> index 4ef0c80..c96a86d 100644
>> --- a/drivers/scsi/stex.c
>> +++ b/drivers/scsi/stex.c
>> @@ -166,6 +166,13 @@ enum {
>>
>>   	ST_ADDITIONAL_MEM			= 0x200000,
>>   	ST_ADDITIONAL_MEM_MIN			= 0x80000,
>> +	PMIC_SHUTDOWN				= 0x0D,
>> +	PMIC_REUMSE					= 0x10,
>> +	ST_IGNORED					= -1,
>> +	ST_S3						= 3,
>> +	ST_S4						= 4,
>> +	ST_S5						= 5,
>> +	ST_S6						= 6,
>>   };
>>
>>   struct st_sgitem {
>> @@ -1733,7 +1740,7 @@ out_disable:
>>   	return err;
>>   }
>>
>> -static void stex_hba_stop(struct st_hba *hba)
>> +static void stex_hba_stop(struct st_hba *hba, int st_sleep_mic)
>>   {
>>   	struct req_msg *req;
>>   	struct st_msg_header *msg_h;
>> @@ -1749,11 +1756,18 @@ static void stex_hba_stop(struct st_hba *hba)
>>   	} else
>>   		memset(req, 0, hba->rq_size);
>>
>> -	if (hba->cardtype == st_yosemite || hba->cardtype == st_yel) {
>> +	if ((hba->cardtype == st_yosemite || hba->cardtype == st_yel)
>> +		&& st_sleep_mic == ST_IGNORED) {
>>   		req->cdb[0] = MGT_CMD;
>>   		req->cdb[1] = MGT_CMD_SIGNATURE;
>>   		req->cdb[2] = CTLR_CONFIG_CMD;
>>   		req->cdb[3] = CTLR_SHUTDOWN;
>> +	} else if (hba->cardtype == st_yel && st_sleep_mic != ST_IGNORED) {
>> +		req->cdb[0] = MGT_CMD;
>> +		req->cdb[1] = MGT_CMD_SIGNATURE;
>> +		req->cdb[2] = CTLR_CONFIG_CMD;
>> +		req->cdb[3] = PMIC_SHUTDOWN;
>> +		req->cdb[4] = st_sleep_mic;
>>   	} else {
>>   		req->cdb[0] = CONTROLLER_CMD;
>>   		req->cdb[1] = CTLR_POWER_STATE_CHANGE;
>> @@ -1773,10 +1787,12 @@ static void stex_hba_stop(struct st_hba *hba)
>>   	while (hba->ccb[tag].req_type & PASSTHRU_REQ_TYPE) {
>>   		if (time_after(jiffies, before + ST_INTERNAL_TIMEOUT * HZ)) {
>>   			hba->ccb[tag].req_type = 0;
>> +			hba->mu_status = MU_STATE_STOP;
>>   			return;
>>   		}
>>   		msleep(1);
>>   	}
>> +	hba->mu_status = MU_STATE_STOP;
>>   }
>>
>>   static void stex_hba_free(struct st_hba *hba)
>> @@ -1816,9 +1832,44 @@ static void stex_shutdown(struct pci_dev *pdev)
>>   {
>>   	struct st_hba *hba = pci_get_drvdata(pdev);
>>
>> -	stex_hba_stop(hba);
>> +	if (hba->supports_pm == 0)
>> +		stex_hba_stop(hba, ST_IGNORED);
>> +	else
>> +		stex_hba_stop(hba, ST_S5);
>> +}
>> +
>> +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->supports_pm == 1)
>> +		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);
>> +
>> +	hba->mu_status = MU_STATE_STARTING;
>> +	stex_handshake(hba);
>> +	return 0;
>> +}
>>   MODULE_DEVICE_TABLE(pci, stex_pci_tbl);
>>
>>   static struct pci_driver stex_pci_driver = {
>> @@ -1827,6 +1878,8 @@ static struct pci_driver stex_pci_driver = {
>>   	.probe		= stex_probe,
>>   	.remove		= stex_remove,
>>   	.shutdown	= stex_shutdown,
>> +	.suspend	= stex_suspend,
>> +	.resume		= stex_resume,
>>   };
>>
>>   static int __init stex_init(void)
>
> Looks OK from my side
> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Resend PATCH 3/3] scsi:stex.c Add S3/S4 support
  2016-01-29 11:23   ` Charles Chiou
@ 2016-02-04 11:22     ` Charles Chiou
  2016-02-04 11:37       ` Oliver Neukum
  0 siblings, 1 reply; 8+ messages in thread
From: Charles Chiou @ 2016-02-04 11:22 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, JBottomley, Oliver Neukum, grace.chang,
	linus.chen, victor.p, linux-scsi, linux-kernel, eva.cheng

 From f442518879f8f41d103b684046d912eca13844e7 Mon Sep 17 00:00:00 2001
From: Charles <charles.chiou@tw.promise.com>
Date: Wed, 2 Sep 2015 20:54:45 +0800
Subject: [PATCH 3/3] scsi:stex.c Add S3/S4 support

Add S3/S4 support, add .suspend and .resume function in pci_driver.
In .suspend handler, driver send S3/S4 signal to the device.

V2: Remove blank lines

Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

---
   drivers/scsi/stex.c | 59 
++++++++++++++++++++++++++++++++++++++++++++++++++---
   1 file changed, 56 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 4ef0c80..c96a86d 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -166,6 +166,13 @@ enum {

       ST_ADDITIONAL_MEM            = 0x200000,
       ST_ADDITIONAL_MEM_MIN            = 0x80000,
+    PMIC_SHUTDOWN                = 0x0D,
+    PMIC_REUMSE                    = 0x10,
+    ST_IGNORED                    = -1,
+    ST_S3                        = 3,
+    ST_S4                        = 4,
+    ST_S5                        = 5,
+    ST_S6                        = 6,
   };

   struct st_sgitem {
@@ -1733,7 +1740,7 @@ out_disable:
       return err;
   }

-static void stex_hba_stop(struct st_hba *hba)
+static void stex_hba_stop(struct st_hba *hba, int st_sleep_mic)
   {
       struct req_msg *req;
       struct st_msg_header *msg_h;
@@ -1749,11 +1756,18 @@ static void stex_hba_stop(struct st_hba *hba)
       } else
           memset(req, 0, hba->rq_size);

-    if (hba->cardtype == st_yosemite || hba->cardtype == st_yel) {
+    if ((hba->cardtype == st_yosemite || hba->cardtype == st_yel)
+        && st_sleep_mic == ST_IGNORED) {
           req->cdb[0] = MGT_CMD;
           req->cdb[1] = MGT_CMD_SIGNATURE;
           req->cdb[2] = CTLR_CONFIG_CMD;
           req->cdb[3] = CTLR_SHUTDOWN;
+    } else if (hba->cardtype == st_yel && st_sleep_mic != ST_IGNORED) {
+        req->cdb[0] = MGT_CMD;
+        req->cdb[1] = MGT_CMD_SIGNATURE;
+        req->cdb[2] = CTLR_CONFIG_CMD;
+        req->cdb[3] = PMIC_SHUTDOWN;
+        req->cdb[4] = st_sleep_mic;
       } else {
           req->cdb[0] = CONTROLLER_CMD;
           req->cdb[1] = CTLR_POWER_STATE_CHANGE;
@@ -1773,10 +1787,12 @@ static void stex_hba_stop(struct st_hba *hba)
       while (hba->ccb[tag].req_type & PASSTHRU_REQ_TYPE) {
           if (time_after(jiffies, before + ST_INTERNAL_TIMEOUT * HZ)) {
               hba->ccb[tag].req_type = 0;
+            hba->mu_status = MU_STATE_STOP;
               return;
           }
           msleep(1);
       }
+    hba->mu_status = MU_STATE_STOP;
   }

   static void stex_hba_free(struct st_hba *hba)
@@ -1816,9 +1832,44 @@ static void stex_shutdown(struct pci_dev *pdev)
   {
       struct st_hba *hba = pci_get_drvdata(pdev);

-    stex_hba_stop(hba);
+    if (hba->supports_pm == 0)
+        stex_hba_stop(hba, ST_IGNORED);
+    else
+        stex_hba_stop(hba, ST_S5);
+}
+
+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->supports_pm == 1)
+        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);
+
+    hba->mu_status = MU_STATE_STARTING;
+    stex_handshake(hba);
+    return 0;
+}
   MODULE_DEVICE_TABLE(pci, stex_pci_tbl);

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

   static int __init stex_init(void)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Resend PATCH 3/3] scsi:stex.c Add S3/S4 support
  2016-02-04 11:22     ` [Resend PATCH " Charles Chiou
@ 2016-02-04 11:37       ` Oliver Neukum
  2016-02-22  2:38         ` Charles Chiou
  0 siblings, 1 reply; 8+ messages in thread
From: Oliver Neukum @ 2016-02-04 11:37 UTC (permalink / raw)
  To: Charles Chiou
  Cc: Johannes Thumshirn, Christoph Hellwig, JBottomley, grace.chang,
	linus.chen, victor.p, linux-scsi, linux-kernel, eva.cheng

On Thu, 2016-02-04 at 19:22 +0800, Charles Chiou wrote:
> +static int stex_choice_sleep_mic(pm_message_t state)
> +{
> +    switch (state.event) {
> +    case PM_EVENT_SUSPEND:
> +        return ST_S3;
> +    case PM_EVENT_FREEZE:

Why do you react to PM_EVENT_FREEZE at all?
That is too early. You will get a HIBERNATE
event anyway. If the write out fails you are
in trouble if you already reacted to 
PM_EVENT_FREEZE

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Resend PATCH 3/3] scsi:stex.c Add S3/S4 support
  2016-02-04 11:37       ` Oliver Neukum
@ 2016-02-22  2:38         ` Charles Chiou
  0 siblings, 0 replies; 8+ messages in thread
From: Charles Chiou @ 2016-02-22  2:38 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Johannes Thumshirn, Christoph Hellwig, JBottomley, grace.chang,
	linus.chen, victor.p, linux-scsi, linux-kernel, eva.cheng

Hi Oliver,
sure, we'll fix it at the next patch version. Thank you.
Charles

On 02/04/2016 07:37 PM, Oliver Neukum wrote:
> On Thu, 2016-02-04 at 19:22 +0800, Charles Chiou wrote:
>> +static int stex_choice_sleep_mic(pm_message_t state)
>> +{
>> +    switch (state.event) {
>> +    case PM_EVENT_SUSPEND:
>> +        return ST_S3;
>> +    case PM_EVENT_FREEZE:
>
> Why do you react to PM_EVENT_FREEZE at all?
> That is too early. You will get a HIBERNATE
> event anyway. If the write out fails you are
> in trouble if you already reacted to
> PM_EVENT_FREEZE
>
> 	Regards
> 		Oliver
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] scsi:stex.c Add S3/S4 support
  2015-09-03  1:50 [PATCH " Charles Chiou
@ 2015-09-03  6:52 ` Johannes Thumshirn
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Thumshirn @ 2015-09-03  6:52 UTC (permalink / raw)
  To: Charles Chiou
  Cc: Christoph Hellwig, JBottomley, Oliver Neukum, ed.lin,
	grace.chang, linus.chen, victor.p, linux-scsi, linux-kernel

Charles Chiou <ch1102chiou@gmail.com> writes:

> From 7d98f8c500de452277e2700a950b23bf4685ed64 Mon Sep 17 00:00:00 2001
> From: Charles <charles.chiou@tw.promise.com>
> Date: Wed, 2 Sep 2015 20:54:45 +0800
> Subject: [PATCH 3/3] scsi:stex.c Add S3/S4 support
>
> Add S3/S4 support, add .suspend and .resume function in pci_driver.
> In .suspend handler, driver send S3/S4 signal to the device.
>
> Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>
> ---
>  drivers/scsi/stex.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 62 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index 6578f3d..45482d5 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -166,6 +166,13 @@ enum {
>
>  	ST_ADDITIONAL_MEM			= 0x200000,
>  	ST_ADDITIONAL_MEM_MIN			= 0x80000,
> +	PMIC_SHUTDOWN				= 0x0D,
> +	PMIC_REUMSE					= 0x10,
> +	ST_IGNORED					= -1,
> +	ST_S3						= 3,
> +	ST_S4						= 4,
> +	ST_S5						= 5,
> +	ST_S6						= 6,
>  };
>
>  struct st_sgitem {
> @@ -360,6 +367,8 @@ static const char console_inq_page[] =
>  	0x0C,0x20,0x20,0x20,0x20,0x20,0x20,0x20
>  };
>
> +
> +

Same as with 1/1

>  MODULE_AUTHOR("Ed Lin");
>  MODULE_DESCRIPTION("Promise Technology SuperTrak EX Controllers");
>  MODULE_LICENSE("GPL");
> @@ -1359,6 +1368,9 @@ static void stex_reset_work(struct work_struct *work)
>  	stex_do_reset(hba);
>  }
>
> +
> +
> +

Again

>  static int stex_biosparam(struct scsi_device *sdev,
>  	struct block_device *bdev, sector_t capacity, int geom[])
>  {
> @@ -1736,7 +1748,7 @@ out_disable:
>  	return err;
>  }
>
> -static void stex_hba_stop(struct st_hba *hba)
> +static void stex_hba_stop(struct st_hba *hba, int st_sleep_mic)
>  {
>  	struct req_msg *req;
>  	struct st_msg_header *msg_h;
> @@ -1752,11 +1764,18 @@ static void stex_hba_stop(struct st_hba *hba)
>  	} else
>  		memset(req, 0, hba->rq_size);
>
> -	if (hba->cardtype == st_yosemite || hba->cardtype == st_yel) {
> +	if ((hba->cardtype == st_yosemite || hba->cardtype == st_yel)
> +		&& st_sleep_mic == ST_IGNORED) {
>  		req->cdb[0] = MGT_CMD;
>  		req->cdb[1] = MGT_CMD_SIGNATURE;
>  		req->cdb[2] = CTLR_CONFIG_CMD;
>  		req->cdb[3] = CTLR_SHUTDOWN;
> +	} else if (hba->cardtype == st_yel && st_sleep_mic != ST_IGNORED) {
> +		req->cdb[0] = MGT_CMD;
> +		req->cdb[1] = MGT_CMD_SIGNATURE;
> +		req->cdb[2] = CTLR_CONFIG_CMD;
> +		req->cdb[3] = PMIC_SHUTDOWN;
> +		req->cdb[4] = st_sleep_mic;
>  	} else {
>  		req->cdb[0] = CONTROLLER_CMD;
>  		req->cdb[1] = CTLR_POWER_STATE_CHANGE;
> @@ -1776,10 +1795,12 @@ static void stex_hba_stop(struct st_hba *hba)
>  	while (hba->ccb[tag].req_type & PASSTHRU_REQ_TYPE) {
>  		if (time_after(jiffies, before + ST_INTERNAL_TIMEOUT * HZ)) {
>  			hba->ccb[tag].req_type = 0;
> +			hba->mu_status = MU_STATE_STOP;
>  			return;
>  		}
>  		msleep(1);
>  	}
> +	hba->mu_status = MU_STATE_STOP;
>  }
>
>  static void stex_hba_free(struct st_hba *hba)
> @@ -1819,9 +1840,45 @@ static void stex_shutdown(struct pci_dev *pdev)
>  {
>  	struct st_hba *hba = pci_get_drvdata(pdev);
>
> -	stex_hba_stop(hba);
> +	if (hba->supports_pm == 0)
> +		stex_hba_stop(hba, ST_IGNORED);
> +	else
> +		stex_hba_stop(hba, ST_S5);
> +}
> +
> +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->supports_pm == 1)
> +		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);
> +
> +	hba->mu_status = MU_STATE_STARTING;
> +	stex_handshake(hba);
> +	return 0;
> +}
>  MODULE_DEVICE_TABLE(pci, stex_pci_tbl);
>
>  static struct pci_driver stex_pci_driver = {
> @@ -1830,6 +1887,8 @@ static struct pci_driver stex_pci_driver = {
>  	.probe		= stex_probe,
>  	.remove		= stex_remove,
>  	.shutdown	= stex_shutdown,
> +	.suspend	= stex_suspend,
> +	.resume		= stex_resume,
>  };
>
>  static int __init stex_init(void)

-- 
Johannes Thumshirn                                           Storage
jthumshirn@suse.de                                 +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/3] scsi:stex.c Add S3/S4 support
@ 2015-09-03  1:50 Charles Chiou
  2015-09-03  6:52 ` Johannes Thumshirn
  0 siblings, 1 reply; 8+ messages in thread
From: Charles Chiou @ 2015-09-03  1:50 UTC (permalink / raw)
  To: Charles Chiou, Christoph Hellwig, JBottomley, Oliver Neukum
  Cc: ed.lin, grace.chang, linus.chen, victor.p, linux-scsi, linux-kernel


 From 7d98f8c500de452277e2700a950b23bf4685ed64 Mon Sep 17 00:00:00 2001
From: Charles <charles.chiou@tw.promise.com>
Date: Wed, 2 Sep 2015 20:54:45 +0800
Subject: [PATCH 3/3] scsi:stex.c Add S3/S4 support

Add S3/S4 support, add .suspend and .resume function in pci_driver.
In .suspend handler, driver send S3/S4 signal to the device.

Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>
---
  drivers/scsi/stex.c | 65 
++++++++++++++++++++++++++++++++++++++++++++++++++---
  1 file changed, 62 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 6578f3d..45482d5 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -166,6 +166,13 @@ enum {

  	ST_ADDITIONAL_MEM			= 0x200000,
  	ST_ADDITIONAL_MEM_MIN			= 0x80000,
+	PMIC_SHUTDOWN				= 0x0D,
+	PMIC_REUMSE					= 0x10,
+	ST_IGNORED					= -1,
+	ST_S3						= 3,
+	ST_S4						= 4,
+	ST_S5						= 5,
+	ST_S6						= 6,
  };

  struct st_sgitem {
@@ -360,6 +367,8 @@ static const char console_inq_page[] =
  	0x0C,0x20,0x20,0x20,0x20,0x20,0x20,0x20
  };

+
+
  MODULE_AUTHOR("Ed Lin");
  MODULE_DESCRIPTION("Promise Technology SuperTrak EX Controllers");
  MODULE_LICENSE("GPL");
@@ -1359,6 +1368,9 @@ static void stex_reset_work(struct work_struct *work)
  	stex_do_reset(hba);
  }

+
+
+
  static int stex_biosparam(struct scsi_device *sdev,
  	struct block_device *bdev, sector_t capacity, int geom[])
  {
@@ -1736,7 +1748,7 @@ out_disable:
  	return err;
  }

-static void stex_hba_stop(struct st_hba *hba)
+static void stex_hba_stop(struct st_hba *hba, int st_sleep_mic)
  {
  	struct req_msg *req;
  	struct st_msg_header *msg_h;
@@ -1752,11 +1764,18 @@ static void stex_hba_stop(struct st_hba *hba)
  	} else
  		memset(req, 0, hba->rq_size);

-	if (hba->cardtype == st_yosemite || hba->cardtype == st_yel) {
+	if ((hba->cardtype == st_yosemite || hba->cardtype == st_yel)
+		&& st_sleep_mic == ST_IGNORED) {
  		req->cdb[0] = MGT_CMD;
  		req->cdb[1] = MGT_CMD_SIGNATURE;
  		req->cdb[2] = CTLR_CONFIG_CMD;
  		req->cdb[3] = CTLR_SHUTDOWN;
+	} else if (hba->cardtype == st_yel && st_sleep_mic != ST_IGNORED) {
+		req->cdb[0] = MGT_CMD;
+		req->cdb[1] = MGT_CMD_SIGNATURE;
+		req->cdb[2] = CTLR_CONFIG_CMD;
+		req->cdb[3] = PMIC_SHUTDOWN;
+		req->cdb[4] = st_sleep_mic;
  	} else {
  		req->cdb[0] = CONTROLLER_CMD;
  		req->cdb[1] = CTLR_POWER_STATE_CHANGE;
@@ -1776,10 +1795,12 @@ static void stex_hba_stop(struct st_hba *hba)
  	while (hba->ccb[tag].req_type & PASSTHRU_REQ_TYPE) {
  		if (time_after(jiffies, before + ST_INTERNAL_TIMEOUT * HZ)) {
  			hba->ccb[tag].req_type = 0;
+			hba->mu_status = MU_STATE_STOP;
  			return;
  		}
  		msleep(1);
  	}
+	hba->mu_status = MU_STATE_STOP;
  }

  static void stex_hba_free(struct st_hba *hba)
@@ -1819,9 +1840,45 @@ static void stex_shutdown(struct pci_dev *pdev)
  {
  	struct st_hba *hba = pci_get_drvdata(pdev);

-	stex_hba_stop(hba);
+	if (hba->supports_pm == 0)
+		stex_hba_stop(hba, ST_IGNORED);
+	else
+		stex_hba_stop(hba, ST_S5);
+}
+
+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->supports_pm == 1)
+		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);
+
+	hba->mu_status = MU_STATE_STARTING;
+	stex_handshake(hba);
+	return 0;
+}
  MODULE_DEVICE_TABLE(pci, stex_pci_tbl);

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

  static int __init stex_init(void)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-02-22  2:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-03 12:39 [PATCH 3/3] scsi:stex.c Add S3/S4 support Charles Chiou
2015-09-03 14:03 ` Johannes Thumshirn
2016-01-29 11:23   ` Charles Chiou
2016-02-04 11:22     ` [Resend PATCH " Charles Chiou
2016-02-04 11:37       ` Oliver Neukum
2016-02-22  2:38         ` Charles Chiou
  -- strict thread matches above, loose matches on Subject: below --
2015-09-03  1:50 [PATCH " Charles Chiou
2015-09-03  6:52 ` Johannes Thumshirn

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.