All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] thunderbolt: Additional minor improvements
@ 2020-09-09 10:59 Mika Westerberg
  2020-09-09 10:59 ` [PATCH 2/7] thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m Mika Westerberg
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Mika Westerberg @ 2020-09-09 10:59 UTC (permalink / raw)
  To: linux-usb
  Cc: Michael Jamet, Yehezkel Bernat, Andreas Noever, Lukas Wunner,
	Mika Westerberg

Hi all,

This series has some additional minor improvements and cleanups from my
internal development tree. All of this is v5.10 material and apply on top
of thunderbolt.git/next.

Mika Westerberg (7):
  thunderbolt: Only stop control channel when entering freeze
  thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m
  thunderbolt: Use "if USB4" instead of "depends on" in Kconfig
  thunderbolt: Handle ERR_LOCK notification
  thunderbolt: Log correct zeroX entries in decode_error()
  thunderbolt: Correct tb_check_quirks() kernel-doc
  thunderbolt: Capitalize comment on top of QUIRK_FORCE_POWER_LINK_CONTROLLER

 drivers/thunderbolt/Kconfig   |  6 ++++--
 drivers/thunderbolt/Makefile  |  3 +--
 drivers/thunderbolt/ctl.c     | 18 +++++++++++++++---
 drivers/thunderbolt/domain.c  | 31 +++++++++++++++++++++++++++++++
 drivers/thunderbolt/nhi.c     | 21 ++++++++++++++++++---
 drivers/thunderbolt/quirks.c  |  2 +-
 drivers/thunderbolt/tb.c      | 18 ++++++++++++++++++
 drivers/thunderbolt/tb.h      | 16 +++++++++++++++-
 drivers/thunderbolt/tb_msgs.h |  1 +
 drivers/thunderbolt/test.c    | 13 ++++++++++++-
 10 files changed, 116 insertions(+), 13 deletions(-)

-- 
2.28.0


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

* [PATCH 2/7] thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m
  2020-09-09 10:59 [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
@ 2020-09-09 10:59 ` Mika Westerberg
  2020-09-09 10:59 ` [PATCH 3/7] thunderbolt: Use "if USB4" instead of "depends on" in Kconfig Mika Westerberg
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2020-09-09 10:59 UTC (permalink / raw)
  To: linux-usb
  Cc: Michael Jamet, Yehezkel Bernat, Andreas Noever, Lukas Wunner,
	Mika Westerberg

This adds a bit more build coverage for the tests even though these are
not expected to be enabled by normal users and distros. In order to make
this working we need to open-code kunit_test_suite() and call the
relevant functions directly in the driver init/exit hook.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/Kconfig  |  2 +-
 drivers/thunderbolt/Makefile |  3 +--
 drivers/thunderbolt/domain.c |  4 ++++
 drivers/thunderbolt/tb.h     |  8 ++++++++
 drivers/thunderbolt/test.c   | 13 ++++++++++++-
 5 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/thunderbolt/Kconfig b/drivers/thunderbolt/Kconfig
index 2257c22f8ab3..afa3551633aa 100644
--- a/drivers/thunderbolt/Kconfig
+++ b/drivers/thunderbolt/Kconfig
@@ -28,5 +28,5 @@ config USB4_DEBUGFS_WRITE
 
 config USB4_KUNIT_TEST
 	bool "KUnit tests"
+	depends on USB4
 	depends on KUNIT=y
-	depends on USB4=y
diff --git a/drivers/thunderbolt/Makefile b/drivers/thunderbolt/Makefile
index 61d5dff445b6..571537371072 100644
--- a/drivers/thunderbolt/Makefile
+++ b/drivers/thunderbolt/Makefile
@@ -6,5 +6,4 @@ thunderbolt-objs += nvm.o retimer.o quirks.o
 
 thunderbolt-${CONFIG_ACPI} += acpi.o
 thunderbolt-$(CONFIG_DEBUG_FS) += debugfs.o
-
-obj-${CONFIG_USB4_KUNIT_TEST} += test.o
+thunderbolt-${CONFIG_USB4_KUNIT_TEST} += test.o
diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c
index a0182bf5a5f8..f0de94f7acbf 100644
--- a/drivers/thunderbolt/domain.c
+++ b/drivers/thunderbolt/domain.c
@@ -827,6 +827,8 @@ int tb_domain_init(void)
 {
 	int ret;
 
+	tb_test_init();
+
 	tb_debugfs_init();
 	ret = tb_xdomain_init();
 	if (ret)
@@ -841,6 +843,7 @@ int tb_domain_init(void)
 	tb_xdomain_exit();
 err_debugfs:
 	tb_debugfs_exit();
+	tb_test_exit();
 
 	return ret;
 }
@@ -852,4 +855,5 @@ void tb_domain_exit(void)
 	tb_nvm_exit();
 	tb_xdomain_exit();
 	tb_debugfs_exit();
+	tb_test_exit();
 }
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 8b04a9deffc7..5687bcf38a9e 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -1030,4 +1030,12 @@ static inline void tb_switch_debugfs_init(struct tb_switch *sw) { }
 static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { }
 #endif
 
+#ifdef CONFIG_USB4_KUNIT_TEST
+int tb_test_init(void);
+void tb_test_exit(void);
+#else
+static inline int tb_test_init(void) { return 0; }
+static inline void tb_test_exit(void) { }
+#endif
+
 #endif
diff --git a/drivers/thunderbolt/test.c b/drivers/thunderbolt/test.c
index a4d78811f7e2..464c2d37b992 100644
--- a/drivers/thunderbolt/test.c
+++ b/drivers/thunderbolt/test.c
@@ -1623,4 +1623,15 @@ static struct kunit_suite tb_test_suite = {
 	.name = "thunderbolt",
 	.test_cases = tb_test_cases,
 };
-kunit_test_suite(tb_test_suite);
+
+static struct kunit_suite *tb_test_suites[] = { &tb_test_suite, NULL };
+
+int tb_test_init(void)
+{
+	return __kunit_test_suites_init(tb_test_suites);
+}
+
+void tb_test_exit(void)
+{
+	return __kunit_test_suites_exit(tb_test_suites);
+}
-- 
2.28.0


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

* [PATCH 3/7] thunderbolt: Use "if USB4" instead of "depends on" in Kconfig
  2020-09-09 10:59 [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
  2020-09-09 10:59 ` [PATCH 2/7] thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m Mika Westerberg
@ 2020-09-09 10:59 ` Mika Westerberg
  2020-09-09 10:59 ` [PATCH 4/7] thunderbolt: Handle ERR_LOCK notification Mika Westerberg
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2020-09-09 10:59 UTC (permalink / raw)
  To: linux-usb
  Cc: Michael Jamet, Yehezkel Bernat, Andreas Noever, Lukas Wunner,
	Mika Westerberg

This groups the USB4 options more nicely, and also does not require that
every config option lists explicit depends on USB4.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/thunderbolt/Kconfig b/drivers/thunderbolt/Kconfig
index afa3551633aa..7fc058f81d00 100644
--- a/drivers/thunderbolt/Kconfig
+++ b/drivers/thunderbolt/Kconfig
@@ -16,9 +16,10 @@ menuconfig USB4
 	  To compile this driver a module, choose M here. The module will be
 	  called thunderbolt.
 
+if USB4
+
 config USB4_DEBUGFS_WRITE
 	bool "Enable write by debugfs to configuration spaces (DANGEROUS)"
-	depends on USB4
 	help
 	  Enables writing to device configuration registers through
 	  debugfs interface.
@@ -28,5 +29,6 @@ config USB4_DEBUGFS_WRITE
 
 config USB4_KUNIT_TEST
 	bool "KUnit tests"
-	depends on USB4
 	depends on KUNIT=y
+
+endif # USB4
-- 
2.28.0


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

* [PATCH 4/7] thunderbolt: Handle ERR_LOCK notification
  2020-09-09 10:59 [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
  2020-09-09 10:59 ` [PATCH 2/7] thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m Mika Westerberg
  2020-09-09 10:59 ` [PATCH 3/7] thunderbolt: Use "if USB4" instead of "depends on" in Kconfig Mika Westerberg
@ 2020-09-09 10:59 ` Mika Westerberg
  2020-09-09 10:59 ` [PATCH 5/7] thunderbolt: Log correct zeroX entries in decode_error() Mika Westerberg
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2020-09-09 10:59 UTC (permalink / raw)
  To: linux-usb
  Cc: Michael Jamet, Yehezkel Bernat, Andreas Noever, Lukas Wunner,
	Mika Westerberg

If the USB4 router downstream port is locked, sending configuration
packet to a router below it causes ERR_LOCK to be sent. Instead of warn
splat about unknown error we log the error (just warning level) and
return -EACCESS instead. The idea is that we may want to do something
when such error code is received, like perform unlock.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/ctl.c     | 7 +++++++
 drivers/thunderbolt/tb_msgs.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index 2364efa23991..88b40b3b3ad7 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -282,6 +282,10 @@ static void tb_cfg_print_error(struct tb_ctl *ctl,
 		tb_ctl_WARN(ctl, "CFG_ERROR(%llx:%x): Route contains a loop\n",
 			res->response_route, res->response_port);
 		return;
+	case TB_CFG_ERROR_LOCK:
+		tb_ctl_warn(ctl, "%llx:%x: downstream port is locked\n",
+			    res->response_route, res->response_port);
+		return;
 	default:
 		/* 5,6,7,9 and 11 are also valid error codes */
 		tb_ctl_WARN(ctl, "CFG_ERROR(%llx:%x): Unknown error\n",
@@ -950,6 +954,9 @@ static int tb_cfg_get_error(struct tb_ctl *ctl, enum tb_cfg_space space,
 		return -ENODEV;
 
 	tb_cfg_print_error(ctl, res);
+
+	if (res->tb_error == TB_CFG_ERROR_LOCK)
+		return -EACCES;
 	return -EIO;
 }
 
diff --git a/drivers/thunderbolt/tb_msgs.h b/drivers/thunderbolt/tb_msgs.h
index fc208c567953..0e01dbc63e72 100644
--- a/drivers/thunderbolt/tb_msgs.h
+++ b/drivers/thunderbolt/tb_msgs.h
@@ -28,6 +28,7 @@ enum tb_cfg_error {
 	TB_CFG_ERROR_LOOP = 8,
 	TB_CFG_ERROR_HEC_ERROR_DETECTED = 12,
 	TB_CFG_ERROR_FLOW_CONTROL_ERROR = 13,
+	TB_CFG_ERROR_LOCK = 15,
 };
 
 /* common header */
-- 
2.28.0


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

* [PATCH 5/7] thunderbolt: Log correct zeroX entries in decode_error()
  2020-09-09 10:59 [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
                   ` (2 preceding siblings ...)
  2020-09-09 10:59 ` [PATCH 4/7] thunderbolt: Handle ERR_LOCK notification Mika Westerberg
@ 2020-09-09 10:59 ` Mika Westerberg
  2020-09-09 11:00 ` [PATCH 6/7] thunderbolt: Correct tb_check_quirks() kernel-doc Mika Westerberg
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2020-09-09 10:59 UTC (permalink / raw)
  To: linux-usb
  Cc: Michael Jamet, Yehezkel Bernat, Andreas Noever, Lukas Wunner,
	Mika Westerberg

There was copy & paste error so it always printed value of pkg->zero1.
Also use tb_ctl_warn() here, no need to print backtrace.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/ctl.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index 88b40b3b3ad7..9894b8f63064 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -219,6 +219,7 @@ static int check_config_address(struct tb_cfg_address addr,
 static struct tb_cfg_result decode_error(const struct ctl_pkg *response)
 {
 	struct cfg_error_pkg *pkg = response->buffer;
+	struct tb_ctl *ctl = response->ctl;
 	struct tb_cfg_result res = { 0 };
 	res.response_route = tb_cfg_get_route(&pkg->header);
 	res.response_port = 0;
@@ -227,9 +228,13 @@ static struct tb_cfg_result decode_error(const struct ctl_pkg *response)
 	if (res.err)
 		return res;
 
-	WARN(pkg->zero1, "pkg->zero1 is %#x\n", pkg->zero1);
-	WARN(pkg->zero2, "pkg->zero1 is %#x\n", pkg->zero1);
-	WARN(pkg->zero3, "pkg->zero1 is %#x\n", pkg->zero1);
+	if (pkg->zero1)
+		tb_ctl_warn(ctl, "pkg->zero1 is %#x\n", pkg->zero1);
+	if (pkg->zero2)
+		tb_ctl_warn(ctl, "pkg->zero2 is %#x\n", pkg->zero2);
+	if (pkg->zero3)
+		tb_ctl_warn(ctl, "pkg->zero3 is %#x\n", pkg->zero3);
+
 	res.err = 1;
 	res.tb_error = pkg->error;
 	res.response_port = pkg->port;
-- 
2.28.0


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

* [PATCH 6/7] thunderbolt: Correct tb_check_quirks() kernel-doc
  2020-09-09 10:59 [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
                   ` (3 preceding siblings ...)
  2020-09-09 10:59 ` [PATCH 5/7] thunderbolt: Log correct zeroX entries in decode_error() Mika Westerberg
@ 2020-09-09 11:00 ` Mika Westerberg
  2020-09-09 11:00 ` [PATCH 7/7] thunderbolt: Capitalize comment on top of QUIRK_FORCE_POWER_LINK_CONTROLLER Mika Westerberg
  2020-09-16 12:03 ` [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2020-09-09 11:00 UTC (permalink / raw)
  To: linux-usb
  Cc: Michael Jamet, Yehezkel Bernat, Andreas Noever, Lukas Wunner,
	Mika Westerberg

Remove extra white space and make the sentence end with a period.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/quirks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/quirks.c b/drivers/thunderbolt/quirks.c
index 7eac3e0f90a2..57e2978a3c21 100644
--- a/drivers/thunderbolt/quirks.c
+++ b/drivers/thunderbolt/quirks.c
@@ -27,7 +27,7 @@ static const struct tb_quirk tb_quirks[] = {
  * tb_check_quirks() - Check for quirks to apply
  * @sw: Thunderbolt switch
  *
- *  Apply any quirks for the Thunderbolt controller
+ * Apply any quirks for the Thunderbolt controller.
  */
 void tb_check_quirks(struct tb_switch *sw)
 {
-- 
2.28.0


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

* [PATCH 7/7] thunderbolt: Capitalize comment on top of QUIRK_FORCE_POWER_LINK_CONTROLLER
  2020-09-09 10:59 [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
                   ` (4 preceding siblings ...)
  2020-09-09 11:00 ` [PATCH 6/7] thunderbolt: Correct tb_check_quirks() kernel-doc Mika Westerberg
@ 2020-09-09 11:00 ` Mika Westerberg
  2020-09-16 12:03 ` [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2020-09-09 11:00 UTC (permalink / raw)
  To: linux-usb
  Cc: Michael Jamet, Yehezkel Bernat, Andreas Noever, Lukas Wunner,
	Mika Westerberg

To keep it consistent with the other single line comments in the driver.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 5687bcf38a9e..7754b0b2ea66 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -1007,7 +1007,7 @@ int usb4_usb3_port_allocate_bandwidth(struct tb_port *port, int *upstream_bw,
 int usb4_usb3_port_release_bandwidth(struct tb_port *port, int *upstream_bw,
 				     int *downstream_bw);
 
-/* keep link controller awake during update */
+/* Keep link controller awake during update */
 #define QUIRK_FORCE_POWER_LINK_CONTROLLER		BIT(0)
 
 void tb_check_quirks(struct tb_switch *sw);
-- 
2.28.0


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

* Re: [PATCH 0/7] thunderbolt: Additional minor improvements
  2020-09-09 10:59 [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
                   ` (5 preceding siblings ...)
  2020-09-09 11:00 ` [PATCH 7/7] thunderbolt: Capitalize comment on top of QUIRK_FORCE_POWER_LINK_CONTROLLER Mika Westerberg
@ 2020-09-16 12:03 ` Mika Westerberg
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2020-09-16 12:03 UTC (permalink / raw)
  To: linux-usb; +Cc: Michael Jamet, Yehezkel Bernat, Andreas Noever, Lukas Wunner

On Wed, Sep 09, 2020 at 01:59:54PM +0300, Mika Westerberg wrote:
> Hi all,
> 
> This series has some additional minor improvements and cleanups from my
> internal development tree. All of this is v5.10 material and apply on top
> of thunderbolt.git/next.
> 
> Mika Westerberg (7):
>   thunderbolt: Only stop control channel when entering freeze
>   thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m
>   thunderbolt: Use "if USB4" instead of "depends on" in Kconfig
>   thunderbolt: Handle ERR_LOCK notification
>   thunderbolt: Log correct zeroX entries in decode_error()
>   thunderbolt: Correct tb_check_quirks() kernel-doc
>   thunderbolt: Capitalize comment on top of QUIRK_FORCE_POWER_LINK_CONTROLLER
> 
>  drivers/thunderbolt/Kconfig   |  6 ++++--
>  drivers/thunderbolt/Makefile  |  3 +--
>  drivers/thunderbolt/ctl.c     | 18 +++++++++++++++---
>  drivers/thunderbolt/domain.c  | 31 +++++++++++++++++++++++++++++++
>  drivers/thunderbolt/nhi.c     | 21 ++++++++++++++++++---
>  drivers/thunderbolt/quirks.c  |  2 +-
>  drivers/thunderbolt/tb.c      | 18 ++++++++++++++++++
>  drivers/thunderbolt/tb.h      | 16 +++++++++++++++-
>  drivers/thunderbolt/tb_msgs.h |  1 +
>  drivers/thunderbolt/test.c    | 13 ++++++++++++-
>  10 files changed, 116 insertions(+), 13 deletions(-)

All applied to thunderbolt.git/next.

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

end of thread, other threads:[~2020-09-16 18:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 10:59 [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg
2020-09-09 10:59 ` [PATCH 2/7] thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m Mika Westerberg
2020-09-09 10:59 ` [PATCH 3/7] thunderbolt: Use "if USB4" instead of "depends on" in Kconfig Mika Westerberg
2020-09-09 10:59 ` [PATCH 4/7] thunderbolt: Handle ERR_LOCK notification Mika Westerberg
2020-09-09 10:59 ` [PATCH 5/7] thunderbolt: Log correct zeroX entries in decode_error() Mika Westerberg
2020-09-09 11:00 ` [PATCH 6/7] thunderbolt: Correct tb_check_quirks() kernel-doc Mika Westerberg
2020-09-09 11:00 ` [PATCH 7/7] thunderbolt: Capitalize comment on top of QUIRK_FORCE_POWER_LINK_CONTROLLER Mika Westerberg
2020-09-16 12:03 ` [PATCH 0/7] thunderbolt: Additional minor improvements Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.