Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2660972rwb; Mon, 19 Sep 2022 08:11:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jE2Q2ALfUa6/vqjQB4tRMbnsDTgtrtM/8yxwkGkab+FYGwgmOTjGiRmTJxkYW7XBszAOz X-Received: by 2002:a05:6402:5110:b0:450:c196:d7b1 with SMTP id m16-20020a056402511000b00450c196d7b1mr15849360edd.117.1663600277257; Mon, 19 Sep 2022 08:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663600277; cv=none; d=google.com; s=arc-20160816; b=V/zsaFAr4Gnk9orYfCfMjaMsP1rYxS2snlgzvaGmUdHKfo03OKJuEemH2DLUu2uhk+ CGJWKXHPrwguilWtG8jlvOtMJS4gwngAxm31jSY9iVwEBk/qOIYGFVNJvAPBgCSXs45P 4HXKVpKIkJySEvNWAF9QB2GIVd2/+ovmE8Js4dgnqT6Kfl8AujSUUo9kpnzJDHeqXmL3 6ScJQpWnS/Vkv40NAhNxDxa8ihf46K9gfJ/+VvSsUdhzfRR0eINaWs+Mx7ugFz/y2QOK CGjzbbBD1cIKAedsifhfu0ByqDmWUsILxlTTyww7oBRlGvsjq3jmCZ2uILEIuq9zwGF9 NGxg== 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=29Q13qvIrzikJw/fUgHdsSOAwHmgeU1WfwREQ1Cge1Y=; b=w7CdcGCGcJGEo0beeiGzmPIohz46Rau/ONmAnawiXAZ+b11mw/qIm34ISWxKeQUyav QvagBAexm63y6c/Y8uksXn2uBS+HRhnxobypjelIlxNtbuDfvY9Uy7YbtrtWMg6/d4G0 ysITOFLSAAV5b+audCfrg+GTucrR8UlFP5r3J5AowNLK6GnMxY4q5w/eR97nRoIFip50 icP+Erzvr1/Qf7JNYbX6TV3kcbOWeYQJ7B82/VwV/83gxdcjUopEzv8bqRkXujUzaqxo DCw4OfAPuuMlh4epOTXzvubYgCDTij0Jc8xPpgqnlbGQEA/9O6u8EZzIubEMcRrxRZGB rPmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lwxdIbe5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a056402511100b0043c8f3fe2ebsi11638543edd.74.2022.09.19.08.10.51; Mon, 19 Sep 2022 08:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@chromium.org header.s=google header.b=lwxdIbe5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbiISPDi (ORCPT + 99 others); Mon, 19 Sep 2022 11:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbiISPDa (ORCPT ); Mon, 19 Sep 2022 11:03:30 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E0F533A0D for ; Mon, 19 Sep 2022 08:03:27 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id a8so47330434lff.13 for ; Mon, 19 Sep 2022 08:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=29Q13qvIrzikJw/fUgHdsSOAwHmgeU1WfwREQ1Cge1Y=; b=lwxdIbe5BjxF0HFPnwF9Ofpvu0luMg35Ct6ff/AF8HWxyNhmnKGYXO+mANg2sK0aRp zDmKcO1OJAa/tYrxnxzBvTsVbyoz/6hGfgwWltTQlppuEsv2vmOuV0C99/+dJ3qo1nuD nT6doWb23QqnDbH824dGANTgN7MsuOFdOTvQQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=29Q13qvIrzikJw/fUgHdsSOAwHmgeU1WfwREQ1Cge1Y=; b=dIcOoey9bbXsmlXm4NqP60TGl1iJTCc8XR3jaJ7966HtcIEkNZ8zXeB7dIJ6qV71q4 ko9js22rkkThZFNGkFxZChNg9ZK3KEgfsRhb+GClMQ+YAHiycDd2PJTyJnL5vzOkpTfK VTgzoBBnHw8hJKGsTAH6aHMvHaHWiJzcMWTYZtUmpIcXcwt9kJa09MYkgQFuLlREyA1/ AyADTbFiKOUy7oRufdjA7pNzb2C8F7g4594Ilz7Ng2wjaE369ShmtNdintd+hX75kzcT I1pWk/IRbOiToXZXnwR4QS/L+S25VwPAz06B6gxG6jVsN/hUhpLk2Cimfvba+sKsk3St hQBQ== X-Gm-Message-State: ACrzQf2PEJVN7mUXLCIozBiozRQTvGuSd1IpXmluEL8Cxbnj9nFR0Iik cy6KKlwRPexyQ+H9NJzjgzerGTzPB5qt2Q== X-Received: by 2002:a05:6512:2384:b0:497:ad1c:799 with SMTP id c4-20020a056512238400b00497ad1c0799mr6230382lfv.294.1663599805195; Mon, 19 Sep 2022 08:03:25 -0700 (PDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id s4-20020a056512202400b0049ad315cfc3sm4615078lfs.162.2022.09.19.08.03.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Sep 2022 08:03:23 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id q17so20300760lji.11 for ; Mon, 19 Sep 2022 08:03:23 -0700 (PDT) X-Received: by 2002:a05:651c:17a7:b0:261:c0b1:574b with SMTP id bn39-20020a05651c17a700b00261c0b1574bmr5541662ljb.40.1663599802963; Mon, 19 Sep 2022 08:03:22 -0700 (PDT) MIME-Version: 1.0 References: <20220915002235.v2.1.I7c0a79e9b3c52584f5b637fde5f1d6f807605806@changeid> In-Reply-To: From: Sven van Ashbrook Date: Mon, 19 Sep 2022 11:03:11 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] random: move add_hwgenerator_randomness()'s wait outside function To: Dominik Brodowski , Peter Huewe , Jarkko Sakkinen Cc: LKML , Herbert Xu , Olivia Mackall , Alex Levin , Andrey Pronin , "Jason A. Donenfeld" , 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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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-kernel@vger.kernel.org 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