From patchwork Tue Oct 25 20:38:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 10982 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1207156wru; Tue, 25 Oct 2022 13:43:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6LFtIn7z9hFtL3ejhyqKTbw5tQPyAEtKLN1+CMr8PTTVwBaXI+val/oG+Cc7P607PiXB0V X-Received: by 2002:a17:90b:4b42:b0:20d:954e:28d with SMTP id mi2-20020a17090b4b4200b0020d954e028dmr133828pjb.93.1666730598932; Tue, 25 Oct 2022 13:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666730598; cv=none; d=google.com; s=arc-20160816; b=jkHIxVNaOmcjJoLL5udlFe3aBtM0W/y3Iiar39GDjp0RmJplsR3XE/doCSK3FnDfag PBe7fJy3IwvykaGdxI2xF8bSF6U/tSxukMOJ45QnT4nys193ZgHLLZRH/eLl7QagSqaI 2D8iPBTWd2AK3uxy6Jn0M31VWJxXC4SGSf0aCO4boHbNePf0/xbKudNx5lsbwBopL3wy aolWqA/fXwKtDioOBLDI/LsRT+FbOHFctO+Y4YS98dBJDGBpb9S0V25cx4XX3aEunCoY 1HtYXkdLkCTnhIbne0tLqfKLe/NsMzD6ta5aGrbDBuGL7DzAu+35HY6nVbuSxt++m2nt 8+AA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KdMVDJF2s9cRnSP3tN46zA1QeLPJANoY1PhVU3Conz4=; b=nX/5XSLRHDrhMR6bX+uW8Veo9wV79wYg0SKw+bIic7tRy6ggLSxiNFaae5U7qOUxyd ckPeQ7cORqKJbGu/zjJW0N1LpTrTeCVfjJflBhAW2iV4iHB+2zPoNMSXVYFxA+Dm4QFJ RxFY8K+niO0KIOikJiyyLcOzawn3e0VmNy4dGvbTsQMRJqvhpx76EFaICcG1tDCRjxra W4TJfwe1nMi/+8gxMixjAaIP5Zim7oaiTuzM6II0g6v7H9szLbuhzz0p7o9mTRBUVSmc MhGKcXdXoAvlPOS/6N+bcZeh83eLs3V3YCzp1HG//uaNxaI2jm2Qpy/FX5I4rJnZKMzT Edsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D8wzUcoD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170902f35100b0017f6a3970c1si3330845ple.599.2022.10.25.13.43.05; Tue, 25 Oct 2022 13:43:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D8wzUcoD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232898AbiJYUj1 (ORCPT + 99 others); Tue, 25 Oct 2022 16:39:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232576AbiJYUjJ (ORCPT ); Tue, 25 Oct 2022 16:39:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A113AAC4B9; Tue, 25 Oct 2022 13:39:07 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 3E23761939; Tue, 25 Oct 2022 20:39:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72DF9C433C1; Tue, 25 Oct 2022 20:39:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666730346; bh=vCVXdFd/vOJXZ5Ft1C9G2B9SS3OtMyZNZFuvq1nhZBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D8wzUcoDPeAJB096khZ8JyEU6r0mOW1CQ/O+2NeKYhPNYW7b8yQvH8TqGLqxkOtw2 RHDkkr8PWqIYyp+5rOtSlyeMBPdMtdLTjJdqq4jb2r5FlQLwlWZivRKUuXcahjEV/P FTddle25VtNJDm2ponpgOVIBNE6OixgfF5MNdjk3qb3y7ZBCPjnVny8+ld0ZtRJX6y xhD9mzSCCrnm6qRU6jljCJNSAEn5jCEvEEqhyJnnjjiHwuqf+jdRAjCyG36UENQYZe 9casbCa3wXXas87x9KSs6l8OCIp7aluPD4D5qnHfr9yu+CUoopyMF/bZ0gUVcmBH2h 60NDA9fbqEXnQ== From: Bjorn Helgaas To: David Airlie Cc: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , "Rafael J . Wysocki" , Vaibhav Gupta , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH v2 4/8] agp/ati: Convert to generic power management Date: Tue, 25 Oct 2022 15:38:48 -0500 Message-Id: <20221025203852.681822-5-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221025203852.681822-1-helgaas@kernel.org> References: <20221025203852.681822-1-helgaas@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747693704615009152?= X-GMAIL-MSGID: =?utf-8?q?1747693704615009152?= From: Bjorn Helgaas Convert agpgart-ati from legacy PCI power management to the generic power management framework. Previously agpgart-ati used legacy PCI power management, and agp_ati_suspend() and agp_ati_resume() were responsible for both device-specific things and generic PCI things like saving and restoring config space and managing power state: agp_ati_suspend pci_save_state <-- generic PCI pci_set_power_state(PCI_D3hot) <-- generic PCI agp_ati_resume pci_set_power_state(PCI_D0) <-- generic PCI pci_restore_state <-- generic PCI ati_configure <-- device-specific With generic power management, the PCI bus PM methods do the generic PCI things, and the driver needs only the device-specific part, i.e., suspend_devices_and_enter dpm_suspend_start(PMSG_SUSPEND) pci_pm_suspend # PCI bus .suspend() method agp_ati_suspend <-- not needed at all; removed suspend_enter dpm_suspend_noirq(PMSG_SUSPEND) pci_pm_suspend_noirq # PCI bus .suspend_noirq() method pci_save_state <-- generic PCI pci_prepare_to_sleep <-- generic PCI pci_set_power_state ... dpm_resume_end(PMSG_RESUME) pci_pm_resume # PCI bus .resume() method pci_restore_standard_config pci_set_power_state(PCI_D0) <-- generic PCI pci_restore_state <-- generic PCI agp_ati_resume # driver->pm->resume ati_configure <-- device-specific Based on 0aeddbd0cb07 ("via-agp: convert to generic power management") by Vaibhav Gupta . Signed-off-by: Bjorn Helgaas --- drivers/char/agp/ati-agp.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c index 6f5530482d83..3c1fce48aabe 100644 --- a/drivers/char/agp/ati-agp.c +++ b/drivers/char/agp/ati-agp.c @@ -238,23 +238,10 @@ static int ati_configure(void) } -#ifdef CONFIG_PM -static int agp_ati_suspend(struct pci_dev *dev, pm_message_t state) +static int agp_ati_resume(struct device *dev) { - pci_save_state(dev); - pci_set_power_state(dev, PCI_D3hot); - - return 0; -} - -static int agp_ati_resume(struct pci_dev *dev) -{ - pci_set_power_state(dev, PCI_D0); - pci_restore_state(dev); - return ati_configure(); } -#endif /* *Since we don't need contiguous memory we just try @@ -559,15 +546,14 @@ static const struct pci_device_id agp_ati_pci_table[] = { MODULE_DEVICE_TABLE(pci, agp_ati_pci_table); +static DEFINE_SIMPLE_DEV_PM_OPS(agp_ati_pm_ops, NULL, agp_ati_resume); + static struct pci_driver agp_ati_pci_driver = { .name = "agpgart-ati", .id_table = agp_ati_pci_table, .probe = agp_ati_probe, .remove = agp_ati_remove, -#ifdef CONFIG_PM - .suspend = agp_ati_suspend, - .resume = agp_ati_resume, -#endif + .driver.pm = &agp_ati_pm_ops, }; static int __init agp_ati_init(void)