linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Martin Mareš" <mj@ucw.cz>
To: Matthew Wilcox <willy@infradead.org>
Cc: "Bjorn Helgaas" <helgaas@kernel.org>,
	"Pali Rohár" <pali@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	linux-pci@vger.kernel.org, "Bjorn Helgaas" <bhelgaas@google.com>
Subject: Re: [PATCH] lspci: Don't report PCIe link downgrades for downstream ports
Date: Fri, 21 Jan 2022 14:20:54 +0100	[thread overview]
Message-ID: <mj+md-20220121.131934.39347.albireo@ucw.cz> (raw)
In-Reply-To: <20210318173325.GR3420@casper.infradead.org>

Hello!

This fell through the cracks in my mailbox, but I finally assembled
pieces and here is what I applied.

				Martin


commit 9f7681202fcfaefd02e202eb64c01eb9e962729d
Author: Martin Mares <mj@ucw.cz>
Date:   Fri Jan 21 14:16:37 2022 +0100

    lspci: Improvements to PCIe link speed downgrade reporting
    
    Do not report PCIe link downgrades for downstream ports.
    
    Changed wording so that "overdriven" is reported instead of
    "strange" for speeds greater than the maximum supported one.
    
    Also report nothing instead of "ok".
    
    Inspired by patches by Bjorn Helgaas and Matthew Wilcox.

diff --git a/ls-caps.c b/ls-caps.c
index 91acb59..79b61cd 100644
--- a/ls-caps.c
+++ b/ls-caps.c
@@ -771,13 +771,16 @@ static char *link_speed(int speed)
     }
 }
 
-static char *link_compare(int sta, int cap)
+static char *link_compare(int type, int sta, int cap)
 {
-  if (sta < cap)
-    return "downgraded";
   if (sta > cap)
-    return "strange";
-  return "ok";
+    return " (overdriven)";
+  if (sta == cap)
+    return "";
+  if ((type == PCI_EXP_TYPE_ROOT_PORT) || (type == PCI_EXP_TYPE_DOWNSTREAM) ||
+      (type == PCI_EXP_TYPE_PCIE_BRIDGE))
+    return "";
+  return " (downgraded)";
 }
 
 static char *aspm_support(int code)
@@ -850,11 +853,11 @@ static void cap_express_link(struct device *d, int where, int type)
   w = get_conf_word(d, where + PCI_EXP_LNKSTA);
   sta_speed = w & PCI_EXP_LNKSTA_SPEED;
   sta_width = (w & PCI_EXP_LNKSTA_WIDTH) >> 4;
-  printf("\t\tLnkSta:\tSpeed %s (%s), Width x%d (%s)\n",
+  printf("\t\tLnkSta:\tSpeed %s%s, Width x%d%s\n",
 	link_speed(sta_speed),
-	link_compare(sta_speed, cap_speed),
+	link_compare(type, sta_speed, cap_speed),
 	sta_width,
-	link_compare(sta_width, cap_width));
+	link_compare(type, sta_width, cap_width));
   printf("\t\t\tTrErr%c Train%c SlotClk%c DLActive%c BWMgmt%c ABWMgmt%c\n",
 	FLAG(w, PCI_EXP_LNKSTA_TR_ERR),
 	FLAG(w, PCI_EXP_LNKSTA_TRAIN),

  reply	other threads:[~2022-01-21 13:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 17:02 [PATCH] lspci: Don't report PCIe link downgrades for downstream ports Bjorn Helgaas
2021-03-18 17:11 ` Bjorn Helgaas
2021-03-18 17:33 ` Matthew Wilcox
2022-01-21 13:20   ` Martin Mareš [this message]
2021-03-21 16:09 ` Pali Rohár
2021-03-21 16:32   ` Matthew Wilcox

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=mj+md-20220121.131934.39347.albireo@ucw.cz \
    --to=mj@ucw.cz \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=willy@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).