From: Bjorn Helgaas <helgaas@kernel.org>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: jingoohan1@gmail.com, gustavo.pimentel@synopsys.com,
Sergey.Semin@baikalelectronics.ru, lpieralisi@kernel.org,
kw@linux.com, robh@kernel.org, bhelgaas@google.com,
linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: dwc: Fix writing wrong value if snps,enable-cdm-check
Date: Thu, 16 Feb 2023 11:58:22 -0600 [thread overview]
Message-ID: <20230216175822.GA3321300@bhelgaas> (raw)
In-Reply-To: <20230216092012.3256440-1-yoshihiro.shimoda.uh@renesas.com>
On Thu, Feb 16, 2023 at 06:20:12PM +0900, Yoshihiro Shimoda wrote:
> The "val" of PCIE_PORT_LINK_CONTROL will be reused on the
> "Set the number of lanes". But, if snps,enable-cdm-check" exists,
> the "val" will be set to PCIE_PL_CHK_REG_CONTROL_STATUS.
> Therefore, unexpected register value is possible to be used
> to PCIE_PORT_LINK_CONTROL register if snps,enable-cdm-check" exists.
> So, read PCIE_PORT_LINK_CONTROL register again to fix the issue.
>
> Fixes: ec7b952f453c ("PCI: dwc: Always enable CDM check if "snps,enable-cdm-check" exists")
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> drivers/pci/controller/dwc/pcie-designware.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 6d5d619ab2e9..3bb9ca14fb9c 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -824,6 +824,7 @@ void dw_pcie_setup(struct dw_pcie *pci)
> }
>
> /* Set the number of lanes */
> + val = dw_pcie_readl_dbi(pci, PCIE_PORT_LINK_CONTROL);
Definitely a bug, thanks for the fix and the Fixes: tag.
But I would like the whole function better if it could be structured
so we read PCIE_PORT_LINK_CONTROL once and wrote it once. And the
same for PCIE_LINK_WIDTH_SPEED_CONTROL.
Maybe there's a reason PCIE_PL_CHK_REG_CONTROL_STATUS must be written
between the two PCIE_PORT_LINK_CONTROL writes or the two
PCIE_LINK_WIDTH_SPEED_CONTROL writes, I dunno. If so, a comment there
about why that is would be helpful.
> val &= ~PORT_LINK_FAST_LINK_MODE;
> val &= ~PORT_LINK_MODE_MASK;
> switch (pci->num_lanes) {
> --
> 2.25.1
>
next prev parent reply other threads:[~2023-02-16 17:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 9:20 [PATCH] PCI: dwc: Fix writing wrong value if snps,enable-cdm-check Yoshihiro Shimoda
2023-02-16 17:58 ` Bjorn Helgaas [this message]
2023-02-16 20:49 ` Serge Semin
2023-02-17 0:46 ` Yoshihiro Shimoda
2023-02-17 8:06 ` Serge Semin
2023-02-17 11:21 ` Bjorn Helgaas
2023-02-16 20:37 ` Serge Semin
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=20230216175822.GA3321300@bhelgaas \
--to=helgaas@kernel.org \
--cc=Sergey.Semin@baikalelectronics.ru \
--cc=bhelgaas@google.com \
--cc=gustavo.pimentel@synopsys.com \
--cc=jingoohan1@gmail.com \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=robh@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.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