Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7545586imm; Tue, 28 Aug 2018 14:10:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaU35BXkRUAD2Zcj8svyZ5lMKfpoJq6e+iNSjSdg1TqPhGNlj54qEwbuRJf6mo/KhprQ3Z9 X-Received: by 2002:a63:1a1a:: with SMTP id a26-v6mr3040087pga.449.1535490647065; Tue, 28 Aug 2018 14:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535490647; cv=none; d=google.com; s=arc-20160816; b=IdFn0dJlUF2lyu8GQ5oMsb35niAQn4HzLsfyT9d1FCYUG335tDFCL/kF6d8uwHlG20 n8oSj+PQ2R0HDcD7AK4YHFuhkSEYomtzTf8KQxhTcEt1utCGxENlghWskGR/DSrhyo8t 9GWk0yrefnV4DCxqF6u5URncjRCW1JXOhl8T9Cw3fxBSdORPeJu58Yw2AjEldQ804PeZ fteoLwZ+L7suZHEVnVyQLA7wk1PtojIpNYH0QeLsWM6BjB7OHAGlvy0+y15ZKa3tXD+d z5dHPa6z8Li1FqT0+BZTMrx54WTYm76jsTSnwacOE5TP8ZprKNYgfpoEYC+UB04Dbnjx uBOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=iI6Jo981TwTDpbtdPlLeDknObMnjACPoLIG0zLUkMw8=; b=L9dZ1ikdn8aV4mYIpztIEO/T9dpB3OA3XlrbQzdBsZruUMq7ocdGGVkA9bM3VfJuDi QecbPg7r56OVsmECACTIptSQvQKx2fvvrom2duTJimWiuQhW3onPHky+KFhp2HM0+9AX Z6ul1qr/NhOna/RCi/hF717qpmMqcm6cA0c8t74GVYBEsqeDNAYvtg4w1RwxX9pxFVVV d943LNCHaM4Jn+jIUEmlGzU3Q7jZUivONS/CpxQ0ME3VypzZN/Gf8r8Vbs7ad6iC3arA 5Bh5dVTfd6hXPA228iS5iaAbpxkqdaYaxl80ndGpY/+2ikWQyaL8IheBiQEpv91B5x0s /fhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=I3qIuawD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2-v6si1858656plo.246.2018.08.28.14.10.32; Tue, 28 Aug 2018 14:10:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=I3qIuawD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727796AbeH2BCG (ORCPT + 99 others); Tue, 28 Aug 2018 21:02:06 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:47936 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbeH2BCF (ORCPT ); Tue, 28 Aug 2018 21:02:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=iI6Jo981TwTDpbtdPlLeDknObMnjACPoLIG0zLUkMw8=; b=I3qIuawD83BA m9ZY0mS5zKvUzeBMaYDk6OzNYYJBKNCTaI1+tkrCk1jgh+xx7sJRb9fdtOe+bB6dPNniOBvA4ou+3 UVdrn5GNFmT2bHkdLn2LAgPnq040X+Go7V+gEuvvvVev2G5kONTdI5GDrB1q1PGrRoowa+kAIQ+LK bPwtI=; Received: from 94.197.121.204.threembb.co.uk ([94.197.121.204] helo=finisterre.ee.mobilebroadband) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fulE0-0007ld-5O; Tue, 28 Aug 2018 21:08:32 +0000 Received: by finisterre.ee.mobilebroadband (Postfix, from userid 1000) id D4A934400A1; Tue, 28 Aug 2018 21:58:56 +0100 (BST) From: Mark Brown To: Geert Uytterhoeven Cc: Fabio Estevam , Mark Brown , Mark Brown , Kirill Kapranov , linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-spi@vger.kernel.org Subject: Applied "spi: Fix double IDR allocation with DT aliases" to the spi tree In-Reply-To: <20180821095303.27664-1-geert+renesas@glider.be> Message-Id: <20180828205856.D4A934400A1@finisterre.ee.mobilebroadband> Date: Tue, 28 Aug 2018 21:58:56 +0100 (BST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch spi: Fix double IDR allocation with DT aliases has been applied to the spi tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 04b2d03a75652bda989de1595048f0501dc0c0a0 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 21 Aug 2018 11:53:03 +0200 Subject: [PATCH] spi: Fix double IDR allocation with DT aliases If the SPI bus number is provided by a DT alias, idr_alloc() is called twice, leading to: WARNING: CPU: 1 PID: 1 at drivers/spi/spi.c:2179 spi_register_controller+0x11c/0x5d8 couldn't get idr Fix this by moving the handling of fixed SPI bus numbers up, before the DT handling code fills in ctlr->bus_num. Fixes: 1a4327fbf4554d5b ("spi: fix IDR collision on systems with both fixed and dynamic SPI bus numbers") Signed-off-by: Geert Uytterhoeven Tested-by: Fabio Estevam Signed-off-by: Mark Brown --- drivers/spi/spi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index a00d006d4c3a..9da0bc5a036c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2143,8 +2143,17 @@ int spi_register_controller(struct spi_controller *ctlr) */ if (ctlr->num_chipselect == 0) return -EINVAL; - /* allocate dynamic bus number using Linux idr */ - if ((ctlr->bus_num < 0) && ctlr->dev.of_node) { + if (ctlr->bus_num >= 0) { + /* devices with a fixed bus num must check-in with the num */ + mutex_lock(&board_lock); + id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num, + ctlr->bus_num + 1, GFP_KERNEL); + mutex_unlock(&board_lock); + if (WARN(id < 0, "couldn't get idr")) + return id == -ENOSPC ? -EBUSY : id; + ctlr->bus_num = id; + } else if (ctlr->dev.of_node) { + /* allocate dynamic bus number using Linux idr */ id = of_alias_get_id(ctlr->dev.of_node, "spi"); if (id >= 0) { ctlr->bus_num = id; @@ -2170,15 +2179,6 @@ int spi_register_controller(struct spi_controller *ctlr) if (WARN(id < 0, "couldn't get idr")) return id; ctlr->bus_num = id; - } else { - /* devices with a fixed bus num must check-in with the num */ - mutex_lock(&board_lock); - id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num, - ctlr->bus_num + 1, GFP_KERNEL); - mutex_unlock(&board_lock); - if (WARN(id < 0, "couldn't get idr")) - return id == -ENOSPC ? -EBUSY : id; - ctlr->bus_num = id; } INIT_LIST_HEAD(&ctlr->queue); spin_lock_init(&ctlr->queue_lock); -- 2.18.0