Message ID | 20240214-pcie-qcom-bridge-v3-1-3a713bbc1fd7@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-65156-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1151428dyb; Wed, 14 Feb 2024 03:46:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFt9wL3cEK1vMSoRst5dfMZcGNrLj+Dq0gLbvdIUDUr0IPWnCl36AMJYqqNnKYHY0cHfYqWQAEcCpaY2P4xqdkabIISg== X-Google-Smtp-Source: AGHT+IFX1pPot3cNHZC9WQwQstjUbk5ayqY/VNMDAW4Rc7n/eKCE96HWk6MMF7OjDQj6Vnrvf/9O X-Received: by 2002:ac8:5d8b:0:b0:42d:adef:bf68 with SMTP id d11-20020ac85d8b000000b0042dadefbf68mr2252785qtx.63.1707911208789; Wed, 14 Feb 2024 03:46:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707911208; cv=pass; d=google.com; s=arc-20160816; b=fdqRuKfoZhFL1WF9fQx7+nIIbGsAdyy3fy1N8vXyLJP0sEIg6znHXCFxxd9Mp+UTVS 4/YMIFfihiKza3oLuUqjbq/5/hO61UBu8QxbwWdX5B+b3/wpBoINndX93K0S+ZUd/LwK B0eioKEZqYWQAYcf2NkRssHjEPcjPBwqufXW5HLpWO8N92eiGhNuxL4zM0Ya2EqtEZnK zO4ECVE4ppS9jtfADzVCxVziB8Dc8i7/DaMhRRffGXOfQLxRWkXwA1PNd2CCk97qLNcg 7USVOZEJhGyIEfnzIxRLjDkJjtS2+/dUsMWstWbPzkBOtmzpSmMvndUz8l3/2yLR4TEj eTBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=stU+R4KG+NyQbt4ql0bZhshhmz0bDBsi5UUfG+CKyak=; fh=7giD6Xj+jkirm3LyfsJr+4lmRUr+4ayLZSzSqNHtbPI=; b=PwnBNpU5gwPCusDbgv5l1UNeTuKFgNSA/KHMES8Fi8B6lyboz60Mq0SBy04NMzcROz vrzi9uBMneI3z11E/wGAr2FW8xo3rgB+xjYvA91O4UtqoY2CaxnV+SZceSiYhrrwpOgT QYqvzk2VJW7S2GOQ2/K761GJvIAecR6Z1TXzkiwWJEdJHotayKzRfLURZ3vLIcqHi1uo 1/I8eyE5x+/2pXOlBjWvYvYIWLLWx9gG4dh4QPRDjj6mHq7Lg8zHaGLySrJr1STsPzt1 GbyrXG2NBwzBy5ggSZ3kKkKQr8Yg1EGhT/1RRUBG9iljPfH2KTmppVuL15OtSb/SRaYT N66w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mgi9IlDT; 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-65156-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65156-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=2; AJvYcCVTr4YlmVKiT/CMfzBmfmcMlvHt3qG7N9Y7QHbicE+u6oAN17uDY5bOzNkFLLdvgKmgJfZCU8FvoIFdYtM98/flSLdePA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y13-20020a05622a004d00b0042db40d6934si2748341qtw.91.2024.02.14.03.46.48 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:46:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65156-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mgi9IlDT; 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-65156-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65156-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 202DB1C22A85 for <ouuuleilei@gmail.com>; Wed, 14 Feb 2024 11:46:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C9BB1BC3A; Wed, 14 Feb 2024 11:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Mgi9IlDT" Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 B50B41B962 for <linux-kernel@vger.kernel.org>; Wed, 14 Feb 2024 11:46:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707911177; cv=none; b=KIMaA8bl8rTSWKjecFup07Fr2ZdSy9FMz8Y+oTmY/xu/3CmfQnfo+j6zSc6X4NMX5FDAmKBR/hdFQ/PNy0e2FM7u6E26XTlFZUXFllHxsdKdIQoGET0zN4DnlvIP8PKCDBHx4RjadCKyRz/SEBuS6UKVMS7md32z6mFGBw3XUbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707911177; c=relaxed/simple; bh=iaFhux7+ftCQreqL4+9rxGj5oghyh3WmJyVki73C+Bc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=Z19KWh8/Ra28qFubH/YiaekMzjB581wkOr1g+9lLcaaAdnaFEyi+Qffuu7RZu0qH/sotElYId/NJ9IUB5vLUKYNCtU2OF/JsbatnfC1iHN42DEy3pgWkZ1fKD3+MsUkm6bGAJtY6604CPfUGCuryHuy9VUH8Z2QUem1co0QrqQg= 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=Mgi9IlDT; arc=none smtp.client-ip=209.85.210.44 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-ot1-f44.google.com with SMTP id 46e09a7af769-6e2ddc5f31eso1895026a34.0 for <linux-kernel@vger.kernel.org>; Wed, 14 Feb 2024 03:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707911175; x=1708515975; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=stU+R4KG+NyQbt4ql0bZhshhmz0bDBsi5UUfG+CKyak=; b=Mgi9IlDThPJqe5w4Qu/TPIQC9vhvcSB0iPqI1PeOCHDncgzMm+uoXA8YgU8fX5fCTA 9l1IBhnL2VxVPR97Ea/vW+0C+/zRdKWBk7WOFACsdGmLzVXh5gmVjALxJrJz6zRsmHWP GQW3l8j3FOVdixcvlhTZvXMQ96sV7D7qno3CcXMzqSm2asfEMS4OhY3y1/EajTnmOiM1 G7qvQp9L3ZLPSoYLTmeGJucVk5FN7Nj5yWriW/wOcjeiVVOjBrVkj7xEBvrpeo90lb26 buIHoJRGknozEYAeySNURmGUInZ6US0IeTYwMBYzMucFvGPH/p41+boRkXY8BkVjaMQP hCxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707911175; x=1708515975; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=stU+R4KG+NyQbt4ql0bZhshhmz0bDBsi5UUfG+CKyak=; b=sWPJiN5YA9EM5UUrK4RPU4WOT+L20g70mxLr5J+60PcIuxss4PCTC2A6RqMiTbFOJl CPuUX94zytM5Y71iMC7tY/wKJ45wPK5OCcsD9OtmhSNfEaT4gCj6iT9ouXcOr56LIJty 8ReIAV7QTsHwoGyoBhHPejTKsHBcUm8vFG1X+VSx8G/ZhbiIb6SHFEowWvWXUU6EzgSF 5EfIJMXk8jbaSp386iuOg1JWFKjXip1HAP5V1TDpn5qzZ8p1qLG0SE4Gar4hLMTBQ3G/ VvqEmQvgyG33mrgmrX1r7smtngjSweajDw8rMqfTWorApAoDXXYPDpxbEjyDINEITmTf 1SSw== X-Forwarded-Encrypted: i=1; AJvYcCUmJt5FJ7myXj9ShnhLadcmO5f9Fg/jZ9ko97LStY14SWHyy2/x0iC0t26dISoN/24aWfHIxpTpWtvQmTISNo36aNwvFqhc5UDhhMKc X-Gm-Message-State: AOJu0YyJq7MwakIi6vYJJH08wvHKaanfzHQPT2vd1Va718I6KfCcxI5j l//CcmvfhmMQ7Fwd99laM33eq48paMrq8t7URN0/K5XDoclVzzJjvUGblUFX0g== X-Received: by 2002:a05:6358:b00d:b0:176:40d5:2bd5 with SMTP id l13-20020a056358b00d00b0017640d52bd5mr2310044rwn.6.1707911174688; Wed, 14 Feb 2024 03:46:14 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXT9B6A1cp+QOKPZkvk+EwZp++YLu3rcZe5XHi3LJPDwegVbg5YoQNUr/IRQzOR4W/UNqypDIlwKgEsy1WfzcUeEUUDoNmPd6wFJNhdGMVJ7vDtUmaogh1BNAj+ebpQ8Uz6qxK4NBfQLVKH1AC3ef/HMZDk5yj43xW9zn+yJ7d37oM1EZPpmNDamtf33G8ZhlQEJVgFvbKLmMe5MY7ZGD8XSFXYmPV93t8Q8kQJH/8Lgkf89yLGVqEMFpZQvLjvBAubk84IpYZPqNvH5WMoHre1Pn0kDY+PTdYAz/LLFwynQKg9QZ4FdmfB3HBbFWIK1LQrHqv19JjObAfB3JKFnzrc+Mzzsrwf4mTr1FJsrRI+ZjUgLnDxeZNlbfe/GRFNhy49k57ljD0YhGwLvgsNDY51wmEBi8AraTrrT4h7JSMb2LKFLQDO43LIhw== Received: from [127.0.1.1] ([103.28.246.124]) by smtp.gmail.com with ESMTPSA id y189-20020a62cec6000000b006e0d1e6036bsm6674283pfg.129.2024.02.14.03.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:46:14 -0800 (PST) From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Date: Wed, 14 Feb 2024 17:16:09 +0530 Subject: [PATCH v3] PCI: Add D3 support for PCI bridges in DT based platforms Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240214-pcie-qcom-bridge-v3-1-3a713bbc1fd7@linaro.org> X-B4-Tracking: v=1; b=H4sIAACozGUC/3WOQQ6CMBBFr2K6tqbTIi2uvIdh0dICkyjF1hAN4 e4WdIEJLv+fvPdnJNEFdJGcdiMJbsCIvktB7HekanXXOIo2ZcIZzxgIoH2Fjt4rf6MmoE13kyv GdSEl04IkrA+uxueivJQptxgfPryWhQHm9iPjbEM2AGW0dk4W0tTmyOT5ip0O/uBDM8u/JP9DZ rmVUhVK5BVbk/MfA19tQ7Zh4BRoYW1ujQGj4Ge7nKbpDWmfCRotAQAA To: Bjorn Helgaas <bhelgaas@google.com>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Lorenzo Pieralisi <lpieralisi@kernel.org>, =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= <kw@linux.com>, Rob Herring <robh@kernel.org> Cc: Lukas Wunner <lukas@wunner.de>, Mika Westerberg <mika.westerberg@linux.intel.com>, quic_krichai@quicinc.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3809; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=iaFhux7+ftCQreqL4+9rxGj5oghyh3WmJyVki73C+Bc=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBlzKgCyomV+XS6Wz5pwRsl7Pq4qvnDSmu3D+FVx gggOTH/97qJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZcyoAgAKCRBVnxHm/pHO 9R9nB/9dmzL8gNylVCHcQQfkMcfyzrnKwuvQ6ASSQ3DXHhdDWw08KgwxD3Cfm2G0GLZo08Mj+me hoIqviztRLCA/stpX3XDSqhoOlbECFUuWumoXrdjWd6JskL5rhljSyu7ol51qEkD/9NpmfolqIJ S+Al6CQJP6OluE7WZI1vtTCMHLJ+cF/bicicceBSerjNdIh6/ziBvs9yhytrODKmS3bvBvN5bwV ogNqJLvo5Qxb2MDslQNdwKQZhF5/JlONMqQbmB+5RTY/ltCESJ7kIYq/u9xwBBm3OucAMZGPYZJ VGflmQpHGohZagBRbBwV2grEKa5LnPHdZ831PQWQD0vzUcf/ X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790864058349569203 X-GMAIL-MSGID: 1790874703831996832 |
Series |
[v3] PCI: Add D3 support for PCI bridges in DT based platforms
|
|
Commit Message
Manivannan Sadhasivam
Feb. 14, 2024, 11:46 a.m. UTC
Currently, PCI core will enable D3 support for PCI bridges only when the
following conditions are met:
1. Platform is ACPI based
2. Thunderbolt controller is used
3. pcie_port_pm=force passed in cmdline
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.
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
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
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(+)
---
base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
change-id: 20240131-pcie-qcom-bridge-b6802a9770a3
Best regards,
Comments
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 <manivannan.sadhasivam@linaro.org> > > --- > > 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 <manivannan.sadhasivam@linaro.org> > >
On Wed, Feb 21, 2024 at 10:49:58AM +0530, Manivannan Sadhasivam wrote: > 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 ;) So it sounds like this is supposed to cover two cases: 1) D3hot doesn't work per spec. This sounds like a hardware defect in the device that should be a quirk based on Vendor/Device ID, not something in DT. I don't actually know if this is common, although there are several existing quirks that mention issues with D3. 2) The platform doesn't support putting the bridge in D3cold and back to D0. I don't understand this either because I assumed DT would describe *hardware*, and "supports-d3" might imply the presence of hardware power control, but doesn't tell us how to operate it, and it must be up to a native driver to know how to do it. These are two vastly different scenarios, and I would really like to untangle them so they aren't conflated. I see that you're extending platform_pci_bridge_d3(), which apparently has that conflation baked into it already, but my personal experience is that this is really hard to maintain. > > > 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 > [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 <manivannan.sadhasivam@linaro.org> > > > --- > > > 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 <manivannan.sadhasivam@linaro.org> > > > > > -- > மணிவண்ணன் சதாசிவம்
On Wed, Feb 21, 2024 at 12:20:00PM -0600, Bjorn Helgaas wrote: > On Wed, Feb 21, 2024 at 10:49:58AM +0530, Manivannan Sadhasivam wrote: > > 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 ;) > > So it sounds like this is supposed to cover two cases: > > 1) D3hot doesn't work per spec. This sounds like a hardware > defect in the device that should be a quirk based on > Vendor/Device ID, not something in DT. I don't actually know if > this is common, although there are several existing quirks that > mention issues with D3. > I'd love to use quirks if we started from that. But right now, quirks are not used and there are multiple checks based on various factors [1], including relying on ACPI. So that's the reason I went with DT based approach. If quirks has to be used now, then it has to be used for both ACPI and DT based platforms. For DT it won't be an issue since nobody bothered until now, but for ACPI, we need to add quirks for all the bridges in the wild which is not feasible. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pci.c#n3116 > 2) The platform doesn't support putting the bridge in D3cold and > back to D0. I don't understand this either because I assumed DT > would describe *hardware*, and "supports-d3" might imply the > presence of hardware power control, but doesn't tell us how to > operate it, and it must be up to a native driver to know how to > do it. > "supports-d3" implies that both D3hot and D3cold works as in the spec and the OS can handle it appropriately. If this is absent, then OS should not transition the bridge to any of the D3 states. I don't understand what is the confusion here. This is similar to what we already have for ACPI (whether or not it is correct is another topic). > These are two vastly different scenarios, and I would really like to > untangle them so they aren't conflated. I see that you're extending > platform_pci_bridge_d3(), which apparently has that conflation baked > into it already, but my personal experience is that this is really > hard to maintain. > I do agree that it is not in a good shape, but there is no better solution other than making use of the DT property. If you have any better idea, please suggest. - Mani > > > > 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 > > > [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 <manivannan.sadhasivam@linaro.org> > > > > --- > > > > 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 <manivannan.sadhasivam@linaro.org> > > > > > > > > -- > > மணிவண்ணன் சதாசிவம்
On Thu, Feb 22, 2024 at 09:36:29AM +0530, Manivannan Sadhasivam wrote: > On Wed, Feb 21, 2024 at 12:20:00PM -0600, Bjorn Helgaas wrote: > > On Wed, Feb 21, 2024 at 10:49:58AM +0530, Manivannan Sadhasivam wrote: > > > 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 ;) > > > > So it sounds like this is supposed to cover two cases: > > > > 1) D3hot doesn't work per spec. This sounds like a hardware > > defect in the device that should be a quirk based on > > Vendor/Device ID, not something in DT. I don't actually know if > > this is common, although there are several existing quirks that > > mention issues with D3. > > > > I'd love to use quirks if we started from that. But right now, quirks are not > used and there are multiple checks based on various factors [1], including > relying on ACPI. So that's the reason I went with DT based approach. > > If quirks has to be used now, then it has to be used for both ACPI and DT based > platforms. For DT it won't be an issue since nobody bothered until now, but for > ACPI, we need to add quirks for all the bridges in the wild which is not > feasible. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pci.c#n3116 > > > 2) The platform doesn't support putting the bridge in D3cold and > > back to D0. I don't understand this either because I assumed DT > > would describe *hardware*, and "supports-d3" might imply the > > presence of hardware power control, but doesn't tell us how to > > operate it, and it must be up to a native driver to know how to > > do it. > > "supports-d3" implies that both D3hot and D3cold works as in the > spec and the OS can handle it appropriately. If this is absent, then > OS should not transition the bridge to any of the D3 states. I don't > understand what is the confusion here. This is similar to what we > already have for ACPI (whether or not it is correct is another > topic). What does "the OS can handle it appropriately" mean? Whatever it means, it sounds like a property of the OS, not a property of the device. I don't know what "D3cold works as in the spec" means, either. The spec says how D3cold affects internal device state, but it doesn't say anything about how to put devices in D3cold or back in D0. > > These are two vastly different scenarios, and I would really like to > > untangle them so they aren't conflated. I see that you're extending > > platform_pci_bridge_d3(), which apparently has that conflation baked > > into it already, but my personal experience is that this is really > > hard to maintain. > > I do agree that it is not in a good shape, but there is no better > solution other than making use of the DT property. If you have any > better idea, please suggest. The longer this goes on the worse shape we are in because we're always adding new special cases. The fundamental problem I have is that "supports-d3" doesn't say anything specific other than "current Linux can put the device in D3hot or D3cold and get it back out again". I think DT should tell us characteristics of the device or the platform, e.g., "PMCSR doesn't work to enter/leave D3hot on this device" or "regulator X controls main power to the device to enter/leave D3cold". But right now it sounds like a mixture of "PMCSR works correctly to enter/leave D3hot" and "some unspecified software can control main power to this device". Putting devices in D3cold and back in D0 needs some kind of platform support like ACPI methods or a native power management driver that knows how to control power on a specific platform. That's completely different from D3hot, where the PCI spec tells us all we need to know. > > > > > 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 > > > > > [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 <manivannan.sadhasivam@linaro.org> > > > > > --- > > > > > 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 <manivannan.sadhasivam@linaro.org> > > > > > > > > > > > -- > > > மணிவண்ணன் சதாசிவம் > > -- > மணிவண்ணன் சதாசிவம்
On Mon, Feb 26, 2024 at 05:39:30PM -0600, Bjorn Helgaas wrote: > On Thu, Feb 22, 2024 at 09:36:29AM +0530, Manivannan Sadhasivam wrote: > > On Wed, Feb 21, 2024 at 12:20:00PM -0600, Bjorn Helgaas wrote: > > > On Wed, Feb 21, 2024 at 10:49:58AM +0530, Manivannan Sadhasivam wrote: > > > > 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 ;) > > > > > > So it sounds like this is supposed to cover two cases: > > > > > > 1) D3hot doesn't work per spec. This sounds like a hardware > > > defect in the device that should be a quirk based on > > > Vendor/Device ID, not something in DT. I don't actually know if > > > this is common, although there are several existing quirks that > > > mention issues with D3. > > > > > > > I'd love to use quirks if we started from that. But right now, quirks are not > > used and there are multiple checks based on various factors [1], including > > relying on ACPI. So that's the reason I went with DT based approach. > > > > If quirks has to be used now, then it has to be used for both ACPI and DT based > > platforms. For DT it won't be an issue since nobody bothered until now, but for > > ACPI, we need to add quirks for all the bridges in the wild which is not > > feasible. > > > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pci.c#n3116 > > > > > 2) The platform doesn't support putting the bridge in D3cold and > > > back to D0. I don't understand this either because I assumed DT > > > would describe *hardware*, and "supports-d3" might imply the > > > presence of hardware power control, but doesn't tell us how to > > > operate it, and it must be up to a native driver to know how to > > > do it. > > > > "supports-d3" implies that both D3hot and D3cold works as in the > > spec and the OS can handle it appropriately. If this is absent, then > > OS should not transition the bridge to any of the D3 states. I don't > > understand what is the confusion here. This is similar to what we > > already have for ACPI (whether or not it is correct is another > > topic). > > What does "the OS can handle it appropriately" mean? Whatever it > means, it sounds like a property of the OS, not a property of the > device. > "appropiately" means as per the PCIe spec. > I don't know what "D3cold works as in the spec" means, either. The > spec says how D3cold affects internal device state, but it doesn't say > anything about how to put devices in D3cold or back in D0. > > > > These are two vastly different scenarios, and I would really like to > > > untangle them so they aren't conflated. I see that you're extending > > > platform_pci_bridge_d3(), which apparently has that conflation baked > > > into it already, but my personal experience is that this is really > > > hard to maintain. > > > > I do agree that it is not in a good shape, but there is no better > > solution other than making use of the DT property. If you have any > > better idea, please suggest. > > The longer this goes on the worse shape we are in because we're always > adding new special cases. > > The fundamental problem I have is that "supports-d3" doesn't say > anything specific other than "current Linux can put the device in > D3hot or D3cold and get it back out again". I think DT should tell us > characteristics of the device or the platform, e.g., "PMCSR doesn't > work to enter/leave D3hot on this device" or "regulator X controls > main power to the device to enter/leave D3cold". > > But right now it sounds like a mixture of "PMCSR works correctly to > enter/leave D3hot" and "some unspecified software can control main > power to this device". > > Putting devices in D3cold and back in D0 needs some kind of platform > support like ACPI methods or a native power management driver that > knows how to control power on a specific platform. That's completely > different from D3hot, where the PCI spec tells us all we need to know. > Ok, I got the issue. TBH, I added the device tree property based on the existing quirks for the ACPI devices. But none of the DT based platforms I'm aware of (even the legacy Qcom MSM8996 chipset released in early 2016) doesn't have any issue with D3hot. But I'm just nervous to assume it is the case for all the DT based platforms in the wild. But to proceed further, what is your preference? Should we ammend the DT property to make it explicit that the propery only focuses on the D3hot capability of the bridge and it works as per the spec (PMCSR) or bite the bullet and enable D3hot for all the non-ACPI platforms? We can add quirks for the bridges later on if we happen to receive any bug report. - Mani > > > > > > 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 > > > > > > > [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 <manivannan.sadhasivam@linaro.org> > > > > > > --- > > > > > > 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 <manivannan.sadhasivam@linaro.org> > > > > > > > > > > > > > > -- > > > > மணிவண்ணன் சதாசிவம் > > > > -- > > மணிவண்ணன் சதாசிவம்
On Tue, Feb 27, 2024 at 01:00:57PM +0530, Manivannan Sadhasivam wrote: > On Mon, Feb 26, 2024 at 05:39:30PM -0600, Bjorn Helgaas wrote: > > On Thu, Feb 22, 2024 at 09:36:29AM +0530, Manivannan Sadhasivam wrote: > > > On Wed, Feb 21, 2024 at 12:20:00PM -0600, Bjorn Helgaas wrote: > > > > On Wed, Feb 21, 2024 at 10:49:58AM +0530, Manivannan Sadhasivam wrote: > > > > > 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 ;) > > > > > > > > So it sounds like this is supposed to cover two cases: > > > > > > > > 1) D3hot doesn't work per spec. This sounds like a hardware > > > > defect in the device that should be a quirk based on > > > > Vendor/Device ID, not something in DT. I don't actually know if > > > > this is common, although there are several existing quirks that > > > > mention issues with D3. > > > > > > > > > > I'd love to use quirks if we started from that. But right now, quirks are not > > > used and there are multiple checks based on various factors [1], including > > > relying on ACPI. So that's the reason I went with DT based approach. > > > > > > If quirks has to be used now, then it has to be used for both ACPI and DT based > > > platforms. For DT it won't be an issue since nobody bothered until now, but for > > > ACPI, we need to add quirks for all the bridges in the wild which is not > > > feasible. > > > > > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pci.c#n3116 > > > > > > > 2) The platform doesn't support putting the bridge in D3cold and > > > > back to D0. I don't understand this either because I assumed DT > > > > would describe *hardware*, and "supports-d3" might imply the > > > > presence of hardware power control, but doesn't tell us how to > > > > operate it, and it must be up to a native driver to know how to > > > > do it. > > > > > > "supports-d3" implies that both D3hot and D3cold works as in the > > > spec and the OS can handle it appropriately. If this is absent, then > > > OS should not transition the bridge to any of the D3 states. I don't > > > understand what is the confusion here. This is similar to what we > > > already have for ACPI (whether or not it is correct is another > > > topic). > > > > What does "the OS can handle it appropriately" mean? Whatever it > > means, it sounds like a property of the OS, not a property of the > > device. > > "appropiately" means as per the PCIe spec. > > > I don't know what "D3cold works as in the spec" means, either. The > > spec says how D3cold affects internal device state, but it doesn't say > > anything about how to put devices in D3cold or back in D0. > > > > > > These are two vastly different scenarios, and I would really like to > > > > untangle them so they aren't conflated. I see that you're extending > > > > platform_pci_bridge_d3(), which apparently has that conflation baked > > > > into it already, but my personal experience is that this is really > > > > hard to maintain. > > > > > > I do agree that it is not in a good shape, but there is no better > > > solution other than making use of the DT property. If you have any > > > better idea, please suggest. > > > > The longer this goes on the worse shape we are in because we're always > > adding new special cases. > > > > The fundamental problem I have is that "supports-d3" doesn't say > > anything specific other than "current Linux can put the device in > > D3hot or D3cold and get it back out again". I think DT should tell us > > characteristics of the device or the platform, e.g., "PMCSR doesn't > > work to enter/leave D3hot on this device" or "regulator X controls > > main power to the device to enter/leave D3cold". > > > > But right now it sounds like a mixture of "PMCSR works correctly to > > enter/leave D3hot" and "some unspecified software can control main > > power to this device". > > > > Putting devices in D3cold and back in D0 needs some kind of platform > > support like ACPI methods or a native power management driver that > > knows how to control power on a specific platform. That's completely > > different from D3hot, where the PCI spec tells us all we need to know. > > Ok, I got the issue. TBH, I added the device tree property based on > the existing quirks for the ACPI devices. But none of the DT based > platforms I'm aware of (even the legacy Qcom MSM8996 chipset > released in early 2016) doesn't have any issue with D3hot. But I'm > just nervous to assume it is the case for all the DT based platforms > in the wild. > > But to proceed further, what is your preference? Should we ammend > the DT property to make it explicit that the propery only focuses on > the D3hot capability of the bridge and it works as per the spec > (PMCSR) or bite the bullet and enable D3hot for all the non-ACPI > platforms? > > We can add quirks for the bridges later on if we happen to receive > any bug report. I would assume all devices support D3hot via PMCSR per spec. We can add quirks if we discover something that doesn't. If we add annotations that "this device works correctly", we're digging a hole for ourselves because it's impossible to remove those annotations and they complicate all future maintenance. Bjorn
On Tue, Feb 27, 2024 at 10:25:35AM -0600, Bjorn Helgaas wrote: [...] > > Ok, I got the issue. TBH, I added the device tree property based on > > the existing quirks for the ACPI devices. But none of the DT based > > platforms I'm aware of (even the legacy Qcom MSM8996 chipset > > released in early 2016) doesn't have any issue with D3hot. But I'm > > just nervous to assume it is the case for all the DT based platforms > > in the wild. > > > > But to proceed further, what is your preference? Should we ammend > > the DT property to make it explicit that the propery only focuses on > > the D3hot capability of the bridge and it works as per the spec > > (PMCSR) or bite the bullet and enable D3hot for all the non-ACPI > > platforms? > > > > We can add quirks for the bridges later on if we happen to receive > > any bug report. > > I would assume all devices support D3hot via PMCSR per spec. We can > add quirks if we discover something that doesn't. > When you say "all devices", are you referring to bridges in DT platforms or the bridges across all platforms? - Mani > If we add annotations that "this device works correctly", we're > digging a hole for ourselves because it's impossible to remove those > annotations and they complicate all future maintenance. > > Bjorn
On Tue, Feb 27, 2024 at 10:38:40PM +0530, Manivannan Sadhasivam wrote: > On Tue, Feb 27, 2024 at 10:25:35AM -0600, Bjorn Helgaas wrote: > > [...] > > > > Ok, I got the issue. TBH, I added the device tree property based on > > > the existing quirks for the ACPI devices. But none of the DT based > > > platforms I'm aware of (even the legacy Qcom MSM8996 chipset > > > released in early 2016) doesn't have any issue with D3hot. But I'm > > > just nervous to assume it is the case for all the DT based platforms > > > in the wild. > > > > > > But to proceed further, what is your preference? Should we ammend > > > the DT property to make it explicit that the propery only focuses on > > > the D3hot capability of the bridge and it works as per the spec > > > (PMCSR) or bite the bullet and enable D3hot for all the non-ACPI > > > platforms? > > > > > > We can add quirks for the bridges later on if we happen to receive > > > any bug report. > > > > I would assume all devices support D3hot via PMCSR per spec. We can > > add quirks if we discover something that doesn't. > > When you say "all devices", are you referring to bridges in DT > platforms or the bridges across all platforms? This patch is only concerned with DT, so that's what I'm commenting on here. I don't know how to untangle the question of ACPI systems. This patch affects platform_pci_bridge_d3(), so just based on the "platform" in the function name, I would expect it to be concerned with the D3cold case and whether the platform supports controlling main power. It looks like this patch says "we can put devices in D3cold if DT has 'supports-d3'". But I don't know how to make sense of that because that requires (a) platform hardware to control main power and (b) software that knows how to use that hardware. Wouldn't this require a little more DT description, like "regulator X controls main power for this bridge"? And then an OS would only be able to actually use D3cold if it knows how to *operate* the regulator, and it doesn't seem like DT could answer that. > > If we add annotations that "this device works correctly", we're > > digging a hole for ourselves because it's impossible to remove those > > annotations and they complicate all future maintenance. > > > > Bjorn > > -- > மணிவண்ணன் சதாசிவம்
On Tue, Feb 27, 2024 at 11:37:05AM -0600, Bjorn Helgaas wrote: > On Tue, Feb 27, 2024 at 10:38:40PM +0530, Manivannan Sadhasivam wrote: > > On Tue, Feb 27, 2024 at 10:25:35AM -0600, Bjorn Helgaas wrote: > > > > [...] > > > > > > Ok, I got the issue. TBH, I added the device tree property based on > > > > the existing quirks for the ACPI devices. But none of the DT based > > > > platforms I'm aware of (even the legacy Qcom MSM8996 chipset > > > > released in early 2016) doesn't have any issue with D3hot. But I'm > > > > just nervous to assume it is the case for all the DT based platforms > > > > in the wild. > > > > > > > > But to proceed further, what is your preference? Should we ammend > > > > the DT property to make it explicit that the propery only focuses on > > > > the D3hot capability of the bridge and it works as per the spec > > > > (PMCSR) or bite the bullet and enable D3hot for all the non-ACPI > > > > platforms? > > > > > > > > We can add quirks for the bridges later on if we happen to receive > > > > any bug report. > > > > > > I would assume all devices support D3hot via PMCSR per spec. We can > > > add quirks if we discover something that doesn't. > > > > When you say "all devices", are you referring to bridges in DT > > platforms or the bridges across all platforms? > > This patch is only concerned with DT, so that's what I'm commenting on > here. I don't know how to untangle the question of ACPI systems. > Ok, I just wanted to confirm. > This patch affects platform_pci_bridge_d3(), so just based on the > "platform" in the function name, I would expect it to be concerned > with the D3cold case and whether the platform supports controlling > main power. > > It looks like this patch says "we can put devices in D3cold if DT has > 'supports-d3'". But I don't know how to make sense of that because > that requires (a) platform hardware to control main power and (b) > software that knows how to use that hardware. Wouldn't this require a > little more DT description, like "regulator X controls main power for > this bridge"? And then an OS would only be able to actually use > D3cold if it knows how to *operate* the regulator, and it doesn't seem > like DT could answer that. > Fair point. And for most of the DT based platforms, there is no dedicated power supply for the bridge described in DT. So transitioning the bridge to D3cold is not entirely possible in the OS. Since we concluded that enabling D3hot for all bridges in DT platforms is the way to go, I'll drop supporting the DT property in next version. I'll also remove it from the binding. - Mani
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) { }