linux-stable/drivers/thunderbolt
Lukas Wunner c9cc3aaa02 thunderbolt: Use Device ROM retrieved from EFI
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 <lukas@wunner.de> [MacBookPro9,1]
Tested-by: Pierre Moreau <pierre.morrow@free.fr> [MacBookPro11,3]
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Acked-by: Andreas Noever <andreas.noever@gmail.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pedro Vilaça <reverser@put.as>
Cc: Peter Jones <pjones@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20161112213237.8804-10-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-11-13 08:23:16 +01:00
..
cap.c thunderbolt: Add thunderbolt capability handling 2014-06-19 14:07:47 -07:00
ctl.c thunderbolt: Fix typos and magic number 2016-04-08 11:09:34 -05:00
ctl.h
eeprom.c thunderbolt: Use Device ROM retrieved from EFI 2016-11-13 08:23:16 +01:00
Kconfig thunderbolt: Use Device ROM retrieved from EFI 2016-11-13 08:23:16 +01:00
Makefile thunderbolt: Read switch uid from EEPROM 2014-06-19 14:13:00 -07:00
nhi.c thunderbolt: Add support for INTEL_FALCON_RIDGE_2C controller. 2016-08-31 13:25:02 +02:00
nhi.h
nhi_regs.h
path.c thunderbolt: Clear hops before overwriting 2014-08-26 14:54:48 -07:00
switch.c thunderbolt: Use Device ROM retrieved from EFI 2016-11-13 08:23:16 +01:00
tb.c thunderbolt: Fix typos and magic number 2016-04-08 11:09:34 -05:00
tb.h thunderbolt: Fix typos and magic number 2016-04-08 11:09:34 -05:00
tb_regs.h thunderbolt: Fix typos and magic number 2016-04-08 11:09:34 -05:00
tunnel_pci.c thunderbolt: Add support for simple pci tunnels 2014-06-19 14:07:47 -07:00
tunnel_pci.h thunderbolt: Add support for simple pci tunnels 2014-06-19 14:07:47 -07:00