From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Life is hard, and then you die" Subject: Re: [PATCH v2] spi/acpi: enumerate all SPI slaves in the namespace Date: Sun, 9 Jun 2019 16:44:27 -0700 Message-ID: <20190609234427.GA16597@innovation.ch> References: <20190530111634.32209-1-ard.biesheuvel@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Lukas Wunner , "Rafael J. Wysocki" , linux-spi@vger.kernel.org, linux-acpi@vger.kernel.org, andy.shevchenko@gmail.com, broonie@kernel.org, Jarkko Nikula , masahisa.kojima@linaro.org, Mika Westerberg , linux-arm-kernel@lists.infradead.org To: Ard Biesheuvel Return-path: Content-Disposition: inline In-Reply-To: <20190530111634.32209-1-ard.biesheuvel@linaro.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org List-Id: linux-spi.vger.kernel.org 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 > Cc: linux-spi@vger.kernel.org > Cc: broonie@kernel.org > Cc: andy.shevchenko@gmail.com > Cc: masahisa.kojima@linaro.org > Cc: "Rafael J. Wysocki" > Cc: Jarkko Nikula > Cc: linux-acpi@vger.kernel.org > Cc: Lukas Wunner > > Signed-off-by: Ard Biesheuvel > --- > 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