From patchwork Thu Feb 4 11:22:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Chiou X-Patchwork-Id: 8219811 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 624A39F3CD for ; Thu, 4 Feb 2016 11:26:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FC3A20279 for ; Thu, 4 Feb 2016 11:26:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E3042012E for ; Thu, 4 Feb 2016 11:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933741AbcBDLXP (ORCPT ); Thu, 4 Feb 2016 06:23:15 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36333 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933238AbcBDLXN (ORCPT ); Thu, 4 Feb 2016 06:23:13 -0500 Received: by mail-pf0-f194.google.com with SMTP id n128so3222660pfn.3; Thu, 04 Feb 2016 03:23:13 -0800 (PST) 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 :references:in-reply-to:content-type:content-transfer-encoding; bh=uEc0L5yBRYwk8D69Cubkdtq4/uxITxP9HKazH+gL5Xw=; b=TCmU+QxPNLG5PbPqE4znDeK9aoaTXEa80qGqUroLN791gNJ7ri/uklADf7MiMDhqO4 qNqkZTfY1hOBrjYgzvodlU41E65/RN+/doyWjQw7Sz042ErE8A/1Gi3wzpaLpGiAjMdo GBP6K9nc6OUM9rD59kIpN/NjBXYaYuo5lwCioy3JkPmABEIQk6Xelv83sxJ7sX79pX55 uQahuv1VZKO0iqK+QVIg0Q/owFybpA9X8s23nBQ5oS5Y7PhPOH8plFlb0KCTGshtsPZr vYW07KPAER+o8jQ1UNkAggSw7f7QtOHO7HFyMXsdmhDYKHHDIz2C7rmmVdm/K62529Jv EfRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=uEc0L5yBRYwk8D69Cubkdtq4/uxITxP9HKazH+gL5Xw=; b=Z9OWICe5rwEVSO1/gT8TtLoQRSQaj0ck2L1WcLuege4459Imdc6zE8y/5D3M85+DY9 /iORLzYWgHYqcaWCh/v70hkTzKJjLcFKzbEnEIMXXOsYveZDPRssGoTEmEctH4a+fMm6 uOkWAehf8/eQvye0sbyOXvDh0TaW7srSRB7QG1jIMsM9W6phPQ8lRKcZpBXwGhPrBiwa tKqpLPEqB9y4CVDfbBVZk0dxTIIOA8t58jsz8Zkc6RuqNNXTXHHMdKOt6Eyzx2oxutmK jzw6LAKxyM3LDr6dadfxJy7EXQWqYweNJl2C1kdYcX8A4X/9wvhhnJXJEDKBRMZXlTiU VlKg== X-Gm-Message-State: AG10YORPkh4x2CDjgqMR0hgwYrHxWMfaExc4noq3d7BD7LaLCjIt4n4VBS4YSfmABrZ3Fw== X-Received: by 10.66.237.35 with SMTP id uz3mr10106570pac.96.1454584993032; Thu, 04 Feb 2016 03:23:13 -0800 (PST) Received: from [192.168.204.32] (vpn.promise.com.tw. [61.222.81.253]) by smtp.googlemail.com with ESMTPSA id 79sm16416929pfq.65.2016.02.04.03.23.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Feb 2016 03:23:12 -0800 (PST) Message-ID: <56B33493.80300@gmail.com> Date: Thu, 04 Feb 2016 19:22:59 +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: Johannes Thumshirn CC: Christoph Hellwig , JBottomley@parallels.com, Oliver Neukum , grace.chang@tw.promise.com, linus.chen@tw.promise.com, victor.p@promise.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, eva.cheng@tw.promise.com Subject: [Resend PATCH 3/3] scsi:stex.c Add S3/S4 support References: <55E83F66.2060300@gmail.com> <56AB4BBD.2030702@gmail.com> In-Reply-To: <56AB4BBD.2030702@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 f442518879f8f41d103b684046d912eca13844e7 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. V2: Remove blank lines Signed-off-by: Charles Chiou Reviewed-by: Johannes Thumshirn --- drivers/scsi/stex.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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)