Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp333063lqo; Thu, 16 May 2024 07:37:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhwe2Sh7CpMEVuqm/3L1zzI2sxZ9TIPJ5xAkQvMbs/oYn2ihDIEWS7CEQ/bN+sEZSb+AeoGBFJQQG82ZTWLEo9TVrXFLtuLcKlTBn0vw== X-Google-Smtp-Source: AGHT+IFD0SrNdczCcASYkXnAeKmypv4NtYcgJFH3oJTYcm6GI3rJ6J+KMwZvnnHgFzt4y0qAPSgJ X-Received: by 2002:a17:902:728f:b0:1eb:538e:6c6e with SMTP id d9443c01a7336-1ef43e25fbamr183576075ad.33.1715870251370; Thu, 16 May 2024 07:37:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715870251; cv=pass; d=google.com; s=arc-20160816; b=kVGlfiS+tfwiHc06lQh9d3/nz9rvLtbeX+XN3IEQeJtECuIp4V9HsghSM+eOj0tkLy OoSIeCCjyau7ENyxcF0P2U6LiIAuJnOOJoYHNEGDrO4BhdHiihYVzYF68H+Z9+sdf5A7 16A1ziAoNjiG739RjV9SJX52G0GALKLtVC7215qJhvL+OCt0Y2bVvM2s3ZGdxNjPHGy6 DlM18kYiveuABrbb1TQe2vCmEYlfsy1Gr3qpIRgbKzhmTjoXqWCvNbBBIzCK4panp/Is Bx8fSTKeRYXmgLYm5XS1ZlyP2t47WqF89YB8znXXomMlnFclMVJes4Jw+ZUX53Fne9Ox DAxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=3ZOCADbz3OwcSrpGlTG7JoHBwcrSFGYRtD/O02Jz6P8=; fh=GjGMYrM16PYM7ibCZzzvGOOfyn/O11XYrbQ+qLRYArs=; b=cuy/AUaj53PPOKJDMOYalC5dflipr9JasYFGsVu3fi0gHAjmeTsJu84gDELGCOQ20U NR059gqf1kxgXlELwlOQjDUK7+Jv0JQ1O7HOjMY4mtJVmVG3RCyDCq/0qEU6Hc5WD84w t4fLLsYnfeR7xosCmuC0kSxr3sh+0OBWfywDlzbaMfcTxv4tKkP1W7jI/Z3adaGBtixy NUnUR4a+Ypvl22qQ1eYQ6xv9Eszx9QDxKIXCuqPULPX62aMf06rNqVJK/1nJhDEFIUfI zE092Tc3DwZ7DomUvtMWytxYxsEcEjlYWiib2oC+WKo3i8q0613hLLuqRcODfGFDBpj8 vBtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=TMtep9Ft; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-crypto+bounces-4210-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4210-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0b9cfaddsi167570885ad.130.2024.05.16.07.37.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 07:37:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4210-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=TMtep9Ft; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-crypto+bounces-4210-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4210-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6BA96284953 for ; Thu, 16 May 2024 14:37:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26FD214B953; Thu, 16 May 2024 14:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="TMtep9Ft" X-Original-To: linux-crypto@vger.kernel.org Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1D1B1DFEF; Thu, 16 May 2024 14:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.207.212.93 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715870246; cv=none; b=cgGQfaYJtaTTgUgIbQh3reb1SkfuscaPie3bdfuf6LPEPGJMC/YYM3bYWmlFp4vFevdY5/4x3dua0TGFNHgb4jynBWnjA5jMqFSXIM6Z+L6AbHA8zfUHheii9H5XEDpJRcBM8+qVxGARmjxxui5TTaha2HclGXMoxdbe2wttpHo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715870246; c=relaxed/simple; bh=o1gMEjFi/WHr2qKAmFjmxfC7395/RL7/fXI1xGCNG40=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=APd87ve+uvWbeqOyXxrdtmc7wjjh5EXnNk2vH7rfRqhO/41ZDT9hMoG4xPqGZ1I6rX26pg7sMWrG4/mexsAQmKeOQh8Vm1nP/aEaRvNhgD56Ccziy5zJ7Y4gMP73DV6/0yZCpw/Hsrw91nvtK7NI16J4O7LXBcbrL1c8f6ZynvM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=TMtep9Ft; arc=none smtp.client-ip=91.207.212.93 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44GDhYKP005402; Thu, 16 May 2024 16:36:34 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= selector1; bh=3ZOCADbz3OwcSrpGlTG7JoHBwcrSFGYRtD/O02Jz6P8=; b=TM tep9Ft/091Dsf51h3LVxZejBEVKw8E43mdTVikDAwUvcwfA3C869shJ+MPBV36gh bi+N2PWjTaJkMfPfCX3MiKzDca+F8z8/AzKXgf2SmB602osq3OL59phinPzZZcBb tNV7LcgAHv8OZS1xV121KFrxr+ArV5nf6DHBK3J1sOn0bVU+kBaU/+8Bgq79gcLo ESnJnh1l37xWfKU00ErNSC1+Ih8J+GhuFaZGX10U2DWI1stwjyNnViYsXv8XdsQI u3cEBtCaxAkFA7czVIiPoPRMNXolYIuEF7ugpAjpp/tqZWNffHAk3zKE61kR1jZm lVMAavVlaMBbbwDfFhLg== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3y4symdu0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 May 2024 16:36:34 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 8DC5940044; Thu, 16 May 2024 16:36:26 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 894BD220B76; Thu, 16 May 2024 16:35:29 +0200 (CEST) Received: from [10.48.87.204] (10.48.87.204) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 16 May 2024 16:35:28 +0200 Message-ID: Date: Thu, 16 May 2024 16:35:28 +0200 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [RFC] clk: stm32mp1: Keep RNG1 clock always running To: Marek Vasut , CC: =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , Alexandre Torgue , Gabriel Fernandez , Herbert Xu , Maxime Coquelin , Michael Turquette , Olivia Mackall , Rob Herring , Stephen Boyd , Yang Yingliang , , , References: <20240513220349.183568-1-marex@denx.de> <51951dd4-8e8c-4e67-89f6-6a710022e34f@foss.st.com> <3257e8f8-5bb0-4c75-a3a3-e5685b65de2a@denx.de> <5b39b5b6-7008-4362-a578-3faab87cd23b@foss.st.com> <2eb2b80e-8650-46cf-9d8f-6dd6a884558a@denx.de> Content-Language: en-US From: Gatien CHEVALLIER In-Reply-To: <2eb2b80e-8650-46cf-9d8f-6dd6a884558a@denx.de> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SHFCAS1NODE2.st.com (10.75.129.73) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-16_07,2024-05-15_01,2023-05-22_02 On 5/16/24 12:43, Marek Vasut wrote: > On 5/16/24 9:42 AM, Gatien CHEVALLIER wrote: > > Hi, > >>>>>> What if you add a trace in a random generation function in random.c? >>>>> >>>>> Do you have a function name or line number for me ? >>>> >>>> I put a trace in _get_random_bytes() in drivers/char/random.c. I'm not >>>> 100% sure but this should be the entry point when getting a random >>>> number. >>> >>> You're right, there is a read attempt right before the hang, and >>> __clk_is_enabled() returns 0 in stm32_read_rng() . In fact, it is the >>> pm_runtime_get_sync() which is returning -EACCES instead of zero, and >>> this is currently not checked so the failure is not detected before >>> register access takes place, to register file with clock disabled, >>> which triggers a hard hang. >>> >>> I'll be sending a patch shortly, thanks for this hint ! >>> >> >> Great news, indeed the return code isn't checked. Let's use >> pm_runtime_resume_and_get(). > > Yes please. > > I will wonder why we get EACCES though, that basically means we are > suspending already. Is it safe to return -errno from rng read function > in that case ? The framework expects a function that can return an error code so I don't see why not. Else the framework would have an issue. I still haven't figured out what is happening. Could it be that the kernel is getting entropy with hwrng_fillfn() like it does periodically to feed the entropy pool and it happens at the same time as your pm test sequence? FYI, I have been running your script with (echo devices > /sys/power/pm_test) for 5 hours now and haven't been able to reproduce the issue. > >>>>>> After this, I'll try to reproduce the issue. >>>>> >>>>> If you have a minute to test it on some ST MP15 board, that would >>>>> be real nice. Thanks ! >>>> >>>> I tried to reproduce the issue you're facing on a STM32MP157C-DK2 no >>>> SCMI on the 6.9-rc7 kernel tag. I uses OP-TEE and TF-A in the bootchain >>>> but this should not have an impact here. >>>> >>>> How did you manage to test using "echo core > /sys/power/pm_test"? >>>> In kernel/power/suspend.c, enter_state(). If the pm_test_level is core, >>>> then an error is fired with the following trace: >>>> "Unsupported test mode for suspend to idle, please choose >>>> none/freezer/devices/platform." >>> >>> Could this be firmware related ? >>> >>>> I've tried using "echo devices > /sys/power/pm_test" so that I can >>>> at least test that the driver is put to sleep then wakes up. I do not >>>> reproduce your issue. >>> >>> Can you try 'processors' ? >>> >> >> Given this: >> #ifdef CONFIG_PM_DEBUG >>          if (pm_test_level != TEST_NONE && pm_test_level <= TEST_CPUS) { >>              pr_warn("Unsupported test mode for suspend to idle > > You're supposed to be suspending to 'mem' , not 'idle' . Could that be it ? Yes you're right, I've been missing that. I do not have "deep" available in /sys/power/mem_sleep... not upstreamed yet maybe... Have you coded a PSCI service for this in U-Boot? I'm either missing something or I can't reproduce your setup. Thanks, Gatien