Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1762710ybh; Mon, 20 Jul 2020 06:40:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZxQgJPV/kg/cFQV3IcPe7z8Ak2L0RQHrfGx/JiBMNzeKuxgQmkbY+lWUQs+hTiljnxK4V X-Received: by 2002:a17:906:65b:: with SMTP id t27mr15859577ejb.457.1595252444994; Mon, 20 Jul 2020 06:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595252444; cv=none; d=google.com; s=arc-20160816; b=ApfcKgp0V1fO6NHZ7InLQXxkoRtOHF0BBoYulfHMhZGsa0gNAi+aGUsRnQ3VGL/Rsy JtKQTkcckmiij9X8xhxe+XMqfR7mtdtP31UYGWlkto6Hpi6VATCyPYGNwBBKGloO0Dj4 HW59odA0ZuS9ZQJ2RrJ9Sf1Jjoxpei9MVYCjeONUK4NzUJXq/nyB8RYgm3RhxR5V5bOo WOQ3YDHT52JXVULBtxPxU7XE0PaQSMxHh8WJmurcucNL9Z2t/w8wt7+q+nwhb93sUGol OtzvnZllym+vnUpmA+uXC4ZxynwO5I6HUDtVuHCNzxQ5kRuiVE0tyYcgNKPPLkhOtU/7 4exQ== 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=g/tyeJF8PDKMzFJdLXmzBSv8b1mcXisQeNVbn9w363w=; b=XTifYf2/3TvhJlo6UxHSCeqpvUYP8qyL15qtEdLQUVQ0NWQ4eJdvCsvCi3skr9pPuN 0Pv7nTMvt0+OXptm4uYk8jazrcKjkaDQEtu+zmjZSxKnJnElB1dmcXsltUCBCxrHUOL1 g9HrMOeqsZu24EG7aAWvAYd7ancbC8nHX4tgwtAxiCZLKNMtodZfB7ZpCc7ilMYPoVPm PZVw/LJZf5UulXN2fgVOdbLHWiDrHNtkvrv5jYF6OwbuTlN4h9tbrcGJeXGsnAmD83j/ SWTS+PBkbmZ4RUwq1BbDipPFpnTAShNAKM3kJYTkVR2mH87hHKo1Glrwd0233cLiNmJN gJ2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nVu+bkUf; 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 o15si10381299eja.702.2020.07.20.06.40.22; Mon, 20 Jul 2020 06:40:44 -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=nVu+bkUf; 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 S1728139AbgGTNhh (ORCPT + 99 others); Mon, 20 Jul 2020 09:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbgGTNhg (ORCPT ); Mon, 20 Jul 2020 09:37:36 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D35AC0619D2; Mon, 20 Jul 2020 06:37:36 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id a24so9065647pfc.10; Mon, 20 Jul 2020 06:37:36 -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=g/tyeJF8PDKMzFJdLXmzBSv8b1mcXisQeNVbn9w363w=; b=nVu+bkUfU8uZ6Y9bM5MnpehhbVKa0HZT0XFlnc43jPvwL7tBnEQAmHSLtZ+gBgJqxb NeL+J5yg3sIbdGuNJhrwUDWdAvieqT4tO666p6jzELlF7zks0HQfA6p9QlWRUl/ZPHVs kzSWlrnoxI667undAsKwN0eac0ZlwirAKNoc6iVFfp7Zhr/NMFTDl11OuVRsOwT7RBw6 7Kuh6/4F7n0HBDlQjYN+qPvsdXO4WzvKPDr/3JDnkdR2UQQCivhOv8S6tEU31aVWCRoH 0SvT94CNwtUs0DOF1Gb4vMJu2STGzjzYVKmzZMISwRki8yPbhsO4lGd5lK35G0828yzi 2Zdg== 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=g/tyeJF8PDKMzFJdLXmzBSv8b1mcXisQeNVbn9w363w=; b=XY9aaIO+hy4snf7NWWEOma46lMVoEPmYs/WvqFLac2zGKe7kIwD1boAt8jA35gdE5L uwxjvZBTxohZW5wvO0ow+lINnCYkKIXq6uZQtqowG9pRL+Vg1m89Mu/SEoR7IUQoKYkH KClqWAU9fcKNIfpWHDM7W9CiJjRjBqbfIubCF5WGfN095EuWh2weqR6HOojzsnfCFq82 n1epGtxo38KDZIzliHLAoxLkY/+v6B8iqQxad9yW4n5DCJ5/SceNy92c4AMLq/m2gLpc /2g1Na29Nwacuqi6/7tm8XvYi+gjASjyRQi0mZPw0ssgTKH7n1Oa/rkiqsBn9jG/ovlq CHiA== X-Gm-Message-State: AOAM530prnlfW7dWbiIgPOK9mb3tXCTd8YyUdVOgbLgNw3rSMasuB70c /765eNiiCEsG3/jQByY6ZEw= X-Received: by 2002:a63:531e:: with SMTP id h30mr18016413pgb.165.1595252255802; Mon, 20 Jul 2020 06:37:35 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 06:37:35 -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 06/15] scsi: esas2r: use generic power management Date: Mon, 20 Jul 2020 19:04:19 +0530 Message-Id: <20200720133427.454400-7-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/esas2r/esas2r.h | 5 ++-- drivers/scsi/esas2r/esas2r_init.c | 48 +++++++++---------------------- drivers/scsi/esas2r/esas2r_main.c | 3 +- 3 files changed, 18 insertions(+), 38 deletions(-) diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index 7f43b95f4e94..6ad3e0871ef0 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h @@ -996,8 +996,9 @@ void esas2r_adapter_tasklet(unsigned long context); irqreturn_t esas2r_interrupt(int irq, void *dev_id); irqreturn_t esas2r_msi_interrupt(int irq, void *dev_id); void esas2r_kickoff_timer(struct esas2r_adapter *a); -int esas2r_suspend(struct pci_dev *pcid, pm_message_t state); -int esas2r_resume(struct pci_dev *pcid); + +extern const struct dev_pm_ops esas2r_pm_ops; + void esas2r_fw_event_off(struct esas2r_adapter *a); void esas2r_fw_event_on(struct esas2r_adapter *a); bool esas2r_nvram_write(struct esas2r_adapter *a, struct esas2r_request *rq, diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c index eb7d139ffc00..6c5854969791 100644 --- a/drivers/scsi/esas2r/esas2r_init.c +++ b/drivers/scsi/esas2r/esas2r_init.c @@ -640,53 +640,31 @@ void esas2r_kill_adapter(int i) } } -int esas2r_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused esas2r_suspend(struct device *dev) { - struct Scsi_Host *host = pci_get_drvdata(pdev); - u32 device_state; + struct Scsi_Host *host = dev_get_drvdata(dev); struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), "suspending adapter()"); + esas2r_log_dev(ESAS2R_LOG_INFO, dev, "suspending adapter()"); if (!a) return -ENODEV; esas2r_adapter_power_down(a, 1); - device_state = pci_choose_state(pdev, state); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_save_state() called"); - pci_save_state(pdev); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_disable_device() called"); - pci_disable_device(pdev); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_set_power_state() called"); - pci_set_power_state(pdev, device_state); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), "esas2r_suspend(): 0"); + esas2r_log_dev(ESAS2R_LOG_INFO, dev, "esas2r_suspend(): 0"); return 0; } -int esas2r_resume(struct pci_dev *pdev) +static int __maybe_unused esas2r_resume(struct device *dev) { - struct Scsi_Host *host = pci_get_drvdata(pdev); + struct Scsi_Host *host = dev_get_drvdata(dev); struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; - int rez; + int rez = 0; - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), "resuming adapter()"); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_set_power_state(PCI_D0) " + esas2r_log_dev(ESAS2R_LOG_INFO, dev, "resuming adapter()"); + esas2r_log_dev(ESAS2R_LOG_INFO, dev, + "device_wakeup_disable() " "called"); - pci_set_power_state(pdev, PCI_D0); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_enable_wake(PCI_D0, 0) " - "called"); - pci_enable_wake(pdev, PCI_D0, 0); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_restore_state() called"); - pci_restore_state(pdev); - esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev), - "pci_enable_device() called"); - rez = pci_enable_device(pdev); - pci_set_master(pdev); + device_wakeup_disable(dev); if (!a) { rez = -ENODEV; @@ -730,11 +708,13 @@ int esas2r_resume(struct pci_dev *pdev) } error_exit: - esas2r_log_dev(ESAS2R_LOG_CRIT, &(pdev->dev), "esas2r_resume(): %d", + esas2r_log_dev(ESAS2R_LOG_CRIT, dev, "esas2r_resume(): %d", rez); return rez; } +SIMPLE_DEV_PM_OPS(esas2r_pm_ops, esas2r_suspend, esas2r_resume); + bool esas2r_set_degraded_mode(struct esas2r_adapter *a, char *error_str) { set_bit(AF_DEGRADED_MODE, &a->flags); diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 7b49e2e9fcde..aab3ea580e6b 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -346,8 +346,7 @@ static struct pci_driver .id_table = esas2r_pci_table, .probe = esas2r_probe, .remove = esas2r_remove, - .suspend = esas2r_suspend, - .resume = esas2r_resume, + .driver.pm = &esas2r_pm_ops, }; static int esas2r_probe(struct pci_dev *pcid, -- 2.27.0