From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06BD7C43334 for ; Mon, 4 Jul 2022 22:04:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233381AbiGDWEw (ORCPT ); Mon, 4 Jul 2022 18:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbiGDWEu (ORCPT ); Mon, 4 Jul 2022 18:04:50 -0400 Received: from mail.toke.dk (mail.toke.dk [IPv6:2a0c:4d80:42:2001::664]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCBBE266C; Mon, 4 Jul 2022 15:04:48 -0700 (PDT) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1656972287; bh=IGiBHguNm0JhMDuYYUOhaSJP4Atb4sExjleMTY3V9ew=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=mDS/Tg0OxqatuII1EkZ9+DcicKi2FIYR9gYQMH4vj0uaJ1G4zK/JpyR07EtvHnojj pif0Is6VYbanO43ONdNRSb9HRaok6cHW2n0R1q+h29GFyJTG4HgUGpIf5MH7HU1aOi Pc8a1z9sxH7q2+Pk8kDzJkNhDFrHg4DA9W8lH/9aVhYLjO0ywn0dEfvy5j4CavVPZX tIvBtECKQdej3zt2P/EeRVyvJstjBdEZTaCifSI5W13HOpPSlt3SUY61Eed31AtcBH CAjnKAfHb0bk1cFFO0pQn8Pxm6AGdHS5NlbTr0tOrfecXoASTnwDUNiRGtmpw0pY68 FxabSybILZxQA== To: "Jason A. Donenfeld" , Herbert Xu , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Cc: Gregory Erwin , Kalle Valo , Rui Salvaterra , stable@vger.kernel.org Subject: Re: [PATCH v8] ath9k: let sleep be interrupted when unregistering hwrng In-Reply-To: <20220629114240.946411-1-Jason@zx2c4.com> References: <20220629114240.946411-1-Jason@zx2c4.com> Date: Tue, 05 Jul 2022 00:04:46 +0200 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <874jzw8rgh.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org "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, and > hwrng_unregister() is called. When the deadlock is hit, sleep is delayed > 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() while > 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 dumpin= g into random.c") > Link: https://lore.kernel.org/all/CAO+Okf6ZJC5-nTE_EJUGQtd8JiCkiEHytGgDsF= GTEjs0c00giw@mail.gmail.com/ > Link: https://lore.kernel.org/lkml/CAO+Okf5k+C+SE6pMVfPf-d8MfVPVq4PO7EY8H= ys_DVXtent3HA@mail.gmail.com/ > Link: https://bugs.archlinux.org/task/75138 > Signed-off-by: Jason A. Donenfeld With the change to EXPORT_SYMBOL_GPL() for wake_up_state that Kalle has kindly agreed to fix up while applying: Acked-by: Toke H=C3=B8iland-J=C3=B8rgensen