26 Aug, 2019
1 commit
-
There are two ways to mark a port as unimplemented. Typical way is to
return port type as TB_TYPE_INACTIVE when its config space is read.
Alternatively if the port is not physically present (such as ports 10
and 11 in ICL) reading from port config space returns
TB_CFG_ERROR_INVALID_CONFIG_SPACE instead. Currently the driver bails
out from adding the switch if it receives any error during port
inititialization which is wrong.Handle this properly and just leave the port as TB_TYPE_INACTIVE before
continuing to the next port.This also allows us to get rid of special casing for Light Ridge port 5
in eeprom.c.Signed-off-by: Mika Westerberg
Reviewed-by: Yehezkel Bernat
Tested-by: Mario Limonciello
06 Aug, 2019
1 commit
-
Use device_property_count_uXX() directly, that makes code neater.
Signed-off-by: Andy Shevchenko
Acked-by: Yehezkel Bernat
Signed-off-by: Mika Westerberg
03 Oct, 2018
2 commits
-
Intel has done pretty major changes to the driver and we continue to do
so in the future as well. Add Intel as copyright holder of the files we
have done changes.While there drop "Cactus Ridge" from the headers because this driver
works also with other Thunderbolt controllers.No functional changes intended.
Signed-off-by: Mika Westerberg
Acked-by: Yehezkel Bernat
Signed-off-by: Greg Kroah-Hartman -
Currently the driver logs quite a lot to the system message buffer even
when doing normal operations. This information is not useful for
ordinary users and might even annoy some.For this reason convert most of the logs at info level to happen at
debug level instead. The nice output formatting is untouched.Logging can be easily re-enabled by passing "thunderbolt.dyndbg" in the
kernel command line (or using the corresponding control file runtime).Signed-off-by: Mika Westerberg
Acked-by: Yehezkel Bernat
Signed-off-by: Greg Kroah-Hartman
02 Nov, 2017
1 commit
-
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.By default all files without license information are under the default
license of the kernel, which is GPL version 2.Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if
Reviewed-by: Philippe Ombredanne
Reviewed-by: Thomas Gleixner
Signed-off-by: Greg Kroah-Hartman
11 Aug, 2017
1 commit
-
Some Alpine Ridge LP DROMs (there might be others) erroneusly list more
ports than the controller actually has. Most probably because DROM of
the full Dual/Single port Thunderbolt controller was reused for LP
version. The current DROM parser does not check the upper bound thus it
leads to crash when sw->ports[] is accessed over bounds:BUG: unable to handle kernel NULL pointer dereference at 00000000000002ec
IP: tb_drom_read+0x383/0x890 [thunderbolt]
PGD 0
P4D 0
Oops: 0000 [#1] SMP
CPU: 3 PID: 12248 Comm: systemd-udevd Not tainted 4.13.0-rc1-next-20170719 #1
Hardware name: LENOVO 20HF000YGE/20HF000YGE, BIOS N1WET32W (1.11 ) 05/23/2017
task: ffff8a293e4bcd80 task.stack: ffffa698027a8000
RIP: 0010:tb_drom_read+0x383/0x890 [thunderbolt]
RSP: 0018:ffffa698027ab990 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff8a2940af7800 RCX: 0000000000000000
RDX: ffff8a2940ebb400 RSI: 0000000000000000 RDI: ffffa698027ab9a0
RBP: ffffa698027ab9d0 R08: 0000000000000001 R09: 0000000000000002
R10: ffff8a2940ebb5b0 R11: 0000000000000000 R12: ffff8a293bfa968c
R13: 000000000000002c R14: 0000000000000056 R15: 0000000000000056
FS: 00007f0a945a38c0(0000) GS:ffff8a2961580000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000000002ec CR3: 000000043e785000 CR4: 00000000003606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
tb_switch_add+0x9d/0x730 [thunderbolt]
? tb_switch_alloc+0x3cd/0x4d0 [thunderbolt]
icm_start+0x5a/0xa0 [thunderbolt]
tb_domain_add+0xc3/0xf0 [thunderbolt]
nhi_probe+0x19e/0x310 [thunderbolt]
local_pci_probe+0x42/0xa0
pci_device_probe+0x18d/0x1a0
driver_probe_device+0x2ff/0x450
__driver_attach+0xa4/0xe0
? driver_probe_device+0x450/0x450
bus_for_each_dev+0x6e/0xb0
driver_attach+0x1e/0x20
bus_add_driver+0x1d0/0x270
? 0xffffffffc0bbb000
driver_register+0x60/0xe0
? 0xffffffffc0bbb000
__pci_register_driver+0x4c/0x50
nhi_init+0x28/0x1000 [thunderbolt]
do_one_initcall+0x50/0x190
? __vunmap+0x81/0xb0
? _cond_resched+0x1a/0x50
? kmem_cache_alloc_trace+0x15f/0x1c0
? do_init_module+0x27/0x1e9
do_init_module+0x5f/0x1e9
load_module+0x24e7/0x2a60
? vfs_read+0x115/0x130
SYSC_finit_module+0xfc/0x120
? SYSC_finit_module+0xfc/0x120
SyS_finit_module+0xe/0x10
do_syscall_64+0x67/0x170
entry_SYSCALL64_slow_path+0x25/0x25Fix this by making sure we only enumerate DROM port entries the hardware
actually has.Reported-by: Christian Kellner
Signed-off-by: Mika Westerberg
Reviewed-by: Lukas Wunner
Tested-by: Christian Kellner
Cc: stable
Signed-off-by: Greg Kroah-Hartman
09 Jun, 2017
8 commits
-
Trivial fix to spelling mistake in tb_sw_warn warning message
Signed-off-by: Colin Ian King
Signed-off-by: Greg Kroah-Hartman -
The DMA (NHI) port of a switch provides access to the NVM of the host
controller (and devices starting from Intel Alpine Ridge). The NVM
contains also more complete DROM for the root switch including vendor
and device identification strings.This will look for the DMA port capability for each switch and if found
populates sw->dma_port. We then teach tb_drom_read() to read the DROM
information from NVM if available for the root switch.The DMA port capability also supports upgrading the NVM for both host
controller and devices which will be added in subsequent patches.This code is based on the work done by Amir Levy and Michael Jamet.
Signed-off-by: Michael Jamet
Signed-off-by: Mika Westerberg
Reviewed-by: Yehezkel Bernat
Reviewed-by: Andy Shevchenko
Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
The device DROM contains name of the vendor and device among other
things. Extract this information and expose it to the userspace via two
new attributes.Signed-off-by: Mika Westerberg
Reviewed-by: Yehezkel Bernat
Reviewed-by: Michael Jamet
Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
Currently tb_drom_parse_entry() is only able to parse drom entries of
type TB_DROM_ENTRY_PORT. Rename it to tb_drom_parse_entry_port().
Fold tb_drom_parse_port_entry() into it.Its return value is currently ignored. Evaluate it and abort parsing on
error.Change tb_drom_parse_entries() to accommodate for parsing of other entry
types than TB_DROM_ENTRY_PORT.Signed-off-by: Lukas Wunner
Signed-off-by: Mika Westerberg
Reviewed-by: Andy Shevchenko
Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
There are devices out there where CRC32 of the DROM is not correct. One
reason for this is that the ICM firmware does not validate it and it
seems that neither does the Apple driver. To be able to support such
devices we continue parsing the DROM contents regardless of whether
CRC32 failed or not. We still keep the warning there.Signed-off-by: Mika Westerberg
Reviewed-by: Yehezkel Bernat
Reviewed-by: Michael Jamet
Reviewed-by: Andy Shevchenko
Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
Thunderbolt domain consists of switches that are connected to each
other, forming a bus. This will convert each switch into a real Linux
device structure and adds them to the domain. The advantage here is
that we get all the goodies from the driver core, like reference
counting and sysfs hierarchy for free.Also expose device identification information to the userspace via new
sysfs attributes.In order to support internal connection manager (ICM) we separate switch
configuration into its own function (tb_switch_configure()) which is
only called by the existing native connection manager implementation
used on Macs.Signed-off-by: Mika Westerberg
Reviewed-by: Yehezkel Bernat
Reviewed-by: Michael Jamet
Reviewed-by: Andy Shevchenko
Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
DROM version 2 is compatible with the previous generation so no need to
warn about that.Signed-off-by: Mika Westerberg
Reviewed-by: Yehezkel Bernat
Reviewed-by: Michael Jamet
Reviewed-by: Andy Shevchenko
Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
At least Falcon Ridge when in host mode does not have any kind of DROM
available and reading DROM offset returns 0 for these. Do not try to
read DROM any further in that case.Signed-off-by: Mika Westerberg
Reviewed-by: Yehezkel Bernat
Reviewed-by: Michael Jamet
Reviewed-by: Andy Shevchenko
Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman
13 Nov, 2016
1 commit
-
Macs with Thunderbolt 1 do not have a unit-specific DROM: The DROM is
empty with uid 0x1000000000000. (Apple started factory-burning a unit-
specific DROM with Thunderbolt 2.)Instead, the NHI EFI driver supplies a DROM in a device property. Use
it if available. It's only available when booting with the efistub.
If it's not available, silently fall back to our hardcoded DROM.The size of the DROM is always 256 bytes. The number is hardcoded into
the NHI EFI driver. This commit can deal with an arbitrary size however,
just in case they ever change that.Background information: The EFI firmware volume contains ROM files for
the NHI, GMUX and several other chips as well as key material. This
strategy allows Apple to deploy ROM or key updates by simply publishing
an EFI firmware update on their website. Drivers do not access those
files directly but rather through a file server via EFI protocol
AC5E4829-A8FD-440B-AF33-9FFE013B12D8. Files are identified by GUID, the
NHI DROM has 339370BD-CFC6-4454-8EF7-704653120818.The NHI EFI driver amends that file with a unit-specific uid. The uid
has 64 bit but its entropy is much lower: 24 bit represent the model,
24 bit are taken from a serial number, 16 bit are fixed. The NHI EFI
driver obtains the serial number via the DataHub protocol, copies it
into the DROM, calculates the CRC and submits the result as a device
property.A modification is needed in the resume code where we currently read the
uid of all switches in the hierarchy to detect plug events that occurred
during sleep. On Thunderbolt 1 root switches this will now lead to a
mismatch between the uid of the empty DROM and the EFI DROM. Exempt the
root switch from this check: It's built in, so the uid should never
change. However we continue to *read* the uid of the root switch, this
seems like a good way to test its reachability after resume.Tested-by: Lukas Wunner [MacBookPro9,1]
Tested-by: Pierre Moreau [MacBookPro11,3]
Signed-off-by: Lukas Wunner
Signed-off-by: Matt Fleming
Acked-by: Andreas Noever
Cc: Ard Biesheuvel
Cc: Linus Torvalds
Cc: Pedro Vilaça
Cc: Peter Jones
Cc: Peter Zijlstra
Cc: Thomas Gleixner
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20161112213237.8804-10-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar
03 May, 2016
1 commit
-
If tb_drom_read() fails, sw->drom is freed but not set to NULL. sw->drom
is then freed again in the error path of tb_switch_alloc().The bug can be triggered by unplugging a thunderbolt device shortly after
it is detected by the thunderbolt driver.Clear sw->drom if tb_drom_read() fails.
[bhelgaas: add Fixes:, stable versions of interest]
Fixes: 343fcb8c70d7 ("thunderbolt: Fix nontrivial endpoint devices.")
Signed-off-by: Andreas Noever
Signed-off-by: Bjorn Helgaas
CC: stable@vger.kernel.org # v3.17+
CC: Lukas Wunner
09 Apr, 2016
2 commits
-
Add support for the 1st gen Light Ridge controller, which is built into
these systems:iMac12,1 2011 21.5"
iMac12,2 2011 27"
Macmini5,1 2011 i5 2.3 GHz
Macmini5,2 2011 i5 2.5 GHz
Macmini5,3 2011 i7 2.0 GHz
MacBookPro8,1 2011 13"
MacBookPro8,2 2011 15"
MacBookPro8,3 2011 17"
MacBookPro9,1 2012 15"
MacBookPro9,2 2012 13"Light Ridge (CV82524) was the very first copper Thunderbolt controller,
introduced 2010 alongside its fiber-optic cousin Light Peak (CVL2510).
Consequently the chip suffers from some teething troubles:- MSI is broken for hotplug signaling on the downstream bridges: The chip
just never sends an interrupt. It requests 32 MSIs for each of its six
bridges and the pcieport driver only allocates one per bridge. However
I've verified that even if 32 MSIs are allocated there's no interrupt
on hotplug. The only option is thus to disable MSI, which is also what
OS X does. Apparently all Thunderbolt chips up to revision 1 of Cactus
Ridge 4C are plagued by this issue so quirk those as well.- The chip supports a maximum hop_count of 32, unlike its successors
which support only 12. Fixup ring_interrupt_active() to cope with
values >= 32.- Another peculiarity is that the chip supports a maximum of 13 ports
whereas its successors support 12. However the additional port (#5)
seems to be unusable as reading its TB_CFG_PORT config space results in
TB_CFG_ERROR_INVALID_CONFIG_SPACE. Add a quirk to mark the port
disabled on the root switch, assuming that's necessary on all Macs
using this chip.Tested-by: Lukas Wunner [MacBookPro9,1]
Tested-by: William Brown [MacBookPro8,2]
Signed-off-by: Lukas Wunner
Signed-off-by: Bjorn Helgaas
Acked-by: Andreas Noever -
Fix typo in tb_cfg_print_error() message. Fix bytecount in struct
tb_drom_entry_port comment. Replace magic number in tb_switch_alloc().
Rename tb_sw_set_unpplugged() and TB_CAL_IECS to fix typos.[bhelgaas: no functional change intended]
Signed-off-by: Lukas Wunner
Signed-off-by: Bjorn Helgaas
Acked-by: Andreas Noever
21 Jun, 2014
4 commits
-
tb_eeprom_get_drom_offset is local to this file.
Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
Force enum tb_drom_entry_type to unsigned to fix the following error:
drivers/thunderbolt/eeprom.c:202:39: error: dubious one-bit signed bitfield
Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
The result of "sizeof(struct tb_drom_entry_port)" is a size_t, which
is not necessarily the same as 'long', so we should use the appropriate
%z format string instead of %l.Signed-off-by: Arnd Bergmann
Acked-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
Fixes the below error:
drivers/thunderbolt/eeprom.c:407:2: error: implicit declaration of function ‘kzalloc’ [-Werror=implicit-function-declaration]
drivers/thunderbolt/eeprom.c:444:2: error: implicit declaration of function ‘kfree’ [-Werror=implicit-function-declaration]Signed-off-by: Sachin Kamat
Acked-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman
20 Jun, 2014
2 commits
-
All Thunderbolt switches (except the root switch) contain a drom which
contains information about the device. Right now we only read the UID.Add code to read and parse this drom. For now we are only interested in
which ports are disabled and which ports are "dual link ports" (a
physical thunderbolt port/socket contains two such ports).Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman -
Add eeprom access code and read the uid during switch initialization.
The UID will be used to check device identity after suspend.Signed-off-by: Andreas Noever
Signed-off-by: Greg Kroah-Hartman