From patchwork Tue Sep 27 14:19:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12990701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EFAAC6FA82 for ; Tue, 27 Sep 2022 14:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=a7wGc0lzhrkoFY4gybPMb3tOImR/HtJ3yy8NAD2Y7ks=; b=0eU0h0uNgEleJx gFjfyvq0D0AkDCDrlzOEiSTSlX4Nv+wxxp2HBFuJHiuzsC6E9Oyk1B1ohVm42VW8eChV1UZs+D+ar IpuOnLmUhKi+gNw37LW1m2bn+iTydaeeZazOQLl4EFD7lY9R0My5KbiClh0JMkkjreh7x91YJxmsW 5c1oJJlPDz/yW17wDnMDDicBcx9viQpfs9G2nXHrWIcTGmhIhcWWDcZQV1t+Mqei5g3DNUv7ISPcA nZu79QNxJgRWdhrUDNbKHDYLOdqixhHvkUz7pqUhLpcOxW5TH4+TEa00/1Wbvpqm/bey7aCLnTc3v 3xZOX9RKhFELoK3mLAIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBRq-00BBMA-Kj; Tue, 27 Sep 2022 14:20:35 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBR2-00BB3q-8R for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2022 14:19:45 +0000 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 CD329619F6; Tue, 27 Sep 2022 14:19:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D273AC433B5; Tue, 27 Sep 2022 14:19:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664288383; bh=o7J6npk2M1p2mUy6ywvZZk3hCCRvaTeij5XETt0TETY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T1HO6/4WY5vpwoo/AiwFbL9VjHuxwuwsvzU/GUUE2GZNJNnCCOHy+51Au7JZuDG6R QfmlncIE0R9axvANVT8IXj3G+pUaOYUrAZT0YdkqVeckAO1tKpyOK0wzITSTYaM6GQ UvmI5IoVY7sdZnv4uDqYCvWlEYu3/f56qq1dGMzjK3rGTzUxiH2IvuwSwVT45F6OXX kKq1T8IATC/JOjuJtJFqrfQsS+rKuKGvAjoDRX7uEMeX6Y1BL3HrZBqibrfeQ01Tii tFiajoZ8pTnhFmLZGSVmTYHPqWCSAyRcqtlFZUwX8wSDvnlKzGqWticllasEazd1M7 9VlYmSYYeqLBQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lorenzo Pieralisi Cc: Bjorn Helgaas , Gregory CLEMENT , pali@kernel.org, =?utf-8?q?K?= =?utf-8?q?rzysztof_Wilczy=C5=84ski?= , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Miquel Raynal , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v2 06/10] PCI: aardvark: Add suspend to RAM support Date: Tue, 27 Sep 2022 16:19:22 +0200 Message-Id: <20220927141926.8895-7-kabel@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220927141926.8895-1-kabel@kernel.org> References: <20220927141926.8895-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220927_071944_433263_DC1279A7 X-CRM114-Status: GOOD ( 16.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Miquel Raynal Add suspend and resume callbacks. We need to use the _noirq variants via NOIRQ_SYSTEM_SLEEP_PM_OPS(), because these are called when IRQ handlers are disabled, as explained in Documentation/driver-api/pm/devices.rst. This ensures that the PCIe controller's IRQ handler is not called during suspend/resume handler, as this could cause races, as explained in the above mentioned file, section Entering System Suspend. Signed-off-by: Miquel Raynal Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- Changes since batch 6 v1: - more explicit commit message Changes since batch 5: - clarified commit message - changed to new macro NOIRQ_SYSTEM_SLEEP_PM_OPS, as was done for many PCI controller drivers with commit 19b7858c3357 ("PCI: Convert to new *_PM_OPS macros") --- drivers/pci/controller/pci-aardvark.c | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 3beafc893969..e30a33a4ecc6 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1890,6 +1890,39 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie) return ret; } +static int advk_pcie_suspend(struct device *dev) +{ + struct advk_pcie *pcie = dev_get_drvdata(dev); + + advk_pcie_disable_phy(pcie); + + clk_disable_unprepare(pcie->clk); + + return 0; +} + +static int advk_pcie_resume(struct device *dev) +{ + struct advk_pcie *pcie = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(pcie->clk); + if (ret) + return ret; + + ret = advk_pcie_enable_phy(pcie); + if (ret) + return ret; + + advk_pcie_setup_hw(pcie); + + return 0; +} + +static const struct dev_pm_ops advk_pcie_dev_pm_ops = { + NOIRQ_SYSTEM_SLEEP_PM_OPS(advk_pcie_suspend, advk_pcie_resume) +}; + static int advk_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -2167,6 +2200,7 @@ static struct platform_driver advk_pcie_driver = { .driver = { .name = "advk-pcie", .of_match_table = advk_pcie_of_match_table, + .pm = &advk_pcie_dev_pm_ops, }, .probe = advk_pcie_probe, .remove = advk_pcie_remove,