From patchwork Thu Jan 18 19:52:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 763891 Received: from nbd.name (nbd.name [46.4.11.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD9672E638 for ; Thu, 18 Jan 2024 20:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705609481; cv=none; b=IQxI23RLC+K6oUqsPv2eMTZwXoj8HZ6ys2dejbCWlMDOqvYTepPFGFARuSnAkEc7VLvD8WErLT9liSFypQq9VUb0l68Wt0WL1hyklrmgPhoNjagjOi/6bdyDY4shzdNJgu3m6TdZ1WMPESuOZfk3rVLCm7pveBCAFycNdVn//sA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705609481; c=relaxed/simple; bh=RI1aKO6DhMyb5MqETo1O88T+LB4RYxLVROc+0gI05zo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=r1wAOA5ZIpBfGXltMNTO3eVNJc8ENZiwd48IPPauI++IykMLd7TjPUUSM7ncSN3CGR8/tgzWdyVdHhRO7Rppzpp8r+Op6TisDYsicFcTYDl2hwyGoNxC77MJ10RINa+A4bsUuhLjY4fo7bYW6dScpy2lmquaS77W6qyq54f3BJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=none smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=CJ4b1r0x; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=nbd.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="CJ4b1r0x" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6tkEcJFhqIhXum4DqljO2a94J18fHHSMslWTe3EccPw=; b=CJ4b1r0xPn1GWWa9R+46crsZ0K H4vZGf9TrHVvHHjkYJltbAxPNIT0BcNT74nTK1enu4GYYp4W4L7/KZtefikqIUjkbOs1+fTfOwp/W 8unoU3C/OWxDmk9LVGOMM7uHutf2HJn+dW5Kod5JN2Z4aua2QeQPE/Jvyg0Ve2ylY378=; Received: from p200300daa7090900680536e7cb8d8cd3.dip0.t-ipconnect.de ([2003:da:a709:900:6805:36e7:cb8d:8cd3] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1rQYQy-0054tJ-LJ; Thu, 18 Jan 2024 20:52:16 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: Peter Chiu Subject: [PATCH 1/5] wifi: mt76: disable HW AMSDU when using fixed rate Date: Thu, 18 Jan 2024 20:52:12 +0100 Message-ID: <20240118195216.80974-1-nbd@nbd.name> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Chiu When using fixed rate, HW uses txd DW9 to store tx arrivial time if VTA is set. It would overwrite the msdu_id in txd and lead to token pending if amsdu is enable. Signed-off-by: Peter Chiu Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c index c7914643e9c0..630c6402ec25 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c @@ -544,7 +544,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, val = FIELD_PREP(MT_TXD5_PID, pid); if (pid >= MT_PACKET_ID_FIRST) { val |= MT_TXD5_TX_STATUS_HOST; - amsdu_en = amsdu_en && !is_mt7921(dev); + amsdu_en = 0; } txwi[5] = cpu_to_le32(val); @@ -579,6 +579,8 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi, spe_idx = 24 + phy_idx; txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, spe_idx)); } + + txwi[7] &= ~cpu_to_le32(MT_TXD7_HW_AMSDU); } } EXPORT_SYMBOL_GPL(mt76_connac2_mac_write_txwi); From patchwork Thu Jan 18 19:52:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 764242 Received: from nbd.name (nbd.name [46.4.11.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64C912E63B for ; Thu, 18 Jan 2024 20:24:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705609476; cv=none; b=DoI6wf+4xFbYTMnOuSgRHnqAU1jmbic73XuK0EVu6fkmO/JrczHFQYC8llV9glJqYmv/ZBpQxEP6i3z59eLaySmiDMOTCWy8QQgWg4BAtWASSMj7pejvYr3561oH7Yatws7V0LgbwIyngNeCCzXVfU9ccRXaSDyKpCZ2RaVFkRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705609476; c=relaxed/simple; bh=1r+mdaZq+yNTakzipJ+ui54CtKQ1IBnAtt8vq8jvkYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AeBcBYqQYpNP0rJguRE33tPE2NjAdUqJDusglZDvTYVm0SYWrjhaUHZZ3/a45tCr0UaV1HK+9FCcufwgMZnVnQGJY+xx0ehsa7VNWAkn8vaTw1RBHFBjk4HLjNEuj43GmIWe8JKjf7W9NEBkhTIN/zRfY4eef+PpugJjDQgrB38= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=none smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=NLRxCP8a; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=nbd.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="NLRxCP8a" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=26SlX6N5+Pz/rWkz1+xOTiqMeWMakt0FpigpxeykWEM=; b=NLRxCP8aTEDGpb139IPjVpiNos i4MHA45GxAJIy5MKV+470AJItbOksnqpfOHBy7hTwIqSv9S1k7PgsmqRtundJte+1D7sblKUmH00J ZvgPQVeC2sOKshgdtOKBrLx60KjjzDfo4NTndtsGLe+a5qWACCf/BB5jYqxymVyxV5bs=; Received: from p200300daa7090900680536e7cb8d8cd3.dip0.t-ipconnect.de ([2003:da:a709:900:6805:36e7:cb8d:8cd3] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1rQYQy-0054tJ-Rl; Thu, 18 Jan 2024 20:52:16 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: Peter Chiu Subject: [PATCH 2/5] wifi: mt76: check txs format before getting skb by pid Date: Thu, 18 Jan 2024 20:52:13 +0100 Message-ID: <20240118195216.80974-2-nbd@nbd.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118195216.80974-1-nbd@nbd.name> References: <20240118195216.80974-1-nbd@nbd.name> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Chiu The PPDU TxS does not include the error bit so it cannot use to report status to mac80211. Signed-off-by: Peter Chiu Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt76_connac2_mac.h | 5 +++++ drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac2_mac.h b/drivers/net/wireless/mediatek/mt76/mt76_connac2_mac.h index bd2a92467a97..5f132115ebfc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac2_mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac2_mac.h @@ -32,6 +32,11 @@ enum { MT_LMAC_PSMP0, }; +enum { + MT_TXS_MPDU_FMT = 0, + MT_TXS_PPDU_FMT = 2, +}; + #define MT_TX_FREE_MSDU_CNT GENMASK(9, 0) #define MT_TX_FREE_WLAN_ID GENMASK(23, 14) #define MT_TX_FREE_COUNT GENMASK(12, 0) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c index 630c6402ec25..b841bf628d02 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c @@ -716,6 +716,9 @@ bool mt76_connac2_mac_add_txs_skb(struct mt76_dev *dev, struct mt76_wcid *wcid, struct sk_buff_head list; struct sk_buff *skb; + if (le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT) == MT_TXS_PPDU_FMT) + return false; + mt76_tx_status_lock(dev, &list); skb = mt76_tx_status_skb_get(dev, wcid, pid, &list); if (skb) { From patchwork Thu Jan 18 19:52:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 763892 Received: from nbd.name (nbd.name [46.4.11.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D0592E650 for ; Thu, 18 Jan 2024 20:24:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705609470; cv=none; b=GAYcfCvWWqneaneoyAGu/s3D179R8eTPoN5j047enCJR16LrCpfDzuLXJlivJOkSMSUdvFqBLg+Aq8Mra6u6LfdPFVszMm35vrIdm3IWyIsu0axIMRLeUGDqSi5zSYx3PmEsMv7R7pJZYDVB88WSh7Z1JWQdw7UQPm+vcs0gODo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705609470; c=relaxed/simple; bh=o/GY+3kLDIGwB7enL0iyA1BkpUidxFI98NcIW3WkRrk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NvBBkh8cSh5H6gxzOGWeXF3zVdvlPg+C7kgwzc9nBsKpAnzvQoTJiTyw3LpNfzyf8lNy7z66Gx4cJ69yOnutvH1J7dxfak8SIMfzuT8jVHjMOEpJm8qxOWbIv2HV3XMS3ilnszqST1tE4mjFb9Ei/Kt06lahj3Ng72xEd+I4Q40= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=none smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=cfMVRYQo; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=nbd.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="cfMVRYQo" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=O5pFZlFuGXTjnRDTH6yNouSKV4frCuDHNN0xl6h5Vl8=; b=cfMVRYQofz7cbIUJgwBbxZf6Su GVNgYlVjycq32ApKdyMNfORyoS6m4L2pw5PKq17z5Uh9RIrwsaCImDJFYVmbO42z2rDHrVVYYFFcV KniWznl9uqKw83EKdYSnyrrOhhJ0nmLdV1bBK24OMKVeIz8gsrdeg2fd+15GgXsnr/FI=; Received: from p200300daa7090900680536e7cb8d8cd3.dip0.t-ipconnect.de ([2003:da:a709:900:6805:36e7:cb8d:8cd3] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1rQYQz-0054tJ-14 for linux-wireless@vger.kernel.org; Thu, 18 Jan 2024 20:52:17 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 3/5] wifi: mt76: mt7915: fix error recovery with WED enabled Date: Thu, 18 Jan 2024 20:52:14 +0100 Message-ID: <20240118195216.80974-3-nbd@nbd.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118195216.80974-1-nbd@nbd.name> References: <20240118195216.80974-1-nbd@nbd.name> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Do not clear the interrupt mask register on MT7915, since that prevents MCU_CMD interrupts from being reported, thus causing timeouts during the reset sequence. Defer stopping WED until tx/rx processing activity has stopped. Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index b01edbed969c..e45361111f9b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1520,12 +1520,6 @@ void mt7915_mac_reset_work(struct work_struct *work) if (!(READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA)) return; - if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { - mtk_wed_device_stop(&dev->mt76.mmio.wed); - if (!is_mt798x(&dev->mt76)) - mt76_wr(dev, MT_INT_WED_MASK_CSR, 0); - } - ieee80211_stop_queues(mt76_hw(dev)); if (ext_phy) ieee80211_stop_queues(ext_phy->hw); @@ -1545,6 +1539,9 @@ void mt7915_mac_reset_work(struct work_struct *work) mutex_lock(&dev->mt76.mutex); + if (mtk_wed_device_active(&dev->mt76.mmio.wed)) + mtk_wed_device_stop(&dev->mt76.mmio.wed); + mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_DMA_STOPPED); if (mt7915_wait_reset_state(dev, MT_MCU_CMD_RESET_DONE)) { From patchwork Thu Jan 18 19:52:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 764243 Received: from nbd.name (nbd.name [46.4.11.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F44C1B96A for ; Thu, 18 Jan 2024 20:24:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705609466; cv=none; b=i5w1lc6oaakAZyXjJ/kn1WHnc1QDfCdhh7PqJ3JFkSrvICrXIMXhwMaJmr4tnpctjMfceHqYV+vGv0YdJw6rvSAUSfwXMwuWX/5ipoTxuZ6u7LQMGNl+tT/i+sPDNOk8U6mjs7h765Bs+Yw2jqGUBXYyOFGOED4vdiSTp0Oa0d8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705609466; c=relaxed/simple; bh=gdx9D6e9HCsQk6lirjvtmenTzWkKtii8/V5ifZHXOK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dk8B9WMN7fHEhxqN5gBJ9I/kUd8KgBpDg40pMReLIElUVlNFpPHNdjhWSS9aFMzuapEIqNsf1fv5NsPshBbAne0xZEZ1GfjSbJyyjedyj21wa8KhlmvI2gldeFLwuzq5EG6TWx6+OusqoDKKs0dkTOYoZyHnPQf9uPGnb3cPUWA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=none smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=PcmQj4Jr; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=nbd.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="PcmQj4Jr" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=2zaiAQegrb7sxTbZzD9E1p1jA7PFDM4qXDv9SwRT+rU=; b=PcmQj4JrCYpk9mFLJB74h7KS8X VHvIpPKTAP1eaOAXxzh7ERfD5Y59P5pLwemO6/oScC3XP57zed1Px8Cd42CxlC1Nqvj/ftq6LWSDN FhzA0U2NVWSL0jfmqakGnB/s7xhjGLg5SYIH6HNOZ3svuqQdxbOVBMFVvwLT01OgByDM=; Received: from p200300daa7090900680536e7cb8d8cd3.dip0.t-ipconnect.de ([2003:da:a709:900:6805:36e7:cb8d:8cd3] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1rQYQz-0054tJ-7H; Thu, 18 Jan 2024 20:52:17 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: Shayne Chen Subject: [PATCH 4/5] wifi: mt76: mt7915: add locking for accessing mapped registers Date: Thu, 18 Jan 2024 20:52:15 +0100 Message-ID: <20240118195216.80974-4-nbd@nbd.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118195216.80974-1-nbd@nbd.name> References: <20240118195216.80974-1-nbd@nbd.name> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shayne Chen Sicne the mapping is global, mapped register access needs to be protected against concurrent access, otherwise a race condition might cause the reads or writes to go towards the wrong register Signed-off-by: Shayne Chen Signed-off-by: Peter Chiu Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7915/mmio.c | 45 ++++++++++++++++--- .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 + 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c index aff4f21e843d..cea2a31ae138 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c @@ -490,6 +490,11 @@ static u32 __mt7915_reg_addr(struct mt7915_dev *dev, u32 addr) return dev->reg.map[i].maps + ofs; } + return 0; +} + +static u32 __mt7915_reg_remap_addr(struct mt7915_dev *dev, u32 addr) +{ if ((addr >= MT_INFRA_BASE && addr < MT_WFSYS0_PHY_START) || (addr >= MT_WFSYS0_PHY_START && addr < MT_WFSYS1_PHY_START) || (addr >= MT_WFSYS1_PHY_START && addr <= MT_WFSYS1_PHY_END)) @@ -514,15 +519,30 @@ void mt7915_memcpy_fromio(struct mt7915_dev *dev, void *buf, u32 offset, { u32 addr = __mt7915_reg_addr(dev, offset); - memcpy_fromio(buf, dev->mt76.mmio.regs + addr, len); + if (addr) { + memcpy_fromio(buf, dev->mt76.mmio.regs + addr, len); + return; + } + + spin_lock_bh(&dev->reg_lock); + memcpy_fromio(buf, dev->mt76.mmio.regs + + __mt7915_reg_remap_addr(dev, offset), len); + spin_unlock_bh(&dev->reg_lock); } static u32 mt7915_rr(struct mt76_dev *mdev, u32 offset) { struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); - u32 addr = __mt7915_reg_addr(dev, offset); + u32 addr = __mt7915_reg_addr(dev, offset), val; - return dev->bus_ops->rr(mdev, addr); + if (addr) + return dev->bus_ops->rr(mdev, addr); + + spin_lock_bh(&dev->reg_lock); + val = dev->bus_ops->rr(mdev, __mt7915_reg_remap_addr(dev, offset)); + spin_unlock_bh(&dev->reg_lock); + + return val; } static void mt7915_wr(struct mt76_dev *mdev, u32 offset, u32 val) @@ -530,7 +550,14 @@ static void mt7915_wr(struct mt76_dev *mdev, u32 offset, u32 val) struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); u32 addr = __mt7915_reg_addr(dev, offset); - dev->bus_ops->wr(mdev, addr, val); + if (addr) { + dev->bus_ops->wr(mdev, addr, val); + return; + } + + spin_lock_bh(&dev->reg_lock); + dev->bus_ops->wr(mdev, __mt7915_reg_remap_addr(dev, offset), val); + spin_unlock_bh(&dev->reg_lock); } static u32 mt7915_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val) @@ -538,7 +565,14 @@ static u32 mt7915_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val) struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); u32 addr = __mt7915_reg_addr(dev, offset); - return dev->bus_ops->rmw(mdev, addr, mask, val); + if (addr) + return dev->bus_ops->rmw(mdev, addr, mask, val); + + spin_lock_bh(&dev->reg_lock); + val = dev->bus_ops->rmw(mdev, __mt7915_reg_remap_addr(dev, offset), mask, val); + spin_unlock_bh(&dev->reg_lock); + + return val; } #ifdef CONFIG_NET_MEDIATEK_SOC_WED @@ -707,6 +741,7 @@ static int mt7915_mmio_init(struct mt76_dev *mdev, dev = container_of(mdev, struct mt7915_dev, mt76); mt76_mmio_init(&dev->mt76, mem_base); + spin_lock_init(&dev->reg_lock); switch (device_id) { case 0x7915: diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 4727d9c7b11d..6e79bc65f5a5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -287,6 +287,7 @@ struct mt7915_dev { struct list_head sta_rc_list; struct list_head twt_list; + spinlock_t reg_lock; u32 hw_pattern; From patchwork Thu Jan 18 19:52:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 764244 Received: from nbd.name (nbd.name [46.4.11.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 440AA31758 for ; Thu, 18 Jan 2024 20:01:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705608076; cv=none; b=DwYdsAAATxFO8CnbfganeR4Q0o3wuznCu+cwhLVM693S74ACVVa//idSdkn1zdJTxCgTp64M36OKhS1bQagQU+tk0Iv+S6VPfEZkTd3q69xPA99zoN4KaWuKUHGuM+VpAhmT7ZM/i0q7pH1fhcLoyW5JEQiZR2OdKuT0J8WO7hA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705608076; c=relaxed/simple; bh=/vTfgtyVYDExTkSgyEoSylFpYPMk6fjG/H8qj1PWuJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NpoCOPywRXtUqZqpD3k15hAEo02DBJXtWFbt3+wjUJyHH5RLpSmiuuXa3Ijral/s7KXYNqtRAAPtVIPNC7JBQYLcGgDVOXRoUVk1Y6ocFpYc7ztflg/tOqZQlkdVkEX387WsVN2e1H4y0afg3PaGrIbfUfy+snTPbx3pRKXb95k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=none smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=nOxFdn9K; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=nbd.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="nOxFdn9K" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=nFPRCsAoE0PWSCm07IF+LFbJmh9UozGQwWBa+8jVUC0=; b=nOxFdn9KwjHzpx8ucyP+8dD+x1 8QIXjKKgtBMYt3yq3MlKVpVsqM74gIA7A3yMc5Bt0leZvobyuDRMaV6ScZSGLOT+zAIYWyjqySCgV jp82qa2dDJgUr1dQyr2o4spsJVXJbPGZcYUc/HRH/osj+FU8cUC2no249VXGzhn5YQEs=; Received: from p200300daa7090900680536e7cb8d8cd3.dip0.t-ipconnect.de ([2003:da:a709:900:6805:36e7:cb8d:8cd3] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1rQYQz-0054tJ-DZ; Thu, 18 Jan 2024 20:52:17 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: Peter Chiu Subject: [PATCH 5/5] wifi: mt76: mt7915: update mt798x_wmac_adie_patch_7976 Date: Thu, 18 Jan 2024 20:52:16 +0100 Message-ID: <20240118195216.80974-5-nbd@nbd.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118195216.80974-1-nbd@nbd.name> References: <20240118195216.80974-1-nbd@nbd.name> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Chiu Add support for a newer ADIE version Signed-off-by: Peter Chiu Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7915/soc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/soc.c b/drivers/net/wireless/mediatek/mt76/mt7915/soc.c index 8b4809703efc..f5b99917c08e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/soc.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/soc.c @@ -516,7 +516,8 @@ static int mt798x_wmac_adie_patch_7976(struct mt7915_dev *dev, u8 adie) if (ret) return ret; - if (version == 0x8a00 || version == 0x8a10 || version == 0x8b00) { + if (version == 0x8a00 || version == 0x8a10 || + version == 0x8b00 || version == 0x8c10) { rg_xo_01 = 0x1d59080f; rg_xo_03 = 0x34c00fe0; } else {