From patchwork Fri Jun 3 12:14:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Chiou X-Patchwork-Id: 9152985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C3B8660221 for ; Fri, 3 Jun 2016 12:14:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B372C28304 for ; Fri, 3 Jun 2016 12:14:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A70B628328; Fri, 3 Jun 2016 12:14:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39CEE28304 for ; Fri, 3 Jun 2016 12:14:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161165AbcFCMOT (ORCPT ); Fri, 3 Jun 2016 08:14:19 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:33101 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161075AbcFCMOQ (ORCPT ); Fri, 3 Jun 2016 08:14:16 -0400 Received: by mail-pa0-f67.google.com with SMTP id di3so5903594pab.0; Fri, 03 Jun 2016 05:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=JagERaRqoOkVlVzzkW14dmootV40qvPa97ViirIvY+8=; b=dNOoeje9LU1jVXMntm2kXn0YZDKR0v+aNgcPG/V8nBYqnFi6BCOjLqRzId/P58f343 oC0NxKPAdhSx75aJDJPzmP2nDVZGfB70Hct23fKJAkOEvXiZfqFtlBoEZzbKiBfhidnl hcAKZInJK5DLTOe0s2YwHlRcAezzWpCS/nlzbOrt4u266hIIXcpuYakGtwoXPNEspBdL WeLZShXKGbmweUzxsKCcz1UcU0yBCCnZ1xU68n+l8QJp69okSN69oglIrUmYO9If2gOG Pn7m6YIAsols18OV2+l8YzLS/w1OYSjpSBAG47RzysSeaGOrbB79pMnAeZOc7ik83EU/ bztQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JagERaRqoOkVlVzzkW14dmootV40qvPa97ViirIvY+8=; b=epThV2F0ZTXV80iVGQkkaYCcLVtK+aYV9g9+0PVHSKF8Ku73swx0NN8Ulb1I6zCQ8B Tq8ZmJn4xDXTmsTgTy0ZKT+zGH6iJ/bvU1QHcIBa8ZzsPef1/Om23BQZ7INMY7CxvWwN 1tUCk9Pr6FNYkhCrlld7MZLGrvpQc983AW79cMLiK/y9Kzj9aoeDTXGf81ajU4kImh9E BdKLo+lS/tVoWEBGJFFJ1l5NeJgeF5KS22yhaMxml+UTggO1l67Mxl+c6u3oNXGK2iJ5 D39l5CgAwTpPhGKITQ8Hfol9ehAJhXX10Muv/ls/LfDnzusPxnYAwwcMZ43+AAo7lYPH HUPw== X-Gm-Message-State: ALyK8tIyT9dkFhsuKXnom37Z1I6W3YC79EAgD37nZI4FpY70nF3W18VKrG58VpdBdisC9Q== X-Received: by 10.66.132.72 with SMTP id os8mr4910012pab.63.1464956055181; Fri, 03 Jun 2016 05:14:15 -0700 (PDT) Received: from charles-desktop.promise.com.tw (vpn.promise.com.tw. [61.222.81.253]) by smtp.gmail.com with ESMTPSA id j3sm8047027pfk.94.2016.06.03.05.14.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Jun 2016 05:14:14 -0700 (PDT) From: Charles Chiou To: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linus.chen@tw.promise.com, grace.chang@tw.promise.com, victor.p@promise.com, eva.cheng@tw.promise.com, charles.chiou@tw.promise.com Cc: Paul Subject: [PATCH 5/5] Add P3 support, acpi s5 & s6 Date: Fri, 3 Jun 2016 20:14:11 +0800 Message-Id: <1464956051-16930-1-git-send-email-ch1102chiou@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paul 1.Add reboot notifier 2.Register reboot notifier in probe 3.Reboot set a flag for shutdown callback Signed-off-by: Paul --- drivers/scsi/stex.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index b18c434..9de2de2 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -362,6 +363,12 @@ struct st_card_info { u16 sts_count; }; +int S6flag; +static int stex_halt(struct notifier_block *nb, ulong event, void *buf); +static struct notifier_block stex_notifier = { + stex_halt, NULL, 0 +}; + static int msi; module_param(msi, int, 0); MODULE_PARM_DESC(msi, "Enable Message Signaled Interrupts(0=off, 1=on)"); @@ -1669,6 +1676,9 @@ static int stex_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_master(pdev); + S6flag = 0; + register_reboot_notifier(&stex_notifier); + host = scsi_host_alloc(&driver_template, sizeof(struct st_hba)); if (!host) { @@ -1944,15 +1954,19 @@ static void stex_remove(struct pci_dev *pdev) scsi_host_put(hba->host); pci_disable_device(pdev); + + unregister_reboot_notifier(&stex_notifier); } static void stex_shutdown(struct pci_dev *pdev) { struct st_hba *hba = pci_get_drvdata(pdev); - - if (hba->supports_pm == 0) + if (hba->supports_pm == 0) { stex_hba_stop(hba, ST_IGNORED); - else + } else if (hba->supports_pm == 1 && S6flag) { + unregister_reboot_notifier(&stex_notifier); + stex_hba_stop(hba, ST_S6); + } else stex_hba_stop(hba, ST_S5); } @@ -1989,6 +2003,13 @@ static int stex_resume(struct pci_dev *pdev) stex_handshake(hba); return 0; } + +static int stex_halt(struct notifier_block *nb, unsigned long event, void *buf) +{ + S6flag = 1; + return NOTIFY_OK; +} + MODULE_DEVICE_TABLE(pci, stex_pci_tbl); static struct pci_driver stex_pci_driver = {