Skip to content

Commit 3cea8af

Browse files
Gil Finewesteri
Gil Fine
authored andcommitted
thunderbolt: Honor TMU requirements in the domain when setting TMU mode
Currently, when configuring TMU (Time Management Unit) mode of a given router, we take into account only its own TMU requirements ignoring other routers in the domain. This is problematic if the router we are configuring has lower TMU requirements than what is already configured in the domain. In the scenario below, we have a host router with two USB4 ports: A and B. Port A connected to device router #1 (which supports CL states) and existing DisplayPort tunnel, thus, the TMU mode is HiFi uni-directional. 1. Initial topology [Host] A/ / [Device #1] / Monitor 2. Plug in device #2 (that supports CL states) to downstream port B of the host router [Host] A/ B\ / \ [Device #1] [Device #2] / Monitor The TMU mode on port B and port A will be configured to LowRes which is not what we want and will cause monitor to start flickering. To address this we first scan the domain and search for any router configured to HiFi uni-directional mode, and if found, configure TMU mode of the given router to HiFi uni-directional as well. Cc: stable@vger.kernel.org Signed-off-by: Gil Fine <gil.fine@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
1 parent e9e1b20 commit 3cea8af

File tree

1 file changed

+42
-6
lines changed
  • drivers/thunderbolt

1 file changed

+42
-6
lines changed

drivers/thunderbolt/tb.c

+42-6
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,24 @@ static void tb_increase_tmu_accuracy(struct tb_tunnel *tunnel)
288288
device_for_each_child(&sw->dev, NULL, tb_increase_switch_tmu_accuracy);
289289
}
290290

291+
static int tb_switch_tmu_hifi_uni_required(struct device *dev, void *not_used)
292+
{
293+
struct tb_switch *sw = tb_to_switch(dev);
294+
295+
if (sw && tb_switch_tmu_is_enabled(sw) &&
296+
tb_switch_tmu_is_configured(sw, TB_SWITCH_TMU_MODE_HIFI_UNI))
297+
return 1;
298+
299+
return device_for_each_child(dev, NULL,
300+
tb_switch_tmu_hifi_uni_required);
301+
}
302+
303+
static bool tb_tmu_hifi_uni_required(struct tb *tb)
304+
{
305+
return device_for_each_child(&tb->dev, NULL,
306+
tb_switch_tmu_hifi_uni_required) == 1;
307+
}
308+
291309
static int tb_enable_tmu(struct tb_switch *sw)
292310
{
293311
int ret;
@@ -302,12 +320,30 @@ static int tb_enable_tmu(struct tb_switch *sw)
302320
ret = tb_switch_tmu_configure(sw,
303321
TB_SWITCH_TMU_MODE_MEDRES_ENHANCED_UNI);
304322
if (ret == -EOPNOTSUPP) {
305-
if (tb_switch_clx_is_enabled(sw, TB_CL1))
306-
ret = tb_switch_tmu_configure(sw,
307-
TB_SWITCH_TMU_MODE_LOWRES);
308-
else
309-
ret = tb_switch_tmu_configure(sw,
310-
TB_SWITCH_TMU_MODE_HIFI_BI);
323+
if (tb_switch_clx_is_enabled(sw, TB_CL1)) {
324+
/*
325+
* Figure out uni-directional HiFi TMU requirements
326+
* currently in the domain. If there are no
327+
* uni-directional HiFi requirements we can put the TMU
328+
* into LowRes mode.
329+
*
330+
* Deliberately skip bi-directional HiFi links
331+
* as these work independently of other links
332+
* (and they do not allow any CL states anyway).
333+
*/
334+
if (tb_tmu_hifi_uni_required(sw->tb))
335+
ret = tb_switch_tmu_configure(sw,
336+
TB_SWITCH_TMU_MODE_HIFI_UNI);
337+
else
338+
ret = tb_switch_tmu_configure(sw,
339+
TB_SWITCH_TMU_MODE_LOWRES);
340+
} else {
341+
ret = tb_switch_tmu_configure(sw, TB_SWITCH_TMU_MODE_HIFI_BI);
342+
}
343+
344+
/* If not supported, fallback to bi-directional HiFi */
345+
if (ret == -EOPNOTSUPP)
346+
ret = tb_switch_tmu_configure(sw, TB_SWITCH_TMU_MODE_HIFI_BI);
311347
}
312348
if (ret)
313349
return ret;

0 commit comments

Comments
 (0)