Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3237861imw; Mon, 11 Jul 2022 04:58:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sQv6Z9VpH7zSxV/IdKGa2+3A0XENUqX3+TkQIW31YeT/mIbeS6bpDjl0fJPFcqtXe1EArY X-Received: by 2002:a17:906:149:b0:711:fca6:bc2f with SMTP id 9-20020a170906014900b00711fca6bc2fmr17931918ejh.497.1657540716300; Mon, 11 Jul 2022 04:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657540716; cv=none; d=google.com; s=arc-20160816; b=bzWdZSRv3GrDXTu9e8az1j7aXBUc4pHXRnpDztPxwHWdvA1MpBpjRY9s7dnnNQQKIx aKk9fF8U3lqnJnx9XWKhH22UANsOASOjdUx7HtuiT9GSsksP6p9FBpfJtTqnujC9tXq6 UY/um4dr9BPYfeiwp1BgcebZmjoInnpVp5bc6IP7ZujfGO3TyZ/VpI1eEYjdMIkOvHBI pLJ97+Sd8sTa4S2v+9K7Xx6vOWzxm9+5ztz5+TaDxG1Yien5oOKtbdOIZN/VWwnDAQZB Z55tM/00Ah6B2sY6Hc9GU9mr+zAfjwAXAiRdpO5FAPl+lQPrQrBNldUAfXREN5sG2Kp8 hZ/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature; bh=720mTc1nsSAPrwWFG+973FguSUx8/hicJxk0ef4PlVU=; b=wY2BgbP6HU88rTtFp68RMXJ1rGRwb0j5DCR3CWlhlkWQiLTNV7WBOOQ4xkwenzk46g 38BGMuB3HzCXdS+QSytKQGQW7mGex2Tv+Ie2uq16KLgrdZUuDMucFewY0VW9MAYJf86r uYXkzQdoRAMQVsxudA3dq6wayPDZ2n+aFzbZKhdTgj6mwkOPGyLsajerlXTIg1k0/mQn T0iityWvI8lgaAGuB4kxpOKfYNBo61HcnbTD49svy42OnrNcAClPaLc2Udq90HaLr7m3 L1DWLZaET8twN9CpfhgNoAvSDAwxvKIOVX5CR/wh90lhXYy+YLmMcpMI64w1yNeQOX+N SgGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=MzCw4sK9; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 gn36-20020a1709070d2400b007156d6e22c3si15324520ejc.473.2022.07.11.04.58.18; Mon, 11 Jul 2022 04:58:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=MzCw4sK9; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 S231211AbiGKLyQ (ORCPT + 64 others); Mon, 11 Jul 2022 07:54:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbiGKLyA (ORCPT ); Mon, 11 Jul 2022 07:54:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2DA5275C8; Mon, 11 Jul 2022 04:53:39 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 5C7866114C; Mon, 11 Jul 2022 11:53:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D45EC341CD; Mon, 11 Jul 2022 11:53:38 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="MzCw4sK9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1657540414; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=720mTc1nsSAPrwWFG+973FguSUx8/hicJxk0ef4PlVU=; b=MzCw4sK9qZsQsPPK1O23afqypc3QjfcYtfDr5Phr3bgH0rLukZ9+znNizqsFlom/dF4uHM 4soBx2Yc2m42FPOdZLdHkwPe3k/XNSU4S8HNZlpaf7wFGsuXqBlhq4YjM4rCHDXACMn6jy KlLcwb0nbtXoBZIEdZBZhRwd3TtXWlw= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id f0912a61 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Mon, 11 Jul 2022 11:53:34 +0000 (UTC) Received: by mail-il1-f169.google.com with SMTP id v1so2847305ilg.11; Mon, 11 Jul 2022 04:53:34 -0700 (PDT) X-Gm-Message-State: AJIora9GZFVJ2OWd16ug+6eNkIayYvS4lF7xxZPYUPmBgAPuZX1PaIai 68cSfPGyYKN1aD9xo4VjkKga5jxNO6lSme3ko5w= X-Received: by 2002:a05:6e02:164f:b0:2dc:6d38:ff8e with SMTP id v15-20020a056e02164f00b002dc6d38ff8emr5606184ilu.16.1657540412032; Mon, 11 Jul 2022 04:53:32 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6e02:20e5:0:0:0:0 with HTTP; Mon, 11 Jul 2022 04:53:31 -0700 (PDT) In-Reply-To: References: <20220629114240.946411-1-Jason@zx2c4.com> <87v8s8ubws.fsf@kernel.org> From: "Jason A. Donenfeld" Date: Mon, 11 Jul 2022 13:53:31 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8] ath9k: let sleep be interrupted when unregistering hwrng To: Valentin Schneider Cc: Kalle Valo , Herbert Xu , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, Gregory Erwin , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , Rui Salvaterra , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Christian Brauner , linux-crypto@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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,T_SCC_BODY_TEXT_LINE 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-wireless@vger.kernel.org Hi Valentin, On 7/11/22, Valentin Schneider wrote: > On 07/07/22 19:26, Kalle Valo wrote: >> "Jason A. Donenfeld" writes: >> >>> There are two deadlock scenarios that need addressing, which cause >>> problems when the computer goes to sleep, the interface is set down, an= d >>> hwrng_unregister() is called. When the deadlock is hit, sleep is delaye= d >>> for tens of seconds, causing it to fail. These scenarios are: >>> >>> 1) The hwrng kthread can't be stopped while it's sleeping, because it >>> uses msleep_interruptible() instead of >>> schedule_timeout_interruptible(). >>> The fix is a simple moving to the correct function. At the same time= , >>> we should cleanup a common and useless dmesg splat in the same area. >>> >>> 2) A normal user thread can't be interrupted by hwrng_unregister() whil= e >>> it's sleeping, because hwrng_unregister() is called from elsewhere. >>> The solution here is to keep track of which thread is currently >>> reading, and asleep, and signal that thread when it's time to >>> unregister. There's a bit of book keeping required to prevent >>> lifetime issues on current. >>> >>> Reported-by: Gregory Erwin >>> Cc: Toke H=C3=B8iland-J=C3=B8rgensen >>> Cc: Kalle Valo >>> Cc: Rui Salvaterra >>> Cc: Herbert Xu >>> Cc: stable@vger.kernel.org >>> Fixes: fcd09c90c3c5 ("ath9k: use hw_random API instead of directly >>> dumping into random.c") >>> Link: >>> https://lore.kernel.org/all/CAO+Okf6ZJC5-nTE_EJUGQtd8JiCkiEHytGgDsFGTEj= s0c00giw@mail.gmail.com/ >>> Link: >>> https://lore.kernel.org/lkml/CAO+Okf5k+C+SE6pMVfPf-d8MfVPVq4PO7EY8Hys_D= VXtent3HA@mail.gmail.com/ >>> Link: https://bugs.archlinux.org/task/75138 >>> Signed-off-by: Jason A. Donenfeld >>> --- >>> Changes v7->v8: >>> - Add a missing export_symbol. >>> >>> drivers/char/hw_random/core.c | 30 ++++++++++++++++++++++++---- >>> drivers/net/wireless/ath/ath9k/rng.c | 19 +++++++----------- >>> kernel/sched/core.c | 1 + >>> 3 files changed, 34 insertions(+), 16 deletions(-) >> >> I don't see any acks for the hw_random and the scheduler change, adding >> more >> people to CC. Full patch here: >> >> https://patchwork.kernel.org/project/linux-wireless/patch/20220629114240= .946411-1-Jason@zx2c4.com/ >> >> Are everyone ok if I take this patch via wireless-next? >> > > Thanks for the Cc. > > I'm not hot on the export of wake_up_state(), IMO any wakeup with > !(state & TASK_NORMAL) should be reserved to kernel internals. Now, here > IIUC the problem is that the patch uses an inline invoking > > wake_up_state(p, TASK_INTERRUPTIBLE) > > so this isn't playing with any 'exotic' task state, thus it shouldn't > actually need the export. > > I've been trying to figure out if this could work with just a > wake_up_process(), but the sleeping pattern here is not very conforming > (cf. 'wait loop' pattern in sched/core.c), AFAICT the signal is used to > circumvent that :/ I don't intend to work on this patch more. If you'd like to ack the trivial scheduler change (adding EXPORT_SYMBOL), that'd help, and then this can move forward as planned. Otherwise, if you have particular opinions about this patch that you want to happen, feel free to pick up the patch and send your own revisions (though I don't intend to do further review). Alternatively, I'll just send a patch to remove the driver entirely. Hopefully you do find this ack-able, though. Jason