Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2666197ybz; Mon, 27 Apr 2020 02:06:34 -0700 (PDT) X-Google-Smtp-Source: APiQypINeSiQsdDls8ODy8v8iZM0WjUSs83Ri29OXTHl6CRk9FSZqe6wAt+GkCjQ2pcGCIK6pjOI X-Received: by 2002:a17:906:6b05:: with SMTP id q5mr18249766ejr.329.1587978394312; Mon, 27 Apr 2020 02:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587978394; cv=none; d=google.com; s=arc-20160816; b=ciljudErwb7eLTgGMJmpCj5S5GkW6VzXHxjsyEf8Hq7FlyaAId6Fw79hqqcnD+Ryvm yFUyMxE/52HqLpkT7Ck8RxSjbfaA4L1eN3u50dFRTLXTho70Nfmg05Lfgwyq+70GALeZ cMR3t2oFCtBtPX+EP7L4/WVwWPN/fbXksgwhhekG6E6/sPTdGVv+EuSW9oKOla84mqfz Xd+Oz76wiQ/RX3Gz8TmIO8326WKvF5LBeqkhTDRSAYez3t8EkP04SE70sH4NQWzoNM4r cOvj7iDQtlQOcDL13JabZpWYuyIfKroao+HiGDaFk0b3uxsgCdN2Yy83r/EGOKVAT+Y7 jf6Q== 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=No3l3tVxMOYI0sBvPh0yz49YIT/rbemERKzXNkg42cM=; b=tj7fBbBQe7MciikgQBQhcWrB7CeYU3DzrNaTRO6JP0uLSiJ1QbHTSOnjmsVv27xD/F Oq9vCyML9cF/kwjTPEQXMwQpSfqSsj5QubDMfeXQpTpGuJag6sHUMYpBkA7nFNJOrXKp Tlbk7Xw6gbcLZMzGTZ0IhpJn8P81ag6jMQBT8hmsixUvD+9GNzzc7dBBn8pcffqZUZta w+lAoE3IBMNQLtLmYrkffpX7SAd9/p+sbwsbWOOuXa7dK6ft7I6rdfMMvJwRFK+Iqcsh VgwXE6yyY2K9KT8N1zj9QhcH+12YU02xe0qaDHkG2zOtquTcrPJTCFMfL0b+LUhMPWFt CE9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S9jfsLt2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si7402636edy.293.2020.04.27.02.06.11; Mon, 27 Apr 2020 02:06:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S9jfsLt2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbgD0JCj (ORCPT + 99 others); Mon, 27 Apr 2020 05:02:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726003AbgD0JCi (ORCPT ); Mon, 27 Apr 2020 05:02:38 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EF4EC061A41; Mon, 27 Apr 2020 02:02:38 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id d17so8433120pgo.0; Mon, 27 Apr 2020 02:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=No3l3tVxMOYI0sBvPh0yz49YIT/rbemERKzXNkg42cM=; b=S9jfsLt2b0vbA6WMBsREA7m6FlxSVBc3AMXqrbDArXxsA8rUUnJxJIRlxKInrpwWlp lTlJL9PCHUkvCXneeeWDf1hQTWBvUtrBro/PDbKbsOsi43NNcuGxsClyz7dos/p2c64d 1o3oygCQlmNgD8D0lhNQiPMoEr+uCpLCTDS513OTOJ1wgZ/iNJksjU6PfSPGrWNXnWFs 8MHPpa9vpG1DH8nOcul/+7xQMs9uT1in+UJ0Uk/4oYsoulT7yRiHw3HVfdm0wvrS9tNd gMzZ7vpDlx0gD1YMGHmcEkcHGgrLvNiYBMUxtr+hdMM1nkdBKgE40Uyoqd71BEG0u4F2 wmVA== 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=No3l3tVxMOYI0sBvPh0yz49YIT/rbemERKzXNkg42cM=; b=Qy6pbG8Zla65RNPpzsXOHV+28mimg9YB34w7/skunzoaPI9gj1MGn30AjipxCnWsHy 3B98Dk+brsawthE5qx6Wku0CNKOCx3S76pKLCMtW65Ir0L6ybWMC242ZwOJMqjZIiFI7 J2lJBqg1zZM0kElgfpTo+VNSwhlml3e0YFFB2bh/tfeBPN3l54sbA2RYTgiZTixTlmB1 SJnageh6U0jF1KzY5T3PmCwT/rYCuXef+JU2PdOPrYEYnJ3n/4+/DW/OsfEv8uNjs7qV DIp7LDsZ2V0jy0zgPR58ETLSec+qAUBAk6hc4u7N/yyf609ndE8pb1YghdfflR8zIlhS I7/Q== X-Gm-Message-State: AGi0PuaztzWuNj9PFfa2gfnaPzmOSB9sPqQwIZzZMeJcnStOzLyH535G wfh3TqHAso91QxGiyczPAOfNmfHr26iYx+GmNRE= X-Received: by 2002:a62:5ec7:: with SMTP id s190mr22398681pfb.130.1587978158112; Mon, 27 Apr 2020 02:02:38 -0700 (PDT) MIME-Version: 1.0 References: <20200423220056.29450-1-john.stultz@linaro.org> In-Reply-To: From: Andy Shevchenko Date: Mon, 27 Apr 2020 12:02:31 +0300 Message-ID: Subject: Re: [RFC][PATCH] serial: amba-pl011: Make sure we initialize the port.lock spinlock To: Valentin Schneider Cc: John Stultz , lkml , Russell King , Greg Kroah-Hartman , Jiri Slaby , "open list:SERIAL DRIVERS" , Andy Shevchenko 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 On Mon, Apr 27, 2020 at 2:29 AM Valentin Schneider wrote: > > > On 25/04/20 05:04, John Stultz wrote: > > On Thu, Apr 23, 2020 at 4:14 PM Valentin Schneider > > wrote: > >> On 23/04/20 23:00, John Stultz wrote: > >> > Which seems to be due to the fact that after allocating the uap > >> > structure, the pl011 code doesn't initialize the spinlock. > >> > > >> > This patch fixes it by initializing the spinlock and the warning > >> > has gone away. > >> > > >> > >> Thanks for having a look. It does seem like the reasonable thing to do, and > >> I no longer get the warning on h960. > >> > >> That said, I got more curious as this doesn't show up on my Juno (same > >> Image). Digging into it I see that uart_add_one_port() has a call to > >> uart_port_spin_lock_init() a few lines before uart_configure_port() (in > >> which the above warning gets triggered). That thing says: > >> > >> * Ensure that the serial console lock is initialised early. > >> * If this port is a console, then the spinlock is already initialised. > >> > >> Which requires me to ask: are we doing the right thing here? > > > > So I got a little bit of time to look at this before I got pulled off > > to other things (and now its Friday night, so I figured I'd reply > > before I forget it on Monday). > > > > I did check and lockdep is tripping when we add ttyAMA6 which is the > > serial console on the board. I wasn't able to trace back to why we > > hadn't already called spin_lock_init() in the console code, but it > > seems we haven't. > > > > So on the Juno (ttyAMA0), the first time I see us hitting > uart_port_spin_lock_init() is via: > > uart_add_one_port() -> uart_port_spin_lock_init() > > Since port->cons->(index, line) is (-1, 0) at this point in time, > uart_console(port) returns false and we init the spinlock. When then > happily trickle down to uart_configure_port() -> register_console() > > > On the Hikey960 (ttyAMA6) I see the same initial flow, but (index, line) > is (6, 6), so uart_console(port) returns true and we skip the > spin_lock_init(). When then hit the splat on the rest of the way down > uart_add_one_port(). > > > I did a tiny bit of git spelunking; I found a commit that changed > uart_console_enabled() into uart_console() within > uart_port_spin_lock_init(): > > a3cb39d258ef ("serial: core: Allow detach and attach serial device for console") > > Reverting just that one change in uart_port_spin_lock_init() seems to go > fine on both Juno & HiKey960, but I think that doesn't play well with the > rest of the aforementioned commit. I think that this initial (index, line) > tuple is to blame, though I've added Andy in Cc just in case. The above mentioned commit reveals the issue in the code which doesn't register console properly. See what I put in 0f87aa66e8c31 ("serial: sunhv: Initialize lock for non-registered console"). -- With Best Regards, Andy Shevchenko