Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp126441iof; Sun, 5 Jun 2022 23:09:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynAmaJzGA7HYDZvKGFDQNWnPidE/ot1ewAlTsE/3JC1PWfCpmhoqZ19gSGTFz+h20tk5MV X-Received: by 2002:a05:6a00:2291:b0:51b:e4c5:627 with SMTP id f17-20020a056a00229100b0051be4c50627mr14694658pfe.20.1654495763409; Sun, 05 Jun 2022 23:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654495763; cv=none; d=google.com; s=arc-20160816; b=B0ZDc2OdcRylqj4mQeP/QK2cPaRUjt8DW2gKmtIZLwNC3ZcrWr6UJ4gsuJls4Qt4wz SU+FFmXAnNcTB2C5sB3rYKZ70fEddSoduBnaaexbdNIzGc3nbJLUVBkcPPnqT431zANx haucGc03+TRyQYkqy8zjaFQ4vdPrSHHLbHeYE+EDPTdO2Jijnft+T1uiaa+F8iE41QbI X6YFYIDc6FDodcB1iOWWkfkrNuJmWhxqeHekCAI4a+BHkb8lQ4CcKQq15NeWr/b9CV5G 10wWy3D9JJzhjJ3DWv+xzeV6Jur/gk7+3iJBdxnDJmJ9DORch08e4HJmTpokQVQSs6GS qhIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KkVNQXqC4j753deo5BPeaTFHyUiPYwf88R5FNkeXs8o=; b=aPy+8xBeVWvYA0VDt5VnBkDtsFg1JbnWAC6P7tnJdHcqssGHAHNXVnH8X/BRpIyJLF gx3ixyQF8b9EMG4EaWDN7/N7u2V4OO0KbmC4cevxHgjxrfajsQimZcMyCPl2W9ANWCg8 d1r5I8E8et1yrtcPYlKKt01SrxwCeekLzoPM5Vx0U8JxgJJIIJ6gn0Dar0jgGxlbvvvg P/8eRTr3sAh97w6y+WdEUb4zsVaZ73eX4bKe87k0MLRo1XjMe+aHAJDurFhdvD0ObnfQ giD0vjKhIR753R2IrYiIM34d6HOQtKw333SUbSXiBmG/bHj9TLoupVMvyg8KdNVM4mWQ C0Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CIqgM5bz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j3-20020a170903028300b0015d56a3c9d0si25601889plr.534.2022.06.05.23.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 23:09:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CIqgM5bz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B4AE4F45D0; Sun, 5 Jun 2022 22:00:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348230AbiFCSQb (ORCPT + 99 others); Fri, 3 Jun 2022 14:16:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238830AbiFCSEz (ORCPT ); Fri, 3 Jun 2022 14:04:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CE2A57111; Fri, 3 Jun 2022 10:58:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1C080B8241D; Fri, 3 Jun 2022 17:57:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BB87C385A9; Fri, 3 Jun 2022 17:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654279027; bh=tSQXz/ZFbI2pYTh4TigjjrPwJuuXCKdaX9A7q3dypck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CIqgM5bzOWqa5VptNCzQD9VdXr45N0olLKqaLNocTIOjNiB5rq6sSiMWCntiJ63Gv 0t5f6Nh2t+FjF4/QWuJdJVA4dAJXuDcgo9GmERTksHIhDuPA1PQDlqQhz07O+zr/Z8 Ko8USy7XCVE1K8lmrZG0L0luQUeEboqpkbL8G7m0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabio Estevam , =?UTF-8?q?Horia=20Geant=C4=83?= , Vabhav Sharma , Gaurav Jain , Herbert Xu Subject: [PATCH 5.18 29/67] crypto: caam - fix i.MX6SX entropy delay value Date: Fri, 3 Jun 2022 19:43:30 +0200 Message-Id: <20220603173821.563313170@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173820.731531504@linuxfoundation.org> References: <20220603173820.731531504@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabio Estevam commit 4ee4cdad368a26de3967f2975806a9ee2fa245df upstream. Since commit 358ba762d9f1 ("crypto: caam - enable prediction resistance in HRWNG") the following CAAM errors can be seen on i.MX6SX: caam_jr 2101000.jr: 20003c5b: CCB: desc idx 60: RNG: Hardware error hwrng: no data available This error is due to an incorrect entropy delay for i.MX6SX. Fix it by increasing the minimum entropy delay for i.MX6SX as done in U-Boot: https://patchwork.ozlabs.org/project/uboot/patch/20220415111049.2565744-1-gaurav.jain@nxp.com/ As explained in the U-Boot patch: "RNG self tests are run to determine the correct entropy delay. Such tests are executed with different voltages and temperatures to identify the worst case value for the entropy delay. For i.MX6SX, it was determined that after adding a margin value of 1000 the minimum entropy delay should be at least 12000." Cc: Fixes: 358ba762d9f1 ("crypto: caam - enable prediction resistance in HRWNG") Signed-off-by: Fabio Estevam Reviewed-by: Horia Geantă Reviewed-by: Vabhav Sharma Reviewed-by: Gaurav Jain Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/caam/ctrl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -609,6 +609,13 @@ static bool check_version(struct fsl_mc_ } #endif +static bool needs_entropy_delay_adjustment(void) +{ + if (of_machine_is_compatible("fsl,imx6sx")) + return true; + return false; +} + /* Probe routine for CAAM top (controller) level */ static int caam_probe(struct platform_device *pdev) { @@ -855,6 +862,8 @@ static int caam_probe(struct platform_de * Also, if a handle was instantiated, do not change * the TRNG parameters. */ + if (needs_entropy_delay_adjustment()) + ent_delay = 12000; if (!(ctrlpriv->rng4_sh_init || inst_handles)) { dev_info(dev, "Entropy delay = %u\n", @@ -871,6 +880,15 @@ static int caam_probe(struct platform_de */ ret = instantiate_rng(dev, inst_handles, gen_sk); + /* + * Entropy delay is determined via TRNG characterization. + * TRNG characterization is run across different voltages + * and temperatures. + * If worst case value for ent_dly is identified, + * the loop can be skipped for that platform. + */ + if (needs_entropy_delay_adjustment()) + break; if (ret == -EAGAIN) /* * if here, the loop will rerun,