From patchwork Thu Mar 10 15:17:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 550945 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25A50C433FE for ; Thu, 10 Mar 2022 15:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236570AbiCJPWS (ORCPT ); Thu, 10 Mar 2022 10:22:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232723AbiCJPWJ (ORCPT ); Thu, 10 Mar 2022 10:22:09 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2071.outbound.protection.outlook.com [40.107.237.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 265921301AE; Thu, 10 Mar 2022 07:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iPf6ZDqlJgVBUy3LCK5NgohJDdrKYdCQ6URR5JBYjJc8BjMx0Tq3b6HlyhAqPdGxrWzoVjQcW25dAvQgU0P+PGguLeFyKHix4gmKJcXeGQPGMg0WryEcFI4KbEyxneNRPtA68DKRq5G0Z4iyMGrMwvaHnMhQpNZ5ohcAzOkBe9twJ2qg8mTCug0MKlm7UCB6lRGUwejHUegtsEYQs33zyZVyQUDIOAWb0Yn/WhS4EYs9t6hixXZ2qszbpSeqCzQT/ECLqKp21f4J+vdpfYrdf0eJTGk1ROJwXTjRfrdZ0s8BBbe0hK3T+mwtQePrMPgYs838Mep/7r9WrXEBV5ahhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=OC67LfcbIuMORF6/jtsq5rbnDdCdck1fGDZ+Tyc1E+k=; b=FvA+2Tuh2olbRPfE4fWMuI+UT0nTta0jq/DU99Q7Cdo5BC6fBeBy2QO8UPWS0EQUSARh/NIfjDSKXHWocEqdOFn1U0y/Zp3U1qY896jAf2Ih3fkURecvLmKpE23U/zgCz134+yssUypu985yhpz9DWk9qquQEnZAJjlxF/si7cz7yxSnjDL3OMRbbM6ySQQwHYdzJ5XEvDAu30m4SjXtQA+CYm93PTMvj1hESB1GPnn3Zh2bgnN25mUVU2XKaUPijUYKPN1vrsVv3De9ih5IJuWzhgsD++h6/aUj/WQcVjdj9AHtec5aPlczVnisHXTetgSE9kC1O7xzdBtklvrxmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OC67LfcbIuMORF6/jtsq5rbnDdCdck1fGDZ+Tyc1E+k=; b=0l+GTyGXjLjN7B2Z3ajyYxMzwjxQCnfcWWV31yRxoJEwn9dwvG9aJlMEqvTBopN6Dy5G/ovJtS9Nh1upCujZUeCtqvBXkRx1XZ2tGZYtzJlUT4JGJa4Le3WXXdFFoLocgM8md4hfAZy3ESPIjM2JMv3g0crVHmzZcVjh1XB+T1g= Received: from DM5PR06CA0084.namprd06.prod.outlook.com (2603:10b6:3:4::22) by MN2PR12MB4502.namprd12.prod.outlook.com (2603:10b6:208:263::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.15; Thu, 10 Mar 2022 15:21:03 +0000 Received: from DM6NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:3:4:cafe::23) by DM5PR06CA0084.outlook.office365.com (2603:10b6:3:4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.21 via Frontend Transport; Thu, 10 Mar 2022 15:21:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT063.mail.protection.outlook.com (10.13.172.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5061.22 via Frontend Transport; Thu, 10 Mar 2022 15:21:02 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 10 Mar 2022 09:21:01 -0600 From: Mario Limonciello To: Hans de Goede , Mark Gross , "Rafael J . Wysocki" CC: "open list:X86 PLATFORM DRIVERS" , , Mario Limonciello Subject: [PATCH 1/4] ACPI / x86: Add support for LPS0 callback handler Date: Thu, 10 Mar 2022 09:17:02 -0600 Message-ID: <20220310151705.577442-1-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0379178e-664c-4e8f-0669-08da02a996bb X-MS-TrafficTypeDiagnostic: MN2PR12MB4502:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: um+5Y/yWvyqRicx9k1rX+0iAZSm2XAu2BY0F0efEPGuj1TpRKUbktdn3+UWRLcD3sTdIZcjvgz/49pfFGt6r6GPecokJbJTw6eQfBMV7ojsguqHOPI4TFL2yKNNxh+vghCGPHOeZb+H7CjPr4WTmC79nUpwwmn+/mpB2/VZXmNt3RuDDg5zg0xQlsWlpzKrZvjI53RWuHi7VNp2OaiPshEcmNIw8qUBr9ILrKsYsuhlNx+FCImq7UDn/aG06QGIF0QBZ1MB3AaVGycdbcEVWXgLLpByCbD/qIR/C8rqmXCPF/MqpnZIEN+K1qvBaBIEDfSZjsYDEKx3Ngaw7EobwQAG0jCXLpi3YeDGgssfYqkLUkj0+cQWA+QVRFR/tHQsk9ju17ikHg+I+KFFYPps8ohBz6BFiZPLuVZlDfwI6hgmDzFxe50wPicg+6vPqBChskR4RM+SQ6u1ojt+gZmZsxTizVt6r2Gx8grQ5OJeBwS4UklQz1rCRhc/FIb+DlSRB7gptRp2zQj6eN5eSqEynL5q/FeuYeKZpKX0A+lJuzrbn+IAKAqSnd0U2sJp60Y3gPOX16hK95+CnHQSyJqeNQlShhe6uDNEDI/giNl7OuQqRH6lvgmbxoiM3EJVGJ5+WpjaOJWvJSpPuddEfarYoXdYvkEFIC2c3uo6APIEN34B///8G+hJV+B84D2EGwhRK0nTT48B7QCPpIJUxWZIKyw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(47076005)(81166007)(83380400001)(356005)(36860700001)(40460700003)(36756003)(82310400004)(8676002)(4326008)(86362001)(54906003)(110136005)(70206006)(70586007)(316002)(44832011)(8936002)(5660300002)(16526019)(1076003)(26005)(426003)(2616005)(186003)(336012)(2906002)(45080400002)(508600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2022 15:21:02.6976 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0379178e-664c-4e8f-0669-08da02a996bb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4502 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currenty the latest thing run during a suspend to idle attempt is the LPS0 `prepare_late` callback and the earliest thing is the `resume_early` callback. There is a desire for the `amd-pmc` driver to suspend later in the suspend process (ideally the very last thing), so create a callback that it or any other driver can hook into to do this. Signed-off-by: Mario Limonciello --- drivers/acpi/x86/s2idle.c | 76 ++++++++++++++++++++++++++++++++++++++- include/linux/acpi.h | 9 ++++- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index abc06e7f89d8..652dc2d75458 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -86,6 +86,16 @@ struct lpi_device_constraint_amd { int min_dstate; }; +struct lps0_callback_handler { + struct list_head list_node; + int (*prepare_late_callback)(void *context); + void (*restore_early_callback)(void *context); + void *context; +}; + +static LIST_HEAD(lps0_callback_handler_head); +static DEFINE_MUTEX(lps0_callback_handler_mutex); + static struct lpi_constraints *lpi_constraints_table; static int lpi_constraints_table_size; static int rev_id; @@ -444,6 +454,9 @@ static struct acpi_scan_handler lps0_handler = { int acpi_s2idle_prepare_late(void) { + struct lps0_callback_handler *handler; + int rc = 0; + if (!lps0_device_handle || sleep_no_lps0) return 0; @@ -474,14 +487,31 @@ int acpi_s2idle_prepare_late(void) acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_ENTRY, lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); } - return 0; + + mutex_lock(&lps0_callback_handler_mutex); + list_for_each_entry(handler, &lps0_callback_handler_head, list_node) { + rc = handler->prepare_late_callback(handler->context); + if (rc) + goto out; + } +out: + mutex_unlock(&lps0_callback_handler_mutex); + + return rc; } void acpi_s2idle_restore_early(void) { + struct lps0_callback_handler *handler; + if (!lps0_device_handle || sleep_no_lps0) return; + mutex_lock(&lps0_callback_handler_mutex); + list_for_each_entry(handler, &lps0_callback_handler_head, list_node) + handler->restore_early_callback(handler->context); + mutex_unlock(&lps0_callback_handler_mutex); + /* Modern standby exit */ if (lps0_dsm_func_mask_microsoft > 0) acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT, @@ -524,4 +554,48 @@ void acpi_s2idle_setup(void) s2idle_set_ops(&acpi_s2idle_ops_lps0); } +int acpi_register_lps0_callbacks(int (*prepare_late)(void *context), + void (*restore_early)(void *context), + void *context) +{ + struct lps0_callback_handler *handler; + + if (!lps0_device_handle || sleep_no_lps0) + return -ENODEV; + + handler = kmalloc(sizeof(*handler), GFP_KERNEL); + if (!handler) + return -ENOMEM; + handler->prepare_late_callback = prepare_late; + handler->restore_early_callback = restore_early; + handler->context = context; + + mutex_lock(&lps0_callback_handler_mutex); + list_add(&handler->list_node, &lps0_callback_handler_head); + mutex_unlock(&lps0_callback_handler_mutex); + + return 0; +} +EXPORT_SYMBOL_GPL(acpi_register_lps0_callbacks); + +void acpi_unregister_lps0_callbacks(int (*prepare_late)(void *context), + void (*restore_early)(void *context), + void *context) +{ + struct lps0_callback_handler *handler; + + mutex_lock(&lps0_callback_handler_mutex); + list_for_each_entry(handler, &lps0_callback_handler_head, list_node) { + if (handler->prepare_late_callback == prepare_late && + handler->restore_early_callback == restore_early && + handler->context == context) { + list_del(&handler->list_node); + kfree(handler); + break; + } + } + mutex_unlock(&lps0_callback_handler_mutex); +} +EXPORT_SYMBOL_GPL(acpi_unregister_lps0_callbacks); + #endif /* CONFIG_SUSPEND */ diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 6274758648e3..cae0fde309f2 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1023,7 +1023,14 @@ void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state, acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b); - +#ifdef CONFIG_X86 +int acpi_register_lps0_callbacks(int (*prepare_late)(void *context), + void (*restore_early)(void *context), + void *context); +void acpi_unregister_lps0_callbacks(int (*prepare_late)(void *context), + void (*restore_early)(void *context), + void *context); +#endif /* CONFIG_X86 */ #ifndef CONFIG_IA64 void arch_reserve_mem_area(acpi_physical_address addr, size_t size); #else From patchwork Thu Mar 10 15:17:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 550176 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EA3DC4332F for ; Thu, 10 Mar 2022 15:21:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbiCJPWW (ORCPT ); Thu, 10 Mar 2022 10:22:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbiCJPWL (ORCPT ); Thu, 10 Mar 2022 10:22:11 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2072.outbound.protection.outlook.com [40.107.243.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2774C131106; Thu, 10 Mar 2022 07:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LOMXfI+y8wZrotKQToOj8j+k7EJmS4O0xblcTgsmI7OG5Drq9Tzh1xna0mfW5QzaNipSyjIhXVpvVPJY34GTTI58R/o8WPAMYoD+QJsF9KLdJUvyK4IL5rDKH71iFPyD+pmX6SmJkG9pe0s9fdu2g9vdTyGoGGO4ZB/GDhRWIqqIxvSuyFPyfXMN5OQIuChCbi/XxRB7hetDYO1TjuZL2Ti55nLkUyToKTPY6DrBn7uQgq0uNbRomVcV4FSCpZo1Xi//ZzT36PIcNeBkZ3bBKg4yASzeyGnIBnhoBbomwCa+CDMRvHVxVjXLmN//6jgV3Cii3d240U/zqUKKGE7clQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=pw6kypIgJG6AFEHTAL6YHWj6aQf/I10GRPNj901bof0=; b=KEwqPxy2g8gzzXNDRUE+GCoOPfw0kjiNPQyc1PhPwDVU2JTAP91wptr5gLhWN8reON/sroHBtoDuRwZrp4aBBZCwXDH9Q7HlPxo7g8MrKv3q8LGPCdVlCBxCGXfiQgltb4eecyHIbFUUM6tBTDQYeDFxS2LJ7AI4MhxHwYFgf3dzGnnbCnecZNWeQw7bGK2KdWEZmFAXzn7Ev+zg9NPJ4x595YE1z9DVs4jDLvO1Uu6TyhD/NomPSIziExuGlkhnPK2XgTh1jo+1U8dBJ7k1lBKVvgDSHfZr8H5f70MmZjy+Wl89kPVwevaKYZNtKOmSbatJPJ2KrGtSwriVLQ24cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pw6kypIgJG6AFEHTAL6YHWj6aQf/I10GRPNj901bof0=; b=itxhJ2ED7TixrAxHwmGliBF06KdSaj/eqmYw9NNUvG9mIdb4+IqRVqkZuWKWR+q5+BGqwAVjyh/Rjybn6Xt9wCpZ/PP2VXSZHbNuuZrHfPEkGNH6yAqnTJW5RXsg2ST8t6myKQeEulvnnrKbmDf7P7YQB1CadJ0Qg1dwiupVViA= Received: from DM5PR06CA0087.namprd06.prod.outlook.com (2603:10b6:3:4::25) by DM5PR12MB2584.namprd12.prod.outlook.com (2603:10b6:4:b0::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.19; Thu, 10 Mar 2022 15:21:04 +0000 Received: from DM6NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:3:4:cafe::e6) by DM5PR06CA0087.outlook.office365.com (2603:10b6:3:4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.29 via Frontend Transport; Thu, 10 Mar 2022 15:21:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT063.mail.protection.outlook.com (10.13.172.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5061.22 via Frontend Transport; Thu, 10 Mar 2022 15:21:03 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 10 Mar 2022 09:21:01 -0600 From: Mario Limonciello To: Hans de Goede , Mark Gross , "Rafael J . Wysocki" CC: "open list:X86 PLATFORM DRIVERS" , , Mario Limonciello Subject: [PATCH 2/4] ACPI / x86: Pass the constraints checking result to LPS0 callback Date: Thu, 10 Mar 2022 09:17:03 -0600 Message-ID: <20220310151705.577442-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220310151705.577442-1-mario.limonciello@amd.com> References: <20220310151705.577442-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 369ba85a-23e3-40f6-c329-08da02a9973b X-MS-TrafficTypeDiagnostic: DM5PR12MB2584:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +jLGlbFlKTTL14kYue7XLchZf5LT1z/EmFO0jjRaYxYwcgmXNVh8r3gpyxofZDPmNTzCi8ScglKb2O34KOYVIlJrSi5Z8RIfQJLfQ25GHZcojVCxjfZMQPiGBYFBiDx9h0V+thWEa+IoE4Y2dzTb5pr5vkwU6lZaUkqPH7Vqge9SDiaLAW4nRV7w5mN7rfrs5He7xC/sp9Z8LzHBPdDcw0KqHT9KO3kTbDrN3vy39SizvJXAE6amz94vc9b//fX8cByNpT4Du7rmJsCuhJtzRAL0lbl9pZulr4YTfASg4E7T1b+aAA325SbShebFhLKZbZJBtG+egICJEC/IUrKZFsJNh/Ij7WMlYNBPqzugWmaXyrBGj03K2i6AxRqs/FTLNKekA3cmav+au6uK3WMbRlYMtaJOryT/dMtu+tHOMab6+R8M3My4roRFYfduqxf3lgWA1keiqjnMiRcCfAnhtft4ktgtNYnUwR6zzwIRmbbnjXRys4obQZ6sclq2Dcj2Pkt5/xH6RiSqJSkTUW2OkMPHx8swyLwKHzHLF1mG699QW3qGXMXjp7ukXonvk8A2Dt3M3ckAuuxPtCB8fT3cU+rbQ8UuKU1OzzycVaw4Eg8t48fhG5L/xcS//BMJ7NeIZFEbPNaP96zKlKiDfACUF09E9POczWA+TflyUDOUWwEJu8ohpFsQTQDVCyg7AJ9ZVpT8L3UO6suapRQKTwoF8g== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(4326008)(40460700003)(2616005)(186003)(26005)(1076003)(81166007)(356005)(70586007)(70206006)(36756003)(110136005)(8936002)(54906003)(316002)(16526019)(8676002)(86362001)(36860700001)(2906002)(508600001)(5660300002)(47076005)(83380400001)(82310400004)(426003)(336012)(44832011)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2022 15:21:03.5257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 369ba85a-23e3-40f6-c329-08da02a9973b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2584 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org If constraints checking has been enabled by the LPS0 code, it may also be useful for drivers using the callback to make a decision what to do. For example this may in the future allow a failing constraints check preventing another driver from notifying firmware that all required devices have entered the deepest state. Signed-off-by: Mario Limonciello --- drivers/acpi/x86/s2idle.c | 17 ++++++++++------- include/linux/acpi.h | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index 652dc2d75458..c737a8e5d5a5 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -88,7 +88,7 @@ struct lpi_device_constraint_amd { struct lps0_callback_handler { struct list_head list_node; - int (*prepare_late_callback)(void *context); + int (*prepare_late_callback)(void *context, bool constraints); void (*restore_early_callback)(void *context); void *context; }; @@ -297,7 +297,7 @@ static void lpi_device_get_constraints(void) ACPI_FREE(out_obj); } -static void lpi_check_constraints(void) +static void lpi_check_constraints(bool *met) { int i; @@ -319,11 +319,13 @@ static void lpi_check_constraints(void) continue; } - if (adev->power.state < lpi_constraints_table[i].min_dstate) + if (adev->power.state < lpi_constraints_table[i].min_dstate) { acpi_handle_info(handle, "LPI: Constraint not met; min power state:%s current power state:%s\n", acpi_power_state_string(lpi_constraints_table[i].min_dstate), acpi_power_state_string(adev->power.state)); + *met = false; + } } } @@ -455,13 +457,14 @@ static struct acpi_scan_handler lps0_handler = { int acpi_s2idle_prepare_late(void) { struct lps0_callback_handler *handler; + bool constraints_met = true; int rc = 0; if (!lps0_device_handle || sleep_no_lps0) return 0; if (pm_debug_messages_on) - lpi_check_constraints(); + lpi_check_constraints(&constraints_met); /* Screen off */ if (lps0_dsm_func_mask > 0) @@ -490,7 +493,7 @@ int acpi_s2idle_prepare_late(void) mutex_lock(&lps0_callback_handler_mutex); list_for_each_entry(handler, &lps0_callback_handler_head, list_node) { - rc = handler->prepare_late_callback(handler->context); + rc = handler->prepare_late_callback(handler->context, constraints_met); if (rc) goto out; } @@ -554,7 +557,7 @@ void acpi_s2idle_setup(void) s2idle_set_ops(&acpi_s2idle_ops_lps0); } -int acpi_register_lps0_callbacks(int (*prepare_late)(void *context), +int acpi_register_lps0_callbacks(int (*prepare_late)(void *context, bool constraints), void (*restore_early)(void *context), void *context) { @@ -578,7 +581,7 @@ int acpi_register_lps0_callbacks(int (*prepare_late)(void *context), } EXPORT_SYMBOL_GPL(acpi_register_lps0_callbacks); -void acpi_unregister_lps0_callbacks(int (*prepare_late)(void *context), +void acpi_unregister_lps0_callbacks(int (*prepare_late)(void *context, bool constraints), void (*restore_early)(void *context), void *context) { diff --git a/include/linux/acpi.h b/include/linux/acpi.h index cae0fde309f2..5aae774670dc 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1024,10 +1024,10 @@ void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state, acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b); #ifdef CONFIG_X86 -int acpi_register_lps0_callbacks(int (*prepare_late)(void *context), +int acpi_register_lps0_callbacks(int (*prepare_late)(void *context, bool constraints), void (*restore_early)(void *context), void *context); -void acpi_unregister_lps0_callbacks(int (*prepare_late)(void *context), +void acpi_unregister_lps0_callbacks(int (*prepare_late)(void *context, bool constraints), void (*restore_early)(void *context), void *context); #endif /* CONFIG_X86 */ From patchwork Thu Mar 10 15:17:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 550944 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F108C433FE for ; Thu, 10 Mar 2022 15:21:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238147AbiCJPWV (ORCPT ); Thu, 10 Mar 2022 10:22:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbiCJPWL (ORCPT ); Thu, 10 Mar 2022 10:22:11 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2053.outbound.protection.outlook.com [40.107.92.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3228813111C; Thu, 10 Mar 2022 07:21:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q54qkZr8YHYL3hxSYEGI5daaR+0zkR+Qk4Qtmk9QjQQ/3PnH0ACvH3kLBQ/zwt6LhktJSIGQm+xdFfeRr2S0ZiS97Bflt8jyXuakEIzJ3KCR06l6JTBKj9rbsHaIcC+nz78yFOoQqtVLiuqeytdQmVRaUxJf1aDDT9NUNqce78BsV5wn6cmnU4dLPeNPysNnO29IXI1h3uNnaDaS+OiZk6ITdj3xmn10V7rR8S3T0LMJqPs+PA7gWXRRic5EkZpA8DLEfPhuPb0Ue3ufRclrZoYLC5mHukNYXtoKLovd4SNoP6olCsUrhPDwFvLmuH+WqoU6mwXaYL00uGVy/v0fNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=CnsAEQexI7GD1H3chcI69yDQYzk4JoMJLOpqi6iCOs4=; b=gALhRsovDuU0eg2rxiiZEXX2j6Gum6HIU9661P5odrS/l+1ynCbWRG9CIlhFD0MKPB3R6dXziuNnyvgbHtL9RJGupCFYh6OeCaq8Km1Ip4fw3baf9Axs+S1mkZ9TuVY+O+mauChpFuVzePXhj7A7xBGjMM9I4XjqEsm/1gTuj7YXRWD6vJB/39p8lSFDVqyeFuD8TmQdyTRtqssxwgEL4gYaMJMTs0jCHp9IcsQTDl1n/dZIuJbWPMu1mzQDwXWpoubEvd5dbnL848bIP8x+zOLTZPN6qHQVaFnFKVDLWJskD/mYGWqW96YNoMJtBYypkGcRLq2j7mHiDvL4Ox1nyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CnsAEQexI7GD1H3chcI69yDQYzk4JoMJLOpqi6iCOs4=; b=OYZiL8q+C94uEVgmv3OwYe668NyXGyKs6j3P4MEC9jRKYki0JNiOTKdtbB9esq37nAxDnYckNE6n3xR4cd0h7ZV7p6uyDB9IUFS8hjwyfsk4kI1BrI0xlAsigxIMX1Cf84xVHH8H7eQmcGfiRwFrrX9iNQEhSh0zCEcHomZIMRU= Received: from DM5PR06CA0088.namprd06.prod.outlook.com (2603:10b6:3:4::26) by CY4PR12MB1176.namprd12.prod.outlook.com (2603:10b6:903:38::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.17; Thu, 10 Mar 2022 15:21:04 +0000 Received: from DM6NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:3:4:cafe::4d) by DM5PR06CA0088.outlook.office365.com (2603:10b6:3:4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.22 via Frontend Transport; Thu, 10 Mar 2022 15:21:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT063.mail.protection.outlook.com (10.13.172.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5061.22 via Frontend Transport; Thu, 10 Mar 2022 15:21:04 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 10 Mar 2022 09:21:02 -0600 From: Mario Limonciello To: Hans de Goede , Mark Gross , "Rafael J . Wysocki" CC: "open list:X86 PLATFORM DRIVERS" , , Mario Limonciello Subject: [PATCH 3/4] platform/x86: amd-pmc: Move to later in the suspend process Date: Thu, 10 Mar 2022 09:17:04 -0600 Message-ID: <20220310151705.577442-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220310151705.577442-1-mario.limonciello@amd.com> References: <20220310151705.577442-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c8fc826-0fd0-46c4-6d66-08da02a997a9 X-MS-TrafficTypeDiagnostic: CY4PR12MB1176:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zgp3nCzV48LoUKhwTeRjke1nzXjiaEobCDddhe2YNUVzg3yKuTFXLxLJXlj7ZwqVB84KD3OJzfwjCSb+v22EFMkg8SxSybODRit4xvOvy+HePiB0BR8fJP+eG5poNG5naKP3G+uab/lJnOpM/HqL0F9dr6hmamvEHpXLSUk45RlfI2max4wRVCRsZ0gNIK+y/eRwEZw1PradY+2LlDyA90CyQsV8Q3WkGjRGqaJ0mxMcKPyihwYgIdS+ait5mk7+sFAfyBfm9X8BmvI/O1tBkfiK1dtIa2n8WYZt7j1Y0iEcZblQf+2ZAC1hI0DtiONj0Z6rOleFEf4sjBvwJa5rUX1+OMuW8i+lCuXq8i74L8sIjSFRSqrci9M+kEt/puGFQwi5wVofZjRBg/xhyy/zcFk6cmlcyeVabZYqr3kq5Fh3ciUK5/t1q9SsKw7w6D6NTa8DXm7O/nyFOPsQIijVG2gacS/MyIyFmPEjkpRYHFPqgdWl8blG1GQjnkzaTvE3w9708SIDvyZL5zj2ESyG7UMA5lAYem7KVFhK24i17tJTElEhwBk/unKgGxP6u6lk+YeLTJLSrQxQXAIpl2rEkHRRFcMgsjhwGe69ueZkKJWOlRK6SebyRyLF+2veDt7mJ1JHA3sXHYMjHsxs9jg7VVgQTxhgjwpo2IBXY9vnkJ7GDV7GkHMi6NZm29WElSqKGMsykO+ljraV5dUIMuuy1g== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(47076005)(82310400004)(81166007)(186003)(36860700001)(15650500001)(70206006)(70586007)(110136005)(54906003)(4326008)(36756003)(86362001)(316002)(8676002)(40460700003)(2616005)(1076003)(5660300002)(83380400001)(356005)(336012)(26005)(508600001)(8936002)(16526019)(2906002)(44832011)(426003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2022 15:21:04.2444 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c8fc826-0fd0-46c4-6d66-08da02a997a9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1176 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The `OS_HINT` message is supposed to indicate that everything else that is supposed to go into the deepest state has done so. This assumption is invalid as: 1) The CPUs will still go in and out of the deepest state 2) Other devices may still run their `noirq` suspend routines 3) The LPS0 ACPI device will still run To more closely mirror how this works on other operating systems, move the `amd-pmc` suspend to the very last thing before the s2idle loop via an lps0 callback. Fixes: 8d89835b0467 ("PM: suspend: Do not pause cpuidle in the suspend-to-idle path") Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd-pmc.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c index 971aaabaa9c8..c13fd93f2662 100644 --- a/drivers/platform/x86/amd-pmc.c +++ b/drivers/platform/x86/amd-pmc.c @@ -639,9 +639,9 @@ static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg) return rc; } -static int __maybe_unused amd_pmc_suspend(struct device *dev) +static int amd_pmc_suspend(void *context, bool constraints_met) { - struct amd_pmc_dev *pdev = dev_get_drvdata(dev); + struct amd_pmc_dev *pdev = dev_get_drvdata((struct device *)context); int rc; u8 msg; u32 arg = 1; @@ -658,7 +658,7 @@ static int __maybe_unused amd_pmc_suspend(struct device *dev) } /* Dump the IdleMask before we send hint to SMU */ - amd_pmc_idlemask_read(pdev, dev, NULL); + amd_pmc_idlemask_read(pdev, pdev->dev, NULL); msg = amd_pmc_get_os_hint(pdev); rc = amd_pmc_send_cmd(pdev, arg, NULL, msg, 0); if (rc) { @@ -681,28 +681,28 @@ static int __maybe_unused amd_pmc_suspend(struct device *dev) return rc; } -static int __maybe_unused amd_pmc_resume(struct device *dev) +static void amd_pmc_resume(void *context) { - struct amd_pmc_dev *pdev = dev_get_drvdata(dev); + struct amd_pmc_dev *pdev = dev_get_drvdata((struct device *)context); int rc; u8 msg; msg = amd_pmc_get_os_hint(pdev); rc = amd_pmc_send_cmd(pdev, 0, NULL, msg, 0); if (rc) - dev_err(pdev->dev, "resume failed\n"); + dev_err(pdev->dev, "resume failed: %d\n", rc); /* Let SMU know that we are looking for stats */ amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_DUMP_DATA, 0); /* Dump the IdleMask to see the blockers */ - amd_pmc_idlemask_read(pdev, dev, NULL); + amd_pmc_idlemask_read(pdev, pdev->dev, NULL); /* Write data incremented by 1 to distinguish in stb_read */ if (enable_stb) rc = amd_pmc_write_stb(pdev, AMD_PMC_STB_PREDEF + 1); if (rc) - dev_err(pdev->dev, "error writing to STB\n"); + dev_err(pdev->dev, "error writing to STB: %d\n", rc); /* Restore the QoS request back to defaults if it was set */ if (pdev->cpu_id == AMD_CPU_ID_CZN) @@ -711,15 +711,8 @@ static int __maybe_unused amd_pmc_resume(struct device *dev) /* Notify on failed entry */ amd_pmc_validate_deepest(pdev); - - return rc; } -static const struct dev_pm_ops amd_pmc_pm_ops = { - .suspend_noirq = amd_pmc_suspend, - .resume_noirq = amd_pmc_resume, -}; - static const struct pci_device_id pmc_pci_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_YC) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_CZN) }, @@ -884,6 +877,12 @@ static int amd_pmc_probe(struct platform_device *pdev) amd_pmc_get_smu_version(dev); platform_set_drvdata(pdev, dev); + err = acpi_register_lps0_callbacks(amd_pmc_suspend, + amd_pmc_resume, + &pdev->dev); + if (err) + goto err_pci_dev_put; + amd_pmc_dbgfs_register(dev); cpu_latency_qos_add_request(&dev->amd_pmc_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; @@ -897,6 +896,9 @@ static int amd_pmc_remove(struct platform_device *pdev) { struct amd_pmc_dev *dev = platform_get_drvdata(pdev); + acpi_unregister_lps0_callbacks(amd_pmc_suspend, + amd_pmc_resume, + &pdev->dev); amd_pmc_dbgfs_unregister(dev); pci_dev_put(dev->rdev); mutex_destroy(&dev->lock); @@ -917,7 +919,6 @@ static struct platform_driver amd_pmc_driver = { .driver = { .name = "amd_pmc", .acpi_match_table = amd_pmc_acpi_ids, - .pm = &amd_pmc_pm_ops, }, .probe = amd_pmc_probe, .remove = amd_pmc_remove, From patchwork Thu Mar 10 15:17:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 550175 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14E9AC433EF for ; Thu, 10 Mar 2022 15:21:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239120AbiCJPWX (ORCPT ); Thu, 10 Mar 2022 10:22:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234209AbiCJPWN (ORCPT ); Thu, 10 Mar 2022 10:22:13 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2042.outbound.protection.outlook.com [40.107.100.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0CF8131F4A; Thu, 10 Mar 2022 07:21:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FLJE0xixT022h3dyyGVJp6m7/Ya9Asu6A4MrXL+fGZmIYLI7BN8SgLxlONNuzgrYouNm2xGRyp0VB01whjHvPT9DESJSvb+4wuCh97D5/qjw8tv5oEDxIr+Ai0V6BSCaJ63due8S+AEl8tuq16jcxxHQW8E+Fr+H+mp9Dic7zepTLKa05TdPNhbdknAoEgQsWTuWVsSRo25la5yYDLhnSJN3hgW0Ok1DWx5Blb6pCUvDLhkYYRjggxU0lO3EDhJ6jqA6QYEjjMyZNZ+3Etz8RhKap4B/sh2iMtv0DXXnKh4DMvLTaSgm0WzHisXTnfbdMYLOMu/L647D+buHX3t0XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=F2c4NG+ccv608RyWdPEmQ1k9HRtQ0Rq+TASTHf7B80Q=; b=PB+plGx/dNDt2Yy+t0Lp16gYLosyiqhbUl+yToZq5M3hNjs4lvlCfllmmrt/clonrkcGUYUt8yA0LXrM//XdiMFEdhbyDUI8P31BY1HH76IHrk40VAOcOjYy6qbf3j0Z55Ci7fA1ipmsW2Fa2kGzzhpcLw3ShlfKE54BAZh1GeNEy/k3bVLnKLzR+Jvq22JLxtmw3T0BjO1QgFfPg5nGz+JiHEbjQvOorAgj1BmrMOpqApZ8wwerq3PcdzN5NiWkUyKs7xr6Sr7VyrbFMo19jMIWF0OKwtK4rHh7kKpcgAt2XmLhnCgkLv1TcvaeR6ojwrIqdVqjf1uUUNwitVGVNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F2c4NG+ccv608RyWdPEmQ1k9HRtQ0Rq+TASTHf7B80Q=; b=kuJtTTl/SJl/Zwv8/ynxpuQVoOfKxgr7XNmuYyZYAhizbXm5SSe3vRL8BTKo/Y+BmcfBvi+qti503fW+qycC9UV6y4SBHpJnbIyC7AvnHuwyhJV+KWz6Squ9WWjOEE3HTpxbdhGqF0zZoldQtlIy3qOkP+naRmaGYaqYlF7lhzY= Received: from DM5PR06CA0082.namprd06.prod.outlook.com (2603:10b6:3:4::20) by CH2PR12MB4840.namprd12.prod.outlook.com (2603:10b6:610:c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.15; Thu, 10 Mar 2022 15:21:05 +0000 Received: from DM6NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:3:4:cafe::59) by DM5PR06CA0082.outlook.office365.com (2603:10b6:3:4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.27 via Frontend Transport; Thu, 10 Mar 2022 15:21:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT063.mail.protection.outlook.com (10.13.172.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5061.22 via Frontend Transport; Thu, 10 Mar 2022 15:21:05 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 10 Mar 2022 09:21:02 -0600 From: Mario Limonciello To: Hans de Goede , Mark Gross , "Rafael J . Wysocki" CC: "open list:X86 PLATFORM DRIVERS" , , Mario Limonciello Subject: [PATCH 4/4] platform/x86: amd-pmc: Drop CPU QoS workaround Date: Thu, 10 Mar 2022 09:17:05 -0600 Message-ID: <20220310151705.577442-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220310151705.577442-1-mario.limonciello@amd.com> References: <20220310151705.577442-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef46745c-b79a-4f6e-0332-08da02a99823 X-MS-TrafficTypeDiagnostic: CH2PR12MB4840:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SeTU4CWSGo9tGWO4uV1z8AzzqHKt5DRyWOuAQaXyNR901Uuk3OLoJRGtdS3h8QXLtCzl4PruK4hOedRvM8ROVTlo/KpAVz6w24Q+SDI856edKEVdF7B/z5e7FVClEDa+0MQ7Tc7zG9qiOXnc0hWDM+KtlcbIZFJo+Ifu+aJUnqdcNB9d6n8HdEknLTYENOkyEuzVkWLwCfNkDkUWkH3GvtN739dRhXVVhdJwXdcAdjXWirvI1mOsROn1ULu+WKp2Xs3uCIAAbn3QNFIrRB8nKm7+uwF8EovkHWkYq8q21LzmWY+oKlMybEeoWW5/WtdQJx767qkb0F2UvZqv1GceiXN3qPRBOMIeEHOUBldU5aXmgjDkKT9LMkqekO9I7dLbPCVBmuBZY1ZOYif/M7O3lBFVcn9xCEh18SFNm9dV84ofIeoIK8hXOn+vrieul5Q05Rj2rlQeC34f0ZFAfhxTmdgEy77gSiuAu8FZhszA5L91pwTHK0P5jxrWQw64KF3nUerpMVQUGCsl7EqI9/ia4k9+Ow11wcb6MsaZqVHwS3KHFmKRZQrKqZgJGRuf2954Xp2KfRzo4q29iHKVrohdf08BU7cngRz58+mG3kbdJeaRVtzDilePPHTj6KqXhwrnvTmFnWUh+2ixJygcWfr6YWSnLxqOQSC27PPGnQJuhVLt0pS5ZilsE4tv8Q4Z4BcjIk/RuKwBvJ3ffee78VhS4Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(40460700003)(2906002)(8936002)(47076005)(36756003)(2616005)(54906003)(110136005)(316002)(86362001)(70206006)(336012)(186003)(4326008)(26005)(82310400004)(16526019)(8676002)(426003)(70586007)(1076003)(83380400001)(44832011)(508600001)(36860700001)(81166007)(356005)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2022 15:21:05.0569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef46745c-b79a-4f6e-0332-08da02a99823 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4840 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org A workaround was previously introduced as part of commit 646f429ec2de ("platform/x86: amd-pmc: Set QOS during suspend on CZN w/ timer wakeup") to prevent CPUs from going into the deepest state during the execution of the `noirq` stage of `amd_pmc`. As `amd_pmc` has been pushed to the last step for suspend on AMD platforms, this workaround is no longer necessary. Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd-pmc.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c index c13fd93f2662..b636fbe90407 100644 --- a/drivers/platform/x86/amd-pmc.c +++ b/drivers/platform/x86/amd-pmc.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -96,9 +95,6 @@ #define PMC_MSG_DELAY_MIN_US 50 #define RESPONSE_REGISTER_LOOP_MAX 20000 -/* QoS request for letting CPUs in idle states, but not the deepest */ -#define AMD_PMC_MAX_IDLE_STATE_LATENCY 3 - #define SOC_SUBSYSTEM_IP_MAX 12 #define DELAY_MIN_US 2000 #define DELAY_MAX_US 3000 @@ -153,7 +149,6 @@ struct amd_pmc_dev { struct device *dev; struct pci_dev *rdev; struct mutex lock; /* generic mutex lock */ - struct pm_qos_request amd_pmc_pm_qos_req; #if IS_ENABLED(CONFIG_DEBUG_FS) struct dentry *dbgfs_dir; #endif /* CONFIG_DEBUG_FS */ @@ -628,14 +623,6 @@ static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg) rc = rtc_alarm_irq_enable(rtc_device, 0); dev_dbg(pdev->dev, "wakeup timer programmed for %lld seconds\n", duration); - /* - * Prevent CPUs from getting into deep idle states while sending OS_HINT - * which is otherwise generally safe to send when at least one of the CPUs - * is not in deep idle states. - */ - cpu_latency_qos_update_request(&pdev->amd_pmc_pm_qos_req, AMD_PMC_MAX_IDLE_STATE_LATENCY); - wake_up_all_idle_cpus(); - return rc; } @@ -675,9 +662,6 @@ static int amd_pmc_suspend(void *context, bool constraints_met) return 0; fail: - if (pdev->cpu_id == AMD_CPU_ID_CZN) - cpu_latency_qos_update_request(&pdev->amd_pmc_pm_qos_req, - PM_QOS_DEFAULT_VALUE); return rc; } @@ -704,11 +688,6 @@ static void amd_pmc_resume(void *context) if (rc) dev_err(pdev->dev, "error writing to STB: %d\n", rc); - /* Restore the QoS request back to defaults if it was set */ - if (pdev->cpu_id == AMD_CPU_ID_CZN) - cpu_latency_qos_update_request(&pdev->amd_pmc_pm_qos_req, - PM_QOS_DEFAULT_VALUE); - /* Notify on failed entry */ amd_pmc_validate_deepest(pdev); } @@ -884,7 +863,6 @@ static int amd_pmc_probe(struct platform_device *pdev) goto err_pci_dev_put; amd_pmc_dbgfs_register(dev); - cpu_latency_qos_add_request(&dev->amd_pmc_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; err_pci_dev_put: