Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3943997ybz; Tue, 28 Apr 2020 03:05:25 -0700 (PDT) X-Google-Smtp-Source: APiQypJlj8YQhA/X9sdMlaC0uPd+XYpQyvbp0rNAuaSOzpxYGVkL3FygBGg27XQ2LxnEI6wpkXg0 X-Received: by 2002:a17:906:2558:: with SMTP id j24mr24489141ejb.72.1588068325313; Tue, 28 Apr 2020 03:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588068325; cv=none; d=google.com; s=arc-20160816; b=BsGyW0goc/7l7HlLSZzF6TNt9yQKFLU2XtnJO4XFiljJJqVwBN/KULqU76Lm31S8wz K7nss887JIJA0aBNbpy3zXhsjcDm2gbPpeQX+l4WZle8On1WYCCH06zA5dEofBP800qx E6qVc+bi6+7repGg7aKp+GmiWoNOtqggZ2ovVy8Jt6bKfnHIUDXBW2XzuW9m1pocZaYK OqoW1MPoGmL8FB5tNugk6j1B4q9xMlXgLeM4o+m0uRf8noy+kBCHSYYa4EPUCgGjWidw WvYeZ9alq8lYjZ1DYn4+bnV3Pvmn46NDuSA64hpreduXbm50K3d+ucnaiaZV0kRqG3hV UqRw== 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=B47MWor82gS9pbzIegeM3QuLFmWB3mDHdrQ9VL++afI=; b=n+FV7kPf+WhIJlUYTwdubF7S6n/z47VdI6vHRuMjE0oTyXpiBasPi/36zeLya1DSlY CwE59jxUcQQSfV53yAv9eHSjmXY93iG5kVCzERvjhGiisKoGmNvkcx+RGoJLz0jTnZqa loAj8tiqLq7Z9Mg1EElwoIKOJticktP/0SYI8+HLptlYY+LZO5qXiHPvg0L3UGmJVbe+ aNVgkZ+o6bmY3sAloo1pc7O4j2Oz0A2JM/dMROaGISuenB6Mz4csB1p6cg4t+t5Bpy1t HlR+jz7AYUEBHwstnBZ5GiQCiFhBeO0cel0bIaoRYODTjWnTDw4n4LVH6+5hmAwn10OO d5gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nrCK7SnA; 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 j23si1471105ejt.284.2020.04.28.03.05.01; Tue, 28 Apr 2020 03:05:25 -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=nrCK7SnA; 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 S1727773AbgD1KDh (ORCPT + 99 others); Tue, 28 Apr 2020 06:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726932AbgD1KDh (ORCPT ); Tue, 28 Apr 2020 06:03:37 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 248C6C03C1A9; Tue, 28 Apr 2020 03:03:37 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t7so2250913plr.0; Tue, 28 Apr 2020 03:03:37 -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=B47MWor82gS9pbzIegeM3QuLFmWB3mDHdrQ9VL++afI=; b=nrCK7SnAoBKnsW47PH6KdJVngh2wmddILURXMBln553biX696/xlswk8+NI/1huiq/ WAUd13XaNPT/agYm3VF4fXKbJDWG2CXvOKTe/7X6KnmC67lkkTGb6oO9b8PedRKHbEyT RBYDscitMQ+Fim7G2Qx0nNTXy395hfXXdkDJx6rwMp82tLUu6EgmS42LAB2EFi6EUUJY hZBaNewYyMTmdIQJi2G6WImQvKHZbwoMXlQ+JxOqT5KOB9VF2CDqhSf8SVh7O+vRfusT nmVdC4HGEPmKO9VbnnAlKgKC+Z6lWj4eDnq4he3J0IkVJwyyP/1BmKICCYoD45iQ70WB unTA== 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=B47MWor82gS9pbzIegeM3QuLFmWB3mDHdrQ9VL++afI=; b=tvo+MWeeBOE7cVHhTUdaX5IoTUirn4YIPMvmQlQ42hSubkdrAQITNX0guJvj6Z8aBD wL4P5f7EtXTsCiliZrh7sTjyoaGkHcPPQUyrrzk6BKKgT7YXBJr1z0UODW/hdfikFxkY xUEwkYFcRx1fIt9kVTV3ERrnbKdTdGb0OyTpbbLsw7g79i03xJvL5z73FKOCvKP0I+pa lPot7i0K8nMUunWh344bH69737e8/FBQe7CIu7ilCpyBtqxC39db8bUobfoQMGtl/4qy OBsirPKTi6RpGrQC/8WMDOAGs0TkWVT2dVBQUqhGQoxVGkcdVVDnwDo8Fh2wgMiLClTU QJAg== X-Gm-Message-State: AGi0PuawYZpu+qHAbm9fOYwZmuGQWbM7sjjxdmeCqzrOB7ShB7hkJYRQ vppuKjhyMXKHtf3mXDDTvu1AdKtswh0OZ1as8Oo= X-Received: by 2002:a17:90a:224b:: with SMTP id c69mr4246982pje.8.1588068216432; Tue, 28 Apr 2020 03:03:36 -0700 (PDT) MIME-Version: 1.0 References: <20200423220056.29450-1-john.stultz@linaro.org> In-Reply-To: From: Andy Shevchenko Date: Tue, 28 Apr 2020 13:03:25 +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 Tue, Apr 28, 2020 at 11:54 AM Valentin Schneider wrote: > > > On 27/04/20 10:02, Andy Shevchenko wrote: > >> 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"). > > Thanks for the pointer. I'm still a puzzled as to why it goes fine on one > board and not on another, but at this point I don't have any better > suggestion than the unconditional init. My patch relied on the behaviour of 8250 [1] and that comment (near to spin lock initialization routine). It seems AMBA UART drivers unconditionally assign consoles ([2], [3]) without registering it properly at console_initcall(). Least invasive fix is what John's patch does, but real fix is to do something like 8250 does. So, the rule of thumb is simple: if we assign console to the port we must initialize the lock even if we are not registering console. I dunno the history of different behaviours among drivers and what change(s) brought us to the messy spin lock initialization code in them. [1]: https://elixir.bootlin.com/linux/v5.7-rc3/source/drivers/tty/serial/8250/8250_core.c#L684 [2]: https://elixir.bootlin.com/linux/v5.7-rc3/source/drivers/tty/serial/amba-pl010.c#L691 [3]: https://elixir.bootlin.com/linux/v5.7-rc3/source/drivers/tty/serial/amba-pl011.c#L2496 -- With Best Regards, Andy Shevchenko