From patchwork Thu Sep 11 13:03:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 4886421 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B0EE59F32E for ; Thu, 11 Sep 2014 13:06:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59B36201EC for ; Thu, 11 Sep 2014 13:06:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 026DC20149 for ; Thu, 11 Sep 2014 13:06:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XS42v-00021L-Dm; Thu, 11 Sep 2014 13:04:21 +0000 Received: from bhuna.collabora.co.uk ([93.93.135.160]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XS42s-0001vf-MA for linux-arm-kernel@lists.infradead.org; Thu, 11 Sep 2014 13:04:19 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: javier) with ESMTPSA id 9083D601B44 Message-ID: <54119DB6.8020807@collabora.co.uk> Date: Thu, 11 Sep 2014 15:03:50 +0200 From: Javier Martinez Canillas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0 MIME-Version: 1.0 To: Mark Brown Subject: SPI and module auto-loading X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140911_060419_035157_05E9C4C4 X-CRM114-Status: GOOD ( 18.56 ) X-Spam-Score: -2.5 (--) Cc: devicetree@vger.kernel.org, wsa@the-dreams.de, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, sjoerd.simons@collabora.co.uk, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello Mark, We found an issue with module auto-loading on an I2C driver [0] and it turned out to be a problem on how the I2C subsystem reports the module alias to user-space. It always report modalias as "i2c:" even when the driver is probed via DT. The problem with this particular driver is that the I2C device ID table didn't contain an entry that matched what the I2C core was reporting as the MODALIAS uevent env var. I looked at the SPI core and it does the same. It always reports to udev as modalias "spi:" so the aliases filled in a module from the OF table are never used. This can be easily worked around (and probably why it never was an issue) if the OF and SPI tables are kept in sync but I don't know if that is a hard requirement for all use-cases (e.g: a SPI driver that is DT only?). Now, changing this behavior will break module auto-loading for a lot of drivers relies on the current behavior and don't define a struct of_device_id or are not using the MODULE_DEVICE_TABLE(of,..) macro but I wonder if that means that the drivers are broken and should be fixed? I'm sending an RFC patch [1] to know what you think about it. Thanks a lot and best regards, Javier [0]: https://lkml.org/lkml/2014/9/11/127 [1] From a7cd35209a597a578df6c801e5ff7b63b584bf3e Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 11 Sep 2014 14:31:04 +0200 Subject: [PATCH RFC] spi: core: report OF style modalias when probing using DT An SPI driver that supports both OF and legacy platforms, will have both an OF and SPI ID table. This means that when built as a module, the aliases will be filled from both tables, e.g: $ modinfo cros_ec_spi | grep alias alias: spi:cros-ec-spi alias: of:N*T*Cgoogle,cros-ec-spi* But currently always an alias of the form spi: is reported even when the it was probed by matching the OF compatible string. $ cat /sys/devices/12d40000.spi/spi_master/spi2/spi2.0/modalias spi:cros-ec-spi Drivers for IP blocks that are included in DT-only platforms, may not have an updated SPI ID table so if a device is probed by matching its compatible string, udev can get a MODALIAS uevent env var that doesn't match with one of the valid aliases so the module won't be auto-loaded by libkmod/modprobe. This patch reports OF related uevent env vars (e.g: OF_COMPATIBLE) and so the module can be auto-loaded and also report the correctly on sysfs: $ cat /sys/devices/12d40000.spi/spi_master/spi2/spi2.0/modalias of:Ncros-ecTCgoogle,cros-ec-spi Signed-off-by: Javier Martinez Canillas --- NOTE: this will break module auto-loading for all drivers that rely on the current behavior so it should not be applied unless is part of a series that fix all the broken drivers. drivers/spi/spi.c | 8 ++++++++ 1 file changed, 8 insertions(+) return len; @@ -124,6 +128,10 @@ static int spi_uevent(struct device *dev, struct kobj_uevent_env *env) const struct spi_device *spi = to_spi_device(dev); int rc; + rc = of_device_uevent_modalias(dev, env); + if (rc != -ENODEV) + return rc; + rc = acpi_device_uevent_modalias(dev, env); if (rc != -ENODEV) return rc; diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 95cfe3b..154e1d6 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -63,6 +63,10 @@ modalias_show(struct device *dev, struct device_attribute *a, char *buf) const struct spi_device *spi = to_spi_device(dev); int len; + len = of_device_get_modalias(dev, buf, PAGE_SIZE - 1); + if (len != -ENODEV) + return len; + len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1); if (len != -ENODEV)