Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp865931rwb; Thu, 12 Jan 2023 13:27:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXvKv5Lz1eth2ehG7ZC7F2164g/KISOoRqSF8mrnKO51bltPLq68uWp7kTChOOFfIq4uDTUp X-Received: by 2002:a17:90a:2e17:b0:227:7f5:9fdb with SMTP id q23-20020a17090a2e1700b0022707f59fdbmr18009782pjd.23.1673558863631; Thu, 12 Jan 2023 13:27:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673558863; cv=none; d=google.com; s=arc-20160816; b=tWH2YqFTOpKxZvg2ZDXP6CLWEhXefOwiE/Thdafk9m+rj6vH3q60ujfHOCyC5ua1UH VRPDP1Xvf4hF9IkGqWgvPK9CY3Kk5Y83WzA+HzAW10mqPrBLJ4WYYydnsNth2ur6DwM5 FHmxwppUmzku1jD3+BHDbv+90E/dbTi863NkAvt/qxZcOTI8+p8omEFJeb4Ovquh+vVe tMIa1vqG1yK3lIhBq02J71O/OEHzXy3qLr21YNHEO1q2sYu6FDy8oZwEyLbFg/Xw856c QvpkLo7XXdp6ZhD+s/qlxck2hvrJyzATjrWo9bPTfmQ3zmaI/o0z9e4fAJaXkfnTO1LR TA7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=L2nFgdDb65kynrrmfmzSLp/jRdwKd3Nk1yZl/VPrHZs=; b=i4y3nPF44tNTs5vH2CYuf0RC5TRx5cE14K2obYDIMcjJwunvy0Y1TD9Y4SM9+DptHY 12WhHycI6MiCX5UIhAX1Au00iew7D7enqXGMG0iIE3CnMjHBPWfOQ6RdumYLY1kLDpfi fUPE3+t3qcPhTT+OiVFDnr7IcvTtuIxsvcw4Zm0VRps3KBPKhSyR5V3RT4HOpUcU40gX deafLNrcCzDiwKgVDt/anz8zOKQBZ+v8rgjMyjQnmJB9/Ox3iAmB7xMfRPVVoSfG/HKX 7m3pcFL5CoHfQCvk9w2ChDtpFJrx3eEdk7Q1oIVTg9FhNT6snj9GJH39n4uGRYxJPIps 1Urw== ARC-Authentication-Results: i=1; mx.google.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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 68-20020a17090a09ca00b00229008bcf6bsi2876923pjo.16.2023.01.12.13.27.36; Thu, 12 Jan 2023 13:27:43 -0800 (PST) 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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235201AbjALUzQ (ORCPT + 51 others); Thu, 12 Jan 2023 15:55:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240459AbjALUx2 (ORCPT ); Thu, 12 Jan 2023 15:53:28 -0500 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 932AE17581; Thu, 12 Jan 2023 12:31:55 -0800 (PST) Received: by mail-ej1-f51.google.com with SMTP id mp20so1004821ejc.7; Thu, 12 Jan 2023 12:31:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=L2nFgdDb65kynrrmfmzSLp/jRdwKd3Nk1yZl/VPrHZs=; b=DN5b560iNswoycqndzNzb8swfw01ooPIMdVp3pe5EaSOknyKsO59E92VttsBN73Lwt iLIVBWyje3HZfwa9FrGsEdiMdBfpqdKizVltKyuo2mUpTix7oUTvOioQGOjpejT31hBb 8SuG8SP0dNcbDPMvxyaEmz/iEaprz01LPQyYONePTtB5QELDa+Xzti7QfK/kdvXZ7j15 SagVHfUVg3K8ItGz0TGrSgrL9dBASVfXJKQpRuyLL4WJQXnMMOjkK7odYtWaABNmOO8E /liy/AVdcmZZ7gBlBQDh2Wpq+/7UlGV6iAo2ve3js8/GfxtXAKntBSVf8DSEQeRLGVMz l0PA== X-Gm-Message-State: AFqh2kp8+Cv1srM08aZsN5AusUJkje/VBcfvyY00c2HIr7jj47P5qODV awFuMc8wWM0+Nvdg8C/CFZI1JxlPfxiuHqD6m6g= X-Received: by 2002:a17:907:75ea:b0:7c0:f118:7e4e with SMTP id jz10-20020a17090775ea00b007c0f1187e4emr4485732ejc.478.1673555514054; Thu, 12 Jan 2023 12:31:54 -0800 (PST) MIME-Version: 1.0 References: <5659681.DvuYhMxLoT@kreacher> <20230112202132.GA1788706@bhelgaas> In-Reply-To: <20230112202132.GA1788706@bhelgaas> From: "Rafael J. Wysocki" Date: Thu, 12 Jan 2023 21:31:42 +0100 Message-ID: Subject: Re: [PATCH v3] PCI / ACPI: PM: Take _S0W of the target bridge into account in acpi_pci_bridge_d3(() To: Bjorn Helgaas Cc: "Rafael J. Wysocki" , linux-pci@vger.kernel.org, "Limonciello, Mario" , "Rafael J. Wysocki" , Len Brown , Bjorn Helgaas , Mika Westerberg , Mehta Sanju , Lukas Wunner , "Rafael J . Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Linux PM Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS 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 On Thu, Jan 12, 2023 at 9:21 PM Bjorn Helgaas wrote: > > On Wed, Jan 11, 2023 at 11:38:55AM +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > It is generally questionable to allow a PCI bridge to go into D3 if > > it has _S0W returning D2 or a shallower power state, so modify > > acpi_pci_bridge_d3(() to always take the return value of _S0W for the > > target bridge into accout. That is, make it return 'false' if _S0W > > returns D2 or a shallower power state for the target bridge regardless > > of its ancestor PCIe Root Port properties. Of course, this also causes > > 'false' to be returned if the PCIe Root Port itself is the target and > > its _S0W returns D2 or a shallower power state. > > > > However, still allow bridges without _S0W that are power-manageable via > > ACPI to enter D3 to retain the current code behavior in that case. > > > > Link: https://lore.kernel.org/linux-pci/20221031223356.32570-1-mario.limonciello@amd.com/ > > Reported-by: Mario Limonciello > > Signed-off-by: Rafael J. Wysocki > > --- > > > > v2 -> v3: > > * Use rpadev for the ACPI companion of the Root Port in acpi_pci_bridge_d3(() > > to avoid confusion. > > * Make the function evaluating _S0W return the value produced by it or "unknown > > state" on errors and let its caller deal with that value. > > > > --- > > drivers/acpi/device_pm.c | 19 +++++++++++++++++++ > > drivers/pci/pci-acpi.c | 45 +++++++++++++++++++++++++++++++-------------- > > include/acpi/acpi_bus.h | 1 + > > 3 files changed, 51 insertions(+), 14 deletions(-) > > > > Index: linux-pm/drivers/pci/pci-acpi.c > > =================================================================== > > --- linux-pm.orig/drivers/pci/pci-acpi.c > > +++ linux-pm/drivers/pci/pci-acpi.c > > @@ -976,24 +976,41 @@ bool acpi_pci_power_manageable(struct pc > > bool acpi_pci_bridge_d3(struct pci_dev *dev) > > { > > struct pci_dev *rpdev; > > - struct acpi_device *adev; > > - acpi_status status; > > - unsigned long long state; > > + struct acpi_device *adev, *rpadev; > > const union acpi_object *obj; > > > > if (acpi_pci_disabled || !dev->is_hotplug_bridge) > > return false; > > > > - /* Assume D3 support if the bridge is power-manageable by ACPI. */ > > - if (acpi_pci_power_manageable(dev)) > > - return true; > > + adev = ACPI_COMPANION(&dev->dev); > > + if (adev) { > > + /* > > + * If the bridge has _S0W, whether or not it can go into D3 > > + * depends on what is returned by that object. In particular, > > + * if the power state returned by _S0W is D2 or shallower, > > + * entering D3 should not be allowed. > > + */ > > + if (acpi_dev_power_state_for_wake(adev) <= ACPI_STATE_D3_HOT) > > The comment suggests that this should check for "<= ACPI_STATE_D2" > (not ACPI_STATE_D3_HOT). Or is there some subtlety here that I'm > missing? No, this is a mistake. I'll send a v4.