Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4333974pxu; Mon, 12 Oct 2020 16:35:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYQYs3+kCTsAySLuV0/LkBFMpYwxayhT4T91jMD+h+dF3y2AOXVmXW4x/qYiiAeAVZkiPr X-Received: by 2002:a17:906:52d5:: with SMTP id w21mr31722530ejn.501.1602545727909; Mon, 12 Oct 2020 16:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602545727; cv=none; d=google.com; s=arc-20160816; b=XeqxmkwE8UUWcdg3mxc0xgg5YGAKLx72ZZqvRbqZfXeSCMb/KMt114JsFAhLq9SbCs d9OnfSyC+M/iryaCXkYPqZu250yFB88n2FQfCG57ydyBTEkPCHxTrqbUMUg9+cT42A9j TT34V9Uc9LQ7xJE3Z9dRxC1Ky8ko98sYuyiXYjs2vEocVJWcK1sjzNAeI9cEJZltHyew g91XVazpVMw0MgDtAJZnpaFmd9PwnKsLBp4HeqlIAK+tX/SR68sPnhCSUDofPfhaZWRC xFqRC8ofzoiOG/Wgv23Ro63lwZpGd4X2OrH/4koOytqkhD9i/u+7+tTwQIQL71asuIyg I7PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PqlMUltE2W9iAaxN6WjlhXzg0nmGA76YahuGN2MZY6Q=; b=UvEsAMI15U5jEvHeOdJ4N86YStYqNqkj6eKQ9HmsQCG5vH7dAkMjOL8Bvxe9+7TS8V gzn/NLkkWKyb67GQVmtTX+TFc1TdVEKpbZ/9q0RHdo6L19lPV8pVezPqbuGOKe9dvmFM Fs4KgfJUfKRjb0+ZSUuQr5upsIPdhKSXQ1RZIwCwF9vn3rAR7sGyUCWE971EVpGq2ET8 wPeGzWNLxJDI1LCNnttGMNGhXqRQ+7/y2ZiSqR2AXyL85iQGbs8gOBJMMfOMFYQ05rqh 6YAj8OkyPzEwYpKTpZHEb6GzLaBP12rM/6aj1QQDr9tDRKM3WFVE2ipd2F55vemidyQ7 cU1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IJIqPV8Y; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id md27si12849140ejb.714.2020.10.12.16.35.05; Mon, 12 Oct 2020 16:35:27 -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=@kernel.org header.s=default header.b=IJIqPV8Y; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389242AbgJLNnX (ORCPT + 99 others); Mon, 12 Oct 2020 09:43:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:47136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389141AbgJLNmR (ORCPT ); Mon, 12 Oct 2020 09:42:17 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 11A1821D7F; Mon, 12 Oct 2020 13:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510136; bh=ZHxrrTtIL4qvu+XzZtjBKNSlmeA6jwRsBaw7+lM8ec0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IJIqPV8YRQIxwRRT0NzZShnWZ96rMNgGa3ljKU8gfMzSbctfCvVNCXbH21axc1sOE 5nTmshCTe3zmSyUxjU3sHYcNGMsdbYzwCG44LaGCvItt6araex4d7B6OjukicR/WYa kDMiqmT8uwvHz8FTS/XNOM6ilGley2PlvE7lw3vI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vaibhav Gupta , Andrew Bowers , Tony Nguyen , Sasha Levin Subject: [PATCH 5.4 56/85] iavf: use generic power management Date: Mon, 12 Oct 2020 15:27:19 +0200 Message-Id: <20201012132635.565534692@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132632.846779148@linuxfoundation.org> References: <20201012132632.846779148@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vaibhav Gupta [ Upstream commit bc5cbd73eb493944b8665dc517f684c40eb18a4a ] With the support of generic PM callbacks, drivers no longer need to use legacy .suspend() and .resume() in which they had to maintain PCI states changes and device's power state themselves. The required operations are done by PCI core. PCI drivers are not expected to invoke PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), pci_set_power_state(), etc. Their tasks are completed by PCI core itself. Compile-tested only. Signed-off-by: Vaibhav Gupta Tested-by: Andrew Bowers Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/iavf/iavf_main.c | 45 ++++++--------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c index 222ae76809aa1..bcb95b2ea792f 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -3773,7 +3773,6 @@ err_dma: return err; } -#ifdef CONFIG_PM /** * iavf_suspend - Power management suspend routine * @pdev: PCI device information struct @@ -3781,11 +3780,10 @@ err_dma: * * Called when the system (VM) is entering sleep/suspend. **/ -static int iavf_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused iavf_suspend(struct device *dev_d) { - struct net_device *netdev = pci_get_drvdata(pdev); + struct net_device *netdev = dev_get_drvdata(dev_d); struct iavf_adapter *adapter = netdev_priv(netdev); - int retval = 0; netif_device_detach(netdev); @@ -3803,12 +3801,6 @@ static int iavf_suspend(struct pci_dev *pdev, pm_message_t state) clear_bit(__IAVF_IN_CRITICAL_TASK, &adapter->crit_section); - retval = pci_save_state(pdev); - if (retval) - return retval; - - pci_disable_device(pdev); - return 0; } @@ -3818,24 +3810,13 @@ static int iavf_suspend(struct pci_dev *pdev, pm_message_t state) * * Called when the system (VM) is resumed from sleep/suspend. **/ -static int iavf_resume(struct pci_dev *pdev) +static int __maybe_unused iavf_resume(struct device *dev_d) { + struct pci_dev *pdev = to_pci_dev(dev_d); struct iavf_adapter *adapter = pci_get_drvdata(pdev); struct net_device *netdev = adapter->netdev; u32 err; - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - /* pci_restore_state clears dev->state_saved so call - * pci_save_state to restore it. - */ - pci_save_state(pdev); - - err = pci_enable_device_mem(pdev); - if (err) { - dev_err(&pdev->dev, "Cannot enable PCI device from suspend.\n"); - return err; - } pci_set_master(pdev); rtnl_lock(); @@ -3859,7 +3840,6 @@ static int iavf_resume(struct pci_dev *pdev) return err; } -#endif /* CONFIG_PM */ /** * iavf_remove - Device Removal Routine * @pdev: PCI device information struct @@ -3961,16 +3941,15 @@ static void iavf_remove(struct pci_dev *pdev) pci_disable_device(pdev); } +static SIMPLE_DEV_PM_OPS(iavf_pm_ops, iavf_suspend, iavf_resume); + static struct pci_driver iavf_driver = { - .name = iavf_driver_name, - .id_table = iavf_pci_tbl, - .probe = iavf_probe, - .remove = iavf_remove, -#ifdef CONFIG_PM - .suspend = iavf_suspend, - .resume = iavf_resume, -#endif - .shutdown = iavf_shutdown, + .name = iavf_driver_name, + .id_table = iavf_pci_tbl, + .probe = iavf_probe, + .remove = iavf_remove, + .driver.pm = &iavf_pm_ops, + .shutdown = iavf_shutdown, }; /** -- 2.25.1