Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp958585pxb; Tue, 14 Sep 2021 12:34:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/t1oZJj1ba7ckrFmLlaGn9Abr2X92FozJwoPAhiPGq/rE+uXeBD+Me/+fHxnX2LiIZ5x1 X-Received: by 2002:a05:6638:1491:: with SMTP id j17mr15822238jak.75.1631648085118; Tue, 14 Sep 2021 12:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631648085; cv=none; d=google.com; s=arc-20160816; b=tXcqVZLDpIUlhvMHOW+jv/OPTpY/848mkhqo3Kh4msXyN5JSH9r5grKPf+KYJmAFCV VIH+qnTTYheOmk2ibWlreytSB4+7U33oOoqiq8YeRvuHu3M94JRYO/1UNZYoxl/5YkZa BAi4WhTyYpqCWaw75rdIurB+V+2x3arico/042zRcCSePOl0/0iw7rmxh+E8JVPWHHsV s05wn1+veaUyvDXPxtEljAILRirDut+0kzKPligJBxm6OFZaNWb5L6zW+otOuf5QDumJ FoygcZ3i/B51cn35mw+NuxoVhsXyl0Vgwpw1Scc/BV5adYdJGjN3FvK+vL0/cMkkzYXD 7NIg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FH9Bf5Z5jKmzaUtPo1IAodISLJGI/7ubrTstJ+ZXW50=; b=FFq0SU8M/+T9F3mX8ql3UH8sCkbHMa2spCAJfCafWj7UYCL2WjTlDLvAS9kftYBg98 Sep+00Jt/nxSRJA+XBkETWJeirODi3w05+m1DO3yAeaRuHfLHt7bL6V41IUmKtmVu0V8 IZc2qKufZhu6+19tRib370Wjy7daFDR+DqlcSCWBZDrfYZj9BTZrtNWG7mpQS153Meow J5r5LCM/uoQ5UTCSLYoBqjF/kL8xQT4lWPoY/pMkxnN3IrFo+NY6CGzwQTi5yq/95Kjc WKY4KiB5tL0idpwW2FUXIpNGaDh9BaA1DXtqqWvR2IpqkOrB4riCG1UgqCKr1QZoOyro K1oA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si10649718ilh.21.2021.09.14.12.34.32; Tue, 14 Sep 2021 12:34:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233456AbhINTfC (ORCPT + 99 others); Tue, 14 Sep 2021 15:35:02 -0400 Received: from mail.aperture-lab.de ([116.203.183.178]:44930 "EHLO mail.aperture-lab.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232113AbhINTey (ORCPT ); Tue, 14 Sep 2021 15:34:54 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D4D2641015; Tue, 14 Sep 2021 21:25:34 +0200 (CEST) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: Kalle Valo , Felix Fietkau , Sujith Manoharan , ath9k-devel@qca.qualcomm.com Cc: linux-wireless@vger.kernel.org, "David S . Miller" , Jakub Kicinski , "John W . Linville" , Felix Fietkau , Simon Wunderlich , Sven Eckelmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Linus=20L=C3=BCssing?= , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH 3/3] ath9k: Fix potential hw interrupt resume during reset Date: Tue, 14 Sep 2021 21:25:15 +0200 Message-Id: <20210914192515.9273-4-linus.luessing@c0d3.blue> In-Reply-To: <20210914192515.9273-1-linus.luessing@c0d3.blue> References: <20210914192515.9273-1-linus.luessing@c0d3.blue> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Lüssing There is a small risk of the ath9k hw interrupts being reenabled in the following way: 1) ath_reset_internal() ... -> disable_irq() ... <- returns 2) ath9k_tasklet() ... -> ath9k_hw_resume_interrupts() ... 1) ath_reset_internal() continued: -> tasklet_disable(&sc->intr_tq); (= ath9k_tasklet() off) By first disabling the ath9k interrupt there is a small window afterwards which allows ath9k hw interrupts being reenabled through the ath9k_tasklet() before we disable this tasklet in ath_reset_internal(). Leading to having the ath9k hw interrupts enabled during the reset, which we should avoid. Fixing this by first disabling all ath9k tasklets. And only after they are not running anymore also disabling the overall ath9k interrupt. Either ath9k_queue_reset()->ath9k_kill_hw_interrupts() or ath_reset_internal()->disable_irq()->ath_isr()->ath9k_kill_hw_interrupts() should then have ensured that no ath9k hw interrupts are running during the actual ath9k reset. We could reproduce this issue with two Lima boards from 8devices (QCA4531) on OpenWrt 19.07 while sending UDP traffic between the two and triggering an ath9k_queue_reset() and with added msleep()s between disable_irq() and tasklet_disable() in ath_reset_internal(). Cc: Sven Eckelmann Cc: Simon Wunderlich Cc: Linus Lüssing Fixes: e3f31175a3ee ("ath9k: fix race condition in irq processing during hardware reset") Signed-off-by: Linus Lüssing --- drivers/net/wireless/ath/ath9k/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 98090e40e1cf..b9f9a8ae3b56 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -292,9 +292,9 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan) __ath_cancel_work(sc); - disable_irq(sc->irq); tasklet_disable(&sc->intr_tq); tasklet_disable(&sc->bcon_tasklet); + disable_irq(sc->irq); spin_lock_bh(&sc->sc_pcu_lock); if (!sc->cur_chan->offchannel) { -- 2.31.0