From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CA4A36828E for ; Tue, 16 Dec 2025 12:52:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765889523; cv=none; b=PuWYqjVA8EFViq4v8q3T/fhTFP9LRWOna0asx36mvuTHtsiVVFj+udg0eZ1gmU8TsSPQ1v8XkrWQZZQPkSe1HrRQEmSwqIkHiXYq9kV7m35zwBAWW6vick/NSxeRpAUqymrHgGneADVtRwngRlH23beH5IgB17i7XCriOvW0wmw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765889523; c=relaxed/simple; bh=jEohyugUt2xltGKMjwJH/v02rbokHrSkGszVOtUh1RI=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=XEwmaqef/gIH/7o/nD+UpovRXQASNq+qMGvTGJXL5q2lY4CcETW0vux5HbLNFUtefvRxgCeSF9Ti+LdOMxv487ZP6PrkSGOGUdUNDXimo0l5qhJr2kM8iB5u/BPg37f6dYYhmiwxwVjPG+ePKj9gBVRw+aNXK8hLMFRxzlrSjM8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=MVH6nD/3; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=hJuShlpH; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="MVH6nD/3"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="hJuShlpH" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BGBvDkM2810486 for ; Tue, 16 Dec 2025 12:51:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=V4gvJGhNuoZx4aXPrkf3CJ Tlv/0fPKbsYo+ci3xMIQ8=; b=MVH6nD/3ET6SmBzRPLuSWiCmia6j0FOk+Mq6l1 VtINLCmhzeyIaNbGEJaFil2mpm/wQ7hZbgKv96RlvTH62LMUaAVeGDiVAgCbl1wq oCTpa9ZZAoReGxsgh9OMrgTnyU9t+8L/a1VWQym/EhOc4RIFx4GpxhLbQe6NmbFo hWeKGZftpWD6yF3jthqbkU6SpLybsUI579MMQqfQweJcqLxYnHJTqOMAG6DDp+bV xOLF1ozx+gAT7WHJKlbZPGeSRn0Dc1QBxuznUbeLT5Dwapa7zGbUC+XB2DbiIQLQ 99TzGxJeHsPT9UcCevvGBr9fHyjicSqGIsMC8BqeclTxwcXw== Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4b32gasdfe-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 16 Dec 2025 12:51:59 +0000 (GMT) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-7a99a5f77e0so7502285b3a.2 for ; Tue, 16 Dec 2025 04:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1765889518; x=1766494318; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=V4gvJGhNuoZx4aXPrkf3CJTlv/0fPKbsYo+ci3xMIQ8=; b=hJuShlpH37zMRZEl4M5XdTGQXF62LGB6NvmBFQkAxj/JSrZxWwxRbL1h0PKWPajnaA sHleX7hW1mudd/byJSCk/XqthVCfuzsI/orrfW/PhE7fPs/Cx1a7eDQM9mU4nnjh75H4 5mpnbX/naGWOINBqL2RKHcQp6TvFwX4paRVfFJkDJcPIo1Rf2eGaKQvaiTUOZccp8gxW J+ettQ0rlFUGKoQ/aTibYhf+s0g+nIY+O1Xwi6kiAoiaPYJaNXl5iiSDmYaet3xVuK7e T5hvPezpBPklgyE5ixXLAcj4zC5PVes95Q8+eMShA4mfaVDwXJokyWJM5fXcOAe2IyNl UbHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765889518; x=1766494318; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=V4gvJGhNuoZx4aXPrkf3CJTlv/0fPKbsYo+ci3xMIQ8=; b=fhqoGF/2S1kAFIAiYHTC0bx8KpEo7+fcjbj/Hi6qHpsurf8AvKB6KTd6lf1gJiDPQY JJ0SluJghGuAdrqa+09tske7GCRVVZBllHcIOCEUDkFq+alZLjQvYgNdjrMGi60+SpEA hRfiapBPJlXw2VYg1oDn4+y1QXlCZx8z+VpZqWsuMbmuzVou9o9faZLc1Gp8MyyCLy7f /dX95aJXovF7+3MKMVV205moV3d3nQCzTe9VUG7tS/so2vNWABh54JsxhSAcyonI8CKQ 5Kv8QNxZfRGWmCzk/NslLq5EiihdT0+Z+QGClobC6Awph7Ca3G6bbjsyoCVj1EN+CjCa QD8w== X-Forwarded-Encrypted: i=1; AJvYcCXKCSRgimYEGgXPYXCW/EMLdkqr8Ihwr8jZqFZ/3iUO0+p7hzVTtmUq9rZl4AOfMpd40hVg0Qy2ZmXdZbw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3hj5/N+c5gJ4IekVlOwCa6AYfHRJctnxwXT0m0Nxgwze8Gpsc Vq9yaKcubMDBdaVmHRTfG3ksvPXUZOmJWtM9vbHbc2x2frHRaljhwnc3+3Zr92+61TlAKSRvkr+ neyytzWcgl0dq6awpRH3oRY/GcmyoLu9IHxD3AoPiRCUNUTG4TUT+QokjvOv2ArSu3gOctbsn+7 Q= X-Gm-Gg: AY/fxX7vwsu2A/4iG33lVT+S14i0ZUPm4lC+zrvkUTCYsjSZsJ2lyTRsl5jcx0Hk3Wf 0IVG0+o1Ty9oCpGb/1e3yjB4jP+XSpiAByVOznP4fOgIb08DPkclcqwpt5e3H0vnINHin0y3/JL n+pESB6sD4IrtIxyf1FVJj7Yb7aPZpz91Xr+KaGRTfx0eOyaP9bNpxuhBKvJ9vVGivnjuw57qHv xjLzl2cUyo0+AwUV5beA3EwEtBba56o891Bva7EOBWJwW5u4O1ySIK5cpi3tEs9TcCoNjqEiofa j21rjsKVdcTKhnVwOHQvN9jP/ptOjqx8zhr8osRAccrGNmXHgoPEqMpEAhvzYxz+cuy15kYkk/K n2zgFxLXzURq5KUzPu7CGIpicltOHZuzrvozwHRN2uQ== X-Received: by 2002:a05:6a00:8016:b0:7aa:bc48:abbb with SMTP id d2e1a72fcca58-7f66753ea07mr14129562b3a.3.1765889518210; Tue, 16 Dec 2025 04:51:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnw0nq+20BiU/H2/8max6+ztNgOlbQQNUoPUNmYAiLOQL26Oahp2+NqahZ4UXkFI52v2vvXw== X-Received: by 2002:a05:6a00:8016:b0:7aa:bc48:abbb with SMTP id d2e1a72fcca58-7f66753ea07mr14129532b3a.3.1765889517697; Tue, 16 Dec 2025 04:51:57 -0800 (PST) Received: from [192.168.1.102] ([117.193.213.190]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f5ab7d87e8sm13634362b3a.25.2025.12.16.04.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Dec 2025 04:51:57 -0800 (PST) From: Manivannan Sadhasivam Subject: [PATCH v2 0/5] PCI/pwrctrl: Major rework to integrate pwrctrl devices with controller drivers Date: Tue, 16 Dec 2025 18:21:42 +0530 Message-Id: <20251216-pci-pwrctrl-rework-v2-0-745a563b9be6@oss.qualcomm.com> 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-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAN5VQWkC/32NQQ6CMBBFr0Jm7RA6akFW3sOwaMogjUBxiqAh3 N3KAdz85P3kv79CYHEcoExWEJ5dcH6IQIcEbGuGO6OrIwNldFaKTjhah+MidpIOhRcvD7QXZTQ rbanREIejcOPeu/RWRW5dmLx89o9Z/dq/ullhhnlhctKU6+JYX30I6fNlOuv7Po0B1bZtX90kc k27AAAA X-Change-ID: 20251124-pci-pwrctrl-rework-c91a6e16c2f6 To: Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Bartosz Golaszewski , Bartosz Golaszewski Cc: linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai , Brian Norris , Krishna Chaitanya Chundru , Niklas Cassel , Alex Elder , Manivannan Sadhasivam , Chen-Yu Tsai , Bartosz Golaszewski X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5986; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=jEohyugUt2xltGKMjwJH/v02rbokHrSkGszVOtUh1RI=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpQVXnhtZwgDtQjs20sZnRGBeoa6Woygs7yvgw9 RwGW8m+7/aJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaUFV5wAKCRBVnxHm/pHO 9eofB/9YymqsL1YolNRn2q15B8VixiUBeeGbKHB4zCXlTfx7P9EBBco6RYc/fXLwlSOxWGvWVCE FnMxZSi28bsVPt82iXP9UZwrAinrP4r1htKlW9IlwEGovZW892B4b9HMkylV474WIIgTPwmZ1IP /ny3USuEJ6/QH7Gp1LpX8OoVMTKMVR4Qcj1+D33tdNh3Jke+JhHIl8IuZ5Cl7JbuVmIT4Wi2wIF n+5b0CYAFdlFm4a0dw46wGcyQhHsOx7dkIAOl0YP7YglYctKPepFz+ZP/gypIkc2mZTku4KGNsZ z+H8Lnzp0f4qRGIrQ4z3MMORQ6hqokHikd9E6eGGWK+iZ1mM X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Authority-Analysis: v=2.4 cv=Vcb6/Vp9 c=1 sm=1 tr=0 ts=694155ef cx=c_pps a=m5Vt/hrsBiPMCU0y4gIsQw==:117 a=wnJ2AIBC+6MZbTdryK78rQ==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=BTS5Xa3S7kRhHNBJ3u0A:9 a=QEXdDO2ut3YA:10 a=IoOABgeZipijB_acs4fv:22 X-Proofpoint-GUID: Vqf77jM01DDManW2M7QGERY-2mtWDtFY X-Proofpoint-ORIG-GUID: Vqf77jM01DDManW2M7QGERY-2mtWDtFY X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjE2MDEwOSBTYWx0ZWRfX7FB2iYdGSXwm 3fLlalzJ3YR9qIIF1pgD1HCuwaOOr2wFsWQAI49dSDkWIz+Wu7wwbcXaat+F3cjbLyzR6X6x+/5 onUnFUVqBRKtr2Y5giUHeObUQCKidw7DyQVxioChcH9zf+YH0fz21MXTFL8PyTrHFhO3nj8RciE loXL0ogH3H+7014rmBc2SdD1AQOtGqJUn813QDZVrEppkoCoF+5DLkd/7qvVga0oEP1tn+tLBcv YYEOp947YwDCHJL08dnjxAIGepWwjJZ2iGmKanBcsTMo+WOFgEqHLgbH4biar9m/SNG7eFT+Y29 Gx/UF6IBNd4sQvFxgS0LRgZlJ5UVkrBZkiSEjbHCxK7boV+rRRd9bk0P+rM7SPBeovvy09cCFyY jUpqUrl12oXhuFGKYr/Vi2fBp6tl2Q== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-16_02,2025-12-16_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 impostorscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512160109 Hi, This series provides a major rework for the PCI power control (pwrctrl) framework to enable the pwrctrl devices to be controlled by the PCI controller drivers. Problem Statement ================= Currently, the pwrctrl framework faces two major issues: 1. Missing PERST# integration 2. Inability to properly handle bus extenders such as PCIe switch devices First issue arises from the disconnect between the PCI controller drivers and pwrctrl framework. At present, the pwrctrl framework just operates on its own with the help of the PCI core. The pwrctrl devices are created by the PCI core during initial bus scan and the pwrctrl drivers once bind, just power on the PCI devices during their probe(). This design conflicts with the PCI Express Card Electromechanical Specification requirements for PERST# timing. The reason is, PERST# signals are mostly handled by the controller drivers and often deasserted even before the pwrctrl drivers probe. According to the spec, PERST# should be deasserted only after power and reference clock to the device are stable, within predefined timing parameters. The second issue stems from the PCI bus scan completing before pwrctrl drivers probe. This poses a significant problem for PCI bus extenders like switches because the PCI core allocates upstream bridge resources during the initial scan. If the upstream bridge is not hotplug capable, resources are allocated only for the number of downstream buses detected at scan time, which might be just one if the switch was not powered and enumerated at that time. Later, when the pwrctrl driver powers on and enumerates the switch, enumeration fails due to insufficient upstream bridge resources. Proposal ======== This series addresses both issues by introducing new individual APIs for pwrctrl device creation, destruction, power on, and power off operations. Controller drivers are expected to invoke these APIs during their probe(), remove(), suspend(), and resume() operations. This integration allows better coordination between controller drivers and the pwrctrl framework, enabling enhanced features such as D3Cold support. The original design aimed to avoid modifying controller drivers for pwrctrl integration. However, this approach lacked scalability because different controllers have varying requirements for when devices should be powered on. For example, controller drivers require devices to be powered on early for successful PHY initialization. By using these explicit APIs, controller drivers gain fine grained control over their associated pwrctrl devices. This series modified the pcie-qcom driver (only consumer of pwrctrl framework) to adopt to these APIs and also removed the old pwrctrl code from PCI core. This could be used as a reference to add pwrctrl support for other controller drivers also. For example, to control the 3.3v supply to the PCI slot where the NVMe device is connected, below modifications are required: Devicetree ---------- // In SoC dtsi: pci@1bf8000 { // controller node ... pcie1_port0: pcie@0 { // PCI Root Port node compatible = "pciclass,0604"; // required for pwrctrl driver bind ... }; }; // In board dts: &pcie1_port0 { reset-gpios = <&tlmm 152 GPIO_ACTIVE_LOW>; // optional vpcie3v3-supply = <&vreg_nvme>; // NVMe power supply }; Controller driver ----------------- // Select PCI_PWRCTRL_SLOT in controller Kconfig probe() { ... // Initialize controller resources pci_pwrctrl_create_devices(&pdev->dev); pci_pwrctrl_power_on_devices(&pdev->dev); // Deassert PERST# (optional) ... pci_host_probe(); // Allocate host bridge and start bus scan } suspend { // PME_Turn_Off broadcast // Assert PERST# (optional) pci_pwrctrl_power_off_devices(&pdev->dev); ... } resume { ... pci_pwrctrl_power_on_devices(&pdev->dev); // Deassert PERST# (optional) } I will add a documentation for the pwrctrl framework in the coming days to make it easier to use. Testing ======= This series is tested on the Lenovo Thinkpad T14s laptop based on Qcom X1E chipset and RB3Gen2 development board with TC9563 switch based on Qcom QCS6490 chipset. **NOTE**: With this series, the controller driver may undergo multiple probe deferral if the pwrctrl driver was not available during the controller driver probe. This is pretty much required to avoid the resource allocation issue. Signed-off-by: Manivannan Sadhasivam --- Changes in v2: - Exported of_pci_supply_present() API - Demoted the -EPROBE_DEFER log to dev_dbg() - Collected tags and rebased on top of v6.19-rc1 - Link to v1: https://lore.kernel.org/r/20251124-pci-pwrctrl-rework-v1-0-78a72627683d@oss.qualcomm.com --- Krishna Chaitanya Chundru (1): PCI/pwrctrl: Add APIs for explicitly creating and destroying pwrctrl devices Manivannan Sadhasivam (4): PCI: qcom: Parse PERST# from all PCIe bridge nodes PCI/pwrctrl: Add 'struct pci_pwrctrl::power_{on/off}' callbacks PCI/pwrctrl: Add APIs to power on/off the pwrctrl devices PCI/pwrctrl: Switch to the new pwrctrl APIs drivers/pci/controller/dwc/pcie-qcom.c | 124 +++++++++++++--- drivers/pci/of.c | 1 + drivers/pci/probe.c | 59 -------- drivers/pci/pwrctrl/core.c | 248 +++++++++++++++++++++++++++++-- drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c | 30 +++- drivers/pci/pwrctrl/slot.c | 46 ++++-- drivers/pci/remove.c | 20 --- include/linux/pci-pwrctrl.h | 16 +- 8 files changed, 408 insertions(+), 136 deletions(-) --- base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 change-id: 20251124-pci-pwrctrl-rework-c91a6e16c2f6 Best regards, -- Manivannan Sadhasivam