From patchwork Wed Jul 10 13:33:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 13729331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 412B4C3DA41 for ; Wed, 10 Jul 2024 13:34:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=1y6QWcxBkpL8sLlZ7Lnp0OFscz5jEsI1SABkkWAxiaY=; b=fl8zBIB+Gr2/nOlcV31FOzutE7 ZEYnpBqsOqjsY/QKpdAnCAqCY6ITHpPiUYkVg56MKb6Oz0ACaqdUKYrMXh6XjDq9BSL2E0SE4pzRd nhQdXKSae5++Epl0slWJk6NBbVzdjvGkcZvLGDWH3pbo1wpTi4Wr4GHfhUP7ohbRxbIPCRVt24chx jb9OmGgizpYi1+hTV4U2arNKzuMrEXyxALCXlLFdPOhkQOrn3UEBIzi++uqPd/mrxxyJVQyqx9tPs vrLJw/348qgFczKAjRD+qge8QoCY90pbaz4ATLG1plQ8df4juD9jejvY3tSsBimjtLIONeUqBt5xG 8LQIpZjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRXSE-0000000AfVM-1gBt; Wed, 10 Jul 2024 13:33:54 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRXRw-0000000AfRi-2tmw for linux-arm-kernel@lists.infradead.org; Wed, 10 Jul 2024 13:33:38 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-58ef19aa69dso7135477a12.3 for ; Wed, 10 Jul 2024 06:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720618415; x=1721223215; darn=lists.infradead.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=1y6QWcxBkpL8sLlZ7Lnp0OFscz5jEsI1SABkkWAxiaY=; b=MHiiHv+fmDKCr6JA3SCyavEhzxuQsTEJwmuS10G5WaPLsHGwaWxcrWNZp00bQoE5GW R/FQtsXyH8uNZHQIegoFf9awmls1gFBCYLeTV6qNGXWZRIvdoKf1GuLY25Uz1WbBe7gr eChklG+0k3MoGL5sfKxISZp+ntzyxE/EACIpnFDbn0WADBDukxZ+YIHmwAudy98dm62n OX7dDAObJwU4zxceNJxVpNsBRpfaBvJTG/k9LCV49Rggkx6WBPjiq83wsvPXWWAOCBJL nOqPpO80gYCdTDEp77oqw/Jld1r8xJgt9TX7dkLhDWX2NaKyNjJZLFPHxar8+V1pmo77 W8Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720618415; x=1721223215; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1y6QWcxBkpL8sLlZ7Lnp0OFscz5jEsI1SABkkWAxiaY=; b=tdxdAFWqo7MImwLmpYONr6LQccMyK2HpoWiWoUOc4w+NfKmb5lf9OSQbHv3dpkWqry jqVwO6bZ81o6C7NV+kS5Xzu0eDL1z1uIW0JBPDmrfGAxbZUyUsMCpyinNrlobInckNNw PLLJ5OxBqVGsRQR2DD8LXUgVNdXLJG9jy5RF723JhwI5ywzN2shfzgv4Kx/7+5aNt4qj HDBPFx8+3Ei+d3JBLsqL5L8c84ce3DLt0XdDo3chyQsSrhmjDu1IQ7q6GRMg8bh+O6wt STzB5rkcdqTJdlBMfeggUUjqQ8hmldyt0GyPxvMkg0gPvUrnZZqzNWwHJRqbzEZPGeXu eELA== X-Forwarded-Encrypted: i=1; AJvYcCVtu5nMB/eDayfeovecQCsg961E+dwmrGyWw/pMaN4hj2yXbtKI/14Sm/gxe9tUWxQz7Z+HPv0KvbHbhc2CzZYjC4yzhtgF1h5VTQyi4CbecX9hybQ= X-Gm-Message-State: AOJu0Yw/+4BSTV5EBCSthBiUxvt0sICP8+puIaUdZjrk1bBTWOxqvT9f HE2fb4DQesCKGjR6az016qxnJSWFtU8XX7lGv00o5EkE958RxaTnuGft6PgnykA= X-Google-Smtp-Source: AGHT+IEEff496JavyqfJq2LbrLMOXmUgoqw2wNiKA4XmY54IbkKvb8k1RWAvkt+sVr9kiG7HW6bnWA== X-Received: by 2002:a05:6402:b19:b0:58d:842:6272 with SMTP id 4fb4d7f45d1cf-594bb67e9demr2995655a12.25.1720618414622; Wed, 10 Jul 2024 06:33:34 -0700 (PDT) Received: from puffmais.c.googlers.com (8.239.204.35.bc.googleusercontent.com. [35.204.239.8]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-594bc4e81a6sm2220643a12.49.2024.07.10.06.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 06:33:34 -0700 (PDT) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Wed, 10 Jul 2024 14:33:29 +0100 Subject: [PATCH] tty: serial: samsung: add clock comment for earlycon on gs101 MIME-Version: 1.0 Message-Id: <20240710-samsung_tty-gs101earlycon-v1-1-bd0f8481542a@linaro.org> X-B4-Tracking: v=1; b=H4sIAKiNjmYC/x3MQQqDMBBA0avIrBuY0RTBq5RSopmkAzaWjIoi3 t3g8i3+P0A5Cyt01QGZV1GZUgE9Khi+LkU24ouhxtpiS2jU/XRJ8TPPu4lKSOzyuA9TMpbanhr 04UkeSv/PHGS736/3eV5IQ8KBawAAAA== To: Krzysztof Kozlowski , Alim Akhtar , Greg Kroah-Hartman , Jiri Slaby Cc: Peter Griffin , Tudor Ambarus , Will McVicker , Sam Protsenko , kernel-team@android.com, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, =?utf-8?q?Andr?= =?utf-8?q?=C3=A9_Draszik?= X-Mailer: b4 0.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240710_063336_757584_AB5FDF8D X-CRM114-Status: GOOD ( 23.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As pointed out in [1] before, the hand-over between earlycon and serial console is fragile due to clocking issues: ... causing earlycon to stop to work sometime into the boot for two reasons: * peric0_top1_ipclk_0 requires its parent gout_cmu_peric0_ip to be running, but because earlycon doesn't deal with clocks that parent will be disabled when none of the other drivers that actually deal with clocks correctly require it to be running and the real serial driver (which does deal with clocks) hasn't taken over yet The console UART, and I2C bus 8 are on the same cmu_peric0 controller, and that cmu_peric0 has two clocks coming from cmu_top, ip and bus. For I2C8 & UART to work, both of these clocks from cmu_top need to to be on as they are the parent of the i2c8-(ip|pclk) and uart-(ip|pclk) each. The bootloader leaves those clocks running, yes. So earlycon works (for a while). At some point into the boot, one of two things happens: 1) Linux will load the i2c driver. That driver does clock handling (correctly), it will initialise and then it has nothing to do, therefore it disables cmu_peric0's i2c8 ip and pclk clocks. Because at that stage nothing appears to be using the cmu_peric0's ip clock (the real serial driver hasn't initialised yet), Linux decides to also disable the parent ip clock coming from cmu_top. At this stage, the earlycon driver stops working, as the parent ip clock of the uart ip clock is not running any more. No serial output can be observed from this stage onwards. I think what is probably happening is that the console uart FIFO doesn't get emptied anymore, and earlycon will simply wait forever for space to become available in the FIFO (but I didn't debug this). Anyway, the boot doesn't progress, the system appears to hang. In any case it's not usable as we have no other means of using it at this stage (network / usb / display etc.). 2) Alternatively, the UART driver will load at this stage. Again, it will tweak the clocks and after probe it will leave its clocks disabled. The serial console driver hasn't taken over at this stage and earlycon is still active. Again, the system will hang, because IP and PCLK have been disabled by the UART driver. Once the serial console is enabled, clocks are being enabled again, but because earlycon is still waiting for progress, the boot doesn't progress past disabling ip and pclk. It never gets to enabling the serial console (re-enabling the clocks). So in both cases we get some output from earlycon, but the system hangs once the first consumer driver of an IP attached to cmu_peric0 has completed probing. ... If earlycon is not enabled in kernel command line, everything works fine, the kernel buffers its messages and once the real serial console driver starts, all messages since boot are being printed. As requested, add a comment to the code for posterity, so the information is not lost. The patch referenced in the comment can be found at [2]. Link: https://lore.kernel.org/all/d45de3b2bb6b48653842cf1f74e58889ed6783ae.camel@linaro.org/ [1] Link: https://lore.kernel.org/all/20240710-gs101-non-essential-clocks-2-v3-2-5dcb8d040d1c@linaro.org/ [2] Suggested-by: Sam Protsenko Signed-off-by: André Draszik --- drivers/tty/serial/samsung_tty.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- base-commit: 523b23f0bee3014a7a752c9bb9f5c54f0eddae88 change-id: 20240710-samsung_tty-gs101earlycon-417b130df51d Best regards, diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index dc35eb77d2ef..ae2378cfcf84 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -2821,6 +2821,15 @@ static int __init gs101_early_console_setup(struct earlycon_device *device, return s5pv210_early_console_setup(device, opt); } +/* + * Note that for earlycon to work, the respective ipclk and pclk need to be + * running! The bootloader normally leaves them enabled, but the serial + * driver will start handling those clocks before the console driver takes + * over from earlycon, breaking earlycon. If earlycon is required, please + * revert the patch "clk: samsung: gs101: don't mark non-essential (UART) + * clocks critical" locally first to mark them CLK_IS_CRITICAL and avoid this + * problem. + */ OF_EARLYCON_DECLARE(gs101, "google,gs101-uart", gs101_early_console_setup); /* Apple S5L */