Received: by 10.192.165.148 with SMTP id m20csp3984075imm; Tue, 8 May 2018 00:29:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpP6H5U4x/Kg1KkIK0KXTyGaGmW5Gc4o4F/wBXCXzkZBGr8YUYRtQ6eLKbJntIrj4v4FXhg X-Received: by 10.98.78.200 with SMTP id c191mr38425934pfb.153.1525764585966; Tue, 08 May 2018 00:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525764585; cv=none; d=google.com; s=arc-20160816; b=CLf/qFqehx1AfyVSIhkkb237HhutS/8I3wZNRI8NLLSj82GpByn8WwDVvy0vcc3w9b UKK97F0WLwliZhp000NTsqliUBCdMAMZWrk2AdHLWgNnkODZOx6j57XD1nL8sySJ/hcj JBIqopUbvY887OtchRa71vVJpR80avdd8EHEhV1Ou0ipLMRP+votWpWGaWnkmPoBTiF9 Y2GGrqsuDcs3UscYO5Kl+h82cGUp6ZuFXqm6nQbqajiN0PMHfxE1j3M9rQRz2mXqW3CJ sxTYksBzarmKnBGXBnnu65uoXXRl1xuMKDkisuB7Dn4qPKvO5FyNpX9NBiaQDIP8vkG2 kvMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=CGSJqcmeq4TY0iZIJJrhbTikCaeTIeqMQkHmRi2vy6c=; b=b9/J2lvxCYeptpuOgCbrMAGCcXZ2GQmnDsaskmxUJNCK6wsTmDYw0+7H7ty8L3nZj/ 7RzIx+GBNBIcDmlR+6sMivibfM/Dq0tJkyZEj4nPL5TFWeI+njfqQxyi2Reu+RuvrUdd 9TXDJHZ2WgrXBy6wr01cprr81R+F42Jv2Jwo9K6nKW5hnJ1rvpCbeCoRXdScYv14DLkx In8+hlxXMjj/6hABEwvl3t0OTLl0RqglWz8ThMr827NBIKTHNU0v9hjI6oZUd9FW5nMn tkZIcJPGiu+qBSwXZn+08RARnUEsfmZ21VtQK9u2JsBjc/f5cGAVtYIWFfvstE79yvbm P9FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=SFWVL6xG; 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 p91-v6si23237070plb.457.2018.05.08.00.29.31; Tue, 08 May 2018 00:29:45 -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=@gmail.com header.s=20161025 header.b=SFWVL6xG; 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 S1754734AbeEHH3I (ORCPT + 99 others); Tue, 8 May 2018 03:29:08 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:36837 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754263AbeEHH3G (ORCPT ); Tue, 8 May 2018 03:29:06 -0400 Received: by mail-ua0-f194.google.com with SMTP id b25so13385709uak.3; Tue, 08 May 2018 00:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=CGSJqcmeq4TY0iZIJJrhbTikCaeTIeqMQkHmRi2vy6c=; b=SFWVL6xG40J99I/UyCgau2gsxpjRQhxuA2zojpjgZF/p3Bxfe+dmiS1PI3FEwxI/B1 EGYZ4Oi8rFYUt1Rfi07pTDuRz0Z0dtEgiXTzK8C9wL3n0jub6dEk5m2MU6K4sWEPFhgi bj8cAq07aPDsGBuvpypmaPlGTePTJ7McPv5CXU+c4T0rgyYfQXbbbGe9S8tdgRV+m6os fWhjyi6w7iALriNcrmpHVXmAs8EVCBIwhP2M15F6lhtN4JoaboC/S6PnTk+e8XHORdzD CcpRzngDVjiQl8pONweQdmdKxQGx0ww+AhiHglreb5t88Dc//RU7iDN6/DozWN3wnyiR Vadg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=CGSJqcmeq4TY0iZIJJrhbTikCaeTIeqMQkHmRi2vy6c=; b=kXyhynuMD6LixjkHHmRNO7JLyYlINv+J9iYNQg1/WA87c/VljvssH8UpmuBcDOV7MN dDIpau9xwgpcNa+dkseJzBOeud3UkurcquiqO/e28E1gJbC2Z7lI1aS+nHkvt4EqqmC0 4F5o32iXrRtFCz6bqV+KrnEpp8OqfsboAhXkGYVySQX62W/GP8+Jp+D34UawNdOycygq lGjbz8ogM7GcNBvzRxTT9+t8Hn6paIJxsJQ9OMphmANHU67w+AWzNwdnD7nf6iS2rNZD fNNGWMhouP3yKJglPEkVpCYeYLYBu26iNS5/Tw/KoKM7tuFjYelG6tBYER4/VCinnfBt mGaA== X-Gm-Message-State: ALQs6tBIxwiyAgWSFy5gq7n3/Vpz1WRU+HAVC4L867ReXzL/PF8IIGRA Z6bQy/PYfIieDG+FRXJ4CtbD4YfAAWD+Ze4LDUSmeA== X-Received: by 10.159.46.15 with SMTP id t15mr36114294uaj.114.1525764545424; Tue, 08 May 2018 00:29:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.122.10 with HTTP; Tue, 8 May 2018 00:29:04 -0700 (PDT) In-Reply-To: <66cd1363-9f62-e2f5-2271-1fa78509f2cd@monom.org> References: <20180430080918.16763-1-wagi@monom.org> <20180507124704.s4qlrcc3leoky4r7@linutronix.de> <66cd1363-9f62-e2f5-2271-1fa78509f2cd@monom.org> From: Geert Uytterhoeven Date: Tue, 8 May 2018 09:29:04 +0200 X-Google-Sender-Auth: ChP1UmmQApt8Fp66R45lfPOuzFw Message-ID: Subject: Re: [PATCH] serial: sh-sci: Use spin_{try}lock_irqsave instead of open coding version To: Daniel Wagner Cc: Sebastian Andrzej Siewior , Linux Kernel Mailing List , linux-rt-users@vger.kernel.org, "open list:SERIAL DRIVERS" , Greg Kroah-Hartman , Linux-sh list , Daniel Wagner , Shinya Kuribayashi Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, On Tue, May 8, 2018 at 9:23 AM, Daniel Wagner wrote: > On 05/07/2018 02:47 PM, Sebastian Andrzej Siewior wrote: >> 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. > > > So I understand, the initial version of this patch was correct. > > @Geert if you don't object I'll send a v3 (v1 ported to mainline). Please go ahead, thanks! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds