Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp176716lqr; Wed, 5 Jun 2024 02:39:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOXLy7E0L8AZocJmA2B3Za771xvKGw+dGAgQ/YU04VzIsOIvGEs3QNiGrMkLXg/ybxerk2D3S2iu46MsFCna/dIlpeUKqp1gmsF1JgIw== X-Google-Smtp-Source: AGHT+IFZupEvT0FOTIo4q3KvZqCo+NKD/3voXkDNXQflkUE1nGwvJnd2qBcFhwzf3b8AaX27x5xo X-Received: by 2002:a50:aad4:0:b0:57a:2cf9:f614 with SMTP id 4fb4d7f45d1cf-57a8b7c62c9mr1459004a12.32.1717580350049; Wed, 05 Jun 2024 02:39:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717580350; cv=pass; d=google.com; s=arc-20160816; b=I8ts0u16sPIwsK3wmtFVGuCUGVYJQJMxERXspeKUOoJXe/bxnZRrfxrOt73yrI/E+Q Ka90e+TcPjQXaw9CMbfVYrkJdX3nSt1rPwBZMJt35hJNKCqrCTEb3bdmNHtWD9Bu/vYq 9kg484A5EUO2drBF+Ji97PSt7uqMjmDnN62B1cU0l3ysLiJH2suPx+MSrcpZCoKsbr95 OMoiYLSPAy1bDmjrWvMOxnwJ559iD93kGfEyuC7p5WM4zIwPHV6yIp4pJcCBA8XyfVob 3Tx1W+AhgFkYlNyDtMbTa1FNTg9IPodZxk674FmBEaiOKKlrbeNF82DxQgOyt6THhAUw R42A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=30NObruWx5GMlzINttF9ReWXSPJzl5BeuLrf410WPvU=; fh=xBoscXWYkSj5agzu+xB2/rZvsEv1eoQP9WJS8LMKhT4=; b=gDqZjgD60lDupoNXFmsmU2WZmAQC9OG5vBR0m9gstO/dYcTSA58qtrWC371aZFgVP4 Zn1zhNct9ORxQd5lnw9EhJW3Ki9+4t5ygG5Ll7DxB3zuMQB6ZJxNKS3AI2DXPvXb1lPl UbHQSDBD6zz87TqbH07gTh60L02Zh2XmUrnTYyhNINOWgKhxVXyWXPplK7kmNk5Ud+Dy eQmMD8fKh80Mk0Ol6QvLEMF2yeMAkQv3SQ5ZsoMiZLHppvwCDco7gWhlIuG+cUFxmbtm SgXe3iNgCIrWoJM1gb+bghM+iKZ29gKvNYNEa1Pi12KTR6/OxfSaIGWKqD5gIQLN9cFd 7aJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dHiEOcww; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-202121-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202121-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a834e5086si1564209a12.642.2024.06.05.02.39.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 02:39:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202121-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dHiEOcww; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-202121-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202121-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C3AC01F22ED3 for ; Wed, 5 Jun 2024 09:39:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E958193072; Wed, 5 Jun 2024 09:34:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dHiEOcww" Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA19E190043 for ; Wed, 5 Jun 2024 09:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717580092; cv=none; b=N2KMYG+HwQshV9ae/0O21OuaMUlYXHNKIDL4A5tB56w8AlduASL4FlcdJrcZSLasjeMU7mZb4/x3rAvwtTT/ljYOoBfCHz9gBnmP+NLTgMn/cR10aA90zwwE70Q51EN1Mm8zPhmJEqHXRTPis7T8rVEQGD/r7npSGyZLciZgQNU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717580092; c=relaxed/simple; bh=VyMzcl86epfd+4JJGD/brazuobQXR4TW+Im54cfRqwo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=A1ApY4LFVPEha0jNr8oWVU87/K65XvuobbSDwUrUdHBFdpQTU8cWvo7ZAwWi9WxNpM62z7bJsegdjZFhsCgB8mzwTz6uMYmvq1ywPOdQrYKXj6/iYXdASut8pBqUi8gWhkJ/PxxNdmZK86m0bA6HBx0aPEYHYAhGgLZT2rnq0nI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=dHiEOcww; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-dfab5f7e749so2178894276.0 for ; Wed, 05 Jun 2024 02:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717580090; x=1718184890; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=30NObruWx5GMlzINttF9ReWXSPJzl5BeuLrf410WPvU=; b=dHiEOcwwuTLPAfYeOBtsVP/FZJxtxu1GtHzC46rdRec8WsXNQ+14+jYF+g6J3PUFwk AnWuu9pMSnqSNg5SV31NNHk0JZqDDvtgyZKc6AyEgoh1ii4sGTkY/Akdt/86Vz6oXrU1 nYEqKXiAkP55s1P2Me3xjTMOsa8Xw2jzuK6I3FtZLcN9Rd3WqjUMDBhsxKo+D4TqEeQn /87PrKq8oPGrixS9WbfIGLGjtmTAkN3MlmPC3zWyIU8wb88rY+W6Sd+87fFaQ1zvrgbu l0CFQmQeyw3EDvMbuAIcukPnw0tc6wX7ZTWjlxBbuH1eA3/KiVpM9OQaqsBUv0wgGpuS XXXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717580090; x=1718184890; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=30NObruWx5GMlzINttF9ReWXSPJzl5BeuLrf410WPvU=; b=VTp/CbwVhXPLL3EXBEtHQjU0t7WbT8H6lmACXLNVTwN+ipIgRvHITx4E89gEWvyqzv cp6vN3Q3IVl6FkhXMtHrIDWCi0pgY9IaI7h0+cE+Zdy35s+AwvLe7aTPUPsGLv75tY/v v4rHxOXbIBD1+yi4zzWtRWNnru0+TgNxy/acxR9NsX507JUZm156EsP2ZTPiOttDb2If EXhroWX2F1158L0YZRqjVXZAnRvQa2/m/aYPaUsPKp/aD732rBt5n5tUceWUdGbB7Lhe RbgB3kJtCCiJxlHqiZOfp59oZtg1lEOhEHoBBG0kHtSEveVp9bgD7uEWDmszxtXdLkUg bPOg== X-Forwarded-Encrypted: i=1; AJvYcCVE8xpawRS9ig5LV3zm2u9HHM2QSqICi6UUpkAqdR5VZxIZAXRc3Cg/AU+GJUw3uOJpdIYKDJI5vNEWtizdUKsD0ijDu5GSiWr6ilnd X-Gm-Message-State: AOJu0YzqmWtt3AjzSKE5WVwqykJOOZNtDC+6KMqCbzicqmiQYVWoz5HJ oOTcCyFPEI9XlDM/sq8lV7KqS0ITzB+uPFr0rQz63ucAF9/hvNVBXX3cLxZgzfUQNk8Lbaa4K+l p9FrkjsaPRKLUpY5juf0zyegmb13Vi88JgP1uyw== X-Received: by 2002:a05:6902:230f:b0:df7:97d4:b790 with SMTP id 3f1490d57ef6-dfaca9bd66cmr2065639276.18.1717580089668; Wed, 05 Jun 2024 02:34:49 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Ulf Hansson Date: Wed, 5 Jun 2024 11:34:13 +0200 Message-ID: Subject: Re: [PATCH/RFC 0/3] pmdomain: renesas: rmobile-sysc: Remove serial console handling To: Geert Uytterhoeven Cc: Greg Kroah-Hartman , Jiri Slaby , "Rafael J . Wysocki" , Rob Herring , Saravana Kannan , Claudiu Beznea , Peng Fan , linux-pm@vger.kernel.org, linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen Content-Type: text/plain; charset="UTF-8" + Tomi On Mon, 27 May 2024 at 14:41, Geert Uytterhoeven wrote: > > Hi all, > > Since commit a47cf07f60dcb02d ("serial: core: Call > device_set_awake_path() for console port"), the serial driver properly > handles the case where the serial console is part of the awake path, and > it looked like we could start removing special serial console handling > from PM Domain drivers like the R-Mobile SYSC PM Domain driver. > Unfortunately the devil is in the details, as usual... > > Earlycon relies on the serial port to be initialized by the firmware > and/or bootloader. Linux is not aware of any hardware dependencies that > must be met to keep the port working, and thus cannot guarantee they > stay met, until the full serial driver takes over. > > E.g. all unused clocks and unused PM Domains are disabled in a late > initcall. As this happens after the full serial driver has taken over, > the serial port's clock and/or PM Domain are no longer deemed unused, > and this is typically not a problem. > > However, if the serial port's clock or PM Domain is shared with another > device, and that other device is runtime-suspended before the full > serial driver has probed, the serial port's clock and/or PM Domain will > be disabled inadvertently. Any subsequent serial console output will > cause a crash or system lock-up. E.g. on R/SH-Mobile SoCs, the serial > ports share their PM Domain with several other I/O devices. After the > use of pwm (Armadillo-800-EVA) or i2c (KZM-A9-GT) during early boot, > before the full serial driver takes over, the PM Domain containing the > early serial port is powered down, causing a lock-up when booted with > "earlycon". Hi Geert, Thanks for the detailed description of the problem! As pointed out in regards to another similar recent patch [1], this is indeed a generic problem, not limited to the serial console handling. At Linaro Connect a few weeks ago I followed up with Saravana from the earlier discussions at LPC last fall. We now have a generic solution for genpd drafted on plain paper, based on fw_devlink and the ->sync_state() callback. I am currently working on the genpd series, while Saravana will re-spin the series (can't find the link to the last version) for the clock framework. Ideally, we want these things to work in a very similar way. That said, allow me to post the series for genpd in a week or two to see if it can solve your problem too, for the serial console. Kind regards Uffe [1] https://lore.kernel.org/linux-arm-kernel/CAPDyKFqShuq98qV5nSPzSqwLLUZ7LxLvp1eihGRBkU4qUKdWwQ@mail.gmail.com/ > > This RFC patch series aims to provide a mechanism for handling this, and > to fix it for the PM Domain case: > 1. The first patch provides a mechanism to let the clock and/or PM > Domain subsystem or drivers handle this, by exporting the clock and > PM Domain dependencies for the serial port, as available in the > system's device tree, > 2. The second patch introduces a new flag to handle a PM domain that > must be kept powered-on during early boot, and by setting this flag > if the PM Domain contains the serial console (originally I handled > this inside rmobile-sysc, but it turned out to be easy to > generalize this to other platforms in the core PM Domain code). > 3. The third patch removes the no longer needed special console > handling from the R-Mobile SYSC PM Domain driver. > > I did not fix the similar clock issue, as it is more complex (there can > be multiple clocks, and each clock provider can have its own value of > #clock-cells), and I do not need it for Renesas ARM platforms. I will defer to Sarvana here, but ideally his series for the clock framework should solve this case too. > > This has been tested on the APE6-EVM, Armadillo-800-EVA, and KZM-A9-GT > development boards, with and without earlycon, including s2ram with and > without no_console_suspend. > > Notes: > - This should not be needed on RZ/G3S, where each serial port device > has its own PM Domain, > - drivers/clk/imx/clk.c and drivers/pmdomain/imx/scu-pd.c have special > handling for the of_stdout device, but is probably not affected, as > each serial port seems to share its PM Domain only with the serial > port's clock controller. > > Thanks for your comments! > > Geert Uytterhoeven (3): > earlycon: Export clock and PM Domain info from FDT > pmdomain: core: Avoid earlycon power-down > pmdomain: renesas: rmobile-sysc: Remove serial console handling > > drivers/pmdomain/core.c | 24 ++++++++++++++++-- > drivers/pmdomain/renesas/rmobile-sysc.c | 33 +------------------------ > drivers/tty/serial/earlycon.c | 14 ++++++++++- > include/linux/pm_domain.h | 4 +++ > include/linux/serial_core.h | 10 ++++++++ > 5 files changed, 50 insertions(+), 35 deletions(-) > > -- Kind regards Uffe