Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp133091lqo; Thu, 16 May 2024 01:14:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfIsYmBlfhdRddbWEynwx1+PlFNzHZ6zy7txvfQwK/STJk6qQk7/wmCUn9rUW7rF6xR4KNAOWd1kwhtQCUX9ep3015htPszux5X2NegA== X-Google-Smtp-Source: AGHT+IGovWPFkSdEsv5uON93Wg64V9PJ37TMeYkT43/v5hu6j2gJTFfbW9/7X8KGL7X2v/DGoj1G X-Received: by 2002:a17:90a:2e06:b0:2b2:195a:d7bd with SMTP id 98e67ed59e1d1-2b65f827576mr28860626a91.2.1715847283535; Thu, 16 May 2024 01:14:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715847283; cv=pass; d=google.com; s=arc-20160816; b=D97dXHVym69Xt0cpMtox/gt218CgRxSVPosav8bKYZi0igsVEz43l2M2GWu3atDtuw M9OSqpmTXagA9incKXvWHj9y3cUQ4X+z6QP/CFlojZs57+Pn8rHENJRYW+R5c4h9nN9j QGiBwP2nNizlY/ZYAUtMWz8jOZUcjcCSA0uNAG1YTvGCjpOav4OXGyc25789IPJTH9mY 9iXub6GVIf+8/bsv1P0m84HpZLQTkXewlBXOJWlbP8N31j+2c3u6609Lgn61QnKgBieF kneLpAZLwDQ3Ywg0XzWJMBssxDeHtGuyKvy3s290NOV1+V3lhhnOikC7kE1Ud9SKZc37 emlA== 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=zsebgqL7ME1csjyfoz1MEw6bVhUR+QtHfWqn47Yy6Es=; fh=2BOf/mn0d/zdscwgtxJEJ9q6i3LtHiyapVRJqYd0lkE=; b=p3Hu2sKxQ2q2QhvCEhOXEZkl5KMnenaupUNQopVbSOXggoiHGcazl52dTNIk3gzNyo 5sIrlTi23ohuL//XAaR/y0hxA/7Bbsa/l2T6g5AOVBt1DPZMbBjjFqsJOXyM5n7dAGu6 QG4jPiBYsHdCn7LK68TI5Ao5sTU25AyG7S2iQoOwRkzEbthKtpY+kMhPv5oLatLuPKTY rSOQ/vlZfpBqhzoqkG/1mzLbQ9wZi3Q1mdZ63tgtt9CwsXcJq1JpFWIoYKufisOi+zo5 o9J9x9CWoEo3b8kOtqXdWWgkBIDD7uIqJZU19IQZuzRXDDF517qlwcFuBpLJY/f5UbUZ 00WQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=ZvFoatxb; 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-4198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4198-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628ea7902si133306a91.121.2024.05.16.01.14.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 01:14:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=ZvFoatxb; 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-4198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4198-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 325AA281944 for ; Thu, 16 May 2024 08:14:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F34D112CDBF; Thu, 16 May 2024 08:14:31 +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="ZvFoatxb" 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 B67FD282EF for ; Thu, 16 May 2024 08:14:29 +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=1715847271; cv=none; b=oVe7mQ6TCLkRAevfdtPXG4SvNZM0xlUxijCRkwVMl/4EkzP0fe6bJkS7eAMmo5Efm30psPSffXMYmEotSZC6ZoM+bV7ELtNZ+zHo/gWwB4GQSzM6dCK8b150EayjbxNmJMLkQ5S2WADB5+PZdB996Vl4RyBHqH7UDieHJlfHidU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715847271; c=relaxed/simple; bh=GJYIoxXtm1FJsRPU9W4XdmUkrmPA7ZDe6MUe5OHlrR4=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=SP5AHkPPqeURuuhvxU66rra0S9RdjZOwH0jjCinanNJCS58n2n3Oy39WM8HA6SF4G4XGjzhyx8d6LfxmZZuk4y+r/Fo0AZP47IQfqdWe9C2XhOO9waGBT9YaypqkwIojrcUwbRA2istV5LFamsbtbV8kzNVgNwQDannS3Gjd7m8= 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=ZvFoatxb; 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 (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44G7mxDh002240; Thu, 16 May 2024 10:13:49 +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=zsebgqL7ME1csjyfoz1MEw6bVhUR+QtHfWqn47Yy6Es=; b=Zv Foatxbf8NVvCbuOSQfGXHE1SkqeW9cluSq3uZxNTrpQU/9cAAxkiz0etBZzNTJdt ZB5RzL5nUDpIoelVVCx6DwBGMaO2HiWPcHbclL/niBQzTAKnDBXQj5mnrAbYaocX Q+1aUeL0npOqrQTYpNL70K/TI9VA7j+7kUxmnyMVgukUPr2tnU2jb/6kkoPO1dEB 8T06x96m8xaluiS0oN6NU0kQYw93FS24DuerDIPrAPh6KEEfitSYpLtGW2iMwcuT LWHn2/2mGU6yAC8huIJvlr6gTSTKNiLk9kgVY8EbG2Wky03Lc1pKAsz+cHmyXqmO 8XLdqVjDHkicnZSub0/w== 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 3y4sxvmacv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 May 2024 10:13:49 +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 C96DE4002D; Thu, 16 May 2024 10:13:43 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id F1C53210582; Thu, 16 May 2024 10:12:56 +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 10:12:56 +0200 Message-ID: Date: Thu, 16 May 2024 10:12:55 +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 1/2] hwrng: stm32 - use pm_runtime_resume_and_get() To: Marek Vasut , CC: =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , Alexandre Torgue , Herbert Xu , Maxime Coquelin , Olivia Mackall , Rob Herring , Yang Yingliang , , , References: <20240516012210.128307-1-marex@denx.de> Content-Language: en-US From: Gatien CHEVALLIER In-Reply-To: <20240516012210.128307-1-marex@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_03,2024-05-15_01,2023-05-22_02 On 5/16/24 03:20, Marek Vasut wrote: > include/linux/pm_runtime.h pm_runtime_get_sync() description suggests to > ... consider using pm_runtime_resume_and_get() instead of it, especially > if its return value is checked by the caller, as this is likely to result > in cleaner code. > > This is indeed better, switch to pm_runtime_resume_and_get() which > correctly suspends the device again in case of failure. Also add error > checking into the RNG driver in case pm_runtime_resume_and_get() does > fail, which is currently not done, and it does detect sporadic -EACCES > error return after resume, which would otherwise lead to a hang due to > register access on un-resumed hardware. Now the read simply errors out > and the system does not hang. > > Signed-off-by: Marek Vasut > --- > Cc: "Uwe Kleine-König" > Cc: Alexandre Torgue > Cc: Gatien Chevallier > Cc: Herbert Xu > Cc: Marek Vasut > Cc: Maxime Coquelin > Cc: Olivia Mackall > Cc: Rob Herring > Cc: Yang Yingliang > Cc: kernel@dh-electronics.com > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-crypto@vger.kernel.org > Cc: linux-stm32@st-md-mailman.stormreply.com > --- > drivers/char/hw_random/stm32-rng.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c > index 0e903d6e22e30..6dec4adc49853 100644 > --- a/drivers/char/hw_random/stm32-rng.c > +++ b/drivers/char/hw_random/stm32-rng.c > @@ -187,7 +187,9 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) > int retval = 0, err = 0; > u32 sr; > > - pm_runtime_get_sync((struct device *) priv->rng.priv); > + retval = pm_runtime_resume_and_get((struct device *)priv->rng.priv); > + if (retval) > + return retval; > > if (readl_relaxed(priv->base + RNG_SR) & RNG_SR_SEIS) > stm32_rng_conceal_seed_error(rng); Hi Marek, I'll check in other stm32 drivers as well. Acked-by: Gatien Chevallier Thanks, Gatien