Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2161812rdb; Tue, 20 Feb 2024 21:20:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZh5wkV9V91jampDMOQxjJvEGjvTio7vHJ98CwRKAS92nF9vXtBqbRj2+v8rtEpFt62Al+HnmteHY7Xirf+21bmhDeOWN4LfnVythskQ== X-Google-Smtp-Source: AGHT+IFSIgO9V+cc7VVfutuIjX0FUO9+zC34iE44hCXm/Gmfk1rHPL7HPTSN6bSG/3kXUtf7h1CC X-Received: by 2002:a05:6359:411f:b0:176:5364:4c11 with SMTP id kh31-20020a056359411f00b0017653644c11mr17940841rwc.18.1708492836416; Tue, 20 Feb 2024 21:20:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708492836; cv=pass; d=google.com; s=arc-20160816; b=yxHuvebQF4WVZ2YBJ3KVFekZPvK7uGRF2laacWRvXGg+B5/TrPFDO8fVM912HxvetE rbiMjwMXFxuUVzfPahcpUNsCIwxh6tGuBhnYolSTaDjty8MKd+AKD5Tm8CWgPuMmENwH YdNv1tF2/TETAcBU+PBBOBspEQ//7ATZz5kPumhSn2Y4kJTZiJHUKYlKdu8zaWM7sMUl ozV8KdIxJh7BG6ptxrCZ2iKvGzVoyw+ysByfeVqnKMWzIczmVbc+o887Zx7dKVssFV84 aybKGFDAui4KCCYPQUHnJqwU/h8JsZ5nmy/1TPW1qiF3/RbbWyY9T3xxe0edcwOJplu/ bNHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pHwFms0+JDvWd5qBV1E84IHlDR/CGNV6i5IheOsfMC8=; fh=6MNSYrbL/9E5ib+/8kRBvYt9r15IdDpxwcQ5XZwhJr8=; b=oXiqi0N0pDNuxGaaC4E9hq7r0DvDXHBo/5YORhj7kvbDpbbaK1Rd6+hcFcBjERdLD5 13+BseuYbSX4QROX9Rl9zuwmuBDG0XFkhWJhCHuMDxm60XllCOsatOfTWTzbCYFRmuTb UtYPAShX9japg5PToQa87cQZn68ti+xi28ceyC6D3Y1eecx40hp0Bba2GqRoTHH6tsvW vQvBJss2lZXGOEjPN0Ye4EO1jCjR9MMFma/pgSNBoFjPdCiC6W+YBuFL+/gCPiZqpudM SrHkeQHR1Tn5oqv1sFBs2Raa6Z55Gg0qzo6onr3XdX/yG4Vxk+zJT5DHGT2fVSGI2spF lzig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sNyUboI7; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-74068-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74068-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u185-20020a6385c2000000b005dc833ef4e6si7231917pgd.75.2024.02.20.21.20.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 21:20:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74068-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sNyUboI7; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-74068-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74068-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id EC750B22184 for ; Wed, 21 Feb 2024 05:20:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56A2839FC3; Wed, 21 Feb 2024 05:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sNyUboI7" Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 935DFA35 for ; Wed, 21 Feb 2024 05:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708492810; cv=none; b=oMjJ2VdVL87+uUd9XV9PnOdZaJ+8qHtolfGb59RhC2iIvri/1SVzrFaJpqvMTjX5DFj7nbTg3eKx+c7C1lvKVzSWiSOw0my9XfHObQcgwACjV7VCslrSkKWH+7TEmwdaRIgY6xMLVJDzbaEqO7lOQiJIJ3cqIz24MpD4h3hJfoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708492810; c=relaxed/simple; bh=tU5D19gbAMGh1onifR5Xg6u/MCOTn3Br+s4+IWELJxs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L+Um0b5ijU16ABHFikPOK1ZEjH7plS04iQ6Y35Q8TXg08iFKg3meXDRR7ZlFurABtyIq6eblcBFIpz312Xi1x3O/snLxpJD80Ykp5Cv0tnNn2yYc11pOzkL7uOQ0WnMmWcemKL2eL2SZDnZ0ZDR56G3X/yi7FWS3gVJ6SWhPsYw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=sNyUboI7; arc=none smtp.client-ip=209.85.167.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3c0485fc8b8so5033769b6e.3 for ; Tue, 20 Feb 2024 21:20:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708492806; x=1709097606; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=pHwFms0+JDvWd5qBV1E84IHlDR/CGNV6i5IheOsfMC8=; b=sNyUboI7JjcrA9gmxW+cZnonG5IJJRXd10GdZyjGTTIYKVHW8MHbW8ETRDml2z9+Ti SzsDMLrRfHlH0627RFSqY7hH01k8rVXJLVgOk3bWDhMdKABu1ZSEFHls1wAZioO27iBF WOIseyq/vtl01juCKYwSdRlb+45owNAbZ+dRb+Fv2WB61wszdpIgCset5yNXgCicMCZj DS3qDVuuOmAWnq1BmLFcA4gs9X2lgAgh5HNmbeuWCDTqu6aY6h9PzrnoRF1Y0+iu0lIh 0FCrV8nhF1HhYBFMK3NuRaTtYMv2MihiIP9heEeTSN2KG22vfzGfXLpixeLvvDa5LQKI Xq8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708492806; x=1709097606; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pHwFms0+JDvWd5qBV1E84IHlDR/CGNV6i5IheOsfMC8=; b=u9cl3yv9jjr0M/JgDXC1ZgkNRmyBx9YuLUkjaJV2K/btHePUbGaF5Afj8oQZ50V77K ESjTUW+ZcqytS7CYpzaH1G4yOqT7LvnRAJVkAwow+9q7ncGZVTB/5+qlbtuZfr1RcZXM WEPm5IJNcgftLICOL2YXSbn4f+qxZUHYPQpunp2aXOMkK4W5oVyzKD9sjdNfcU8q/WC2 zTLgqDTYN4iiqdaTZX9F6aa6E6mf/ytpW5PJretaeMnXRN21lomLFve/57LDx+mB1NMB +gWTo3xLMxqqkaK5FKZ8Ycn1ccsFx4UZ2BxtaPORGcxl3HDruE56xE6JhjWseIA20ew9 XTXQ== X-Forwarded-Encrypted: i=1; AJvYcCXjA//hpR0KQVmzDClg5t1GykSSAoXq7putKXmKPO4TYCDjcZQoyzxcab/bjlCRxzQ+ILuQ+Mi4wFRV6BAiuJ/OGAOIIOEaVS8QJR0L X-Gm-Message-State: AOJu0Yy92fHWK3rEVmSFVrIyJkg7WiSidKXanlHSxpWtmwqEMixgO66i P0ZLx236KCcaDbBiPnlEUFrpYCIDMh8IlmlggM/8oX5+jZ3tX0aqlm6nx4ygTA== X-Received: by 2002:a54:470c:0:b0:3c0:3044:dfbc with SMTP id k12-20020a54470c000000b003c03044dfbcmr16658295oik.18.1708492806631; Tue, 20 Feb 2024 21:20:06 -0800 (PST) Received: from thinkpad ([117.207.28.224]) by smtp.gmail.com with ESMTPSA id w24-20020aa78598000000b006e4695e519csm4360375pfn.194.2024.02.20.21.20.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 21:20:06 -0800 (PST) Date: Wed, 21 Feb 2024 10:49:58 +0530 From: Manivannan Sadhasivam To: Bjorn Helgaas Cc: Bjorn Helgaas , Bjorn Andersson , Konrad Dybcio , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Lukas Wunner , Mika Westerberg , quic_krichai@quicinc.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v3] PCI: Add D3 support for PCI bridges in DT based platforms Message-ID: <20240221051958.GA11693@thinkpad> References: <20240214-pcie-qcom-bridge-v3-1-3a713bbc1fd7@linaro.org> <20240220220240.GA1507934@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240220220240.GA1507934@bhelgaas> On Tue, Feb 20, 2024 at 04:02:40PM -0600, Bjorn Helgaas wrote: > On Wed, Feb 14, 2024 at 05:16:09PM +0530, Manivannan Sadhasivam wrote: > > Currently, PCI core will enable D3 support for PCI bridges only when the > > following conditions are met: > > Whenever I read "D3", I first have to figure out whether we're talking > about D3hot or D3cold. Please save me the effort :) > Both actually, that's why I used "D3" as in the spec. I should've explicitly mentioned that in the commit message. > > 1. Platform is ACPI based > > 2. Thunderbolt controller is used > > 3. pcie_port_pm=force passed in cmdline > > Are these joined by "AND" or "OR"? I guess probably "OR"? > > "... all the following conditions are met" or "... one of the > following conditions is met" would clarify this. > Will use "one of the..." > > While options 1 and 2 do not apply to most of the DT based platforms, > > option 3 will make the life harder for distro maintainers. Due to this, > > runtime PM is also not getting enabled for the bridges. > > > > To fix this, let's make use of the "supports-d3" property [1] in the bridge > > DT nodes to enable D3 support for the capable bridges. This will also allow > > the capable bridges to support runtime PM, thereby conserving power. > > Looks like "supports-d3" was added by > https://github.com/devicetree-org/dt-schema/commit/4548397d7522. > The commit log mentions "platform specific ways", which suggests maybe > this is D3cold, since D3hot should be supported via PMCSR without any > help from the platform. > > So I *guess* this really means "platform provides some non-architected > way to put devices in D3cold and bring them back to D0"? > By reading the comments and git log of the pci_bridge_d3_possible() function in drivers/pci/pci.c, we can understand that some of the old bridges do not support both D3hot and D3cold. And to differentiate such bridges, platforms have to notify the OS using some ways. ACPI has its own implementation [1] and DT uses "supports-d3" property. And yes, in an ideal world PMCSR should be sufficient for D3hot, but you know the PCI vendors more than me ;) > > Ideally, D3 support should be enabled by default for the more recent PCI > > bridges, but we do not have a sane way to detect them. > > > > [1] https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/pci/pci-pci-bridge.yaml#L31 > > This link won't remain accurate as lines are added/removed. The > kernel.org cgit allows specific commits > (https://git.kernel.org/linus/0dd3ee311255) or line references at > specific commits or tags > (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=v6.0#n94) > I'm not aware of such references in github. So I'll reference the commit instead. - Mani [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pci-acpi.c#n976 > > Signed-off-by: Manivannan Sadhasivam > > --- > > This patch is tested on Qcom SM8450 based development board with an out-of-tree > > DT patch. > > > > NOTE: I will submit the DT patches adding this property for applicable bridges > > in Qcom SoCs separately. > > > > Changes in v3: > > - Fixed kdoc, used of_property_present() and dev_of_node() (Lukas) > > - Link to v2: https://lore.kernel.org/r/20240214-pcie-qcom-bridge-v2-1-9dd6dbb1b817@linaro.org > > > > Changes in v2: > > - Switched to DT based approach as suggested by Lukas. > > - Link to v1: https://lore.kernel.org/r/20240202-pcie-qcom-bridge-v1-0-46d7789836c0@linaro.org > > --- > > drivers/pci/of.c | 12 ++++++++++++ > > drivers/pci/pci.c | 3 +++ > > drivers/pci/pci.h | 6 ++++++ > > 3 files changed, 21 insertions(+) > > > > diff --git a/drivers/pci/of.c b/drivers/pci/of.c > > index 51e3dd0ea5ab..24b0107802af 100644 > > --- a/drivers/pci/of.c > > +++ b/drivers/pci/of.c > > @@ -786,3 +786,15 @@ u32 of_pci_get_slot_power_limit(struct device_node *node, > > return slot_power_limit_mw; > > } > > EXPORT_SYMBOL_GPL(of_pci_get_slot_power_limit); > > + > > +/** > > + * of_pci_bridge_d3 - Check if the bridge is supporting D3 states or not > > + * > > + * @node: device tree node of the bridge > > + * > > + * Return: %true if the bridge is supporting D3 states, %false otherwise. > > + */ > > +bool of_pci_bridge_d3(struct device_node *node) > > +{ > > + return of_property_present(node, "supports-d3"); > > +} > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > > index d8f11a078924..8678fba092bb 100644 > > --- a/drivers/pci/pci.c > > +++ b/drivers/pci/pci.c > > @@ -1142,6 +1142,9 @@ static inline bool platform_pci_bridge_d3(struct pci_dev *dev) > > if (pci_use_mid_pm()) > > return false; > > > > + if (dev_of_node(&dev->dev)) > > + return of_pci_bridge_d3(dev->dev.of_node); > > + > > return acpi_pci_bridge_d3(dev); > > } > > > > diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h > > index 2336a8d1edab..10387461b1fe 100644 > > --- a/drivers/pci/pci.h > > +++ b/drivers/pci/pci.h > > @@ -635,6 +635,7 @@ int of_pci_get_max_link_speed(struct device_node *node); > > u32 of_pci_get_slot_power_limit(struct device_node *node, > > u8 *slot_power_limit_value, > > u8 *slot_power_limit_scale); > > +bool of_pci_bridge_d3(struct device_node *node); > > int pci_set_of_node(struct pci_dev *dev); > > void pci_release_of_node(struct pci_dev *dev); > > void pci_set_bus_of_node(struct pci_bus *bus); > > @@ -673,6 +674,11 @@ of_pci_get_slot_power_limit(struct device_node *node, > > return 0; > > } > > > > +static inline bool of_pci_bridge_d3(struct device_node *node) > > +{ > > + return false; > > +} > > + > > static inline int pci_set_of_node(struct pci_dev *dev) { return 0; } > > static inline void pci_release_of_node(struct pci_dev *dev) { } > > static inline void pci_set_bus_of_node(struct pci_bus *bus) { } > > > > --- > > base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d > > change-id: 20240131-pcie-qcom-bridge-b6802a9770a3 > > > > Best regards, > > -- > > Manivannan Sadhasivam > > -- மணிவண்ணன் சதாசிவம்