Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2472566lqo; Mon, 13 May 2024 22:28:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlvYA8nCR1z2KDqrsMWid9QT58+QMlucELcJAhSgFaKuu3xayoKA0NCSf9vUSmVizjhbWz7XPUZjEAV8K2ot0tiJBw7hIPHlS+YwwgeQ== X-Google-Smtp-Source: AGHT+IErKGeB75LTnyyxKE2HCQ4InQCaPHb6dYvQ6h+SvOgSdIGQLfDJVRftUM7rpc27pEO8CVMm X-Received: by 2002:a17:907:720f:b0:a59:9ed5:eefc with SMTP id a640c23a62f3a-a5a2d30ba12mr1361138166b.32.1715664535135; Mon, 13 May 2024 22:28:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715664535; cv=pass; d=google.com; s=arc-20160816; b=QNcxQtHFOf6mM6KslteqdHPYNnNfkrbwjFj6C+a0gFJaDXkVbyKyuRgXF/HVzaihn8 aqpO3u+eRv0hY9RiOcVU1CuLzX8UxeLE0vyrWTeconLlkgUsQP/tBf2DyGOQFAlgKkjr RMyeAE/4Q//oYhqROuIVkg7PVJ7vcQ9013aJbU4QWwt4JI3M4aaoAb1Tk/RlH0lvKvDP q+ISBlTlWT2vuXEy8naRIuzDyWcm7qc+X9fM3iK1ZybatgUrqXWIJAjmttSado0H0O6C lg8uPN651CQbyCgjVsw95mFuexLQ5ci3YOw2n971rh/lccNmJP3uAjuNFLceUaHwX3gj mHKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=VpnQ2lDrTqhYrWSyEk6Bql0P0I4Ojy2QpnH60lvz9RA=; fh=CkhDxfuPC8gMwlm/QLM747HN46D2yt6bBNnrt9t0WAs=; b=1IoYuY9d137Tx3OqaOgXtFZWgL+0LH2lfA+64+bfjnd14iuIaH/BA4XuF3KGirrcRg 2Jd5kOjgqIARlRG3MtbSwX0qLVlHvBZazcBNuvBr8SvvYoN5ecAqy5eEalskaCRHFWa5 4jd5lGCIZVPwxgIArUdpl/y5IHjX6aVkQuSTPDGv9Iu8uvthw2nlY6gsfGhBdHNpJnW5 2xu7Y19P8npAuF9qoZG6MLB7XNxm/63jAkhmoinuu3DXtIHbVHUm5kntRL34JzsmtVGP pGDZ7ExJHJYSJtVq0ppJUI/NgMzCW9Ev0ILmOXl+Vm31YOOn8FGpJSigz3fET0K5nzp0 wJvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel+bounces-178329-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178329-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a1b602bcbsi573471566b.489.2024.05.13.22.28.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 22:28:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178329-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel+bounces-178329-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178329-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id DA8771F229E8 for ; Tue, 14 May 2024 05:28:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACE15182AE; Tue, 14 May 2024 05:28:48 +0000 (UTC) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) (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 5571A171AB; Tue, 14 May 2024 05:28:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=92.121.34.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715664528; cv=none; b=u9AHlz2x936g+Nf+H9Y5WA3Zb4T1bXGEPew28I/f4HRRYaxu9gFq9vGkmA+lbq5u3tQIaCPl1azfdiu48Q2bR36Q30y3i/vnPhinWS3ih4kIlKeLlMqLvDlJaIFMbG+HNVyv41BLBzl34zasF/EWQDJBw6Dlnmv99GP9HrwUd8o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715664528; c=relaxed/simple; bh=NRqzaYlat30Cka6lLWm1QfveJqU5KFy7bW8Zc9IvWpI=; h=From:To:Cc:Subject:Date:Message-Id; b=gdS8vyBtbGog4eb3X1H1CgRl+bOIn+VK6WvldPNjT8lKY44LiTlhb5KeECGFw+36viMV3optOmzDToLsfPqUX95UG5JeSrI94qzuPqG4EF+WZC8lnVgwbLgDy2xDDI7sNv2fkwSSrSDJVHKdwGQDnatah38x8XIIjBhrepSMKcI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; arc=none smtp.client-ip=92.121.34.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 59DB71A0BC9; Tue, 14 May 2024 07:28:38 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 0FA831A0BA8; Tue, 14 May 2024 07:28:38 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 56BBC1820F77; Tue, 14 May 2024 13:28:36 +0800 (+08) From: Richard Zhu To: bhelgaas@google.com, lorenzo.pieralisi@arm.com, frank.li@nxp.com, mani@kernel.org Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, imx@lists.linux.dev, Richard Zhu Subject: [PATCH v1] PCI: dwc: Fix resume failure if no EP is connected at some platforms. Date: Tue, 14 May 2024 13:09:18 +0800 Message-Id: <1715663358-8900-1-git-send-email-hongxing.zhu@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The dw_pcie_suspend_noirq() function currently returns success directly if no endpoint (EP) device is connected. However, on some platforms, power loss occurs during suspend, causing dw_resume() to do nothing in this case. This results in a system halt because the DWC controller is not initialized after power-on during resume. Change call to deinit() in suspend and init() at resume regardless of whether there are EP device connections or not. It is not harmful to perform deinit() and init() again for the no power-off case, and it keeps the code simple and consistent in logic. Fixes: 4774faf854f5 ("PCI: dwc: Implement generic suspend/resume functionality") Signed-off-by: Richard Zhu --- https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=controller/dwc This patch depends on the branch listed above, because it's not in pci-next. But suppose it will be in there soon. .../pci/controller/dwc/pcie-designware-host.c | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index a0822d5371bc5..cb8c3c2bcc790 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -933,23 +933,23 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci) if (dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKCTL) & PCI_EXP_LNKCTL_ASPM_L1) return 0; - if (dw_pcie_get_ltssm(pci) <= DW_PCIE_LTSSM_DETECT_ACT) - return 0; - - if (pci->pp.ops->pme_turn_off) - pci->pp.ops->pme_turn_off(&pci->pp); - else - ret = dw_pcie_pme_turn_off(pci); + if (dw_pcie_get_ltssm(pci) > DW_PCIE_LTSSM_DETECT_ACT) { + /* Only send out PME_TURN_OFF when PCIE link is up */ + if (pci->pp.ops->pme_turn_off) + pci->pp.ops->pme_turn_off(&pci->pp); + else + ret = dw_pcie_pme_turn_off(pci); - if (ret) - return ret; + if (ret) + return ret; - ret = read_poll_timeout(dw_pcie_get_ltssm, val, val == DW_PCIE_LTSSM_L2_IDLE, - PCIE_PME_TO_L2_TIMEOUT_US/10, - PCIE_PME_TO_L2_TIMEOUT_US, false, pci); - if (ret) { - dev_err(pci->dev, "Timeout waiting for L2 entry! LTSSM: 0x%x\n", val); - return ret; + ret = read_poll_timeout(dw_pcie_get_ltssm, val, val == DW_PCIE_LTSSM_L2_IDLE, + PCIE_PME_TO_L2_TIMEOUT_US/10, + PCIE_PME_TO_L2_TIMEOUT_US, false, pci); + if (ret) { + dev_err(pci->dev, "Timeout waiting for L2 entry! LTSSM: 0x%x\n", val); + return ret; + } } if (pci->pp.ops->deinit) -- 2.37.1