Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1761526ybh; Mon, 20 Jul 2020 06:39:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf6annBbMijIqjovkddlLbOywshohJc6XB0yVY6/yJ1onwT5CET/4pkLGnN5E/32OvolMC X-Received: by 2002:a17:906:c259:: with SMTP id bl25mr20525480ejb.303.1595252341002; Mon, 20 Jul 2020 06:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595252340; cv=none; d=google.com; s=arc-20160816; b=ARMhAcOTERaUvo77gqXrczh1me1yGFZpN/g8xpQw+qT2K9w7ZZRNhwiCkeL/pUio7Y EjmJh+C11v4p8kyoKmTiOuBFscZMEqFzCkoYAxIxB8JW9I2r81FIzsrvaTAJEsOPfu2q WOZB8sMZ88d26AtMzdWJLwhG+QhZwazeqXwrfE0tnNGfOoO3tQmz6ym+IkXYU538xS7G 9A6TrTzw9QmWyTKm6mfvWHQ6QBjzSjv3PRdQp5b/dzApUVtbZFkhT0vxXZve3sVgy3Rg TRYi90u9cXywxxzJ0Zx4DBK4UXNeCQkMmX8TipXaR0O/VlT+IxRMyXx7QUaNfDHm5D86 oAag== 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=oHOwkj4fnhtZnaXLc1XXpmlO0WhcrZr5c89iPSNlAKc=; b=zyxOgtzhb9Yxmsa57Ylpil5bLdIIvUfrGlXLnQgJ/An2zmbZ33pIYNTKFG0TkpYRpy Uu9yPkZJXrshAlfpEspcEotmZkwFEK7S2NWy2DUhZV23HnFEmhH0PS/xQ4LXoCb0/nT+ W5VUWHPd//UWieOtsnDHvGMJe4jv4+iOMz4OZ8Hcss2hWXQJTvfyP4PkFFX5DCd7vJXR yvQZxxMEiVRf0iZuBCj8JvguUEDEpBMl/78ppr9h6Wz8mM9rTDLdKRGPgzxmOIK6ictW Yru9Y0TNs3uimD1KBhm+xyGRwiXIHWG6b5blOo4GLr99I/xqjLYgx0gwVjVadkVJ3LWR eb1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N3fETepz; 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 cf15si10515351edb.350.2020.07.20.06.38.37; Mon, 20 Jul 2020 06:39:00 -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=N3fETepz; 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 S1728169AbgGTNhp (ORCPT + 99 others); Mon, 20 Jul 2020 09:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbgGTNhp (ORCPT ); Mon, 20 Jul 2020 09:37:45 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0200FC061794; Mon, 20 Jul 2020 06:37:45 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id m9so9070218pfh.0; Mon, 20 Jul 2020 06:37:44 -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=oHOwkj4fnhtZnaXLc1XXpmlO0WhcrZr5c89iPSNlAKc=; b=N3fETepzmOozX/AxOkoCUFSDqCpy0ZzL2Rs4rgiRCwW4aDxyzCdhb8wb1BZvzRhQ65 AlH8lGu3Ff1vJwY4/wqtUmaPXnEjyAEw+C0+ALch561vPqpwi3jIDRbIwct37jI9NIJn I8y8Otjt3arzq7cjPvA4ZarBcHL6cK6kE56NjAsKiQTmZ8tTcVY4HK0aGyXih5pfTORS mGF1qZnF8aWUNkA+cCvXTcEfcKSmTh6phJa1M6ApdVSV49gerGNLC3hvL6VttAyGktzE /50/T+qmqpxZbVuTrKEGa6u2sfhIFY0e3rfLTt4cDrSwsyPdl5VZzCsHT8o68oC1haog dAKg== 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=oHOwkj4fnhtZnaXLc1XXpmlO0WhcrZr5c89iPSNlAKc=; b=ru1aObsy6E4zS87GuGBb6/VXOu8/0myArDTgjyCe+Aj4/U21nyME9D81hurPJzaZxG G6TaqpomNxPXBB9PcSiBI5NgtRaTUPuDb+JNiR8cvYpF/rBkgyUijsiOOaIleMqkmoi7 vj7dKKnKI3f3/2gvlAoTGMlZdQCVaUOXwcTyhQeQnYBGk5q9DFNOFS7rIO1cD6NzKbwv +w2aKecnBTYyooHsngAqWTdSyLORcExdUlSngd3CwZ6aFInwj6JsbWNs3qbw8RqprX0G AyzOh7ndVpU/2zfH0UPXcszy+DDUO0OCjDu5gffYoFoB87JsIHT2JNU3U3k86Oe9u/Bq 3CeA== X-Gm-Message-State: AOAM532SxFQawjAiBFlj7ovzndmCN5Kt75Ngveaz4SPlhU3a10KEQBrb 2b0lzdDuL+otmGXnws1AA58= X-Received: by 2002:aa7:8557:: with SMTP id y23mr19420720pfn.148.1595252264494; Mon, 20 Jul 2020 06:37:44 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id s6sm17042183pfd.20.2020.07.20.06.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 06:37:43 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , 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 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 v2 07/15] scsi: hisi_sas_v3_hw: use generic power management Date: Mon, 20 Jul 2020 19:04:20 +0530 Message-Id: <20200720133427.454400-8-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720133427.454400-1-vaibhavgupta40@gmail.com> References: <20200720133427.454400-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/hisi_sas/hisi_sas_v3_hw.c | 32 +++++++++----------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 55e2321a65bc..824bfbe1abbb 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3374,13 +3374,13 @@ enum { hip08, }; -static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused hisi_sas_v3_suspend(struct device *dev_d) { + struct pci_dev *pdev = to_pci_dev(dev_d); struct sas_ha_struct *sha = pci_get_drvdata(pdev); struct hisi_hba *hisi_hba = sha->lldd_ha; struct device *dev = hisi_hba->dev; struct Scsi_Host *shost = hisi_hba->shost; - pci_power_t device_state; int rc; if (!pdev->pm_cap) { @@ -3406,12 +3406,7 @@ static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) hisi_sas_init_mem(hisi_hba); - device_state = pci_choose_state(pdev, state); - dev_warn(dev, "entering operating state [D%d]\n", - device_state); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, device_state); + dev_warn(dev, "entering suspend state\n"); hisi_sas_release_tasks(hisi_hba); @@ -3419,8 +3414,9 @@ static int hisi_sas_v3_suspend(struct pci_dev *pdev, pm_message_t state) return 0; } -static int hisi_sas_v3_resume(struct pci_dev *pdev) +static int __maybe_unused hisi_sas_v3_resume(struct device *dev_d) { + struct pci_dev *pdev = to_pci_dev(dev_d); struct sas_ha_struct *sha = pci_get_drvdata(pdev); struct hisi_hba *hisi_hba = sha->lldd_ha; struct Scsi_Host *shost = hisi_hba->shost; @@ -3430,16 +3426,8 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) dev_warn(dev, "resuming from operating state [D%d]\n", device_state); - pci_set_power_state(pdev, PCI_D0); - pci_enable_wake(pdev, PCI_D0, 0); - pci_restore_state(pdev); - rc = pci_enable_device(pdev); - if (rc) { - dev_err(dev, "enable device failed during resume (%d)\n", rc); - return rc; - } + device_wakeup_disable(dev_d); - pci_set_master(pdev); scsi_unblock_requests(shost); clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); @@ -3447,7 +3435,6 @@ static int hisi_sas_v3_resume(struct pci_dev *pdev) rc = hw_init_v3_hw(hisi_hba); if (rc) { scsi_remove_host(shost); - pci_disable_device(pdev); return rc; } hisi_hba->hw->phys_init(hisi_hba); @@ -3468,13 +3455,16 @@ static const struct pci_error_handlers hisi_sas_err_handler = { .reset_done = hisi_sas_reset_done_v3_hw, }; +static SIMPLE_DEV_PM_OPS(hisi_sas_v3_pm_ops, + hisi_sas_v3_suspend, + hisi_sas_v3_resume); + static struct pci_driver sas_v3_pci_driver = { .name = DRV_NAME, .id_table = sas_v3_pci_table, .probe = hisi_sas_v3_probe, .remove = hisi_sas_v3_remove, - .suspend = hisi_sas_v3_suspend, - .resume = hisi_sas_v3_resume, + .driver.pm = &hisi_sas_v3_pm_ops, .err_handler = &hisi_sas_err_handler, }; -- 2.27.0