Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp411486lqt; Thu, 18 Apr 2024 22:02:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCULgbguRI10oIj8jLxL/IVFoe+ntbLKwfHMJzMOXFAsfUvAhMCw09ctdMK3456IijN4LjKS+xJ8p7VesViuW7A6uLZBgeV9p7L8W9T42g== X-Google-Smtp-Source: AGHT+IHi4RJS4U+vbJ4YJWfrirCjBSGtsdqxP6Ypxnn213s9JaicNXRDmDhC/f/qu1cc/Q/+ideu X-Received: by 2002:a0c:c212:0:b0:69f:5269:d594 with SMTP id l18-20020a0cc212000000b0069f5269d594mr1092602qvh.4.1713502978125; Thu, 18 Apr 2024 22:02:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713502978; cv=pass; d=google.com; s=arc-20160816; b=yHm/Wx9pR1fmEFFhR1C8mqJG58IVAQv1bsxeVuZUeEgSAtlPkx7fx8r56fbwrmw6MG rn6mXyO8VECYEDUDA7DWG8sss/5OTrAmoKaoKkPcuqc+/fFvhkHpmXBASrhuX8fX9u5y xHlHf+i/Ze6JBpZNesnZCEbr0aQv4pbX2oJbb2h3v3D1WkL15ZU8C8aHY7GSHUjjVxAI 1kSfUSUqL7NphnHgwJ+AnijuzbFFCHox0loOrwDcVzF62as4cGqZQVfSuAtsaH1QQaAg O6I+uYjXMIvst7gRtwEcusyneL6p/clZXdddoqMo7XmdILNTue74WLMBTJ3zR2Gpu2GF 7znA== 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=N8/EA3hDMebRjyBpAuXzGXG8aRiiHl6ioFyyZFh37vA=; fh=yT/1B276qWXj1dSLqqEKiMaTwSYIInkftguVP37bbiQ=; b=qqJSpxBhyqJ0A5ScaUPjdBVNtibmNsjac7tM4ab1/2tJyGxSamHtJWFhv5jSYZYztJ UJvIYxP1zUyQij+fRN30ebQ8t8WkuUL7+MkPwE103b+WYNSlA3uVaJUY5DBkT1Iz1Iwl fJLcWLu0wD9Uq8aZsSRhqAVz4Gg9Y0tkRVXvdCWuEzh7mF+cNAaeFH/sfjXelLiY1dJG WfOUwzmL5w06u/pbMc8A+yRVQmac3quXJf4QfyXQKxgmU4I/IXwhp42vSb8e4X7fNpz0 UwiGZ7eALXbPrun0H0FuCiijNS/3Te70CHZ/SpRiOwjUvDSYhEffCtwUQ1aQ63URNxSU UN1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=SLFL6bgx; 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-3690-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3690-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. [147.75.199.223]) by mx.google.com with ESMTPS id ke14-20020a056214300e00b0069b56f0e477si3121689qvb.27.2024.04.18.22.02.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 22:02:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3690-linux.lists.archive=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=@denx.de header.s=phobos-20191101 header.b=SLFL6bgx; 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-3690-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3690-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 453641C224EC for ; Fri, 19 Apr 2024 05:02:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D615C8F5B; Fri, 19 Apr 2024 05:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="SLFL6bgx" 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 C45D7C8DD for ; Fri, 19 Apr 2024 05:02:45 +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=1713502969; cv=none; b=ZzGv/VT1bTA3lCaz+eo5AOMlYdyjh2igRc8vgnCH7r7PlRW50Qlxiba9COPLT+zRZ+nhiO5ELKlcyfZ3mu98sjOOjYs0bW7n5XXlsQvkDgrIfqEdLmZaLfId0bkFeO1dbt2Js/T/isFR1cb23B7GiyHTbxDWgCpbQH+ERWwEyfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713502969; c=relaxed/simple; bh=u8NwNL1SHVvTlbkB6aviZs3CqGvTcDMVga3X7X1929A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QVEdzRKv5x+KI2TVfsd9Ie8WWxtGM63QcqPcqDb7fBfgtfoJMEOJZMRU688Whhn7XlOyRyT3+uyOIm4J1lG6rgePI93VoEBphnrn3cvMyrUf+0uCe6Mtj+9v5FQTWxV/kXq4Aw+f9JtB1SgWSFyjAswlXndDgjbr9Z1eZKwQRuw= 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=SLFL6bgx; 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 025A288629; Fri, 19 Apr 2024 07:02:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1713502963; bh=N8/EA3hDMebRjyBpAuXzGXG8aRiiHl6ioFyyZFh37vA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SLFL6bgxwDc6dhg4rCLT0ldEAeOVv9qTHjcms1mdX6MRdriGgh+6ok37zMH9mwHVO ++/SqflUc+q9vLZVx0G5pI149VR8Jn/0OHzQQHAJDlCzg/RZxJaNiVJwUMaryKR+On RYYe1Q3CYAAF2QM1kZw+7B3PrhIT0bTTZmos4Y1AB7h1yf1Km4jBe0r3JU3DKnluAp 6C0uNpCv8Pu85btZAsGFIoAHHUnOybqN0JLjEyvu5k6tJcRRuTYJDTt4RSps1VERNR rRWBTuzqRhRV2hmr5+KkQ7Hi6RQpIRtdotE4HowZ8kEmTkhC84QouRIRvvIRTgnMQP wA3eiSUOfx0EQ== From: Marek Vasut To: linux-crypto@vger.kernel.org Cc: Marek Vasut , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Alexandre Torgue , Gatien Chevallier , Herbert Xu , Maxime Coquelin , Olivia Mackall , Rob Herring , Yang Yingliang , kernel@dh-electronics.com, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH 2/3] hwrng: stm32 - put IP into RPM suspend on failure Date: Fri, 19 Apr 2024 07:01:13 +0200 Message-ID: <20240419050201.181041-2-marex@denx.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240419050201.181041-1-marex@denx.de> References: <20240419050201.181041-1-marex@denx.de> 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 an irrecoverable failure, put the IP into RPM suspend to avoid RPM imbalance. I did not trigger this case, but it seems it should be done based on reading the code. Fixes: b17bc6eb7c2b ("hwrng: stm32 - rework error handling in stm32_rng_read()") Signed-off-by: Marek Vasut --- Cc: "Uwe Kleine-König" Cc: Alexandre Torgue Cc: Gatien Chevallier Cc: Herbert Xu 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c index 1cc61ef8ee54c..b6182f86d8a4b 100644 --- a/drivers/char/hw_random/stm32-rng.c +++ b/drivers/char/hw_random/stm32-rng.c @@ -220,7 +220,8 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) if (err && i > RNG_NB_RECOVER_TRIES) { dev_err((struct device *)priv->rng.priv, "Couldn't recover from seed error\n"); - return -ENOTRECOVERABLE; + retval = -ENOTRECOVERABLE; + goto exit_rpm; } continue; @@ -238,7 +239,8 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) if (err && i > RNG_NB_RECOVER_TRIES) { dev_err((struct device *)priv->rng.priv, "Couldn't recover from seed error"); - return -ENOTRECOVERABLE; + retval = -ENOTRECOVERABLE; + goto exit_rpm; } continue; @@ -250,6 +252,7 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) max -= sizeof(u32); } +exit_rpm: pm_runtime_mark_last_busy((struct device *) priv->rng.priv); pm_runtime_put_sync_autosuspend((struct device *) priv->rng.priv); -- 2.43.0