Received: by 10.192.165.148 with SMTP id m20csp3980509imm; Tue, 8 May 2018 00:24:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq4WqB/pVcNq+HqSrnrXXQkTE9D9/6+EOH4KO8i/i0Yax7M8u4CmzAGdfl5j0FgCXo67L47 X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr29300560ple.285.1525764281960; Tue, 08 May 2018 00:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525764281; cv=none; d=google.com; s=arc-20160816; b=XGkTc76VJu9pgfb5WhVDUBJehHDLBDC1AA7iOxgnLQem9kuDNaL3YthqzDq87TC/8/ 8vWUUm9lyofv8HNNB/1ZSpCzOoCyqapHFXkVrVUIdP1EMCMYksCuRgYSa6ooTzngXWcg OYevglCdeqM7AxMhLrfEb+zlIpLK8gJV9UnuuYWlEC6J1G2A9le4UcswGp/Shvn7Y5yX 1rWp0KTn3wr1uAmNN/k+HB0z4/FqUYK4hTu6ywDZ2t4ZZoa68Zb+QeIJ/taYzcUu2nXT ZjlWACFZ4f3/zHsg7SKLVoo187BZN2cxxp2cBsyLkg9wJSecRqAGYmuLOwPAMPURo1bR XJCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=GB9CLsyt8ya/+nEJv/8JDXyfTvYhiEH1D3y8hEWQjIg=; b=vb+UjuUpS1MzAz+LdxkjB4wEsEvwCXpeqkARICa3VreNrjN32d0uYPpIIBsCwiK40H xijY8/pTG4ovDA8+/vMuWVKm1nVhImMgfeT7YKFnMrfGNwr0eNZQ0yEti3EQx1tP3bhB FG5TkuwH7NRg5f95PuQM0Bdx2GiXosX+cpd+qKxUv/RKV8RmxgtV8tVWXHGLs+Nt/TlY NjScZ/v85zMWX0Np6qC2I8s2VlefvpZtJgvTtegP/yaDMd7H+Lg7A9XZoubuNPlpK6jy psp0fzjK5UzbsW71o0rWQbKjpgVWVNsglPCw+hvWIPOZXy2tkMB5QHQGxF5Sskn/lfZI VBaQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=monom.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j123si24804562pfd.207.2018.05.08.00.24.27; Tue, 08 May 2018 00:24:41 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=monom.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754697AbeEHHYC (ORCPT + 99 others); Tue, 8 May 2018 03:24:02 -0400 Received: from mail.monom.org ([188.138.9.77]:38788 "EHLO mail.monom.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754412AbeEHHYB (ORCPT ); Tue, 8 May 2018 03:24:01 -0400 Received: from mail.monom.org (localhost [127.0.0.1]) by filter.mynetwork.local (Postfix) with ESMTP id 86ED7500C40; Tue, 8 May 2018 09:23:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail.monom.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 Received: from helium.monom.org (ppp-93-104-170-164.dynamic.mnet-online.de [93.104.170.164]) by mail.monom.org (Postfix) with ESMTPSA id F10865004CD; Tue, 8 May 2018 09:23:57 +0200 (CEST) Subject: Re: [PATCH] serial: sh-sci: Use spin_{try}lock_irqsave instead of open coding version To: Sebastian Andrzej Siewior , Geert Uytterhoeven Cc: Linux Kernel Mailing List , linux-rt-users@vger.kernel.org, "open list:SERIAL DRIVERS" , Greg Kroah-Hartman , Linux-sh list , Daniel Wagner , Shinya Kuribayashi References: <20180430080918.16763-1-wagi@monom.org> <20180507124704.s4qlrcc3leoky4r7@linutronix.de> From: Daniel Wagner Message-ID: <66cd1363-9f62-e2f5-2271-1fa78509f2cd@monom.org> Date: Tue, 8 May 2018 09:23:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180507124704.s4qlrcc3leoky4r7@linutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). Thanks, Daniel