From patchwork Thu Nov 7 08:44:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhu X-Patchwork-Id: 13866002 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2069.outbound.protection.outlook.com [40.107.247.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A20B1DC18B for ; Thu, 7 Nov 2024 08:35:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730968514; cv=fail; b=dpWadQOxCf09Ly6DeYL/btG2OnwNLLQPQquBefGdFVOVsPb07px1UK9amh+B7apCHofAcK+MS90ZCIS8Abk2F2zejVdNlWQiVXcXbNFRGjrAM8Ei3f9bSE1OXNuP36WkFz/CsJKJ3YOmnpD2bi0dpvKKQGEs+RX2+H7tIEzPp6k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730968514; c=relaxed/simple; bh=H7mjlRPdK40FEvdH4bmaeoT9tTh/ZGiZ3SsyeBt18ss=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=iQ0pkCplqdi9Wk1vyM5XFQ5Y2mKsEvW94J7/hsI8MinZF+LVAw1qmEF9GSVlCh+Avq/nKjevuQg9SHVq/XvQcG0JfKAZ8MgM1sJbjd/RmG330mGNCWTTeSRAudCGzQyBvGGJeVZ16VYaoZ/LvobAMGYKGDwHNBmaRzaTfonzAFY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=H/XP61Op; arc=fail smtp.client-ip=40.107.247.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="H/XP61Op" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MwEwl9QgCw0u24YEPc7o3wlAISdNIh3PknUaXGx+SnN1N8/3EVnrcX5WHXXj4OWJWPpE26EbHMxJurIzIqJzsqub8uOLW1ZnwrdcHm7HaJCWmJ3SfgeGIHM7lP3bcJbKm68Z3HHFaNtKzo098eLuGkcn8Cypui8icF3dW6GfsPXzcj2bm4Ns7S8Ydo86kM9UvZ70esE/2ReUaePPpd7lAMkQcmWTbbCc5MfOlVPO9PtkHlDFs3fjKTdJqYIPkAd0w+UdBxD1EUYjJGvfMaFcXlVzdFkjzpEwmlTiUjeoZln+nIMRleXyvkl8SEDZftsRZSKw6sbbHLxYuwNIfwtnmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XZvH3gt6g6E4MJzd8KA8i9b51Tvnsmsc0XSRVcwILdo=; b=Y9g6WaKi9vulvG30ZTesooHo2Y6+yEKnXUf5Bre/R6xwg+/9p9THnojYOHh69eYm8lq+JAzpTElyP8VIAfuIak9wgf/ygx5KQ7c2iPIVezFDG+cooDh9NiRr78L8bM9d1XeqfR1i8vYus6xEMpJq6PLuEO+TmyOOwnQCaaf15MMVw3SBZ8cl0FUy6y/qaJoj79ASAAK6aC2rZ4N4Xj4drwjFhjczcavZ9oJpgkBySPnRCrebQjiMp4WFx15V93DGs2iEUyUBjFqvi0OSpEyBhX8723uyZHvfjjo01/cwbT88sfjVWonxKW2Ihy+/3i154XeSfM14X3C50BMHhCFPcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XZvH3gt6g6E4MJzd8KA8i9b51Tvnsmsc0XSRVcwILdo=; b=H/XP61OpyR3tr8ot7acjtPV9hu9spj0cmyMArF5kzDTvgt/XjIvWhGtHdc8Ero7FJwFkMQ6F7CHot5Va6OjGskOO+4glmpXaK230YUTin6zf5tQeIRq1dsX0rbbXrchEeHCjRqKdTu5IIqIRcbfPfp7CnlXaZHMvrWY0xLc/V9C5gI4I+fGgp2a0xIU5o9z2JswDTai7ut9aJbtd9XyXhb4T/bPs0dOnBeo0XWCa+C4Akxx/LeeexIRagy/MujLG68/ODIa/OF/DTHtRFleoI99KWw28usvXe85gE1gCf6SfYU7iQKKDrL7vvzZx8NIGABapxPCO3aBrTer5e5T5ow== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8676.eurprd04.prod.outlook.com (2603:10a6:20b:42b::10) by VI1PR04MB6847.eurprd04.prod.outlook.com (2603:10a6:803:134::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 08:35:07 +0000 Received: from AS8PR04MB8676.eurprd04.prod.outlook.com ([fe80::28b2:de72:ad25:5d93]) by AS8PR04MB8676.eurprd04.prod.outlook.com ([fe80::28b2:de72:ad25:5d93%7]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 08:35:07 +0000 From: Richard Zhu To: jingoohan1@gmail.com, bhelgaas@google.com, lpieralisi@kernel.org, kw@linux.com, manivannan.sadhasivam@linaro.org, robh@kernel.org, frank.li@nxp.com Cc: imx@lists.linux.dev, kernel@pengutronix.de, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Zhu Subject: [PATCH v1] PCI: dwc: Clean up some unnecessary codes in dw_pcie_suspend_noirq() Date: Thu, 7 Nov 2024 16:44:55 +0800 Message-Id: <20241107084455.3623576-1-hongxing.zhu@nxp.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: SI1PR02CA0041.apcprd02.prod.outlook.com (2603:1096:4:1f6::18) To AS8PR04MB8676.eurprd04.prod.outlook.com (2603:10a6:20b:42b::10) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8676:EE_|VI1PR04MB6847:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c20da41-b965-42a0-e322-08dcff071535 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: E3PPxVvMdo1yqR/2PrFfmcG6JPcd8muJ7c6VkBso+xy0xEDNZ5EKNzLrv6zFRpiR9rJf5hX21p3qSjaj/4diAjdJeMkJSK75B5nCOCF7JyQXA5VtrJO+4aagiq0Fp+Tm2nZbX4MDcx+GTSkjjyGw7SlPavLmCf5M+lXTfNVJxfg18NF2HBaUku17iOv10B4Sahj9kpM0qM0TCD3Sa6gXwa2GqONN8WWF2aVb9qHQuuXBR3c16v0DLf/fCb+iXIHqqECYras7YJNaajYQd61y2ISH1qi9nYKnLX2ai/KIFYZRA6Q4k06TZ7HEJxV4Th1wDz7Tt7X8qsprUktlCqUAyyeMOdwDXVkPieA54tliKCQjZq/ojDlArjHauz5dKR8Oe973aVshmDqoBHtR926siYaaLJh5Tv+XszuDRdP7fx8/bPHuVpJustTSCjmUiP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(7416014)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p70JZ/sNg87hmkBrNRpt1fcixqAgCQ6iJLhNQCXpHkfU8mQycCNrwuqIX2HkMZrgUwu3Z1p7SkU2zNntNovY6u14/KFr4KredTaoNijQXsxhqYTL5JFT7iKCwmnWe94f/J2Vt3Dck0oRCJvKp7n6PNnPWTjkmW9H9/UnSGkWdhjdNbGcWceo0hgXKpRHylmvP2KfF25rmxpih2+EAJBcQ91bIhPfMkii2PXBDWuMWLFVNmNtPJdBkJuxcc9I6elT/CNZNSpw323D6li6V/lMqsQpU6SH7BQg80AEARDV7uiIuiw+6d9v/7cKHmAQrdbFvgbSC0S/ddV6+CCmzdy44qs3up7zRrhcvBdha+904RD4TtAHFQjploCHbzm4PEmLRerAsTZFSD2viwi2GJNTKHQ6yljVwgCUwmdEEDPgDNHB87Joezzfi3Z06p1E0kugp5mp9bDineFTaUawVaBblD1JktfR5YfY8Iz/iG169xE1aaDduh9qEF1ItwdC7LgbsBBW8HHdUX0z1lpH69slKEYRj/IJtpSaCc+dfOATnPQhHesNC/FqDlQ2ypIswclxeBBPGbIuiZ2FSfAhtDe/W96mnWTXh/MftGbQgAOUvsQl07kDQCSdHCWpe4mdHXQV5noXEXYckDG0GD/I2Hlz75XR4buDIObh3GjxifCDlIVd0PPEekfLJLalt3yt9ItA66tdvTNoZWjwt1sAL9LX8hFHhubnPSElbU8/he3NKvGJQBnEbKKjD8kCLG2NabHwfzV5F08iEJOu+QRyb6BQuUI2/cP1NlOurG/QzXFudX9OmfpR/TyMeKf2v/3+Gm8wNxGo+i5J+iJG7ilbwAobfEo1t98mQV7XXiOXre9NWttSJDbjS5u/cnwhUbbjNUnabBEvIZ5yDmoLXDf4uwL9CS6MWJ6oevD1aiVrS1rBl6NRnOWS7Hul41w/8LLZytBmOrLdUK5VqZfv0vykwC7gW+Sf5aYsI6Gtfzn8Mxp1lJjcK8fL+d/EJL1TYGyoxT1+hqt64iVx2FHCcldJIJt2pEod+3Bg3zo5THtIivDcVx2RzlM3rf2n4cWHiteJn7XlJksTEfjj/c2kpRE/0rcN2Y0oYg3pGmh1u/O+7uh50en4piplY0SdpC5sWuJY1lAqX56fSZFVoVSP2YiI02RLLNosipnHmgGwOeAScH3nqy3Fwo5MjiWjQ++iKr2bImXv7XJR9Rj5AOlocACbWaJOr91ycV0HqFttAzA7CEQlyyU4P0q2M8h4sCnY8UPbRtcmX4QmP9KCy0w7w//bxXqA7UQJ4HvPuU95SnoPE798LhovvGIITu/AfLcqb86WJstFMe8YFJrlMkM0uq4eJjZMRTQYUJR3/YDOwxU4jBeyfoePELlfxFM8Y+oZ8lCIGrmACKGv4ci28ZS8s3QeDNIbtbYOXP3KFc+OP35TNdoCic24CGQOUwOt5aMO2LdoP86UhNdAsiO7JRQk6arNjBFvXjKoS+5Byz/lqU6nAWlHG5U7cvUjt65uCM/DlQzBRr2lo+x/YcA0l02aaBoC3UluKsnQinDrIaI+yxpefad2XflPfWPfeSy4jQX5nvXAn4Ee X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c20da41-b965-42a0-e322-08dcff071535 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8676.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 08:35:06.8761 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6sNyoIfVsI20iY/Qhs4O8eheTnXX2NLIrEzEElEbejFlkrSOeQLc+X+enXNaoy+Dd/DGgPzugbgOVN8aSXZshA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6847 Before sending PME_TURN_OFF, don't test the LTSSM stat. Since it's safe to send PME_TURN_OFF message regardless of whether the link is up or down. So, there would be no need to test the LTSSM stat before sending PME_TURN_OFF message. Remove the L2 poll too, after the PME_TURN_OFF message is sent out. Because the re-initialization would be done in dw_pcie_resume_noirq(). Signed-off-by: Richard Zhu --- .../pci/controller/dwc/pcie-designware-host.c | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index f86347452026..64c49adf81d2 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -917,7 +917,6 @@ static int dw_pcie_pme_turn_off(struct dw_pcie *pci) int dw_pcie_suspend_noirq(struct dw_pcie *pci) { u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); - u32 val; int ret = 0; /* @@ -927,23 +926,12 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci) if (dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKCTL) & PCI_EXP_LNKCTL_ASPM_L1) return 0; - /* Only send out PME_TURN_OFF when PCIE link is up */ - if (dw_pcie_get_ltssm(pci) > DW_PCIE_LTSSM_DETECT_ACT) { - if (pci->pp.ops->pme_turn_off) - pci->pp.ops->pme_turn_off(&pci->pp); - else - ret = dw_pcie_pme_turn_off(pci); - + if (pci->pp.ops->pme_turn_off) { + pci->pp.ops->pme_turn_off(&pci->pp); + } else { + ret = dw_pcie_pme_turn_off(pci); if (ret) return ret; - - ret = read_poll_timeout(dw_pcie_get_ltssm, val, val == DW_PCIE_LTSSM_L2_IDLE, - PCIE_PME_TO_L2_TIMEOUT_US/10, - PCIE_PME_TO_L2_TIMEOUT_US, false, pci); - if (ret) { - dev_err(pci->dev, "Timeout waiting for L2 entry! LTSSM: 0x%x\n", val); - return ret; - } } dw_pcie_stop_link(pci);