linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] pciehp: Add check for DL_ACTIVE bit in pciehp_check_link_status()
@ 2020-10-19 18:46 Sanjay R Mehta
  2020-10-20  8:33 ` Ethan Zhao
  0 siblings, 1 reply; 2+ messages in thread
From: Sanjay R Mehta @ 2020-10-19 18:46 UTC (permalink / raw)
  To: bhelgaas, lukas, andriy.shevchenko, stuart.w.hayes, mr.nuke.me
  Cc: linux-kernel, Sanjay R Mehta

From: Sanjay R Mehta <sanju.mehta@amd.com>

if DL_ACTIVE bit is set it means that there is no need to check
PCI_EXP_LNKSTA_LT bit, as DL_ACTIVE would have set only if the link
is already trained. Hence adding a check which takes care of this
scenario.

Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
---
 drivers/pci/hotplug/pciehp_hpc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 53433b37e181..8ab2f6a2f388 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -309,7 +309,8 @@ int pciehp_check_link_status(struct controller *ctrl)
 
 	pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
 	ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
-	if ((lnk_status & PCI_EXP_LNKSTA_LT) ||
+	if (((lnk_status & PCI_EXP_LNKSTA_LT) &&
+	     !(lnk_status & PCI_EXP_LNKSTA_DLLLA)) ||
 	    !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
 		ctrl_err(ctrl, "link training error: status %#06x\n",
 			 lnk_status);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] pciehp: Add check for DL_ACTIVE bit in pciehp_check_link_status()
  2020-10-19 18:46 [PATCH v2] pciehp: Add check for DL_ACTIVE bit in pciehp_check_link_status() Sanjay R Mehta
@ 2020-10-20  8:33 ` Ethan Zhao
  0 siblings, 0 replies; 2+ messages in thread
From: Ethan Zhao @ 2020-10-20  8:33 UTC (permalink / raw)
  To: Sanjay R Mehta
  Cc: Bjorn Helgaas, Lukas Wunner, Andy Shevchenko, Stuart Hayes,
	Alexandru Gagniuc, Linux Kernel Mailing List

On Tue, Oct 20, 2020 at 2:33 PM Sanjay R Mehta <Sanju.Mehta@amd.com> wrote:
>
> From: Sanjay R Mehta <sanju.mehta@amd.com>
>
> if DL_ACTIVE bit is set it means that there is no need to check
> PCI_EXP_LNKSTA_LT bit, as DL_ACTIVE would have set only if the link
> is already trained. Hence adding a check which takes care of this
> scenario.
Sorry, I couldn't understand the logic here. if DL_ACTIVE was set,
PCI_EXP_LNKSTA_LT is to be cleared, vice versa.  why need

(lnk_status & PCI_EXP_LNKSTA_LT) &&
 !(lnk_status & PCI_EXP_LNKSTA_DLLLA)

Double safe ?

Thanks,
Ethan

>
> Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
> ---
>  drivers/pci/hotplug/pciehp_hpc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
> index 53433b37e181..8ab2f6a2f388 100644
> --- a/drivers/pci/hotplug/pciehp_hpc.c
> +++ b/drivers/pci/hotplug/pciehp_hpc.c
> @@ -309,7 +309,8 @@ int pciehp_check_link_status(struct controller *ctrl)
>
>         pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
>         ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
> -       if ((lnk_status & PCI_EXP_LNKSTA_LT) ||
> +       if (((lnk_status & PCI_EXP_LNKSTA_LT) &&
> +            !(lnk_status & PCI_EXP_LNKSTA_DLLLA)) ||
>             !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
>                 ctrl_err(ctrl, "link training error: status %#06x\n",
>                          lnk_status);
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-20  8:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 18:46 [PATCH v2] pciehp: Add check for DL_ACTIVE bit in pciehp_check_link_status() Sanjay R Mehta
2020-10-20  8:33 ` Ethan Zhao

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).