Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp752867pxb; Wed, 15 Sep 2021 12:18:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1YFwuPqbhLR3E355H6cUDidJuyAf6M0jR2ztm2J6KjHhx63mMNbvIh5MFCR8FKXVkfSXc X-Received: by 2002:a92:c9c9:: with SMTP id k9mr1245035ilq.82.1631733517354; Wed, 15 Sep 2021 12:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631733517; cv=none; d=google.com; s=arc-20160816; b=nXEeHWGmqFtQiUCyWsKNoV4BF3Lo8gsbEkwfktRF4ktDr8SkO9qlYh0j1zIjvEzJWm dM0Hm3n6vJLVBlYa5jf7x/YHcqTolEi2rG7IBoC3iuHyFL6oPnI8nOWPfo7xlS4HutB5 Olv7LKHSYzuuDc9NITk8GHPWoyj2HMdkeNJJ3nO+NrIlvIR5ZrwbmH1LILTHEtF3I8jh DN9NU+DC6BJe4XYnEeRW0lWbDNljiJcUjtvzFPC9PwF1ZjFFPOztEN7VKF/heTAUdZSK n3oUtYI/TykG2k+xgowT0bPzN/8DW0vpcuOdkuJBXa6d04Q0nEi9wJYILrkMPG/Ygd57 kMRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tY7F4fSsg3PB+sO6kCZT3b+6VeUGChdPdq/Yi8r8n9I=; b=OWD0UB1tvG4XlFe6x3nSQA5cFXiE3c3PeWwebu111E32GVnadjXOLkpr6C6h1xOUH1 XWejQyOo+6FZwD1/psciJpendl2q78d8ZpRq950WbCHno0hhJKe4UdP+Csfo5rero07z HUfCVVAzAysJ13I2L3oHPxEqZRJVLq8cBstYcl9k6eUOSBA7BqiNtW89zOJbk6hz0IuA X6YCTbJqMHwthOfdtqjACGlgA0fGQg9MUOpxa3FnLBT4D00bkcWqKhOGby5G8s0CWH2F KVuLG7UpFXyvlllU5slD/uIwm6MirMojMaaz3+gcaL9v+CbmxkXkKrQ8efxY+q6E0LfI BePg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-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 y10si726297ion.41.2021.09.15.12.18.20; Wed, 15 Sep 2021 12:18:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231494AbhIOTTe (ORCPT + 99 others); Wed, 15 Sep 2021 15:19:34 -0400 Received: from mail.aperture-lab.de ([116.203.183.178]:37308 "EHLO mail.aperture-lab.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231153AbhIOTTe (ORCPT ); Wed, 15 Sep 2021 15:19:34 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9BD3A3EB3C; Wed, 15 Sep 2021 21:18:05 +0200 (CEST) Date: Wed, 15 Sep 2021 21:18:03 +0200 From: Linus =?utf-8?Q?L=C3=BCssing?= To: Felix Fietkau Cc: Kalle Valo , Sujith Manoharan , ath9k-devel@qca.qualcomm.com, 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, Linus =?utf-8?Q?L=C3=BCssing?= Subject: Re: [PATCH 3/3] ath9k: Fix potential hw interrupt resume during reset Message-ID: References: <20210914192515.9273-1-linus.luessing@c0d3.blue> <20210914192515.9273-4-linus.luessing@c0d3.blue> <255a49c7-d763-50d9-87e0-da22f4a9b053@nbd.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <255a49c7-d763-50d9-87e0-da22f4a9b053@nbd.name> X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Wed, Sep 15, 2021 at 11:48:55AM +0200, Felix Fietkau wrote: > > On 2021-09-14 21:25, Linus Lüssing wrote: > > 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. > I don't see a way in which interrupts can be re-enabled through the > tasklet. disable_irq disables the entire PCI IRQ (not through ath9k hw > registers), and they will only be re-enabled by the corresponding > enable_irq call. Ah, okay, then I think I misunderstood the previous fixes to the ath9k interrupt shutdown during reset here. I had only tested the following diff and assumed that it were not okay to have the ath9k hw interrupt registers enabled within the spinlock'd section: ``` @@ -299,11 +299,23 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan) __ath_cancel_work(sc); disable_irq(sc->irq); + for (r = 0; r < 200; r++) { + msleep(5); + + if (REG_READ(ah, AR_INTR_SYNC_CAUSE) || + REG_READ(ah, AR_INTR_ASYNC_CAUSE)) { + break; + } + } tasklet_disable(&sc->intr_tq); tasklet_disable(&sc->bcon_tasklet); spin_lock_bh(&sc->sc_pcu_lock); + if (REG_READ(ah, AR_INTR_SYNC_CAUSE) || + REG_READ(ah, AR_INTR_ASYNC_CAUSE)) + ATH_DBG_WARN(1, "%s: interrupts are enabled", __func__); + if (!sc->cur_chan->offchannel) { fastcc = false; caldata = &sc->cur_chan->caldata; ``` And yes, the general ath9k interrupt should still be disabled. Didn't test for that but seems like it. (And now I noticed that actually ath_reset_internal() -> ath_prepare_reset() -> ath9k_hw_disable_interrupts() -> ath9k_hw_kill_interrupts() disables the ath9k hw interrupt registers before the ath_reset_internal()->ath9k_hw_reset() call anyway.) What would you prefer, should this patch just be dropped or should I resend it without the "Fixes:" line as a cosmetic change? (e.g. to have the order in reverse to reenablement at the end of ath_reset_internal(), to avoid confusion in the future?) Regards, Linus