From nobody Tue Apr 7 23:40:10 2026 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 3A92E3932CE for ; Tue, 7 Apr 2026 13:03:51 +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=1775567032; cv=none; b=Hn0ye5o+xiZzYJiaeJ9/z8Bk7AQr13DncEEmKzx7gF1dVvZXgFgXPcAA0ujiUSLTjEJOC/su6d33mUTJlpOS13D5VDYuSMdQOb6y0Up58ZDl6KLvvPLqqoFpXounGfW+FKJsrKnNdx/gDfyxagLeoOs1SDJ/6EDJtSXvVX4SH/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775567032; c=relaxed/simple; bh=W1OhNcEspfBwAlfmZve2ZqD5tZvvm1E8mVApzAXXGuI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GNQQG2BefGX3dPMC3bDaDSugRfGZSDz6EZAR1VvMHYv0Zq/1ZL+fpGDG5uZHSw1dij2YbCzd4amcvSW46cdaV64Jxz99Sl7dKp9oW+EtEF2tyzoTFXibVPW+WbUp1n/aJMWtk6hpXP3D03Dp2567FQ2qCHm0BEhJd5dslBfqg/A= 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=bCnvo+02; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=SBPvjqDH; 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="bCnvo+02"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="SBPvjqDH" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 637Ca1E1492506 for ; Tue, 7 Apr 2026 13:03:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 33isoV0yWVJ9xotd+3ciXf4Msdfdu+7UChBrj+6r8Zg=; b=bCnvo+02LZ73oC4a eqaGfX+dMblgz/tmkFLmUryVC8AsbKahxJw3KkHa49PXG2aIEFG4pyZQBGTAQNqk 54RqPlyHWxE+hWnEP07Gz6MBvzGaTWbyreMmBdoPVRjVSs1NonS/wvoiK1vZjQFi DFcDlMeD+SnxH5B+ZOTLHjfxAqca00CboKsTjcW4f6VDpEerqFRFcuHKosXPQA2+ se4Gzic4JU8h7qKl7kCiLKes/msnmiIkMHgllj4+F4tEHDw/rd371UB6vnxoYwag mtfyotCOoZ9kBllaT3KB9tkG190fFMhiikAAWZ19JT7ZWCNxDI4rvfWTPSgTJzhR c0QwHw== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dcmr8trpd-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 07 Apr 2026 13:03:49 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2b0c92ff4ebso65794355ad.2 for ; Tue, 07 Apr 2026 06:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1775567029; x=1776171829; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=33isoV0yWVJ9xotd+3ciXf4Msdfdu+7UChBrj+6r8Zg=; b=SBPvjqDHoMwSnVxcv6XOLh4kIhI8YZZroVKIiSz4fTgoqAhd+EIP7GLf8ha3jggtvO 3ovQDtFDH/YxdfO01x4vBJPh7HUG/8dQ0BvFEi6gWAS5r08AR9d8qUV2YLE65sz+70Q+ lMgrwToICoaSGTJ5rdvb41lGCrLs6vt1G1HbMTgm+DcFbZ8WR+mjBvuHdMu3OBwsAokq fn8w9Is012qT3Hb2tC7vivi1pB5LGOG+tO3XXbaL6wRVa/GMJif3UD8CFp8/yGfyr+9P pYY63tb4u6vrWLCJJBFPIULuYL0U/KCPcWUhs8uMjkbAvNi4KrPi5MHJF8D72bBPT6nu bVrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775567029; x=1776171829; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=33isoV0yWVJ9xotd+3ciXf4Msdfdu+7UChBrj+6r8Zg=; b=l3DmNV+UQ2GKVnPvfYyNWo8xxSr9LTqx+LkqZedjiHbMN4BcVgOhlwyHrzxPAQxxXq xTA415n7NpJrRvPGAwTSZoKt4BdayBZKZXTlJRzoKgKzzWz8mGtUoSN4mGkY3AxRk+Jn TQEK59H42CVLoP8SksMTyNzEDh0dvou2P+0HDWr8kQFnkRWS2K8onYVvoKt9YbqJ0tY5 nmfnP1tLO21p/s5CIz59jJq9i55rOKO6uq9TxiyEPDwnRZc/rAfFpUGWrmc3SPwwN2kb XfUUi8mJEsBxmRAvxGs/PrcSNEIeldL4UrnGwa2P1e20vP6PzwThIbhXo2Jq8Fr/hA32 WjTA== X-Forwarded-Encrypted: i=1; AJvYcCVr/02Ehlnd5ke5n0zYOHaJyrviJ8WBN1eBU9R7tK7UcQS2iFJ4y8kOwuy12NUEoI4+U6UF6+OA1a7y2pE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3ybSLQ0RYUhDhFccESg+xMTVeuORm03ezwWfMo/bCEAnUtKUe ifF1oDdaIioolEaxfHYG9m7UFu/IjtXxC64MRtKrTLbtXFBzoW9cImjqbAy8w5lOyBeZ6OJ/oRi yrXVny9MJOyBZNCZCDe7B4+0q3FSPD/W1aO7PX7n9Zm++R4wYsjQzYng7fwSTNSAT7jU= X-Gm-Gg: AeBDievstR3BCeETGSfZy5auQ8mbqoqxQw9q0gSfFPvIiGAzyuR2bZNzrg8i9HZqEpY 9G4cHkFvsmTQpIlSQswAf/7mR2DsIl/CkNfrA9j+860iC8lKx9bkq613QzGBHQVCknkuwDNV1/c Je8y32YxDStAkcYrsLFiRJ/WAK/1J88Qit9Ss6zaQRInt4lC0kQzW3FwSkehVn9Fxi64Sm9TxKo 6NLkcJN2mTRSKrBMO8NKIqy+VMD1ZTyn5dF/kLDCPrDM973tiPHuIq5APwUtWLz6zIYPu/Yx6Uu ywyloYd8D3eDyq2vBNXli11Vn1RVH6xBKX7tgo/favO02mUPBV2/J+UvhRBj8b9mHCx3JyoRheS jWn8Wz+WeV/irJ+52yOPLXE4gBfBTMpZr+3sKDMJF0FiVOfpTdAFExncF X-Received: by 2002:a17:903:185:b0:2b0:5be9:f423 with SMTP id d9443c01a7336-2b2819180c5mr167577785ad.43.1775567028698; Tue, 07 Apr 2026 06:03:48 -0700 (PDT) X-Received: by 2002:a17:903:185:b0:2b0:5be9:f423 with SMTP id d9443c01a7336-2b2819180c5mr167577015ad.43.1775567027939; Tue, 07 Apr 2026 06:03:47 -0700 (PDT) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2749794e8sm181564885ad.53.2026.04.07.06.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 06:03:47 -0700 (PDT) From: Krishna Chaitanya Chundru Date: Tue, 07 Apr 2026 18:33:12 +0530 Subject: [PATCH v4 5/5] PCI: qcom: Add D3cold support 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: quoted-printable Message-Id: <20260407-d3cold-v4-5-bb171f75b465@oss.qualcomm.com> References: <20260407-d3cold-v4-0-bb171f75b465@oss.qualcomm.com> In-Reply-To: <20260407-d3cold-v4-0-bb171f75b465@oss.qualcomm.com> To: Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Will Deacon Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jonathanh@nvidia.com, bjorn.andersson@oss.qualcomm.com, Krishna Chaitanya Chundru X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1775566995; l=7930; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=W1OhNcEspfBwAlfmZve2ZqD5tZvvm1E8mVApzAXXGuI=; b=o5n5mzRCb1hInEwIP9Lo/mkqs1V+NaPD+q4D06Qd+qeyiIvLq3qU775agBpWtloe/QTme7jjR nCXcRkr1zXNBKMFJTclv0uXBflgy6ODXlnpBwnYuu/TuB08Ps/73MqU X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Proofpoint-GUID: roacLmXh3vbrfDqioWiFcyXsbHIFTcaA X-Proofpoint-ORIG-GUID: roacLmXh3vbrfDqioWiFcyXsbHIFTcaA X-Authority-Analysis: v=2.4 cv=c9abhx9l c=1 sm=1 tr=0 ts=69d500b5 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=3yJ-4rlz3SFKGY1FFUMA:9 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEyMSBTYWx0ZWRfX7nbaXx6G/b6h ttfX7ThJoZqHZG2KmNDtawW8sUlJusseT0SE3oTO8eayu+ZCF89MqCmGk0CJ+Z41+KMXWDicM3N Mu/5mjfqfGCouCvWOPcBWjmNBdy0jSIXt7mc0I5bdW9/k5B8sWRFUOri31tZCd6/yKu0gXWh+wo IiAemx9Il3oxt+IBSRMbW3vG1qMsSg622M38XE+fnu1nyOVUULEpRL04AS1FCNdbuPVNXQveBTd OIz4BqfRAnyYZAmPtKWtXYclan+DTodMxfYNdFH9rD1vNj/IgnXnj75h1hDgin+eh+goq0K0KAZ NzG6klPgF2Px9YrhwbHAqtSNYW2YrvFeWWXyPMfR7S9LsqFJNCmuMLs7UkZaCBXO1brwhq543lb bma0V6IpXIfUtd4kqCvdwSetOnSMk++SJJDSrtELkgcnQguAumfArNHy8Y99vjM/48Oo0G+NuUp ebne4YWVEIh5HDhq1aw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-07_02,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 adultscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604070121 Add support for transitioning PCIe endpoints under host bridge into D3cold by integrating with the DWC core suspend/resume helpers. Implement PME_TurnOff message generation via ELBI_SYS_CTRL and hook it into the DWC host operations so the controller follows the standard PME_TurnOff-based power-down sequence before entering D3cold. When the device is suspended into D3cold, fully tear down interconnect bandwidth, OPP votes. If D3cold is not entered, retain existing behavior by keeping the required interconnect and OPP votes. Use dw_pcie::skip_pwrctrl_off to avoid powering off devices during suspend to preseve wakeup capability of the devices and also not to power on the devices in the init path. Drop the qcom_pcie::suspended flag and rely on the existing dw_pcie::suspended state, which now drives both the power-management flow and the interconnect/OPP handling. Signed-off-by: Krishna Chaitanya Chundru --- drivers/pci/controller/dwc/pcie-qcom.c | 150 ++++++++++++++++++++---------= ---- 1 file changed, 92 insertions(+), 58 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controlle= r/dwc/pcie-qcom.c index c14c3eb70f356b6ad8a2ffe48b107327d2babf77..e8d109c44dd270610272906244d= 1afeec3664f41 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -145,6 +145,7 @@ =20 /* ELBI_SYS_CTRL register fields */ #define ELBI_SYS_CTRL_LT_ENABLE BIT(0) +#define ELBI_SYS_CTRL_PME_TURNOFF_MSG BIT(4) =20 /* AXI_MSTR_RESP_COMP_CTRL0 register fields */ #define CFG_REMOTE_RD_REQ_BRIDGE_SIZE_2K 0x4 @@ -283,7 +284,6 @@ struct qcom_pcie { const struct qcom_pcie_cfg *cfg; struct dentry *debugfs; struct list_head ports; - bool suspended; bool use_pm_opp; }; =20 @@ -1336,13 +1336,17 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *p= p) if (ret) goto err_deinit; =20 - ret =3D pci_pwrctrl_create_devices(pci->dev); - if (ret) - goto err_disable_phy; + if (!pci->suspended) { + ret =3D pci_pwrctrl_create_devices(pci->dev); + if (ret) + goto err_disable_phy; + } =20 - ret =3D pci_pwrctrl_power_on_devices(pci->dev); - if (ret) - goto err_pwrctrl_destroy; + if (!pp->skip_pwrctrl_off) { + ret =3D pci_pwrctrl_power_on_devices(pci->dev); + if (ret) + goto err_pwrctrl_destroy; + } =20 if (pcie->cfg->ops->post_init) { ret =3D pcie->cfg->ops->post_init(pcie); @@ -1386,11 +1390,14 @@ static void qcom_pcie_host_deinit(struct dw_pcie_rp= *pp) =20 qcom_pcie_perst_assert(pcie); =20 - /* - * No need to destroy pwrctrl devices as this function only gets called - * during system suspend as of now. - */ - pci_pwrctrl_power_off_devices(pci->dev); + if (!pci->pp.skip_pwrctrl_off) { + /* + * No need to destroy pwrctrl devices as this function only gets called + * during system suspend as of now. + */ + pci_pwrctrl_power_off_devices(pci->dev); + } + qcom_pcie_phy_power_off(pcie); pcie->cfg->ops->deinit(pcie); } @@ -1404,10 +1411,18 @@ static void qcom_pcie_host_post_init(struct dw_pcie= _rp *pp) pcie->cfg->ops->host_post_init(pcie); } =20 +static void qcom_pcie_host_pme_turn_off(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp); + + writel(ELBI_SYS_CTRL_PME_TURNOFF_MSG, pci->elbi_base + ELBI_SYS_CTRL); +} + static const struct dw_pcie_host_ops qcom_pcie_dw_ops =3D { .init =3D qcom_pcie_host_init, .deinit =3D qcom_pcie_host_deinit, .post_init =3D qcom_pcie_host_post_init, + .pme_turn_off =3D qcom_pcie_host_pme_turn_off, }; =20 /* Qcom IP rev.: 2.1.0 Synopsys IP rev.: 4.01a */ @@ -2072,53 +2087,51 @@ static int qcom_pcie_suspend_noirq(struct device *d= ev) if (!pcie) return 0; =20 - /* - * Set minimum bandwidth required to keep data path functional during - * suspend. - */ - if (pcie->icc_mem) { - ret =3D icc_set_bw(pcie->icc_mem, 0, kBps_to_icc(1)); - if (ret) { - dev_err(dev, - "Failed to set bandwidth for PCIe-MEM interconnect path: %d\n", - ret); - return ret; - } - } + ret =3D dw_pcie_suspend_noirq(pcie->pci); + if (ret) + return ret; =20 - /* - * Turn OFF the resources only for controllers without active PCIe - * devices. For controllers with active devices, the resources are kept - * ON and the link is expected to be in L0/L1 (sub)states. - * - * Turning OFF the resources for controllers with active PCIe devices - * will trigger access violation during the end of the suspend cycle, - * as kernel tries to access the PCIe devices config space for masking - * MSIs. - * - * Also, it is not desirable to put the link into L2/L3 state as that - * implies VDD supply will be removed and the devices may go into - * powerdown state. This will affect the lifetime of the storage devices - * like NVMe. - */ - if (!dw_pcie_link_up(pcie->pci)) { - qcom_pcie_host_deinit(&pcie->pci->pp); - pcie->suspended =3D true; - } + if (pcie->pci->suspended) { + ret =3D icc_disable(pcie->icc_mem); + if (ret) + dev_err(dev, "Failed to disable PCIe-MEM interconnect path: %d\n", ret); =20 - /* - * Only disable CPU-PCIe interconnect path if the suspend is non-S2RAM. - * Because on some platforms, DBI access can happen very late during the - * S2RAM and a non-active CPU-PCIe interconnect path may lead to NoC - * error. - */ - if (pm_suspend_target_state !=3D PM_SUSPEND_MEM) { ret =3D icc_disable(pcie->icc_cpu); if (ret) dev_err(dev, "Failed to disable CPU-PCIe interconnect path: %d\n", ret); =20 if (pcie->use_pm_opp) dev_pm_opp_set_opp(pcie->pci->dev, NULL); + } else { + /* + * Set minimum bandwidth required to keep data path functional during + * suspend. + */ + if (pcie->icc_mem) { + ret =3D icc_set_bw(pcie->icc_mem, 0, kBps_to_icc(1)); + if (ret) { + dev_err(dev, + "Failed to set bandwidth for PCIe-MEM interconnect path: %d\n", + ret); + return ret; + } + } + + /* + * Only disable CPU-PCIe interconnect path if the suspend is non-S2RAM. + * Because on some platforms, DBI access can happen very late during the + * S2RAM and a non-active CPU-PCIe interconnect path may lead to NoC + * error. + */ + if (pm_suspend_target_state !=3D PM_SUSPEND_MEM) { + ret =3D icc_disable(pcie->icc_cpu); + if (ret) + dev_err(dev, "Failed to disable CPU-PCIe interconnect path: %d\n", + ret); + + if (pcie->use_pm_opp) + dev_pm_opp_set_opp(pcie->pci->dev, NULL); + } } return ret; } @@ -2132,25 +2145,46 @@ static int qcom_pcie_resume_noirq(struct device *de= v) if (!pcie) return 0; =20 - if (pm_suspend_target_state !=3D PM_SUSPEND_MEM) { + if (pcie->pci->suspended) { ret =3D icc_enable(pcie->icc_cpu); if (ret) { dev_err(dev, "Failed to enable CPU-PCIe interconnect path: %d\n", ret); return ret; } - } =20 - if (pcie->suspended) { - ret =3D qcom_pcie_host_init(&pcie->pci->pp); - if (ret) - return ret; + ret =3D icc_enable(pcie->icc_mem); + if (ret) { + dev_err(dev, "Failed to enable PCIe-MEM interconnect path: %d\n", ret); + goto disable_icc_cpu; + } =20 - pcie->suspended =3D false; + /* + * Ignore -ENODEV & -EIO here since it is expected when no endpoint is + * connected to the PCIe link. + */ + ret =3D dw_pcie_resume_noirq(pcie->pci); + if (ret && ret !=3D -ENODEV && ret !=3D -EIO) + goto disable_icc_mem; + } else { + if (pm_suspend_target_state !=3D PM_SUSPEND_MEM) { + ret =3D icc_enable(pcie->icc_cpu); + if (ret) { + dev_err(dev, "Failed to enable CPU-PCIe interconnect path: %d\n", + ret); + return ret; + } + } } =20 qcom_pcie_icc_opp_update(pcie); =20 return 0; +disable_icc_mem: + icc_disable(pcie->icc_mem); +disable_icc_cpu: + icc_disable(pcie->icc_cpu); + + return ret; } =20 static const struct of_device_id qcom_pcie_match[] =3D { --=20 2.34.1