* [PATCH v3] PCI: dw-rockchip: Fix initial PERST# GPIO value
@ 2024-04-17 16:42 Niklas Cassel
2024-04-30 8:38 ` Heiko Stübner
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Niklas Cassel @ 2024-04-17 16:42 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Heiko Stuebner, Simon Xue, Kever Yang
Cc: Damien Le Moal, Niklas Cassel, Jianfeng Liu,
Manivannan Sadhasivam, stable, linux-pci, linux-arm-kernel,
linux-rockchip
PERST# is active low according to the PCIe specification.
However, the existing pcie-dw-rockchip.c driver does:
gpiod_set_value(..., 0); msleep(100); gpiod_set_value(..., 1);
When asserting + deasserting PERST#.
This is of course wrong, but because all the device trees for this
compatible string have also incorrectly marked this GPIO as ACTIVE_HIGH:
$ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3568*
$ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3588*
The actual toggling of PERST# is correct.
(And we cannot change it anyway, since that would break device tree
compatibility.)
However, this driver does request the GPIO to be initialized as
GPIOD_OUT_HIGH, which does cause a silly sequence where PERST# gets
toggled back and forth for no good reason.
Fix this by requesting the GPIO to be initialized as GPIOD_OUT_LOW
(which for this driver means PERST# asserted).
This will avoid an unnecessary signal change where PERST# gets deasserted
(by devm_gpiod_get_optional()) and then gets asserted
(by rockchip_pcie_start_link()) just a few instructions later.
Before patch, debug prints on EP side, when booting RC:
[ 845.606810] pci: PERST# asserted by host!
[ 852.483985] pci: PERST# de-asserted by host!
[ 852.503041] pci: PERST# asserted by host!
[ 852.610318] pci: PERST# de-asserted by host!
After patch, debug prints on EP side, when booting RC:
[ 125.107921] pci: PERST# asserted by host!
[ 132.111429] pci: PERST# de-asserted by host!
This extra, very short, PERST# assertion + deassertion has been reported
to cause issues with certain WLAN controllers, e.g. RTL8822CE.
Fixes: 0e898eb8df4e ("PCI: rockchip-dwc: Add Rockchip RK356X host controller driver")
Tested-by: Jianfeng Liu <liujianfeng1994@gmail.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: stable@vger.kernel.org # 5.15+
---
Changes since v2:
-Picked up tag from Heiko.
-Change subject (Bjorn).
-s/PERST/PERST#/ (Bjorn).
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index d6842141d384..a909e42b4273 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -240,7 +240,7 @@ static int rockchip_pcie_resource_get(struct platform_device *pdev,
return PTR_ERR(rockchip->apb_base);
rockchip->rst_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
- GPIOD_OUT_HIGH);
+ GPIOD_OUT_LOW);
if (IS_ERR(rockchip->rst_gpio))
return PTR_ERR(rockchip->rst_gpio);
--
2.44.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] PCI: dw-rockchip: Fix initial PERST# GPIO value
2024-04-17 16:42 [PATCH v3] PCI: dw-rockchip: Fix initial PERST# GPIO value Niklas Cassel
@ 2024-04-30 8:38 ` Heiko Stübner
2024-05-15 21:20 ` Bjorn Helgaas
2024-05-17 11:22 ` Krzysztof Wilczyński
2 siblings, 0 replies; 4+ messages in thread
From: Heiko Stübner @ 2024-04-30 8:38 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Simon Xue, Kever Yang, Niklas Cassel
Cc: Damien Le Moal, Niklas Cassel, Jianfeng Liu,
Manivannan Sadhasivam, stable, linux-pci, linux-arm-kernel,
linux-rockchip
Am Mittwoch, 17. April 2024, 18:42:26 CEST schrieb Niklas Cassel:
> PERST# is active low according to the PCIe specification.
>
> However, the existing pcie-dw-rockchip.c driver does:
> gpiod_set_value(..., 0); msleep(100); gpiod_set_value(..., 1);
> When asserting + deasserting PERST#.
>
> This is of course wrong, but because all the device trees for this
> compatible string have also incorrectly marked this GPIO as ACTIVE_HIGH:
> $ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3568*
> $ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3588*
>
> The actual toggling of PERST# is correct.
> (And we cannot change it anyway, since that would break device tree
> compatibility.)
>
> However, this driver does request the GPIO to be initialized as
> GPIOD_OUT_HIGH, which does cause a silly sequence where PERST# gets
> toggled back and forth for no good reason.
>
> Fix this by requesting the GPIO to be initialized as GPIOD_OUT_LOW
> (which for this driver means PERST# asserted).
>
> This will avoid an unnecessary signal change where PERST# gets deasserted
> (by devm_gpiod_get_optional()) and then gets asserted
> (by rockchip_pcie_start_link()) just a few instructions later.
>
> Before patch, debug prints on EP side, when booting RC:
> [ 845.606810] pci: PERST# asserted by host!
> [ 852.483985] pci: PERST# de-asserted by host!
> [ 852.503041] pci: PERST# asserted by host!
> [ 852.610318] pci: PERST# de-asserted by host!
>
> After patch, debug prints on EP side, when booting RC:
> [ 125.107921] pci: PERST# asserted by host!
> [ 132.111429] pci: PERST# de-asserted by host!
>
> This extra, very short, PERST# assertion + deassertion has been reported
> to cause issues with certain WLAN controllers, e.g. RTL8822CE.
>
> Fixes: 0e898eb8df4e ("PCI: rockchip-dwc: Add Rockchip RK356X host controller driver")
> Tested-by: Jianfeng Liu <liujianfeng1994@gmail.com>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Cc: stable@vger.kernel.org # 5.15+
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
it also matches what the vendor kernel does.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] PCI: dw-rockchip: Fix initial PERST# GPIO value
2024-04-17 16:42 [PATCH v3] PCI: dw-rockchip: Fix initial PERST# GPIO value Niklas Cassel
2024-04-30 8:38 ` Heiko Stübner
@ 2024-05-15 21:20 ` Bjorn Helgaas
2024-05-17 11:22 ` Krzysztof Wilczyński
2 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2024-05-15 21:20 UTC (permalink / raw)
To: Niklas Cassel
Cc: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Heiko Stuebner, Simon Xue, Kever Yang,
Damien Le Moal, Jianfeng Liu, Manivannan Sadhasivam, stable,
linux-pci, linux-arm-kernel, linux-rockchip
On Wed, Apr 17, 2024 at 06:42:26PM +0200, Niklas Cassel wrote:
> PERST# is active low according to the PCIe specification.
>
> However, the existing pcie-dw-rockchip.c driver does:
> gpiod_set_value(..., 0); msleep(100); gpiod_set_value(..., 1);
> When asserting + deasserting PERST#.
>
> This is of course wrong, but because all the device trees for this
> compatible string have also incorrectly marked this GPIO as ACTIVE_HIGH:
> $ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3568*
> $ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3588*
>
> The actual toggling of PERST# is correct.
> (And we cannot change it anyway, since that would break device tree
> compatibility.)
>
> However, this driver does request the GPIO to be initialized as
> GPIOD_OUT_HIGH, which does cause a silly sequence where PERST# gets
> toggled back and forth for no good reason.
>
> Fix this by requesting the GPIO to be initialized as GPIOD_OUT_LOW
> (which for this driver means PERST# asserted).
>
> This will avoid an unnecessary signal change where PERST# gets deasserted
> (by devm_gpiod_get_optional()) and then gets asserted
> (by rockchip_pcie_start_link()) just a few instructions later.
>
> Before patch, debug prints on EP side, when booting RC:
> [ 845.606810] pci: PERST# asserted by host!
> [ 852.483985] pci: PERST# de-asserted by host!
> [ 852.503041] pci: PERST# asserted by host!
> [ 852.610318] pci: PERST# de-asserted by host!
>
> After patch, debug prints on EP side, when booting RC:
> [ 125.107921] pci: PERST# asserted by host!
> [ 132.111429] pci: PERST# de-asserted by host!
>
> This extra, very short, PERST# assertion + deassertion has been reported
> to cause issues with certain WLAN controllers, e.g. RTL8822CE.
>
> Fixes: 0e898eb8df4e ("PCI: rockchip-dwc: Add Rockchip RK356X host controller driver")
> Tested-by: Jianfeng Liu <liujianfeng1994@gmail.com>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Cc: stable@vger.kernel.org # 5.15+
Applied by Krzysztof to pci/controller/rockchip. His outgoing mail
queue was stuck, but I'm trying to squeeze this into v6.10.
> ---
> Changes since v2:
> -Picked up tag from Heiko.
> -Change subject (Bjorn).
> -s/PERST/PERST#/ (Bjorn).
>
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index d6842141d384..a909e42b4273 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -240,7 +240,7 @@ static int rockchip_pcie_resource_get(struct platform_device *pdev,
> return PTR_ERR(rockchip->apb_base);
>
> rockchip->rst_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
> - GPIOD_OUT_HIGH);
> + GPIOD_OUT_LOW);
> if (IS_ERR(rockchip->rst_gpio))
> return PTR_ERR(rockchip->rst_gpio);
>
> --
> 2.44.0
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] PCI: dw-rockchip: Fix initial PERST# GPIO value
2024-04-17 16:42 [PATCH v3] PCI: dw-rockchip: Fix initial PERST# GPIO value Niklas Cassel
2024-04-30 8:38 ` Heiko Stübner
2024-05-15 21:20 ` Bjorn Helgaas
@ 2024-05-17 11:22 ` Krzysztof Wilczyński
2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Wilczyński @ 2024-05-17 11:22 UTC (permalink / raw)
To: Niklas Cassel
Cc: Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Simon Xue, Kever Yang, Damien Le Moal, Jianfeng Liu,
Manivannan Sadhasivam, stable, linux-pci, linux-arm-kernel,
linux-rockchip
Hello,
> PERST# is active low according to the PCIe specification.
>
> However, the existing pcie-dw-rockchip.c driver does:
> gpiod_set_value(..., 0); msleep(100); gpiod_set_value(..., 1);
> When asserting + deasserting PERST#.
>
> This is of course wrong, but because all the device trees for this
> compatible string have also incorrectly marked this GPIO as ACTIVE_HIGH:
> $ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3568*
> $ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3588*
>
> The actual toggling of PERST# is correct.
> (And we cannot change it anyway, since that would break device tree
> compatibility.)
>
> However, this driver does request the GPIO to be initialized as
> GPIOD_OUT_HIGH, which does cause a silly sequence where PERST# gets
> toggled back and forth for no good reason.
>
> Fix this by requesting the GPIO to be initialized as GPIOD_OUT_LOW
> (which for this driver means PERST# asserted).
>
> This will avoid an unnecessary signal change where PERST# gets deasserted
> (by devm_gpiod_get_optional()) and then gets asserted
> (by rockchip_pcie_start_link()) just a few instructions later.
>
> Before patch, debug prints on EP side, when booting RC:
> [ 845.606810] pci: PERST# asserted by host!
> [ 852.483985] pci: PERST# de-asserted by host!
> [ 852.503041] pci: PERST# asserted by host!
> [ 852.610318] pci: PERST# de-asserted by host!
>
> After patch, debug prints on EP side, when booting RC:
> [ 125.107921] pci: PERST# asserted by host!
> [ 132.111429] pci: PERST# de-asserted by host!
>
> This extra, very short, PERST# assertion + deassertion has been reported
> to cause issues with certain WLAN controllers, e.g. RTL8822CE.
Applied to controller/rockchip, thank you!
[1/1] PCI: dw-rockchip: Fix initial PERST# GPIO value
https://git.kernel.org/pci/pci/c/b00c483a1075
Krzysztof
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-17 11:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-17 16:42 [PATCH v3] PCI: dw-rockchip: Fix initial PERST# GPIO value Niklas Cassel
2024-04-30 8:38 ` Heiko Stübner
2024-05-15 21:20 ` Bjorn Helgaas
2024-05-17 11:22 ` Krzysztof Wilczyński
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).