Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2642659lqz; Wed, 3 Apr 2024 04:36:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWotrimT/wE91HyEitxFwgg9K68tf/8VuOMtwkZXq0IYIbGsM83ZWGgAo/qbbcPZ5bstEDhnTzSepg27g+lOfP3ChyQmAYPHQOyDbQkkg== X-Google-Smtp-Source: AGHT+IGFZddTXfNCDo8vYJE+AuF0sMMCkALNfiXGtjnDFfxYdjEtPYlMVWJF5Xzo+cxrMoZPapYh X-Received: by 2002:a05:6402:1ec9:b0:56d:c73f:98ab with SMTP id g9-20020a0564021ec900b0056dc73f98abmr9246708edg.19.1712144181637; Wed, 03 Apr 2024 04:36:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712144181; cv=pass; d=google.com; s=arc-20160816; b=t3cf27E86Gx2S56aZMi0fj28+De2k7jaE3ijXkdcnvulxjFVT0IfUH4VFTWqk2/wiV o5KIYsUgtsSzbJUveDQChu+n6OEN3WwKLmOG76BAAJvYI+SnpNRGIm9ONtzDgZLHEA+5 Nc+1OB6zqdRr+aBDKk0my7ITr37Ur06qwTtQa9VshQUf9Ywv0PWk/wc1vHx8jGqKPXai kuAqGB2gomEpLoQacZgeC71nJvOi13oD5zBi1BmhwcZgGLNr0WendBADOMSUayyMYgKR MWb6BRNnJ0UO5usvpAcE3roCw9xJeKZrA/Ss7m3lRm12n4JJxpkGgF27vabSNGgbRmt1 WRUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=AwOgCCV+cQRD/xaqFLHbohMfDMRq7iMVCXN+izSf/FE=; fh=K+V32oPbgxsxocF6iRpqHpmOUWfWssy84NoLm7K8soo=; b=ULzEsjfVZl/4urYJ5xJG/NP18idr/R/kCAlYF/WSD7wiXwUNrndKUfcQU2BtF8KbvV NrwF/6EXIc3vXrAacEAfV0yFx/8I4lCmvbPRpCbmHzW6sE2vzX2wPxC7nao6FjnyAR1i pZPLd3HbKdgi2gVofn5/BpqUBPOGg9ZYpMKTldEkjMNalNEInCpIHhlRgZuSs81smujM 4qZs2cFY8B/1a096c5+QR/32qQXUMaVSLiVfy6bxA4YnaQgsTP7PkiSShZQwMPwEFgNZ hull021tgUdqZUkB8zUvYTiQZ48LuDk1ZExAHIRdiX51NOgYhbn6kFCJnChP81apj6bw xkSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JH3JfN6o; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-129671-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129671-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id er21-20020a056402449500b0056bfcbdb535si6929091edb.396.2024.04.03.04.36.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 04:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129671-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JH3JfN6o; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-129671-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129671-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5E3311F282AE for ; Wed, 3 Apr 2024 11:36:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C8BD14386D; Wed, 3 Apr 2024 11:36:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JH3JfN6o"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="K5frRWXH" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D455142E82; Wed, 3 Apr 2024 11:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712144164; cv=none; b=oDB9Fj8mImHnwNAdNZQ0fiuIqzIH3SOJn5accc3AFyVTh+761tv4um+GPHt45dRIwhu3+B70SCjMNLMiJia9dEqP+YT7AFNMd84RSQrzoDNv3LCMN2MSbhD+TxY8G04MlfYOLW2RDtscJkLHYQI6MrnNnylAp6Atw9Cu1wWom2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712144164; c=relaxed/simple; bh=t18WbamfCv19fhu0p/T4b+utaHreGFY0yfyl+Y4YJhY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=H2DcFWrYK+DwFgPF1lp06br/Its9rOnFsfFZ2SL65t8IfPPTvULN+gO3fxZxjejCgp2g4tAuOJmugzJvN01TAL3rl1gCEa1M6tbT6eTfN+nCh99mGEQFMbnMKDuY9XTDmlPkUhbJwWPqt+lIWdxOJcwdoZwLtT2SiZ7PPbYFaQ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JH3JfN6o; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=K5frRWXH; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712144159; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AwOgCCV+cQRD/xaqFLHbohMfDMRq7iMVCXN+izSf/FE=; b=JH3JfN6otUW/3RhGkD/vbOB9GI5MO9vk1GD+EssaV5ajEO0GTD8s8rA142kdX6SvBw3lgJ iX+rKGiW9DzSliLGVQ7lM1TtawMvTrVgiJjaYrK/6aGTocYgXVy4rcvIiq0bVAkPcpH9WU U2HS/Mni+6URhCqkvm03o1B2d/qQBhpEKYNbnrodk8jr9fRLSxTmVPywai/vDcSVsj8j87 iC7dNY0ELzYizUGYHIrdzP+1dv8BMr7VzlQLBmZp3vk97ZbEqIC5EwYSjd00Ehg9rBZ5Y3 Qt/5/IRHHMaus2myWEIieTCbMb2mYah+I8DIr51HpxgeJH3G3cjpawQTKi7Ynw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712144159; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AwOgCCV+cQRD/xaqFLHbohMfDMRq7iMVCXN+izSf/FE=; b=K5frRWXHLVFBs3ZMv26aoVB8lQ2Qp2HLp/+1xlk6R/kFn+KKF3fn7fbxCnVu5vNtmDWa6+ 0Gbt7TkH5cgUMxDQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , Russell King , Tony Lindgren , Ilpo =?utf-8?Q?J=C3=A4rvinen?= , Andy Shevchenko , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , =?utf-8?Q?Th=C3=A9o?= Lebrun , Linus Walleij , Lino Sanfilippo , Fabio Estevam , Arnd Bergmann , linux-serial@vger.kernel.org, Sebastian Andrzej Siewior Subject: Re: [PATCH printk v4 09/27] printk: nbcon: Implement processing in port->lock wrapper In-Reply-To: <20240402221129.2613843-10-john.ogness@linutronix.de> References: <20240402221129.2613843-1-john.ogness@linutronix.de> <20240402221129.2613843-10-john.ogness@linutronix.de> Date: Wed, 03 Apr 2024 13:41:56 +0206 Message-ID: <87cyr6y8yr.fsf@jogness.linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On 2024-04-03, John Ogness wrote: > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index d6a58a9e072a..2652b4d5c944 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -3146,7 +3146,7 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u > uport->state = state; > > state->pm_state = UART_PM_STATE_UNDEFINED; > - uport->cons = drv->cons; > + uart_port_set_cons(uport, drv->cons); > uport->minor = drv->tty_driver->minor_start + uport->line; > uport->name = kasprintf(GFP_KERNEL, "%s%d", drv->dev_name, > drv->tty_driver->name_base + uport->line); Sebastian Siewior pointed out that the port lock is initialized shortly after this code. Since uart_port_set_cons() uses the port lock, the spinlock initialization must come first. The changes for serial_core.c should be: diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index d6a58a9e072a..0c13ea6a3afa 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3145,8 +3145,15 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u state->uart_port = uport; uport->state = state; + /* + * If this port is in use as a console then the spinlock is already + * initialised. + */ + if (!uart_console_registered(uport)) + uart_port_spin_lock_init(uport); + state->pm_state = UART_PM_STATE_UNDEFINED; - uport->cons = drv->cons; + uart_port_set_cons(uport, drv->cons); uport->minor = drv->tty_driver->minor_start + uport->line; uport->name = kasprintf(GFP_KERNEL, "%s%d", drv->dev_name, drv->tty_driver->name_base + uport->line); @@ -3155,13 +3162,6 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u goto out; } - /* - * If this port is in use as a console then the spinlock is already - * initialised. - */ - if (!uart_console_registered(uport)) - uart_port_spin_lock_init(uport); - if (uport->cons && uport->dev) of_console_check(uport->dev->of_node, uport->cons->name, uport->line);