From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795961154; b=TvNm1oUdub7j4/W+tdgLHOl4LB10hYZWKzOp/ZvY4EkgXVBcuRa95jfYHAH3peFOSMN4 bik3uAi+H+QNKv70XM7r27CwycZkjmjNpeWrMrQg8OAj4hFPJl4rMTRIf3G1Q2x/Ugm8U Aot7YQ1XVKHB9WfcdLSyqr3PbkQFjr+nIcrK2m4ulRVBvqRg8ydNEGRTkddKqh9vJ4xfL GQjC4/TaqYKB3ipqegc452MsIuuzENnvPPQO1hrj5icoEkCUJP0zIeQN4ULfGWNDAXPz7 UGxVAdioTMrvb+SAOBfzAUFQIHBW4bVqKuFy80GJRSmSnkEX87/ckmaSDpcbIVl71kQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795961154; h=Received:MIME-Version:Content-Type:Content-Transfer-Encoding:Subject: From:To:Cc:In-Reply-To:References:Date:Message-Id:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=r/8SKC3QXpPnBJ/Sui4pJj2HoYZCLUVK5NxQDqu+tJk=; b=tkjwoG7a5PZFVexlhKHTbYeCZ3xSWWF4CocPJBsuSw6I+ZEMUS7DIpameveKo19GPfrC EKn1ncDEsApDtwicbJj1vg8ni4IuQNDJuFpgL6n6tCSlDtZPPDRUHOphWLE7aBpHg6C4k jEZ9/MEGH3hcihwi7O9xilrecda8AAJBDTPBCQTmI7BCuxN4TJPJgFev59A1B1W1XmAeo 4yozGU71ZFrsdqeCvh3ycCO8qrLK1B93wK6NZ13fnrYqoxEyz/tfOS2SuocSsV77gE4Du vm24BOoT6qJzhMoRwvC7EWE06kD5PpjdzPc7O7r8bMxXvEwMlR1TnYu/zJ1h+OY3YSQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F5AF606A31C; Sun, 29 Nov 2026 14:05:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 442461F000C1; Sun, 29 Nov 2026 14:05:48 +0000 (UTC) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: Re: [PATCH v5 2/2] PCI: rockchip-host: Make the PERST# inactive delay configurable From: Manivannan Sadhasivam To: =?utf-8?q?Enrique_Hern=C3=A1ndez_Bello?= Cc: shawn.lin@rock-chips.com, lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, bhelgaas@google.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de, dlemoal@kernel.org, iav@iav.lv, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org In-Reply-To: <20261104215848.2087944-3-ehbello@gmail.com> References: <20261104215848.2087944-1-ehbello@gmail.com> <20261104215848.2087944-3-ehbello@gmail.com> Date: Sun, 29 Nov 2026 19:35:45 +0530 Message-Id: <179596114526.2288.5995800864070065544.b4-reply@b4> X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3991; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=d6YSChAbznMno5lFiMHTarq+6pauJNlHzy0A/D8cGVo=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBrDDE8rVpryXEdPORl299LL8YgtiOf0aL81Av2+ cf6DRvb5fGJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCawwxPAAKCRBVnxHm/pHO 9dg4B/wLSwe7Sr6bmGoId3HkjHWWko0Jm18OYv6FuAbH54zANC+SW55eYguoawzZbnZiyEFH7VU SGjDwA4BTJGeq7eV+yk4IdLHuRyA4dhSVjEkjbFb9WoXIP1q0aLF+/ddF+/VnpEp9rYR6NedrXE fWO54tfU9v8tUhNpUQlH2TAF9+cCQmBj7dne6BbxFgYIzeHDuNXXMI/CvcUc7HHiCQUuhaSF6W6 JNPjo9b3E0hAW289rkSN9RzpJKCJxPJ3ZK/eRs5sW+CVLDQyN/M9gh+Cwq+QEBFJw6EaPk51cyn zRzZteCLhhmzlPF0gOXk87RcmcDf3yjflKEGDYCMJG9Q14qO X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 On 2026-11-04 21:58 +0000, Enrique Hernández Bello wrote: > rockchip_pcie_host_init_port() waits T_PVPERL, 100 ms, before releasing > PERST#. The GPIO is acquired with GPIOD_OUT_LOW early in probe, so PERST# > is already asserted when that wait starts, and the wait therefore sets the > reset pulse width as well. > > That suits a board which powers the slot at the moment it asserts PERST#, > but endpoints do not agree on what they want. On a ROCK Pi 4C carrying a > JMB585 SATA controller, a pulse that long stops the endpoint answering > configuration reads at all. Measured on that board with a single kernel and > two module parameters, one sleeping before the GPIO is acquired and one in > place of the wait, timing the pulse with a ktime delta across the two > gpiod_set_value() calls: > > pre (ms) post (ms) pulse trials enumerated > 0 0 1-11 ms 5 5 > 0 10 ~18 ms 3 3 > 0 15 24-47 ms 4 4 > 0 20 ~28 ms 3 1 > 0 100 ~108 ms 4 0 > 200 0 6-11 ms 5 5 > 200 100 ~108 ms 1 0 > > Delaying the assertion changes nothing, while widening the pulse decides > everything. The slot supply on this board is regulator-always-on, so power > had been valid for seconds in every row above, the failing ones included. > > Rather than change the delay for every board, read it from the device tree, > reusing the property names the Rockchip vendor driver already carries for > the dwc-based controllers in pcie-dw-rockchip.c. The default is unchanged, > so a board that describes nothing behaves exactly as before. Whatever the > board asks for, PERST# stays asserted for at least the 100 us minimum the > specification sets, which covers T_PERST and T_PERST-CLK. > Sorry for the delay, but I'm still not convinced that what you are describing is true. While inspecting the driver, I found out that the driver is starting LTSSM before PERST# deassert, which is not common and may cause issue with the Endpoint. When PERST# is not deasserted, the device is not obliged to respond to any config requests. So it is certainly possible that LTSSM could be getting timedout here and the 100ms delay can create an impression that delaying PERST# is what causing the failure. So can you try this below diff and see if it fixes the issue? diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index 5b071bdc4f90..6482ce075d05 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -311,19 +311,19 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip) status |= PCI_EXP_LNKCTL_RCB; rockchip_pcie_write(rockchip, status, PCIE_RC_CONFIG_CR + PCI_EXP_LNKCTL); - /* Enable Gen1 training */ - rockchip_pcie_write(rockchip, PCIE_CLIENT_LINK_TRAIN_ENABLE, - PCIE_CLIENT_CONFIG); - msleep(PCIE_T_PVPERL_MS); gpiod_set_value_cansleep(rockchip->perst_gpio, 1); msleep(PCIE_RESET_CONFIG_WAIT_MS); + /* Enable Gen1 training */ + rockchip_pcie_write(rockchip, PCIE_CLIENT_LINK_TRAIN_ENABLE, + PCIE_CLIENT_CONFIG); + /* 500ms timeout value should be enough for Gen1/2 training */ err = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_BASIC_STATUS1, status, PCIE_LINK_UP(status), 20, - 500 * USEC_PER_MSEC); + 1000 * USEC_PER_MSEC); if (err) { dev_err(dev, "PCIe link training gen1 timeout!\n"); goto err_power_off_phy; Basically, I just moved the LTSSM start after PERST# deassert and increased the status check to 1s as per the spec. - Mani