Commit cd1be4b2 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'thunderbolt-for-v7.1-rc1' of...

Merge tag 'thunderbolt-for-v7.1-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-next

Mika writes:

thunderbolt: Changes for v7.1 merge window

This includes following USB4/Thunderbolt changes for the v7.1 merge
window:

  - Disable CL-states for Titan Ridge based devices with older firmware.
  - MAINTAINER update.
  - Simplify allocation of various structures with kzalloc_flex().

All these have been in linux-next with no reported issues.

* tag 'thunderbolt-for-v7.1-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
  thunderbolt: tunnel: Simplify allocation
  thunderbolt: Use kzalloc_flex() for struct tb_path allocation
  thunderbolt: dma_port: kmalloc_array + kzalloc to flex
  MAINTAINERS: Remove bouncing maintainer, Mika takes over DMA test driver
  thunderbolt: Disable CLx on Titan Ridge-based devices with old firmware
  thunderbolt: Read router NVM version before applying quirks
parents 8f993d30 498c0582
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26310,7 +26310,7 @@ F: drivers/media/i2c/thp7312.c
F:	include/uapi/linux/thp7312.h
THUNDERBOLT DMA TRAFFIC TEST DRIVER
M:	Isaac Hazan <isaac.hazan@intel.com>
M:	Mika Westerberg <westeri@kernel.org>
L:	linux-usb@vger.kernel.org
S:	Maintained
F:	drivers/thunderbolt/dma_test.c
+3 −12
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ struct tb_dma_port {
	struct tb_switch *sw;
	u8 port;
	u32 base;
	u8 *buf;
	u8 buf[];
};

/*
@@ -209,16 +209,10 @@ struct tb_dma_port *dma_port_alloc(struct tb_switch *sw)
	if (port < 0)
		return NULL;

	dma = kzalloc_obj(*dma);
	dma = kzalloc_flex(*dma, buf, MAIL_DATA_DWORDS);
	if (!dma)
		return NULL;

	dma->buf = kmalloc_array(MAIL_DATA_DWORDS, sizeof(u32), GFP_KERNEL);
	if (!dma->buf) {
		kfree(dma);
		return NULL;
	}

	dma->sw = sw;
	dma->port = port;
	dma->base = DMA_PORT_CAP;
@@ -232,11 +226,8 @@ struct tb_dma_port *dma_port_alloc(struct tb_switch *sw)
 */
void dma_port_free(struct tb_dma_port *dma)
{
	if (dma) {
		kfree(dma->buf);
	kfree(dma);
}
}

static int dma_port_wait_for_completion(struct tb_dma_port *dma,
					unsigned int timeout)
+7 −21
Original line number Diff line number Diff line
@@ -150,22 +150,17 @@ struct tb_path *tb_path_discover(struct tb_port *src, int src_hopid,
		num_hops++;
	}

	path = kzalloc_obj(*path);
	path = kzalloc_flex(*path, hops, num_hops);
	if (!path)
		return NULL;

	path->path_length = num_hops;

	path->name = name;
	path->tb = src->sw->tb;
	path->path_length = num_hops;
	path->activated = true;
	path->alloc_hopid = alloc_hopid;

	path->hops = kzalloc_objs(*path->hops, num_hops);
	if (!path->hops) {
		kfree(path);
		return NULL;
	}

	tb_dbg(path->tb, "discovering %s path starting from %llx:%u\n",
	       path->name, tb_route(src->sw), src->port);

@@ -245,10 +240,6 @@ struct tb_path *tb_path_alloc(struct tb *tb, struct tb_port *src, int src_hopid,
	size_t num_hops;
	int i, ret;

	path = kzalloc_obj(*path);
	if (!path)
		return NULL;

	first_port = last_port = NULL;
	i = 0;
	tb_for_each_port_on_path(src, dst, in_port) {
@@ -259,20 +250,17 @@ struct tb_path *tb_path_alloc(struct tb *tb, struct tb_port *src, int src_hopid,
	}

	/* Check that src and dst are reachable */
	if (first_port != src || last_port != dst) {
		kfree(path);
	if (first_port != src || last_port != dst)
		return NULL;
	}

	/* Each hop takes two ports */
	num_hops = i / 2;

	path->hops = kzalloc_objs(*path->hops, num_hops);
	if (!path->hops) {
		kfree(path);
	path = kzalloc_flex(*path, hops, num_hops);
	if (!path)
		return NULL;
	}

	path->path_length = num_hops;
	path->alloc_hopid = true;

	in_hopid = src_hopid;
@@ -339,7 +327,6 @@ struct tb_path *tb_path_alloc(struct tb *tb, struct tb_port *src, int src_hopid,
	}

	path->tb = tb;
	path->path_length = num_hops;
	path->name = name;

	return path;
@@ -372,7 +359,6 @@ void tb_path_free(struct tb_path *path)
		}
	}

	kfree(path->hops);
	kfree(path);
}

+7 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ static void quirk_dp_credit_allocation(struct tb_switch *sw)

static void quirk_clx_disable(struct tb_switch *sw)
{
	if (tb_switch_is_titan_ridge(sw) && sw->nvm && sw->nvm->major >= 0x65)
		return;

	sw->quirks |= QUIRK_NO_CLX;
	tb_sw_dbg(sw, "disabling CL states\n");
}
@@ -61,6 +64,10 @@ static const struct tb_quirk tb_quirks[] = {
	/* Dell WD19TB supports self-authentication on unplug */
	{ 0x0000, 0x0000, 0x00d4, 0xb070, quirk_force_power_link },
	{ 0x0000, 0x0000, 0x00d4, 0xb071, quirk_force_power_link },

	/* Intel Titan Ridge CLx is unstable on early firmware versions */
	{ 0x8086, PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_BRIDGE, 0x0000, 0x0000,
		  quirk_clx_disable },
	/*
	 * Intel Goshen Ridge NVM 27 and before report wrong number of
	 * DP buffers.
+26 −4
Original line number Diff line number Diff line
@@ -347,7 +347,7 @@ static int nvm_write(void *priv, unsigned int offset, void *val, size_t bytes)
	return ret;
}

static int tb_switch_nvm_add(struct tb_switch *sw)
static int tb_switch_nvm_init(struct tb_switch *sw)
{
	struct tb_nvm *nvm;
	int ret;
@@ -365,6 +365,26 @@ static int tb_switch_nvm_add(struct tb_switch *sw)
	if (ret)
		goto err_nvm;

	sw->nvm = nvm;
	return 0;

err_nvm:
	tb_sw_dbg(sw, "NVM upgrade disabled\n");
	sw->no_nvm_upgrade = true;
	if (!IS_ERR(nvm))
		tb_nvm_free(nvm);

	return ret;
}

static int tb_switch_nvm_add(struct tb_switch *sw)
{
	struct tb_nvm *nvm = sw->nvm;
	int ret;

	if (!nvm)
		return 0;

	/*
	 * If the switch is in safe-mode the only accessible portion of
	 * the NVM is the non-active one where userspace is expected to
@@ -383,13 +403,11 @@ static int tb_switch_nvm_add(struct tb_switch *sw)
			goto err_nvm;
	}

	sw->nvm = nvm;
	return 0;

err_nvm:
	tb_sw_dbg(sw, "NVM upgrade disabled\n");
	sw->no_nvm_upgrade = true;
	if (!IS_ERR(nvm))
	tb_nvm_free(nvm);

	return ret;
@@ -3311,6 +3329,10 @@ int tb_switch_add(struct tb_switch *sw)
		return ret;
	}

	ret = tb_switch_nvm_init(sw);
	if (ret)
		return ret;

	if (!sw->safe_mode) {
		tb_switch_credits_init(sw);

Loading