From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8ED5C433EA for ; Fri, 17 Jul 2020 06:37:41 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BDF2520704 for ; Fri, 17 Jul 2020 06:37:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JgIvuxA5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDF2520704 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 849B684BC9; Fri, 17 Jul 2020 06:37:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rwxKoE5fTIZ8; Fri, 17 Jul 2020 06:37:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id D23E284B80; Fri, 17 Jul 2020 06:37:38 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C00E5C07FF; Fri, 17 Jul 2020 06:37:38 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18894C0733 for ; Fri, 17 Jul 2020 06:37:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 071ED84BC9 for ; Fri, 17 Jul 2020 06:37:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CnY7_w75qFiu for ; Fri, 17 Jul 2020 06:37:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 8158E84B80 for ; Fri, 17 Jul 2020 06:37:37 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id m22so6189877pgv.9 for ; Thu, 16 Jul 2020 23:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qP/lw2OrWNJnMcQg/XtLZOmUZ9RFHua2vKNQYNPkmuc=; b=JgIvuxA5S7jRpinQ35TeTekMHkcWqFT0YCB36hWQGieyffHLNvn9hqpzm3CxGPZ92j c/6o97E4x4oeV5VSZD+BnSoxDURyeTqoDWiRbc2tZHYErKXWQH/YovEbER9CRSQfuC9n p6RAYGTRmjyP1miker0qpT5xQQnwgKgL/ZN211YxsJnlhdodz+WFbkBBvZrg5ID2JRYG OUpEejIxhzao47pIP4zThzhx+0StHUMDYVyZ/vTlg4+Uaanj0TKLbWTTrmkohUaezT9m RlAQky0pw9U8/RxtjtI0QiH7jDCcUukHnQokCkP4/YcUGHXXxQIqEHvS+QzRfphnNtC7 tlqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qP/lw2OrWNJnMcQg/XtLZOmUZ9RFHua2vKNQYNPkmuc=; b=HTjl1JV9bG8WEsQJwEXut+qFNWIs2iDahOc2m9H/1l2SoZqTPfVazlvXfTOPXQfDD3 uecTttP6GjQVHmmDqLiyiNt2B3SUE+cunoBS4ZOIb882sFwcuh7/qlnpGwzTUEbK58cC 0tFFKI9mk1dZO9GqBqdWJNiMjuG7nbRC160bMGgl3d1iYEMR1odXkPs2zfVzS6v190WM JF4xmAnqZbl8bYwuUlVGVJVK3vQQsjJquVIljP3Oh543xhtkYQk+5w5sxCduGfAdNEii 17JFY+GKlM21dLd9L2TN9etCcZfhywxM0r74NYOtoXt6dDTHNnqga9y2QDlhcGGcOVl5 a2Yw== X-Gm-Message-State: AOAM5315pUFPyk729CnmY4JwcY7dXK8LltBskW081o1BP06wRZDqOwqG K4FhqfBXlJ02BBqQV6qc4Xc= X-Google-Smtp-Source: ABdhPJwvStyOWLkyQLnrZmfWxlA/fym705gjoIlQRCjarlkL2/z5zMIOBmeBMi+MVTOv3maIWKrrHQ== X-Received: by 2002:a63:7c4d:: with SMTP id l13mr7546893pgn.12.1594967857050; Thu, 16 Jul 2020 23:37:37 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id y22sm1683392pjp.41.2020.07.16.23.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 23:37:36 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Adam Radford , "James E.J. Bottomley" , "Martin K. Petersen" , Adaptec OEM Raid Solutions , Hannes Reinecke , Bradley Grove , John Garry , Don Brace , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang , Vaibhav Gupta Date: Fri, 17 Jul 2020 12:04:31 +0530 Message-Id: <20200717063438.175022-9-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717063438.175022-1-vaibhavgupta40@gmail.com> References: <20200717063438.175022-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Cc: linux-scsi@vger.kernel.org, Vaibhav Gupta , MPT-FusionLinux.pdl@broadcom.com, esc.storagedev@microsemi.com, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, megaraidlinux.pdl@broadcom.com Subject: [Linux-kernel-mentees] [PATCH v1 08/15] scsi: mpt3sas_scsih: use generic power management X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" With legacy PM, drivers themselves were responsible for managing the device's power states and takes care of register states. After upgrading to the generic structure, PCI core will take care of required tasks and drivers should do only device-specific operations. The driver was calling pci_save/restore_state(), pci_choose_state(), pci_enable/disable_device() and pci_set_power_state() which is no more needed. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 36 +++++++++++----------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 08fc4b381056..f3c6e68b2921 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -10829,44 +10829,40 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) return rv; } -#ifdef CONFIG_PM /** * scsih_suspend - power management suspend main entry point - * @pdev: PCI device struct - * @state: PM state change to (usually PCI_D3) + * @dev: Device struct * * Return: 0 success, anything else error. */ -static int -scsih_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused +scsih_suspend(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *shost = pci_get_drvdata(pdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - pci_power_t device_state; mpt3sas_base_stop_watchdog(ioc); flush_scheduled_work(); scsi_block_requests(shost); _scsih_nvme_shutdown(ioc); - device_state = pci_choose_state(pdev, state); - ioc_info(ioc, "pdev=0x%p, slot=%s, entering operating state [D%d]\n", - pdev, pci_name(pdev), device_state); + ioc_info(ioc, "pdev=0x%p, slot=%s, entering suspended state\n", + pdev, pci_name(pdev)); - pci_save_state(pdev); mpt3sas_base_free_resources(ioc); - pci_set_power_state(pdev, device_state); return 0; } /** * scsih_resume - power management resume main entry point - * @pdev: PCI device struct + * @dev: Device struct * * Return: 0 success, anything else error. */ -static int -scsih_resume(struct pci_dev *pdev) +static int __maybe_unused +scsih_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *shost = pci_get_drvdata(pdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); pci_power_t device_state = pdev->current_state; @@ -10875,9 +10871,7 @@ scsih_resume(struct pci_dev *pdev) ioc_info(ioc, "pdev=0x%p, slot=%s, previous operating state [D%d]\n", pdev, pci_name(pdev), device_state); - pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); - pci_restore_state(pdev); + device_wakeup_disable(dev); ioc->pdev = pdev; r = mpt3sas_base_map_resources(ioc); if (r) @@ -10888,7 +10882,6 @@ scsih_resume(struct pci_dev *pdev) mpt3sas_base_start_watchdog(ioc); return 0; } -#endif /* CONFIG_PM */ /** * scsih_pci_error_detected - Called when a PCI error is detected. @@ -11162,6 +11155,8 @@ static struct pci_error_handlers _mpt3sas_err_handler = { .resume = scsih_pci_resume, }; +static SIMPLE_DEV_PM_OPS(scsih_pm_ops, scsih_suspend, scsih_resume); + static struct pci_driver mpt3sas_driver = { .name = MPT3SAS_DRIVER_NAME, .id_table = mpt3sas_pci_table, @@ -11169,10 +11164,7 @@ static struct pci_driver mpt3sas_driver = { .remove = scsih_remove, .shutdown = scsih_shutdown, .err_handler = &_mpt3sas_err_handler, -#ifdef CONFIG_PM - .suspend = scsih_suspend, - .resume = scsih_resume, -#endif + .driver.pm = &scsih_pm_ops, }; /** -- 2.27.0 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees