Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2323920lqo; Mon, 13 May 2024 15:04:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/+WXEUr1+xB5Z1p9RfrvBvwwbOsiP5rcI4QVF4d30wgcVisDP91orUcy1rMlsdCXbGEHlqnGoRSywwG1duq0Udc6MuFdRIZmnz0zSHg== X-Google-Smtp-Source: AGHT+IHv4FGgw9wrBs5uS6jlNmoDRf4ECHmBylmlctHdnWnn9LhbMAfHj0RROxwMQv2IRRl+q4y0 X-Received: by 2002:a05:6808:2a89:b0:3c8:2c1c:a39b with SMTP id 5614622812f47-3c997082f06mr13739343b6e.32.1715637857524; Mon, 13 May 2024 15:04:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715637857; cv=pass; d=google.com; s=arc-20160816; b=aGcojLdRpqBV87dSJaonfQp4JVbHY8bpd8WPTMWUPqgzdijFqyfOC7x6nfNppbIsnW TO7pu7GQSFaQM/5CcJXEWjHR0HDUv2nnjJbzWDk7t3vm/5teBAYI5iH6a+w31e2nIAU6 l/PuTp6JNR4+vjyidzv+0ZrdKPh4o8nfhjLmVbZffmnCwBCC5lBkFF3FBAsTWbdR/BRg CDA29AoP9K8nn1m9wcnhheErUoXMOBM+RtzhoWAUccF3ZqExpkqQZWOVshtC78n7bl7M rrymV32RTFn0dhQIvUK5PnhCTu+yyUtDrgunZmJnAqNUF8QDuOYm7gzlXaYCAJn/cGjG Hdvg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=r7aGBuMKfnpQF7IqQKDwqXemymokbgzAAMpCCmuF0v4=; fh=hIluVCADknmmkQvbABgtZfFGHIy+zR0752+osvbitDU=; b=aGHlc2iY2D7E56OMy3RYP1O/vIJbT5Y+DDKtIxCM3tCnsbCvcpOCW1SDZErQYHQEKe O0CRtb8YGN/0xLeO5DgvGX1eRGGoXjpCh5PXxkEcQdvPmrhjVTYi+MB/ZiVculVPvEfn 49x/X+0v68ItfPU+1GCBmkql1Hzu9xoNiNC5t4VD8OO8tvWao0ur8Pz2E63lMy8Mc/Ln L4G4Gzm/qbx+/qGd+eraOXde9VNT+VtAZziG49UIneR3vIOYa27CTRFPxObOSyjCm5qR SGnRTD9HjxFB6PdUjPRXlZ8WqwAQkYSGYpaK1AX6UbqhuwEAkxIEV9TFOHN18NLpCwOn VJTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=omC4OWUq; arc=pass (i=1 spf=pass spfdomain=denx.de dkim=pass dkdomain=denx.de dmarc=pass fromdomain=denx.de); spf=pass (google.com: domain of linux-crypto+bounces-4150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4150-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a1e0cc1a2514c-7f9002e6fb2si1755991241.195.2024.05.13.15.04.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 15:04:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=omC4OWUq; arc=pass (i=1 spf=pass spfdomain=denx.de dkim=pass dkdomain=denx.de dmarc=pass fromdomain=denx.de); spf=pass (google.com: domain of linux-crypto+bounces-4150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4150-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de 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 3C9541C20BA5 for ; Mon, 13 May 2024 22:04:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B3C684A3E; Mon, 13 May 2024 22:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="omC4OWUq" X-Original-To: linux-crypto@vger.kernel.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 C72C580BE3; Mon, 13 May 2024 22:04:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.214.62.61 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715637853; cv=none; b=CMGBK7T+tV062ilMCzoqLhBgTcnKoDcyMye7hbVtAumlCtwnhFIc1EFytYypfju3ItMCmDNYBozqRVV38QyH0mTWORIZbEI/Opzh5YPja/GD1JBBxGuiA/2e9Z6RiBpKJZJJwpo0SdL5SBFdXGD3z4o+7ExEri3MnxEJLDe0bW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715637853; c=relaxed/simple; bh=+5NnhdTqGLgbqRt65aGcxQilFEyt2d+vF5jyJsqWz/8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Zi5SofWGkCpv9M3Yzskgfol3WQ8KgOGmtDaH+oIdv2WjrmPiQJa4p3y+2t+o3aRMqt2SqZix7X97LMAIhuLBolHDnADGw2KskKoMY0YqxVznVxFizNHrA8uJ5jk9PZ0qu0D+ii6DONjyNxq0zPSbbqvVlpqbaHcwYptO4SJw+D0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de; spf=pass smtp.mailfrom=denx.de; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b=omC4OWUq; arc=none smtp.client-ip=85.214.62.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=denx.de Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id F1DE587CDA; Tue, 14 May 2024 00:04:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1715637848; bh=r7aGBuMKfnpQF7IqQKDwqXemymokbgzAAMpCCmuF0v4=; h=From:To:Cc:Subject:Date:From; b=omC4OWUq8OW0Fh1BIO1BB1rG7Ghaa5THWYgXgUqQO7sCYWq6+bfVn2BQKECj49yi0 y7496Llpj0770i2+ShOVs/CoPgq0+WxeaOmreOE9A3OaL7T7AiEwwQcGPDbomY0ji9 RZ+3scgUBYT3DkxpPLpgct9L/dBUnRMpimL72GnNwEyrb/U669A7tf9jnhLC8eBCdN ItFO3LYUyRnSRY8ORmC8qxUzqQ/vay6UpYB1z2B0gfWhwziXYSMKLhWMvH547zMN1y u2qSQ9o0D6aMgXDTcDO3VuJOmaTVRzu85iCScEol2s7SJ4oaX16oWWJzkGRHDrc8U0 vBdZ/XDsOKuzQ== From: Marek Vasut To: linux-crypto@vger.kernel.org Cc: Marek Vasut , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Alexandre Torgue , Gabriel Fernandez , Gatien Chevallier , Herbert Xu , Maxime Coquelin , Michael Turquette , Olivia Mackall , Rob Herring , Stephen Boyd , Yang Yingliang , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH] [RFC] clk: stm32mp1: Keep RNG1 clock always running Date: Tue, 14 May 2024 00:02:28 +0200 Message-ID: <20240513220349.183568-1-marex@denx.de> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean In case of STM32MP15xC/F SoC, in case the RNG1 is enabled in DT, the RNG1 clock are managed by the driver. The RNG1 clock are toggled off on entry to suspend and back on on resume. For reason thus far unknown (could this be some chip issue?), when the system goes through repeated suspend/resume cycles, the system eventually hangs after a few such cycles. This can be reproduced with CONFIG_PM_DEBUG 'pm_test' this way: " echo core > /sys/power/pm_test while true ; do echo mem > /sys/power/state sleep 2 ; done " The system locks up after about a minute and if WDT is active, resets. If the RNG1 clock are kept enabled across suspend/resume, either using this change, or by keeping the clock enabled in RNG driver suspend/resume callbacks, the system does not lock up. NOTE: This patch is a workaround. It would be good to know why does this change make the hang go away, whether this is a chip issue or some other problem ? Signed-off-by: Marek Vasut --- Cc: "Uwe Kleine-König" Cc: Alexandre Torgue Cc: Gabriel Fernandez Cc: Gatien Chevallier Cc: Herbert Xu Cc: Maxime Coquelin Cc: Michael Turquette Cc: Olivia Mackall Cc: Rob Herring Cc: Stephen Boyd Cc: Yang Yingliang Cc: linux-arm-kernel@lists.infradead.org Cc: linux-clk@vger.kernel.org Cc: linux-crypto@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com --- drivers/char/hw_random/stm32-rng.c | 2 ++ drivers/clk/stm32/clk-stm32mp1.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c index 7d0de8ab5e7f5..ec0314f05ff3e 100644 --- a/drivers/char/hw_random/stm32-rng.c +++ b/drivers/char/hw_random/stm32-rng.c @@ -403,6 +403,7 @@ static int __maybe_unused stm32_rng_suspend(struct device *dev) writel_relaxed(priv->pm_conf.cr, priv->base + RNG_CR); + // Keeping the clock enabled across suspend/resume helps too clk_disable_unprepare(priv->clk); return 0; @@ -434,6 +435,7 @@ static int __maybe_unused stm32_rng_resume(struct device *dev) int err; u32 reg; + // Keeping the clock enabled across suspend/resume helps too err = clk_prepare_enable(priv->clk); if (err) return err; diff --git a/drivers/clk/stm32/clk-stm32mp1.c b/drivers/clk/stm32/clk-stm32mp1.c index 7e2337297402a..1a6e853d935fa 100644 --- a/drivers/clk/stm32/clk-stm32mp1.c +++ b/drivers/clk/stm32/clk-stm32mp1.c @@ -2000,7 +2000,7 @@ static const struct clock_config stm32mp1_clock_cfg[] = { KCLK(SDMMC3_K, "sdmmc3_k", sdmmc3_src, 0, G_SDMMC3, M_SDMMC3), KCLK(FMC_K, "fmc_k", fmc_src, 0, G_FMC, M_FMC), KCLK(QSPI_K, "qspi_k", qspi_src, 0, G_QSPI, M_QSPI), - KCLK(RNG1_K, "rng1_k", rng_src, 0, G_RNG1, M_RNG1), + KCLK(RNG1_K, "rng1_k", rng_src, CLK_IS_CRITICAL, G_RNG1, M_RNG1), KCLK(RNG2_K, "rng2_k", rng_src, 0, G_RNG2, M_RNG2), KCLK(USBPHY_K, "usbphy_k", usbphy_src, 0, G_USBPHY, M_USBPHY), KCLK(STGEN_K, "stgen_k", stgen_src, CLK_IS_CRITICAL, G_STGEN, M_STGEN), -- 2.43.0