From patchwork Wed Feb 14 11:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 200927 Return-Path: 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 (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 ; 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 ; 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 ; 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 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 , Bjorn Andersson , Konrad Dybcio , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring Cc: Lukas Wunner , Mika Westerberg , quic_krichai@quicinc.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam 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 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 --- 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, 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) { }