On Thu, May 30, 2019 at 01:16:34PM +0200, Ard Biesheuvel wrote: > Currently, the ACPI enumeration that takes place when registering a > SPI master only considers immediate child devices in the ACPI namespace, > rather than checking the ResourceSource field in the SpiSerialBus() > resource descriptor. > > This is incorrect: SPI slaves could reside anywhere in the ACPI > namespace, and so we should enumerate the entire namespace and look for > any device that refers to the newly registered SPI master in its > resource descriptor. > > So refactor the existing code and use a lookup structure so that > allocating the SPI device structure is deferred until we have identified > the device as an actual child of the controller. This approach is > loosely based on the way the I2C subsystem handles ACPI enumeration. > > Note that Apple x86 hardware does not rely on SpiSerialBus() resources > in _CRS but uses nested devices below the controller's device node in > the ACPI namespace, with a special set of device properties. This means > we have to take care to only parse those properties for device nodes > that are direct children of the controller node. > > Cc: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx> > Cc: linux-spi@xxxxxxxxxxxxxxx > Cc: broonie@xxxxxxxxxx > Cc: andy.shevchenko@xxxxxxxxx > Cc: masahisa.kojima@xxxxxxxxxx > Cc: "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx> > Cc: Jarkko Nikula <jarkko.nikula@xxxxxxxxxxxxxxx> > Cc: linux-acpi@xxxxxxxxxxxxxxx > Cc: Lukas Wunner <lukas@xxxxxxxxx> > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> > --- > drivers/spi/spi.c | 103 ++++++++++++++------ > 1 file changed, 72 insertions(+), 31 deletions(-) [snip] FYI, I tested this on a MacBook Pro where the (SPI) keyboard driver depends on those special device properties, and verified this patch doesn't break anything there. Cheers, Ronald