Commit 1cb36293 authored by Mario Limonciello's avatar Mario Limonciello Committed by Mika Westerberg
Browse files

thunderbolt: Add support for authenticate on disconnect



Some external devices can support completing thunderbolt authentication
when they are unplugged. For this to work though, the link controller must
remain operational.

The only device known to support this right now is the Dell WD19TB, so add
a quirk for this.

Signed-off-by: default avatarMario Limonciello <mario.limonciello@dell.com>
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 4b794f80
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -276,3 +276,16 @@ Date: Oct 2020
KernelVersion:	v5.9
Contact:	Mika Westerberg <mika.westerberg@linux.intel.com>
Description:	Retimer vendor identifier read from the hardware.

What:		/sys/bus/thunderbolt/devices/.../nvm_authenticate_on_disconnect
Date:		Oct 2020
KernelVersion:	v5.9
Contact:	Mario Limonciello <mario.limonciello@dell.com>
Description:	For supported devices, automatically authenticate the new Thunderbolt
		image when the device is disconnected from the host system.

		This file will accept writing values "1" or "2"
		- Writing "1" will flush the image to the storage
		area and prepare the device for authentication on disconnect.
		- Writing "2" will run some basic validation on the image
		and flush it to the storage area.
+1 −1
Original line number Diff line number Diff line
@@ -2,6 +2,6 @@
obj-${CONFIG_USB4} := thunderbolt.o
thunderbolt-objs := nhi.o nhi_ops.o ctl.o tb.o switch.o cap.o path.o tunnel.o eeprom.o
thunderbolt-objs += domain.o dma_port.o icm.o property.o xdomain.o lc.o tmu.o usb4.o
thunderbolt-objs += nvm.o retimer.o
thunderbolt-objs += nvm.o retimer.o quirks.o

obj-${CONFIG_USB4_KUNIT_TEST} += test.o
+1 −0
Original line number Diff line number Diff line
@@ -599,6 +599,7 @@ parse:
		sw->uid = header->uid;
	sw->vendor = header->vendor_id;
	sw->device = header->model_id;
	tb_check_quirks(sw);

	crc = tb_crc32(sw->drom + TB_DROM_DATA_START, header->data_len);
	if (crc != header->data_crc32) {
+14 −0
Original line number Diff line number Diff line
@@ -366,3 +366,17 @@ int tb_lc_dp_sink_dealloc(struct tb_switch *sw, struct tb_port *in)
	tb_port_dbg(in, "sink %d de-allocated\n", sink);
	return 0;
}

/**
 * tb_lc_force_power() - Forces LC to be powered on
 * @sw: Thunderbolt switch
 *
 * This is useful to let authentication cycle pass even without
 * a Thunderbolt link present.
 */
int tb_lc_force_power(struct tb_switch *sw)
{
	u32 in = 0xffff;

	return tb_sw_write(sw, &in, TB_CFG_SWITCH, TB_LC_POWER, 1);
}
+42 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Thunderbolt driver - quirks
 *
 * Copyright (c) 2020 Mario Limonciello <mario.limonciello@dell.com>
 */

#include "tb.h"

static void quirk_force_power_link(struct tb_switch *sw)
{
	sw->quirks |= QUIRK_FORCE_POWER_LINK_CONTROLLER;
}

struct tb_quirk {
	u16 vendor;
	u16 device;
	void (*hook)(struct tb_switch *sw);
};

const static struct tb_quirk tb_quirks[] = {
	/* Dell WD19TB supports self-authentication on unplug */
	{ 0x00d4, 0xb070, quirk_force_power_link },
};

/**
 * tb_check_quirks() - Check for quirks to apply
 * @sw: Thunderbolt switch
 *
 *  Apply any quirks for the Thunderbolt controller
 */
void tb_check_quirks(struct tb_switch *sw)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(tb_quirks); i++) {
		const struct tb_quirk *q = &tb_quirks[i];

		if (sw->device == q->device && sw->vendor == q->vendor)
			q->hook(sw);
	}
}
Loading