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

Mika Westerberg
2019-08-05T13:18:15Z

On Sat, Aug 03, 2019 at 04:14:01PM +0200, Lukas Wunner wrote:
> 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.

Indeed. I'll check this - as I have Mac with LR, and update the patch
accordingly (e.g drop the check if the error does not appear).