From patchwork Fri Aug 18 05:13:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357351 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 5BB76C001DE for ; Fri, 18 Aug 2023 05:16:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356214AbjHRFO4 (ORCPT ); Fri, 18 Aug 2023 01:14:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345251AbjHRFOt (ORCPT ); Fri, 18 Aug 2023 01:14:49 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2077.outbound.protection.outlook.com [40.107.92.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D828171C; Thu, 17 Aug 2023 22:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hwwQoZPF563aQrA4Fn08vCwrywkzC/POUt/h5mzSMVZIEq8wxp7uvgdVGWBsD4Z1lwklRfQ/vMgkl9aiLc6unejDkP4M7NVrcu9XlEHVYVpninTgJuDSVlNnURSnMRwZfXgx0KIRiKk8Z7r+VLPmR9uhGJln0qXzYEt015M0J8XggVPApXiw8l56YsukoyZxVlOV/iA3PN08c5iHlB0l+w1AaS7RrVCGk6q6wKssmzXFIqyHeL5tWtxHwmbH16AQDjlBfu3jwOEE7UQgXJ2qo2GCzdITAvLaU07pPG7xIXcXAAn1hekRbRBLO7q574b45mTtJxoTBjoNa10gS0vpkw== 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=IEiDlO3T4brGDkVTEm6oj5nolg5lnzhnVukZlSHVBSI=; b=mI86wAE8Iel3Ud+uqjv8NWZTjtHAwDlFZBYU/KWnz9ICuH1ujOFv/X3al/G/wcg9H/7JKlhS6GvY2SR2NZ1SIWb1jtgR/tuW48+yS+yxRr14itwiRxLYzP/jViEGaozzat4yfpJSlMsCjNJ3NyzlaVoLv8nvlqLJfNgop3+qHE5L4vR0QfgJb39M6MfqfD79HO/clPz1NWBSefnTR4IFHJ9JKLerU5fVhQk+3b/YkY4oEaeoVsPJefof0vyXKBdPWqth492I5Zbgg9/+1ph9ZpKk3uQ3Vtg/b1EorB+kI9fnJwc2/l1Todz838yoGVgmFwKp1Abs2WbWq39xemeWzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=IEiDlO3T4brGDkVTEm6oj5nolg5lnzhnVukZlSHVBSI=; b=rnpNERsoqZJ5QnA2WnKC7Jv/rkxCXBQylM9aj+SQfwBkVoE38j02DgtcnO3xLwRInPqspsuKAP1FcyYQovOQX3JqTrubalQByLHGPyLNBRDzNKBX+1kooHI0A2nAu0gDLIa3dNpLeoyLQVs0sxHfO8zl9H7kAV9aJrzcL8klXMY= Received: from DM5PR07CA0095.namprd07.prod.outlook.com (2603:10b6:4:ae::24) by BY5PR12MB4997.namprd12.prod.outlook.com (2603:10b6:a03:1d6::13) 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 05:14:45 +0000 Received: from CY4PEPF0000EE35.namprd05.prod.outlook.com (2603:10b6:4:ae:cafe::f) by DM5PR07CA0095.outlook.office365.com (2603:10b6:4:ae::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.17 via Frontend Transport; Fri, 18 Aug 2023 05:14:45 +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 CY4PEPF0000EE35.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 18 Aug 2023 05:14:45 +0000 Received: from SITE-L-T34-2.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 00:14:43 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello , Subject: [PATCH v13 01/12] PCI: Only put Intel PCIe ports >= 2015 into D3 Date: Fri, 18 Aug 2023 00:13:08 -0500 Message-ID: <20230818051319.551-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE35:EE_|BY5PR12MB4997:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a9bce19-cde7-4125-ee4b-08db9faa0970 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BOMXDw/cMAJ9xlSi/7k7kXLYe77jZ6kIxvIdSWpKi7iqDzXIh0ZsZC5slEsSzSkHT03GWBciC+E8C+oIcgMtX7DR4is+EfJ2wO2rK3hePdNPuWI2FqkVFgnUT3NSn6HD3R6rTgBpuRsr1PJsTQZdopJWSWzX8JZ4l0EamjP9dnIPIrhyonYg514lRywIZ/daHV8mEveX16JwPHXCFj2Tpd4nzxM9aBI8VzEX5akB7jwt8AyV2OzN49LowS3TWOmltNIzE0yLJl9Ljg/9XMl/fEuuJEUL4Hg/bQBVcbsK27/1woX2PtQY3uLh+DWcZ/njqyc40kmWKnHDg/ZodQcb45Y+LFKC91zpSVrO6K3zbyJm1X8L4q/oQ8ppkxVdBZH/JPRxGEuw2UX6U+/mxfcAGFDDcrwhT6ppmpX5tVMDyRo63KlZ76EjOrDMsdCgTGXUt+SCZts79RKX1GRYFWrfz6vSaDnM6Kk4kiC7lqcuLFtOUiQxVgLrz8MxkdgAFoyshdkqC597DzSRaarkmEFkQoeWj5TFhWUhNatKbfkEYi2rohT0qiJ2QtuuK7mHr5RRbBKeR5X9Ra5XMmgTyRJANgvJJqppH2vsf4YJxpmFiMYTWPb3Yps2GWcelAFlB7v5ysXDqRT1ryKRTWEe1ULh0B6Lvw2eOh4psEonIgxY50RcFLMyZru85LDf29zQRXxKagjyfe+0xPm9dJMDIHemyC+Eo4nJvsCLuOLJjdo0jKpHqAmIV0I4zMOi2n7fbZS8 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)(39860400002)(396003)(136003)(346002)(376002)(1800799009)(451199024)(186009)(82310400011)(40470700004)(36840700001)(46966006)(5660300002)(83380400001)(40480700001)(40460700003)(82740400003)(70586007)(316002)(54906003)(70206006)(478600001)(966005)(110136005)(81166007)(356005)(7416002)(44832011)(2906002)(41300700001)(8936002)(4326008)(8676002)(47076005)(2616005)(426003)(7696005)(6666004)(1076003)(336012)(26005)(36860700001)(16526019)(86362001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:14:45.3616 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a9bce19-cde7-4125-ee4b-08db9faa0970 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: CY4PEPF0000EE35.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4997 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend") changed pci_bridge_d3_possible() so that any vendor's PCIe ports from modern machines (>=2015) are allowed to be put into D3. Iain reports that USB devices can't be used to wake a Lenovo Z13 from suspend. This is because the PCIe root port has been put into D3 and AMD's platform can't handle USB devices waking in this case. This behavior is only reported on Linux. Comparing the behavior on Windows and Linux, Windows doesn't put the root ports into D3. To fix the issue without regressing existing Intel systems, limit the >=2015 check to only apply to Intel PCIe ports. Cc: stable@vger.kernel.org Fixes: 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend") Reported-by: Iain Lane Closes: https://forums.lenovo.com/t5/Ubuntu/Z13-can-t-resume-from-suspend-with-external-USB-keyboard/m-p/5217121 Signed-off-by: Mario Limonciello Reviewed-by:Kuppuswamy Sathyanarayanan --- v12->v13: * New patch --- drivers/pci/pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 60230da957e0c..051e88ee64c63 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3037,10 +3037,11 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) return false; /* - * It should be safe to put PCIe ports from 2015 or newer + * It is safe to put Intel PCIe ports from 2015 or newer * to D3. */ - if (dmi_get_bios_year() >= 2015) + if (bridge->vendor == PCI_VENDOR_ID_INTEL && + dmi_get_bios_year() >= 2015) return true; break; } From patchwork Fri Aug 18 05:13:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357352 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 20714C7113D for ; Fri, 18 Aug 2023 05:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239903AbjHRFO5 (ORCPT ); Fri, 18 Aug 2023 01:14:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352334AbjHRFOu (ORCPT ); Fri, 18 Aug 2023 01:14:50 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2089.outbound.protection.outlook.com [40.107.223.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B665810C8; Thu, 17 Aug 2023 22:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aNTJxBxp+iSjgByzcI8EPv8DtnY2IwTTtrj/14/i6u+2iwN9ygW9HMsRozJZSxl2iXT0EMSJJ3r3xP3b+ivsvqvpOJPPgWV2pqnK0z9ARVApMuXEBCbIEtfWf3xQKtmwTzpoHHOleuN8k6IQyGdNmB9hp9HRnw7rl6yn2KTG6zGTwxA6TJR+M9attQ+alseoPw5YrtfngIGr1zc4R3k5t2LIJlRMs53Y4BujL4vqIByzKfak+/FTwRRmGQkN02UkY7p7a56qB3Yrx5t2Dl2UKnsn7RPZ3t0s+J8D6Nm2o2UfG9abaq8kDtNsDukuP2RlmW+ed6Ul4MmsclrBIiHLVA== 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=Nubf76jY+v8EjUmA2sf3PE3mZp7CYUrOFXK6b2nb75I=; b=jt0b+daBGePtlcQEc0dyx7SFaa3KjiFdLOKy2S/36yMEK38VE9qOePI20VQaskkPIsUpjcTTA43hWFMBq9gqzbFoxhHR0sCbp6QIjN4jrgWPSv3gNN8UmU47G2kj/nag37bt2CnXcXDxAhNl2x084I6ZwMACITx7F42r5SDXuz2Vq/eZ5+N69WM84RXMOSTya+L5EKvCtYImXUBfYMK5tkk2Fvs+lBmiMwUtVezMSqNE/dSiVI7juopDc9G0zkZSBQE4yh6900cf2lMm9rmWbNXdN1harei8hPUFxXxFs7Xto+Lpjk4smMNNB3S5pZ+fS/5BIMSnZWqLUdDV3DTa7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=Nubf76jY+v8EjUmA2sf3PE3mZp7CYUrOFXK6b2nb75I=; b=cxsyTz/ogS7/KL87aMU2+vpUK3AMZ7t6ADlG4Zib33z5ooOFHT6nXGy/HkaE3lEjVHVI/rNhXW2upgXl0w6RT5TWzduZDalyRaAOxFg8U3voVPEOSsBmZst6Ls9kN92a15ZkMRKwC6P1qleMD1a846bBdqcdU0t9D5pacwxrbGk= Received: from DM5PR07CA0101.namprd07.prod.outlook.com (2603:10b6:4:ae::30) by DM6PR12MB4417.namprd12.prod.outlook.com (2603:10b6:5:2a4::12) 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 05:14:46 +0000 Received: from CY4PEPF0000EE35.namprd05.prod.outlook.com (2603:10b6:4:ae:cafe::26) by DM5PR07CA0101.outlook.office365.com (2603:10b6:4:ae::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.17 via Frontend Transport; Fri, 18 Aug 2023 05:14:46 +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 CY4PEPF0000EE35.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 18 Aug 2023 05:14:46 +0000 Received: from SITE-L-T34-2.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 00:14:45 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 02/12] ACPI: Add comments to clarify some #ifdef statements Date: Fri, 18 Aug 2023 00:13:09 -0500 Message-ID: <20230818051319.551-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE35:EE_|DM6PR12MB4417:EE_ X-MS-Office365-Filtering-Correlation-Id: a19ede08-661e-4918-fb7b-08db9faa09ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G8FdOtwZQQILlLEfd6FMrl+VQryapByBK2xZa0+d6R5y4PRmitPdT7QS2ynWVIgbUZSgxXzfe85t48imvspv6qS3lFLOg3S0DFHbzpiUdssci2OJTe8gcna3GHho+cUn504RwPb4JGvWvgbiiDKl2Y4I/225MXBdaGhp/myMt004RPigLoeOFlrKL/1a1meb28KaVFNcSgwCIe84g938dmXGJ8/psSH1R7NXtJ+Dax4KD+OtEH5HSgZClojufTdp7Mk/R6uotm/24t4nB41Vo319LyJRXCAyOGoEhgz3Z923sehshCtSuZdj6EXqKXrGBnbgqoEe7LgpYQ0aGyiajHBcSJaG8LVdI+v5oEidUOLB2beG8yiRfOimOxHm6w3ShqwpKoGgBhgwynULs2FFMb2RJKzgAv4GrxfXoJXZqvIf2qLFNCfjtLNIjtc/P8RJEHKgVHOAEwGmYUPyEruHVZoMvaKaJM/nYu7f/MLac+iVjAthDMBksOeHGILGZ69Eh7wp2gwScxQiTPlLLa4WOngwGo3wRrg9at+wpP7vtxBiBJO5ceC0jGxb6w/gEvw7TXWi0KtMnyz9DRHjU5XDvn/CjxjEg2G+f4hKJWBGW7Hlpbso/9u4b+XuZtUybkJpaP+JE29AfRvwaz5S+ZQhLBqJaDz5I5rHWcVp9Dru8eq8a2rZJLPPhS8xBhc7kgYHqSgAnIOrJ60139wSm8lRQxyli/9am2lBGMbXpJX9A9nFrwIyOhjhDgYUD/CyIIcROn5xF6tM1+zXW26CaglbVw== 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)(39860400002)(396003)(136003)(346002)(376002)(186009)(1800799009)(82310400011)(451199024)(46966006)(36840700001)(40470700004)(36756003)(40480700001)(86362001)(40460700003)(81166007)(356005)(54906003)(316002)(70206006)(478600001)(110136005)(70586007)(41300700001)(82740400003)(16526019)(6666004)(47076005)(36860700001)(7696005)(26005)(426003)(1076003)(336012)(2616005)(8676002)(4326008)(8936002)(5660300002)(2906002)(44832011)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:14:46.2834 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a19ede08-661e-4918-fb7b-08db9faa09ff 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: CY4PEPF0000EE35.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4417 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org With nested #ifdef statements it's sometimes difficult to tell which code goes with which statement. * One comment said it was for the end of a CONFIG_X86 block, which was wrong as it was actually a CONFIG_IA64 block. * Another block for CONFIG_ACPI didn't have a comment. Fix the comment for the CONFIG_IA64 block and add a comment for the CONFIG_ACPI block. Signed-off-by: Mario Limonciello --- v12->v13: * Commit message improvements v9->v10: * no changes --- 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 641dc48439873..0d5277b7c6323 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1117,10 +1117,10 @@ static inline void arch_reserve_mem_area(acpi_physical_address addr, size_t size) { } -#endif /* CONFIG_X86 */ +#endif /* CONFIG_IA64 */ #else #define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0) -#endif +#endif /* CONFIG_ACPI */ #if defined(CONFIG_ACPI) && defined(CONFIG_PM) int acpi_dev_suspend(struct device *dev, bool wakeup); From patchwork Fri Aug 18 05:13:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357353 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 31BA5C7113C for ; Fri, 18 Aug 2023 05:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356237AbjHRFO4 (ORCPT ); Fri, 18 Aug 2023 01:14:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353052AbjHRFOv (ORCPT ); Fri, 18 Aug 2023 01:14:51 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2067.outbound.protection.outlook.com [40.107.237.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11561171C; Thu, 17 Aug 2023 22:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ec3IVGMXZNCUYKBpOoXbcRy5lcHyfTQZ7baDBSnx77G3q3D4RFxGQTNVN5NcEfYFh+uohitcvim2ndUN7Ua/wx5RDkVIp1YU2aNweM5lmwpzLtf21taxWh16KRm1XlctzkZ6wsMTor8lK7SCZ62eNqzsd6EojtiGRfT9/lh21QypCG/eL1kxUMYj8VH0cVoO3lwxAQeFOmPUQXPqLCSicgk9l4/aWP6a+k7rskaYT0a7yCVFOCP3qLZ1byNy5wL2Dw/IA3/nGtdKWPTh3UwmiFpo36IPBLjWGC8SfKDU7dpdGPT4OlGMBLAjMvlVJEPMW4MAiYIeOQ9W710r5/MJbA== 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=npFFCNaSb9s3Xep4/Z3wGxspl3BhkO3fG9jDfecYYhLYROn/sqp96S6B9aiG6GaMNHQXQSW+1arh+31eJyualsfnibuQy9TiyyQrGuSFQGu5LTkRd0PFXETMhIpxOU4TbmpuLo3rA2SP/ozFj+MIBUa7pjWgiGWIFNLDdZUpGHfdMfVLV2w6RrPVjff8o3ZZToeM3M0HkHQpj1SR5pcEFz2vQPPfRr4smOWqUdlvtC6XtqqnKR31B7jVZwshhlwcjYgxADqp/BZUqA5Ee/ifS2lqDBQtV0yAmeBBbt3rHB4YuGUn+H1BVpcatbRiv0vl8GlmNgB3h0GaZLlKzvfjkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=SrYHZTwdSSG331NtV/9JzZPFjILiyyxM8W8Df6wqu8ix44Bm8Evn96iGp1Y6QYCUyVkHmPdBUaoCO8VsaT+ABkoW5aRYAQNNYO5R7Q2TMuMvbbtmjjAdERcxvWhGTfkgNNCfaiNokjzsCTKRZQfrEMH3nBBHhg4JiKg8+h5LVU8= Received: from DM6PR02CA0037.namprd02.prod.outlook.com (2603:10b6:5:177::14) by DM4PR12MB8570.namprd12.prod.outlook.com (2603:10b6:8:18b::14) 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 05:14:48 +0000 Received: from CY4PEPF0000EE37.namprd05.prod.outlook.com (2603:10b6:5:177:cafe::1a) by DM6PR02CA0037.outlook.office365.com (2603:10b6:5:177::14) 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 05:14:47 +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 CY4PEPF0000EE37.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 18 Aug 2023 05:14:47 +0000 Received: from SITE-L-T34-2.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 00:14:46 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 03/12] ACPI: Adjust #ifdef for *_lps0_dev use Date: Fri, 18 Aug 2023 00:13:10 -0500 Message-ID: <20230818051319.551-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE37:EE_|DM4PR12MB8570:EE_ X-MS-Office365-Filtering-Correlation-Id: 97c6a6d0-6fc6-4864-998d-08db9faa0ac6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 12JgZ79XFUcSPNv8jhzqWQ1QInNuuCChhKlCsfCQ2l5tjuucf4MJ1aAJ/xUQ0mZvzjbIvfGq5ze04ZDSVpsX9ZdMpMCXIBz+E9OPRxzE08cUZMjPTtzBymy/m8c/4TUkzsWcmwuTx14CtZDteikNGtjMMEtR6Ol00adhdonZYjfxSkmvIh7Yoc52wQmSn0bVA2aw1Wl3LKmkJDWibFvief/ea54H9O2kX3pZnPD/xJEgbeFqn9hMM/7q947PGvc8jumCrtkZGAVHOmhjYDz67LMHJWuuI/HToM6aSiOo6veQl/R0uYQYpKWKQUFMJpb/aCt5z17DL0TdDN6x2+rzr3t7tSEeB73VvP9MKOHbqJ+PwbIuXNK27WWUUWIQA3pw56o47YEVVk1GysZy3qgh0TEw4RgYjB8H/qclc/qEQRKbWD1YirhVk59C70/Q34vCad6w39DalQnloqqDfqDaEWm+224I4tZBuPKt0mllnsjhodtOXLMkAMpSVn+pFJFTyViF+8bzRmjXnXXQr/yOJGmG6Hq1/Z5/og91FA3OKaKEa98AyUOnxOpE64RGMWfJIqTWC2buwt2dQpMpp+Xa3qwbSGTHKSQGBj7BVQcPwvDR5+ydXGuGoKCuLx7ELW262d1Juu9JtCldlUNqNJjPlUmGXB/XOxL0p8Dc66tfrssCc/yXj/tk2Vx9oiVAc7lZNwTP4Nfw0PjF2YqSI4d2AwGGnkLrr9yCVzBETE3Qs8lvtGzg0oyU/yoSSW99W2GjdgZytPSb7IG79mz/LEQ6ng== 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)(376002)(39860400002)(396003)(136003)(1800799009)(186009)(451199024)(82310400011)(46966006)(40470700004)(36840700001)(478600001)(44832011)(316002)(5660300002)(16526019)(26005)(426003)(336012)(40480700001)(4326008)(8936002)(8676002)(110136005)(54906003)(41300700001)(70586007)(70206006)(7696005)(2906002)(40460700003)(6666004)(2616005)(36756003)(36860700001)(47076005)(1076003)(83380400001)(81166007)(356005)(82740400003)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:14:47.6007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97c6a6d0-6fc6-4864-998d-08db9faa0ac6 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: CY4PEPF0000EE37.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8570 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 05:13:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357356 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 12A0AC71157 for ; Fri, 18 Aug 2023 05:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356702AbjHRFPl (ORCPT ); Fri, 18 Aug 2023 01:15:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356102AbjHRFO4 (ORCPT ); Fri, 18 Aug 2023 01:14:56 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2046.outbound.protection.outlook.com [40.107.244.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DEB510C8; Thu, 17 Aug 2023 22:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U9KtHNub7nwdt/0EmtRd+aILk9kHeLsAw3+cFSZJoX2rY8Iaa8xUX5lE64EpnT14eMQlpIDFqIk124gtWrs3Q3MzhIS847aNwRH9FzSK/FAAeOeEicNdNj0ZykcvHjnQhddr9aFjj/mSEKEXIoy1MBqJ4KDDkEcE1wUlm32+nTncBCUFZ/ijgVRw+JWakKW0JyzaIUkOb9haubeI2+A//j1QuTG5UEFHoBJaS1PKUSzNGOoAt8ECZGIC0pMg73xM7yA59MqBaHxIFoW9wTrJu+7e/zZ7ivua1dT/oDIYaPrNBVR285q9t0D1LOWmpSuQv/Ng+v0mHwQ0oMBXDc8sag== 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=YXQKo98cdznQp4wg1ONokavx6aL+2MZujt49S6wV3dnvvSFeWsTnQgMmOWsrF2djzBbQh9GMER6ee8pX4EG3RwOSb8cqrCsqwPUl1YuGk5mSGbIwlLQfKNlk7iDtovUb2g/wBt92NxEPxL+bYFc1u5mlTbJcW+Fzhsaek2U5nzhYvhgTGD2E68y510wP409aku28uhMm5c2tztaH7O9VjYW4USIglB36SNqjFH96CRm2xM4oAsivye+OM4x/kmn1uuaRRNO5f9cFTFeivR1QnpboIE2kGwIV2AsQjzorcxTPBPm2izMqc58dFHOUpsisIHHDKqoM7DAf9EjZdwsGzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=lEKibi/S25jFpbhsB+VM4hcbF8CqfM5FsBPaT84StM28LMg4euyIIa6BUWT9l6/scqDUKQh4gtuf2pmsKCmIxlklv8HtJ01lHMBHghVxMVlwZ7rWj1G9l1dS8JIC9lhUo1DmDe3WTgGoEWB/FEvgyAFl5QN5XQusuK+K+JbtBH0= Received: from CY5P221CA0096.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:9::31) by PH0PR12MB8008.namprd12.prod.outlook.com (2603:10b6:510:26f::11) 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 05:14:49 +0000 Received: from CY4PEPF0000EE36.namprd05.prod.outlook.com (2603:10b6:930:9:cafe::25) by CY5P221CA0096.outlook.office365.com (2603:10b6:930:9::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.17 via Frontend Transport; Fri, 18 Aug 2023 05:14:48 +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 CY4PEPF0000EE36.mail.protection.outlook.com (10.167.242.42) 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 05:14:48 +0000 Received: from SITE-L-T34-2.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 00:14:47 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 04/12] ACPI: x86: s2idle: Post-increment variables when getting constraints Date: Fri, 18 Aug 2023 00:13:11 -0500 Message-ID: <20230818051319.551-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE36:EE_|PH0PR12MB8008:EE_ X-MS-Office365-Filtering-Correlation-Id: dbeea1d8-9fb0-422c-049e-08db9faa0b65 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dfACwTUL+w7rtR/ZyCwsD1QshfQBh/B7oVaIVyQmkQ7hmqGEePBUSAEEUXBM7LJELIjclSDBrhJxbm/e+cBMvgE7ivnroYNTEfOJ68iYnv2dSUluIwzxyI+5n6kacGEUWit2vtP3sYbIfb2tGCrvaIy3/JC5PNbzWmGKCJxP98+paKObGdUHxwR9kWYD/JgR1FFA7kmpm28YycA2I6oR3hZaeRh2VHW/tUBLQM5sVqqEYXObGjrn8CbU56zHxvrp9XuAJBC9h0OHNtpoWnjS4pWhU2x7KCDms2eMkdNjdPCFLO2IE2C57mg7CFrch3XCqhZ+cautUh9rBEW6+inbVw136ydeDXNFXnQYduj4QzNJR2H6FlYN+2a9uNS3WvWCK92OfyAXciH3ayDImCLPHEADxRV54gzWZiCJ/DX7/VqN2cYSYX7vmx9b0N57Jif1SQPQpGUwSYHQY8et9o9paHoM7Qe81+EUIMJii/4oglGn5ZrQr7t+FMmwT9p78s+xER51QjOl7RSHpmDHSQmRCheh+C2VkoCE187irDoJaEoJzyUwaRXboz8VDxS1NGHN3gzO4nGbHqZdqbaLY+qiGOMpkthLJXl2SA5JbavD3/lzzIEp00jvoy30zaQKO7ySyomOtzw+hSJWqw4YXqMsb7WQqDQ25LRrYcWrbACcJc+c/jeb/wKxxOrGwgmzqcXbGHhrt4mslL0N98CaS9jPlSh654P8iy6K6s2SSvyKTjqXuNq3dzrmcRGN0EGSHwc5JSzg8afUp8+t2ICnt/U1dA== 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)(376002)(39860400002)(136003)(186009)(1800799009)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(478600001)(316002)(44832011)(5660300002)(16526019)(26005)(426003)(336012)(40480700001)(8936002)(4326008)(8676002)(110136005)(54906003)(41300700001)(70586007)(70206006)(7696005)(2906002)(6666004)(40460700003)(83380400001)(2616005)(36756003)(47076005)(36860700001)(1076003)(86362001)(81166007)(356005)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:14:48.6389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dbeea1d8-9fb0-422c-049e-08db9faa0b65 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: CY4PEPF0000EE36.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8008 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 05:13:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357354 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 89944C71144 for ; Fri, 18 Aug 2023 05:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356295AbjHRFO5 (ORCPT ); Fri, 18 Aug 2023 01:14:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354040AbjHRFOx (ORCPT ); Fri, 18 Aug 2023 01:14:53 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2051.outbound.protection.outlook.com [40.107.92.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20F2610C8; Thu, 17 Aug 2023 22:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CjJsJc8tY1WKcAg2H86ONtIji3xaLuN7mPgcQPQdoP3qeQdD11JhLBZV0DcHjXIZOGHIn0jzvr5MrSVSOsjxYyfbNyxbbTpKtfudtj5iTbkrgqHJGTD/h3PMZfjOKVCo7n6yQ2YRUN6D21dmZYyxDULt8o82kHAth+ZGN3SaUCP4DqG4aEBOOMYIf5RAcgYcegVY3OKSGb29HhFNSEe+llaetsPnVZhhpb7pUc+JmT7NWJplPzXlxwYkVefQ1dq1u0SHigOfki3znJJtGNZVt3M91yfl6h9gdB3zZGzASJ0IdttZIEKNWY/vekaRA735dYvvNQ3acMEFN+gvZ4VQ1A== 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=Luxw8bUCLq7X+D5frLVYEX1wPbQ+Bp7p+GIAk+utiRvnL57nIkqn8h3sa6pGnMh2MMaI+ELGF17MQGRYUKr3nCZPusZIjm1+SOaSpdxUMld1B/9RsyinV5HL3IREZKy2JDCOtM86VUiPlZzDaYcS71eBSrbOQW771p4qO8viUQ6yCuScRD2TygGYCyWs0r3NQayoNb58GVAEHZ30Z5MlgCoVZewcVTrb4x5Xfcb9tOkgrcHxTVOUoXTR+hUrmtStjHOk97vACO8IhLAmJmXwlzxMm1+/ztxsaHgKw+B6pikcn6B/0reSFYiky8eusogXjnHakJCTpWQcAbZuxSQ24g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=fTh4LhorJOZwrD0cKNw9VuasaZtTNPahnw9OBDXF1bmoBl8xl2Jz/v63fqk1oUmReaGkUtX25YZyuMzIHWZCOz8Nwwy41pxzj4RnJdvc/TZAj5ZY+G927908HQBed6Sf80UsWlN4be8zhjH5XIzaUs623KkN+JDozO9MMUKy0BA= Received: from CY5P221CA0087.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:9::30) by DM6PR12MB5517.namprd12.prod.outlook.com (2603:10b6:5:1be::8) 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 05:14:50 +0000 Received: from CY4PEPF0000EE36.namprd05.prod.outlook.com (2603:10b6:930:9:cafe::1c) by CY5P221CA0087.outlook.office365.com (2603:10b6:930:9::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.17 via Frontend Transport; Fri, 18 Aug 2023 05:14:49 +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 CY4PEPF0000EE36.mail.protection.outlook.com (10.167.242.42) 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 05:14:49 +0000 Received: from SITE-L-T34-2.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 00:14:48 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 05/12] ACPI: x86: s2idle: Catch multiple ACPI_TYPE_PACKAGE objects Date: Fri, 18 Aug 2023 00:13:12 -0500 Message-ID: <20230818051319.551-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE36:EE_|DM6PR12MB5517:EE_ X-MS-Office365-Filtering-Correlation-Id: 07476418-982a-4b66-37fe-08db9faa0c1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yW1C6qtRzBelK356F7gNX97+JkHQysLj2DUeUij7VUTIl6pBgpmw+yfHTjH7QMSGldfknwJqczWZ+jxVmmpdIvterS4kmqdtpjzdxH8lT+nb7eb5Rn6aYt5pAsuN/8aGQH09GJOJv7z3ab1PRIL5nKepiinZxljYgJm6449uLFeu3SD2iCJHZSZ4v6phr873FlLBSSihGzDlaKjyY/fN8HNGkA2n0KOV/z2JCp7AsIJrpMxY8zRUJIF5VRjK2bZzMo3hhbCQXCZkduWNJo+mON8U9ACDjmgindtB+/JDsCgqF2EJodAz+5NIs+I7jisyBxXih2X8MjzxugU/0b3q1365/MfzQD3i91ndUiuqYzSv7BS7k+jWgeM239OYwVnxQMUGjaPZUne+1q/1vpUFhffRivFfrRaKwPcaeGA6UxU16hAhEeihXeHj0+rWQF7tKjDpiigs7Jb5120fCmhD5y7nrzgijt8d1Aiqa7pUuSbWRCsCIz7W7sh8TIKx5+gmbw231rucLBUTN6+1Ny7T27bpYhFgkM+XYaYo3mBUHoZSlFKJP0LWXe+YKXUBjEg7b6fOoboYjx4SM3HK9Fq2IrPXJqyEcdXot4tXTOqTEDzwZqKBosVDQvc2hn/B8Pz5w7f71kHv8bwh4lHT2/q9bP3gyt/clR8vgWhCIrKKdu0pNfIFX+GMMywO8AryZrLvT74MFW0vTTeVipYkI75u7sJBZv9hGUkLfH9CMkZsirJLDqvTI/AE+xx5Rc3am3JFIeZe3YvNfvfrhgDErmduFg== 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)(39860400002)(346002)(376002)(136003)(1800799009)(82310400011)(451199024)(186009)(46966006)(36840700001)(40470700004)(40480700001)(40460700003)(316002)(70206006)(70586007)(54906003)(478600001)(110136005)(81166007)(356005)(82740400003)(44832011)(2906002)(4744005)(41300700001)(8936002)(8676002)(4326008)(5660300002)(1076003)(36860700001)(47076005)(426003)(7696005)(6666004)(16526019)(26005)(336012)(2616005)(86362001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:14:49.8421 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07476418-982a-4b66-37fe-08db9faa0c1a 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: CY4PEPF0000EE36.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5517 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 05:13:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357357 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 364A1C7115A for ; Fri, 18 Aug 2023 05:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356738AbjHRFPm (ORCPT ); Fri, 18 Aug 2023 01:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356143AbjHRFO4 (ORCPT ); Fri, 18 Aug 2023 01:14:56 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2080.outbound.protection.outlook.com [40.107.237.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E230D171C; Thu, 17 Aug 2023 22:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dOyIS5FIOr6ahxbISE6gvOYH3dPC/Ez3CmXo43ORYqc0p3qDHHgQeid4YkmumkAoqeqsX5sz7CVtu87jXrqna0XgOLqeAMXQmHd9uRfFhK4RwXoVcORJ940dJOZPddA23pJo0PFNgrTX+JM923lvE0MXzZdo+c9lOUw2mlYvAupcY+KzMzZqfg7zGasdGex60NtPEV9lejS5pZwgFQIhIeY3meAmgDuMnn5bAZQ0aG3MFbIHKgm/pNiMUQNlQuGrIXRzhr6POm+jbWPoCRDJD84ZYGF9YdBEOWPeOqDvwEdk0PDQ3Khyqn6gHNR0GaeH+Z4JMnqZsZVVMAqzFpDqgg== 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=hfa8Ra6yEBgCfoa/EhMbeCBWGGb2v8OE100QHtbfkidTemmiQN3C5n47YKhQ4cU3+DSQX5NqBZDc6VmfRrSBxzgaiHmMttGHF3dQGxZ9WcmikGTxSLZH+wzRBG6Lk55HPQB2puryZ/qixOVUeK56UgRHhz1lqVn/voFQ5tWaL+w1Ijs43XdvCEncpWim4koJd1LfuvblEr5yMfTnZTTI6QWErFXSNJkNTSfig4ZyMLEWPOsV/IoAVB2Z+/Dv5/iNiafy7p7wP/oeTDMW9iZOl8UDLfKLAdQYoGWUHOFfkfvhulbeK9MhcH+NatTx7HX1GkoORiu0P7jQZgp70G5sAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=p+Shp9k8KgOCOZb92uit+CqVpsSnMj99YMTycec6hgYRKb80zkJA+ljoos/8sAxNISiBxOL/OvHSTX/q+oWhNSgbYwwsoF/HjL5QOoZQxwCgyez7doRbriEw+n+9kOsfPXFYWdpYjDOL286b0S5x3MwnhPx8lCr2ipj4nhphZDM= Received: from DM6PR21CA0006.namprd21.prod.outlook.com (2603:10b6:5:174::16) by SN7PR12MB6692.namprd12.prod.outlook.com (2603:10b6:806:270::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Fri, 18 Aug 2023 05:14:51 +0000 Received: from CY4PEPF0000EE30.namprd05.prod.outlook.com (2603:10b6:5:174:cafe::1f) by DM6PR21CA0006.outlook.office365.com (2603:10b6:5:174::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.8 via Frontend Transport; Fri, 18 Aug 2023 05:14:50 +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 CY4PEPF0000EE30.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 18 Aug 2023 05:14:50 +0000 Received: from SITE-L-T34-2.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 00:14:49 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 06/12] ACPI: x86: s2idle: Fix a logic error parsing AMD constraints table Date: Fri, 18 Aug 2023 00:13:13 -0500 Message-ID: <20230818051319.551-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE30:EE_|SN7PR12MB6692:EE_ X-MS-Office365-Filtering-Correlation-Id: a870f430-5c8e-4395-1ee9-08db9faa0cb2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pi+bJWAI4E010eC2jeiEY+0yDnyp+qeoYINI6fpD5qc22zvamYvza6cBq6DK3IyFuV9pAWfTx4M+UuENKwaw7VC81fb9cfovcnmkDwSKBF/B898VwsVj71+z4J2odDchI0Z7+aZTg0a6f3SQEj7J2Fau5O0DO3ebBwRcyM5LgyQxovm51d8PlUW9QthYLrtAiOmjPObEgSMqx08NxtFfU2rQPdBRLugTpw6/3G8sVUxexmpeBVP7N52K2brL56xOweay23G4mMnCH3qJrLonSs1U1b5huXxm6GQ2eXHtgSOt61Eeixcogqd8ICdp7yDhkfFNXUKxWbkJWWsMu1jKZvRdk0YHzU1z1h5IIPfTQn9oeOY2HbKjFA7limAojqPAFfu4YBiJkDuNHqQSo2y1ke3B4MleVfHSCCxDzzQ52v2Y3wF2H1/sEF29WYHEVQvFdh7GkBDMsMRhuS1OwOw22zsOk5u2PhIP74OCyPJkQwvy9HzhwRkuGjCMa+6FSwv0554lSENcX0TbSZPdmbfqpeAWNqrmUAUnG0hUrjlVHxE03tHupaFbptbxr8WBVB9/2PvKonqcgBCvcEvYB/kVTlAxP0G3ivBaIOVrTZqZOw3BfzqxgPUhwJfu+Tfg4xVmGh5Iw/2s79nAjrlkRN9+QEzMb+V95k06+UO5T9kRAbTpfACfyauPE3cZiOx8iinht0fOfvtFrXqe06PMeA0eDh9ZglT1Wz6KS12dnLchRKz5qi4lmfDBje40aIwOS+xhBJDreArxRY11mtVR+J8zJg== 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)(376002)(346002)(39860400002)(396003)(186009)(451199024)(1800799009)(82310400011)(46966006)(40470700004)(36840700001)(2906002)(40460700003)(83380400001)(26005)(86362001)(336012)(40480700001)(478600001)(426003)(7696005)(6666004)(2616005)(1076003)(36756003)(16526019)(44832011)(5660300002)(36860700001)(41300700001)(70586007)(82740400003)(356005)(54906003)(70206006)(81166007)(316002)(110136005)(4326008)(8936002)(8676002)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:14:50.8220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a870f430-5c8e-4395-1ee9-08db9faa0cb2 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: CY4PEPF0000EE30.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6692 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 05:13:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357358 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 59DA4C7115C for ; Fri, 18 Aug 2023 05:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356752AbjHRFPo (ORCPT ); Fri, 18 Aug 2023 01:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354040AbjHRFPG (ORCPT ); Fri, 18 Aug 2023 01:15:06 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2081.outbound.protection.outlook.com [40.107.220.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5712710C8; Thu, 17 Aug 2023 22:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WUhzsMA7Elxcs3D9RlLL3+UmcXs3tA2mlgpSm97IS8qGFynk0ciqZwz18nIbpGcReQoKoZYQImPn936gfyBfohGZ5oGAJbWUlFckyHMqQpJznbz5hN+uA4/YQOeS0AsXNeN4w0podqfS5sYrd6DQEESZ+mkLC6I9K46M/3iqBIA/s0ClbLzlniBW31Yjyt2Sduugp+faxJL5p6WUsMGVrS9ijqColTLKJYM4evz1n9s4IqonwwxhsEctXHxR5EOywENuYhit5HC2YkyPjiDdv9U+rUa4DXgqwi6KCKJ1coMJuL3qnjQGzyt/04VRs9OQe4D/+eBcJHRZEeHvdmEquA== 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=ekGn2jGB2TSk3P+S80O0As5c3sbFGm8a1OGlYSvuxVbA7APkExhyVwZkf2/yX1pF+06Ys5Ox7lONVbla6rCxZhrDpxM9dLNatSvHiPIEaEJuQNf+1yYJkpoJzYqyjF3gw3hZALD+gseINy6sRSxIk4UI1ltHn+7Y1aG00o6IPtaBDOdHpfqP7DmqCedzwD1kxS4UHBKzzLGkfCk7hQ9D69WUBUyuUQKvlwFLXnRPuFFgRbEl7X/ypStBC+7t1hUnMbqeYxni9J26oTz4bvSI0q2EQ16ItU6GCjy3kLzzAUChocUJPf+pKnuyKhiCUswN0FFim3AaYA23vmw08rFLgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=usOJ8fdmhbe1ADLX3zEg5z6kl8oEI1Fd9oAn5/aVH/XkHcswxOQ8IxRvNsTC8ewhFlg3MCgMrG2ErSIr5LtVSudigER2miMYd9jD/jAnIg4MbmcUfldILQv5+BPNLSZSj1HWKPavGzRK+TWUWTvFN8O5CG8bUoj3n5+iISDwJj8= Received: from SN7PR04CA0062.namprd04.prod.outlook.com (2603:10b6:806:121::7) by MN2PR12MB4288.namprd12.prod.outlook.com (2603:10b6:208:1d2::22) 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 05:15:02 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:121:cafe::71) by SN7PR04CA0062.outlook.office365.com (2603:10b6:806:121::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.33 via Frontend Transport; Fri, 18 Aug 2023 05:15:02 +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 SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 18 Aug 2023 05:15:02 +0000 Received: from SITE-L-T34-2.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 00:14:50 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 07/12] ACPI: x86: s2idle: Add more debugging for AMD constraints parsing Date: Fri, 18 Aug 2023 00:13:14 -0500 Message-ID: <20230818051319.551-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636E:EE_|MN2PR12MB4288:EE_ X-MS-Office365-Filtering-Correlation-Id: 431d71e7-afbf-4b85-c747-08db9faa13c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IaUbiuZZGVTrPbbdHdwAME1gdHWcbhFM/Myz5jQqPH+VlTux4pavb1hNzIazFFDSuVyzVdLe0r1H4MvsChaMjoEMLYu5mAuphaPcwbZrIYmoz6uu1o1fuh45eC3S7rr7SUDIpI1lArkvPwG+W/PQVLCyjGU2CAJpiby1Umdvq6hd4EuPH/fQjkoRNPXcjmuYRfnAQnTpho/wd58x4vS0oKBtUkyVcDaw5LQuG5sA6EVc3hf1GBZXeWkfJEJF7qhc/8l6rVpOJQ6A/1ueMNvCN99aoImE5LB7fMvFfKYLEsZvCScp9hadsay8rb1wbPdexa8N8cehYpF4XL8arxwrszTSLtGrNruXI6ZOwqi7/ViPD7G/Z9wgF4HVUeeIXj7u800BqQlWrMOmwRD/kptEex6wJI8BrAWAdgJDw2sTxZlJ5/vMGsWNAltI1GI20hIP0HOXUuAiWQFRoWmrRnQLXFmYWDo482wvz6vOr83yHZCjPtAV+CvmywUB2y54w6wDq3Fe/2ZHuGulWS6+ipdRTp0t53CCdc965vsw7qwC1B9OiA1m8AnvrJihtlLYKuHHEqkBZ5AJ+f6+wFfLjKjNh2H/EV6PYp2Ih2Tynn7ZzIf3Rf6cFMWA6U+OjDw3uqwXoAewRGCBNabRBKW8BRMSX5F/uKy/XIaZIquQhX47IV7in7YOmNAwg8DyIod2LcXDeWoGyrsRajGIY6jKJMeYFYW6/a2yrXLWtjH6fIvCOkYp2Z2muPeEWjQy1VrLFdq55z7XLnWaxvFtY208g/eRZg== 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)(376002)(136003)(396003)(39860400002)(451199024)(1800799009)(82310400011)(186009)(40470700004)(36840700001)(46966006)(86362001)(36756003)(82740400003)(356005)(81166007)(40480700001)(2616005)(5660300002)(44832011)(110136005)(16526019)(70586007)(478600001)(70206006)(7696005)(6666004)(54906003)(316002)(26005)(1076003)(4326008)(8676002)(8936002)(41300700001)(40460700003)(47076005)(336012)(36860700001)(83380400001)(426003)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:15:02.7417 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 431d71e7-afbf-4b85-c747-08db9faa13c5 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: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4288 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 05:13:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357359 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 6A3E9C7115B for ; Fri, 18 Aug 2023 05:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352924AbjHRFPq (ORCPT ); Fri, 18 Aug 2023 01:15:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356473AbjHRFPH (ORCPT ); Fri, 18 Aug 2023 01:15:07 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2065.outbound.protection.outlook.com [40.107.93.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 464EE171C; Thu, 17 Aug 2023 22:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PZyojotYZ+qQmJS8o9zptmB+vgBqCaI44ojJtg1EwmbREke7jd8X5dOlLco6Om8CLhC33PsGTJGtmGBtuvJpPvr/R3hSD0z+r4Mzgoisk6bil/eGrvL+GuBPgy034w3tF3MKW24TF7XNdZ4Rb+G/K3ZhftKgQy5FUh9reAshVChfkdu5KBfJGffPFDrl3U1ZR4ECkf7P/vpwTRVvLY2RHPi70LZdG/V9NCGjSlqB7wseOOuk/ERm0VeB5KErXdgtX27rD4JgDshtwgCPlrWEX3+0fC5w3C2t4B3/enTkIFI23UdaHjCF4tYAlCiudd6bEgk5BLRjMY8mYsJ9LACNQQ== 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=M6ox5Wz2LcD6G4W2hJ7bKEe7q1sKXd6jW/n8JEJzO6ee9FNGmGaLqmH9gq4S4HTfL/FrdZnbUcjIcfahC++lrFG5Uj38oAO6bRPyE8EtYngoqOHZWoabet78LL7AAvYqPZcI/AxxRugv+M05ezxdtywy3/j7C288Q5rG7NVNGf4nahWr3nYBrmY86aLwU5P2JfvK+xt0OmKRmEhIBIgdyt6LjdA5yp07YqvkaGOE3eD4dlhsNL9r7b71nX6xpYOund3AnvHGt5xKqzJ1qAz6Gb+JTSN+i2wegMusSiflBD2xhaVywncu8G6JtWljiJigWSHefazu8cbpRgZ5IN7LHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=TXOBaP4fHeDIePqaGUzQT2YGWKvoBCgfgJrQhcz+x8jVUfkR4f/6QmxEQkq+CHB8Z2Obnagi/OhFS1h9XE7HZGcU5a9pgbTpUioSTEyuV0lS6p2oFjczC+f2PtV/9/iCZB8xq2hq6MHxolnEWyLOihKS1H+19gqFun/CvIoG6+o= Received: from SN7PR04CA0088.namprd04.prod.outlook.com (2603:10b6:806:121::33) by MN2PR12MB4224.namprd12.prod.outlook.com (2603:10b6:208:1dd::8) 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 05:15:03 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:121:cafe::6a) by SN7PR04CA0088.outlook.office365.com (2603:10b6:806:121::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.33 via Frontend Transport; Fri, 18 Aug 2023 05:15: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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 18 Aug 2023 05:15:03 +0000 Received: from SITE-L-T34-2.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 00:15:01 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 08/12] ACPI: x86: s2idle: Add for_each_lpi_constraint() helper Date: Fri, 18 Aug 2023 00:13:15 -0500 Message-ID: <20230818051319.551-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636E:EE_|MN2PR12MB4224:EE_ X-MS-Office365-Filtering-Correlation-Id: cce2a951-0c96-41d6-73d3-08db9faa1433 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jGZlO2lZUe6b5JW/mRb7WqoV3WkUoo2zggeqiccDbUbCuSUAjaeeGLsSt7075F1ddxQoSm0rlbQAVN6MGCHeXL3EXNW1Y4rbUEtvBk4nrp7tyyqUf7CvENFRvIeoYfBjv0UrQK+8RkPreSVb1RZ9i5czo0Z8rPdJa0IATVO2eSd8o4a7qw/s6lJgQtJ8Jho/Il2HiLsVIW8qzllN7uNuy8UNr16AmZ1W7Fxsn45E13tjHGW3zs1aJq4wdbALRxOMej5bb9f5Q4KS4s11EawBQ1yXw/hwbV9fg1FRo9XQ3niv7pfbMHmMtgdf/SX6ZCbh9+iFU4toW79rKjw36qapUBdqTB4C+XvOdQ5/vPQSdYdL1bs3amNffMXFjBRcVeDm1JCwCVGUhjaFacxgvFvD6QZwi5d9ySdkN8RH7VoBXdavuMwQs+E180/hwQp15TZSBRQHBac6MxEcszteXSAyR5v3ENZ6z/94FkltAGzcv+Ml7hD6k7XvoNYAK6fFJaRD5ZnJsa6osuIINSSbjVzv19r9H34h0/NhrKaEX79OLoBgds/Ntq+luFfSvjoSzKM93wDAk6bqGQ2UBYO9iGTZ6LAOcVadPbzkLd7nQqiWfC3uq7T2eKKTifFPO2b6Y7Lt8II5t/3FSIfx4Mnsh2AcozEuY16G6gCpqb3j36JyUMX3dkEKKFaLN4HrhThQixN/t0mUzAZ5FMcwfV2PLtSpab4cFeJyzGjCOFt5c8Vu4DvzjR19yf2FP0gaIE5i7DCXFaM9LkbGpB/lM0GPCee2ig== 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)(39860400002)(396003)(136003)(346002)(376002)(1800799009)(82310400011)(451199024)(186009)(40470700004)(46966006)(36840700001)(6666004)(40460700003)(7696005)(83380400001)(81166007)(16526019)(336012)(356005)(426003)(26005)(82740400003)(86362001)(36756003)(47076005)(36860700001)(40480700001)(2616005)(1076003)(41300700001)(2906002)(316002)(70586007)(70206006)(110136005)(54906003)(44832011)(5660300002)(8676002)(8936002)(4326008)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:15:03.4605 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cce2a951-0c96-41d6-73d3-08db9faa1433 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: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4224 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 05:13:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357361 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 AC4A1C77B73 for ; Fri, 18 Aug 2023 05:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356786AbjHRFPr (ORCPT ); Fri, 18 Aug 2023 01:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356493AbjHRFPJ (ORCPT ); Fri, 18 Aug 2023 01:15:09 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2057.outbound.protection.outlook.com [40.107.100.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4E8A26A8; Thu, 17 Aug 2023 22:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kYcRZVs40BQbuozWxFEij9XtUGzPQHnU+fZgChUK7XoyL2clgXV6Fpi2yWCI/ItNztqeB6S/hfoWCo1cISSsP3LmJexSPSP9f+ksrTqYxNJ5BfvpJHvaWn2N0trbDqmsRHoOa/q6mFVWIxw9/m6+d3HLrI0eZR4P0Nt45rHaFKBM23FAB/UMPCgaYC0jCCmQLK5VdIKVxCkfRTr32gXWnA8bOMS+RL3gCryZgHLaDQaaBlLz/3720NT9dTLipDcJwSFUUBan9BjDEQ+y4mLebTL37zD3v7yRlI9LIvVffHJp0ueHUGio+hRQSjLMk7FmOSXWBruRfdP3Nxzn17Qz/g== 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=0YuM/Sqk8U1Vs5QgWnHntvfb2qSkzjwojLanSNntx0w=; b=hqKjthu4/cSSz4OeL8tYXxmlI/Ri1kqGoynLM/OvHTYef7gtu8CpWfHsHydDzBrCuqdL411vxmbZyZ6P6nmlofVrCBjjWgJP2BfMYDjPv861kV4NxcU1DJkFyI2qS36+OXMyupaN7ZFkn6gI1y5YIpkLAqVeGHwF+5RBoYz4QCBNv3Y3VKuylcH+83o6YwZfpH0XL8VHvED88EPdAf/j2UxLWZpVO5NtJe8sU8eCkxEjJUJZ6vcYsBADZvBTl196xMXgYX8XMwc12gZHnx8h5hR31oMDXlNVQjVjS4xYTrC7UlmoMmzZsYJtPhLC7afp/8JFADGZJOOjOxefuMDL9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=0YuM/Sqk8U1Vs5QgWnHntvfb2qSkzjwojLanSNntx0w=; b=Xw7OTaY/7AxoL4prHydDTWCXGiiqf2eQHlOfWlnAmShnjiHZPwhCu5n9grdkWAsPLazr2w3mm6n+zAGj6Vqh+vdRvaR2MiLW+hcUVeelDVT1cdnYtJ/e0vfiHxvNNaPaY/ONMbQ9iuh/k6ATOF2zb8FyfkC96HJZhbqhonltu9I= Received: from SN7PR04CA0205.namprd04.prod.outlook.com (2603:10b6:806:126::30) by BN9PR12MB5354.namprd12.prod.outlook.com (2603:10b6:408:103::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 05:15:05 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:126:cafe::dd) by SN7PR04CA0205.outlook.office365.com (2603:10b6:806:126::30) 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 05:15: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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) 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 05:15:05 +0000 Received: from SITE-L-T34-2.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 00:15:03 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 09/12] ACPI: x86: s2idle: Add a function to get constraints for a device Date: Fri, 18 Aug 2023 00:13:16 -0500 Message-ID: <20230818051319.551-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|BN9PR12MB5354:EE_ X-MS-Office365-Filtering-Correlation-Id: 69c28048-0627-404d-4363-08db9faa1543 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l204H1twffMidFE659CcoPdMvwlJ+OyjFFg2atIWnCtP1LZxH+wm93u8Vr/NwPvz1c8bxKw/096pQiwXsgMa+V70jytwwzhDMykuUjhLN75ofHAjIE3+2NbTQk1KYNtO3EHUR95tJy3SmpsZsTu2jAqbEMfMmwrDlsuNSS6Y6YvqPQcFgrhfWwuwlAKgfR5unqGpDcdp7M5JZvUTMnXFafK9oGHnOrYKLL6t9RLAhWVWaUrAVkBtbQF8OltG3AnCMntfbRfpKDsGD4ujPYY8KOH5kw6zPATtqVKwLcaLp/U13Q3BHs3srLODmhGPfsT2P/RwT5Jff6OGLKlN/dIfATuQ/0/ubs3LGeixczOCH8swYy+gKIA8ej93O8nf7KkBVjatODeJHw1dI0G1TRc1JcPFJf4EHGkvSkrY2BICKte9c5H6teFIx/dcPKjswKb06TBUiu/Gtq5T4RxHRvkAyRSCKC4RUItm3yFGg/Ltd4vGMWdNjYTYxkkusZ5tWIqmr0qWreDb6vV6zhU007LJiFHQl3bM7hCUORt0RzS/pgj675Go1nfcoRyslOy/ZlI0NslX0WMnWgnIdnsf2x/XW54QBUvm7PesSotgdbZJQKt94Z7wxwlQAyzS8yiouFzha5bo/y+WOY3IZ7t67o5FYMglbEhxmPE37Cyn838xGwMFRSmB0Z1Vjc3J2RWdpCVNkzTOCQwC/KEQzs8dgZ+cDDJjr1Qcpp96PscSXK9ZCXexUe40H95U0DHKQwl3n1Vnt2NWboSnVsME4+ug9MYaVg== 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)(136003)(39860400002)(376002)(396003)(186009)(1800799009)(82310400011)(451199024)(36840700001)(46966006)(40470700004)(6666004)(7696005)(40460700003)(86362001)(16526019)(336012)(426003)(1076003)(26005)(40480700001)(83380400001)(36756003)(36860700001)(47076005)(81166007)(82740400003)(356005)(2616005)(2906002)(54906003)(316002)(41300700001)(70206006)(70586007)(110136005)(44832011)(5660300002)(8676002)(4326008)(8936002)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:15:05.2418 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69c28048-0627-404d-4363-08db9faa1543 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5354 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 --- 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 | 24 ++++++++++++++++++++++++ include/linux/acpi.h | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index 1aa3cd5677bd8..dd961f3a60577 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -299,6 +299,30 @@ static void lpi_device_get_constraints(void) ACPI_FREE(out_obj); } +/** + * acpi_get_lps0_constraint - get any LPS0 constraint for a device + * @dev: device to get constraints for + * + * Returns: + * - the value for constraint. + * - Otherwise, -ENODEV. + */ +int acpi_get_lps0_constraint(struct device *dev) +{ + struct lpi_constraints *entry; + + for_each_lpi_constraint(entry) { + if (!device_match_acpi_handle(dev, entry->handle)) + continue; + acpi_handle_debug(entry->handle, + "ACPI device constraint: %d\n", entry->min_dstate); + return entry->min_dstate; + } + dev_dbg(dev, "No ACPI device constraint specified\n"); + + return -ENODEV; +} + static void lpi_check_constraints(void) { struct lpi_constraints *entry; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index f1552c04a2856..6745535444c76 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 device *dev); +#else /* CONFIG_SUSPEND && CONFIG_X86 */ +static inline int acpi_get_lps0_constraint(struct device *dev) +{ + return -ENODEV; +} #endif /* CONFIG_SUSPEND && CONFIG_X86 */ #ifndef CONFIG_IA64 void arch_reserve_mem_area(acpi_physical_address addr, size_t size); From patchwork Fri Aug 18 05:13:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357362 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 1C0E8C7EE2E for ; Fri, 18 Aug 2023 05:16:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356858AbjHRFPy (ORCPT ); Fri, 18 Aug 2023 01:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356531AbjHRFPX (ORCPT ); Fri, 18 Aug 2023 01:15:23 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2085.outbound.protection.outlook.com [40.107.237.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38ED2171C; Thu, 17 Aug 2023 22:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bFM2lKq+eYovLZxKCMioy2+K9/r5Y7AbZwtP23aSTwpzp9KqcoGhHLaLg5AvdJBqvA0/PkJd1JsZ1IBQmsU4FTNvtxM+kAO0GsgNSSmCFCHTMGjbLoaBPskaAmkfmrYO0YhvnFsqk4A462AS3nQgN6Kk3eeDafuQJJNJx76g1XDkMX6//r5a9aujfcm4VOzW2qKPu1VRb2JXn8iOmHGpsML0ngtbUoVcL5nLmDrhzLoNuWUiDthsmsDhfIAhVHz9+LFEd2rmZPR7P3U0Y8ALgfCaH+vrc6mUEgGhQqYIwyG5v831YlTgBehbB5i4Eza7aax2Tfdxw6sZqZqp4irBkw== 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=p8t9dWr3SYEGcReSvoWYqCJ1XUDQSml1FxGQjktYRqU=; b=eUMa2BEvCKK3N3rhTkig5SCJOr9UwLYz7uy3CkKnjDylWTehChKQ2rJY2j3eW3nqzKYe1oVJEP4gQZjB2Pi7ZposoZbFsT087hfMfGTZHrGqHxVza4ZCmx9t87sRw1eD5A/kVe3gUR4doDUDCvw5J8XF3geLbmlUn7q8gfoEgPCtC/2N6RjSLCSYnYOepZCFGP0UMOWY2YCaTkt7nRUF9LHEZX9fVN+4JYBzoilL+v66YlDFEvPYyQtyo+zrBNFy66XF4jHfnqKzlzxD7HJt3tuAAM94EOhn4/Boj4uRzMDx1Z71DDcVMGvxCvCxHNcYtVCvpN6vucT5AoBxp9QZpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=p8t9dWr3SYEGcReSvoWYqCJ1XUDQSml1FxGQjktYRqU=; b=2YdYBYTB38EjdRFCLoR/R+29AnbvQxfOvDIjV4BMBwcOZZBlz5LMwig89OqzKy7PZrB4EzuRS0iAWuYo6346JjZeLRjzdNfkjOlo9/eQOLoSQzkJEIJ2oJJ2AFBk77Ty1PyuNdMf08lEDhou7LkyHAaqJ/rNjgSOP24fGuCvMzQ= Received: from SN7PR04CA0195.namprd04.prod.outlook.com (2603:10b6:806:126::20) by CH0PR12MB5385.namprd12.prod.outlook.com (2603:10b6:610:d4::14) 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 05:15:08 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:126:cafe::c) by SN7PR04CA0195.outlook.office365.com (2603:10b6:806:126::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.17 via Frontend Transport; Fri, 18 Aug 2023 05:15:07 +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 SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) 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 05:15:07 +0000 Received: from SITE-L-T34-2.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 00:15:04 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 10/12] PCI: ACPI: Add helper functions for converting ACPI <->PCI states Date: Fri, 18 Aug 2023 00:13:17 -0500 Message-ID: <20230818051319.551-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|CH0PR12MB5385:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d003abc-7830-48d6-a769-08db9faa16cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PbSi6u2RVLgUPs5dbR+6mJ+DkAXfnywjmcEwmNGLhELH5V5Fs67YPINOK/hcUIXCXzXn4MnmNZUXI6qTEr8qMuLKnUEeTsU1OarQJpQ5DZIwebPaz9QVNsJL+yYtYBGebwoc4SSHW7LhCXObO1ECZbSF87D4XaWIv6mOtUN7b4FPEoQXxmuoNwgwRBJWW2GxCqS0VU63XFgpBt0T/+ODn1+J07/4yUJEz3bvTuMj+zK156oc0eWP/K73VyhFr+hVJCWPyJ0FRGtUUDmYnk1a7SFfQwKdpPCh6ZYtElqXISEbR4bVnfCIo1hH//h47ob5d6+ZXYS16DASvbc4SwrjNk9Vos2ZQM6pmSuqEyqs3c9BjkXPeita+XTCd7eKTST4T2Pyt+ugToxFj2xPjazICZ5hVGLU9sat3uA//rO0U+4xEyMwiA12JADcdw/eAYjfyUdi/g8rzvAngtAXuZ3GAt+PQLvJI8+asq/KXQYkKcUS7KgIotCl0gCZAcX3jnzM0XLT9gpGBQQAnEk4FaI2cs6ZXC7zsx+lGhDCK5KE0u0Kv/3mam1V63RdwvbH1PEcnJCMEbgDINlMH4sN5mtbF8k56HV/mpkCGc3ttOWvlIs7RIU3I98x8rPqgsm9+r/Vdm8b62WwlG0/8DCeytoJvFwtkmZFXjZBZqUHw5Y0BdQWbu4HikpBXx97Q7yhC/s3ieFCJjUEHfxxvLQ6voeCT65kPr/rcKksZ20Bm6uEZkdpCE1hDTN+KoQk1nHBRZNc0Ihi0BK6dwkYgjV7Q/ztJA== 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)(39860400002)(396003)(136003)(346002)(376002)(451199024)(1800799009)(82310400011)(186009)(46966006)(40470700004)(36840700001)(40480700001)(83380400001)(40460700003)(70206006)(70586007)(316002)(54906003)(478600001)(110136005)(81166007)(356005)(82740400003)(44832011)(2906002)(41300700001)(8676002)(4326008)(5660300002)(8936002)(36860700001)(426003)(2616005)(47076005)(7696005)(6666004)(1076003)(26005)(336012)(16526019)(86362001)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:15:07.8199 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d003abc-7830-48d6-a769-08db9faa16cc 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5385 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Several functions do internal mappings in either direction. Add helpers for this functionality. No intended functional changes. Signed-off-by: Mario Limonciello --- v10->v11: * New patch --- drivers/pci/pci-acpi.c | 87 +++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index a05350a4e49cb..b5b65cdfa3b8b 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -884,6 +884,56 @@ acpi_status pci_acpi_add_pm_notifier(struct acpi_device *dev, return acpi_add_pm_notifier(dev, &pci_dev->dev, pci_acpi_wake_dev); } +/** + * map_pci_to_acpi - map a PCI power state to an ACPI D-state + * @state: PCI power state to map + * + * Returns: Corresponding ACPI D-state, otherwise ACPI_STATE_UNKNOWN + */ +static u8 map_pci_to_acpi(pci_power_t state) +{ + switch (state) { + case PCI_D0: + return ACPI_STATE_D0; + case PCI_D1: + return ACPI_STATE_D1; + case PCI_D2: + return ACPI_STATE_D2; + case PCI_D3hot: + return ACPI_STATE_D3_HOT; + case PCI_D3cold: + return ACPI_STATE_D3_COLD; + } + + return ACPI_STATE_UNKNOWN; +} + +/** + * map_acpi_to_pci - map an ACPI D-state to a PCI power state + * @state: ACPI D-state to map + * + * Returns: Corresponding PCI power state, otherwise PCI_POWER_ERROR. + */ +static pci_power_t map_acpi_to_pci(int state) +{ + switch (state) { + case ACPI_STATE_D0: + return PCI_D0; + case ACPI_STATE_D1: + return PCI_D1; + case ACPI_STATE_D2: + return PCI_D2; + case ACPI_STATE_D3_HOT: + return PCI_D3hot; + case ACPI_STATE_D3_COLD: + return PCI_D3cold; + case ACPI_STATE_UNKNOWN: + return PCI_UNKNOWN; + } + + return PCI_POWER_ERROR; +} + /* * _SxD returns the D-state with the highest power * (lowest D-state number) supported in the S-state "x". @@ -919,19 +969,7 @@ pci_power_t acpi_pci_choose_state(struct pci_dev *pdev) if (acpi_state < 0) return PCI_POWER_ERROR; - switch (acpi_state) { - case ACPI_STATE_D0: - return PCI_D0; - case ACPI_STATE_D1: - return PCI_D1; - case ACPI_STATE_D2: - return PCI_D2; - case ACPI_STATE_D3_HOT: - return PCI_D3hot; - case ACPI_STATE_D3_COLD: - return PCI_D3cold; - } - return PCI_POWER_ERROR; + return map_acpi_to_pci(acpi_state); } static struct acpi_device *acpi_pci_find_companion(struct device *dev); @@ -1056,13 +1094,6 @@ static void acpi_pci_config_space_access(struct pci_dev *dev, bool enable) int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) { struct acpi_device *adev = ACPI_COMPANION(&dev->dev); - static const u8 state_conv[] = { - [PCI_D0] = ACPI_STATE_D0, - [PCI_D1] = ACPI_STATE_D1, - [PCI_D2] = ACPI_STATE_D2, - [PCI_D3hot] = ACPI_STATE_D3_HOT, - [PCI_D3cold] = ACPI_STATE_D3_COLD, - }; int error; /* If the ACPI device has _EJ0, ignore the device */ @@ -1089,7 +1120,7 @@ int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) acpi_pci_config_space_access(dev, false); } - error = acpi_device_set_power(adev, state_conv[state]); + error = acpi_device_set_power(adev, map_pci_to_acpi(state)); if (error) return error; @@ -1111,23 +1142,11 @@ int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) pci_power_t acpi_pci_get_power_state(struct pci_dev *dev) { struct acpi_device *adev = ACPI_COMPANION(&dev->dev); - static const pci_power_t state_conv[] = { - [ACPI_STATE_D0] = PCI_D0, - [ACPI_STATE_D1] = PCI_D1, - [ACPI_STATE_D2] = PCI_D2, - [ACPI_STATE_D3_HOT] = PCI_D3hot, - [ACPI_STATE_D3_COLD] = PCI_D3cold, - }; - int state; if (!adev || !acpi_device_power_manageable(adev)) return PCI_UNKNOWN; - state = adev->power.state; - if (state == ACPI_STATE_UNKNOWN) - return PCI_UNKNOWN; - - return state_conv[state]; + return map_acpi_to_pci(adev->power.state); } void acpi_pci_refresh_power_state(struct pci_dev *dev) From patchwork Fri Aug 18 05:13:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357363 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 CCE53C77B7F for ; Fri, 18 Aug 2023 05:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356102AbjHRFPu (ORCPT ); Fri, 18 Aug 2023 01:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356521AbjHRFPX (ORCPT ); Fri, 18 Aug 2023 01:15:23 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFDED26A8; Thu, 17 Aug 2023 22:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fLQ7ed/+00mE+7yMQAXAwTOmM3HSt+L0/q+apUkPQnZDMCE0Rhj/AoPCeRDeHmD7kUmWtbMoRJIXH7UpQE8VeFqCvQeroelO9rS6AwMXmscL+SpAEafP89LLFBYRRMu6nTvV1RlBXJatSci54be+8su5Ozbw5sFvaUZqc6A2AjtDEZCBPj3byWFZciEyjfGSSDK2KHPULv1KBhWfRmOs1ve5PC3RxeL4DYG8bWXw7A5B8I8G7OXrx25CPXWFtlus94peOPtqh7YHa7zJBvOOlCrknVeTbwfTQhtCp+sJWNg2TDSrzaOSHF9dqs6nSUJP+vO6kKLpGtcbyed22BGtCg== 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=4/GLBpTALHfSqTaJk2XKOp4/BksOjAi5Q1lEo7YK8fw=; b=Qt1N2qjcQWW4+fcEXKHq9fGg7WwhLwkw3+gVGaPpPKgn6DdGOddKxAUGmh62tOpzcvfhC3TVqRDZglj96ccGZeeEeR9t0IVHex2yZtXcQCPXS1LED7yuqia9qnBgUFOhp+/NF5gmf5lJG29Oq4e9lvV4QlJUO4R1Ptr4R2J4aveHs2qkYMXfUa0s1vn69j9qqUOZ0A3H3AF9uN9PJAF8JX4PYdvm67/K3dD1x79J4cRN4s1tuq2ZG0y4SMoBAYU/Br51/NKQljMWUFDV2L2E32WeiIVvdsfwJHOCg2He0q90CTLBK8ArvxAplMDKUEargDolgt3/A+4xChI+zarFVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=4/GLBpTALHfSqTaJk2XKOp4/BksOjAi5Q1lEo7YK8fw=; b=QMdR7UtsS9SkEuYWerrBs9Er0gph2R8TNS9seFkylWXWiHR1ossAvJCc3HErvhTLXC+NZwJ2mrDqJMnA+CWh5qxLtPCJ8kQrtBB5WfVBvuOnr1TgDdTSpxIe5S6pPj7Vna2fM9BFlDeu44EExE3FEGZB7JPPzJ50nfD644nxnyE= Received: from SN7PR04CA0206.namprd04.prod.outlook.com (2603:10b6:806:126::31) by SJ0PR12MB6712.namprd12.prod.outlook.com (2603:10b6:a03:44e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.26; Fri, 18 Aug 2023 05:15:08 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:126:cafe::51) by SN7PR04CA0206.outlook.office365.com (2603:10b6:806:126::31) 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 05:15:08 +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 SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) 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 05:15:08 +0000 Received: from SITE-L-T34-2.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 00:15:06 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 11/12] PCI: ACPI: Use device constraints to opt devices into D3 support Date: Fri, 18 Aug 2023 00:13:18 -0500 Message-ID: <20230818051319.551-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|SJ0PR12MB6712:EE_ X-MS-Office365-Filtering-Correlation-Id: c3d6738d-c21b-47c6-059f-08db9faa172c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kRVwmhQLwmUE9PkHdyQdvA4DVZ1OzCosKlYZWaLHUhzGaLqF0K4dpoC5tpaVYNqsWY/cncPqCZe942Qo7lNrcIkNbwuEVzNWYl7tZppMOgyuRcRfgV4TUFJrCeQa2Rmq1w3r4GXnYmy49I4hc8/5BYWqJSk4ScwAHwDSd66P13yX0p+KgKvDhmpsLzOb3pyVSsYocSG51Yao01VUT8eVGJVJLmC3ByyI9wPo/ilk89HHYHdzRXKKXzX3lP5CZR484TddiSoF4MzdFQetPvtaxXLs5scHTCPIlWf4rnR7zm18ro6YHgiCttBHLt41Px5dUEGv8CGe5uYQQ4DDVEbxrCpcoB8Fp3nBjHw3rQcBOpAVI+9pBkXl8PDRTOeQDS7GYFyv8BRlBdsLvBE2W46TKKxmCaYFwkDm5PPodkJic1K2XCq2p4VXnzzi8Ku9dR6cl3f4iHfaKphZEw8gBJA1jgvkeHRhMR64pAGrsSbf5o0Z0RfhQ00UzsX+fsrbvcOlwvDyOvoX/nNFzee9JLFHYo1zfS+0G9xZLOkZTlQVbTMuqrBpwjuWKds0A1vnVg/N2izkMRXuJAvUJ95ZQX3Mtuve6pgSne3vMoej+AzI3pu7wNug4INr025Lqvb/rvQWlrs88A4drCiT031zkvvadJNSC3Wyp5aLg9MBZHMe7iMEs+hpqaaXfzVIzs1ppYWlTalE7bgcXnhhQkfcXV0wbcsDKBk8nL8WrwDGVKtbKkD+bOqMVd6v35fMw4ojF6d5Eoh1xqNf6zylRWjxN+m7CW1k2S9ob5+ShCpVYLByIfY= 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)(376002)(346002)(39860400002)(396003)(186009)(451199024)(1800799009)(82310400011)(46966006)(40470700004)(36840700001)(2906002)(40460700003)(83380400001)(26005)(86362001)(336012)(40480700001)(478600001)(426003)(7696005)(6666004)(2616005)(1076003)(36756003)(16526019)(966005)(44832011)(5660300002)(36860700001)(41300700001)(70586007)(82740400003)(356005)(54906003)(70206006)(81166007)(316002)(110136005)(4326008)(8936002)(8676002)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:15:08.4449 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3d6738d-c21b-47c6-059f-08db9faa172c 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6712 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In Windows, systems that support Modern Standby specify hardware pre-conditions for the SoC to be able to achieve the lowest power state by using 'device constraints' in a SOC specific "Power Engine Plugin" (PEP) [1] [2]. Device constraints are specified in the return value for a _DSM of a PNP0D80 device, and Linux enumerates the constraints during probing. In cases that the existing logic for pci_bridge_d3_possible() may not enable D3 support query for any constraints specified by the device. If the constraints specify D3 support, then use D3 for the PCI device. Link: https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/platform-design-for-modern-standby#low-power-core-silicon-cpu-soc-dram [1] Link: https://uefi.org/sites/default/files/resources/Intel_ACPI_Low_Power_S0_Idle.pdf [2] Signed-off-by: Mario Limonciello --- v12->v13: * Move back to PCI code * Trim commit message v11->v12: * Adjust for dropped patch 8/9 from v11. * Update comment v10->v11: * Fix kernel kernel build robot errors and various sparse warnings related to new handling of pci_power_t. * Use the new helpers introduced in previous patches --- drivers/pci/pci-acpi.c | 14 ++++++++++++++ drivers/pci/pci.c | 12 ++++++++++++ drivers/pci/pci.h | 5 +++++ 3 files changed, 31 insertions(+) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index b5b65cdfa3b8b..bcc76e9d399c5 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1081,6 +1081,20 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev) return false; } +/** + * acpi_pci_check_d3_constraint - Check if device specifies a D3 platform constraint + * @dev: PCI device to check + * + * This function checks if the platform specifies that a given PCI device should + * be put into D3 to satisfy a low power platform constraint + * + * Returns: TRUE if constraint for D3hot or deeper, FALSE otherwise. + */ +bool acpi_pci_check_d3_constraint(struct pci_dev *dev) +{ + return acpi_get_lps0_constraint(&dev->dev) >= ACPI_STATE_D3_HOT; +} + static void acpi_pci_config_space_access(struct pci_dev *dev, bool enable) { int val = enable ? ACPI_REG_CONNECT : ACPI_REG_DISCONNECT; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 051e88ee64c63..0fc8d35154f97 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1082,6 +1082,14 @@ static inline bool platform_pci_bridge_d3(struct pci_dev *dev) return acpi_pci_bridge_d3(dev); } +static inline bool platform_check_d3_constraint(struct pci_dev *dev) +{ + if (pci_use_mid_pm()) + return false; + + return acpi_pci_check_d3_constraint(dev); +} + /** * pci_update_current_state - Read power state of given device and cache it * @dev: PCI device to handle. @@ -3036,6 +3044,10 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) if (dmi_check_system(bridge_d3_blacklist)) return false; + /* the platform specifies in LPS0 constraints to use D3 */ + if (platform_check_d3_constraint(bridge)) + return true; + /* * It is safe to put Intel PCIe ports from 2015 or newer * to D3. diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index a4c3974340576..ac06c781a9b7c 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -707,6 +707,7 @@ void pci_set_acpi_fwnode(struct pci_dev *dev); int pci_dev_acpi_reset(struct pci_dev *dev, bool probe); bool acpi_pci_power_manageable(struct pci_dev *dev); bool acpi_pci_bridge_d3(struct pci_dev *dev); +bool acpi_pci_check_d3_constraint(struct pci_dev *dev); int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state); pci_power_t acpi_pci_get_power_state(struct pci_dev *dev); void acpi_pci_refresh_power_state(struct pci_dev *dev); @@ -731,6 +732,10 @@ static inline bool acpi_pci_bridge_d3(struct pci_dev *dev) { return false; } +static inline bool acpi_pci_check_d3_constraint(struct pci_dev *dev) +{ + return false; +} static inline int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) { return -ENODEV; From patchwork Fri Aug 18 05:13:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13357360 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 DD3B1C7EE2A for ; Fri, 18 Aug 2023 05:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356843AbjHRFPx (ORCPT ); Fri, 18 Aug 2023 01:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356508AbjHRFPX (ORCPT ); Fri, 18 Aug 2023 01:15:23 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2082.outbound.protection.outlook.com [40.107.101.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7A2726B6; Thu, 17 Aug 2023 22:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ImAx0XHXweq9cxFzwr/38kpHevq4xVbdblWlY4eY2lhnY2sDEAz4tGzvAfm2khQQ3T9sOhJRQi9BFnJgDUTNr68d5VDjZ+UwGMiEa9iiBMm43FduywxkE2O1CM0zrSpljhw6G5VNyLzZwweXhYWoequMkiJRKBC3T30MAgx9d9jU1yU2OzZGRiLXuA9kc91UDpJzTTKAyRsowJYIdrPrt2cb49oavd0WbKH2+Ysdz7t2rkf7KhLru06yNwzz5bF0Q2k5m9/6R5P7yD7RuiBJWX2faRElZyU7LMtnl26bCJMzufFSMA+xaO9r3UwniolV5405wrzXnfHUJ0+x4uYgSg== 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=6mdpErebdeUHIqJqXzE4h8gfzDj6nsgjdNisiSYee2M=; b=ItxB9DbmieBzS/7lNZlfGpiJX8M0gRkXW3OCM8IEYyv9712WUdsgzYFXOIdP9eN/YCwNEHs+cW33uG7/ZjlUplzGkQJxySuEk4lTVuDWNRYwfAc6x+BvmrC3jdhPzYUUuD5cv02CgCgulcbMh9P68N3YO/GpqFvzgVaDfLxvtbkcoJp42nNEvq/3qBdZCgT0rnKF/Uq1TOH62UVTT/X0YOJRHsH4LDbik+7xdAAxGcAPWK2dcNG5pRjPhUXCwlocEAO/ZNqAcCARTz0BDKJzKeB6IGAyyx59mjfXVR7TmxdHRtWxDtLpK1oiuHFhgP8js7+pznfusD6nNVWWZryvpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=6mdpErebdeUHIqJqXzE4h8gfzDj6nsgjdNisiSYee2M=; b=xbgoxgWZBlHK0lcc1p9FE4WFjfIsfJPZ9RAxb9lVoVkn3Z0p1TLa5Sw6sxksrmH7D7PZGNU7wY054xMGHMB91T6SKTG3gtT0slq5lHvS7XmInRjrxv4EstoGgVFlUicONWVrFvLixJMSQXd2g6oKHn6tPXPPhv4Tk4OC/m4q7BM= Received: from SN7PR04CA0194.namprd04.prod.outlook.com (2603:10b6:806:126::19) by SA1PR12MB7367.namprd12.prod.outlook.com (2603:10b6:806:2b5::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 05:15:09 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:126:cafe::7c) by SN7PR04CA0194.outlook.office365.com (2603:10b6:806:126::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.17 via Frontend Transport; Fri, 18 Aug 2023 05:15:09 +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 SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) 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 05:15:09 +0000 Received: from SITE-L-T34-2.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 00:15:07 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Mika Westerberg , Bjorn Helgaas CC: , , "Andy Shevchenko" , , Kuppuswamy Sathyanarayanan , "Iain Lane" , Shyam-sundar S-k , Mario Limonciello Subject: [PATCH v13 12/12] PCI: ACPI: Limit the Intel specific opt-in to D3 to 2024 Date: Fri, 18 Aug 2023 00:13:19 -0500 Message-ID: <20230818051319.551-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818051319.551-1-mario.limonciello@amd.com> References: <20230818051319.551-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|SA1PR12MB7367:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e262cff-f303-4be1-12d1-08db9faa17bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6GYZafMXTYjq2f0Gk9HfJWdLzCfZARHLscM/nu4D4J3PWWnsoVnp58mO2bQ/j7OM1mkFrUDJpLlLKNjOtnfnpIt5a21ir+eaRraBUOJ+Es0qA234tjXwEudwU7+r0VprHgE5H1igKGM6BcsGlWxu3BnYYc1Z/IMrhhXlOWmyBayBmz+9/+YdvBLPWY15X1dvi0DJJcWqPtiTKMlQpWyzzZaAmR8WcNfXudiFSwfZFQgQs/wvn7dWy9shcP/GuGLZ8V6+I4fJPXEiZo/b10cd5awMVDhJAAPkVEs8to7DCo6ztBi0zFaHN7ZXE9AgyCXXpXXvxMhqfF32JRVvVwZx9sS7KnNSnAVUcjdD/veUuncqJAWzn+Z44hL88+f0r9wbD5g4vXAJAKx9oFwXEVTwHHXwXe3paLPX9HSfYNkTDRLgDUxnntuLh3yzkFa7fdn4wsBd+0KlsM8DSVKzg1WlW1UjWjlefEn3kcuioOv5BDG2aznOfbQUXL2ABKpn4eWprJ0MddfV8aOAJQgcPP1drg++5eRhHMn5BPkYw8uKwi+52vWdakQKw0FVATWmrMw86KNKRHF55tlxO3vNTcwSHEMXpzIonGfI0zGvriJYl5s2yiMt9zzSTAytx/G25XaomgNLsNT6voLuyM3gTo1hTUARG0lqcKePQDvBmb811KXNJMYi/oeqFaouhe4k+fEBWU0w5XMg8Mcf2IRZtZVnKIGiQkiFVTT0oxysp73TeluUZX0Ewaz6xPCdDDNw146by7BPCwc4RVlqC6oqoFG77Q== 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)(376002)(136003)(396003)(39860400002)(451199024)(1800799009)(82310400011)(186009)(40470700004)(36840700001)(46966006)(86362001)(36756003)(82740400003)(356005)(81166007)(40480700001)(2616005)(5660300002)(44832011)(110136005)(16526019)(70586007)(478600001)(70206006)(7696005)(6666004)(54906003)(316002)(26005)(1076003)(4326008)(8676002)(8936002)(41300700001)(40460700003)(47076005)(336012)(36860700001)(83380400001)(426003)(4744005)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2023 05:15:09.3668 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e262cff-f303-4be1-12d1-08db9faa17bb 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7367 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Intel systems that need to have PCIe ports in D3 for low power idle specify this by constraints on the ACPI PNP0D80 device. As this information is queried, limit the DMI BIOS year check to stop at 2024. This will allow future systems to rely on the constraints check to set up policy like non-Intel systems do. Signed-off-by: Mario Limonciello --- v12->v13: * New patch --- drivers/pci/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 0fc8d35154f97..5b9e11e254f34 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3049,10 +3049,11 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) return true; /* - * It is safe to put Intel PCIe ports from 2015 or newer + * It is safe to put Intel PCIe ports from 2015 to 2024 * to D3. */ if (bridge->vendor == PCI_VENDOR_ID_INTEL && + dmi_get_bios_year() <= 2024 && dmi_get_bios_year() >= 2015) return true; break;