From patchwork Fri Aug 18 19:40:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13358231 X-Patchwork-Delegate: bhelgaas@google.com 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 E8895EE4997 for ; Fri, 18 Aug 2023 19:41:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379687AbjHRTkw (ORCPT ); Fri, 18 Aug 2023 15:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379668AbjHRTk2 (ORCPT ); Fri, 18 Aug 2023 15:40:28 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2070.outbound.protection.outlook.com [40.107.92.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22CDA4220; Fri, 18 Aug 2023 12:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J/cIonBeHEz88q8i0Yfuv0sluG8s5Cf7PELyWVatDtF4+NZmgDF0IV7U+7OWD4+980fYIVGhdGqmuZglT/tqGYDEWS2qtKh60tYVlo8n0Rv+l7HbCH2dp7kiIvdVLiLJnwhwwNgBir+xaJqlo1DnjhIBpKMX25ZCArpuGVpuRVRsXl+nAnGEZwYmm6tSk0E0Qxb75XaEQOKqMsgCbjLPlPFHNFjtWXnEi2pBKmWKjroYZhz4xw2FktCb6ryPG2ujNTD/LtQM3Fb+hEuiM7h80hPngkprg8LP5OjGCcF6mOVkBLMr53mzOJgEMSggsreu6WT5v3Sy5+EKjOyYAPsS/w== 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=d2LWCT/TRlS+8s8NwTCM0zoeA6pv5LGXIVx+et5JjS0=; b=KRTZ2jDCH1JojxBbQzIsb5NBtkn/Lx0zw3I3Ca4tfDAup9DWK2PiBLvypLXjAxOIzUWVzsym049QZHBk/kEwP2OC1M4zF8pJ/f/kq4+aH/7N5UmNunaA8phuhLUV9buwFsNrfVytxv8xVYVDOQOn+8jF/aMrySzH2GNuXKWrujYQGiU3dx+nzcVdaDGm2Gf9LG7shUsahwzvCFgjrVE1VxwzO9iB+VF7J7QdDm3/toju4DyoY5cD/UFGbyR01qM63f5RMch0g8080nB5VqONDDdsojPjksBsEqagfDdY/Ic7Nmupk0/O2i/GoIIBO71cNGli7le+KJgAgtomoZOvcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.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=d2LWCT/TRlS+8s8NwTCM0zoeA6pv5LGXIVx+et5JjS0=; b=LlgWZXC39LOwphlZ70n3sXuK8l0xHwNrzQIL1GAYEKdfO41X0PqWHkDUPmKVAyHEqnYTYso5munghseGYFtHqyfDS2hVT9ZHFpkrZEyjXDFemG2qKttRBbEIOgfOXZjybB36eYrqxowQy6MyzGJ/NTCvbvZEDrAKeoHUinweANA= Received: from MW4PR04CA0267.namprd04.prod.outlook.com (2603:10b6:303:88::32) by DM8PR12MB5446.namprd12.prod.outlook.com (2603:10b6:8:3c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Fri, 18 Aug 2023 19:40:21 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:88:cafe::74) by MW4PR04CA0267.outlook.office365.com (2603:10b6:303:88::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Fri, 18 Aug 2023 19:40:20 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 18 Aug 2023 19:40:20 +0000 Received: from AUS-LX-MLIMONCI.amd.com (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.2507.27; Fri, 18 Aug 2023 14:40:19 -0500 From: Mario Limonciello To: Mika Westerberg , "Rafael J . Wysocki" , Bjorn Helgaas CC: , , , Iain Lane , "Andy Shevchenko" , Kuppuswamy Sathyanarayanan , Mario Limonciello Subject: [PATCH v14.b 1/7] ACPI: Adjust #ifdef for *_lps0_dev use Date: Fri, 18 Aug 2023 14:40:01 -0500 Message-ID: <20230818194007.27410-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230818194007.27410-1-mario.limonciello@amd.com> References: <20230818194007.27410-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-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|DM8PR12MB5446:EE_ X-MS-Office365-Filtering-Correlation-Id: 05942ba8-b49a-4076-9f14-08dba022f56a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rdd9YE+JndRJH8JSfuHqhc7px2Uz9o3p9Mwki2kynwJ3pRSyX+Zut1OAx50jLLl/BZ9irW6uo6134sDeM2hyXKDo8cQiyXgxU97WH4bKIrg+cIDoQn5+XtnbaUf5773x7Kla5red3UYjjoG1PQ6wyPIZqTDWYwQ5uRZR2Dleyn4GNQ0LxhhXAhEq3GGSszLqwis2HMgzdpspejP7rLyKzzI2oDO6XbOCZo9kbTDmdzHE8kRSv08gAboioIsX7NTLsCdVmbQmMJMWcoL3Qk06lcUAhenXU0S8d0aMF/LGEg9briV8GqUQ6UAO7VrZdIgB4D3/IBSjIrTWJ/2KqIX7OGWff21Qb7l9gv+UrZfL/VVsiDzjRPQSoqxDOcyPRfY0dYU3M/SvPtE5Ajw3KiVgu5auJ+vP9diVCw0OIY1ugzPbQBEB7pkCvlGxakK/yNVjIcDlf207kXLa1yeDavdj3uzBvfidsePVSAso+j4Zq1DNz5BnQByufZ9tn/oqJ0ihq6OLNjageRXthtNRWrQR824c6QwsQvPDq4a47VZWVPa/6PJ6glk124yXUqQqE5Vs64qdz893iBBVYLAB/3AMVJ4Blhi6ocxt2G9WgMHqqwaTfWTM9pJHN+rQkF8jZsoTRnRRrR/A1DEBzK0eJZ6TiSE1J4XIP5ibS87sS/TBr3AV4r+/8FTfwAsiObPDOW1eYPl8/gaHSGlemzKKJPyVoqKJrL81b+TItbD/DABEnNLA0Bn/h4sx9+t+vBwVWbTE0Z+0G+SnWjJtm+MVlONAOw== 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:(13230031)(4636009)(346002)(396003)(136003)(39860400002)(376002)(1800799009)(186009)(82310400011)(451199024)(46966006)(40470700004)(36840700001)(6666004)(7696005)(40460700003)(36860700001)(16526019)(426003)(336012)(40480700001)(26005)(1076003)(83380400001)(36756003)(47076005)(81166007)(82740400003)(356005)(2616005)(316002)(2906002)(54906003)(41300700001)(70206006)(70586007)(86362001)(110136005)(5660300002)(44832011)(8676002)(4326008)(8936002)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 19:40:20.8076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05942ba8-b49a-4076-9f14-08dba022f56a 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5446 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The `#ifdef` for acpi_register_lps0_dev() currently is guarded against `CONFIG_X86`, but actually the functions contained in the block are specifically sleep related functions. Adjust the guard to also check for `CONFIG_SUSPEND`. Signed-off-by: Mario Limonciello --- v12->v13: * Adjust commit messsage v11->v12: * change to CONFIG_SUSPEND v9->v10: * split from other patches --- include/linux/acpi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 0d5277b7c6323..f1552c04a2856 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1100,7 +1100,7 @@ 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 +#if defined(CONFIG_SUSPEND) && defined(CONFIG_X86) struct acpi_s2idle_dev_ops { struct list_head list_node; void (*prepare)(void); @@ -1109,7 +1109,7 @@ struct acpi_s2idle_dev_ops { }; int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg); void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg); -#endif /* CONFIG_X86 */ +#endif /* CONFIG_SUSPEND && CONFIG_X86 */ #ifndef CONFIG_IA64 void arch_reserve_mem_area(acpi_physical_address addr, size_t size); #else From patchwork Fri Aug 18 19:40:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13358233 X-Patchwork-Delegate: bhelgaas@google.com 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 4A3CDEE499E for ; Fri, 18 Aug 2023 19:41:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379670AbjHRTkt (ORCPT ); Fri, 18 Aug 2023 15:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379672AbjHRTk3 (ORCPT ); Fri, 18 Aug 2023 15:40:29 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E65B53C3F; Fri, 18 Aug 2023 12:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GFRPOr6BMF/N621MM50+te9NMMuOcsbQvIDhPR+6dLuuEB2yq9vSiaTHjog6Bnj5wM+HX2m7WZNJoLJxB2REncGmMmIzU34omLTzitXrYJ73tcpZMTtjdvNKhjnW1x0dM4VsWwm8tayEMiFHmbB5tO7pP/i8WPULHrvvQ0cQqpYFmjRDtrhO6dHMCw+vcnabBmqd8ZO1OtcrhsTuQjDfNXjhuAoh37B77gBPQ3kn4A2uFsbR5foYqXEU1157v+pIGJ94uUUJXAH6XskfIY3pMVew8gCI/C/7xZa7LLNHgucA7Jlrqg/chmvYsCpB4jgBIpqKYrcoGLNuIsNsKj7GlA== 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=B9pIliEasY3hi8iYJYhXDM/t9oeU4sjbjdpuPj5rH9Q=; b=d+SapltKNYLM2HwYAdK/em3rh35nycj2G89D+TV+T9SBTH2gyUdmdoYXVHzFUd4v17Q8jU7bh5UH1yfvJmGsnaHKHsstk0y+kZlzpOLc0vNBeiEG8bdvLPUnrCghG9MvhjQjbffkJE/KQbH2JpXjS8rw3nenmS4/pcALhGXktZc9IrdoOAbcLwHddyimjjI+Zz1u/Ppc6CmV/IalTGnf93fPmQhtQRXzQBLxPVKop5aG2WMdXNj5oMV6zxC6Da37a9jVW1LVd+y+P1MfmiWx+/YlMV1zGqjiSgZyWjWnxi2WcdloFs7UTMjM0SJPVNA3VCe9HwM/yd57fs6xsTDZCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.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=B9pIliEasY3hi8iYJYhXDM/t9oeU4sjbjdpuPj5rH9Q=; b=OitMJazDliy0w+DMTXxP5waqlZDQRy1DO/MbCuba4ozvKIccNLXxt9P1K3AUf79onIjUBSzkFlugWTrdleAfQM8n6eW3GCOSRxgljgE8l9MEg/XN8aKtGXP2EDY5YXR22CLRg/00LEl+7y785DoN2bAnPgQx0y31JVtYOCAU9Wg= Received: from MW4PR04CA0254.namprd04.prod.outlook.com (2603:10b6:303:88::19) by BL0PR12MB4946.namprd12.prod.outlook.com (2603:10b6:208:1c5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Fri, 18 Aug 2023 19:40:21 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:88:cafe::71) by MW4PR04CA0254.outlook.office365.com (2603:10b6:303:88::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Fri, 18 Aug 2023 19:40:21 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 18 Aug 2023 19:40:21 +0000 Received: from AUS-LX-MLIMONCI.amd.com (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.2507.27; Fri, 18 Aug 2023 14:40:19 -0500 From: Mario Limonciello To: Mika Westerberg , "Rafael J . Wysocki" , Bjorn Helgaas CC: , , , Iain Lane , "Andy Shevchenko" , Kuppuswamy Sathyanarayanan , Mario Limonciello Subject: [PATCH v14.b 2/7] ACPI: x86: s2idle: Post-increment variables when getting constraints Date: Fri, 18 Aug 2023 14:40:02 -0500 Message-ID: <20230818194007.27410-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230818194007.27410-1-mario.limonciello@amd.com> References: <20230818194007.27410-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-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|BL0PR12MB4946:EE_ X-MS-Office365-Filtering-Correlation-Id: 9460988f-7ce0-428e-73ff-08dba022f5c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qILOEIVONLdRyxaD3UpeE0Xlo3indhsMb0/WzkeK/TU1OHxseHZRQsw+6UKovxGN/9u6MSQZyePS7IXHKRwwShLv18ZIVZ52RKWjBqmx9ZEgFD9poGTdXt+lLfrsW4h/hzDLZJjOZB6Vu+0RVmvUJIRBa9vTfhco7ZN3eNCJQPNppBazjUTG+t86/L4d5ZP7z4F9X3kbEVBo6TUs6ParuR669tS7CXfQmAACrjFtiDNPuRjeHuBWHU7hWA51ARGQTfFGZVFwudPVSDrnqurI+Ab0wisO1TJAT6l3RFGkvLNNnCtjNdNyo7XgR1jkRJCqyvbOETxRJnawslfBstDKbr4yeidNOZ2vdYpYFZv5XnhFDYxUUG3m5k6qS/g3WZ6TOWd7erp7g0gNAltLR7iguKzxxTRjbKhEMXrbyRDQqHu806hJf3IFN9Oyl01NJWr24q1GCThOzLzYFA/+cgyQ44EbH58ctyYzhcChLzuwfU8UARVnzkT5AvneEIU/B5EBSd8+LI91vWi61itjFS/jPaG6WSWQ07bbuPQFY6RJ07TpwLrPB44wYVOokjR4tktrVWFf2/QHUyxEs858tSUf8lkZ7qPECiWFRtBY9bHXkop//BBr9j+c72emfBkqE25miAZ5ykAZXMlT0MloHXofSd1uqTlcNoPS8oa+aLuLAw7xMLeosVUyiV3w9VcHnrd63g2Kcec/fRTcDhuvWbhF6vlutvKIh1gTaoaq5lZz6tC5faM2UxX+ZtChItlZNno5sNu6Ddg8pUeh/PcdvNlXqg== 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:(13230031)(4636009)(346002)(396003)(136003)(39860400002)(376002)(1800799009)(186009)(82310400011)(451199024)(46966006)(40470700004)(36840700001)(6666004)(7696005)(40460700003)(36860700001)(16526019)(426003)(336012)(40480700001)(26005)(1076003)(83380400001)(36756003)(47076005)(81166007)(82740400003)(356005)(2616005)(316002)(2906002)(54906003)(41300700001)(70206006)(70586007)(86362001)(110136005)(5660300002)(44832011)(8676002)(4326008)(8936002)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 19:40:21.3701 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9460988f-7ce0-428e-73ff-08dba022f5c0 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4946 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When code uses a pre-increment it makes the reader question "why". In the constraint fetching code there is no reason for the variables to be pre-incremented so adjust to post-increment. No intended functional changes. Reviewed-by: Kuppuswamy Sathyanarayanan Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello --- v12->v13: * Add tag * Reword message --- drivers/acpi/x86/s2idle.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index ce62e61a9605e..7711dde68947f 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -123,13 +123,13 @@ static void lpi_device_get_constraints_amd(void) acpi_handle_debug(lps0_device_handle, "LPI: constraints list begin:\n"); - for (j = 0; j < package->package.count; ++j) { + for (j = 0; j < package->package.count; j++) { union acpi_object *info_obj = &package->package.elements[j]; struct lpi_device_constraint_amd dev_info = {}; struct lpi_constraints *list; acpi_status status; - for (k = 0; k < info_obj->package.count; ++k) { + for (k = 0; k < info_obj->package.count; k++) { union acpi_object *obj = &info_obj->package.elements[k]; list = &lpi_constraints_table[lpi_constraints_table_size]; @@ -214,7 +214,7 @@ static void lpi_device_get_constraints(void) if (!package) continue; - for (j = 0; j < package->package.count; ++j) { + for (j = 0; j < package->package.count; j++) { union acpi_object *element = &(package->package.elements[j]); @@ -246,7 +246,7 @@ static void lpi_device_get_constraints(void) constraint->min_dstate = -1; - for (j = 0; j < package_count; ++j) { + for (j = 0; j < package_count; j++) { union acpi_object *info_obj = &info.package[j]; union acpi_object *cnstr_pkg; union acpi_object *obj; From patchwork Fri Aug 18 19:40:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13358230 X-Patchwork-Delegate: bhelgaas@google.com 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 C3216EE498E for ; Fri, 18 Aug 2023 19:41:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379663AbjHRTkt (ORCPT ); Fri, 18 Aug 2023 15:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379667AbjHRTk2 (ORCPT ); Fri, 18 Aug 2023 15:40:28 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2045.outbound.protection.outlook.com [40.107.220.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D1F8421E; Fri, 18 Aug 2023 12:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gO5iOTQL6IVORtMtUvNbGs2aQ16pOEm5Y1NYlSTB1+6JpieSimAsN8t9GPuSE8cimwsJTH14IRxGFoQotli4AnmAtoYO8XQkV/yJKbVyXznLBkIjcubsXW4mFs+2PeAGRde7OPOtN4qpRn0v75ox0lvSE8228mo/4KzUCKfGOkl0Lru38mr8/v4wFgj6zgiv+nwn9Lx98NTFu7I9HMNUnsB9ZwyV3SPggq3VqYHOcdyJDh6kh5llJKd3L8jlLbr+MhVUAAidiWaJ4pBTa3uUYbuKH0Eddb3kVHi6XXizXyijtnUE4uG9cpZ+gWnd1H+00ukjn74D8mudzhRRdKMetw== 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=qEDVgXKd5mNpSBxC3wfR85w392WHlAZwDxTaCkxX1Vw=; b=iciA2fpFPo4wllXtEMXXF/2BBDC6Do6IwMZjjH5Cl7YqztfyUqcsErcIBTC6dCNblQXmwKoSH0/jn0T4J7lcjCYoJIXJ4M2GJk822GjtWtJ2Amu1wuP5ye95v8C/0RecNN7BExO76ZZXx0QieqQon5Am+BSHVvS/qsmu+9VoxMM26im2VR8GdrVoBcJLmf1SRIpcfQQVH4rcGN4vDwXca0e8oozli3G50nOny26K9GeSobwcEwjXyT7c5KFtw//06XFiExwwbq47FGJuL74GhAKh2bssvEe8P8LRSWQiZZiaBTcHm3/LjqZzWjc2PtrZOIYNABD+9yx+TwqgFPx0sA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.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=qEDVgXKd5mNpSBxC3wfR85w392WHlAZwDxTaCkxX1Vw=; b=znUZS3gU83tRK0N9kLnPSfl00cEv36itSTQk++mbQRrEXiNL69X1etdXg/U5jiP4vH6NMt3IcRbUQjkV7mHbOQBg7qeXwL4maANqhSE2M+/ywQW+X5H1WqrwYuLw/okg94ax6HWS/X2T9zYt1EoUotUcIJ3IVLETKWk2Xhdjv7M= Received: from MW4PR04CA0263.namprd04.prod.outlook.com (2603:10b6:303:88::28) by IA0PR12MB7673.namprd12.prod.outlook.com (2603:10b6:208:435::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.31; Fri, 18 Aug 2023 19:40:22 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:88:cafe::b0) by MW4PR04CA0263.outlook.office365.com (2603:10b6:303:88::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Fri, 18 Aug 2023 19:40:22 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 18 Aug 2023 19:40:22 +0000 Received: from AUS-LX-MLIMONCI.amd.com (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.2507.27; Fri, 18 Aug 2023 14:40:20 -0500 From: Mario Limonciello To: Mika Westerberg , "Rafael J . Wysocki" , Bjorn Helgaas CC: , , , Iain Lane , "Andy Shevchenko" , Kuppuswamy Sathyanarayanan , Mario Limonciello Subject: [PATCH v14.b 3/7] ACPI: x86: s2idle: Catch multiple ACPI_TYPE_PACKAGE objects Date: Fri, 18 Aug 2023 14:40:03 -0500 Message-ID: <20230818194007.27410-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230818194007.27410-1-mario.limonciello@amd.com> References: <20230818194007.27410-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-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|IA0PR12MB7673:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e24d7dc-f4aa-4913-32c8-08dba022f641 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xFc1apC1jvk353TILoeRDNf9u+DtgA9fKLRCfzB0NrAl6uHRFTY4fTx63gpL5Cotz/hjPNK8j/we3zwrgP0ddHffELhKN0lm+IL4v2D2ZjI7YZ2ocwYL07G3Vq+gJUira9HqUSGJtE7DbxlMYof/O67yZI4hxl+UO9Qh2iXrLPX/C5XpRX67RpdX+P9BF3S56sCo7zoZNMZSwuxCGnEeIRpxlKcYDoaHEUFmofDNoMd6Di9krlMjDYh/u4/sBYiNC6yhogsAlTHGRIa4e2fFFJLyXC0jAJNIqqXW2kdtBfMDiiZbGnRc3jdGoRWUKeWMzJ2uhXZCcPz8PuxLVJ7fN7OWYtzV+jfvnySiyaBKfGKLeDrNKPmjltGAArLDiD7+J3b4Ji/fbNhaMyO6WdfigiIeYbJeq2FMDQBRYf9U/IvQsdlIqo3abDP30odSDMb5wKpWuqoEivwFfYLcb97SCrxVPgwuIkO8cJqB0xHP+qRs1Rr0R+A0M/zLXAPnS9lBnhqAXVrsFWEtBbM1WrIB15BYVAjv8e9nWgw4I8X4ZSWW5g7d3sQBZaq4msZTgShEDDosC4PYSCyRaL/YP171x+EI4HV6s/ucpGKpD2KC3gDUCoMg4ywEgkUK0KSzahvrM5KHbsxPt8YvD8wptrAhZrMXt/5vAeNXdZCN58pPI082nRSVDGKiAbmVB5OfVhMV/M5Py0bYeRMTeIQSYuvBfdeoAGVeoe5zQdhXMN/cOBK4T+ls0oViDdABgGYISfSHgkq1wWDNKZT5jUvUBOyBmQ== 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:(13230031)(4636009)(376002)(396003)(346002)(136003)(39860400002)(186009)(451199024)(82310400011)(1800799009)(40470700004)(36840700001)(46966006)(36756003)(86362001)(40460700003)(40480700001)(8676002)(5660300002)(4744005)(8936002)(44832011)(2906002)(4326008)(41300700001)(26005)(1076003)(16526019)(7696005)(6666004)(336012)(2616005)(47076005)(36860700001)(426003)(82740400003)(478600001)(356005)(70206006)(81166007)(70586007)(110136005)(54906003)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 19:40:22.2138 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e24d7dc-f4aa-4913-32c8-08dba022f641 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7673 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org If a badly constructed firmware includes multiple `ACPI_TYPE_PACKAGE` objects while evaluating the AMD LPS0 _DSM, there will be a memory leak. Explicitly guard against this. Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello --- drivers/acpi/x86/s2idle.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index 7711dde68947f..508decbac2986 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -113,6 +113,12 @@ static void lpi_device_get_constraints_amd(void) union acpi_object *package = &out_obj->package.elements[i]; if (package->type == ACPI_TYPE_PACKAGE) { + if (lpi_constraints_table) { + acpi_handle_err(lps0_device_handle, + "Duplicate constraints list\n"); + goto free_acpi_buffer; + } + lpi_constraints_table = kcalloc(package->package.count, sizeof(*lpi_constraints_table), GFP_KERNEL); From patchwork Fri Aug 18 19:40:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13358236 X-Patchwork-Delegate: bhelgaas@google.com 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 9F795EE49A3 for ; Fri, 18 Aug 2023 19:41:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379696AbjHRTkz (ORCPT ); Fri, 18 Aug 2023 15:40:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379671AbjHRTk2 (ORCPT ); Fri, 18 Aug 2023 15:40:28 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2048.outbound.protection.outlook.com [40.107.223.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1E91421C; Fri, 18 Aug 2023 12:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bmVttqhinbb7JRZEuLIvG9KGafV16PyO8zndIZCJXoedIAZeLu0AvGcEd3+hF3N/j2qg9IOcVpScFj/4hz/3YOWTFMrSX82qcrNtUvhHaOIO3TyV5gsEaklcio9abVB9leg6BECmLGI77rDnVlKuuNFPas9lJM7UcCPQ3O7dXR7MBBwRcRZ00+yM6B7NtXaVFuAz1RExEmOtBbTKywKD74CafIn7YCaD9BN8kF6t05ARWJdqiB86VfkKpdr9Rr6YIuOAvf5wD7wQ9iT76m1X/rW/EqUYEJIHdMvE/lS+azR3JkRJ/uadGA/XtPpoVKhZOxCyW+vXu3BYNmf/Mm0w/Q== 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=2IzIfll1akRPaWeOdAZwh2X1J7LPiGKGIf/2dea8czQ=; b=EWoDsJ2EOZ8fTOVmFvyPJ3FyoN8I88jBDdsARuWvs3o5ryNC93+TU0LUG8tzp4khdFBg6pcL7GHli3n5FI0Gyni4IjS9wjJVTFv97nZ8oKSIEzBdjLSjzPfOeR9XtaU8FClKxxlYD4nZ3BXN5sfIq1uUawW3VSM/RWE3FKyjKAu19TPz2I9vVK7CBwYf5DWtT0qtB030cv+EV8gu0OUj8tzwAnVocB4ggwBSdXV72S48zogyA5MuMP/Kv9z8sqPVjGNAQ/Nf2WIdICM5VMXXEjYj1J8MhHXvzdYb84BjHUxpM/0jy+U8219ExGLHqiuRDXAieFdmyTWJpvLvx9iQmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.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=2IzIfll1akRPaWeOdAZwh2X1J7LPiGKGIf/2dea8czQ=; b=EuBsYx47WTA7IddSRm+qfSRy9dv3LHB+TwcMvshOj1zI4LooFBaW97KA41+kRCDvz9D+mvsIS7AoVS8k8m72CZbJpxu3MecNrOwumyZC2UIE3yyMFVdKJocVKKtIQiT3I9Uepf/YXNASn60hAFgCxjdjxf+0Xv2XWviOG8DBt38= Received: from MW4PR04CA0257.namprd04.prod.outlook.com (2603:10b6:303:88::22) by PH7PR12MB5736.namprd12.prod.outlook.com (2603:10b6:510:1e3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.31; Fri, 18 Aug 2023 19:40:24 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:88:cafe::7) by MW4PR04CA0257.outlook.office365.com (2603:10b6:303:88::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Fri, 18 Aug 2023 19:40:23 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 18 Aug 2023 19:40:23 +0000 Received: from AUS-LX-MLIMONCI.amd.com (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.2507.27; Fri, 18 Aug 2023 14:40:21 -0500 From: Mario Limonciello To: Mika Westerberg , "Rafael J . Wysocki" , Bjorn Helgaas CC: , , , Iain Lane , "Andy Shevchenko" , Kuppuswamy Sathyanarayanan , Mario Limonciello Subject: [PATCH v14.b 4/7] ACPI: x86: s2idle: Fix a logic error parsing AMD constraints table Date: Fri, 18 Aug 2023 14:40:04 -0500 Message-ID: <20230818194007.27410-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230818194007.27410-1-mario.limonciello@amd.com> References: <20230818194007.27410-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-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|PH7PR12MB5736:EE_ X-MS-Office365-Filtering-Correlation-Id: 4cc80f41-b62e-44d9-79d3-08dba022f6ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a50D0SoZTeZ54cm2r5BGyl6+4pRJQ6xx1WU+8fuKu0VWKAVGV4BK9R6WBO9XhhT7EF7+UGBjFsh/8/mS/uV2sBHXJlF5jpy22KOsfssgpE14vizKBsx7k009nHeEbjuZr5M0bmHR7JQG0gRZ3SFdrBk/b+X/L8acEHDW7hWZ7tFOfcDOvADuRBJql4E/9IiJTckglIHJqYdZgaVQfhZ9dSR4O+Z8tj5gl1V+W+I9A4mY1K0H72HyZ5rWCBeJZn9t8GoX2pWpz4Zj4pv6TQEVfLs9eIrV+/gQNemtbfw8W5bkMJCFexhEVmt/J9LwG3konsgFkNW5Bm5MDmEVRfMKLAAG+2DoaEwzYCAeOVVlUIVij1AuvYQfrUmFwYSugzjCA7TR1eOSV4ccf6hser++ftz8L2kso0JO3/Wb77+ZHMvnYpxts8/NMkMmMVCok+0do+LyzMm1H8ZnRaRAjU9e0iz9EtRIyyjp7PrFQOReLVMF5wGAaYGB2thpIy+bbVZJa5/7IgrwMvKBQeBcl6ZzdDlbik8bf3xDZMZ/LrzlOz/q//+mtLfXTx7o22lsdxuxdEdynckaZEJWSLGk/ae4XpuG1Wj+1fBFo9xWh97x3is6olJQfd0fKlh6nVfvjsO7W8h72Dw2XEY78d4rAuhh7NfQjFz3jXRfS4SN00kFqbp2srQliuOJGRxBoky0eoYeGCHcdLXg1OQCxwvwQXS7HC3aYqPZoKogtU0h4e1sRqCgBr/7+xUA/uMRjvWOJ1ZdE7tzYwOwNVRtR6niBUqi8Q== 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:(13230031)(4636009)(136003)(346002)(396003)(376002)(39860400002)(82310400011)(451199024)(1800799009)(186009)(36840700001)(46966006)(40470700004)(86362001)(36756003)(81166007)(82740400003)(356005)(40480700001)(5660300002)(2616005)(44832011)(16526019)(110136005)(6666004)(70206006)(70586007)(316002)(7696005)(54906003)(478600001)(1076003)(26005)(4326008)(8676002)(8936002)(41300700001)(40460700003)(336012)(426003)(36860700001)(2906002)(47076005)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 19:40:23.3232 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4cc80f41-b62e-44d9-79d3-08dba022f6ea 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5736 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The constraints table should be resetting the `list` object after running through all of `info_obj` iterations. This adjusts whitespace as well as less code will now be included with each loop. This fixes a functional problem is fixed where a badly formed package in the inner loop may have incorrect data. Fixes: 146f1ed852a8 ("ACPI: PM: s2idle: Add AMD support to handle _DSM") Signed-off-by: Mario Limonciello --- v11->v12: * Update commit message v9->v10: * split from other patches --- drivers/acpi/x86/s2idle.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index 508decbac2986..60835953ebfc4 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -135,12 +135,11 @@ static void lpi_device_get_constraints_amd(void) struct lpi_constraints *list; acpi_status status; + list = &lpi_constraints_table[lpi_constraints_table_size]; + for (k = 0; k < info_obj->package.count; k++) { union acpi_object *obj = &info_obj->package.elements[k]; - list = &lpi_constraints_table[lpi_constraints_table_size]; - list->min_dstate = -1; - switch (k) { case 0: dev_info.enabled = obj->integer.value; @@ -155,27 +154,21 @@ static void lpi_device_get_constraints_amd(void) dev_info.min_dstate = obj->integer.value; break; } + } - if (!dev_info.enabled || !dev_info.name || - !dev_info.min_dstate) - continue; + if (!dev_info.enabled || !dev_info.name || + !dev_info.min_dstate) + continue; - status = acpi_get_handle(NULL, dev_info.name, - &list->handle); - if (ACPI_FAILURE(status)) - continue; + status = acpi_get_handle(NULL, dev_info.name, &list->handle); + if (ACPI_FAILURE(status)) + continue; - acpi_handle_debug(lps0_device_handle, - "Name:%s\n", dev_info.name); + acpi_handle_debug(lps0_device_handle, + "Name:%s\n", dev_info.name); - list->min_dstate = dev_info.min_dstate; + list->min_dstate = dev_info.min_dstate; - if (list->min_dstate < 0) { - acpi_handle_debug(lps0_device_handle, - "Incomplete constraint defined\n"); - continue; - } - } lpi_constraints_table_size++; } } From patchwork Fri Aug 18 19:40:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13358232 X-Patchwork-Delegate: bhelgaas@google.com 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 3AD71EE499B for ; Fri, 18 Aug 2023 19:41:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379683AbjHRTkw (ORCPT ); Fri, 18 Aug 2023 15:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379673AbjHRTk3 (ORCPT ); Fri, 18 Aug 2023 15:40:29 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2082.outbound.protection.outlook.com [40.107.244.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81A65421D; Fri, 18 Aug 2023 12:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m+RKee5lUDsBpcIfMorV6UPDCOufYta6WPZ1hXEbFUyEgp0FyPuoBCaGILiT3sXUeew8porpUwzAm8eQ9Hfdp3Q2NbtV+Q5nsaQ3tZz+GXxZzSiNeUujXb9SDhIaCfwtP3/1+ipuu5vur0LaFczCeaM7GeH0aUwzZnQCNlC1wUmWiKwY2q3o6PoaVKErjMo/guHpOvWxivhsf3qjysoBRLXLrlhnjcj5/wnZkkgXr0i3szU5VLrEReJrGX2Ly4rlxTBG4oE5I58fegZu7ti84nJIzB17hUUnr08Oai7vk/biyY0fF7dXHiMxppFZ/HdXNiX3AohCPhY7ih51nfPkZg== 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=xTO4xoD0fKS516BA38NxupBB6hbMB0PL0ryX2H7CEcs=; b=aqut4cNqqdrPZZRN7+NlVVrSDlw0GKnWDePUVXTx875gO9ySG311ds+qaKnpV9FO/Ob0Zh//++zekX6jO4dKV8JxOFsYt7MRgBH9uDSrakhWjlPRDaPVCqTN5NMdcjCjlDhY1ad+BLQR9Plk9Dky28Jl4HWAXoCEyNnYUOGFu4MiNXT/H4XvZhxNkxiLfwzPhhqDLVBwcOd/a1R3uobalitz+GmmsWtMRUzgis0rgaw2emzOOWqSFvXSUQkMKw8APoToIIzfOFDhctcFsXzkuFZ4fSpo8MANHJrb4VbHjw/lHKOD/Rt4nZoo2xRL+6kNP5mTNItTxAu8gQ3tZjQJag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.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=xTO4xoD0fKS516BA38NxupBB6hbMB0PL0ryX2H7CEcs=; b=FGr7324ZYvrbHxg4hvjbEetKErOTFHMeZl7ULZo1gkbSTgaqioIn38JKd96D48IxBEpK2JNFv37ek8HFs/XOiczPD5/wCDMpWhm6uQGXLNUEa4dPsVBbbKz7nC1NSBYfZMTMjOK+iXqMtvYO/4IQGrxSGNFQEg/1EIU5KHZBrOo= Received: from MW4PR04CA0245.namprd04.prod.outlook.com (2603:10b6:303:88::10) by SA3PR12MB7901.namprd12.prod.outlook.com (2603:10b6:806:306::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.31; Fri, 18 Aug 2023 19:40:25 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:88:cafe::b1) by MW4PR04CA0245.outlook.office365.com (2603:10b6:303:88::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Fri, 18 Aug 2023 19:40:24 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 18 Aug 2023 19:40:24 +0000 Received: from AUS-LX-MLIMONCI.amd.com (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.2507.27; Fri, 18 Aug 2023 14:40:21 -0500 From: Mario Limonciello To: Mika Westerberg , "Rafael J . Wysocki" , Bjorn Helgaas CC: , , , Iain Lane , "Andy Shevchenko" , Kuppuswamy Sathyanarayanan , Mario Limonciello Subject: [PATCH v14.b 5/7] ACPI: x86: s2idle: Add more debugging for AMD constraints parsing Date: Fri, 18 Aug 2023 14:40:05 -0500 Message-ID: <20230818194007.27410-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230818194007.27410-1-mario.limonciello@amd.com> References: <20230818194007.27410-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-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|SA3PR12MB7901:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b88969c-4577-4a4f-4a5f-08dba022f79d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l8wnGV58Rz2W1UqUPhBN3c6hv2HFhpaHOgBRsWJCR/nSMLPmjAKpzA0uZIsrzCxb7kNEA9QcthDbY43WczVEa+xA14+74PAxsmwt72TDRxVDyxAQFVmyZht3Us9+XNSH8uijr8zm0BIdfq4JaEVgrvSUgnFlha+QPCGTMmZNiUPtPetuKJvLvCeVghigDYZ/8VITxjy3NcKKN0FlEISfzs9rp6FEtlzFIyOAL5IRRevVRCejJRXls4vd5ZBS+0ChoP+07bhEPgMC4zqv6AsFmv7ufRS7cg3VweJcYrT2eGIw7LWsAM5RGaCfB8fCJe0lAShjv33s4FDxBLadKLJHIxhEKq2X85vVWodLuhoBUSdpdOvSEB9vyQIfL3DdjjHYx02afQXl006yiSU9lcu6WtcowIaTED10KgKjjjPrQ7J8aMTLLjECgBg6RA80QaHY1bSZAfC8h12P546thnZzDt5aOHXBPcziyDr/kokwgvKSN9hP//md++39Z4U8IRz8NWEtg49kMXR7aq3cCKhcv7GNmXdQqun7FUwr9LFn+NxBBzUrBzM6qcV9+j7XWOY10yJcoc1+cI8rOnKsfpVWanPiqIE1pRkGF/dTDEW2lD7QBetPki1KB83wLZJ6hZTBqSqK79qyiFO9jhXhkT3siH5dnys2L8KMv7xSdq2hkQ2FFG66knrlpOQLo78QQbJl0aShhQR7nhOHd/EG+a+uIZwYCtRc5nBKbZ8Or1TDCqUFvwlx2FGNJm5+Op4jQyg+QU/hmvtZ1Dkw+kXUHkylpg== 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:(13230031)(4636009)(376002)(39860400002)(346002)(136003)(396003)(1800799009)(186009)(451199024)(82310400011)(46966006)(36840700001)(40470700004)(40480700001)(40460700003)(2906002)(47076005)(83380400001)(426003)(336012)(36860700001)(6666004)(70586007)(70206006)(478600001)(54906003)(7696005)(316002)(44832011)(5660300002)(2616005)(110136005)(16526019)(4326008)(26005)(1076003)(8936002)(41300700001)(8676002)(86362001)(36756003)(81166007)(82740400003)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 19:40:24.4951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b88969c-4577-4a4f-4a5f-08dba022f79d 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7901 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org While parsing the constraints show all the entries for the table to aid with debugging other problems later. Signed-off-by: Mario Limonciello --- v12->v13: * move location of the message to catch non-enabled constraints too v9->v10: * split from other patches --- drivers/acpi/x86/s2idle.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index 60835953ebfc4..87563337a4786 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -156,6 +156,13 @@ static void lpi_device_get_constraints_amd(void) } } + acpi_handle_debug(lps0_device_handle, + "Name:%s, Enabled: %d, States: %d, MinDstate: %d\n", + dev_info.name, + dev_info.enabled, + dev_info.function_states, + dev_info.min_dstate); + if (!dev_info.enabled || !dev_info.name || !dev_info.min_dstate) continue; @@ -164,9 +171,6 @@ static void lpi_device_get_constraints_amd(void) if (ACPI_FAILURE(status)) continue; - acpi_handle_debug(lps0_device_handle, - "Name:%s\n", dev_info.name); - list->min_dstate = dev_info.min_dstate; lpi_constraints_table_size++; From patchwork Fri Aug 18 19:40:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13358235 X-Patchwork-Delegate: bhelgaas@google.com 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 7CDD8EE49A1 for ; Fri, 18 Aug 2023 19:41:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379690AbjHRTkx (ORCPT ); Fri, 18 Aug 2023 15:40:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379676AbjHRTke (ORCPT ); Fri, 18 Aug 2023 15:40:34 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2071.outbound.protection.outlook.com [40.107.102.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E213C3F; Fri, 18 Aug 2023 12:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VnighoZqJNlIH9OPr+LqGFMHpRqRCqnzezzW8PVF6YFriYjvqHfwqw1AT7O3gnMNueJmjXo2fhP8CwmxAhmZeA6ym4zgP+GmIB+MnxTiQTX5Xu3pNZT9jNC03QDeDR1oe0SjkNmmpJarFd2YrNxp4mjx1j+6KsGMNztPvSje4NwiIT7PpKZffr9HV1xR99zqYijYcO3r5yPnQ5PlOpTler67DF6/MPYkJk1PjM3QnmNJUvLoYPy1t29579k1TmBSo9vvz+6vyrNrg9hZjmYfPFpSSQ57Pchlo5+w8uGJpOE16oVFk5Gfub2jzHR86rfM/eAMdGsUbAVbHIu4cmDxPw== 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=EhUTZ1IHoyHfxGrEqHgIYgdrsh6UqMet2Cl3hzYHqFA=; b=T35iu0GXwCC/b5VeQ1QpTm1FpqzWevnpmnpGnRgbHIfeLx1bOrjxhf/XqC9UM5V96c4EEl0hVEuLaw2KdOrZLJByLyN/IkHVLbFQWseaBfsntQA6ZJo9u24hZdqZTgneaGYOGE6gL6FFhb7DOptxyfvCwQeCYF5c+uaCHr7RhEtigM4h0WehPw+ZJtSBEL7hfIbh6yqk03sxKJHe/DWJ67Wy1JYz58zvoAKngiRjKkFRyLcUJRVAmYgA7FKrrO89vDHPsUUI9Am5JrWFhz35fQ50nTCrNfxiQsk7dGY2mYJ4vrRZm1WOKv2NXxG+aohwKqnn6Q+8H/q/lVIpl2sd8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.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=EhUTZ1IHoyHfxGrEqHgIYgdrsh6UqMet2Cl3hzYHqFA=; b=tzRzu7vZCXalPnD8KDkeUqH8G967UfZNxyRSGE/DyZ5oaULg+NZeOTVP7KM/PW8G5N32z5QI9w2lc4SDgk0yWKrPR96K9fzWkOjSW6y9UimzsQOAmjYgEMQXgybcSsEghx3zeLs37XJnbjYu6gKtH6jrkrxFvShUV+eq3WfeX4g= Received: from MW4PR04CA0262.namprd04.prod.outlook.com (2603:10b6:303:88::27) by CH2PR12MB4135.namprd12.prod.outlook.com (2603:10b6:610:7c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Fri, 18 Aug 2023 19:40:25 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:88:cafe::58) by MW4PR04CA0262.outlook.office365.com (2603:10b6:303:88::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Fri, 18 Aug 2023 19:40:25 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 18 Aug 2023 19:40:25 +0000 Received: from AUS-LX-MLIMONCI.amd.com (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.2507.27; Fri, 18 Aug 2023 14:40:22 -0500 From: Mario Limonciello To: Mika Westerberg , "Rafael J . Wysocki" , Bjorn Helgaas CC: , , , Iain Lane , "Andy Shevchenko" , Kuppuswamy Sathyanarayanan , Mario Limonciello Subject: [PATCH v14.b 6/7] ACPI: x86: s2idle: Add for_each_lpi_constraint() helper Date: Fri, 18 Aug 2023 14:40:06 -0500 Message-ID: <20230818194007.27410-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230818194007.27410-1-mario.limonciello@amd.com> References: <20230818194007.27410-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-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|CH2PR12MB4135:EE_ X-MS-Office365-Filtering-Correlation-Id: dac6f949-d382-4d51-44ca-08dba022f819 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cUXnQ9nmwzLf/gNZ30eIw4WOilDf5rvq1/ZZZm/1Tic0OwWHyfFk9kG5azmDD4kyOj1mRWOZYwLxs0/o/I3+cnx9SsDnve32dC1uMT2gfp0XvmCxXuG1gBldkEbf/4u9eMv0V5+om0nh++VNyDicXSLY4Z7XqBcoiM+neRsdzqShjCoGYJdTYw9rl4MIsV0pnddHxnFNTOWDKy+44Qvwm6qG5xHHuk0OrbGLqWvs89AAU0TsdZc7PxSReV+Ud8rSB2GYBAM/yhT+syFI+AKPQAoXMlzOge0DQY30xBt+IlAzM2MXTaEr9zNSYz+QjapeGyrXqkcO1LM22vcdWaTJ8pvi0ETcrcdOqai5/ByafB3oJkPv5hfZb1BEZk6vinHn8zVt3/B0kKTi9h6poMoZKETzkBmP2wdlmViPfqbXf2bdpuTzt76+dLiXa/yVgxRPRAyasfAZMjlJD7Vj4/NgpbuFkgwQM49xXC02ZKhBQiaeIRntM9Fzp9zVQN6av/N2nZg3tNLQ9M4fRyqCQ9fI1m0Z5V8XzDpWsI+OutzMlkg/HryC4UXfp+HNaCGuZk+51JMT0NdAr1hdHC2kq/7+KyfL49GPLyKVWJwYb0K8DMP4bOV7eXFaM3OiwEi3U6qoCV5pXrTQ+iUtWDwQ7EwMY+aJ5Q5e6ut+fvwP5j+mBSX7l/FSt1rXtoMcLjZzMS0jlCIlGTnhTbornxCggMn8NcPsmLsbItUu3r8K+P/JcnLEAg6vLwdFNp+9a2llvED2+7tOOzktxmuiuGTfZtc4kg== 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:(13230031)(4636009)(376002)(39860400002)(346002)(136003)(396003)(451199024)(186009)(1800799009)(82310400011)(40470700004)(46966006)(36840700001)(110136005)(86362001)(70206006)(70586007)(44832011)(5660300002)(2616005)(41300700001)(2906002)(316002)(54906003)(8676002)(8936002)(4326008)(478600001)(40460700003)(6666004)(7696005)(36756003)(82740400003)(356005)(81166007)(47076005)(16526019)(336012)(426003)(36860700001)(1076003)(83380400001)(26005)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 19:40:25.3076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dac6f949-d382-4d51-44ca-08dba022f819 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4135 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Andy Shevchenko We have one existing and one coming user of this macro. Introduce a helper. Signed-off-by: Andy Shevchenko Signed-off-by: Mario Limonciello --- v11->v12: * New patch from Andy --- drivers/acpi/x86/s2idle.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index 87563337a4786..1aa3cd5677bd8 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -94,6 +94,11 @@ static struct lpi_constraints *lpi_constraints_table; static int lpi_constraints_table_size; static int rev_id; +#define for_each_lpi_constraint(entry) \ + for (int i = 0; \ + entry = &lpi_constraints_table[i], i < lpi_constraints_table_size; \ + i++) + static void lpi_device_get_constraints_amd(void) { union acpi_object *out_obj; @@ -296,30 +301,29 @@ static void lpi_device_get_constraints(void) static void lpi_check_constraints(void) { - int i; + struct lpi_constraints *entry; - for (i = 0; i < lpi_constraints_table_size; ++i) { - acpi_handle handle = lpi_constraints_table[i].handle; - struct acpi_device *adev = acpi_fetch_acpi_dev(handle); + for_each_lpi_constraint(entry) { + struct acpi_device *adev = acpi_fetch_acpi_dev(entry->handle); if (!adev) continue; - acpi_handle_debug(handle, + acpi_handle_debug(entry->handle, "LPI: required min power state:%s current power state:%s\n", - acpi_power_state_string(lpi_constraints_table[i].min_dstate), + acpi_power_state_string(entry->min_dstate), acpi_power_state_string(adev->power.state)); if (!adev->flags.power_manageable) { - acpi_handle_info(handle, "LPI: Device not power manageable\n"); - lpi_constraints_table[i].handle = NULL; + acpi_handle_info(entry->handle, "LPI: Device not power manageable\n"); + entry->handle = NULL; continue; } - if (adev->power.state < lpi_constraints_table[i].min_dstate) - acpi_handle_info(handle, + if (adev->power.state < entry->min_dstate) + acpi_handle_info(entry->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(entry->min_dstate), acpi_power_state_string(adev->power.state)); } } From patchwork Fri Aug 18 19:40:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13358234 X-Patchwork-Delegate: bhelgaas@google.com 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 5899EEE499D for ; Fri, 18 Aug 2023 19:41:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379692AbjHRTky (ORCPT ); Fri, 18 Aug 2023 15:40:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379675AbjHRTk3 (ORCPT ); Fri, 18 Aug 2023 15:40:29 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2086.outbound.protection.outlook.com [40.107.223.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E7E84221; Fri, 18 Aug 2023 12:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y+yMy3NvM48ZgfwZOaiwpbw3E+AioSJh02NpdXEOqHwH5ehaIHJmBn31fAobY4Fnuegg7VeOoOC1fNiW3YdVDmQ3LsquQizsptigIQyrXFK1rlXpgMbr+LIAEwfeFpXo7RLEkodaHH04x5BFW7aB4fEjLW0wS/K5wMJ9D7QIFgXMPMuS20PP1THQV++V5nsruykdJ7SZFiv6thBcDkQ+yzjvxGGK2MrAXlmB59u1ZLxK3fl/PRyTM3JplObqKdqhNLPlZVGDygB2qz0DD06zYLtGbU4NKoFcbcgZUfat3pZTGF+RU6BlHVDAOZuii/HxL3F/uLzQNgQ8e5xo5nb6Pw== 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=irFH7+vZKhEXTu8K/folZo2P2pj3lGNa34VIcEc1g6s=; b=X3fNY1ig9w1G3j+B+Qlgb3gpFu2kjIIvil0N2hUVMrqLx1XqEQQRJ+LiKdMV+9m5qfqj5F0oD2B+PbII1FOqDWZMb9Fr92c+0wjYX//a4nuKyYmYF6Wfm9iPz6nWV3woT/R6t1SRaUYNqNN/zimdn64Qaaae8F2pTf8BuqiKZUYKqnYPQbk5m3w/zZsx4w/DYNASCjtcg6pL6zueR5XxXuZHIixynOemf60wldFFgzo1UaiDHSPIJKhIuablvCwvSfBwVoF/0uArU7ThKN+teVOLB8PRSWz1iJUJOXwl0MoR5dyiSOtC6uTEIcwQfB5+jQjk4Gmm1VrpZPVW0N+pNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.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=irFH7+vZKhEXTu8K/folZo2P2pj3lGNa34VIcEc1g6s=; b=gcNO7WZcKj//RNe971EkHo7QNqPyQuoDh6ai7SIJ8YFQw4TkPWWPC1ikgfcpjwvvq5Wdrh0AvjmWQW5P17k+Iw6o3p+hZ1CL+86ugsFt2acocch2HbrBrYlZYdaPrGvEOILhuuXSa0wNfGmQAAUkyRgii3nNQ4oVID23mNOVGoc= Received: from MW4PR04CA0258.namprd04.prod.outlook.com (2603:10b6:303:88::23) by MW5PR12MB5597.namprd12.prod.outlook.com (2603:10b6:303:192::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 18 Aug 2023 19:40:26 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:88:cafe::80) by MW4PR04CA0258.outlook.office365.com (2603:10b6:303:88::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20 via Frontend Transport; Fri, 18 Aug 2023 19:40:26 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 18 Aug 2023 19:40:25 +0000 Received: from AUS-LX-MLIMONCI.amd.com (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.2507.27; Fri, 18 Aug 2023 14:40:23 -0500 From: Mario Limonciello To: Mika Westerberg , "Rafael J . Wysocki" , Bjorn Helgaas CC: , , , Iain Lane , "Andy Shevchenko" , Kuppuswamy Sathyanarayanan , Mario Limonciello Subject: [PATCH v14.b 7/7] ACPI: x86: s2idle: Add a function to get constraints for a device Date: Fri, 18 Aug 2023 14:40:07 -0500 Message-ID: <20230818194007.27410-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230818194007.27410-1-mario.limonciello@amd.com> References: <20230818194007.27410-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-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|MW5PR12MB5597:EE_ X-MS-Office365-Filtering-Correlation-Id: d8472c3a-857f-48e7-67bc-08dba022f87d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K9Fxy5+ZWV+NtJbG34Daxxt81Cv+FLMB2cCstrP3szsFq1hL+il5LkyGwam3TR3BBx80Tyq3iINRg5z6aCgAR8mR2FYzalbiYdI7oCyczqiaepjWy7ldhzyen5rDKMhNuiy/O39JR1ncvYSxMyxr5PHhspyNeIA8gFmaOq58FkPjHR1esqj/XKHMSufD07uHhVkPHCymcjBRZs50webBHiRderhBkp+CV2VtiXL6wnX8+zbx9r9cfet9ingIZZBMt2n/BTntv7ThyVWMup2S5t210lxbYuxnxKrY9qdVufCnnHv7E8/B+5MVsdi56cZErdViOdj/dRFSv97xSbRSvyKyWwSIG0aQmXMZEJXzbDSgs39ewZadnyXw6kXH7o+NJ6CL9DGa9ELLu0FDogzCKHIwCPhgpC2jHZbhVQQVARJoLxCtihXocPsjsWtcW6xhfeQtqp9IT/UTJsEywS0eStIeF9AxxgyrD5Fu2MfIBGv2y8ieTbrHKk9/ZzI1+mg/TdBp9gB4RyJEr1KmV4xwKAjgkehI3KX5LrOxYzVXbhTrpmtqQc0KNy7Q24Z2n81SXYSBqqeUtp9trvlcUrxv7KL6TxQ3V0qqKpqwr3ozFf31e8OZH6N/ShuDBscENmkZD22bWOoNIDb9qX/StejSqAmVUxmMZuSgMw0By+RiX9W3A446DyV8OI0cxf41iyF+BtxbsaoMBwZ3H+RNgwuXeO0bPHqQLor8yoivHap8IN/BVzljGgezT2JabCACO+6++XO3Gfxla8O/PYvzL4UULw== 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:(13230031)(4636009)(396003)(136003)(346002)(39860400002)(376002)(186009)(451199024)(82310400011)(1800799009)(36840700001)(40470700004)(46966006)(2906002)(40460700003)(83380400001)(26005)(86362001)(336012)(478600001)(40480700001)(426003)(7696005)(6666004)(1076003)(2616005)(36756003)(16526019)(44832011)(41300700001)(5660300002)(36860700001)(70586007)(82740400003)(356005)(54906003)(70206006)(81166007)(110136005)(316002)(4326008)(8936002)(8676002)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 19:40:25.9482 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8472c3a-857f-48e7-67bc-08dba022f87d 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5597 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Other parts of the kernel may use constraints information to make decisions on what power state to put a device into. Signed-off-by: Mario Limonciello --- v13->v14: * Use acpi_device instead * Drop debugging statements (will be used by caller instead) * Return ACPI_STATE_UNKNOWN on no enabled constraints v12->v13: * Drop checking for enabled, just return constraints v11->v12: * Use for_each_lpi_constraint instead * use CONFIG_SUSPEND instead of CONFIG_ACPI_SLEEP v9->v10: * split from other patches * kerneldoc fixes * move debug statement to this function --- drivers/acpi/x86/s2idle.c | 21 +++++++++++++++++++++ include/linux/acpi.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index 1aa3cd5677bd8..3019ca760ac1b 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -299,6 +299,27 @@ static void lpi_device_get_constraints(void) ACPI_FREE(out_obj); } +/** + * acpi_get_lps0_constraint - get the LPS0 constraint for a device + * @dev: device to get constraints for + * + * Returns: + * - ACPI state value for constraint. + * - Otherwise, ACPI_STATE_UNKNOWN. + */ +int acpi_get_lps0_constraint(struct acpi_device *adev) +{ + struct lpi_constraints *entry; + + for_each_lpi_constraint(entry) { + if (adev->handle != entry->handle) + continue; + return entry->min_dstate; + } + + return ACPI_STATE_UNKNOWN; +} + static void lpi_check_constraints(void) { struct lpi_constraints *entry; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index f1552c04a2856..2212668ce60b7 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1109,6 +1109,12 @@ struct acpi_s2idle_dev_ops { }; int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg); void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg); +int acpi_get_lps0_constraint(struct acpi_device *adev); +#else /* CONFIG_SUSPEND && CONFIG_X86 */ +static inline int acpi_get_lps0_constraint(struct device *dev) +{ + return ACPI_STATE_UNKNOWN; +} #endif /* CONFIG_SUSPEND && CONFIG_X86 */ #ifndef CONFIG_IA64 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);