From patchwork Tue Oct 17 10:44:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 116061 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4726172qgn; Tue, 17 Oct 2017 03:45:44 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBEdxTpIeGfiKxik4VgVsYBS3ci4XUtWu8WutanAmPpIYM3tK+FfC0tcx4Q6uKUNsvFfsSP X-Received: by 10.159.252.65 with SMTP id t1mr11593545plz.31.1508237144085; Tue, 17 Oct 2017 03:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508237144; cv=none; d=google.com; s=arc-20160816; b=feQGpEGqMym7eKoSJng/J/4pTqNy/4xTST179l+v1HI51MvWku9njQX+RLl3IgFLCz R6jX4SO2LjMYRULWdbgB3m+/XIjHeqafAWXbTej/fHSkInIp8rs08XEySda7TSnzj3pz ltbbUUsS6VoDl+jc2+DHGIySxpUf3wHWiPLypZ7lUUEszA/L6LxfXGpC4QMZlS1h0f3E qyIf0wKrnmrhVjE8nhFNG+NXI1FGXiL2Ahh063IZQ75zU+9fBnF4OP6x3BrF0n9noTu5 oKLq1RpFuF8MJSCfKG0VIbFDZq+hH9+E2y3vIi+NMIXK6jvjDjfWsvf9c8oUZ4AaYevF Uc8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ijJaUKHUlbKBaewMtMoN7ul91zxVCghvJ5xgyEQgd0g=; b=pKYh9b3GKym/1hWzZYSyl7fdWO02OUJATYxh3qTP1KgfpJl5kzQL1IcUbj/qHkUS7Z 7GZ4NIWyLDORs5Wy0WYk8/dEgZ+s27q9dwMEqgvgLfyYy7dTnSfgFclIEDhHDK/piZCq 56YeGRatzW2YaHifLmGMGoeejyWrHX9JIMPi/Blg8GQECPlmpA8Biy5NCM4QyV2VLtGK M0aoLeBAtWTozQm7wHu88Bz1mlgkIYTxrSv/jSUDyBIxtLJa9TJJLhsHmggXZXhsje9C s85x5Gt+K65O9YLt0wpJUYwY1MJSA4DDDEO8FTjbY6mK+87g3DEN5neWgE9O5IL0DXIy /5kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10si5306277pgc.359.2017.10.17.03.45.43; Tue, 17 Oct 2017 03:45:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756331AbdJQKpn (ORCPT + 1 other); Tue, 17 Oct 2017 06:45:43 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:65505 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752841AbdJQKpm (ORCPT ); Tue, 17 Oct 2017 06:45:42 -0400 Received: from wuerfel.lan ([46.223.139.202]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0M1CHs-1dFb4b1Ysq-00tCGo; Tue, 17 Oct 2017 12:45:21 +0200 From: Arnd Bergmann To: Mark Brown Cc: Lucas Stach , Naresh Kamboju , Arnd Bergmann , Geert Uytterhoeven , Andy Shevchenko , "Rafael J. Wysocki" , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: fix bogus SPI bus number Date: Tue, 17 Oct 2017 12:44:50 +0200 Message-Id: <20171017104519.878892-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:2wt02w9Jll4St1alaGbwgUb2BBDFvSJoeyHjvu/3NkbOPNbrQO6 ea4v1hkeE3A8CFe1gna+AUl8hMdeCbJP5gN6RNkf/P+LC7sTWzuZsELERe++klW56DXCvA+ 0BihKlESajL85RlZcMVN8zncvKZqLgALVQESiRvq1qkf3UX2AI014pVubM676Cirf4aBZFy reixQIPk8FHEcxyq+a0fA== X-UI-Out-Filterresults: notjunk:1; V01:K0:wx0gpR2a9ns=:BOemI6birSINFpS3WBphJ6 M3g64fDEutzNHR66o58O9LHnMtgTXuX4sTi9t4IRIfa6yMhssSrME9oXT2ZALa1ld4P1k4o3c 0J8Y1iUW1ZK6E9rMYFTLqC2iZ6leVKb/ba7EYCQ4fwXC89gV6UUkgY/3Qc5GDNO1kiW5oS5pY XJIwJW9uPhyxMX9GalnHMQJpKfXYh0f+tAlMjR56sfDLcfa//T1JMJULmDmwkP4UHzhVwc2gz g3oZPfjQxyaj/fMeCILCDizJD13UT4xHH99adWRNi58IFte9bVq0KCXqU0wXCV1iv0+SL5Gzt xahxTWEsBHGxV+kEGon24cC0ljxPpZQyvvet+QDu1aMFJDqdiX/P6P6MKhDMz7ueWPvSEKtsE CqYXfOacayVCR+pz24JKkdROp4EJ9L4ZCYLETxKYHQanX53p/qbxoqKb7sD7uuNPtVhvnol6J godAxI7CUyqGRp3Hd1lzrA7uFkfCA+vLi5JKLJJcI3maNyfykXolapgYaW6HI5dFWTm6gwrLf fcuUscCO3DLbQL4xUSn5CaYgli0DwKqdP1PK4mmT/gNibqyM7DZZW2+yKbHXWNqcDm9/+c3ec eglabXyjbBjFuT8XAuEA0Qdm9UKSobzqvQdbL2CB0zJC4Vt98y3pFgWCZaVCOkPL8NLrmdCE1 w7vt/KeODlXJZNhFYgVozVZuTOdZxfr1SeqA6kqdtE+OcntSY2wZNBdeMEg2LzM4dRo+HDVll GeYLyVnO4DxaJ3KcIY11wYAB8wAbQ96NMsVk5Q== Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org lkft found a boot time regression on the Hikey board that has no aliases entry for spi buses. of_alias_get_highest_id() here returns -ENODEV, which is then used as the initial number for the IDR allocation, and that in turn triggers a WARN_ON: WARNING: CPU: 3 PID: 53 at include/linux/idr.h:113 spi_register_controller+0x890/0x940 This reworks the algorithm to turn any negative number into zero again, restoring the original behavior for the Hikey case. Fixes: 9ce70d49fa80 ("spi: fix IDR collision on systems with both fixed and dynamic SPI bus numbers") Reported-by: Naresh Kamboju Link: https://lkft.validation.linaro.org/scheduler/job/48009#L3147 Signed-off-by: Arnd Bergmann --- Not tested yet, please review carefully --- drivers/spi/spi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 0483410e7cb3..4b6985ec962c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2116,9 +2116,11 @@ int spi_register_controller(struct spi_controller *ctlr) } if (ctlr->bus_num < 0) { mutex_lock(&board_lock); + id = of_alias_get_highest_id("spi"); + if (id < 0) + id = -1; id = idr_alloc(&spi_master_idr, ctlr, - of_alias_get_highest_id("spi") + 1, - 0, GFP_KERNEL); + id + 1, 0, GFP_KERNEL); mutex_unlock(&board_lock); if (WARN(id < 0, "couldn't get idr")) return id;