Skip to contentSkip to conversation

wifi: mt76: mt7925: add AXI DMA calibration cache for MT7928

PATCH New Allan Wang 1 participant 1 message Aug 11

Subsystems (2)
lore
Share & tools
lore

Allan Wang

author
#0 lore raw

PATCH v3 1/1 wifi: mt76: mt7925: add AXI DMA calibration cache for MT7928

MT7928 supports caching calibration (fact-cal) data in a host-side DMA buffer over AXI DMA, so the firmware can reuse previously computed calibration results across warm resets instead of recomputing them on every bring-up.

Add a new cached_cal source file under mt7925/, built into mt7925e since the cache is reachable only over PCIe AXI DMA, that:
- allocates a coherent DMA region laid out for the common/group/channel fact-cal buffers plus the mapping table,
- programs the firmware with the region base/offset via the new MCU_UNI_CMD_AXIDMA command,
- builds and streams the fact-cal mapping table to the firmware via the new MCU_UNI_CMD_FACT_CAL command.

On MT7928 run-firmware, the cache is enabled only when the chip advertises MT792x_CHIP_CAP_AXIDMA_EN. A carried-over buffer that still holds FW-written cal data is reused (reused=true); a freshly allocated zeroed buffer starts cold. The region is freed on device unregister.

The buf_info and mapping-table layouts are size-asserted to match the MT7928 firmware ABI.

---

v3:
- fix the ACK handling: wait for the MCU response on every fact-cal command

v2:
- rebase onto the current mt76 tree
- tag the subject with the wireless-next prefix and advertise base-commit
- no functional change

 .../wireless/mediatek/mt76/mt76_connac_mcu.h  |   2 +
 .../wireless/mediatek/mt76/mt7925/Makefile    |   2 +-
 .../mediatek/mt76/mt7925/cached_cal.c         | 298 ++++++++++++++++++
 .../mediatek/mt76/mt7925/cached_cal.h         | 151 +++++++++
 .../wireless/mediatek/mt76/mt7925/mt7925.h    |   1 +
 .../net/wireless/mediatek/mt76/mt7925/pci.c   |  62 +++-
 .../wireless/mediatek/mt76/mt7925/pci_mac.c   |   2 +
 .../wireless/mediatek/mt76/mt7925/pci_mcu.c   |   2 +
 drivers/net/wireless/mediatek/mt76/mt792x.h   |   8 +
 9 files changed, 526 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/cached_cal.c
 create mode 100644 drivers/net/wireless/mediatek/mt76/mt7925/cached_cal.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +2 -0
index 0ededa569e9a..e46cb4ae37a9 100644
@@ -1357,9 +1357,11 @@ enum {
 	MCU_UNI_CMD_ALL_STA_INFO = 0x6e,
 	MCU_UNI_CMD_ASSERT_DUMP = 0x6f,
 	MCU_UNI_CMD_EXT_EEPROM_CTRL = 0x74,
+	MCU_UNI_CMD_FACT_CAL = 0x7c,
 	MCU_UNI_CMD_RADIO_STATUS = 0x80,
 	MCU_UNI_CMD_MLD = 0x82,
 	MCU_UNI_CMD_SDO = 0x88,
+	MCU_UNI_CMD_AXIDMA = 0xa2,
 };
 
 enum {
drivers/net/wireless/mediatek/mt76/mt7925/Makefile +1 -1
index f9dcc0bba393..33539121a15c 100644
@@ -6,5 +6,5 @@ obj-$(CONFIG_MT7925U) += mt7925u.o
 
 mt7925-common-y := mac.o mcu.o regd.o main.o init.o debugfs.o nan.o
 mt7925-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
-mt7925e-y := pci.o pci_mac.o pci_mcu.o
+mt7925e-y := pci.o pci_mac.o pci_mcu.o cached_cal.o
 mt7925u-y := usb.o
drivers/net/wireless/mediatek/mt76/mt7925/cached_cal.c new file +298 -0

298 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/cached_cal.h new file +151 -0

151 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +1 -0
index 321e732347f2..4d79c1e66e66 100644
@@ -353,6 +353,7 @@ int mt7925_mcu_parse_response(struct mt76_dev *mdev, int cmd,
 
 int mt7925e_mac_reset(struct mt792x_dev *dev);
 int mt7925e_mcu_init(struct mt792x_dev *dev);
+void mt7925e_axidma_cal_cache_init(struct mt792x_dev *dev);
 void mt7925_mac_add_txs(struct mt792x_dev *dev, void *data);
 void mt7928_mac_add_txs_msg(struct mt792x_dev *dev, void *evt);
 void mt7925_set_runtime_pm(struct mt792x_dev *dev);
drivers/net/wireless/mediatek/mt76/mt7925/pci.c +61 -1

86 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c +2 -0
index 8477d21abc66..c90f129b3a34 100644
@@ -135,6 +135,8 @@ int mt7925e_mac_reset(struct mt792x_dev *dev)
 	if (err)
 		goto out;
 
+	mt7925e_axidma_cal_cache_init(dev);
+
 	err = mt7925_mcu_set_eeprom(dev);
 	if (err)
 		goto out;
drivers/net/wireless/mediatek/mt76/mt7925/pci_mcu.c +2 -0
index 72707eddc3db..258f3753db1f 100644
@@ -46,6 +46,8 @@ int mt7925e_mcu_init(struct mt792x_dev *dev)
 	mt76_rmw_field(dev, dev->pcie_reg->pm, MT_PCIE_MAC_PM_L0S_DIS, 1);
 
 	err = mt7925_run_firmware(dev);
+	if (!err)
+		mt7925e_axidma_cal_cache_init(dev);
 
 	mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_FWDL], false);
 
drivers/net/wireless/mediatek/mt76/mt792x.h +8 -0
index 9efc251cb745..740d517eb38b 100644
@@ -33,6 +33,7 @@
 #define MT792x_CHIP_CAP_REGD_EN BIT(5)
 #define MT792x_CHIP_CAP_MLO_EN BIT(8)
 #define MT792x_CHIP_CAP_MLO_EML_EN BIT(9)
+#define MT792x_CHIP_CAP_AXIDMA_EN BIT(16)
 
 /* NOTE: used to map mt76_rates. idx may change if firmware expands table */
 #define MT792x_BASIC_RATES_TBL	14
@@ -342,6 +343,13 @@ struct mt792x_dev {
 	struct ieee80211_vif *nan_vif;
 	const struct ieee80211_iface_combination *iface_combinations;
 	int n_iface_combinations;
+
+	struct {
+		void *va;
+		dma_addr_t dma_addr;
+		u32 size;
+		bool reused;
+	} cached_cal;
 };
 
 static inline struct mt792x_bss_conf *

base-commit: 4df22710a77d2365e56d720bc4106e54c1dfa2ff

Signature · 1 line
2.45.2