Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1085110ybl; Wed, 4 Dec 2019 16:42:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyDbUX/zCRuO6ApKIBMQnUxiR7mYFkj29iOq9KJw8JM7DvmTDUBkqMqn9iSQFTEZN1K0nHo X-Received: by 2002:a05:6830:591:: with SMTP id c17mr4402855oth.226.1575506565753; Wed, 04 Dec 2019 16:42:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575506565; cv=none; d=google.com; s=arc-20160816; b=SF/xg1bGq9Xocu5VRxIdNB/2lXBOVH/eRRWgejpgMguC+blpNs0T9AiW9dr8sA9J8i lTiwC/G9DZbSRt2lCdSLY48w56sq0hcLP39muiFBdGMmazdgpHAnxaxRsH4uZyRcGFCg NJfOlVRwcejfnX5japTDUe6YNc24atVC+fLhaokDm6329bgLXjZuCR1jvZ/KbLis0Tc/ YYzYLmnIAqXgiQUnTYJzUFXyogiG6ePI/Y6H0/inp9U/ig2c2Nco+rUWtoKWDODaKQ9e sEdE27raXwuqeBv8ykdd3C7O+C67f2fPwBRjWnwAfxbMetplCc6NHb/i3iG2pD9hcSCW Lcbg== 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 :in-reply-to:references:mime-version:dkim-signature; bh=fO9gtIsalSOE0LJbwjwWOC5kliKZZAsXyfcY1acwND4=; b=lPGf5XujAKh/CHuPP9NdvKTghI+t3e9iuMA61JOaLN2iXOeHl4Pv2PjCNqRTvQXNPh 5mRpneanYq/YFRfHLwr+idzPoYEjf10Ywe45KXNqTPjmgBoB9whnlOB5b6uCqNQcTEKY k2Su0YYw95qwZCpOAs2xvYApNSrdky1E1CrD/UOvbcyqQeAeFE0pBrC+fd/Zb/D8ZoOr bY5PrR6Ye6R06XCFsIXGPRM71pjXH2lMICowaQzZslgBmBOLLk9eHznAQmSk9DkmhmEX 0zIoKDzPd3Faxt+N2EjlCuPVMxmbKAKFLbgOv0kkEDSaWA1gWAIvSU4QJGiISNFlRr2e qidw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NwIoRKWP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si3830009oti.167.2019.12.04.16.42.33; Wed, 04 Dec 2019 16:42:45 -0800 (PST) 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=pass header.i=@chromium.org header.s=google header.b=NwIoRKWP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728604AbfLEAke (ORCPT + 99 others); Wed, 4 Dec 2019 19:40:34 -0500 Received: from mail-il1-f194.google.com ([209.85.166.194]:37845 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbfLEAke (ORCPT ); Wed, 4 Dec 2019 19:40:34 -0500 Received: by mail-il1-f194.google.com with SMTP id t9so1394953iln.4 for ; Wed, 04 Dec 2019 16:40:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fO9gtIsalSOE0LJbwjwWOC5kliKZZAsXyfcY1acwND4=; b=NwIoRKWP9rsacN/oIOZabiTCAFvcFmwPfU/2JxMX5t4NY71U2tiGRRz1U2SqE7kuWr MdsNP3zQqY9F1xmYSzB349Q1PJOAYwKDF9OefiklEiTj9B6ql9L5etsZ+NvtKuoD0Wj3 30gOu7Vm2UmvSDF2+QVZCj/OdaLHMIGFBnu5U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fO9gtIsalSOE0LJbwjwWOC5kliKZZAsXyfcY1acwND4=; b=cTtGxuX79qvr9w3AIVMPtHFIkpbNRm7mQVzIfMhvONqa+1IqI68Wpj/EK25181yd/V 0e0uOmyD+TL3w4cO/Ykvv6ewZ4k+FH2T8A8gICcAgPrfWT/T/HRK17YRFn1CQ/aoIoSq u4mkrtHcsSYIYzAmzQdEfC+fuywEY6ebDkaK3EW41z1S/WU/HdSwoD7uLQnNnk0a2S4c Md7wQIbw/yYpwqC9Q/rCduTMBP1cKf/Z72fgfwWzoj2+ipGVVEGGqS0EmM/HLiD8RprO ups8dj1wtqUhOwwingvDdJ+TvSyx0GzbLg/ePGMqCAGluh2S9jxqCiIGzArzQWGmHHuk vyfg== X-Gm-Message-State: APjAAAUsbQHSfY8BfaZP07hKtuSAs8g6qliCyKHfsO7MoMudGjBPiNtn OBlU8HOdjv6vR98HoTh121EDfUKUPcg= X-Received: by 2002:a92:5855:: with SMTP id m82mr6229672ilb.302.1575506433307; Wed, 04 Dec 2019 16:40:33 -0800 (PST) Received: from mail-il1-f175.google.com (mail-il1-f175.google.com. [209.85.166.175]) by smtp.gmail.com with ESMTPSA id q3sm2290086ilk.15.2019.12.04.16.40.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Dec 2019 16:40:32 -0800 (PST) Received: by mail-il1-f175.google.com with SMTP id t9so1394893iln.4 for ; Wed, 04 Dec 2019 16:40:31 -0800 (PST) X-Received: by 2002:a92:3c41:: with SMTP id j62mr6440578ila.269.1575506431610; Wed, 04 Dec 2019 16:40:31 -0800 (PST) MIME-Version: 1.0 References: <20191127141544.4277-1-leo.yan@linaro.org> <20191127141544.4277-2-leo.yan@linaro.org> In-Reply-To: <20191127141544.4277-2-leo.yan@linaro.org> From: Doug Anderson Date: Thu, 5 Dec 2019 08:40:20 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] tty: serial: msm_serial: Fix lockup for sysrq and oops To: Leo Yan Cc: Andy Gross , Greg Kroah-Hartman , Jiri Slaby , Bjorn Andersson , Stephen Boyd , Nicolas Dechesne , Jeffrey Hugo , linux-arm-msm , linux-serial@vger.kernel.org, LKML 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, On Wed, Nov 27, 2019 at 10:16 PM Leo Yan wrote: > > As the commit 677fe555cbfb ("serial: imx: Fix recursive locking bug") > has mentioned the uart driver might cause recursive locking between > normal printing and the kernel debugging facilities (e.g. sysrq and > oops). In the commit it gave out suggestion for fixing recursive > locking issue: "The solution is to avoid locking in the sysrq case > and trylock in the oops_in_progress case." > > This patch follows the suggestion (also used the exactly same code with > other serial drivers, e.g. amba-pl011.c) to fix the recursive locking > issue, this can avoid stuck caused by deadlock and print out log for > sysrq and oops. > > Fixes: 04896a77a97b ("msm_serial: serial driver for MSM7K onboard serial peripheral.") > Signed-off-by: Leo Yan > --- > drivers/tty/serial/msm_serial.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c > index 3657a24913fc..889538182e83 100644 > --- a/drivers/tty/serial/msm_serial.c > +++ b/drivers/tty/serial/msm_serial.c > @@ -1576,6 +1576,7 @@ static void __msm_console_write(struct uart_port *port, const char *s, > int num_newlines = 0; > bool replaced = false; > void __iomem *tf; > + int locked = 1; > > if (is_uartdm) > tf = port->membase + UARTDM_TF; > @@ -1588,7 +1589,13 @@ static void __msm_console_write(struct uart_port *port, const char *s, > num_newlines++; > count += num_newlines; > > - spin_lock(&port->lock); > + if (port->sysrq) > + locked = 0; > + else if (oops_in_progress) > + locked = spin_trylock(&port->lock); > + else > + spin_lock(&port->lock); I don't have tons of experience with the "msm" serial driver, but the above snippet tickled a memory in my brain for when I was looking at the "qcom_geni" serial driver, which is a close cousin. I seemed to remember that the "if (port->sysrq)" was something you didn't want. ...but maybe that's only if you do something like commit 336447b3298c ("serial: qcom_geni_serial: Process sysrq at port unlock time")? Any way you can try making a similar change to the msm driver and see if it allow you to remove the special case for "port->sysrq"? -Doug