From patchwork Thu Sep 3 01:50:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Chiou X-Patchwork-Id: 7114491 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 73CEF9F372 for ; Thu, 3 Sep 2015 01:50:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8DA7D201F2 for ; Thu, 3 Sep 2015 01:50:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FEC320672 for ; Thu, 3 Sep 2015 01:50:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755775AbbICBu2 (ORCPT ); Wed, 2 Sep 2015 21:50:28 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35880 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752846AbbICBu1 (ORCPT ); Wed, 2 Sep 2015 21:50:27 -0400 Received: by pacwi10 with SMTP id wi10so29171911pac.3; Wed, 02 Sep 2015 18:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=ZoccoPlKowgwK7CwyNem+Qb2ViMwY0+6I8LPO0/smOI=; b=iZEc1NVNFTZhdw6ygrk/Vb8tN0JU+OsHlhzfWgVbFIX+oDNQJ6Zp2ocpbu1Vjg+uye laS2kVCLMS1J0gK0c260/WgWA4Jb9QCdK4KV3ReUPgYSlcgCtrgPcxHcSgz2UdbTMjbM oE86+BJOuNYh4Y0Kyr4sMZq1tqKz5Owvk0QcZm4fIjAjfcn12PHHiYmxLU/cJNXd3Y6j zCwyQa+DkXHrsEeJwXxPOILdfeDDxwIaMJT3BCmn6YqqL4BK8uiNop4MD4UJHIiI3Uvl Lo5LyCPZQRZqNc5PCTNIMYXHtcZufsXj4iON/bppeRRTNzLtECZ+fOcPd5YBEyqMObx9 uvjQ== X-Received: by 10.66.141.231 with SMTP id rr7mr63151354pab.11.1441245027272; Wed, 02 Sep 2015 18:50:27 -0700 (PDT) Received: from [192.168.204.65] (vpn.promise.com.tw. [61.222.81.253]) by smtp.googlemail.com with ESMTPSA id wj8sm23182865pab.3.2015.09.02.18.50.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Sep 2015 18:50:26 -0700 (PDT) Message-ID: <55E7A760.1040404@gmail.com> Date: Thu, 03 Sep 2015 09:50:24 +0800 From: Charles Chiou User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Charles Chiou , Christoph Hellwig , JBottomley@parallels.com, Oliver Neukum CC: ed.lin@promise.com, grace.chang@tw.promise.com, linus.chen@tw.promise.com, victor.p@promise.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] scsi:stex.c Add S3/S4 support Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From 7d98f8c500de452277e2700a950b23bf4685ed64 Mon Sep 17 00:00:00 2001 From: Charles 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 --- 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)