Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3289436pxk; Mon, 21 Sep 2020 09:47:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4q84Wp9M1EfXmOMLAlT67Zkar/ofKG5KmjBKBIiPguGOU06btKcMZ9f0pHSaMAgXwH8ET X-Received: by 2002:a50:e44b:: with SMTP id e11mr550862edm.73.1600706876786; Mon, 21 Sep 2020 09:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706876; cv=none; d=google.com; s=arc-20160816; b=KsdSvrHigYP4kRjM3mxi+Mceb998Wu3Ye1FqkcyeNE/5tmAsq6LWmYMnsPtO8VaxX8 g/pJ1xF/wE8A/ZRDYp05cYCwiggXbyOX7/bBoMhyefBSQRm0jKqJ9JIW1MChXRgEl2At GpwWr8HWOxm36D1z3fgcJdEl14SFEi4cabEMS/7it51pglesz16L28VRMuYvr65uZ1Ly u0KjdQKmVcQFUsGxuWlb17eRhWTcPfqfxBFggXDtb5gzlWhCQ/U1BgcmpkHOASS9TYfl SKeo/iQGUWgnMCmWjBH1lIirXMYR67dIXAncLpumSNRO/mOiiFGyoXyWMuorS1ITiYug ja7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5lrkeTCP/+2Y8jSsH0LScl7hJAdoGkbj0/WoGyMZovM=; b=IQ4rZEMJJttd/jDPMk4fODwp6gaSljrDH+kJwCXn9uLG21Gz0tpcW7rjsKuhGLP+gD /TTV3+D/sLOI3IK+78rCOauHHCSjzG+a/P2q5l9L3xKVNWjPTaibeL6wH4y10cROUDwf 1jSwKpclNiMRA2EJ32jECS+sYofnzDfnsasLVZGmuFmnykwfDWYGbZucvF6+Xt/7DyjU XCWmuTvTBr8BSWBqUagkxnj281vBFkS+Y+4tFcXDNDw5T/Ys3Rli6y24B6VXsNMkBQ7+ o0XCgAILVKFA2MzGbNk6FAdbz3TER+pYzO4mGuCAs2dFfWMyXDuZb0KAYTKEgTahQI5K Qh3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iO5vzpKE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si8270597edy.150.2020.09.21.09.47.32; Mon, 21 Sep 2020 09:47:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iO5vzpKE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729028AbgIUQqn (ORCPT + 99 others); Mon, 21 Sep 2020 12:46:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:53076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729168AbgIUQqk (ORCPT ); Mon, 21 Sep 2020 12:46:40 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 608D22388E; Mon, 21 Sep 2020 16:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706799; bh=/MoVMQ+YV+oqcRcLnR9UqxOJQhWQ6bhb789n8we9Mbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iO5vzpKEpujWlawDfnzdJKQ1rctFEK7MHo7irprk4TOvQhX94KydVSM588HMi9K60 P7ewKTwcsMfiy322vegXhNQiiHJ65SsqqiR2WqIOvF7e+d3DC+MVjuc/8FquVqhbKB 7vArYpk4Pj3fv+LmT/8qh4p0UWS4XCXaBgjqsW78= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Andy Shevchenko Subject: [PATCH 5.8 100/118] serial: core: fix port-lock initialisation Date: Mon, 21 Sep 2020 18:28:32 +0200 Message-Id: <20200921162041.022221044@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit fe88c6489264eaea23570dfdf03e1d3f5f47f423 upstream. Commit f743061a85f5 ("serial: core: Initialise spin lock before use in uart_configure_port()") tried to work around a breakage introduced by commit a3cb39d258ef ("serial: core: Allow detach and attach serial device for console") by adding a second initialisation of the port lock when registering the port. As reported by the build robots [1], this doesn't really solve the regression introduced by the console-detach changes and also adds a second redundant initialisation of the lock for normal ports. Start cleaning up this mess by removing the redundant initialisation and making sure that the port lock is again initialised once-only for ports that aren't already in use as a console. [1] https://lore.kernel.org/r/20200802054852.GR23458@shao2-debian Fixes: f743061a85f5 ("serial: core: Initialise spin lock before use in uart_configure_port()") Fixes: a3cb39d258ef ("serial: core: Allow detach and attach serial device for console") Cc: stable # 5.7 Signed-off-by: Johan Hovold Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200909143101.15389-2-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/serial_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2376,13 +2376,6 @@ uart_configure_port(struct uart_driver * uart_change_pm(state, UART_PM_STATE_ON); /* - * If this driver supports console, and it hasn't been - * successfully registered yet, initialise spin lock for it. - */ - if (port->cons && !(port->cons->flags & CON_ENABLED)) - __uart_port_spin_lock_init(port); - - /* * Ensure that the modem control lines are de-activated. * keep the DTR setting that is set in uart_set_options() * We probably don't need a spinlock around this, but @@ -2897,7 +2890,12 @@ int uart_add_one_port(struct uart_driver goto out; } - uart_port_spin_lock_init(uport); + /* + * If this port is in use as a console then the spinlock is already + * initialised. + */ + if (!uart_console_enabled(uport)) + __uart_port_spin_lock_init(uport); if (uport->cons && uport->dev) of_console_check(uport->dev->of_node, uport->cons->name, uport->line);