Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2654948rwb; Mon, 19 Sep 2022 08:07:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tDPl5RoqGmr5CUuozlA3X5kbXj9IU1xtA9ngYzkwWpCMai5XsEJ6p3BEN6ypOQb9zGIVy X-Received: by 2002:a17:907:743:b0:740:ef93:2ffc with SMTP id xc3-20020a170907074300b00740ef932ffcmr13154744ejb.514.1663600023932; Mon, 19 Sep 2022 08:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663600023; cv=none; d=google.com; s=arc-20160816; b=JqoAZf8YKZB/9qLeMqFMbj7D+lhblCO+T+hpYtyfxoC/WOey76ieIpVjIb5yBg+c4n rnLJ1k3U7mm9n6hJSbE2xy85qNbeGDijHIWccUMQ/lNQo0foWOKhveeSq8erRJwBnLb5 U5FfB8ghVzNAZbRePHmlqI/wz7wXfuir7RaoXJqdXis9S9vq71Xww1RTDSQejLtlC4vg 2dgJqsAEbb01gIBCnj1fcbKu/Oq+fYU4vVxjR2AGd26xFOuB2UMGBo2p+CKtyOYAT+rG 320uIMioLJDytFdbo6H1qrq/IeLvLVwsrD6yBRjucTzcAD4YUnc0DFQDBvjoRui7lxnW e2Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zKkl3xs4dw9Lj94MomA5+nV3PBnjgpv2vQC+E9dtRb0=; b=uMU5YGt75ncrGVlOWcWndM7bytPUPf4iLWrCX/d9OfNgEWyNYGmlyg8gSTKvf0NCmX dSbzeZJ8DGriynBJ1sM0ixpnf3AHStSmf/AOk9Gk9qs98l3wCschF9foM3wPP25v84TS 7E9drW6Ez5GU5fShC2AylbSwrP7JUrFJCnZ10JbvH55bawKz93D3QsOme+UUwiqkZqnq cTyVAZU8iW8Htaausy7elZiU2TZbfWsO1/Dr10fVfJUcvgKXNMjfbOTkIao31ESMdVut ZmcsJW6tKlxW+0Ul+26pByeZ5UNfDVnZ5bRwASG18W1mMzRjlaySDdRzaXJ7AJbvYgA3 f0UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=DTemwdZG; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz2-20020a1709072ce200b007806964b2fcsi10710260ejc.447.2022.09.19.08.06.26; Mon, 19 Sep 2022 08:07:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=DTemwdZG; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229560AbiISPGK (ORCPT + 99 others); Mon, 19 Sep 2022 11:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbiISPGJ (ORCPT ); Mon, 19 Sep 2022 11:06:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 406632A244; Mon, 19 Sep 2022 08:06:05 -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 7FC94B81C88; Mon, 19 Sep 2022 15:06:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8740C43140; Mon, 19 Sep 2022 15:06:01 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="DTemwdZG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1663599957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zKkl3xs4dw9Lj94MomA5+nV3PBnjgpv2vQC+E9dtRb0=; b=DTemwdZG2NWKTArNvqDEty4lsvTYPeqccgWfm4uOUcZdI+X5XgGDhxRw3fcLxHsuDmRYzP +aAo9H2Ej6mPRpJSwdttRXAnDa+6IIZruvUJmY5vlKmyFCGQ38akyEPaHP6udMZRUOr7MW Vx3at90n9QEQke9/wFxdNDHJ/838lzc= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id c802ce19 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 19 Sep 2022 15:05:56 +0000 (UTC) Received: by mail-vs1-f46.google.com with SMTP id h1so30193492vsr.11; Mon, 19 Sep 2022 08:05:56 -0700 (PDT) X-Gm-Message-State: ACrzQf0yA3cJtP0Lo7RM67yJNzqdQcVgN6s2/j3bVEgE52wmVp/ZWDpd jXhu8j9v25nBv9niwwzk0BS2eWwLS7NLdAgafaA= X-Received: by 2002:a67:e401:0:b0:398:89f1:492f with SMTP id d1-20020a67e401000000b0039889f1492fmr6927638vsf.21.1663599954306; Mon, 19 Sep 2022 08:05:54 -0700 (PDT) MIME-Version: 1.0 References: <20220915002235.v2.1.I7c0a79e9b3c52584f5b637fde5f1d6f807605806@changeid> In-Reply-To: From: "Jason A. Donenfeld" Date: Mon, 19 Sep 2022 17:05:41 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] random: move add_hwgenerator_randomness()'s wait outside function To: Sven van Ashbrook Cc: Dominik Brodowski , Peter Huewe , Jarkko Sakkinen , LKML , Herbert Xu , Olivia Mackall , Alex Levin , Andrey Pronin , Stephen Boyd , Rajat Jain , Eric Biggers , Petr Mladek , Sebastian Andrzej Siewior , "Theodore Ts'o" , linux-crypto@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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-crypto@vger.kernel.org On Mon, Sep 19, 2022 at 5:03 PM Sven van Ashbrook wrote: > > On Fri, Sep 16, 2022 at 10:51 AM Jason A. Donenfeld wrote: > > > > The other thing that occurred to me when reading this patch in context > > of the other one is that this sleep you're removing here is not the > > only sleep in the call chain. Each hwrng driver can also sleep, and > > many do, sometimes for a long time, blocking until there's data > > available, which might happen after minutes in some cases. So maybe > > that's something to think about in context of this patchset -- that > > just moving this to a delayed worker might not actually fix the issue > > you're having with sleeps. > > > > This is an excellent point. A look at tpm2_calc_ordinal_duration() > reveals that tpm_transmit() may block for 300s at a time. So when > we are using a WQ_FREEZABLE delayed_work, the PM may have to wait > for up to 300s when draining the wq on suspend. That will introduce > a lot of breakage in suspend/resume. > > Dominik: in light of this, please proceed with your patch, without > rebasing it onto mine. > > + tpm maintainers Peter Huewe and Jarkko Sakkinen, a quick recap of > the problem: > > - on ChromeOS we are seeing intermittent suspend/resume errors+warnings > related to activity of the core's hwrng_fillfn. this kthread keeps > runningduring suspend/resume. if this happens to kick off an bus (i2c) > transaction while the bus driver is in suspend, this triggers > a "Transfer while suspended" warning from the i2c core, followed by > an error return: > > i2c_designware i2c_designware.1: Transfer while suspended > tpm tpm0: i2c transfer failed (attempt 1/3): -108 > [ snip 10s of transfer failed attempts] > > - in 2019, Stephen Boyd made an attempt at fixing this by making the > hwrng_fillfn kthread freezable. But a freezable thread requires > different API calls for scheduling, waiting, and timeout. This > generated regressions, so the solution had to be reverted. > > https://patchwork.kernel.org/project/linux-crypto/patch/20190805233241.220521-1-swboyd@chromium.org/ > > - the current patch attempts to halt hwrng_fillfn during suspend by > converting it to a self-rearming delayed_work. The PM drains all > work before going into suspend. But, the potential minute-long > blocking delays in tpm make this solution infeasible. > > Peter and Jarkko, can you think of a possible way forward to eliminate > the warnings+errors? > > -Sven By the way, there was a recent ath9k patch that kind of went to a similar tune. The solution was to make ath9k's hwrng driver sleep using a hwrng-specific sleep function that allowed the core framework to cancel that sleep. Maybe that's a potential solution here, or something similar to it. Might be worth taking a look at that patch. I think it's in one of Herbert's trees. Jason