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 92CBB282F13 for ; Wed, 26 Aug 2026 07:16:57 +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=1787728619; cv=none; b=Km2/ppFC93HHy0JRy692uvMr47foccd6qfZcE1hxI7I/7fJGoHLVu/n2PBrQGip+7GPXLwu6PPe9aPy3fSrHma2ni/cBxQVMBNiIjVx/XinVigeNfiD+SGsUf8ShOlKGxk8Qu8l/kUQQjARK/WhFLZtivi1wG3ZCkPsd7WqUV+8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787728619; c=relaxed/simple; bh=A/jOtPIPzsGu+5AEAU4SsavTqBbpQwy1rF8OS55oVq8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Md/YZKHB8XrZFB0tQSrbao4GQqhGwAUQoYA/kdVA712v8og7l2WEpwNmSQqO8b+WnzTJ/Z8L6VMXoy7qhp6ccNzCYUp/ELppCahh47AcfiDVsURb2O9A9JKwx0LN2QjRf6xwDA4p4s8Xq9/UNfx2pmSfXf9Th88mexYRzqvgLhI= 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=UPv2vfBi; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=WnF35m8W; 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="UPv2vfBi"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="WnF35m8W" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67Q6RcSq3794497 for ; Wed, 26 Aug 2026 07:16:57 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= xXvLOxWUEjm7stkkC5GR6N0n9UM3KHHZuVkUy/3iUqs=; b=UPv2vfBiS+OBlAsJ wVQQPdGBwsYjJOr144v4u6hctYwtlRFkDbmHISIRVQPepb9uPc/wEIjm6Lo45vGI N5QzuqTNaJ7mbt7uaWkaaAZVixbRNgNgZ2+zGtdoEwRmrr17giMHFiNRMOMY9Etw bCO9Pi8VHNbIUrnEf/o/AnsOllLnJNYoqAzxSxfw92NsEoMNQnREbJXQPmSJL7jW /K+L6rKOpJZR5EUaOWv+uLTAMYs5HLGsfHmncjp6GBkczWir85PXDMnJeJCHyVZ9 jlxNzB8ew8d3Sy5XsTioyycMECpTvry2oPtOzQlRnGUVn27+M2GX8GI/QvnL8xtO XdqoPA== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g9smx8haa-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 26 Aug 2026 07:16:56 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cb835525b10so831236a12.2 for ; Wed, 26 Aug 2026 00:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787728616; x=1788333416; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xXvLOxWUEjm7stkkC5GR6N0n9UM3KHHZuVkUy/3iUqs=; b=WnF35m8Wm5iGj8Ui0uHri7xCiKZLuSFMNE+p+PEo/61CQBLkjkI5cQ6K4z5rx5gcu2 41E/wug6PJb3VVVaJClN/AnZU3mEavfyGm0uhco2aH2L6skcLBLW9FpsNH1M1o0Ci69s 8x1fDEIDrn55DWDuEImEZLOqPCvwUrL8KhR8NuizNEgPbpdfkyKpdoRDJwiVGf8aUjmP Y7q+IKgZm2Q9NpMQGAiIZBqw3BRl+7Vt3rGEOZ/dK+k7LFgHm0BN/5YfeTNY4FYvPxG1 CMEyqbuBOd5JVWeQl4p40If2OVBUVh8drXVwHnuxR1eDAt0RylCEn23HKTHG7eFIajpn 4uJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787728616; x=1788333416; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xXvLOxWUEjm7stkkC5GR6N0n9UM3KHHZuVkUy/3iUqs=; b=VvtaMR0AfG3reRzY2ObWL+91jtqfQuRv21cd92X6SjBxIEquW8PqA+i+AyHFndZ3Gb 2Yss0tpxaqZWfZIlmEIoCbCFUv2hXKuBTjIJ+kO4lSLqSYsqVndLtYih6XjOyMwCiq7w kCs2hWDv/U7e4zqXRQiht8fqrrp0+aLCr/JhI0G53ct2q/X81QFQ34eqLN7Ia1nOFBF4 zsGkHzm5N5yVc6J/Q8SoHs0Ttt+H8Qsi0yDRqc82SInrRALOlbtMKMtq3Nn+Wpw08tLJ j4gsCelMlmd1LI1GNiwpSBSG/JgXkW1kSIPBuLaHSo4w6opsxwL5Qlc0JDmdrzux8jgz dzYA== X-Forwarded-Encrypted: i=1; AHgh+RrqzTUwYIwY+3TdYRfKZHN8EK2uFt4NjphOPdlOw8Ykhl25jD9PvhB1xFVFXrI7luAyrYF/I5245UE61MM=@vger.kernel.org X-Gm-Message-State: AFuF++kQWeS6sFf4J0poxe6jqomIsHXaPFRcuWVxNiT4uFRRRU6jQbu9 CHKefA1EYdd1piJiWjEH3gqBYWLWD+tbE0RjYq+6V6Hd1hiCXXvpwI7nfTE1itsnqP0TbVGGn/F niOEmr0j7GEzEmufqgiqD1t4UVFuWAIgJlFsA2HAGAaHFhSlzCrtEK2Vhz9LxR+vz2oA= X-Gm-Gg: AR+sD11lV1vCnUkqPBK0wR74gvEDTNyqe2d1BaUalSvAhF+5CK6xES3x08KPol2v6UA CS3qk7Akgi0TwrqzFB67sbUhOP20awf2He7nIkdGw3usxfFZ+q3RpDVPwmVx7qhDSFEuk76lN5m A3ME3E6oGnucroPYfUI7u+gYOIZlC+kp+xrWsT9POcW4aG0VDSY2SlygObx0Hma9D4UFgw04ihW VhQseGlxX/EEU8TcNflt5X6TMuflx+ZdBZyU07m9lRX5BR7Fu0zihkf90RkAHV012vZBluVvFCN N3o9yIht76qkEFeownyIa75Yq3ffsrfZlea5PN3cUWgJen3wBVxitYCIIYCcEe5P8RTL0Koqoy1 GdpW7FupwfCfMKAlG7t6RG946B5nUWO0bzag= X-Received: by 2002:a05:6300:2285:b0:3cd:9bb1:c6f5 with SMTP id adf61e73a8af0-3cf83e174damr9343288637.10.1787728615989; Wed, 26 Aug 2026 00:16:55 -0700 (PDT) X-Received: by 2002:a05:6300:2285:b0:3cd:9bb1:c6f5 with SMTP id adf61e73a8af0-3cf83e174damr9343162637.10.1787728615457; Wed, 26 Aug 2026 00:16:55 -0700 (PDT) Received: from hu-krichai-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3283d8dc465sm5553772eec.24.2026.08.26.00.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2026 00:16:54 -0700 (PDT) From: Krishna Chaitanya Chundru Date: Wed, 26 Aug 2026 12:46:31 +0530 Subject: [PATCH v4 2/2] PCI: qcom: Implement shutdown() callback 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 Message-Id: <20260826-shutdown-v4-2-eb5fe9d454ae@oss.qualcomm.com> References: <20260826-shutdown-v4-0-eb5fe9d454ae@oss.qualcomm.com> In-Reply-To: <20260826-shutdown-v4-0-eb5fe9d454ae@oss.qualcomm.com> To: Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: konrad.dybcio@oss.qualcomm.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Krishna Chaitanya Chundru , Manivannan Sadhasivam X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787728602; l=3508; i=krishna.chundru@oss.qualcomm.com; s=20230907; h=from:subject:message-id; bh=KaNGQCf+MG1eiH3jZvZbpQL7k40TDTTho9JS634y7zA=; b=nt2RnwH/BVC/ImTDW1YqIT9OqT5rxIlQI9Xi1c2/05Yh1PLianlBjeuAsUAbIi2CuvwvLOd1p 5iAm/1p2J3tA7Ny4zaGeVVHUHKgfd2pT9zveMxnqNks5TC6cOiSOVyc X-Developer-Key: i=krishna.chundru@oss.qualcomm.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-Authority-Analysis: v=2.4 cv=O/oJeh9W c=1 sm=1 tr=0 ts=6a8e92e8 cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=ZeP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Dn9Z/zFUCDWrxpdclMmbfSBB9Dy SoEmuYkR6Y3AneZ4ZFtWxs2za+VfIKU= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-26_02,2026-08-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608260059 From: Manivannan Sadhasivam PCIe host controllers should bring the link down cleanly before system shutdown/reboot proceeds to remove power/clocks from the controller. Without this, the link may still be up and endpoints still have transactions in flight when power/clocks are cut, which can trip SMMU translation faults or NoC protocol errors. Reuse dw_pcie_suspend_noirq() in the shutdown path to force the link into L2, putting it into D3cold. device_shutdown() runs with interrupts enabled, unlike suspend_noirq(). Mask the chained MSI IRQ(s) and the Global IRQ before tearing down the link and clocks/PHY, since a late/spurious interrupt could otherwise reach a handler that touches now-unclocked PARF/DBI registers. Firmware-managed (ECAM) Root Complexes own their own link teardown and clock/PHY shutdown; for those, only mask the MSI IRQs. Signed-off-by: Manivannan Sadhasivam Signed-off-by: Krishna Chaitanya Chundru --- drivers/pci/controller/dwc/pcie-qcom.c | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index b58a607b713f..fad2f4e2d6be 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -1924,6 +1924,9 @@ static int qcom_pcie_ecam_host_init(struct pci_config_window *cfg) pp->use_imsi_rx = true; dw_pcie_msi_init(pp); + /* Stash pci so qcom_pcie_shutdown() can mask the MSI IRQ(s) later */ + platform_set_drvdata(to_platform_device(dev), pci); + return devm_add_action_or_reset(dev, qcom_pci_free_msi, pp); } @@ -2337,6 +2340,55 @@ static int qcom_pcie_probe(struct platform_device *pdev) return ret; } +static void qcom_pcie_mask_msi_irqs(struct dw_pcie_rp *pp) +{ + u32 ctrl; + + /* + * Mask the chained MSI IRQ(s) before tearing down the link and + * clocks/PHY. Unlike suspend_noirq(), device_shutdown() runs with + * interrupts enabled, so a late/spurious MSI could otherwise hit + * dw_chained_msi_isr() and touch DBI registers after the controller + * is powered off. + */ + for (ctrl = 0; ctrl < MAX_MSI_CTRLS; ctrl++) { + if (pp->msi_irq[ctrl] > 0) + disable_irq(pp->msi_irq[ctrl]); + } +} + +static void qcom_pcie_shutdown(struct platform_device *pdev) +{ + const struct qcom_pcie_cfg *pcie_cfg = of_device_get_match_data(&pdev->dev); + struct qcom_pcie *pcie; + + if (pcie_cfg && pcie_cfg->firmware_managed) { + /* + * Firmware owns the link teardown and clock/PHY shutdown in + * this mode; Linux only owns the chained MSI IRQ(s), which + * still need to be masked off before shutdown proceeds. + */ + struct dw_pcie *pci = platform_get_drvdata(pdev); + + if (pci) + qcom_pcie_mask_msi_irqs(&pci->pp); + return; + } + + pcie = platform_get_drvdata(pdev); + if (pcie) { + qcom_pcie_mask_msi_irqs(&pcie->pci->pp); + + if (pcie->global_irq) + disable_irq(pcie->global_irq); + + dw_pcie_suspend_noirq(pcie->pci); + } + + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); +} + static int qcom_pcie_suspend_noirq(struct device *dev) { struct qcom_pcie *pcie; @@ -2519,5 +2571,6 @@ static struct platform_driver qcom_pcie_driver = { .pm = &qcom_pcie_pm_ops, .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, + .shutdown = qcom_pcie_shutdown, }; builtin_platform_driver(qcom_pcie_driver); -- 2.34.1