From nobody Fri Dec 19 07:35:41 2025 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 D65751531D5 for ; Fri, 30 Aug 2024 08:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725006215; cv=none; b=djJsYtdlNhy57xu6aZA29OJPzhqP7O+x+EeiaEnSviqOVsawJ3bU3WiVQMx2uugAOKdpqgVlx1H/BhAKGZM/+q48PlWfO0Kfg8MFl4GiinxsZIzymfL1G1IToNfD6w5W+Vae5MHPXN0uMjF3ioSWnICYN0yph1hAwY+x8cuYLDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725006215; c=relaxed/simple; bh=dOvy8lq/EHJgmko75sUxm42JQCa3y8fE26e1sl4RadQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=uLSBShn3RMLmBUP4mg2WwCf2rI1+nmXiX4ZvJaA1GDpz3P9kVkkRRmOLdNDAyXllGPcRT1tTWEQo3k8Fz/Z9lVhR6BtV1AMiuH06c16Lt5pJigC/d9/C8QXtRdLqFe9qTzVDh8WVQPIogbqdyJIP77pTRM0USOKDVZrsBZBMYbo= 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=Y58JmQi7; arc=none smtp.client-ip=209.85.210.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Y58JmQi7" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-70f6a7c4dcdso123466a34.1 for ; Fri, 30 Aug 2024 01:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725006211; x=1725611011; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iwkXS2XE5Tkc0QlVhME91uwM7bEp3jrm2KHPu4Lpqm8=; b=Y58JmQi7kq4itQiJnSlbl/zhiuY9+4OG/BLYnz9tAQWDDgeuj5zZUrFK+kmoKGkRGu guj//lpr+deERV0Ef1JvqzHq5Bripolb7PhI1+VpudYVzgNm9/1MRYRYU4rruocy+Hxb LcyxX33OPZdgI9l7205GR3Ts198JhTaJ0alFc1/neiyusfLQnXq3sBA1Vca2grzNaKC7 dh8WOK5jWzhHqkpuxDOVAOk41KKcG3GnTDyG17H5cEuGPMskkktGuTwTah25FEX8fVeh lv1Q4YKhZqQBUknD9ykn9RZE6xnvJ2brChMwlboGUJ1L5qMo9FMhwUrwWkEWzNOPReOk r3uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725006211; x=1725611011; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iwkXS2XE5Tkc0QlVhME91uwM7bEp3jrm2KHPu4Lpqm8=; b=OGTOVRXxjVo/Wd+/WTjtKwtMGuhn0WZGyLLSCd+4J+ciWK32/mhYRyY31aAhHZC6L+ RF8zdFSxeEF7ufeMJh5kf0zbdNXTuZ1zFf4aaahJPzI5f3WX5Poiry9RcGQIvFnCcTlY C6CgRFNNi9r/i3aqXRfbre5LpQlAM5DIyvwEeY55qWSXGQe3Rvd29VVVNT2NiKMC2t3f 2vLMF4PTB0rYUPQzIJJZBNwDUhyGKV4NXWb8yg260fIPgvxOAuVicxE7k4BOnV/1R6eC 9USDW6m8IguNWKmjE4W/uA+iXB0VLo625bfE4vonmDI1lhOrLQf5KzTKw9v4W89gbTRD ImCg== X-Forwarded-Encrypted: i=1; AJvYcCXwOq/kk3KPEneCZPi8kLOxsEtnd97kCyjWIwMdJNN8uFe1LokY/MpWhDniWkdsIcHDw3iJW3tgdfg7HGY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy8OkFdtO2ERiwwwQYFOiI/YmPLJD7+12Loj7fwBW2ABplg0uEn F4LA+2xuPG3P1DuaAkX/MMk/cLYuK9vS+/GjRP8IDh6pO4XYdLYH36hT2rVfmQ== X-Google-Smtp-Source: AGHT+IGQ9ZFGuWGC0MxA2Z/ohzzOno+rbi7BFhIeUOBZkKWCdB3C8rji4O6xHmPZhJ8tf79hvt7rKg== X-Received: by 2002:a05:6358:5289:b0:1b1:a91f:9f7e with SMTP id e5c5f4694b2df-1b603cb7acdmr711886455d.24.1725006210984; Fri, 30 Aug 2024 01:23:30 -0700 (PDT) Received: from localhost.localdomain ([117.193.213.95]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e5576c90sm2265623b3a.2.2024.08.30.01.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 01:23:30 -0700 (PDT) From: Manivannan Sadhasivam To: lpieralisi@kernel.org, kw@linux.com, bhelgaas@google.com Cc: robh@kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam , Dmitry Baryshkov Subject: [PATCH v3] PCI: qcom-ep: Enable controller resources like PHY only after refclk is available Date: Fri, 30 Aug 2024 13:53:19 +0530 Message-Id: <20240830082319.51387-1-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" qcom_pcie_enable_resources() is called by qcom_pcie_ep_probe() and it enables the controller resources like clocks, regulator, PHY. On one of the new unreleased Qcom SoC, PHY enablement depends on the active refclk. And on all of the supported Qcom endpoint SoCs, refclk comes from the host (RC). So calling qcom_pcie_enable_resources() without refclk causes the NoC (Network On Chip) error in the endpoint SoC and in turn results in a whole SoC crash and rebooting into EDL (Emergency Download) mode which is an unrecoverable state. But qcom_pcie_enable_resources() is already called by qcom_pcie_perst_deassert() when PERST# is deasserted, and refclk is available at that time. Hence, remove the unnecessary call to qcom_pcie_enable_resources() from qcom_pcie_ep_probe() to prevent the above mentioned crash. It should be noted that this commit prevents the crash only under normal working condition (booting endpoint before host), but the crash may also occur if PERST# assert happens at the wrong time. For avoiding the crash completely, it is recommended to use SRIS mode which allows the endpoint SoC to generate its own refclk. The driver is not supporting SRIS mode currently, but will be added in the future. Fixes: 869bc5253406 ("PCI: dwc: ep: Fix DBI access failure for drivers requ= iring refclk from host") Tested-by: Dmitry Baryshkov Signed-off-by: Manivannan Sadhasivam --- Changes in v3: * Improved the patch description to mention that the crash in an unrecovera= ble state and also that it may occur if PERST# is asserted at the wrong time. Changes in v2: - Changed the patch description to mention the crash clearly as suggested by Bjorn - Added the Fixes tag Bjorn: This is not going to be a 6.11 material as it is not fixing a regres= sion introduced in 6.11 (offending commit got merged in 6.10). So please merge t= his patch for 6.12. drivers/pci/controller/dwc/pcie-qcom-ep.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/contro= ller/dwc/pcie-qcom-ep.c index 236229f66c80..2319ff2ae9f6 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -846,21 +846,15 @@ static int qcom_pcie_ep_probe(struct platform_device = *pdev) if (ret) return ret; =20 - ret =3D qcom_pcie_enable_resources(pcie_ep); - if (ret) { - dev_err(dev, "Failed to enable resources: %d\n", ret); - return ret; - } - ret =3D dw_pcie_ep_init(&pcie_ep->pci.ep); if (ret) { dev_err(dev, "Failed to initialize endpoint: %d\n", ret); - goto err_disable_resources; + return ret; } =20 ret =3D qcom_pcie_ep_enable_irq_resources(pdev, pcie_ep); if (ret) - goto err_disable_resources; + goto err_ep_deinit; =20 name =3D devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node); if (!name) { @@ -877,8 +871,8 @@ static int qcom_pcie_ep_probe(struct platform_device *p= dev) disable_irq(pcie_ep->global_irq); disable_irq(pcie_ep->perst_irq); =20 -err_disable_resources: - qcom_pcie_disable_resources(pcie_ep); +err_ep_deinit: + dw_pcie_ep_deinit(&pcie_ep->pci.ep); =20 return ret; } --=20 2.25.1