Re: [PATCH 4/8] thunderbolt: Do not fail adding switch if some port is not implemented

From: Lukas Wunner
Date: Sat Aug 03 2019 - 10:14:09 EST


On Fri, Jul 05, 2019 at 12:57:56PM +0300, Mika Westerberg wrote:
> 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.

Your patch may also cause this snippet in eeprom.c to become obsolete:

/* Port 5 is inaccessible on this gen 1 controller */
if (sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE)
sw->ports[5].disabled = true;

To verify this hypothesis, one needs to comment out the call to
tb_drom_copy_efi() as well as the above-quoted snippet and boot
on a Mac with Light Ridge. The driver should hit an error without
your patch and it may work correctly with your patch.

Thanks,

Lukas