From: Bjorn Helgaas <helgaas@kernel.org>
To: Niklas Cassel <cassel@kernel.org>
Cc: "Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Heiko Stuebner" <heiko@sntech.de>,
"Simon Xue" <xxm@rock-chips.com>,
"Shawn Lin" <shawn.lin@rock-chips.com>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Jianfeng Liu" <liujianfeng1994@gmail.com>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
stable@vger.kernel.org, linux-pci@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v2] PCI: dw-rockchip: Fix GPIO initialization flag
Date: Wed, 17 Apr 2024 10:20:17 -0500 [thread overview]
Message-ID: <20240417152017.GA202515@bhelgaas> (raw)
In-Reply-To: <20240416121522.269972-1-cassel@kernel.org>
On Tue, Apr 16, 2024 at 02:15:22PM +0200, Niklas Cassel wrote:
> PERST is active low according to the PCIe specification.
Maybe update the subject to mention that this is about PERST# and
avoiding an unnecessary toggle.
Also maybe worth using "PERST#" here in the commit log to match the
spec and connect with the explicit GPIO levels.
> 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>
> 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 V1:
> -Picked up tags.
> -CC stable.
> -Clarified commit message.
>
> 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
>
prev parent reply other threads:[~2024-04-17 15:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 12:15 [PATCH v2] PCI: dw-rockchip: Fix GPIO initialization flag Niklas Cassel
2024-04-17 14:35 ` Heiko Stübner
2024-04-17 15:20 ` Bjorn Helgaas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240417152017.GA202515@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=heiko@sntech.de \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=liujianfeng1994@gmail.com \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=robh@kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=stable@vger.kernel.org \
--cc=xxm@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox