From patchwork Wed Dec 1 02:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 1561988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=nWjvklpo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4J3kFp2p9Jz9tkd for ; Wed, 1 Dec 2021 13:54:38 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346281AbhLAC5z (ORCPT ); Tue, 30 Nov 2021 21:57:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241510AbhLAC5w (ORCPT ); Tue, 30 Nov 2021 21:57:52 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A516CC06174A; Tue, 30 Nov 2021 18:54:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id F17CDCE1759; Wed, 1 Dec 2021 02:54:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C992C53FC7; Wed, 1 Dec 2021 02:54:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638327268; bh=dvZcBCOO3kK40wuUuAubrhwy3njIEl4xYCrgjYTfBIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nWjvklpoAs0/T2VrbflU7VrlwCYRznKQrkboHoIyttkIwrx/+nmRzdgmHN6rs8F/N 2IlHszKLRYTnmrR5rnlEvDaoGn4CDSJl3K0/mY840wlpCOKAkVKlkglkP9TvzKLhs5 Z1sNnxiMdJgVb2VslgocjBWY8n3e+jR4hWJy0tkGMTkrC1kf51XNroz/WYNFZcKCtt MlqOYyPScGtTiSPboI9zecn2A1NrWNrOV3etZJ21sUZbRw8uhGQd1unnI1Cjpk2Rk5 VtpSZVf5D/5PFX99Qm1Nit4/o56ZHlZLHyv3A09k/pSB8nJVGUtnEuAZaoVBDaWIoi IcCBVqsKydczw== From: Bjorn Helgaas To: David Airlie Cc: Vaibhav Gupta , Vaibhav Gupta , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [PATCH v2 1/3] amd64-agp: convert to generic power management Date: Tue, 30 Nov 2021 20:54:17 -0600 Message-Id: <20211201025419.2797624-2-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211201025419.2797624-1-helgaas@kernel.org> References: <20211201025419.2797624-1-helgaas@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Vaibhav Gupta Convert amd64-agp from legacy PCI power management to the generic power management framework. Previously, amd64-agp used legacy PCI power management. agp_amd64_suspend() looked like this: agp_amd64_suspend pci_save_state(pdev) pci_set_power_state(pdev, pci_choose_state(pdev, state)) With generic power management, these are both done by the PCI core in pci_pm_runtime_suspend(), so drop agp_amd64_suspend() completely. agp_amd64_resume() looked like this: agp_amd64_resume pci_set_power_state(pdev, PCI_D0) pci_restore_state(pdev) ... With generic power management, the PCI parts are done by pci_pm_runtime_resume(), so drop those from agp_amd64_resume(). [bhelgaas: commit log] Signed-off-by: Vaibhav Gupta Signed-off-by: Bjorn Helgaas --- drivers/char/agp/amd64-agp.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index b40edae32817..dc78a4fb879e 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c @@ -588,20 +588,11 @@ static void agp_amd64_remove(struct pci_dev *pdev) agp_bridges_found--; } -#ifdef CONFIG_PM +#define agp_amd64_suspend NULL -static int agp_amd64_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused agp_amd64_resume(struct device *dev) { - pci_save_state(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - - return 0; -} - -static int agp_amd64_resume(struct pci_dev *pdev) -{ - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); + struct pci_dev *pdev = to_pci_dev(dev); if (pdev->vendor == PCI_VENDOR_ID_NVIDIA) nforce3_agp_init(pdev); @@ -609,8 +600,6 @@ static int agp_amd64_resume(struct pci_dev *pdev) return amd_8151_configure(); } -#endif /* CONFIG_PM */ - static const struct pci_device_id agp_amd64_pci_table[] = { { .class = (PCI_CLASS_BRIDGE_HOST << 8), @@ -738,15 +727,14 @@ static const struct pci_device_id agp_amd64_pci_promisc_table[] = { { } }; +static SIMPLE_DEV_PM_OPS(agp_amd64_pm_ops, agp_amd64_suspend, agp_amd64_resume); + static struct pci_driver agp_amd64_pci_driver = { .name = "agpgart-amd64", .id_table = agp_amd64_pci_table, .probe = agp_amd64_probe, .remove = agp_amd64_remove, -#ifdef CONFIG_PM - .suspend = agp_amd64_suspend, - .resume = agp_amd64_resume, -#endif + .driver.pm = &agp_amd64_pm_ops, }; From patchwork Wed Dec 1 02:54:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 1561989 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=VTHt1iOD; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4J3kFp5PvBz9tkj for ; Wed, 1 Dec 2021 13:54:38 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346283AbhLAC54 (ORCPT ); Tue, 30 Nov 2021 21:57:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233453AbhLAC5x (ORCPT ); Tue, 30 Nov 2021 21:57:53 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52BDBC061574; Tue, 30 Nov 2021 18:54:33 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1A692B81DD5; Wed, 1 Dec 2021 02:54:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BFD0C53FCC; Wed, 1 Dec 2021 02:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638327270; bh=Rs5nrByMZEKY50e3/Uybp1EofyQ1cz72KLs3O4vIiuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VTHt1iODePRAHUrXQpKe+QwOyiLxbLEz+nB+knVjM5t5+npWNQCgFogwGuhzFp8gL +lEOr0t7c33hu6Oegss9bZj/unRhzNArb6HNiZDQ6RRzTSb30AFngXEiRkIfI8Gil2 Pm20wxr+Aol8XCAk4EhOQOnJwGiBE7ASipljY7F81eHKRDFAsRrbqH4REuT82j3aJL 6KUNVsrratW0wFG553EdA2pi2N3Hu0MKe5K68wEWujgTf3IPXnJuLJanc85oftSvKd 0F5Bs2KGF2wjzxoofHmBYevb7LE1sZeNsukagUecxkVatBoI70x+0teFxrB4T+Q6MM hXnBe2Ks0DSZQ== From: Bjorn Helgaas To: David Airlie Cc: Vaibhav Gupta , Vaibhav Gupta , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [PATCH v2 2/3] sis-agp: convert to generic power management Date: Tue, 30 Nov 2021 20:54:18 -0600 Message-Id: <20211201025419.2797624-3-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211201025419.2797624-1-helgaas@kernel.org> References: <20211201025419.2797624-1-helgaas@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Vaibhav Gupta Convert sis-agp from legacy PCI power management to the generic power management framework. Previously, sis-agp used legacy PCI power management. agp_sis_suspend() looked like this: agp_sis_suspend pci_save_state(pdev) pci_set_power_state(pdev, pci_choose_state(pdev, state)) With generic power management, these are both done by the PCI core in pci_pm_runtime_suspend(), so drop agp_sis_suspend() completely. agp_sis_resume() looked like this: agp_sis_resume pci_set_power_state(pdev, PCI_D0) pci_restore_state(pdev) sis_driver.configure() With generic power management, the PCI parts are done by pci_pm_runtime_resume(), so drop those from agp_sis_resume(). [bhelgaas: commit log] Signed-off-by: Vaibhav Gupta Signed-off-by: Bjorn Helgaas --- drivers/char/agp/sis-agp.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c index 14909fc5d767..f8a02f4bef1b 100644 --- a/drivers/char/agp/sis-agp.c +++ b/drivers/char/agp/sis-agp.c @@ -217,26 +217,14 @@ static void agp_sis_remove(struct pci_dev *pdev) agp_put_bridge(bridge); } -#ifdef CONFIG_PM +#define agp_sis_suspend NULL -static int agp_sis_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused agp_sis_resume( + __attribute__((unused)) struct device *dev) { - pci_save_state(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - - return 0; -} - -static int agp_sis_resume(struct pci_dev *pdev) -{ - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - return sis_driver.configure(); } -#endif /* CONFIG_PM */ - static const struct pci_device_id agp_sis_pci_table[] = { { .class = (PCI_CLASS_BRIDGE_HOST << 8), @@ -419,15 +407,14 @@ static const struct pci_device_id agp_sis_pci_table[] = { MODULE_DEVICE_TABLE(pci, agp_sis_pci_table); +static SIMPLE_DEV_PM_OPS(agp_sis_pm_ops, agp_sis_suspend, agp_sis_resume); + static struct pci_driver agp_sis_pci_driver = { .name = "agpgart-sis", .id_table = agp_sis_pci_table, .probe = agp_sis_probe, .remove = agp_sis_remove, -#ifdef CONFIG_PM - .suspend = agp_sis_suspend, - .resume = agp_sis_resume, -#endif + .driver.pm = &agp_sis_pm_ops, }; static int __init agp_sis_init(void) From patchwork Wed Dec 1 02:54:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 1561990 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=SXes2SJR; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4J3kFq0c9Nz9tk7 for ; Wed, 1 Dec 2021 13:54:39 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346286AbhLAC55 (ORCPT ); Tue, 30 Nov 2021 21:57:57 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:35590 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346271AbhLAC5z (ORCPT ); Tue, 30 Nov 2021 21:57:55 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 54CA0B81DD4; Wed, 1 Dec 2021 02:54:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1BBBC53FCB; Wed, 1 Dec 2021 02:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638327273; bh=HX8RCwdqu/46D2qyz9bpRkRtDZWJITkdfTUGokM+JjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SXes2SJReN5hqMLFOqRQLM6srx44ZPKmw+xkKXEr1hjGrSpX1WFqZmvbqqrFdvY4J 02EQ/vSAu/ak1n0c+ebhnoMLoHV66nyg6NH4lDwI8n/YrcgTy7JcauC3UGMrTuKtcZ JkZLGAaJGoC2d38+ORhuMfgrJTVM5kds3xV4hHoPbY7IuB4603DMke7jDvJOUBsLg6 ShsUGefIdP88a13c7d99iV91BJyXyoAB0mRVGG63rOaR5lAKasoFJbH596GLRIvy7Y HrNTDfAC2zlQn+zGkAFFUliySqodcRKKDLMPgU1Q8uqWwnUYdtH7qpNVk6xpy2KHOY XFXMx9IIC2VEQ== From: Bjorn Helgaas To: David Airlie Cc: Vaibhav Gupta , Vaibhav Gupta , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas Subject: [PATCH v2 3/3] via-agp: convert to generic power management Date: Tue, 30 Nov 2021 20:54:19 -0600 Message-Id: <20211201025419.2797624-4-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211201025419.2797624-1-helgaas@kernel.org> References: <20211201025419.2797624-1-helgaas@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Vaibhav Gupta Convert via-agp from legacy PCI power management to the generic power management framework. Previously, via-agp used legacy PCI power management. agp_via_suspend() looked like this: agp_via_suspend pci_save_state(pdev) pci_set_power_state(pdev, pci_choose_state(pdev, state)) With generic power management, these are both done by the PCI core in pci_pm_runtime_suspend(), so drop agp_via_suspend() completely. agp_via_resume() looked like this: agp_via_resume pci_set_power_state(pdev, PCI_D0) pci_restore_state(pdev) ... With generic power management, the PCI parts are done by pci_pm_runtime_resume(), so drop those from agp_via_resume(). [bhelgaas: commit log] Signed-off-by: Vaibhav Gupta Signed-off-by: Bjorn Helgaas --- drivers/char/agp/via-agp.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c index 87a92a044570..a460ae352772 100644 --- a/drivers/char/agp/via-agp.c +++ b/drivers/char/agp/via-agp.c @@ -492,22 +492,11 @@ static void agp_via_remove(struct pci_dev *pdev) agp_put_bridge(bridge); } -#ifdef CONFIG_PM +#define agp_via_suspend NULL -static int agp_via_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused agp_via_resume(struct device *dev) { - pci_save_state (pdev); - pci_set_power_state (pdev, PCI_D3hot); - - return 0; -} - -static int agp_via_resume(struct pci_dev *pdev) -{ - struct agp_bridge_data *bridge = pci_get_drvdata(pdev); - - pci_set_power_state (pdev, PCI_D0); - pci_restore_state(pdev); + struct agp_bridge_data *bridge = dev_get_drvdata(dev); if (bridge->driver == &via_agp3_driver) return via_configure_agp3(); @@ -517,8 +506,6 @@ static int agp_via_resume(struct pci_dev *pdev) return 0; } -#endif /* CONFIG_PM */ - /* must be the same order as name table above */ static const struct pci_device_id agp_via_pci_table[] = { #define ID(x) \ @@ -567,16 +554,14 @@ static const struct pci_device_id agp_via_pci_table[] = { MODULE_DEVICE_TABLE(pci, agp_via_pci_table); +static SIMPLE_DEV_PM_OPS(agp_via_pm_ops, agp_via_suspend, agp_via_resume); static struct pci_driver agp_via_pci_driver = { .name = "agpgart-via", .id_table = agp_via_pci_table, .probe = agp_via_probe, .remove = agp_via_remove, -#ifdef CONFIG_PM - .suspend = agp_via_suspend, - .resume = agp_via_resume, -#endif + .driver.pm = &agp_via_pm_ops, };