linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] thunderbolt: debugfs: handle fail reading block
@ 2021-02-16 13:04 Gil Fine
  2021-02-16 13:04 ` [PATCH v2 1/2] " Gil Fine
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gil Fine @ 2021-02-16 13:04 UTC (permalink / raw)
  To: andreas.noever, michael.jamet, mika.westerberg, YehezkelShB
  Cc: gil.fine, linux-usb, lukas

Applies on top of thunderbolt.git/next.

v1 can be found here:

  https://lore.kernel.org/linux-usb/20210201214637.2158-1-gil.fine@intel.com/

Changes from v1:

  * Split the previous patch into two patches so that
    dropping of the unused functions reside in a separate patch

Gil Fine (2):
  thunderbolt: debugfs: handle fail reading block
  thunderbolt: drop unused functions for TGL and ICL

 drivers/thunderbolt/debugfs.c | 38 +++++++++++++++++++++++------------
 drivers/thunderbolt/tb.h      | 26 ------------------------
 2 files changed, 25 insertions(+), 39 deletions(-)

-- 
2.17.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


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

* [PATCH v2 1/2] thunderbolt: debugfs: handle fail reading block
  2021-02-16 13:04 [PATCH v2 0/2] thunderbolt: debugfs: handle fail reading block Gil Fine
@ 2021-02-16 13:04 ` Gil Fine
  2021-02-16 13:04 ` [PATCH v2 2/2] thunderbolt: drop unused functions for TGL and ICL Gil Fine
  2021-03-01 14:33 ` [PATCH v2 0/2] thunderbolt: debugfs: handle fail reading block Mika Westerberg
  2 siblings, 0 replies; 4+ messages in thread
From: Gil Fine @ 2021-02-16 13:04 UTC (permalink / raw)
  To: andreas.noever, michael.jamet, mika.westerberg, YehezkelShB
  Cc: gil.fine, linux-usb, lukas

There are cases when reading block of dwords in single transaction fail,
for several reasons, mostly if HW publish to implement all of the dwords,
while actually it doesn't or if some dwords not accessible for read
for security reasons. We handle these cases by trying to read the block,
dword-by-dword, one dword per transaction, till we get a failure.

Signed-off-by: Gil Fine <gil.fine@intel.com>
---
 drivers/thunderbolt/debugfs.c | 38 +++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/thunderbolt/debugfs.c b/drivers/thunderbolt/debugfs.c
index 9541d7409ab1..f1012eed9511 100644
--- a/drivers/thunderbolt/debugfs.c
+++ b/drivers/thunderbolt/debugfs.c
@@ -251,6 +251,30 @@ static ssize_t counters_write(struct file *file, const char __user *user_buf,
 	return ret < 0 ? ret : count;
 }
 
+static void cap_show_by_dw(struct seq_file *s, struct tb_switch *sw,
+			   struct tb_port *port, unsigned int cap, unsigned int offset,
+			   u8 cap_id, u8 vsec_id, int dwords)
+{
+	int i, ret;
+	u32 data;
+
+	for (i = 0; i < dwords; i++) {
+		if (port)
+			ret = tb_port_read(port, &data, TB_CFG_PORT, cap + offset + i, 1);
+		else
+			ret = tb_sw_read(sw, &data, TB_CFG_SWITCH, cap + offset + i, 1);
+		if (ret) {
+			seq_printf(s, "0x%04x <not accessible>\n", cap + offset);
+			if (dwords - i > 1)
+				seq_printf(s, "0x%04x ...\n", cap + offset + 1);
+			return;
+		}
+
+		seq_printf(s, "0x%04x %4d 0x%02x 0x%02x 0x%08x\n", cap + offset + i,
+			   offset + i, cap_id, vsec_id, data);
+	}
+}
+
 static void cap_show(struct seq_file *s, struct tb_switch *sw,
 		     struct tb_port *port, unsigned int cap, u8 cap_id,
 		     u8 vsec_id, int length)
@@ -267,10 +291,7 @@ static void cap_show(struct seq_file *s, struct tb_switch *sw,
 		else
 			ret = tb_sw_read(sw, data, TB_CFG_SWITCH, cap + offset, dwords);
 		if (ret) {
-			seq_printf(s, "0x%04x <not accessible>\n",
-				   cap + offset);
-			if (dwords > 1)
-				seq_printf(s, "0x%04x ...\n", cap + offset + 1);
+			cap_show_by_dw(s, sw, port, cap, offset, cap_id, vsec_id, dwords);
 			return;
 		}
 
@@ -341,15 +362,6 @@ static void port_cap_show(struct tb_port *port, struct seq_file *s,
 		} else {
 			length = header.extended_short.length;
 			vsec_id = header.extended_short.vsec_id;
-			/*
-			 * Ice Lake and Tiger Lake do not implement the
-			 * full length of the capability, only first 32
-			 * dwords so hard-code it here.
-			 */
-			if (!vsec_id &&
-			    (tb_switch_is_ice_lake(port->sw) ||
-			     tb_switch_is_tiger_lake(port->sw)))
-				length = 32;
 		}
 		break;
 
-- 
2.17.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


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

* [PATCH v2 2/2] thunderbolt: drop unused functions for TGL and ICL
  2021-02-16 13:04 [PATCH v2 0/2] thunderbolt: debugfs: handle fail reading block Gil Fine
  2021-02-16 13:04 ` [PATCH v2 1/2] " Gil Fine
@ 2021-02-16 13:04 ` Gil Fine
  2021-03-01 14:33 ` [PATCH v2 0/2] thunderbolt: debugfs: handle fail reading block Mika Westerberg
  2 siblings, 0 replies; 4+ messages in thread
From: Gil Fine @ 2021-02-16 13:04 UTC (permalink / raw)
  To: andreas.noever, michael.jamet, mika.westerberg, YehezkelShB
  Cc: gil.fine, linux-usb, lukas

We drop the unused functions:
tb_switch_is_tiger_lake() and tb_switch_is_ice_lake()

Signed-off-by: Gil Fine <gil.fine@intel.com>
---
 drivers/thunderbolt/tb.h | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index beea88c34c0f..0fd23db4ce92 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -787,32 +787,6 @@ static inline bool tb_switch_is_titan_ridge(const struct tb_switch *sw)
 	return false;
 }
 
-static inline bool tb_switch_is_ice_lake(const struct tb_switch *sw)
-{
-	if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
-		switch (sw->config.device_id) {
-		case PCI_DEVICE_ID_INTEL_ICL_NHI0:
-		case PCI_DEVICE_ID_INTEL_ICL_NHI1:
-			return true;
-		}
-	}
-	return false;
-}
-
-static inline bool tb_switch_is_tiger_lake(const struct tb_switch *sw)
-{
-	if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
-		switch (sw->config.device_id) {
-		case PCI_DEVICE_ID_INTEL_TGL_NHI0:
-		case PCI_DEVICE_ID_INTEL_TGL_NHI1:
-		case PCI_DEVICE_ID_INTEL_TGL_H_NHI0:
-		case PCI_DEVICE_ID_INTEL_TGL_H_NHI1:
-			return true;
-		}
-	}
-	return false;
-}
-
 /**
  * tb_switch_is_usb4() - Is the switch USB4 compliant
  * @sw: Switch to check
-- 
2.17.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


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

* Re: [PATCH v2 0/2] thunderbolt: debugfs: handle fail reading block
  2021-02-16 13:04 [PATCH v2 0/2] thunderbolt: debugfs: handle fail reading block Gil Fine
  2021-02-16 13:04 ` [PATCH v2 1/2] " Gil Fine
  2021-02-16 13:04 ` [PATCH v2 2/2] thunderbolt: drop unused functions for TGL and ICL Gil Fine
@ 2021-03-01 14:33 ` Mika Westerberg
  2 siblings, 0 replies; 4+ messages in thread
From: Mika Westerberg @ 2021-03-01 14:33 UTC (permalink / raw)
  To: Gil Fine; +Cc: andreas.noever, michael.jamet, YehezkelShB, linux-usb, lukas

On Tue, Feb 16, 2021 at 03:04:25PM +0200, Gil Fine wrote:
> Applies on top of thunderbolt.git/next.
> 
> v1 can be found here:
> 
>   https://lore.kernel.org/linux-usb/20210201214637.2158-1-gil.fine@intel.com/
> 
> Changes from v1:
> 
>   * Split the previous patch into two patches so that
>     dropping of the unused functions reside in a separate patch
> 
> Gil Fine (2):
>   thunderbolt: debugfs: handle fail reading block
>   thunderbolt: drop unused functions for TGL and ICL

I did some minor edits to the patches and applied to
thunderbolt.git/next, thanks!

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

end of thread, other threads:[~2021-03-01 14:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 13:04 [PATCH v2 0/2] thunderbolt: debugfs: handle fail reading block Gil Fine
2021-02-16 13:04 ` [PATCH v2 1/2] " Gil Fine
2021-02-16 13:04 ` [PATCH v2 2/2] thunderbolt: drop unused functions for TGL and ICL Gil Fine
2021-03-01 14:33 ` [PATCH v2 0/2] thunderbolt: debugfs: handle fail reading block Mika Westerberg

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