Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1760065ybh; Thu, 16 Jul 2020 23:40:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxElqIhsnyNLWmrzFD9KU7ku3IfHjekC8DM4R4iyOY98eMMxU0eJ7vvfmWqK/n92Axofyo X-Received: by 2002:aa7:c714:: with SMTP id i20mr8004257edq.215.1594968054420; Thu, 16 Jul 2020 23:40:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594968054; cv=none; d=google.com; s=arc-20160816; b=QHYsMskIfkh3lJoQGGdX7bWZYVUFAlAPuu2R46giNBSzP9OhhxdytAqnnTQMZqGwA7 /wSub1LcnWKn3um9m6aU3OOmB0/YurUMm067OnfNymAjABRNscl7m8r6DVa3bgX86Peq oFb9Q0dw6cdQlMoKO47Y0QaLCHUNJrzm2mft5wgPl09zI/3byeZCnFfXnFzT138vothj 0GY/f6ZZR1N8lpz/DMM2rkj8+WMLqJlfFM9F9FaawOzYBkgVI8w+VAnO42srw5zzDlRk aprTQ4LpHwExNYMUegYBGyWXYkHzJ2FiLwsv6TQ8OSzdy+yzzm1icdJUzO1Br509b87G UzWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qP/lw2OrWNJnMcQg/XtLZOmUZ9RFHua2vKNQYNPkmuc=; b=HwON0LKTzoUKwK+bLjzkMpcOGtQy969QekswC/NV/4SUCJlKp5v/Tg7FCb4flDaLqA rOv2oOBKX1v6k2Y6Pal2X3cvw/iIT7DQSlYPIagmzoxXYkn3kj7+vER7demOjH0e6oaM bu4EtYNWefW4JBhSFjQiylL1Ygojl3wpjgQDoA8UWSatHjN+HYKDFlbEML/Jzn6ErHte hwk7y/wyc/XeF3T6INh52KGmexCa3GVWd7mE+74ferZjUNn/+gTxS92dNrDLeSa0r0X2 piTPmUylY/vyn99Z3uZv7CF7Y8UA+HGODyll4r44Z5RsaJLitMEMl8qV8iIQhMZGEIg1 zpkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JgIvuxA5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n10si4580244ejb.539.2020.07.16.23.40.31; Thu, 16 Jul 2020 23:40:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JgIvuxA5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727986AbgGQGhi (ORCPT + 99 others); Fri, 17 Jul 2020 02:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbgGQGhh (ORCPT ); Fri, 17 Jul 2020 02:37:37 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A2AEC061755; Thu, 16 Jul 2020 23:37:37 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id p3so6223725pgh.3; 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=T9vBY8zYMbrvhBTo+vP3X8nEVizPtC4pUBO3ZxMxYVH5UOPNPY/UsnAc5cdiSNKd35 NymhPI2JDuUhz2XwM8M0jbAuI5vgizgrG3Wega76wksahG36K4oglfr6mThvvf7oaEQF FUlju57ZhcpCsv82PFa6Em4Txfxpnd0XMeUaJMj4/WWJcqjd0G+KgfsEENsXKshi2XHO laS1fPS2RTwueJaGp3yLlJHTachLj5LzvefdeqWHExlMWq3u3TOXvuVhBi3Lqh2x7aM6 r1HEWuhYrY4smWJRX8QUnJt8cmCc2QxHT46WFY4QMUCPR29ZHZ/MMHWG8pjFALp1t9K0 M5zA== X-Gm-Message-State: AOAM531Ob+lo4ZN9staBg4X2M394l39PXqJjlh4xI706sjImhaJWBsgM 4GNERtajfr/97+jdfiTkKd8= 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 Cc: Vaibhav Gupta , Shuah Khan , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-scsi@vger.kernel.org, esc.storagedev@microsemi.com, megaraidlinux.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com Subject: [PATCH v1 08/15] scsi: mpt3sas_scsih: use generic power management 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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