Message ID | 20240127003607.501086-6-andre.draszik@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-40944-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2395:b0:106:343:edcb with SMTP id gw21csp236957dyb; Fri, 26 Jan 2024 16:38:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpQ8p0DhBPGwUCqA4IaNPuHlQ9BN1r90qviCrH8oop/9wB+oslc7nB6Vq3U37XYvZi7VQ4 X-Received: by 2002:a05:620a:40d1:b0:783:69a7:3da with SMTP id g17-20020a05620a40d100b0078369a703damr733044qko.51.1706315934510; Fri, 26 Jan 2024 16:38:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706315934; cv=pass; d=google.com; s=arc-20160816; b=VabNhXgr8B2t8swCM1bR6VzLUwpZkwCAG1+FnpPGlFJQMdsCXFHRBYgYyGImNzlx2g fKxfslICs5hWE1dTXrlJZ92fhCX73gkPQC3BXdSxHYUM3+ypNbnWQ0WxiNKf/EEk9wqj /QvBzMCajcjymKtHaKeyL09juC5Wqwc+jhXHu2nKHL+4fGgl1tzzonteKWzG/Y0GFfwY JhrJ+knA1R7n2c0EUZiJS7HpWMorP107XUJRsSBSVU086vAYxFL6zQ1tC4oQ1kvYHxOe V3gadOKE/FFoHAwfwOz6VhatDioARDvyMkXfBlXBfTt7k8xku7AElpzgPP2PIs15gS40 eVfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=3UWKLkucSe2Xo64gIFBssH+CIGBcy5ZlP0k7ni0x+YY=; fh=WrhIizNXy+YZmlhXQ3CjStW2Q+f/L9mPBsAa/xOhbRk=; b=axIjz0EDlowiRHqL5m34qFwgQGJE9s/PhX/Uug2UkOZy4cpFHYIj7A+R5reoUXFiHW +1n9dgfdIjy0LhHJkmtmy810AGgCi8zuXPVxtts7KXD/zml/vzCBiblCVYkDTxT8J7A6 P6JaKPjv2J9gGu0zm/i9O4Npvr9RdJlgR9SMujMvGqEMjYnMt6iCvE0/3TiUKJUrcLQo kJaNtYapN6JsfRe4k3Dy94HL8v6CRz3RQIEEbANdObpXWNjx5GgmCpe+fPwues0II/JL 9wYVa+mN0Yz/jbAg0SMobDuwRGKAjaa4+KOMm9Lyj2+d7GCjJcw3yuyhWE7XneEN0JvL /Y1g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lTrpy+zU; 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-40944-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40944-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m3-20020a05620a290300b007839273251bsi2805076qkp.322.2024.01.26.16.38.54 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 16:38:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40944-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lTrpy+zU; 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-40944-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40944-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 40EBD1C22636 for <ouuuleilei@gmail.com>; Sat, 27 Jan 2024 00:38:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5372A125A2; Sat, 27 Jan 2024 00:37:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lTrpy+zU" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 E433220FB for <linux-kernel@vger.kernel.org>; Sat, 27 Jan 2024 00:37:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706315832; cv=none; b=bELHa94VpwO7B21rRM81ZqmQ1PTFdbRWI1njPcvKH0lSDfdOTfx99WK0xJldYWl6ny6wLvZ8BuUBSu7dnpp3+AOtp3bcYn/PmXqyLiIOi6j4+nQnWxbjb6TByPAncZQk9PyOYAX7GlZvVQ3+KC90JJNzmVCBqDZYiDOg7Kk/xKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706315832; c=relaxed/simple; bh=26vfIBZ6/FeUBNB7UQejl5tGj/Q2g9dqknKuLgD78Lc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NZg2sqVm4MSIAanbID88Mq1WQX7vxd/2In7PIFylF+1T490k1Keh8QXG5f7oNX0ottjvDKxtnqspx5V3Rv3xBWRZQEC0mDiuq4/pmt4HcsSKjOAz5AwGxmpacFD40f5p03qm4vBkktLVSKCk7IRdWIzjFLpaqSbD0F0krqTT2JY= 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=lTrpy+zU; arc=none smtp.client-ip=209.85.218.53 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-ej1-f53.google.com with SMTP id a640c23a62f3a-a2f79e79f0cso81814166b.2 for <linux-kernel@vger.kernel.org>; Fri, 26 Jan 2024 16:37:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706315827; x=1706920627; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3UWKLkucSe2Xo64gIFBssH+CIGBcy5ZlP0k7ni0x+YY=; b=lTrpy+zUzBcVmE1uFNFdJ0FqZsBvb2YOwicCRyMyqn7sRxkuTE9NFOWAttOO8sWjcm 8B/w1rFU6rTpPbcfgVKqdMi/jT2BsGzoxJVXrqm6q6xu8SrIknM/CSVSr5Cr8wO7S9ZP laQfLTANWr2sTcIJG1pXZHJOa0d/eYDcTxM5gj7SfYORcevO7jar0VA3tcEipfev5nqG ezJEU0guTgrMycCHo91o5SmKIC3jhMJdhaKjcvD7YwvzwafP0LgjC82BeGSATL+m780I AynL3yUIjBsiTdAMcZbmGlhd8Df+34BOnzTtOmeMlGD4Ku2ILzBPXzmtFw2793B5qrOn Gxqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706315827; x=1706920627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3UWKLkucSe2Xo64gIFBssH+CIGBcy5ZlP0k7ni0x+YY=; b=kkrpF0MMlZDM7dHqDGD/DlIltY1uTPXCrRiuSDlaAekQvuPuvPIiUKhjs21WAFTw1/ qeFu/DQu1AO0elNIsLrR62RonXAB+p2ILpeYoOfMTW9vmRmYYiMd157bsLEeQXfx7S3Q QZ05aexzHl7tvD4eY+a4YcKZJD0MTk28oz4EhnLZrWGsK3RvGW8XdcvER+Svf549qQM6 H47QnCsF6QHbeyPtLy7xPSGm7s0eynTODW0dx0gCy8nU+8AMbjSEwRyzI9ieWgoQ89lW o5n+L+p1DdbsFBhJXsBvOfE7YMsaT98RY+6ZzEsm95zPWAoWPRkC83ZpwFJcw6+hKP2d p63Q== X-Gm-Message-State: AOJu0YwyOVIBLAIXhSFBmd4CHq0yhQIMlp6mrtIpo8jE1Yj2zAbgBv5W dvdRVi5kHcmrU0Hoi9K+gx2bUnZzbkW4hSBttWotPdzbz+BHNHIFKdVysqSX3Cw= X-Received: by 2002:a17:907:1006:b0:a35:2841:2ab7 with SMTP id ox6-20020a170907100600b00a3528412ab7mr227213ejb.39.1706315827009; Fri, 26 Jan 2024 16:37:07 -0800 (PST) Received: from puffmais.c.googlers.com.com (229.112.91.34.bc.googleusercontent.com. [34.91.112.229]) by smtp.gmail.com with ESMTPSA id vi1-20020a170907d40100b00a2f48a43c3esm1152235ejc.7.2024.01.26.16.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 16:37:06 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= <andre.draszik@linaro.org> To: peter.griffin@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, tudor.ambarus@linaro.org, willmcvicker@google.com, semen.protsenko@linaro.org, alim.akhtar@samsung.com, s.nawrocki@samsung.com, tomasz.figa@gmail.com, cw00.choi@samsung.com, mturquette@baylibre.com, sboyd@kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical Date: Sat, 27 Jan 2024 00:35:54 +0000 Message-ID: <20240127003607.501086-6-andre.draszik@linaro.org> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog In-Reply-To: <20240127003607.501086-1-andre.draszik@linaro.org> References: <20240127003607.501086-1-andre.draszik@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789201937195351272 X-GMAIL-MSGID: 1789201937195351272 |
Series |
[1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on
|
|
Commit Message
André Draszik
Jan. 27, 2024, 12:35 a.m. UTC
The peric0_top1_ipclk_0 and peric0_top1_pclk_0 are the clocks going to
peric0/uart_usi, with pclk being the bus clock. Without pclk running,
any bus access will hang.
Unfortunately, in commit d97b6c902a40 ("arm64: dts: exynos: gs101:
update USI UART to use peric0 clocks") the gs101 DT ended up specifying
an incorrect pclkk in the respective node and instead the two clocks
here were marked as critical.
We have fixed the gs101 DT and can therefore drop this incorrect
work-around here, the uart driver will claim these clocks as needed.
Note that this commit has the side-effect of 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
* hand-over between earlycon and serial driver appears to be
fragile and clocks get enabled and disabled a few times, which
also causes register access to hang while earlycon is still
active
Nonetheless we shouldn't keep these clocks running unconditionally just
for earlycon. Clocks should be disabled where possible. If earlycon is
required in the future, e.g. for debug, this commit can simply be
reverted (locally!).
Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0")
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
drivers/clk/samsung/clk-gs101.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
Comments
On Sat, 2024-01-27 at 00:35 +0000, André Draszik wrote: > The peric0_top1_ipclk_0 and peric0_top1_pclk_0 are the clocks going to > peric0/uart_usi, with pclk being the bus clock. Without pclk running, > any bus access will hang. > Unfortunately, in commit d97b6c902a40 ("arm64: dts: exynos: gs101: > update USI UART to use peric0 clocks") the gs101 DT ended up specifying > an incorrect pclkk in the respective node and instead the two clocks ^^^^^ 'pclk', I'll send a v2 after collecting any other potential feedback. Cheers, Andre'
On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote: > > The peric0_top1_ipclk_0 and peric0_top1_pclk_0 are the clocks going to > peric0/uart_usi, with pclk being the bus clock. Without pclk running, > any bus access will hang. Empty line is missing here? > Unfortunately, in commit d97b6c902a40 ("arm64: dts: exynos: gs101: > update USI UART to use peric0 clocks") the gs101 DT ended up specifying > an incorrect pclkk in the respective node and instead the two clocks > here were marked as critical. > > We have fixed the gs101 DT and can therefore drop this incorrect > work-around here, the uart driver will claim these clocks as needed. > > Note that this commit has the side-effect of 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 That's weird. Doesn't your bootloader setup serial clocks properly? AFAIU, earlycon should rely on everything already configured in bootloader. > * hand-over between earlycon and serial driver appears to be > fragile and clocks get enabled and disabled a few times, which > also causes register access to hang while earlycon is still > active > Nonetheless we shouldn't keep these clocks running unconditionally just > for earlycon. Clocks should be disabled where possible. If earlycon is > required in the future, e.g. for debug, this commit can simply be > reverted (locally!). That sounds... not ideal. The ability to enable earlycon just by adding some string to bootargs can be very useful for developers. Maybe just make those clocks CLK_IGNORE_UNUSED, if that keeps earlycon functional? With corresponding comments of course. > > Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0") > Signed-off-by: André Draszik <andre.draszik@linaro.org> > --- > drivers/clk/samsung/clk-gs101.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/clk/samsung/clk-gs101.c b/drivers/clk/samsung/clk-gs101.c > index 61bb0dcf84ee..5c338ac9231c 100644 > --- a/drivers/clk/samsung/clk-gs101.c > +++ b/drivers/clk/samsung/clk-gs101.c > @@ -2982,20 +2982,18 @@ static const struct samsung_gate_clock peric0_gate_clks[] __initconst = { > "gout_peric0_peric0_top0_pclk_9", "mout_peric0_bus_user", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_PCLK_9, > 21, 0, 0), > - /* Disabling this clock makes the system hang. Mark the clock as critical. */ > GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0, > "gout_peric0_peric0_top1_ipclk_0", "dout_peric0_usi0_uart", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_0, > - 21, CLK_IS_CRITICAL, 0), > + 21, 0, 0), > GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_2, > "gout_peric0_peric0_top1_ipclk_2", "dout_peric0_usi14_usi", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_2, > 21, 0, 0), > - /* Disabling this clock makes the system hang. Mark the clock as critical. */ > GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0, > "gout_peric0_peric0_top1_pclk_0", "mout_peric0_bus_user", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_0, > - 21, CLK_IS_CRITICAL, 0), > + 21, 0, 0), > GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_2, > "gout_peric0_peric0_top1_pclk_2", "mout_peric0_bus_user", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_2, > -- > 2.43.0.429.g432eaa2c6b-goog >
Hi Sam, On Fri, 2024-01-26 at 21:30 -0600, Sam Protsenko wrote: > On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote: > > > > > Note that this commit has the side-effect of 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 > > That's weird. Doesn't your bootloader setup serial clocks properly? > AFAIU, earlycon should rely on everything already configured in > bootloader. I tried to explain that above, but let me try again... 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. > > * hand-over between earlycon and serial driver appears to be > > fragile and clocks get enabled and disabled a few times, which > > also causes register access to hang while earlycon is still > > active > > Nonetheless we shouldn't keep these clocks running unconditionally just > > for earlycon. Clocks should be disabled where possible. If earlycon is > > required in the future, e.g. for debug, this commit can simply be > > reverted (locally!). > > That sounds... not ideal. The ability to enable earlycon just by > adding some string to bootargs can be very useful for developers. > Maybe just make those clocks CLK_IGNORE_UNUSED, if that keeps earlycon > functional? With corresponding comments of course. CLK_IGNORE_UNUSED doesn't help in this case, the i2c and uart drivers will load and probe before earlycon gets disabled and as part of their probing disable the cmu_top ip clock going to cmu_peric0 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. Other than keeping it as CLK_IS_CRITICAL, there is no way that I can see to way to make the hand-over from earlycon to the real serial driver work in all cases. They are not critical clocks for the system, though, so it's wrong to always keep them running unconditionally. We are past a stage where earlycon is generally required. If it's required for some local development, people can revert this patch locally. BTW, downstream doesn't suffer from this problem because downstream uses ACG throughout and clocks are enabled automatically in hardware as required. Cheers, Andre'
On 1/27/24 00:35, André Draszik wrote: > The peric0_top1_ipclk_0 and peric0_top1_pclk_0 are the clocks going to > peric0/uart_usi, with pclk being the bus clock. Without pclk running, > any bus access will hang. > Unfortunately, in commit d97b6c902a40 ("arm64: dts: exynos: gs101: > update USI UART to use peric0 clocks") the gs101 DT ended up specifying > an incorrect pclkk in the respective node and instead the two clocks > here were marked as critical. > > We have fixed the gs101 DT and can therefore drop this incorrect > work-around here, the uart driver will claim these clocks as needed. > > Note that this commit has the side-effect of 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 > * hand-over between earlycon and serial driver appears to be > fragile and clocks get enabled and disabled a few times, which > also causes register access to hang while earlycon is still > active > Nonetheless we shouldn't keep these clocks running unconditionally just > for earlycon. Clocks should be disabled where possible. If earlycon is > required in the future, e.g. for debug, this commit can simply be > reverted (locally!). > > Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0") > Signed-off-by: André Draszik <andre.draszik@linaro.org> I find the logic fine: Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org> > --- > drivers/clk/samsung/clk-gs101.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/clk/samsung/clk-gs101.c b/drivers/clk/samsung/clk-gs101.c > index 61bb0dcf84ee..5c338ac9231c 100644 > --- a/drivers/clk/samsung/clk-gs101.c > +++ b/drivers/clk/samsung/clk-gs101.c > @@ -2982,20 +2982,18 @@ static const struct samsung_gate_clock peric0_gate_clks[] __initconst = { > "gout_peric0_peric0_top0_pclk_9", "mout_peric0_bus_user", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_PCLK_9, > 21, 0, 0), > - /* Disabling this clock makes the system hang. Mark the clock as critical. */ > GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0, > "gout_peric0_peric0_top1_ipclk_0", "dout_peric0_usi0_uart", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_0, > - 21, CLK_IS_CRITICAL, 0), > + 21, 0, 0), > GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_2, > "gout_peric0_peric0_top1_ipclk_2", "dout_peric0_usi14_usi", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_2, > 21, 0, 0), > - /* Disabling this clock makes the system hang. Mark the clock as critical. */ > GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0, > "gout_peric0_peric0_top1_pclk_0", "mout_peric0_bus_user", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_0, > - 21, CLK_IS_CRITICAL, 0), > + 21, 0, 0), > GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_2, > "gout_peric0_peric0_top1_pclk_2", "mout_peric0_bus_user", > CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_2,
On Mon, Jan 29, 2024 at 8:37 AM André Draszik <andre.draszik@linaro.org> wrote: > > Hi Sam, > > On Fri, 2024-01-26 at 21:30 -0600, Sam Protsenko wrote: > > On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote: > > > > > > > > Note that this commit has the side-effect of 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 > > > > That's weird. Doesn't your bootloader setup serial clocks properly? > > AFAIU, earlycon should rely on everything already configured in > > bootloader. > > I tried to explain that above, but let me try again... > > 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. > > > > > > * hand-over between earlycon and serial driver appears to be > > > fragile and clocks get enabled and disabled a few times, which > > > also causes register access to hang while earlycon is still > > > active > > > Nonetheless we shouldn't keep these clocks running unconditionally just > > > for earlycon. Clocks should be disabled where possible. If earlycon is > > > required in the future, e.g. for debug, this commit can simply be > > > reverted (locally!). > > > > That sounds... not ideal. The ability to enable earlycon just by > > adding some string to bootargs can be very useful for developers. > > Maybe just make those clocks CLK_IGNORE_UNUSED, if that keeps earlycon > > functional? With corresponding comments of course. > > CLK_IGNORE_UNUSED doesn't help in this case, the i2c and uart drivers will load > and probe before earlycon gets disabled and as part of their probing disable > the cmu_top ip clock going to cmu_peric0 > > 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. > > Other than keeping it as CLK_IS_CRITICAL, there is no way that I can see to > way to make the hand-over from earlycon to the real serial driver work in > all cases. > > They are not critical clocks for the system, though, so it's wrong to always > keep them running unconditionally. > > We are past a stage where earlycon is generally required. > > If it's required for some local development, people can revert this patch locally. > That sounds reasonable. But I wonder if that bit (about making this clock CLK_IS_CRITICAL to make earlycon functional) can be documented somewhere. Perhaps in the serial driver (earlycon function), or somewhere in device tree bindings? Because otherwise it might remain an arcane knowledge and people won't be able to use earlycon later. Anyways, for this patch: Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> and if you think it makes sense to document the bit above, please do. > > BTW, downstream doesn't suffer from this problem because downstream uses ACG > throughout and clocks are enabled automatically in hardware as required. > Yes, using QCH clocks (HWACG) seems like a correct way to fix this, and would be nice to have otherwise. Alas, it doesn't seems very easy to implement, and should probably be based on top of regular clock driver anyway. I thought about it for a while, but never came up with particular ideas on how to implement HWACG support in Samsung CCF framework properly. > > Cheers, > Andre' >
On Mon, 2024-01-29 at 13:16 -0600, Sam Protsenko wrote: > That sounds reasonable. But I wonder if that bit (about making this > clock CLK_IS_CRITICAL to make earlycon functional) can be documented > somewhere. Perhaps in the serial driver (earlycon function), or > somewhere in device tree bindings? Because otherwise it might remain > an arcane knowledge and people won't be able to use earlycon later. > Anyways, for this patch: > > Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> > > and if you think it makes sense to document the bit above, please do. Will do on top of https://lore.kernel.org/all/20240119104526.1221243-6-tudor.ambarus@linaro.org/ once that is in. Cheers, Andre'
On 1/30/24 09:31, André Draszik wrote: > On Mon, 2024-01-29 at 13:16 -0600, Sam Protsenko wrote: >> That sounds reasonable. But I wonder if that bit (about making this >> clock CLK_IS_CRITICAL to make earlycon functional) can be documented >> somewhere. Perhaps in the serial driver (earlycon function), or >> somewhere in device tree bindings? Because otherwise it might remain >> an arcane knowledge and people won't be able to use earlycon later. >> Anyways, for this patch: >> >> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> >> >> and if you think it makes sense to document the bit above, please do. > > Will do on top of > https://lore.kernel.org/all/20240119104526.1221243-6-tudor.ambarus@linaro.org/ > once that is in. > It was applied, it's in linux-next. I like the dt bindings idea, it's the first thing I check when dealing with new hardware. No idea though how to add comments just for a specific compatible. Shall be a description somewhere...
diff --git a/drivers/clk/samsung/clk-gs101.c b/drivers/clk/samsung/clk-gs101.c index 61bb0dcf84ee..5c338ac9231c 100644 --- a/drivers/clk/samsung/clk-gs101.c +++ b/drivers/clk/samsung/clk-gs101.c @@ -2982,20 +2982,18 @@ static const struct samsung_gate_clock peric0_gate_clks[] __initconst = { "gout_peric0_peric0_top0_pclk_9", "mout_peric0_bus_user", CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_PCLK_9, 21, 0, 0), - /* Disabling this clock makes the system hang. Mark the clock as critical. */ GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0, "gout_peric0_peric0_top1_ipclk_0", "dout_peric0_usi0_uart", CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_0, - 21, CLK_IS_CRITICAL, 0), + 21, 0, 0), GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_2, "gout_peric0_peric0_top1_ipclk_2", "dout_peric0_usi14_usi", CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_2, 21, 0, 0), - /* Disabling this clock makes the system hang. Mark the clock as critical. */ GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0, "gout_peric0_peric0_top1_pclk_0", "mout_peric0_bus_user", CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_0, - 21, CLK_IS_CRITICAL, 0), + 21, 0, 0), GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_2, "gout_peric0_peric0_top1_pclk_2", "mout_peric0_bus_user", CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_2,