From patchwork Mon Oct 18 23:17:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12568271 X-Patchwork-Delegate: kvalo@adurom.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 671B8C433FE for ; Mon, 18 Oct 2021 23:15:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5067F61074 for ; Mon, 18 Oct 2021 23:15:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233559AbhJRXRj (ORCPT ); Mon, 18 Oct 2021 19:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbhJRXRi (ORCPT ); Mon, 18 Oct 2021 19:17:38 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88566C06161C for ; Mon, 18 Oct 2021 16:15:26 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id m22so44363743wrb.0 for ; Mon, 18 Oct 2021 16:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cqgq7CmylZ5uOrbViyRL+gfi0biEauoJtPG6puA4TVg=; b=Y0ODsvaf5ZQxj5xz7bmOLKad1kYhn+RH4Ua0wsqAeZod6Uq9jKGhPwNCJG4hxeEkSL FM9WV4HKZtzBGJySM7/sP6V/Vf5l/mMGXb49vJqqFj1zMJ/ujbXntX6cpUINNPI0ZDZ3 6Hcu/LgwjoWIezkxF6NcQFlfYgjUgn60z/bCsjS3k/PEHreq6fB/psqCqxXKG5CnskBp nWpwcwHY7CVNEljum3cTy+hLSZewKVzBSBhLsYiiaWJeU7w507uBc3Ju3hiBJNjVwW+y iBYTVYFgHzTCjBnxmZDOR4tK4gcwSeZNsIZb+jmhO4WyDgwPRk/30KMNJ+TOfnSOrpSJ Lqqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cqgq7CmylZ5uOrbViyRL+gfi0biEauoJtPG6puA4TVg=; b=v9YeZT238csSWb5A6TEMlP1hkl22gx1O7rCIiQlrgDAJtlicaqJw+p/DTJQDZIU+o3 r2b3gK00k73pKCTTEPAQV80Gm4eGQGJoGLSyYueKpchfqsKDUPbc0OT2B5CNoIRdcJde mo3zFp01Q17ihlkhBtUh3a4jZXJxOzS+1+vWURDANfVR8l6wLAYfNpPU672epvTsVijr Z6pN5PjO6Ara1uNw8Rmxz5elB9EQ4K1n0GReRevTVlzGh7iDtKh1ekcxAIsyWG4rMiap DhwnOAH12MUstpxNwFsxSux/Gt6IaEsPRCVfElYol4gsamsmCt2hYPpVmP+Nb/VwG4bO yO2g== X-Gm-Message-State: AOAM533jePlBo8PPrTvtbAWmHMaony4Xv0JZ3/8RwY+0lrlnafUpHY+x JOdMfL3Oq2bfxja5GBPTStfCDg== X-Google-Smtp-Source: ABdhPJzeu/mi5sQ0AECApkbIJScjQstkgsvsk2FwVf4f2ED+PSHmEvm0zl0ETS637sJW2Kf4AWsyWw== X-Received: by 2002:adf:d1ee:: with SMTP id g14mr39642914wrd.264.1634598925129; Mon, 18 Oct 2021 16:15:25 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id s8sm3685379wrr.15.2021.10.18.16.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 16:15:24 -0700 (PDT) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org Cc: loic.poulain@linaro.org, benl@squareup.com, daniel.thompson@linaro.org, johannes@sipsolutions.net, bryan.odonoghue@linaro.org Subject: [PATCH v2 1/5] wcn36xx: Fix dxe lock layering violation Date: Tue, 19 Oct 2021 00:17:18 +0100 Message-Id: <20211018231722.873525-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211018231722.873525-1-bryan.odonoghue@linaro.org> References: <20211018231722.873525-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org We are looking at some interesting crashes with wcn36xx in the wild, with some of the data appearing to indicate multiple instances of "WARNING Spurious TX complete indication". Looking at the code here we see that txrx.c is taking the dxe.c lock to set and unset the current TX skbuff pointer. There is no obvious logical bug however, it is a layering violation to share locks like this. Lets tidy up the code a bit by making access functions to set and unset the TX sbuff. This makes it easier to reason about this code without having to switch between multiple files. Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware") Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/dxe.c | 26 +++++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/dxe.h | 2 ++ drivers/net/wireless/ath/wcn36xx/txrx.c | 15 ++------------ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index c4e9e939d7d6d..6c43df4bc92c3 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -878,6 +878,32 @@ int wcn36xx_dxe_tx_flush(struct wcn36xx *wcn) return -EBUSY; } +int wcn36xx_dxe_set_tx_ack_skb(struct wcn36xx *wcn, struct sk_buff *skb) +{ + unsigned long flags; + + spin_lock_irqsave(&wcn->dxe_lock, flags); + if (wcn->tx_ack_skb) { + spin_unlock_irqrestore(&wcn->dxe_lock, flags); + wcn36xx_warn("tx_ack_skb already set\n"); + return -EINVAL; + } + + wcn->tx_ack_skb = skb; + spin_unlock_irqrestore(&wcn->dxe_lock, flags); + + return 0; +} + +void wcn36xx_dxe_unset_tx_ack_skb(struct wcn36xx *wcn) +{ + unsigned long flags; + + spin_lock_irqsave(&wcn->dxe_lock, flags); + wcn->tx_ack_skb = NULL; + spin_unlock_irqrestore(&wcn->dxe_lock, flags); +} + int wcn36xx_dxe_init(struct wcn36xx *wcn) { int reg_data = 0, ret; diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.h b/drivers/net/wireless/ath/wcn36xx/dxe.h index 26a31edf52e99..9a7655d6af982 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.h +++ b/drivers/net/wireless/ath/wcn36xx/dxe.h @@ -468,4 +468,6 @@ int wcn36xx_dxe_tx_frame(struct wcn36xx *wcn, bool is_low); int wcn36xx_dxe_tx_flush(struct wcn36xx *wcn); void wcn36xx_dxe_tx_ack_ind(struct wcn36xx *wcn, u32 status); +int wcn36xx_dxe_set_tx_ack_skb(struct wcn36xx *wcn, struct sk_buff *skb); +void wcn36xx_dxe_unset_tx_ack_skb(struct wcn36xx *wcn); #endif /* _DXE_H_ */ diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c index d727b0dd98de5..1218bd85de3ba 100644 --- a/drivers/net/wireless/ath/wcn36xx/txrx.c +++ b/drivers/net/wireless/ath/wcn36xx/txrx.c @@ -584,7 +584,6 @@ int wcn36xx_start_tx(struct wcn36xx *wcn, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct wcn36xx_vif *vif_priv = NULL; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - unsigned long flags; bool is_low = ieee80211_is_data(hdr->frame_control); bool bcast = is_broadcast_ether_addr(hdr->addr1) || is_multicast_ether_addr(hdr->addr1); @@ -606,15 +605,8 @@ int wcn36xx_start_tx(struct wcn36xx *wcn, if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) { wcn36xx_dbg(WCN36XX_DBG_DXE, "TX_ACK status requested\n"); - spin_lock_irqsave(&wcn->dxe_lock, flags); - if (wcn->tx_ack_skb) { - spin_unlock_irqrestore(&wcn->dxe_lock, flags); - wcn36xx_warn("tx_ack_skb already set\n"); + if (wcn36xx_dxe_set_tx_ack_skb(wcn, skb)) return -EINVAL; - } - - wcn->tx_ack_skb = skb; - spin_unlock_irqrestore(&wcn->dxe_lock, flags); /* Only one at a time is supported by fw. Stop the TX queues * until the ack status gets back. @@ -644,10 +636,7 @@ int wcn36xx_start_tx(struct wcn36xx *wcn, /* If the skb has not been transmitted, * don't keep a reference to it. */ - spin_lock_irqsave(&wcn->dxe_lock, flags); - wcn->tx_ack_skb = NULL; - spin_unlock_irqrestore(&wcn->dxe_lock, flags); - + wcn36xx_dxe_unset_tx_ack_skb(wcn); ieee80211_wake_queues(wcn->hw); } From patchwork Mon Oct 18 23:17:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12568273 X-Patchwork-Delegate: kvalo@adurom.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A88EC433F5 for ; Mon, 18 Oct 2021 23:15:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EF2B61027 for ; Mon, 18 Oct 2021 23:15:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233581AbhJRXRk (ORCPT ); Mon, 18 Oct 2021 19:17:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbhJRXRj (ORCPT ); Mon, 18 Oct 2021 19:17:39 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 760A6C06161C for ; Mon, 18 Oct 2021 16:15:27 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id u18so44330351wrg.5 for ; Mon, 18 Oct 2021 16:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YpmskcKe71TPZGRhow7F3YV4IIOIX62OuOrpbY+RO7Q=; b=R95yIGBIOzovHsbuuEh0AlNoXkgJIQA4VIfFrsW3weOXNHUJwfVQouzYmwfQf0Q5/x bygwNk0rdMkS+2tulz7Vg5QO5Lfi20Hqz8Sa2oVlNxyXH0xoGbu689gPxWAzLhcVU/dm qQIYznUHCb0kdo5RI9RipcC8wBHy/WoqYqF0suHy/QlTrP9uZvGJBCD2NVeeApQy7czR qWApoy2Pwa70l6UzbKbDZDcqXUzYMd8toiNfZ6tLVcaDKCAHnzw4UB20rp/AHPiwyKRW 6oiOED2MjtaddOLhIExzu97A1lOLnJjWWcT+d21ctVhr58D9vAP3D78DMFxDYY7OwsFH jtxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YpmskcKe71TPZGRhow7F3YV4IIOIX62OuOrpbY+RO7Q=; b=raBJYzwR3aBvxeoN+lMMUHk6gpf9hvvNDDVoeQ/t3OHRHzkyfXclt+vU+N/lBVCOZm lr/ZaGUxNg/Bt5P2TdvKIGJFYQrLt/C3WCwrcJFMICkHFSGYHujD0TOwEJj/RXQvhmX6 +4B1sdBti8vFDVU9+RovvlxCS0Mt2dS7K8p5kLPifsP8XJDpEFOZpzGBHqQnjOSO5bbR vTAhvOj0I7Eo9RQFBNeUSs2/OSFQAhNUm+VGmLDUto5QE3zBDqjmTZxdoEKWFEyRVjvv BOzdOPwqqmWhpsqjNnWsB9UNwMkidfI3qAqreAvRPwGTDwdtRTqCnve9Cp6sUmHW6CQ2 Z/Eg== X-Gm-Message-State: AOAM531WJfNY/GW8CgnV0mUji/GIF4AIktPZYZT1d/T9vJN3iaMaesyI +yBHPX2mGP0dKRcTdToVw8B/vQLoT2MGHg== X-Google-Smtp-Source: ABdhPJx1r3OMTiLboWwmBPOeu0pJnZVdfzRAJKBqBn3cU3xQwUspQoBubTB1j8aw/NpXBFvonebIaQ== X-Received: by 2002:adf:9c11:: with SMTP id f17mr40305177wrc.147.1634598926119; Mon, 18 Oct 2021 16:15:26 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id s8sm3685379wrr.15.2021.10.18.16.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 16:15:25 -0700 (PDT) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org Cc: loic.poulain@linaro.org, benl@squareup.com, daniel.thompson@linaro.org, johannes@sipsolutions.net, bryan.odonoghue@linaro.org Subject: [PATCH v2 2/5] wcn36xx: Fix DMA channel enable/disable cycle Date: Tue, 19 Oct 2021 00:17:19 +0100 Message-Id: <20211018231722.873525-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211018231722.873525-1-bryan.odonoghue@linaro.org> References: <20211018231722.873525-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Right now we have a broken sequence where we enable DMA channel interrupts which can be left enabled and never disabled if we hit an error path. Worse still when we unload the driver, the DMA channel interrupt bits are left intact. About the only saving grace here is that we do remember to disable the wcnss interrupt when unload the driver. Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware") Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/dxe.c | 38 ++++++++++++++++++-------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index 6c43df4bc92c3..b832afedde76a 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -272,6 +272,21 @@ static int wcn36xx_dxe_enable_ch_int(struct wcn36xx *wcn, u16 wcn_ch) return 0; } +static void wcn36xx_dxe_disable_ch_int(struct wcn36xx *wcn, u16 wcn_ch) +{ + int reg_data = 0; + + wcn36xx_dxe_read_register(wcn, + WCN36XX_DXE_INT_MASK_REG, + ®_data); + + reg_data &= ~wcn_ch; + + wcn36xx_dxe_write_register(wcn, + WCN36XX_DXE_INT_MASK_REG, + (int)reg_data); +} + static int wcn36xx_dxe_fill_skb(struct device *dev, struct wcn36xx_dxe_ctl *ctl, gfp_t gfp) @@ -939,7 +954,6 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn) WCN36XX_DXE_WQ_TX_L); wcn36xx_dxe_read_register(wcn, WCN36XX_DXE_REG_CH_EN, ®_data); - wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_TX_L); /***************************************/ /* Init descriptors for TX HIGH channel */ @@ -963,9 +977,6 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn) wcn36xx_dxe_read_register(wcn, WCN36XX_DXE_REG_CH_EN, ®_data); - /* Enable channel interrupts */ - wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_TX_H); - /***************************************/ /* Init descriptors for RX LOW channel */ /***************************************/ @@ -975,7 +986,6 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn) goto out_err_rxl_ch; } - /* For RX we need to preallocated buffers */ wcn36xx_dxe_ch_alloc_skb(wcn, &wcn->dxe_rx_l_ch); @@ -998,9 +1008,6 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn) WCN36XX_DXE_REG_CTL_RX_L, WCN36XX_DXE_CH_DEFAULT_CTL_RX_L); - /* Enable channel interrupts */ - wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_RX_L); - /***************************************/ /* Init descriptors for RX HIGH channel */ /***************************************/ @@ -1032,15 +1039,18 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn) WCN36XX_DXE_REG_CTL_RX_H, WCN36XX_DXE_CH_DEFAULT_CTL_RX_H); - /* Enable channel interrupts */ - wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_RX_H); - ret = wcn36xx_dxe_request_irqs(wcn); if (ret < 0) goto out_err_irq; timer_setup(&wcn->tx_ack_timer, wcn36xx_dxe_tx_timer, 0); + /* Enable channel interrupts */ + wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_TX_L); + wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_TX_H); + wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_RX_L); + wcn36xx_dxe_enable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_RX_H); + return 0; out_err_irq: @@ -1057,6 +1067,12 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn) void wcn36xx_dxe_deinit(struct wcn36xx *wcn) { + /* Disable channel interrupts */ + wcn36xx_dxe_disable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_RX_H); + wcn36xx_dxe_disable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_RX_L); + wcn36xx_dxe_disable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_TX_H); + wcn36xx_dxe_disable_ch_int(wcn, WCN36XX_INT_MASK_CHAN_TX_L); + free_irq(wcn->tx_irq, wcn); free_irq(wcn->rx_irq, wcn); del_timer(&wcn->tx_ack_timer); From patchwork Mon Oct 18 23:17:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12568275 X-Patchwork-Delegate: kvalo@adurom.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EA98C43217 for ; Mon, 18 Oct 2021 23:15:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FF4161027 for ; Mon, 18 Oct 2021 23:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233662AbhJRXRl (ORCPT ); Mon, 18 Oct 2021 19:17:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbhJRXRk (ORCPT ); Mon, 18 Oct 2021 19:17:40 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EA5DC061745 for ; Mon, 18 Oct 2021 16:15:28 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 63-20020a1c0042000000b0030d60716239so726003wma.4 for ; Mon, 18 Oct 2021 16:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QBnRHV9rerfqg5IbeiF/8rK0T34zBtjkpRvTdqdQUlc=; b=aFg91Sh9YmPW83M7zi+C8pWgz62P6/sn5LKCIc9U7zuatO2d5tXhdcNnFqrVmF5+kD MqFLmWBOxaq4QZLDqitIM+SY+FSUnT9wMdAADtwfMpVcJ69bTwjVWZMek+sw/yUTsUe3 y7NIksZ2WyGbJxBQmmkvIUTjLA17fNheH9OKFf0j28dprpaGdNkEdFUJJntMlRASQlMz OnvIfli9ErvH5YbHqmnM2pXqY3sLMgJ6QRC9j+BLygiz8XxaVkc2riPJIX2EjYVdIe55 SgXLXHiY173sCqYAWfUiZFZAdjiXyvbPfwlTRo1e0zuwRGqb5Wi1fTMlhKt/9+9Dof+t fgvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QBnRHV9rerfqg5IbeiF/8rK0T34zBtjkpRvTdqdQUlc=; b=Bsph8JaqvlG4cdEuNEmeBIqW3O0iu/0pxCnax8AyCAfgb6KTjTnmM4IEAdQvPyJei6 2W+YdSa+h9NZJ3yDgGiC0uNtmRqb1KTbe42yMeid7uPosFWWEv5hzoSRh2N8/D3tY8AL Tn4qy5qfLpAwARBLY7s1aoZzudY/tkXK8EDuXAiG+qL7P9Wn/IBipUKkEtNWgFRcrie7 VrsldWF/IXH4HL+/mKARq+wh2klzXOILhu6OS6I3TxYprr2wNZ56ghuay1vHfTMTOgcN 7YMX0evo/mELkvWtizUncc8vRG/JcChqH8Yhmq7W7C7B3sMv8ZGHmP1c2lt3AT75sk4p stNw== X-Gm-Message-State: AOAM533YaQCKolEKyY2Rnspo1oxtdERludRphygmO1v8dDmEHQdicyL2 rG0KvB4LZuU3RhC9D3KVgqqa7A== X-Google-Smtp-Source: ABdhPJzHs4xBg3zLrJIi0UafgxAzeqptHLVqONWwzsnBe6ieVbS2qxISzEYujUv7rfwt1BSRyo3wLQ== X-Received: by 2002:a1c:5417:: with SMTP id i23mr2014312wmb.17.1634598927213; Mon, 18 Oct 2021 16:15:27 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id s8sm3685379wrr.15.2021.10.18.16.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 16:15:26 -0700 (PDT) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org Cc: loic.poulain@linaro.org, benl@squareup.com, daniel.thompson@linaro.org, johannes@sipsolutions.net, bryan.odonoghue@linaro.org Subject: [PATCH v2 3/5] wcn36xx: Release DMA channel descriptor allocations Date: Tue, 19 Oct 2021 00:17:20 +0100 Message-Id: <20211018231722.873525-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211018231722.873525-1-bryan.odonoghue@linaro.org> References: <20211018231722.873525-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When unloading the driver we are not releasing the DMA descriptors which we previously allocated. Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware") Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/dxe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index b832afedde76a..30f4484b336c3 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -1084,4 +1084,9 @@ void wcn36xx_dxe_deinit(struct wcn36xx *wcn) wcn36xx_dxe_ch_free_skbs(wcn, &wcn->dxe_rx_l_ch); wcn36xx_dxe_ch_free_skbs(wcn, &wcn->dxe_rx_h_ch); + + wcn36xx_dxe_deinit_descs(wcn->dev, &wcn->dxe_tx_l_ch); + wcn36xx_dxe_deinit_descs(wcn->dev, &wcn->dxe_tx_h_ch); + wcn36xx_dxe_deinit_descs(wcn->dev, &wcn->dxe_rx_l_ch); + wcn36xx_dxe_deinit_descs(wcn->dev, &wcn->dxe_rx_h_ch); } From patchwork Mon Oct 18 23:17:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12568277 X-Patchwork-Delegate: kvalo@adurom.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A72D3C433EF for ; Mon, 18 Oct 2021 23:15:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CACD60FDA for ; Mon, 18 Oct 2021 23:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233722AbhJRXRo (ORCPT ); Mon, 18 Oct 2021 19:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbhJRXRl (ORCPT ); Mon, 18 Oct 2021 19:17:41 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97C96C06161C for ; Mon, 18 Oct 2021 16:15:29 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id r18so44173926wrg.6 for ; Mon, 18 Oct 2021 16:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ums5lH5A6tPRuZbLiAY6nRVNCSm8UQRGQFhKC352/Xs=; b=HPfHLoDquM7RwcND+vgWYueLkNiO7PWgpgDB78EfJZCLRozaCjUGgUBe+L0EkWBs8D oe6kjBNWVhYB9ZQfRQ63pxsrtBbEB94++LbfWizDhOHCG0Dbp1oCzZfIAOtiwSNR2jJX o99ktNMwHwoiVNlLuFNxqqoZPzqN43TfVTv6ckG3PiPXFcALOxxMVkTmoyx8g3ay2at1 Ogqqd8wsWOJg5RKDO1SdNR27TcQFlKJHdlvjGfFFuCSzYQ1go/ImvAT8OE53nt5thYL2 h3GHSNxkMmuQ2LBA9X09Fji001m00w2y9n0tJUv/irXZeEvGYOPT7RhsiDW5I7dQpeWr rgqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ums5lH5A6tPRuZbLiAY6nRVNCSm8UQRGQFhKC352/Xs=; b=U43p9okupF4O43nw3dG6rNJM3wu3EP/BVzgh/BhXCGTVDSvfThR1Uw5t5bRCd4xqGu F9kEMuZTRKlI6Fy19KMcQ/t0Kj1lJiS8G6PaFfNRfCfY6xHtrBDcF1/3Kg6tuwXyxVgh NRngL3abxv7UmGv9dK1h+9Nt72j+5hPJ8HNSHDY2LcqpW1ZKTQd9CNMo0nAfMR8uIsUS YJM7H15vaWLzon1khek0/EPfZZKDcqkQD4PjkhMNbFV0MiLh75UB1XcEWzXQteeTNDal Txi0hmhMYgu4CGRrh02FNpXZVlO3tYzwgJaSTs31war06eUsIaWCBpzBXtvViXqUD+rp cF/g== X-Gm-Message-State: AOAM530NLytpcgQuyA3+ovQfJCpcT95rjth1yntuoZycAHCK5lNijI3w j44UP5+CWWYDASCFDWjDEXplyg== X-Google-Smtp-Source: ABdhPJzQ825m3VfzLCVqqVY4uThT3296xK7cmuholih9I0tL6ZMXMehP/ZzeyfDfu8hErR79FMgHfg== X-Received: by 2002:a05:6000:1563:: with SMTP id 3mr39029542wrz.20.1634598928262; Mon, 18 Oct 2021 16:15:28 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id s8sm3685379wrr.15.2021.10.18.16.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 16:15:27 -0700 (PDT) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org Cc: loic.poulain@linaro.org, benl@squareup.com, daniel.thompson@linaro.org, johannes@sipsolutions.net, bryan.odonoghue@linaro.org Subject: [PATCH v2 4/5] wcn36xx: Functionally decompose DXE reset Date: Tue, 19 Oct 2021 00:17:21 +0100 Message-Id: <20211018231722.873525-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211018231722.873525-1-bryan.odonoghue@linaro.org> References: <20211018231722.873525-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org A follow-on patch will reset the DXE block in dxe_deinit. Prepare the way by first functionally decomposing the reset. Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware") Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/dxe.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index 30f4484b336c3..d4f5746d9b10a 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -919,12 +919,19 @@ void wcn36xx_dxe_unset_tx_ack_skb(struct wcn36xx *wcn) spin_unlock_irqrestore(&wcn->dxe_lock, flags); } -int wcn36xx_dxe_init(struct wcn36xx *wcn) +static void wcn36xx_dxe_reset(struct wcn36xx *wcn) { - int reg_data = 0, ret; + int reg_data = 0; reg_data = WCN36XX_DXE_REG_RESET; wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_REG_CSR_RESET, reg_data); +} + +int wcn36xx_dxe_init(struct wcn36xx *wcn) +{ + int reg_data = 0, ret; + + wcn36xx_dxe_reset(wcn); /* Select channels for rx avail and xfer done interrupts... */ reg_data = (WCN36XX_DXE_INT_CH3_MASK | WCN36XX_DXE_INT_CH1_MASK) << 16 | From patchwork Mon Oct 18 23:17:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12568279 X-Patchwork-Delegate: kvalo@adurom.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6493DC433F5 for ; Mon, 18 Oct 2021 23:15:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EFDC60FDA for ; Mon, 18 Oct 2021 23:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233650AbhJRXRo (ORCPT ); Mon, 18 Oct 2021 19:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233627AbhJRXRm (ORCPT ); Mon, 18 Oct 2021 19:17:42 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84EB3C061745 for ; Mon, 18 Oct 2021 16:15:30 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id k7so43982819wrd.13 for ; Mon, 18 Oct 2021 16:15:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GbLM5Z3jD8SPQEozMJryUhBVooDo33aFTB2Os0auzZc=; b=hAIrENvHRnb4RSIeGT/YWT7oVggO3TgS+sD3kWQ/0yA+1biY1bh6snfeNIpAmdBmmI 2WlL6CSXl3HxWwFJpCPICwkoY/Vyv68aa1khsfHcwcXFiCv6Ql84UDkHa/NTyZTyBGd1 Hzk+LT3iAYZ9F29nfhP7jx1F5+6UtzEwUqUj5J++sefpeUIeVfYhz9beDSqj8pW/3ZdE x49l/OLkuGjxcr8J59p72kTPXqr30JJA9jWIb6uUNNQZEsuGge9NYJajTthIIxN1iylD Ws0sXHCxxezrcf6CwrFKgIJuMD1/Bx/6lJTItcMPKUI31M+2IbXoKLU33l2kGnevv9xy 2Qtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GbLM5Z3jD8SPQEozMJryUhBVooDo33aFTB2Os0auzZc=; b=LlMCvF6jRvqXsL2OC1UU+hQFPVNWEBxKG0pXTJ4htxCXMxDp/Jok5z9tqmulIPP/m5 Rupz7Fa8ZKmHz6E579hLa7NGMUlzSNRI8WX3psS4HFmb1061rYsE/BsncpA5YX/yqh1m QaEWPQiDvP2I8oMgeP4IrZs94JxKRxUzKySDrJm2eA/dA6jVv5OdqOZsnLv5Wd1kKPCC EKSFBG0bVafQnG0sfYXJT3MJAmr/5I598EG4WrKPQw605FXl/s32I9ReRJiwG1COZBXV 2HuHkeKJGbW/dlcyWTZ9RqhmeZVGDxkPU+XeG7WwJ8F96/InXVgPJVVeX1ty6OSon2s0 kjxg== X-Gm-Message-State: AOAM531tyGVLlsG0EDGU5imZracTqCNlIOLd92UYslZAOFTjE3BhnMK2 sZsbZ14SzQIeqU3GxK7kh5r1eg== X-Google-Smtp-Source: ABdhPJxeawc99BF6bii7izYsT+pg4cPUjx39WvlisOhOW36ApDogSAD62YcY3CD36Xz9rfvlCvY4Kg== X-Received: by 2002:adf:bbc3:: with SMTP id z3mr40159667wrg.10.1634598929207; Mon, 18 Oct 2021 16:15:29 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id s8sm3685379wrr.15.2021.10.18.16.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 16:15:28 -0700 (PDT) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org Cc: loic.poulain@linaro.org, benl@squareup.com, daniel.thompson@linaro.org, johannes@sipsolutions.net, bryan.odonoghue@linaro.org Subject: [PATCH v2 5/5] wcn36xx: Put DXE block into reset before freeing memory Date: Tue, 19 Oct 2021 00:17:22 +0100 Message-Id: <20211018231722.873525-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211018231722.873525-1-bryan.odonoghue@linaro.org> References: <20211018231722.873525-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When deiniting the DXE hardware we should reset the block to ensure there is no spurious DMA write transaction from the downstream WCNSS to upstream MSM at a skbuff address we will have released. Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware") Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/dxe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index d4f5746d9b10a..cf85b0cd11be4 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -1089,6 +1089,9 @@ void wcn36xx_dxe_deinit(struct wcn36xx *wcn) wcn->tx_ack_skb = NULL; } + /* Put the DXE block into reset before freeing memory */ + wcn36xx_dxe_reset(wcn); + wcn36xx_dxe_ch_free_skbs(wcn, &wcn->dxe_rx_l_ch); wcn36xx_dxe_ch_free_skbs(wcn, &wcn->dxe_rx_h_ch);