<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/thunderbolt/icm.c, branch linux-5.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-12-11T12:23:29Z</updated>
<entry>
<title>thunderbolt: Fix use-after-free in remove_unplugged_switch()</title>
<updated>2020-12-11T12:23:29Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2020-11-18T11:08:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b92738c4f9d31943244147029d88ce19e41c02d4'/>
<id>urn:sha1:b92738c4f9d31943244147029d88ce19e41c02d4</id>
<content type='text'>
commit 600c0849cf86b75d86352f59745226273290986a upstream.

Paulian reported a crash that happens when a dock is unplugged during
hibernation:

[78436.228217] thunderbolt 0-1: device disconnected
[78436.228365] BUG: kernel NULL pointer dereference, address: 00000000000001e0
...
[78436.228397] RIP: 0010:icm_free_unplugged_children+0x109/0x1a0
...
[78436.228432] Call Trace:
[78436.228439]  icm_rescan_work+0x24/0x30
[78436.228444]  process_one_work+0x1a3/0x3a0
[78436.228449]  worker_thread+0x30/0x370
[78436.228454]  ? process_one_work+0x3a0/0x3a0
[78436.228457]  kthread+0x13d/0x160
[78436.228461]  ? kthread_park+0x90/0x90
[78436.228465]  ret_from_fork+0x1f/0x30

This happens because remove_unplugged_switch() calls tb_switch_remove()
that releases the memory pointed by sw so the following lines reference
to a memory that might be released already.

Fix this by saving pointer to the parent device before calling
tb_switch_remove().

Reported-by: Paulian Bogdan Marinca &lt;paulian@marinca.net&gt;
Fixes: 4f7c2e0d8765 ("thunderbolt: Make sure device runtime resume completes before taking domain lock")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Reviewed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>thunderbolt: Add support for Intel Ice Lake</title>
<updated>2019-08-26T09:15:06Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2018-01-16T20:19:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3cdb9446a117d5d63af823bde6fe6babc312e77b'/>
<id>urn:sha1:3cdb9446a117d5d63af823bde6fe6babc312e77b</id>
<content type='text'>
The Thunderbolt controller is integrated into the Ice Lake CPU itself
and requires special flows to power it on and off using force power bit
in NHI VSEC registers. Runtime PM (RTD3) and Sx flows also differ from
the discrete solutions. Now the firmware notifies the driver whether
RTD3 entry or exit are possible. The driver is responsible of sending
Go2Sx command through link controller mailbox when system enters Sx
states (suspend-to-mem/disk). Rest of the ICM firwmare flows follow
Titan Ridge.

Signed-off-by: Raanan Avargil &lt;raanan.avargil@intel.com&gt;
Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Reviewed-by: Yehezkel Bernat &lt;YehezkelShB@gmail.com&gt;
Tested-by: Mario Limonciello &lt;mario.limonciello@dell.com&gt;
</content>
</entry>
<entry>
<title>thunderbolt: Move NVM upgrade support flag to struct icm</title>
<updated>2019-08-26T09:14:32Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2018-01-16T20:30:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f437c24bf694b0293f835dea8c25e3a5c1433d07'/>
<id>urn:sha1:f437c24bf694b0293f835dea8c25e3a5c1433d07</id>
<content type='text'>
This is depends on the controller and on the platform/CPU we are
running. Move it to struct icm so we can set it per controller.

Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Reviewed-by: Yehezkel Bernat &lt;YehezkelShB@gmail.com&gt;
Tested-by: Mario Limonciello &lt;mario.limonciello@dell.com&gt;
</content>
</entry>
<entry>
<title>thunderbolt: Implement CIO reset correctly for Titan Ridge</title>
<updated>2019-06-14T11:25:43Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2019-05-31T10:31:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0d53827d7c172f1345140f7638fe658bda1bb25d'/>
<id>urn:sha1:0d53827d7c172f1345140f7638fe658bda1bb25d</id>
<content type='text'>
When starting ICM firmware on Apple systems we need to perform CIO reset
as part of the flow. However, it turns out that the reset register has
changed to another location in Titan Ridge.

Fix this by introducing -&gt;cio_reset() callback with corresponding
implementations for Alpine and Titan Ridge.

Fixes: c4630d6ae6e3 ("thunderbolt: Start firmware on Titan Ridge Apple systems")
Reported-by: Peter Bowen &lt;pzb@amazon.com&gt;
Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>thunderbolt: Make sure device runtime resume completes before taking domain lock</title>
<updated>2019-06-12T10:30:46Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2019-05-28T15:56:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4f7c2e0d8765a0266b920c66ffc495fde44c1ec8'/>
<id>urn:sha1:4f7c2e0d8765a0266b920c66ffc495fde44c1ec8</id>
<content type='text'>
When a device is authorized from userspace by writing to authorized
attribute we first take the domain lock and then runtime resume the
device in question. There are two issues with this.

First is that the device connected notifications are blocked during this
time which means we get them only after the authorization operation is
complete. Because of this the authorization needed flag from the
firmware notification is not reflecting the real authorization status
anymore. So what happens is that the "authorized" keeps returning 0 even
if the device was already authorized properly.

Second issue is that each time the controller is runtime resumed the
connection_id field of device connected notification may be different
than in the previous resume. We need to use the latest connection_id
otherwise the firmware rejects the authorization command.

Fix these by moving runtime resume operations to happen before the
domain lock is taken, and waiting for the updated device connected
notification from the firmware before we allow runtime resume of a
device to complete.

While there add missing locking to tb_switch_nvm_read().

Fixes: 09f11b6c99fe ("thunderbolt: Take domain lock in switch sysfs attribute callbacks")
Reported-by: Pengfei Xu &lt;pengfei.xu@intel.com&gt;
Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>thunderbolt: Start firmware on Titan Ridge Apple systems</title>
<updated>2019-04-18T08:18:54Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2019-01-21T13:41:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c4630d6ae6e33b76fedde5c15bdfc7fa579eac32'/>
<id>urn:sha1:c4630d6ae6e33b76fedde5c15bdfc7fa579eac32</id>
<content type='text'>
Titan Ridge flow to start the firmware is the same as Alpine Ridge so we
can do the same on Titan Ridge based Apple systems.

Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>thunderbolt: Make rest of the logging to happen at debug level</title>
<updated>2019-04-18T08:18:53Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2018-09-17T13:32:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=62efe699a7f666b48e1d41511147017e13e8d230'/>
<id>urn:sha1:62efe699a7f666b48e1d41511147017e13e8d230</id>
<content type='text'>
Now that the driver can handle every possible tunnel types there is no
point to log everything as info level so turn these to happen at debug
level instead.

While at it remove duplicated tunnel activation log message
(tb_tunnel_activate() calls tb_tunnel_restart() which print the same
message) and add one missing '\n' termination.

Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>thunderbolt: Make tb_switch_alloc() return ERR_PTR()</title>
<updated>2019-04-18T08:18:53Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2018-12-30T10:17:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=444ac3844895c34ab71ffcec1b3199449d3434a4'/>
<id>urn:sha1:444ac3844895c34ab71ffcec1b3199449d3434a4</id>
<content type='text'>
In order to detect possible connections to other domains we need to be
able to find out why tb_switch_alloc() fails so make it return ERR_PTR()
instead. This allows the caller to differentiate between errors such as
-ENOMEM which comes from the kernel and for instance -EIO which comes
from the hardware when trying to access the possible switch.

Convert all the current call sites to handle this properly.

Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>thunderbolt: Assign remote for both ports in case of dual link</title>
<updated>2019-04-18T08:18:52Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2019-03-07T13:26:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dfe40ca486f60dca1e3223d82acf78cfb39925b8'/>
<id>urn:sha1:dfe40ca486f60dca1e3223d82acf78cfb39925b8</id>
<content type='text'>
Currently the driver only assigns remote port for the primary port if in
case of dual link. This makes things such as walking from one port to
another more complex than necessary because the code needs to change
from secondary to primary port if the path that is established is
created using secondary links.

In order to always assign both remote pointers we need to prevent the
scanning code from following the secondary link. Failing to do that
might cause problems as the same switch may be enumerated twice (or
removed in case of unplug). Handle that properly by introducing a new
function tb_port_has_remote() that returns true only for the primary
port. We also update tb_is_upstream_port() to support both dual link
ports, make it take const port pointer and move it below
tb_upstream_port() to keep similar functions close.

Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>thunderbolt: Do not allocate switch if depth is greater than 6</title>
<updated>2019-04-18T08:18:51Z</updated>
<author>
<name>Mika Westerberg</name>
</author>
<published>2018-12-30T10:14:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f0342e757c271e7c6dd5adedfb6e6695c5af52bf'/>
<id>urn:sha1:f0342e757c271e7c6dd5adedfb6e6695c5af52bf</id>
<content type='text'>
Maximum depth in Thunderbolt topology is 6 so make sure it is not
possible to allocate switches that exceed the depth limit.

While at it update tb_switch_alloc() to use upper/lower_32_bits()
following tb_switch_alloc_safe_mode().

Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
</content>
</entry>
</feed>
