From patchwork Wed May 24 19:07:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 98663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp138153vqr; Wed, 24 May 2023 12:37:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6I6avisj8UV3clBjSz4TrllpmGai7dcfsTncaDEYgNXEL7EBu3d7pG3NrGUSNvTWOdIIVV X-Received: by 2002:a05:6a00:194d:b0:648:a518:4ac6 with SMTP id s13-20020a056a00194d00b00648a5184ac6mr458970pfk.14.1684957067397; Wed, 24 May 2023 12:37:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684957067; cv=pass; d=google.com; s=arc-20160816; b=mB64R9eNh+XvyVykYAgZ8qyylKFWprWzAmd2uwlIP7/n9uB25cReYbvXenDoV3n6au IFA4HzEnva1wiOmiw7LEV6FfOJlbMvR45mWNhQX0EfBBNC4xEwmVW+DX3kclnQs+sxGl erTelAaUGeufTvTA7vCNaZ2ndHek1QncdhhpVWobNvP1vWJ/DcGNmVTXwdBWXmtRHe39 rr5KnB3JsHtpWteemkbociKIUCcyt6Ym7NhYrBUzaQTEmp9OE9tDQPaqiEnhcsXEYhpk Xx9pAY2jTjbSnKbsCwa5nmebVegxbVnKJWknVx6wo8GOhBb+eUAqP/morusbTSO7XeQ0 hsLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=oSYWzcp8wMhvhiUJASaUrK3knaPwcQTaxUWCltf0ZYQ=; b=JqYpdeQ80jxJJvtxKSC+UtF8SykR2cJWIu1m9WqK59I+ZT10mDz35DwsmiCKSODTon alSPZBG8J3Tp5oKxkIG6J8F6DYdP+O7gDBvA4NuGOTCRMVTSH+czao33GXTAMTTf+/21 p4AQxDaELpEajvCVg1KZIno73N2le9U5Dh5W3GRP+37VMZDUQ9Vn9MBL1bx+mSrhqxOF qka/h1Z5pxK4gKox58tAe60KRgwIGOfhmyKq26YdInlutzFLKnCN7jAZK2SSV+8Jw0u+ OdcTXg80iA7JPjqssDLU7M2hN5Q/wsdeIEfrK3C7paymew6J/UsgjZ3wpkJyR0NjEM3e xEcg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=HhaJ1Ggf; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z188-20020a6333c5000000b0050e60e36393si3228380pgz.776.2023.05.24.12.37.35; Wed, 24 May 2023 12:37:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=HhaJ1Ggf; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232878AbjEXTH5 (ORCPT + 99 others); Wed, 24 May 2023 15:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbjEXTHw (ORCPT ); Wed, 24 May 2023 15:07:52 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2043.outbound.protection.outlook.com [40.107.94.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA6EB12E; Wed, 24 May 2023 12:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ubap98wO65k5/9CnZSUilxkgCeOYr6tA2xfUSRuyuDrXqWraAxv3jQ1LyfGZ7eOgLJmlOgj/Y/c7UqRfyFMbONjTwwZuQK0YhBuEeMX1jk/S8p9Ag1kMPNdfwUVoOKevhdmQI2zP56+u36rIvnJUzYYNqWg6yC2Nze+T5C9EzfjScmhEuQg89H7hwdyncs5EsL0DI4WJ/lKKTu3c+4dTPNFp8DtH8O6WJiRLuREmFKt0V5CbXlDGZChbLpIYQZqNps7h9cQL13LgNfEpAWYV7bdCSZJLjZlFi/AJEW1JP06+nmzxWPQ0przlZyMlnC+C/54C96NGAcvKQ/U2uwIL7g== 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=oSYWzcp8wMhvhiUJASaUrK3knaPwcQTaxUWCltf0ZYQ=; b=fKy/PC8YONQcTvJTKGzUEN3yEcX5jiaq1d/a7LpFzVNhlXk6A4qgy7JBK77NrY5296MuyNfBhGP/pz075m/lQPYji4Bhu3uWUZ0cX3ZQq6juo/qGgUINHhw63KwapFHjp0PdoSGaJ11oUYtkEArhsBVtaDugORzMbhALWU0bk936StvvDMfBAg2zr8caXvmzzFmKO+f+HX2GryZ3ZT0r3in6lKYR+pVfkwBgDusbDtWUPL3qoUOEFp4pwnRYZwWT3VzAu0Bny+JKeb7U/5Dqxwo+IW7BnJANyF7qyev9Sn6+SHT+3ebWHWg3NZSFYta0drWqFwNHwbhINoUEwlHlVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oSYWzcp8wMhvhiUJASaUrK3knaPwcQTaxUWCltf0ZYQ=; b=HhaJ1Ggf73BgSRMFr/azOMYy5VuxhlJfowVX9ZXMoNIzP9KQvbhbYOTKnQlkTrTA6hCVMwJ4NAyYGucygNjJw5FmziXNrvP9FFdN1L+2NpgsySJJ6JYTYRVjdIyb/sdnKnoSZQjfkz9lMwbNl7PB6mCUXWQPTKhYXDJBfFpqkpA= Received: from MW4P222CA0030.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::35) by BL1PR12MB5078.namprd12.prod.outlook.com (2603:10b6:208:313::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.15; Wed, 24 May 2023 19:07:46 +0000 Received: from CO1NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::d3) by MW4P222CA0030.outlook.office365.com (2603:10b6:303:114::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Wed, 24 May 2023 19:07: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 CO1NAM11FT006.mail.protection.outlook.com (10.13.174.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6433.16 via Frontend Transport; Wed, 24 May 2023 19:07: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.2375.34; Wed, 24 May 2023 14:07:44 -0500 From: Mario Limonciello To: Bjorn Helgaas , Mika Westerberg , "Rafael J . Wysocki" CC: , , "S-k Shyam-sundar" , Natikar Basavaraj , Deucher Alexander , , Lukas Wunner , Mario Limonciello Subject: [PATCH v4 1/2] PCI: Refactor pci_bridge_d3_possible() Date: Wed, 24 May 2023 14:07:25 -0500 Message-ID: <20230524190726.17012-1-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: 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: CO1NAM11FT006:EE_|BL1PR12MB5078:EE_ X-MS-Office365-Filtering-Correlation-Id: eaadf609-5a8a-4df9-6c60-08db5c8a28e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eevwNxqVm41Sf+A+jT7xOtfccVDjJJZBzGhyUVpNFrcCh1Zwxdn54vU7a6/DivEoVb84p86vqGqLlu9qgJsBQdpixcT3w/CS7REpwOSNvx3qWuJTPFn4xVQNG9b3KWpNl3WXzYX+r4elEBVEjI/hQe9rLXCfikDn8Pk9MQdFF5WUY8IPSY4gkYwcMJu853vuitTT9ci34QlnwYvNdf6wdcyss+17DTtVOWNYRmCFmLwB9VMMXheX85ayMSuasapmG9Erg84aSmwg9ZSfyc1/9Us0N5gq4ring3WlZYijv7co6IGzPX5I/+LX/SGHXFCc1Ltq5ajX4QdYoPD68vH6bf2vaLfRqfwcIrAiWzjJCEDdoCZdzntAh9rlhzGvK1Rmn9S9G8Mci0BBACxgNvRzW6K7BrpmCfcbvOvoo7dLSpHwF9Xmtf3HWsOoafXYnGxMUlqEnp1g8yxedX2VFrKynlTi+3ZctaS+77tnnYi/GLXWTSsA7a1iqo090FKBk/jLDqYYIzzAjJagjP3UZPwup59e2anXqOu6OJtW/O3HSRAETYDUl99jrAsH8T+Uj9OIoqz4Le7E06ZUDIYidmU7RACKpiXB2GOBppv3bHN0VERt7gbWQYRDxh+og0JB/jLe8feyZERzn/ybkDCx5mCYIPEd9QPhK+jU3g3W1xcx6QDwrgxaoEc1yP4p6OF3GfIGTjUnnxBkpp2lWR9l45NrVFN3W4iNMjkKQIrhpdkbtuF441ZDQ53SlO+dsoEur8eRkMp2cLPeuMddhkkuXhQ+3g== 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:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(478600001)(1076003)(82310400005)(186003)(16526019)(54906003)(2616005)(26005)(7696005)(6666004)(426003)(336012)(356005)(81166007)(82740400003)(40460700003)(4326008)(47076005)(83380400001)(36756003)(110136005)(8676002)(316002)(36860700001)(5660300002)(70586007)(2906002)(70206006)(44832011)(8936002)(41300700001)(86362001)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2023 19:07:46.2951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eaadf609-5a8a-4df9-6c60-08db5c8a28e4 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: CO1NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5078 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766805542269529190?= X-GMAIL-MSGID: =?utf-8?q?1766805542269529190?= All of the cases handled by pci_bridge_d3_possible() are specific to these branches: ``` case PCI_EXP_TYPE_ROOT_PORT: case PCI_EXP_TYPE_UPSTREAM: case PCI_EXP_TYPE_DOWNSTREAM: ``` Drop a level of indentation by returning false in the default case instead. No intended functional changes. Signed-off-by: Mario Limonciello Acked-by: Rafael J. Wysocki Reviewed-by: Mika Westerberg --- v3->v4: * New patch --- drivers/pci/pci.c | 68 +++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 5ede93222bc1..d1fa040bcea7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2978,48 +2978,48 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) case PCI_EXP_TYPE_ROOT_PORT: case PCI_EXP_TYPE_UPSTREAM: case PCI_EXP_TYPE_DOWNSTREAM: - if (pci_bridge_d3_disable) - return false; + break; + default: + return false; + } - /* - * Hotplug ports handled by firmware in System Management Mode - * may not be put into D3 by the OS (Thunderbolt on non-Macs). - */ - if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge)) - return false; + if (pci_bridge_d3_disable) + return false; - if (pci_bridge_d3_force) - return true; + /* + * Hotplug ports handled by firmware in System Management Mode + * may not be put into D3 by the OS (Thunderbolt on non-Macs). + */ + if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge)) + return false; - /* Even the oldest 2010 Thunderbolt controller supports D3. */ - if (bridge->is_thunderbolt) - return true; + if (pci_bridge_d3_force) + return true; - /* Platform might know better if the bridge supports D3 */ - if (platform_pci_bridge_d3(bridge)) - return true; + /* Even the oldest 2010 Thunderbolt controller supports D3. */ + if (bridge->is_thunderbolt) + return true; - /* - * Hotplug ports handled natively by the OS were not validated - * by vendors for runtime D3 at least until 2018 because there - * was no OS support. - */ - if (bridge->is_hotplug_bridge) - return false; + /* Platform might know better if the bridge supports D3 */ + if (platform_pci_bridge_d3(bridge)) + return true; - if (dmi_check_system(bridge_d3_blacklist)) - return false; + /* + * Hotplug ports handled natively by the OS were not validated + * by vendors for runtime D3 at least until 2018 because there + * was no OS support. + */ + if (bridge->is_hotplug_bridge) + return false; - /* - * It should be safe to put PCIe ports from 2015 or newer - * to D3. - */ - if (dmi_get_bios_year() >= 2015) - return true; - break; - } + if (dmi_check_system(bridge_d3_blacklist)) + return false; - return false; + /* + * It should be safe to put PCIe ports from 2015 or newer + * to D3. + */ + return dmi_get_bios_year() >= 2015; } static int pci_dev_check_d3cold(struct pci_dev *dev, void *data) From patchwork Wed May 24 19:07:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 98661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp126537vqr; Wed, 24 May 2023 12:15:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74BBejQKfjRJ4xPsOQtwpFdkXoH+UxrJp3YINP9Cbo7EN6YI5vSRqtYTBfnzsRMiUqLs8c X-Received: by 2002:a17:90b:4b51:b0:255:8a12:241b with SMTP id mi17-20020a17090b4b5100b002558a12241bmr7716559pjb.22.1684955729857; Wed, 24 May 2023 12:15:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684955729; cv=pass; d=google.com; s=arc-20160816; b=QXTMXFh3l/YI0PRRnYVKkhTVhDN0GZNdllOq9+7e7Lih2H/tsGEzF4x0YBoNmEAe4Y QYN+lFAeckpuiBIQbb+iq63p8fEfT6Z491hTtRwEIjrVwoBnj5OfybOYUssL13NJLIun r3uMgkNHwJ7UqrAgMuf/H1OjUTksxUvnWIO2nPp5at9z9D+XaPj/iieMzVUoq5/o0LYe 32ZJIHzGiLtaWugYJji9oH9JoWjnErAh0iLdIaAl3M2QGJrHbktGCmz7hCu1hE0bfNwO CMnQl8TFNJzsynqdLgcdM6pMBxLqyp4wpf2Z47OHrA6BqpQxmCTLJ1pb/c1YarCmxLEF Dyfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cN5XhjMdwL/hTBA3wvpOgjLrhkNRBDaNwSHLJzJuxog=; b=hWW1YDCqHpn4wzpcv/tqV1HCi3etIBfsnols0DX7b7PkdXeBEYFifbX3dO4y2px0vL FLXmjVvIz6AMuMPUQIE1BOYPNWLIkBTBAoKf313NICn+dzuKkMsmeHnKqXiGsTeNlRWU 8p+8O2aG8Vl5yOCJ8KOs0zaQMJ02Gyazx/rZonXkFtnKkxU0XF5E4RmTLXzX7+ACcPWb OvFAPQjWs2O9S5hITMx9SFrjN6N/wdK9dudRoNbKbTqvm4zJIw3QoDqWQfAOzZ7eksAp v3kFNLL6RZ15qejOg0aK5S9yTdVtYIDx6Rs5+yFcH8bBGRFo2Dz75J6aHkiZz8RinsgX 6Sjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=jGKFW75g; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a17090ad24b00b00255ab0ed47asi1836385pjw.49.2023.05.24.12.15.14; Wed, 24 May 2023 12:15:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=jGKFW75g; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232371AbjEXTHz (ORCPT + 99 others); Wed, 24 May 2023 15:07:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbjEXTHv (ORCPT ); Wed, 24 May 2023 15:07:51 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFADB12B; Wed, 24 May 2023 12:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JqQPSSvo9axDlZOfc+5rUGx5S27Mx1sxVhGVlLkVJHjFLQBco+GZJ6a8gzyHUCvm9Sao/CDOnnVi5tG0HYPp9GTVqGrmheXqgwkF2FuvFXe2VQ6Qg5XNhA4ay95G7pZdeDSLpVpRYFbdVAepJamFhoKkvg60Ptry8efer0Msdw9Mq/q6AAnB5oSLZRICqBQFPRXRpgsmNlo/8laTl9MWW1/ARj3uxDQL/nXylf5UERn7He94tw6b/CNQhRl9FrJRubfrdRrCrchZwBAHE2Vsn09oIIX1flGkkKAAGhb72269wdp+niDWEEkU/UgrA71GfVZIgLsZmBZhd+synth9Xw== 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=cN5XhjMdwL/hTBA3wvpOgjLrhkNRBDaNwSHLJzJuxog=; b=i03d965G5g0eeVHogn5GPwSBIQ3T/2irQWAn6BE5ORDUIU8pwl8kg8ol8Htoc1zSf35Z6FfBd7f+h1TFsG6+QcOvQniUHQKMS11EUXM/lrxIqmSaaY5q1dSiqYMSy9+JTfw1Uz8C0ShMPbu0cMAhh2ezBQ8Lw4mYR7WCUq9j8XN/hm+KXHjyQLH77ysYev8GLnZVrjQbIJBZ2pSQ/VUAuidW+ZE0BRMvE1SjQD3hUQ39UeaSvZ0rSdEk46UKp+WzeKdf7f6vIICp7fZYYUICJZ+12sltMGAf96Mjswk/QDD47JB1ngBSoCuAAkUGZN0Y8NimbQfM0FuLb94YAMZEkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cN5XhjMdwL/hTBA3wvpOgjLrhkNRBDaNwSHLJzJuxog=; b=jGKFW75gOI064+EGE0LOM7vRNYhCoeBrawHVnZhOr/5ZcUPTlX6SXyM7tUyLU9GyHwPxJq+TtUbO1uJC0K5/ZtbYQKx8CV4hWnLiw7/Zb/7sPx+6iCD873BSgoQSz8y6b8w7W9PwTlUD0BjLRIfbRI2S4voCt0GmeD4z/Xm32wQ= Received: from MW3PR06CA0022.namprd06.prod.outlook.com (2603:10b6:303:2a::27) by CH3PR12MB9077.namprd12.prod.outlook.com (2603:10b6:610:1a2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.15; Wed, 24 May 2023 19:07:48 +0000 Received: from CO1NAM11FT084.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2a:cafe::3f) by MW3PR06CA0022.outlook.office365.com (2603:10b6:303:2a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Wed, 24 May 2023 19:07: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 CO1NAM11FT084.mail.protection.outlook.com (10.13.174.194) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.30 via Frontend Transport; Wed, 24 May 2023 19:07: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.2375.34; Wed, 24 May 2023 14:07:45 -0500 From: Mario Limonciello To: Bjorn Helgaas , Mika Westerberg , "Rafael J . Wysocki" CC: , , "S-k Shyam-sundar" , Natikar Basavaraj , Deucher Alexander , , Lukas Wunner , Mario Limonciello , Iain Lane Subject: [PATCH v4 2/2] PCI: Don't assume root ports from > 2015 are power manageable Date: Wed, 24 May 2023 14:07:26 -0500 Message-ID: <20230524190726.17012-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524190726.17012-1-mario.limonciello@amd.com> References: <20230524190726.17012-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: CO1NAM11FT084:EE_|CH3PR12MB9077:EE_ X-MS-Office365-Filtering-Correlation-Id: 20423d81-28f9-4195-7352-08db5c8a29d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GLgEezDeCwTykxH7CHCamNY/gPbMVzMQu73M8FTT3Ic+xi3mJZSU5ZwfQuUf+ub7UMDNtBbK45WBxZ01g63ylh2zMxAoVxFl6bIY4NKfXTqhHbypvShNSHTzf17tLtv53rMMnYQbcF2KgFsg4B9Q6h9cvh7+x/L/XuduEwM2C+NhvwIn4imj9J8m5QVNqvNbj+dXPHnrM2eWM1nNFiM6/zwhIQvWFFBPXiKEqq3EqVvPUD/l1n55y5hqFZYyqcEDPvpy0dJQmr/TALlO+HSfY2h7ojcl0Yz1DOYQZT89qQZwmD//eMZfNqU15Il3J4XnAfOieXo95KoIhju7cpTdPTKgpBcyPhS1I/b9vJUjx90mG3z40LbCkJ210EHP5JU39KEU5MyOwCrloKUiEOxuYSp1ZKv2roTvkiLRmZX77G0b9TDqTKxu4tmXUugCTrH5YtXGf0s6NgZrrpDLXpVVgV6fTanbUscj89aOvgVg3QxaYaaW2Lct2vS+yS4MZKs7KOm+qEUrBS56wKaKVqSwsG4h5nLyXXqyIunTs8nSz0skT16Gq5Ql2v1qzFuOoqJDvqiurMv/yDmPAoK5D75Lp9v3VaWFgkn4iIS3ZCJTC2+pkA8ACpEMbgd4r+xhRYnEkQSJSPDICYXMxgcTdgq6Kh2MX8hz3sFCSirZEBLftX4xNoVVhGKKaN5eQ126ntxgg6acDG3OMyN0mk91pdFi1o4K7EYr0W8R6tj3/ZZuVarbUu1pYzdpGugwZEIL4L4nOFHSkJUDWMH6avWdr4QHFQ== 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:(13230028)(4636009)(346002)(396003)(39860400002)(376002)(136003)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(5660300002)(8676002)(8936002)(16526019)(186003)(2906002)(36860700001)(86362001)(2616005)(36756003)(336012)(426003)(83380400001)(66574015)(47076005)(44832011)(82740400003)(356005)(40480700001)(26005)(1076003)(82310400005)(316002)(70586007)(70206006)(4326008)(6666004)(110136005)(54906003)(478600001)(81166007)(7696005)(966005)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2023 19:07:47.8944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20423d81-28f9-4195-7352-08db5c8a29d8 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: CO1NAM11FT084.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9077 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766804139035836702?= X-GMAIL-MSGID: =?utf-8?q?1766804139035836702?= Using a USB keyboard or mouse to wakeup the system from s2idle fails when that XHCI device is connected to a USB-C port for an AMD USB4 router. Due to commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend") all PCIe ports go into D3 during s2idle. When specific root ports are put into D3 over s2idle on some AMD platforms it is not possible for the platform to properly identify wakeup sources. This happens whether the root port goes into D3hot or D3cold. Comparing registers between Linux and Windows 11 this behavior to put these specific root ports into D3 at suspend is unique to Linux. On an affected system Windows does not put those specific root ports into D3 over Modern Standby. Windows doesn't put the root ports into D3 because root ports are not power manageable. Linux shouldn't assume root ports support D3 just because they're on a machine newer than 2015, the ports should also be deemed power manageable. Add an extra check explicitly for root ports to ensure D3 isn't selected for these ports. 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 Acked-by: Rafael J. Wysocki Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Mika Westerberg --- v3->v4: * Move after refactor --- drivers/pci/pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d1fa040bcea7..d293db963327 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3015,6 +3015,14 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) if (dmi_check_system(bridge_d3_blacklist)) return false; + /* + * It's not safe to put root ports that don't support power + * management into D3. + */ + if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT && + !platform_pci_power_manageable(bridge)) + return false; + /* * It should be safe to put PCIe ports from 2015 or newer * to D3.