From: Jon Hunter <jonathanh@nvidia.com>
To: "Niklas Cassel" <cassel@kernel.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Thierry Reding" <thierry.reding@gmail.com>
Cc: Vidya Sagar <vidyas@nvidia.com>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH] PCI: tegra194: Handle errors in BPMP response
Date: Wed, 17 Sep 2025 14:15:01 +0100 [thread overview]
Message-ID: <526b895c-adb3-4734-bb2a-018759b66f14@nvidia.com> (raw)
In-Reply-To: <20250911122728.1465254-2-cassel@kernel.org>
On 11/09/2025 13:27, Niklas Cassel wrote:
> From: Vidya Sagar <vidyas@nvidia.com>
>
> The return value from tegra_bpmp_transfer() indicates the success or
> failure of the IPC transaction with BPMP. If the transaction
> succeeded, we also need to check the actual command's result code.
>
> If a host deasserts PERST without providing a refclock, enabling the PHY
> (via a tegra_bpmp_transfer() call) will silently fail, however, because
> we are lacking error handling, pex_ep_event_pex_rst_deassert() will still
> set pcie->ep_state = EP_STATE_ENABLED.
>
> Because of this, any succeeding PERST deassertion will incorrectly be a
> no-op (because of the pcie->ep_state == EP_STATE_ENABLED check in
> pex_ep_event_pex_rst_deassert()), even if the host does provide a refclock
> during the succeeding PERST deassertion.
>
> Add error handling to tegra_bpmp_transfer(), such that the pcie->ep_state
> can not get out of sync with reality, which will incorrectly cause the
> driver to think that it has been successfully initialized, which
> incorrectly makes future calls to pex_ep_event_pex_rst_deassert() a no-op.
>
> Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
> [cassel: improve commit log]
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> drivers/pci/controller/dwc/pcie-tegra194.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
> index 0c0734aa14b68..8c5c370dbba5e 100644
> --- a/drivers/pci/controller/dwc/pcie-tegra194.c
> +++ b/drivers/pci/controller/dwc/pcie-tegra194.c
> @@ -1214,6 +1214,7 @@ static int tegra_pcie_bpmp_set_ctrl_state(struct tegra_pcie_dw *pcie,
> struct mrq_uphy_response resp;
> struct tegra_bpmp_message msg;
> struct mrq_uphy_request req;
> + int err;
>
> /*
> * Controller-5 doesn't need to have its state set by BPMP-FW in
> @@ -1236,7 +1237,13 @@ static int tegra_pcie_bpmp_set_ctrl_state(struct tegra_pcie_dw *pcie,
> msg.rx.data = &resp;
> msg.rx.size = sizeof(resp);
>
> - return tegra_bpmp_transfer(pcie->bpmp, &msg);
> + err = tegra_bpmp_transfer(pcie->bpmp, &msg);
> + if (err)
> + return err;
> + if (msg.rx.ret)
> + return -EINVAL;
> +
> + return 0;
> }
>
> static int tegra_pcie_bpmp_set_pll_state(struct tegra_pcie_dw *pcie,
> @@ -1245,6 +1252,7 @@ static int tegra_pcie_bpmp_set_pll_state(struct tegra_pcie_dw *pcie,
> struct mrq_uphy_response resp;
> struct tegra_bpmp_message msg;
> struct mrq_uphy_request req;
> + int err;
>
> memset(&req, 0, sizeof(req));
> memset(&resp, 0, sizeof(resp));
> @@ -1264,7 +1272,13 @@ static int tegra_pcie_bpmp_set_pll_state(struct tegra_pcie_dw *pcie,
> msg.rx.data = &resp;
> msg.rx.size = sizeof(resp);
>
> - return tegra_bpmp_transfer(pcie->bpmp, &msg);
> + err = tegra_bpmp_transfer(pcie->bpmp, &msg);
> + if (err)
> + return err;
> + if (msg.rx.ret)
> + return -EINVAL;
> +
> + return 0;
> }
>
> static void tegra_pcie_downstream_dev_to_D0(struct tegra_pcie_dw *pcie)
Looks good to me!
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Cheers
Jon
--
nvpublic
next prev parent reply other threads:[~2025-09-17 13:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 12:27 [PATCH] PCI: tegra194: Handle errors in BPMP response Niklas Cassel
2025-09-17 13:15 ` Jon Hunter [this message]
2025-09-20 15:31 ` Manivannan Sadhasivam
2025-09-22 13:36 ` Niklas Cassel
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=526b895c-adb3-4734-bb2a-018759b66f14@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--cc=thierry.reding@gmail.com \
--cc=vidyas@nvidia.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