Received: by 10.192.165.148 with SMTP id m20csp3042899imm; Mon, 7 May 2018 05:47:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr3dkUbJRBWcj46svss1bQPh8h1GgLbacFTrYJNRVhcQBVEV21qWb5Ps3xtOR+wHTpD5O2N X-Received: by 2002:a63:5fd1:: with SMTP id t200-v6mr30722421pgb.246.1525697258034; Mon, 07 May 2018 05:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525697257; cv=none; d=google.com; s=arc-20160816; b=Gki5sfygLkvaI7lnvOFA69K59jxxwOkhw/ZHIMn7DDCEsa3HNTthqDzVKJ+bddhmL3 uNkLqcszo2tJOFB+jGQ8eJalcO71K2y8aCy7/7cTlYPytdkbjGq/B0Tj2hJunhFm13Eq ACzgBlU/ObPjuZpT7zte48XE/I//TRpixZ6Pt8TSDCN/sDR9J55Cs7dITsu2tMZHeY2t kh6KQQ/DxN+QsUJZEk+jztDTP0RIr/gPpZmpBx8KvSham9kuyPaYYxk23cl4AILt4xRQ y0KreUdeQPA5VPQelOf50jGMKxNqLxYOICg7ItyCHWZk9pXLHoyE9uWNmR4FjVhtIa77 YIGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=E7lpbRICr2ARSxBumpu8FUZcCiOGSB6QHjeVujCWYu8=; b=hxLuB0ByL/mndRDdOKJo0Y45GmNBmyEdxZpTZcmKqr+qh4fQQYLdKRute9XxNNBOeE jOcLUWuF95soAuKDJgGSP6SxUh2VLN4MY6aMY1Yn4J5Uz5c0JNOoY3CYavXpADS6kVET Q0bixq5E1wTu2IGmOfNS0oSzGTD38mnW9Cj7/MSBBT4Rvlnja+JxF7gJtS6zJZTan0sZ P6Ukx6QnrCR3Ekkb43OhQVzUUUKJfXMD7RcYnhmfLfy5Ld/p/KNCyzq5io04O0Eoj4qk HhwHDznNNWgynLRTdnNLrAycbB+QWN9oTxxMOhmNqSFHsBF8Exz4C1/cEwQuGExgRJk4 aaIw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12-v6si9984365pgn.479.2018.05.07.05.47.23; Mon, 07 May 2018 05:47:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752221AbeEGMrM (ORCPT + 99 others); Mon, 7 May 2018 08:47:12 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:50861 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751860AbeEGMrK (ORCPT ); Mon, 7 May 2018 08:47:10 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1fFfXk-0005MN-K9; Mon, 07 May 2018 14:47:04 +0200 Date: Mon, 7 May 2018 14:47:04 +0200 From: Sebastian Andrzej Siewior To: Geert Uytterhoeven Cc: Daniel Wagner , Linux Kernel Mailing List , linux-rt-users@vger.kernel.org, "open list:SERIAL DRIVERS" , Greg Kroah-Hartman , Linux-sh list , Daniel Wagner , Shinya Kuribayashi Subject: Re: [PATCH] serial: sh-sci: Use spin_{try}lock_irqsave instead of open coding version Message-ID: <20180507124704.s4qlrcc3leoky4r7@linutronix.de> References: <20180430080918.16763-1-wagi@monom.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180323 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-05-03 09:43:33 [+0200], Geert Uytterhoeven wrote: > > --- a/drivers/tty/serial/sh-sci.c > > +++ b/drivers/tty/serial/sh-sci.c > > @@ -2516,13 +2516,12 @@ static void serial_console_write(struct console *co, const char *s, > > unsigned long flags; > > int locked = 1; > > > > - local_irq_save(flags); > > Hence the below now runs with local interrupts enabled. > > For checking port->sysrq or oops_in_progress that probably isn't an issue. > If oops_in_progress is set, you have other problems, and the race condition > between checking the flag and calling spin_lock{,_irqsave}() existed before, > and is hard to avoid. while oops_in_progress is an issue of its own, the port->sysrq isn't avoided by by local_irq_save(). On SMP systems you can still receive a `break' signal on the UART and have a `printk()' issued on another CPU. > For actual console printing, I think you want to keep interrupts disabled. why? They should be disabled as part of getting the lock and not for any other reason. > > if (port->sysrq) > > locked = 0; > > else if (oops_in_progress) > > - locked = spin_trylock(&port->lock); > > + locked = spin_trylock_irqsave(&port->lock, flags); > > else > > - spin_lock(&port->lock); > > + spin_lock_irqsave(&port->lock, flags); > > Add > > if (!locked > local_irq_save(flags) > > here? So for oops_in_progress you get here with interrupts disabled. And if not, I don't see the point in disabling the interrupts without any kind of locking. > Gr{oetje,eeting}s, > > Geert > Sebastian