Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3046663ybt; Mon, 29 Jun 2020 13:51:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDhQwRn5G8lKxOg+3ubL0dw8oRJcj4rG1chO5SM5duWXdBpTFTXH8Vi6zVAoftRLewYcEf X-Received: by 2002:a17:906:fcba:: with SMTP id qw26mr15295508ejb.112.1593463885994; Mon, 29 Jun 2020 13:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593463885; cv=none; d=google.com; s=arc-20160816; b=ZNPZVOFNqXXKD4jKmS5UqlbvA2qzvQZJ0gNqdVxQNI8t2GneX3lqehodaaXx5T0iYD UdxnxLbKGeHnmyX35gnNDeNu3m0o844+VKrYpiJa71QdEItv48GOMd+qxJYYVt7daKQ0 DkK0GUmhOuQATfzqL+R1dsjWI+tClNnReQGBKR33aRWTqj0ywQoB8c3PYGH2FoZ5qIv5 QrzjDA9gabzZLUBkLWwKwPMpOejDOpBlpFZidkfHc5mt3hcXcPDt5xSxN45AClYMvJjL RL6yXYpmJNG7T/UDrEDIgkcWQmYnyWRcdTEqfF3BrBKGekRZNfV6sR3+wvgpz3/KYUQ6 sfdw== 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=BuikRCWls/1715AYcrraFB3A4+eL6QoET64hwm9dIIo=; b=Bl8tUEhJ+K6gj42xDaOeAcR8CNMUPI6Hix37KO9iQj/MCSkpNPFPaxJ22lPKpXo3LR 2cvL0oxrHjHLBATjMssteTzV4SfOB/jAiVvtPb9g2l3tMxhZhT7dlw+UQzNALb4jO7Ig VAlv2NiBkJQgCCATrz14swdK0agR/dFvwHtlPFnSCYz5pk6EjfB3X9NgoXQDT+tL7J2m OwwWI+TFiz9yohYRh+nSxoF8WAkYpftFv8gxXaAWIsbl3mtMK9EDuoo9CQTdlIJHwo7T q0Y/VydZd5HwOYfZWkr2ZSyLwuGA/+2KoPtbQmSmfnNKTy6SzTV3S4WggCKvWBQ+HHXF 8YBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="jP/gf47e"; 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 e17si322484ejk.740.2020.06.29.13.51.03; Mon, 29 Jun 2020 13:51:25 -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="jP/gf47e"; 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 S1732172AbgF2UsP (ORCPT + 99 others); Mon, 29 Jun 2020 16:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731531AbgF2TNv (ORCPT ); Mon, 29 Jun 2020 15:13:51 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66BD3C0149C5 for ; Mon, 29 Jun 2020 01:17:48 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id y18so6808094plr.4 for ; Mon, 29 Jun 2020 01:17:48 -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=BuikRCWls/1715AYcrraFB3A4+eL6QoET64hwm9dIIo=; b=jP/gf47eOAWCydT0MD5J/MqFLIRfzGNtbv40edfut0G47CNTlMQkGiwDTp8xadJX4m D0ShTR3QHMoyP4xFqKl6nb+ZPOSRDBgEhhTYvvSt5M+RNSKIk3xY0J/bTlyeOnbe9KXn RiStoGsGpw4efhK8fTVYZkT4za65116Fagz+kiU+Xdf4vhkcZ2p61i8n4wuI4gRPRpvG tRp+Gtgfl/ZgR2Op/u0RByKENB6mlWeg6AodbP/0TUMtDvEHSquIMc7JFv28XiF1zWxb 4AIdYlbgOOtpFD7JY1NyI55tClHbn8OCiK9MuBaINVMawfj3E2oIaw2650c5P8+MeHOi rFRQ== 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=BuikRCWls/1715AYcrraFB3A4+eL6QoET64hwm9dIIo=; b=XMm4KfjMTBwLBhp7j5Bsz92Qto5e8mRnrCT5fRA/R3O5dkffq2AqRlPJfDSnHXhCpL FFHsfKK4N8XeM2/Lw6dq7CcRUboEmk+4Zixo2N61nQj4q3Am+CXWjBNVyBlx5Uqda4wz Jcw/NTjuCADFmPAv2VBLoweAowTcC9rh5AQJfqdtzRuBK/qUgu+lhL8PvdRFMR1jTUkK K5SG8/hAaSYt9JaE6HfVv31nhsxZ6UeNpqRPG9Syzy8vToIz/l8Ye6uphuaX5saNG1dP jYYXSGnqpZmK746KoFEAPrfQnxFvwK5xG7y9RB62+Fei4EFU/Y4GpVs2mWeYxa8QHO/z VvSQ== X-Gm-Message-State: AOAM532yBRZU9FUjEFjnfS8SOmCw/Vrpnvbrv9TRau6cz3TZtCJO6t2J 2vHIlpV7rhWOsKhyLh2e35s= X-Received: by 2002:a17:90a:304d:: with SMTP id q13mr16206436pjl.73.1593418667901; Mon, 29 Jun 2020 01:17:47 -0700 (PDT) Received: from varodek.localdomain ([106.210.40.90]) by smtp.gmail.com with ESMTPSA id co1sm3345154pjb.34.2020.06.29.01.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 01:17:47 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , Arnd Bergmann , Greg Kroah-Hartman , Jiri Slaby , Alex Dubov Cc: Vaibhav Gupta , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org Subject: [PATCH v1 5/5] misc/pch_phub.c: use generic power management Date: Mon, 29 Jun 2020 13:45:31 +0530 Message-Id: <20200629081531.214734-6-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629081531.214734-1-vaibhavgupta40@gmail.com> References: <20200629081531.214734-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. It was also saving device register configuration using pch_phub_save/restore_reg_conf() which is not recommended. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/misc/pch_phub.c | 48 ++++++++--------------------------------- 1 file changed, 9 insertions(+), 39 deletions(-) diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c index 60828af7506a..9321d4239932 100644 --- a/drivers/misc/pch_phub.c +++ b/drivers/misc/pch_phub.c @@ -147,9 +147,8 @@ static void pch_phub_read_modify_write_reg(struct pch_phub_reg *chip, iowrite32(((ioread32(reg_addr) & ~mask)) | data, reg_addr); } -#ifdef CONFIG_PM /* pch_phub_save_reg_conf - saves register configuration */ -static void pch_phub_save_reg_conf(struct pci_dev *pdev) +static void __maybe_unused pch_phub_save_reg_conf(struct pci_dev *pdev) { unsigned int i; struct pch_phub_reg *chip = pci_get_drvdata(pdev); @@ -210,7 +209,7 @@ static void pch_phub_save_reg_conf(struct pci_dev *pdev) } /* pch_phub_restore_reg_conf - restore register configuration */ -static void pch_phub_restore_reg_conf(struct pci_dev *pdev) +static void __maybe_unused pch_phub_restore_reg_conf(struct pci_dev *pdev) { unsigned int i; struct pch_phub_reg *chip = pci_get_drvdata(pdev); @@ -270,7 +269,6 @@ static void pch_phub_restore_reg_conf(struct pci_dev *pdev) if ((chip->ioh_type == 2) || (chip->ioh_type == 4)) iowrite32(chip->funcsel_reg, p + FUNCSEL_REG_OFFSET); } -#endif /** * pch_phub_read_serial_rom() - Reading Serial ROM @@ -835,48 +833,19 @@ static void pch_phub_remove(struct pci_dev *pdev) kfree(chip); } -#ifdef CONFIG_PM - -static int pch_phub_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused pch_phub_suspend(struct device *dev_d) { - int ret; - - pch_phub_save_reg_conf(pdev); - ret = pci_save_state(pdev); - if (ret) { - dev_err(&pdev->dev, - " %s -pci_save_state returns %d\n", __func__, ret); - return ret; - } - pci_enable_wake(pdev, PCI_D3hot, 0); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); + device_wakeup_disable(dev_d); return 0; } -static int pch_phub_resume(struct pci_dev *pdev) +static int __maybe_unused pch_phub_resume(struct device *dev_d) { - int ret; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - ret = pci_enable_device(pdev); - if (ret) { - dev_err(&pdev->dev, - "%s-pci_enable_device failed(ret=%d) ", __func__, ret); - return ret; - } - - pci_enable_wake(pdev, PCI_D3hot, 0); - pch_phub_restore_reg_conf(pdev); + device_wakeup_disable(dev_d); return 0; } -#else -#define pch_phub_suspend NULL -#define pch_phub_resume NULL -#endif /* CONFIG_PM */ static const struct pci_device_id pch_phub_pcidev_id[] = { { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH1_PHUB), 1, }, @@ -888,13 +857,14 @@ static const struct pci_device_id pch_phub_pcidev_id[] = { }; MODULE_DEVICE_TABLE(pci, pch_phub_pcidev_id); +static SIMPLE_DEV_PM_OPS(pch_phub_pm_ops, pch_phub_suspend, pch_phub_resume); + static struct pci_driver pch_phub_driver = { .name = "pch_phub", .id_table = pch_phub_pcidev_id, .probe = pch_phub_probe, .remove = pch_phub_remove, - .suspend = pch_phub_suspend, - .resume = pch_phub_resume + .driver.pm = &pch_phub_pm_ops, }; module_pci_driver(pch_phub_driver); -- 2.27.0