* [PATCH] thunderbolt: debugfs: Fix margin debugfs node creation condition
@ 2024-05-29 12:36 Mika Westerberg
2024-05-31 10:15 ` Mika Westerberg
0 siblings, 1 reply; 2+ messages in thread
From: Mika Westerberg @ 2024-05-29 12:36 UTC (permalink / raw)
To: linux-usb
Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
Aapo Vienamo, Mika Westerberg
From: Aapo Vienamo <aapo.vienamo@linux.intel.com>
The margin debugfs node controls the "Enable Margin Test" field of the
lane margining operations. This field selects between either low or high
voltage margin values for voltage margin test or left or right timing
margin values for timing margin test.
According to the USB4 specification, whether or not the "Enable Margin
Test" control applies, depends on the values of the "Independent
High/Low Voltage Margin" or "Independent Left/Right Timing Margin"
capability fields for voltage and timing margin tests respectively. The
pre-existing condition enabled the debugfs node also in the case where
both low/high or left/right margins are returned, which is incorrect.
This change only enables the debugfs node in question, if the specific
required capability values are met.
Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Fixes: d0f1e0c2a699 ("thunderbolt: Add support for receiver lane margining")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/debugfs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/thunderbolt/debugfs.c b/drivers/thunderbolt/debugfs.c
index 193e9dfc983b..70b52aac3d97 100644
--- a/drivers/thunderbolt/debugfs.c
+++ b/drivers/thunderbolt/debugfs.c
@@ -943,8 +943,9 @@ static void margining_port_init(struct tb_port *port)
debugfs_create_file("run", 0600, dir, port, &margining_run_fops);
debugfs_create_file("results", 0600, dir, port, &margining_results_fops);
debugfs_create_file("test", 0600, dir, port, &margining_test_fops);
- if (independent_voltage_margins(usb4) ||
- (supports_time(usb4) && independent_time_margins(usb4)))
+ if (independent_voltage_margins(usb4) == USB4_MARGIN_CAP_0_VOLTAGE_HL ||
+ (supports_time(usb4) &&
+ independent_time_margins(usb4) == USB4_MARGIN_CAP_1_TIME_LR))
debugfs_create_file("margin", 0600, dir, port, &margining_margin_fops);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] thunderbolt: debugfs: Fix margin debugfs node creation condition
2024-05-29 12:36 [PATCH] thunderbolt: debugfs: Fix margin debugfs node creation condition Mika Westerberg
@ 2024-05-31 10:15 ` Mika Westerberg
0 siblings, 0 replies; 2+ messages in thread
From: Mika Westerberg @ 2024-05-31 10:15 UTC (permalink / raw)
To: linux-usb
Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
Aapo Vienamo
On Wed, May 29, 2024 at 03:36:47PM +0300, Mika Westerberg wrote:
> From: Aapo Vienamo <aapo.vienamo@linux.intel.com>
>
> The margin debugfs node controls the "Enable Margin Test" field of the
> lane margining operations. This field selects between either low or high
> voltage margin values for voltage margin test or left or right timing
> margin values for timing margin test.
>
> According to the USB4 specification, whether or not the "Enable Margin
> Test" control applies, depends on the values of the "Independent
> High/Low Voltage Margin" or "Independent Left/Right Timing Margin"
> capability fields for voltage and timing margin tests respectively. The
> pre-existing condition enabled the debugfs node also in the case where
> both low/high or left/right margins are returned, which is incorrect.
> This change only enables the debugfs node in question, if the specific
> required capability values are met.
>
> Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
> Fixes: d0f1e0c2a699 ("thunderbolt: Add support for receiver lane margining")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Applied to thunderbolt.git/fixes.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-31 10:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 12:36 [PATCH] thunderbolt: debugfs: Fix margin debugfs node creation condition Mika Westerberg
2024-05-31 10:15 ` 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.