Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3043686ybt; Mon, 29 Jun 2020 13:45:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzClhAy8w/GzzPwdz8dCLWnVK+lkZQXP4MDuVtTP5WCWa5RuzUgoZycFLA8Cpr9oInyzsaP X-Received: by 2002:aa7:d744:: with SMTP id a4mr19475632eds.94.1593463556686; Mon, 29 Jun 2020 13:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593463556; cv=none; d=google.com; s=arc-20160816; b=VOaAOxxF+Ead6225e25oSclNS+96oc6k8ZzKylCdBzcCYRebF2dhRtM2tEn1d4wwqT RHm+KRD7VUD2HH6Bm1n2mBpEgIDII6k22b01vIB6usI3LldTtKKO/EdHcQA934SQBTui pEoEXCMZHuEhHncjS192Q7XBGMrk6C2Nh/dy9n6Ddeiy3lvopK+xy+YNlj98gBLBuZCf DnAUfAkjWsVx3O9I5VSJlhvLM+aKIQGcPggFTiD2+12ypy44D7ETRLG7VQatoKAuhjFE S4nOeDTMrVWj4FrfacMEubPQovfmO31ODdeGf1eTvk4ani/PXoxbOe+DEP/0OrMvJjca Nz2w== 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=utWWFklWALofIM9bV7ToCXee3PvUOGzhWQpDC33de7M=; b=VEZPh902NVc/wkpfx2VPSYpOmU+oTLK4DNcMA4mmjemE6R+fKw8aTrlAQMzijltlYw nc2t2+/4rPjZ7se1NWpflQfwK0Mr8HvuklPZyTAU1X3rDDlUPNtrpi7mW/TxQUu45Gxt 4wavojImDDOiPjAIfDU4hZZVFiH8DRhHLmQ1FgaHtEVH5CktboRgfTjW2U9VZcA7E3EG vihbNZSSEHckMPjeu2Z6lwUJFG6zkHxAjLa6Ys2YVDXKZgMIXCinaqfsch8S1Mf2q/1C +af68vsgD+05Fi2J7kyMnagApUjKR7iZhcVpdVrjyXtsQHwbmOXjHo8FCNlEbCbkBh6j LrLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="IAvk3F/k"; 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 c89si361523edf.35.2020.06.29.13.45.33; Mon, 29 Jun 2020 13:45:56 -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="IAvk3F/k"; 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 S2389419AbgF2UoY (ORCPT + 99 others); Mon, 29 Jun 2020 16:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731608AbgF2TOA (ORCPT ); Mon, 29 Jun 2020 15:14:00 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71518C008743; Mon, 29 Jun 2020 01:29:51 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id o13so5008361pgf.0; Mon, 29 Jun 2020 01:29:51 -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=utWWFklWALofIM9bV7ToCXee3PvUOGzhWQpDC33de7M=; b=IAvk3F/kG69804ZwlJ0UWXHoVCPCaWP7DEh5wo8+T5c3r7p9l2Dsc1giGQ3ZP3t6Nk Za9YYSclySFOZoMiKb+4olFPBJw87ldQfKBB8/DHtQpqTm5DqMLVumY9dCpiofuuOSXN svbeGi8Rq7oQ/iQgUI0dMXNQLIyc8oSDQvhpv+SZK25D+xK/QbOF1CWjQIroHgmwJWOS dDCoQr7uKdT+NEOWtHmst+PPnFsQv5Bv5hEafJ23Lm22IeZeXWtZAO2NdvuosoVdQN7Z 4nfEJv+iuCXYfrHOBkToxVB2X9WjIZZGTyz+n7RuurK1XrPBc1MPG0HzxH0f1iJmAON6 w4IQ== 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=utWWFklWALofIM9bV7ToCXee3PvUOGzhWQpDC33de7M=; b=fR7x/vCd1jU7VgrVmevZA71zXZcSDbcyUgdJiTmEik30RAbYQZIwIl4SWivag5IpHY RvYvxrIZ92o3HVc76tiGKyEd9f1+gdGPNA5NynnQh7LrsTjUPjpgwx/1OZSCgwmFakWy GVKljfMYpl3AtM33mk5lphOc1pt7Ct3crr60fTMZFlFhS3M1JbvyPwP9bQD5ZSuwiEXl dmBbpSzwjJLmIn1SM1wBoSzWF6Ms7YA3gGuE9hF4/lKzAYnxHN8U+18YMEqn2KWKrZaW soC5dK2n/CioDa+yQXa5mivzs7HBSz/ixFOVP67AE4HOiZhWO1JcB2iNLVfg0kLsNYdq 1uzQ== X-Gm-Message-State: AOAM5339DlJ4Aq9BG0FkDlmmlB0Il8wUyMlG/ZrjJscMh5rchA8GwbSZ hjys3I7THkGPqLhUqJoxpRoBcuyByyc= X-Received: by 2002:aa7:818e:: with SMTP id g14mr8107221pfi.27.1593419390963; Mon, 29 Jun 2020 01:29:50 -0700 (PDT) Received: from varodek.localdomain ([106.210.40.90]) by smtp.gmail.com with ESMTPSA id 202sm9133790pfw.84.2020.06.29.01.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 01:29:50 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , Manish Chopra , GR-Linux-NIC-Dev@marvell.com, Greg Kroah-Hartman Cc: Vaibhav Gupta , netdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org Subject: [PATCH v1 1/4] qlge/qlge_main.c: use genric power management Date: Mon, 29 Jun 2020 13:58:16 +0530 Message-Id: <20200629082819.216405-2-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629082819.216405-1-vaibhavgupta40@gmail.com> References: <20200629082819.216405-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 Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), etc. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. The driver was also using pci_enable_wake(...,..., 0) to disable wake. Use device_wakeup_disable() instead. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/staging/qlge/qlge_main.c | 36 ++++++++------------------------ 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 402edaeffe12..b6f6f681c77b 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -4763,9 +4763,9 @@ static const struct pci_error_handlers qlge_err_handler = { .resume = qlge_io_resume, }; -static int qlge_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused qlge_suspend(struct device *dev_d) { - struct net_device *ndev = pci_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev_d); struct ql_adapter *qdev = netdev_priv(ndev); int err; @@ -4779,35 +4779,19 @@ static int qlge_suspend(struct pci_dev *pdev, pm_message_t state) } ql_wol(qdev); - err = pci_save_state(pdev); - if (err) - return err; - - pci_disable_device(pdev); - - pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } -#ifdef CONFIG_PM -static int qlge_resume(struct pci_dev *pdev) +static int __maybe_unused qlge_resume(struct device *dev_d) { - struct net_device *ndev = pci_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev_d); struct ql_adapter *qdev = netdev_priv(ndev); int err; - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - err = pci_enable_device(pdev); - if (err) { - netif_err(qdev, ifup, qdev->ndev, "Cannot enable PCI device from suspend\n"); - return err; - } pci_set_master(pdev); - pci_enable_wake(pdev, PCI_D3hot, 0); - pci_enable_wake(pdev, PCI_D3cold, 0); + device_wakeup_disable(dev_d); if (netif_running(ndev)) { err = ql_adapter_up(qdev); @@ -4820,22 +4804,20 @@ static int qlge_resume(struct pci_dev *pdev) return 0; } -#endif /* CONFIG_PM */ static void qlge_shutdown(struct pci_dev *pdev) { - qlge_suspend(pdev, PMSG_SUSPEND); + qlge_suspend(&pdev->dev); } +static SIMPLE_DEV_PM_OPS(qlge_pm_ops, qlge_suspend, qlge_resume); + static struct pci_driver qlge_driver = { .name = DRV_NAME, .id_table = qlge_pci_tbl, .probe = qlge_probe, .remove = qlge_remove, -#ifdef CONFIG_PM - .suspend = qlge_suspend, - .resume = qlge_resume, -#endif + .driver.pm = &qlge_pm_ops, .shutdown = qlge_shutdown, .err_handler = &qlge_err_handler }; -- 2.27.0