From patchwork Fri Oct 15 13:17:38 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: 515851 Delivered-To: patch@linaro.org Received: by 2002:adf:a11e:0:0:0:0:0 with SMTP id o30csp544084wro; Fri, 15 Oct 2021 06:15:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3fA9gBjlGmzmVtj3+vWy96WxtZoztXjT7BUrcASENwCMDKw0L6zgAyZp3w2E1cO+IL2kQ X-Received: by 2002:a17:902:b205:b0:13d:b0a1:da90 with SMTP id t5-20020a170902b20500b0013db0a1da90mr11314846plr.26.1634303754132; Fri, 15 Oct 2021 06:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634303754; cv=none; d=google.com; s=arc-20160816; b=svxTvDXS5VPzW9u18L42VJqC7UwmfBfp6R56yb28xI6PQeTy3HF2kMiGvhG/27FAjU 1qDsPZNlhtrQMOr7jODrH4eQ+yz5lAMDlwv/6hmINeQXw71u7s5c8j45tHud5GuxU4E8 n6vx5LVXpwnj+OlKBlUteo1KoOZp7PAC/LKfbVmFh8V9g8IMn1P5oHNeGrpuRqM3Hhl4 iZ1RBUbprdzwqTGO6EEnfu0LQZdy/oY+UtAoSKnUVNUixwN1K2SIFAX7oJxpsvCIP3QF INlwOtYoM1GXOklb+L9FjyQVbNS04m52Snua3ijyR9xsDD7pHtnZTM490zr7U5G3vKoM Hz9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=mwdq2KpJwCiS0cl5rzzhTPWLiDl1dRBzXewlUosaX8k=; b=vO/vnNxJWFXELZNnRQO5rkb5ksc5ydG26O0+ouzjwh7grFWaKIRuOVbSqsNXLL+KY6 E8llFK7LELUX+xEo/l3ncPzy9bOOpzkuWLqiZWG4OqaUKpH4wm2hYXE6I4zIZ5gRm6Ht bt2EUzA+MEm/BsQsLLLbkJQ+hoFaU+auEpM3p7W7oXV7VPWYiduCGXYN2UWBlUk0/Vb5 BIyq2F1pxuYnfYDki2KqFaRjqGuu+lzLrtK/GdL8zpelBkshqqRDs8nlOxESh3zFuSFM qANgPJUJDjksMoRZFs3Ape56LbyjOu0W/j1yKpM+viIuq6JdXm/i6vjVUhM1OZrgGOgw /CgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=DVoO968Y; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=laUkFjTz; spf=neutral (google.com: 2607:7c80:54:e::133 is neither permitted nor denied by best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by mx.google.com with ESMTPS id n2si6991318pjh.91.2021.10.15.06.15.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 06:15:54 -0700 (PDT) Received-SPF: neutral (google.com: 2607:7c80:54:e::133 is neither permitted nor denied by best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=DVoO968Y; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=laUkFjTz; spf=neutral (google.com: 2607:7c80:54:e::133 is neither permitted nor denied by best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mwdq2KpJwCiS0cl5rzzhTPWLiDl1dRBzXewlUosaX8k=; b=DVoO968YC+R4Eb xztFc57xn/5OBEoEHAPq+HOO5exm8BB7QQhJiHgxC1fjtUsqayVVGebPd7ImsEzZW5w41acZkiq8C SVS+JpDsP36fV2FyDiPB7zXuj7ChaCbs2uHDUraE5wNx9+ansMowC439PLwm9/F+bRjxHGGv2NnaA RT6l+9c5E3aiNWoFSchTysPBG03E0yVLGFyKCbwwf9BRjn6bsWj/uwgLbpHO9iJMB9hC5jE7dxfs7 7ZcFLmJhCWRvhv2uSULW41M8Js7214+ARz2PWGDQnVpv8txsexQbw4VvAs5rHGjUz8Ruw45Ae7OCE zKIIDOkZmC6KzodtTe0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbN3w-007ATw-Dt; Fri, 15 Oct 2021 13:15:52 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbN3s-007AQj-8V for wcn36xx@lists.infradead.org; Fri, 15 Oct 2021 13:15:51 +0000 Received: by mail-wr1-x433.google.com with SMTP id v17so26401138wrv.9 for ; Fri, 15 Oct 2021 06:15:45 -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=UHuhRsyo5I9tg994O+s+A8x/tyH5ZdCl1bmMze2pAnU=; b=laUkFjTz3t6pC1ovKbp5JgO8lCUtujhpQa+xjjbbWLawmNYdE1g/9ekgqTm4W8jzOa foPSTOdVpo8tlBF7eTxEyW//MPy+f18a8ch0UBY6zJ3SXP6cLApQ00a6jjS6fv81nuj7 thG30CCCKWlj/tm2exCsxBJ2vZCJhQwPZl4yGsKVHyHuyk12WdZ0DbkgfYrYTjiuftin d5AqhE81uNWP5u+awyqQvPzvJytVD1MUN+OfQN1FV/u66PHYvBiqCUrl5lJYxhvLeais 55KaNvlvNtayZQehr9KYU/0VnKP1b8BA6gH+xpZcR7C677wslyH2gXVsTHVqyQkSDAvM d2+Q== 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=UHuhRsyo5I9tg994O+s+A8x/tyH5ZdCl1bmMze2pAnU=; b=4lNWnJ1+98Fs4wyrL4IhhM9fnz4nRD3w/LoDyFn4ZW2+x558ejdwB7ZAreSMBsj3nv VPFhtNjp2iReeay6vXZRxJA7EJV4GgPKCTInB6y8duf/ajAMQq+++Th21fgOvLoKjcnw fz3Bcqc0ceZfycogpclRGpnXzfciSazf7W5qArmqSTdl0oNuzbP5kadr2RDu7SoX8jPt yKsvD9x8fNnmlsWmb3Lek58cZ9fRrszJiE7HiIQybdJCZDhrd8YjqSdFMiWghgeA+N4p 3YJcFjnbzKqrt2M7hFWGlVHmuQAcE/nJTeOSa4EKfxzOeo49GJrOUx6kH2yOnVsm+stp Zy/A== X-Gm-Message-State: AOAM531A1lj3+Y55h9GJ1Pqj848mnTR7+wLpKOyN/YUUYaB6+Qu3r369 zzVFxNV4bMU8CdzmmmPstY6vVA== X-Received: by 2002:a5d:6245:: with SMTP id m5mr14385783wrv.148.1634303744292; Fri, 15 Oct 2021 06:15:44 -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 e8sm7091716wrg.48.2021.10.15.06.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 06:15:43 -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, bryan.odonoghue@linaro.org Subject: [PATCH 1/4] wcn36xx: Fix DXE lock layering violation Date: Fri, 15 Oct 2021 14:17:38 +0100 Message-Id: <20211015131741.2455824-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211015131741.2455824-1-bryan.odonoghue@linaro.org> References: <20211015131741.2455824-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211015_061548_352275_EC9AC857 X-CRM114-Status: GOOD ( 15.32 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:433 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: wcn36xx@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "wcn36xx" Errors-To: wcn36xx-bounces+patch=linaro.org@lists.infradead.org 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 read and 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(-) -- 2.33.0 _______________________________________________ wcn36xx mailing list wcn36xx@lists.infradead.org http://lists.infradead.org/mailman/listinfo/wcn36xx diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index 8e1dbfda65386..4e898bde1bb8c 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -831,6 +831,32 @@ int wcn36xx_dxe_tx_frame(struct wcn36xx *wcn, return ret; } +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 31b81b7547a32..083a95e7de576 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.h +++ b/drivers/net/wireless/ath/wcn36xx/dxe.h @@ -467,4 +467,6 @@ int wcn36xx_dxe_tx_frame(struct wcn36xx *wcn, struct sk_buff *skb, bool is_low); 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 cab196bb38cd4..969210812cfbb 100644 --- a/drivers/net/wireless/ath/wcn36xx/txrx.c +++ b/drivers/net/wireless/ath/wcn36xx/txrx.c @@ -502,7 +502,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); @@ -524,15 +523,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. @@ -562,10 +554,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 Fri Oct 15 13:17:39 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: 515853 Delivered-To: patch@linaro.org Received: by 2002:adf:a11e:0:0:0:0:0 with SMTP id o30csp544100wro; Fri, 15 Oct 2021 06:15:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG1vrQJhk3L6fKibe58HYe+I1oyFxKU/66HQ+NU+r3SqPmWy0YDtDoC/bULB9JgVY+Dgnu X-Received: by 2002:a4a:9682:: with SMTP id s2mr8952542ooi.29.1634303754583; Fri, 15 Oct 2021 06:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634303754; cv=none; d=google.com; s=arc-20160816; b=tP+5Fj4RThoT4czAtqNpsGCXPWJtz8eNgKytDpVgQda8HZna+Qm1XB0W2XxMOZUYHB l9EOYg0AQYocNXBoWKU8+SCQhlB4Ya+vYdCik9ZUwk8QqM/LU4E3OoOSBugzlkpC5ZBO R3ehkq6cdBK7U5J5ZUzAuU8ByXNeReZ0Yo0dpnXmIiBtACcDoBkUtXDrY6dFkoFMcoJE Nbx21R9Q6imIoLfB2LR9hxDH3Qe2ZxMROpmjoanBRyxn1MgahuaRqJpOvC5buqJKMZMG +Noa74x52CiKUb/E10rJN/sfQx0eyTyTCuRsL3ckTdTbeKYbfVkPDQeXToi8sQMEXrAP xeXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=bl6TqWcH92/JzmAF51qY364rFbxmLerpRDRLzaddYTI=; b=ig2LyqFHdjUx/9TNr493R7wPl8xg92cltjT1S1cNWXs7PSQrMDoQ2ulcxTABOWDHqt puK4J9pNCQPs7okNJT1RnrV51hq8EN4wTc91EXj1GVwBVlraEugwjE92S8sAOBB9vIDg 2qF/N87RziOlo5LRunlIh9fjF79n36K/hTzW3fEvq5BhOrdrVZdSkJEisaSUTLtSIT4g aODeAViuUpPha4w4sj5PXYt4qydUBk/DXkRbdQjnCqn0o79dOBp5DyEfY981onpHMTVS jUNJe5uF3195lASWmbdEMp/zY4IhqzSvmKz2vK2r8A3ka9HrvEyFiHJvfIIrzJC9L2DQ 7nmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=SVkOXgCW; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="jqaE/kml"; spf=pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id e18si7525345oii.311.2021.10.15.06.15.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 06:15:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=SVkOXgCW; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="jqaE/kml"; spf=pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bl6TqWcH92/JzmAF51qY364rFbxmLerpRDRLzaddYTI=; b=SVkOXgCW42jUED /fv6lMF3LOAH7jq0NjcNpbffUzPrZNYhm8wWXQmZMXVM7Ys2eeHeDKqHF0Vv8y+tBDJlmoWKwxkqs LZ3SxxZk4h3JUPS9+1ljbHqOMheeiKgRbjD4u64EGaVmTChxURvgD5hlBFj+IKH6t68j6PoEtOCGW T0+oBTdLLdffBb5lgW+RgSTIYWh7JTbFSFarC5dfu7Ac+bC8Zj/GlmABd5xuEB/3Oa3pgJ3mB9Qh9 YFqr7y4YZQM977XdYdWxMjIja5jamyAAPACosFuRbPGzGF3B1su5Ptv9FGrAILPH6bz8taeKW7/Nm et9KHAZpSd2XlNno+1jg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbN3w-007AUQ-Ok; Fri, 15 Oct 2021 13:15:52 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbN3s-007AQv-5p for wcn36xx@lists.infradead.org; Fri, 15 Oct 2021 13:15:51 +0000 Received: by mail-wm1-x332.google.com with SMTP id s198-20020a1ca9cf000000b0030d6986ea9fso2375840wme.1 for ; Fri, 15 Oct 2021 06:15:46 -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=fIgJBzQ+9WDIc4/3t3RLCBc0AqZncO8wqablVL8xJh8=; b=jqaE/kmlauY05WL5q3IpL/c2KwbmXazywzlqydwpMDBsjy0yfw6yWV8uBaFUOKBkLg JtWfMSAgj71dyn2IlLekP4Pgls6z3wWwFNonJ83ZdeNVvxOBoe2zo82MLPxdVGY8U7Ac D4DH92Y4O/PRraOX7Fmibkq6rC6jY3Qi8dbGNVAIx5ns+TRUuk8Iv2Ife3x7KVswvlow Le+j3IGbl6QYpzEmUWwpiQRMFkpnyTTlqdblbjfQGhZVyR0geebtovGoyoeLjVZ0+0pe REykH8HxD2JCYhGDkazOcbG32AVxchDNw2XprlOE1gjelORJ1C1DCsOTWOtnRk4id+vj vA5w== 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=fIgJBzQ+9WDIc4/3t3RLCBc0AqZncO8wqablVL8xJh8=; b=akxkmxXzeiQl5KlqEfaiyemZo3pRW9qFJNw8lgKB61BzO8y4tPkOjrPj1O6j7TPr1O d6qi3bx3eC6K/bX9nEix5sKumnEILVOiXIrDS8VsFI+0X+vptYEKdSWWVb7rKaJvy6Qn yk7SpLUZBYj555MDYZw+PZH538burYAQEZGXtfothC2RF7ooWGJvNTpcpObT5Uh+tMH0 lHNp9VQj4IJ3g7UK6eAXjCnMedaOl+49JAe7dm1MZu3sriPYMgv8/GkLOZUrWZoQf+p7 R56//OXd5fOLGtFNKhCN5tKQFdPlhao8DPPe/QjarZHdFbDm4bjKXkpsM0bz4s3RHzcM BPgA== X-Gm-Message-State: AOAM532NO+NG55Q7Nbp61+yxvInPq8CjEa2UuRwHkBXviIoOG3W14KZL 7l2cm30+50e/Xsl7IRGeTS9XOw== X-Received: by 2002:a7b:c1cb:: with SMTP id a11mr25657150wmj.39.1634303745310; Fri, 15 Oct 2021 06:15:45 -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 e8sm7091716wrg.48.2021.10.15.06.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 06:15:44 -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, bryan.odonoghue@linaro.org Subject: [PATCH 2/4] wcn36xx: Fix DXE/DMA channel enable/disable cycle Date: Fri, 15 Oct 2021 14:17:39 +0100 Message-Id: <20211015131741.2455824-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211015131741.2455824-1-bryan.odonoghue@linaro.org> References: <20211015131741.2455824-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211015_061548_267957_5C0A09CA X-CRM114-Status: GOOD ( 13.73 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 stop WCNSS, 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 doing the stop. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:332 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: wcn36xx@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "wcn36xx" Errors-To: wcn36xx-bounces+patch=linaro.org@lists.infradead.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 stop WCNSS, 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 doing the stop. 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(-) -- 2.33.0 _______________________________________________ wcn36xx mailing list wcn36xx@lists.infradead.org http://lists.infradead.org/mailman/listinfo/wcn36xx diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index 4e898bde1bb8c..13e9a274fa26a 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) @@ -892,7 +907,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 */ @@ -916,9 +930,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 */ /***************************************/ @@ -928,7 +939,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); @@ -951,9 +961,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 */ /***************************************/ @@ -985,15 +992,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: @@ -1010,6 +1020,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 Fri Oct 15 13:17:40 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: 515850 Delivered-To: patch@linaro.org Received: by 2002:adf:a11e:0:0:0:0:0 with SMTP id o30csp544077wro; Fri, 15 Oct 2021 06:15:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsoWNsOFpMQVy2/9mR08XvK4LHUiy/EJOPjLODh4AKx7M/vA4etkg5wTyBH9k+QfArjmTw X-Received: by 2002:a62:1806:0:b0:44c:5c79:59a7 with SMTP id 6-20020a621806000000b0044c5c7959a7mr11610268pfy.22.1634303753915; Fri, 15 Oct 2021 06:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634303753; cv=none; d=google.com; s=arc-20160816; b=l5F2V3HsFoa2a8+sUzZiR6F8ieublV0tdJ9W2XeRLwFm9zSDhUyWboASmR8TTmadFt r32q7j4wrAmGKs4cTZBpV8HwX/8eodD619i7zwCCHeuRFHiaI71YYQD+eM9pHp/safEI epudJWINpw/5Zl6BtQxukR7NIQkNMbQycqBRhkLGcPt3p7jwOJ8pxCzI+oNPk2gGTWl2 KEqW8kNgayxMAuIS4oVkQukBEQCDm7MKPEGA4dWNLbqjzpeKBlqFWuNGtf0YEFQYXHoR NnC8PAKHFZkFGPK9Lnsypa52rrA4ShswkuSQT2mGmwN3zJpTNHtn68uMVQKAndiXwN59 f1lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=rzGydkz8si3qdyvO/Gm/KM6ulIt55WWt7m4fqgC8Vfc=; b=h1w4MHtmCJaetaaEA1pA6WTL+P8UXdBNC+g1EY6aW10uZSRVA6KsL5pXgMIXCo15RY jguCk0J/ufUMG5jlmEIRBGKbnloz1NwsXAT7SHX7RwSQzu/pywySKZO5H+HfkkQhI4uZ L0cHWFaQEU0QO6tMgE78qETQBvkBCprZjhk7AkoxCtuCuFeEy808ksb/JcVVMTce/vyZ c5zpjDRu2xzfgD2BoBMXktLxsqfQJMPBDYyMKJLWGepUTS3A4fIFRPc8fxKieQzzHGqH ODcdsGFCXul3Ze/FHUmtZZwBCu+VYar2I5qr+PecdSbpAQfU9OMSIsQqc0cGkhCALgR7 JJHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=hDjFPgaS; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=G296r4PI; spf=neutral (google.com: 2607:7c80:54:e::133 is neither permitted nor denied by best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by mx.google.com with ESMTPS id mh15si11041517pjb.45.2021.10.15.06.15.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 06:15:53 -0700 (PDT) Received-SPF: neutral (google.com: 2607:7c80:54:e::133 is neither permitted nor denied by best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=hDjFPgaS; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=G296r4PI; spf=neutral (google.com: 2607:7c80:54:e::133 is neither permitted nor denied by best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rzGydkz8si3qdyvO/Gm/KM6ulIt55WWt7m4fqgC8Vfc=; b=hDjFPgaS+3ycp7 bKsHsQ8Ab3YSS8lwMoqM8KtNGKS7bcnZvtPwK9lAZbly5XwZ4rF6s1sk7x5WznS6W6c4Wo0cyWlzL +wRLMxDF1FIO8FYXgE49YhIKPg9lxZeH4HJbM0wGWkmE9IulMDz+WpDUNVVsKmVm1RZtjmOKz/4mF YLMAnsve7N8zGrY6FCBpm5YprWLd6nKaqErSR3+w8YsFa0h+pqPNMBKJyKFr/ZPyKIaAuexXjXidc b2MLUT8L8pEZmbwqny3ij+yXn9o/aq2oKY8G1hdZoSFEk3KNcU+UwH8KSy2pR7cMlrZ0HB6oZiobl 9IUrPj8Pm9JQrFCj837g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbN3w-007ATq-A4; Fri, 15 Oct 2021 13:15:52 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbN3s-007ARF-Eh for wcn36xx@lists.infradead.org; Fri, 15 Oct 2021 13:15:51 +0000 Received: by mail-wr1-x42e.google.com with SMTP id e12so26489626wra.4 for ; Fri, 15 Oct 2021 06:15:47 -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=gPQUXx6r43e3Va6Xi24ZwKwKL/BEA8D/kNRa5oz8574=; b=G296r4PIby4v3IZVzR/9IYrP/h0gNhSuQaY3Khm2sxUIAxlok1520KstWLMF8qgJLF /+ypUIMdu3Ay64kqhzg+U/9O7sdxnY8JMzYeoZPcqlvQ4F/j4UVIq3Gj8LQ5jj2ln4Hn AA4K68Tsce4m7t0AW+Dg3fMUmrpJpH5pINJJSxu/r4N9DbHPJQ5tlI48oFamsHs4welh 6waWm+FGs/eOGyiqG7727UwWG7WgTFZNS6iB1IYDj2n9YGP+gDCVfzaZQmHx/1PM+ipE nueGq0ZKGhVMxRXKe1En13C6RF3pA9lENdw8dAgkyREf/wfeqPUnC8Kd+PjJsqQarhQJ SFlw== 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=gPQUXx6r43e3Va6Xi24ZwKwKL/BEA8D/kNRa5oz8574=; b=SdDAVf0xxA5sd9h+s9Pira5So6Knk49j2RR7abxouawYdYO0Krs8WA83fvSehKJi5j aVr7gGEjeGdVDVfOxUneMpyuAbO3N+kmIiLhT1m1If68hcLOfyc9+ek6afr+crdC15lf 690L/S7Wv7HaQ1/krJPmJbboZnGzuxFzorG2u81DEcSELEGs1VQ9zfE51xONUYZWAEHy RyS25eC2rkQKHHsvy3A21+teWuQ7JSBYbGAG0ljTYP8OwOc+0clptQjqLEdtUdg/uBkZ ULYSr4r4H3UWZlcYNddS7sx41kYMj5n7ths9hbEUXTzG6WmHs/Ph2QVVFLBiS+JfaOq5 pOnA== X-Gm-Message-State: AOAM532kJChans56YRfzcI4MbAvyI6/FXSaP+hLh8JDP7ipaBI1M40k1 ZAFb1+FGQ+vHwajSK9WA6p67dZ29350IBg== X-Received: by 2002:adf:b31d:: with SMTP id j29mr14267046wrd.429.1634303746417; Fri, 15 Oct 2021 06:15:46 -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 e8sm7091716wrg.48.2021.10.15.06.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 06:15:45 -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, bryan.odonoghue@linaro.org Subject: [PATCH 3/4] wcn36xx: Release DMA channel descriptor allocations Date: Fri, 15 Oct 2021 14:17:40 +0100 Message-Id: <20211015131741.2455824-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211015131741.2455824-1-bryan.odonoghue@linaro.org> References: <20211015131741.2455824-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211015_061548_520788_4C9D7E4A X-CRM114-Status: UNSURE ( 8.39 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When doing a stop callback we are not releasing the DMA descriptors which we previously allocated. The start and stop callbacks can happen incrementally depending on usage. Failure to release the DMA descriptors leads to a reallocation of the DMA descriptors leaking more and more memory over time. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:42e listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: wcn36xx@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "wcn36xx" Errors-To: wcn36xx-bounces+patch=linaro.org@lists.infradead.org When doing a stop callback we are not releasing the DMA descriptors which we previously allocated. The start and stop callbacks can happen incrementally depending on usage. Failure to release the DMA descriptors leads to a reallocation of the DMA descriptors leaking more and more memory over time. 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(+) -- 2.33.0 _______________________________________________ wcn36xx mailing list wcn36xx@lists.infradead.org http://lists.infradead.org/mailman/listinfo/wcn36xx diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index 13e9a274fa26a..e89002502869a 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -1037,4 +1037,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 Fri Oct 15 13:17:41 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: 515854 Delivered-To: patch@linaro.org Received: by 2002:adf:a11e:0:0:0:0:0 with SMTP id o30csp544149wro; Fri, 15 Oct 2021 06:15:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAoKoDKLbqKBqNb9fZKisGaS9+Bc8MUt1Rv23ATml9mUwK8ZVARpc/zPdY9i8N8jATXtNt X-Received: by 2002:a62:7cd8:0:b0:44d:4574:ea8a with SMTP id x207-20020a627cd8000000b0044d4574ea8amr11736460pfc.80.1634303757044; Fri, 15 Oct 2021 06:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634303757; cv=none; d=google.com; s=arc-20160816; b=qlx8zUEr0tVSut3KITKJ65TfUQbBbTH1dmixGztK05pwSsJwaBS/i8hz7ns6lJEPtM m4XqMi0Cc7HLtU1l7Scz3euDuAghQmlrPmlt+NYJeYTqsL+K5rNnhLdPcg10rqui/T1K AqwGuqq7erfYa4ojOFPEiv7O0Ax2P/qiKueVm7tzoxN4XNnmYEkEmzUn29suvJ5NgNSB n2CHVOALQ4a1Yz6/JZn2VZh79VJq4RhJkEmTk0ZRpR7C1aK4VMsNWD+9rFGYf5o7U3+k nhpb+jgpGcgwrAeAa3a93mjPNjJ9aEwbrpXkM0H6i4wlQBS7HX3UOrpxMLpcH2acVljq 4p4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=vmB9axxt/tH89ROsnS9gEphsus5SBW4lfkahEBeA1y0=; b=VgSvRBqSZpqcgNH8tW35K8gIlVSuIZy1CRR7pnjybQBj6NEZnAic+9TufT3vIEJLSo 61S7JKe+C+vrxjGjhwkbhMAkCgSPf9VnF3LnMjppPMjal2aWA17lVzcpzEOoxpc5sbNE N4O3BmCDUHX1ABOPvY2HQnyxyNWpsn3lSr2ogtxSJjCi4373Q0oq1ZqC8OYRERqBlnYj jZUuRR1KytlWFz4KzaalMEUr4twG9ePMWND6CteY6k2ucmaIJY01aLctB1UCRKcAMX4p qSpTJc48GWRQKCFvCMpVio2W0gF2oGm/Qld213tlahfwBTa7uD/38VpRJWzcUVMQqz9i WEEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b="gO9/E6ee"; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=swD8uv4x; spf=neutral (google.com: 2607:7c80:54:e::133 is neither permitted nor denied by best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by mx.google.com with ESMTPS id n12si8436729plh.326.2021.10.15.06.15.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 06:15:57 -0700 (PDT) Received-SPF: neutral (google.com: 2607:7c80:54:e::133 is neither permitted nor denied by best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b="gO9/E6ee"; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=swD8uv4x; spf=neutral (google.com: 2607:7c80:54:e::133 is neither permitted nor denied by best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vmB9axxt/tH89ROsnS9gEphsus5SBW4lfkahEBeA1y0=; b=gO9/E6eeEv3duA U4pK5GU3L+6AXKXyZ4QIy/vS5dUkb5ahz2/apDCYDrVHUT7okTODOdob9dO1b6svOhJZzFqWxC+ki DsO84WM0IanjXzXpI1j6hbkQrnTHIYcyr8gEcHmHnEE/W/uySuozPZ2PI3U0DYyX8Kj9st69o6lNq nOvW4OuwNdrS+KRLN2t9XAdO2e0Wnam3RKVmS334yIsC3PQOFm86ekxGos3EJu23fTESwxmwHLuLm zTD3zFT9PCrCp1Knqwf86No3h2cGl07xn88FdIypvOz1sIu8OHp/fw+iHtDpp/8FqzqC+P4CL5zjs XbESTKDhHP5oKkEXGQcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbN3z-007AW5-C9; Fri, 15 Oct 2021 13:15:55 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbN3w-007ATg-HP for wcn36xx@lists.infradead.org; Fri, 15 Oct 2021 13:15:54 +0000 Received: by mail-wr1-x430.google.com with SMTP id v17so26401731wrv.9 for ; Fri, 15 Oct 2021 06:15:52 -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=6gmGyGZOX0tnnXnf/J6ROMaBVuBmbeJjJwd98SH6/w8=; b=swD8uv4xh5lHBS/mXNWezLGFNq5/+jbSkjnBi3SmewcfhfUNU6KBN8YZrf5y6P9oiG G9EqyKhBORWixMtktl3MD79UYQZfoP6fkdLOg5pYZHtJvTPynDjiabCD6dj6X6APxsY/ HOtexPglLxjkaaHuntyBwWEKbrXAlUZuLPuA5Kd58QTwkmSP59if6TPCoGu/6PXV61FU i9KintPLyAis9oqHqNBdcrzYglqklDPRnOtAO61YWH2ELneLblnYcka9NcBUbJY5MhMK aYBCQhRetRZgdH0imwVJI7mnoaRuiVboC5W49e4kwUOYjo2OLGPm0rHZePbW+BUkwWHF VqEw== 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=6gmGyGZOX0tnnXnf/J6ROMaBVuBmbeJjJwd98SH6/w8=; b=YssBkZAOl6DlUzztb9cL+zjfvr6TBZFQMEweQTQqFHvWd/Nwy8BQVQfvIl9CPt3n8W tCo1SVAGr/JrjAU04d7WGMsmvkBV832t6H+DxxC4lQcoQyiWtGOGRDWb+8RM1nZzh6PL dfJHmxMrZU3XpK1tSgeIcx10dqwkaa6UmxGhvLpKcOs/DBffMJ6LgHsrqGJCi1mQy89d Vb7wTM/GRYljB7+dLEQCZDneC3XrtV5YFXVubqYWc6O/QQYIMdAxibMeDyJhCaSW29Nm Crq2l1Rndd1GYIK7tJxuBWeKGTSz++ge96UFSUG4mHke3Hhy9EgGhqPlc6iXWyegs6ef dZmQ== X-Gm-Message-State: AOAM530AYsOQNCRywYPSla4ZEGU74qm2lvn+ObYpEzskVkY3Hw+7pDcL wrp4bFzAxO3Wvl0h1d90r+PgbkgYG7zogg== X-Received: by 2002:adf:9c02:: with SMTP id f2mr14507888wrc.329.1634303747566; Fri, 15 Oct 2021 06:15:47 -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 e8sm7091716wrg.48.2021.10.15.06.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 06:15:47 -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, bryan.odonoghue@linaro.org Subject: [PATCH 4/4] wcn36xx: Put DXE block into reset before freeing memory Date: Fri, 15 Oct 2021 14:17:41 +0100 Message-Id: <20211015131741.2455824-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211015131741.2455824-1-bryan.odonoghue@linaro.org> References: <20211015131741.2455824-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211015_061552_613661_AB885414 X-CRM114-Status: GOOD ( 13.65 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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. This is actually a pretty serious bug. Immediately after the reset we release skbs, skbs which are from the perspective of the WCNSS DXE still valid addresses for DMA. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:430 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: wcn36xx@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "wcn36xx" Errors-To: wcn36xx-bounces+patch=linaro.org@lists.infradead.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. This is actually a pretty serious bug. Immediately after the reset we release skbs, skbs which are from the perspective of the WCNSS DXE still valid addresses for DMA. Without first placing the DXE block into reset, it is possible for an upstream DMA transaction to write to skbs we have freed. We have seen some backtraces from usage in testing on 50k+ devices which indicates an invalid RX of an APs beacon to unmapped memory. The logical conclusion is that an RX transaction happened to a region of memory that was previously valid but was subsequently released. The only time such a window of opportunity exists is when we have deallocated the skbs attached to the DMA BDs in other words after doing wcn36xx_stop(). If we free the skbs on the DMA channel, we need to make sure we have quiesced potential DMA on that channel prior to freeing. This patch should eliminate that error. Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware") Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/dxe.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.33.0 _______________________________________________ wcn36xx mailing list wcn36xx@lists.infradead.org http://lists.infradead.org/mailman/listinfo/wcn36xx diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index e89002502869a..56f605c23f36c 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -1020,6 +1020,8 @@ int wcn36xx_dxe_init(struct wcn36xx *wcn) void wcn36xx_dxe_deinit(struct wcn36xx *wcn) { + int reg_data = 0; + /* 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); @@ -1035,6 +1037,10 @@ void wcn36xx_dxe_deinit(struct wcn36xx *wcn) wcn->tx_ack_skb = NULL; } + /* Put the DXE block into reset before freeing memory */ + reg_data = WCN36XX_DXE_REG_RESET; + wcn36xx_dxe_write_register(wcn, WCN36XX_DXE_REG_CSR_RESET, reg_data); + wcn36xx_dxe_ch_free_skbs(wcn, &wcn->dxe_rx_l_ch); wcn36xx_dxe_ch_free_skbs(wcn, &wcn->dxe_rx_h_ch);