From patchwork Tue Sep 8 07:26:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Chiou X-Patchwork-Id: 7138871 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 294A19F402 for ; Tue, 8 Sep 2015 07:26:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D06320670 for ; Tue, 8 Sep 2015 07:26:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54818206A9 for ; Tue, 8 Sep 2015 07:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754068AbbIHH0j (ORCPT ); Tue, 8 Sep 2015 03:26:39 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:34527 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753612AbbIHH0h (ORCPT ); Tue, 8 Sep 2015 03:26:37 -0400 Received: by padhy16 with SMTP id hy16so114578165pad.1; Tue, 08 Sep 2015 00:26:37 -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=ghl33l21JkL+o1pvXuSbQuo3orORzTItmNlG9nifYxg=; b=iFG+0rWAemyowXTcc2oKeuZzFNQ/ZRu23yrYNgkujftWgvEgD7/Cc7Nm0zmiUg+RNE q5TDLqNqS27CxVyQn6dPPFVFJ8N+bJDuhj/khyIyCF9fUKwmcO1MQXnBWP9cIAk2+ILD JdJaBbT5ESyxJEM9eTdMPxXwDXJB0ZFp8uHItCAW/s+P74M5yHzo/DG3hi+p33ESDoyD Ypeq4GmFwbXzVqFdHXkfpomoUaSPnLCCUlBNHSutZ0AmPG94mr+q4bTYdDlN117w2Z7P mFf1jAH2/YQxjhakTrLyCZwRATMPKjLXCe9OVquHQZ8kFRRFG58oj/cMpnitmstay/I5 p2NQ== X-Received: by 10.68.89.35 with SMTP id bl3mr55800037pbb.69.1441697197405; Tue, 08 Sep 2015 00:26:37 -0700 (PDT) Received: from [192.168.204.62] (vpn.promise.com.tw. [61.222.81.253]) by smtp.googlemail.com with ESMTPSA id rt6sm2162832pbb.62.2015.09.08.00.26.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Sep 2015 00:26:36 -0700 (PDT) Message-ID: <55EE8DA5.1090001@gmail.com> Date: Tue, 08 Sep 2015 15:26:29 +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: linux-pm@vger.kernel.org, Christoph Hellwig , linux-scsi@vger.kernel.org CC: grace.chang@tw.promise.com, linus.chen@tw.promise.com Subject: Need to distinct shut down or restart on driver side. 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 Hi, we need to get the information that specified the host is going to shut down or restart. Ideally, our device can reference the HW signal to know the host is going to shut down or restart, unfortunately, we face the HW signal issue on various motherboards. We experiment on many motherboards, and we observe that the restart signal is different on different motherboard. If device misses the signal, PCI loss or volume disappearance might happen. Currently, stex.c cannot send reboot signal to the fw because the only way to distinct shut down and restart on driver side is register_reboot_notifier() which is not allow to SCSI driver. Could you provide some suggestions? Add reboot feature is the forth patch in stex.c patch series. Patch 1~3 have been sent to Linux-SCSI mailing list. Patch 4 is the reboot patch and I don't sent it to Linux-SCSI mailing list. Attach patch 4 as following. BRS Charles From 35a709ea3ae213bef9982706e9a95ffb26e04e1e Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 8 Sep 2015 15:09:42 +0800 Subject: [PATCH 4/4] scsi:stex.c Add reboot support 1. Add reboot support, Pegasus devices should be notified that the host is going to shutdown/restart. I register reboot callback function to distinct host is going to shutdown or to restart. Signed-off-by: Charles Chiou --- drivers/scsi/stex.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) struct timeval tv; @@ -1547,6 +1557,7 @@ static int stex_probe(struct pci_dev *pdev, const struct pci_device_id *id) u32 sts_offset, cp_offset, scratch_offset; int err; + isRestart = 0; err = pci_enable_device(pdev); if (err) return err; @@ -1834,8 +1845,12 @@ static void stex_shutdown(struct pci_dev *pdev) if (hba->supports_pm == 0) stex_hba_stop(hba, ST_IGNORED); - else - stex_hba_stop(hba, ST_S5); + else { + if (isRestart) + stex_hba_stop(hba, ST_S6); + else + stex_hba_stop(hba, ST_S5); + } } static int stex_choice_sleep_mic(pm_message_t state) @@ -1882,18 +1897,24 @@ static struct pci_driver stex_pci_driver = { .resume = stex_resume, }; +static struct notifier_block stex_reboot_notifier = { + stex_reboot_callback, NULL, 0 +}; + static int __init stex_init(void) { printk(KERN_INFO DRV_NAME ": Promise SuperTrak EX Driver version: %s\n", ST_DRIVER_VERSION); + register_reboot_notifier(&stex_reboot_notifier); return pci_register_driver(&stex_pci_driver); } static void __exit stex_exit(void) { pci_unregister_driver(&stex_pci_driver); + unregister_reboot_notifier(&stex_reboot_notifier); } module_init(stex_init); diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index c96a86d..63ca921 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -351,6 +352,7 @@ struct st_card_info { u16 sts_count; }; +static int isRestart; static int msi; module_param(msi, int, 0); MODULE_PARM_DESC(msi, "Enable Message Signaled Interrupts(0=off, 1=on)"); @@ -372,6 +374,14 @@ MODULE_DESCRIPTION("Promise Technology SuperTrak EX Controllers"); MODULE_LICENSE("GPL"); MODULE_VERSION(ST_DRIVER_VERSION); +static int stex_reboot_callback(struct notifier_block *self, + unsigned long val, void *data) +{ + if (val == SYS_RESTART) + isRestart = 1; + return NOTIFY_OK; +} + static void stex_gettime(__le64 *time) {