rtw88: add firmware crash recovery and some fixes
cover rtw88: add firmware crash recovery and some fixes
From: Tzu-En Huang <[email protected]>
When firmware crashes, it inturrupts the driver, then driver will save its association state, restart the chip and call ieee80211_restart_hw().
The size of the rx buffer and the declared VHT capability are unmatch, which may lead to rx buffer overflow.
Add regulatory information in the tramit power table.
Tzu-En Huang (5):
rtw88: increse the size of rx buffer size
rtw88: handle and recover when firmware crash
rtw88: add dump firmware fifo support
rtw88: add dump fw crash log
rtw88: show current regulatory in tx power table
drivers/net/wireless/realtek/rtw88/debug.c | 26 ++- drivers/net/wireless/realtek/rtw88/fw.c | 86 ++++++-- drivers/net/wireless/realtek/rtw88/fw.h | 18 +- drivers/net/wireless/realtek/rtw88/mac80211.c | 81 ++------ drivers/net/wireless/realtek/rtw88/main.c | 193 ++++++++++++++++++ drivers/net/wireless/realtek/rtw88/main.h | 32 +++ drivers/net/wireless/realtek/rtw88/pci.c | 3 + drivers/net/wireless/realtek/rtw88/pci.h | 4 +- drivers/net/wireless/realtek/rtw88/reg.h | 5 + drivers/net/wireless/realtek/rtw88/rtw8822b.c | 3 + drivers/net/wireless/realtek/rtw88/rtw8822c.c | 3 + drivers/net/wireless/realtek/rtw88/util.h | 2 + 12 files changed, 372 insertions(+), 84 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/5 rtw88: increse the size of rx buffer size
From: Tzu-En Huang <[email protected]>
The vht capability of MAX_MPDU_LENGTH is 11454 in rtw88; however, the rx buffer size for each packet is 8192. When receiving packets that are larger than rx buffer size, it will leads to rx buffer ring overflow.
--- drivers/net/wireless/realtek/rtw88/pci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/pci.h +2 -2
@@ -9,8 +9,8 @@#define RTK_BEQ_TX_DESC_NUM 256#define RTK_MAX_RX_DESC_NUM 512 -/* 8K + rx desc size */ -#define RTK_PCI_RX_BUF_SIZE (8192 + 24) +/* 11K + rx desc size */ +#define RTK_PCI_RX_BUF_SIZE (11454 + 24)#define RTK_PCI_CTRL 0x300#define BIT_RST_TRXDMA_INTF BIT(20)
Signature · 1 line
2.17.1
Re: [PATCH 1/5] rtw88: increse the size of rx buffer size
Quoted 7 lines · <[email protected]> wrote:
From: Tzu-En Huang <[email protected]>
The vht capability of
MAX_MPDU_LENGTHis 11454 in rtw88; however, the rx buffer size for each packet is 8192. When receiving packets that are larger than rx buffer size, it will leads to rx buffer ring overflow.Signed-off-by Tzu-En Huang <[email protected]>
5 patches applied to wireless-drivers-next.git, thanks.
ee755732b7a1 rtw88: increse the size of rx buffer size 5c831644e1f4 rtw88: handle and recover when firmware crash 0fbc2f0f34cc rtw88: add dump firmware fifo support 714f71f94ab3 rtw88: add dump fw crash log fada09311d17 rtw88: show current regulatory in tx power table
Signature · 3 lines
https://patchwork.kernel.org/patch/11799087/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 2/5 rtw88: handle and recover when firmware crash
In reply to [email protected]From: Tzu-En Huang <[email protected]>
This handles the situation when firmware crashes.
When firmware crashes, it will send an interrupt, and driver will queue a work for recovery.
In the work, driver will reset it's internal association state, which includes removing associated sta's macid, resetting vifs' states and removing keys. After resetting the driver's state, driver will call rtw_enter_ips() to force the chipset power off to reset the chip. Finally, driver calls ieee80211_restart_hw() to inform mac80211 stack to restart.
Since only 8822c firmware supports this feature, the interrupt will only be triggered when 8822c chipset is loaded.
--- drivers/net/wireless/realtek/rtw88/fw.c | 9 ++ drivers/net/wireless/realtek/rtw88/fw.h | 1 + drivers/net/wireless/realtek/rtw88/mac80211.c | 81 +++-------- drivers/net/wireless/realtek/rtw88/main.c | 132 ++++++++++++++++++ drivers/net/wireless/realtek/rtw88/main.h | 14 ++ drivers/net/wireless/realtek/rtw88/pci.c | 3 + drivers/net/wireless/realtek/rtw88/reg.h | 3 + drivers/net/wireless/realtek/rtw88/util.h | 2 + 8 files changed, 181 insertions(+), 64 deletions(-)
drivers/net/wireless/realtek/rtw88/fw.c +9 -0
@@ -193,6 +193,15 @@ void rtw_fw_c2h_cmd_rx_irqsafe(struct rtw_dev *rtwdev, u32 pkt_offset, }EXPORT_SYMBOL (rtw_fw_c2h_cmd_rx_irqsafe); +void rtw_fw_c2h_cmd_isr (struct rtw_dev *rtwdev) +{ +if (rtw_read8 (rtwdev,REG_MCU_TST_CFG ) ==VAL_FW_TRIGGER ) +rtw_fw_recovery (rtwdev); +else +rtw_warn (rtwdev,"unhandled firmware c2h interrupt\n" ); +} +EXPORT_SYMBOL (rtw_fw_c2h_cmd_isr); +static void rtw_fw_send_h2c_command (struct rtw_dev *rtwdev,u8 *h2c) {
drivers/net/wireless/realtek/rtw88/fw.h +1 -0
@@ -564,5 +564,6 @@ void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev, struct cfg80211_ssid *ssid);void rtw_fw_channel_switch (struct rtw_dev *rtwdev,bool enable);void rtw_fw_h2c_cmd_dbg (struct rtw_dev *rtwdev,u8 *h2c); +void rtw_fw_c2h_cmd_isr (struct rtw_dev *rtwdev);#endif
drivers/net/wireless/realtek/rtw88/mac80211.c +17 -64
135 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/main.c +132 -0
144 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/main.h +14 -0
@@ -359,6 +359,7 @@ enum rtw_flags {RTW_FLAG_DIG_DISABLE ,RTW_FLAG_BUSY_TRAFFIC ,RTW_FLAG_WOWLAN , +RTW_FLAG_RESTARTING , NUM_OF_RTW_FLAGS, };
@@ -1699,6 +1700,7 @@ struct rtw_dev {/* c2h cmd queue & handler work */ struct sk_buff_head c2h_queue;struct work_struct c2h_work; +struct work_struct fw_recovery_work;/* used to protect txqs list */ spinlock_t txq_lock;
@@ -1799,6 +1801,11 @@ static inline bool rtw_chip_has_rx_ldpc(struct rtw_dev *rtwdev)return rtwdev->chip->rx_ldpc; } +static inline void rtw_release_macid (struct rtw_dev *rtwdev,u8 mac_id) +{ +clear_bit (mac_id, rtwdev->mac_id_map); +} +void rtw_get_channel_params (struct cfg80211_chan_def *chandef,struct rtw_channel_params *ch_param);bool check_hw_ready (struct rtw_dev *rtwdev,u32 addr,u32 mask,u32 target);
@@ -1821,5 +1828,12 @@ void rtw_core_deinit(struct rtw_dev *rtwdev);int rtw_register_hw (struct rtw_dev *rtwdev,struct ieee80211_hw *hw);void rtw_unregister_hw (struct rtw_dev *rtwdev,struct ieee80211_hw *hw);u16 rtw_desc_to_bitrate (u8 desc_rate); +void rtw_vif_assoc_changed (struct rtw_vif *rtwvif, +struct ieee80211_bss_conf *conf); +int rtw_sta_add (struct rtw_dev *rtwdev,struct ieee80211_sta *sta, +struct ieee80211_vif *vif); +void rtw_sta_remove (struct rtw_dev *rtwdev,struct ieee80211_sta *sta, +bool fw_exist); +void rtw_fw_recovery (struct rtw_dev *rtwdev);#endif
drivers/net/wireless/realtek/rtw88/pci.c +3 -0
@@ -389,6 +389,7 @@ static int rtw_pci_init(struct rtw_dev *rtwdev)IMR_VODOK |IMR_ROK |IMR_BCNDMAINT_E | +IMR_C2HCMD |0 ; rtwpci->irq_mask[1 ] =IMR_TXFOVW |0 ;
@@ -1079,6 +1080,8 @@ static irqreturn_t rtw_pci_interrupt_threadfn(int irq, void *dev)rtw_pci_tx_isr (rtwdev, rtwpci,RTW_TX_QUEUE_H2C );if (irq_status[0 ] &IMR_ROK )rtw_pci_rx_isr (rtwdev, rtwpci,RTW_RX_QUEUE_MPDU ); +if (unlikely (irq_status[0 ] &IMR_C2HCMD )) +rtw_fw_c2h_cmd_isr (rtwdev);/* all of the jobs for this interrupt have been done */ rtw_pci_enable_interrupt (rtwdev, rtwpci);
drivers/net/wireless/realtek/rtw88/reg.h +3 -0
@@ -126,6 +126,9 @@ BIT_WINTINI_RDY | BIT_RAM_DL_SEL)#define FW_READY_MASK 0xffff +#define REG_MCU_TST_CFG 0x84 +#define VAL_FW_TRIGGER 0x1 +#define REG_EFUSE_ACCESS 0x00CF#define EFUSE_ACCESS_ON 0x69#define EFUSE_ACCESS_OFF 0x00
drivers/net/wireless/realtek/rtw88/util.h +2 -0
@@ -17,6 +17,8 @@ struct rtw_dev; ieee80211_iterate_stations_atomic(rtwdev->hw, iterator, data)#define rtw_iterate_keys (rtwdev, vif, iterator, data) \ ieee80211_iter_keys(rtwdev->hw, vif, iterator, data) +#define rtw_iterate_keys_rcu (rtwdev, vif, iterator, data) \ + ieee80211_iter_keys_rcu((rtwdev)->hw, vif, iterator, data)static inline u8 *get_hdr_bssid (struct ieee80211_hdr *hdr) {
Signature · 1 line
2.17.1
Re: [PATCH 2/5] rtw88: handle and recover when firmware crash
Quoted 15 lines · <[email protected]> writes:
From: Tzu-En Huang <[email protected]>
This handles the situation when firmware crashes.
When firmware crashes, it will send an interrupt, and driver will queue a work for recovery.
In the work, driver will reset it's internal association state, which includes removing associated sta's macid, resetting vifs' states and removing keys. After resetting the driver's state, driver will callrtw_enter_ips()to force the chipset power off to reset the chip. Finally, driver callsieee80211_restart_hw()to inform mac80211 stack to restart.
Since only 8822c firmware supports this feature, the interrupt will only be triggered when 8822c chipset is loaded.Signed-off-by Tzu-En Huang <[email protected]>
[...]
Quoted 13 lines
drivers/net/wireless/realtek/rtw88/main.c +13
-0+int rtw_sta_add (struct rtw_dev *rtwdev,struct ieee80211_sta *sta, +struct ieee80211_vif *vif) +{ +struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv; +int i; + + si->mac_id =rtw_acquire_macid (rtwdev); +if (si->mac_id >=RTW_MAX_MAC_ID_NUM ) +return -ENOSPC ; + + si->sta = sta; + si->vif = vif; + si->init_ra_lv =1 ;
drivers/net/wireless/realtek/rtw88/main.c static void rtw_c2h_work(struct work_struct *work) · line 295
Quoted 10 lines
drivers/net/wireless/realtek/rtw88/main.c +10
-0+ewma_rssi_init (&si->avg_rssi); +for (i =0 ; i <ARRAY_SIZE (sta->txq); i++) +rtw_txq_init (rtwdev, sta->txq[i]); + +rtw_update_sta_info (rtwdev, si); +rtw_fw_media_status_report (rtwdev, si->mac_id, true); + + rtwdev->sta_cnt++; +rtw_info (rtwdev,"sta %pM joined with macid %d\n" , + sta->addr, si->mac_id);
This was already in the driver before, but I'll comment still that I find it bad practise to spam the log like this everytime a STA associates or disassociates. So I would be happy to apply a patch to change these messages to a debug message.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 3/5 rtw88: add dump firmware fifo support
In reply to [email protected]From: Tzu-En Huang <[email protected]>
Rtw88 currently has a function to dump reserved page section of the firmware fifo. Reserved page is just part of the firmware fifo, there are multiple sections in the firmware fifo for different usages, such as firmware rx fifo and tx fifo.
This commit adds a function to check not only the reserved page section but also other parts of the firmware fifo. In addition, we need to dump firmware fifo to dump the debug log message if firmware crashes.
--- drivers/net/wireless/realtek/rtw88/debug.c | 3 +- drivers/net/wireless/realtek/rtw88/fw.c | 77 +++++++++++++++---- drivers/net/wireless/realtek/rtw88/fw.h | 3 +- drivers/net/wireless/realtek/rtw88/main.h | 14 ++++ drivers/net/wireless/realtek/rtw88/rtw8822b.c | 3 + drivers/net/wireless/realtek/rtw88/rtw8822c.c | 3 + 6 files changed, 85 insertions(+), 18 deletions(-)
drivers/net/wireless/realtek/rtw88/debug.c +2 -1
@@ -229,7 +229,8 @@ static int rtw_debugfs_get_rsvd_page(struct seq_file *m, void *v)if (!buf)return -ENOMEM ; - ret =rtw_dump_drv_rsvd_page (rtwdev, offset, buf_size, (u32 *)buf); + ret =rtw_fw_dump_fifo (rtwdev,RTW_FW_FIFO_SEL_RSVD_PAGE , offset, + buf_size, (u32 *)buf);if (ret) {rtw_err (rtwdev,"failed to dump rsvd page\n" );vfree (buf);
drivers/net/wireless/realtek/rtw88/fw.c +61 -16
96 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/fw.h +2 -1
@@ -16,7 +16,6 @@#define FIFO_PAGE_SIZE_SHIFT 12#define FIFO_PAGE_SIZE 4096 -#define RSVD_PAGE_START_ADDR 0x780#define FIFO_DUMP_ADDR 0x8000#define DLFW_PAGE_SIZE_SHIFT_LEGACY 12
@@ -565,5 +564,7 @@ void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev,void rtw_fw_channel_switch (struct rtw_dev *rtwdev,bool enable);void rtw_fw_h2c_cmd_dbg (struct rtw_dev *rtwdev,u8 *h2c);void rtw_fw_c2h_cmd_isr (struct rtw_dev *rtwdev); +int rtw_fw_dump_fifo (struct rtw_dev *rtwdev,u8 fifo_sel,u32 addr,u32 size, +u32 *buffer);#endif
drivers/net/wireless/realtek/rtw88/main.h +14 -0
@@ -1083,6 +1083,17 @@ enum rtw_wlan_cpu { RTW_WCPU_11N, }; +enum rtw_fw_fifo_sel { +RTW_FW_FIFO_SEL_TX , +RTW_FW_FIFO_SEL_RX , +RTW_FW_FIFO_SEL_RSVD_PAGE , +RTW_FW_FIFO_SEL_REPORT , +RTW_FW_FIFO_SEL_LLT , +RTW_FW_FIFO_SEL_RXBUF_FW , + +RTW_FW_FIFO_MAX , +}; +/* hardware configuration for each IC */ struct rtw_chip_info {struct rtw_chip_ops *ops;
@@ -1099,6 +1110,7 @@ struct rtw_chip_info {u32 ptct_efuse_size;u32 txff_size;u32 rxff_size; +u32 fw_rxff_size;u8 band;u8 page_size;u8 csi_buf_pg_num;
@@ -1109,6 +1121,8 @@ struct rtw_chip_info {bool rx_ldpc;u8 max_power_index; +u16 fw_fifo_addr[RTW_FW_FIFO_MAX ]; +bool ht_supported;bool vht_supported;u8 lps_deep_mode_supported;
drivers/net/wireless/realtek/rtw88/rtw8822b.c +3 -0
@@ -2442,6 +2442,7 @@ struct rtw_chip_info rtw8822b_hw_spec = { .ptct_efuse_size = 96, .txff_size = 262144, .rxff_size = 24576, + .fw_rxff_size = 12288, .txgi_factor = 1, .is_pwr_by_rate_dec = true, .max_power_index = 0x3f,
@@ -2504,6 +2505,8 @@ struct rtw_chip_info rtw8822b_hw_spec = { .coex_info_hw_regs_num = ARRAY_SIZE(coex_info_hw_regs_8822b), .coex_info_hw_regs = coex_info_hw_regs_8822b, + + .fw_fifo_addr = {0x780, 0x700, 0x780, 0x660, 0x650, 0x680}, };EXPORT_SYMBOL (rtw8822b_hw_spec);
drivers/net/wireless/realtek/rtw88/rtw8822c.c +3 -0
@@ -4294,6 +4294,7 @@ struct rtw_chip_info rtw8822c_hw_spec = { .ptct_efuse_size = 124, .txff_size = 262144, .rxff_size = 24576, + .fw_rxff_size = 12288, .txgi_factor = 2, .is_pwr_by_rate_dec = false, .max_power_index = 0x7f,
@@ -4364,6 +4365,8 @@ struct rtw_chip_info rtw8822c_hw_spec = { .coex_info_hw_regs_num = ARRAY_SIZE(coex_info_hw_regs_8822c), .coex_info_hw_regs = coex_info_hw_regs_8822c, + + .fw_fifo_addr = {0x780, 0x700, 0x780, 0x660, 0x650, 0x680}, };EXPORT_SYMBOL (rtw8822c_hw_spec);
Signature · 1 line
2.17.1
Re: [PATCH 3/5] rtw88: add dump firmware fifo support
Quoted 104 lines · On Fri, Sep 25, 2020 at 02:12:17PM +0800, [email protected] wrote:
From: Tzu-En Huang <[email protected]>
Rtw88 currently has a function to dump reserved page section of the firmware fifo. Reserved page is just part of the firmware fifo, there are multiple sections in the firmware fifo for different usages, such as firmware rx fifo and tx fifo.
This commit adds a function to check not only the reserved page section but also other parts of the firmware fifo. In addition, we need to dump firmware fifo to dump the debug log message if firmware crashes.Signed-off-by Tzu-En Huang <[email protected]>--- drivers/net/wireless/realtek/rtw88/debug.c | 3 +- drivers/net/wireless/realtek/rtw88/fw.c | 77 +++++++++++++++---- drivers/net/wireless/realtek/rtw88/fw.h | 3 +- drivers/net/wireless/realtek/rtw88/main.h | 14 ++++ drivers/net/wireless/realtek/rtw88/rtw8822b.c | 3 + drivers/net/wireless/realtek/rtw88/rtw8822c.c | 3 + 6 files changed, 85 insertions(+), 18 deletions(-)drivers/net/wireless/realtek/rtw88/debug.c +2
-1@@ -229,7 +229,8 @@ static int rtw_debugfs_get_rsvd_page(struct seq_file *m, void *v)if (!buf)return -ENOMEM ; - ret =rtw_dump_drv_rsvd_page (rtwdev, offset, buf_size, (u32 *)buf); + ret =rtw_fw_dump_fifo (rtwdev,RTW_FW_FIFO_SEL_RSVD_PAGE , offset, + buf_size, (u32 *)buf);if (ret) {rtw_err (rtwdev,"failed to dump rsvd page\n" );vfree (buf);drivers/net/wireless/realtek/rtw88/fw.c +32
-16@@ -1413,29 +1413,16 @@ int rtw_fw_download_rsvd_page(struct rtw_dev *rtwdev)return ret; } -int rtw_dump_drv_rsvd_page (struct rtw_dev *rtwdev, -u32 offset,u32 size,u32 *buf) +static void rtw_fw_read_fifo_page (struct rtw_dev *rtwdev,u32 offset,u32 size, +u32 *buf,u32 residue,u16 start_pg) { -struct rtw_fifo_conf *fifo = &rtwdev->fifo; -u32 residue, i; -u16 start_pg; +u32 i;u16 idx =0 ;u16 ctl;u8 rcr; -if (size &0x3 ) { -rtw_warn (rtwdev,"should be 4-byte aligned\n" ); -return -EINVAL ; - } - - offset += fifo->rsvd_boundary <<TX_PAGE_SIZE_SHIFT ; - residue = offset & (FIFO_PAGE_SIZE -1 ); - start_pg = offset >>FIFO_PAGE_SIZE_SHIFT ; - start_pg +=RSVD_PAGE_START_ADDR ; - rcr =rtw_read8 (rtwdev,REG_RCR +2 ); ctl =rtw_read16 (rtwdev,REG_PKTBUF_DBG_CTRL ) &0xf000 ; -/* disable rx clock gate */ rtw_write8 (rtwdev,REG_RCR , rcr |BIT (3 ));@@ -1457,6 +1444,64 @@ int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev, out:rtw_write16 (rtwdev,REG_PKTBUF_DBG_CTRL , ctl);rtw_write8 (rtwdev,REG_RCR +2 , rcr); +} + +static void rtw_fw_read_fifo (struct rtw_dev *rtwdev,enum rtw_fw_fifo_sel sel, +u32 offset,u32 size,u32 *buf) +{ +struct rtw_chip_info *chip = rtwdev->chip; +u32 start_pg, residue; + +if (sel >=RTW_FW_FIFO_MAX ) { +rtw_dbg (rtwdev,RTW_DBG_FW ,"wrong fw fifo sel\n" ); +return ; + } +if (sel ==RTW_FW_FIFO_SEL_RSVD_PAGE ) + offset += rtwdev->fifo.rsvd_boundary <<TX_PAGE_SIZE_SHIFT ; + residue = offset & (FIFO_PAGE_SIZE -1 ); + start_pg = (offset >>FIFO_PAGE_SIZE_SHIFT ) + chip->fw_fifo_addr[sel]; + +rtw_fw_read_fifo_page (rtwdev, offset, size, buf, residue, start_pg); +} + +static bool rtw_fw_dump_check_size (struct rtw_dev *rtwdev, +enum rtw_fw_fifo_sel sel, +u32 start_addr,u32 size) +{ +switch (sel) { +case RTW_FW_FIFO_SEL_TX : +case RTW_FW_FIFO_SEL_RX : +if ((start_addr + size) > rtwdev->chip->fw_fifo_addr[sel]) +return false;
drivers/net/wireless/realtek/rtw88/fw.c int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev, · line 1485
Quoted 10 lines
drivers/net/wireless/realtek/rtw88/fw.c +10
-0+/*fall through*/ +default : +return true; + } +} + +int rtw_fw_dump_fifo (struct rtw_dev *rtwdev,u8 fifo_sel,u32 addr,u32 size, +u32 *buffer) +{ +if (!rtwdev->chip->fw_fifo_addr) {
This causes a clang warning, which points out it is probably not doing what you think it is:
drivers/net/wireless/realtek/rtw88/fw.c:1485:21: warning: address of array 'rtwdev->chip->fw_fifo_addr' will always evaluate to 'true' [-Wpointer-bool-conversion]
if (!rtwdev->chip->fw_fifo_addr) {
~~~~~~~~~~~~~~~^~~~~~~~~~~~1 warning generated.
Was fw_fifo_addr[0] intended or should the check just be deleted?
Cheers,
Nathan
Quoted 126 lines
drivers/net/wireless/realtek/rtw88/fw.c +19
-0+rtw_dbg (rtwdev,RTW_DBG_FW ,"chip not support dump fw fifo\n" ); +return -ENOTSUPP ; + } + +if (size ==0 || !buffer) +return -EINVAL ; + +if (size &0x3 ) { +rtw_dbg (rtwdev,RTW_DBG_FW ,"not 4byte alignment\n" ); +return -EINVAL ; + } + +if (!rtw_fw_dump_check_size (rtwdev, fifo_sel, addr, size)) { +rtw_dbg (rtwdev,RTW_DBG_FW ,"fw fifo dump size overflow\n" ); +return -EINVAL ; + } + +rtw_fw_read_fifo (rtwdev, fifo_sel, addr, size, buffer); +return 0 ; }drivers/net/wireless/realtek/rtw88/fw.h +2
-1@@ -16,7 +16,6 @@#define FIFO_PAGE_SIZE_SHIFT 12#define FIFO_PAGE_SIZE 4096 -#define RSVD_PAGE_START_ADDR 0x780#define FIFO_DUMP_ADDR 0x8000#define DLFW_PAGE_SIZE_SHIFT_LEGACY 12@@ -565,5 +564,7 @@ void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev,void rtw_fw_channel_switch (struct rtw_dev *rtwdev,bool enable);void rtw_fw_h2c_cmd_dbg (struct rtw_dev *rtwdev,u8 *h2c);void rtw_fw_c2h_cmd_isr (struct rtw_dev *rtwdev); +int rtw_fw_dump_fifo (struct rtw_dev *rtwdev,u8 fifo_sel,u32 addr,u32 size, +u32 *buffer);#endif drivers/net/wireless/realtek/rtw88/main.h +14
-0@@ -1083,6 +1083,17 @@ enum rtw_wlan_cpu { RTW_WCPU_11N, }; +enum rtw_fw_fifo_sel { +RTW_FW_FIFO_SEL_TX , +RTW_FW_FIFO_SEL_RX , +RTW_FW_FIFO_SEL_RSVD_PAGE , +RTW_FW_FIFO_SEL_REPORT , +RTW_FW_FIFO_SEL_LLT , +RTW_FW_FIFO_SEL_RXBUF_FW , + +RTW_FW_FIFO_MAX , +}; +/* hardware configuration for each IC */ struct rtw_chip_info {struct rtw_chip_ops *ops;@@ -1099,6 +1110,7 @@ struct rtw_chip_info {u32 ptct_efuse_size;u32 txff_size;u32 rxff_size; +u32 fw_rxff_size;u8 band;u8 page_size;u8 csi_buf_pg_num;@@ -1109,6 +1121,8 @@ struct rtw_chip_info {bool rx_ldpc;u8 max_power_index; +u16 fw_fifo_addr[RTW_FW_FIFO_MAX ]; +bool ht_supported;bool vht_supported;u8 lps_deep_mode_supported;drivers/net/wireless/realtek/rtw88/rtw8822b.c +3
-0@@ -2442,6 +2442,7 @@ struct rtw_chip_info rtw8822b_hw_spec = { .ptct_efuse_size = 96, .txff_size = 262144, .rxff_size = 24576, + .fw_rxff_size = 12288, .txgi_factor = 1, .is_pwr_by_rate_dec = true, .max_power_index = 0x3f,@@ -2504,6 +2505,8 @@ struct rtw_chip_info rtw8822b_hw_spec = { .coex_info_hw_regs_num = ARRAY_SIZE(coex_info_hw_regs_8822b), .coex_info_hw_regs = coex_info_hw_regs_8822b, + + .fw_fifo_addr = {0x780, 0x700, 0x780, 0x660, 0x650, 0x680}, };EXPORT_SYMBOL (rtw8822b_hw_spec);drivers/net/wireless/realtek/rtw88/rtw8822c.c +3
-0@@ -4294,6 +4294,7 @@ struct rtw_chip_info rtw8822c_hw_spec = { .ptct_efuse_size = 124, .txff_size = 262144, .rxff_size = 24576, + .fw_rxff_size = 12288, .txgi_factor = 2, .is_pwr_by_rate_dec = false, .max_power_index = 0x7f,@@ -4364,6 +4365,8 @@ struct rtw_chip_info rtw8822c_hw_spec = { .coex_info_hw_regs_num = ARRAY_SIZE(coex_info_hw_regs_8822c), .coex_info_hw_regs = coex_info_hw_regs_8822c, + + .fw_fifo_addr = {0x780, 0x700, 0x780, 0x660, 0x650, 0x680}, };EXPORT_SYMBOL (rtw8822c_hw_spec);Signature · 1 line
2.17.1
Re: [PATCH 3/5] rtw88: add dump firmware fifo support
+ arnd
Quoted 8 lines · Nathan Chancellor
drivers/net/wireless/realtek/rtw88/fw.c int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev, · line 1485
Quoted 4 lines
drivers/net/wireless/realtek/rtw88/fw.c +4
-0+int rtw_fw_dump_fifo (struct rtw_dev *rtwdev,u8 fifo_sel,u32 addr,u32 size, +u32 *buffer) +{ +if (!rtwdev->chip->fw_fifo_addr) {This causes a clang warning, which points out it is probably not doing what you think it is:
Quoted 8 lines
drivers/net/wireless/realtek/rtw88/fw.c:1485:21: warning: address of array 'rtwdev->chip->fw_fifo_addr' will always evaluate to 'true' [-Wpointer-bool-conversion]if (!rtwdev->chip->fw_fifo_addr) { ~~~~~~~~~~~~~~~^~~~~~~~~~~~1 warning generated.
Was fw_fifo_addr[0] intended or should the check just be deleted?
BTW what is the easiest way to install clang for build testing the kernel? For GCC I use crosstool[1] which is awesome as it makes the installation so simple, do we have something similar for clang?
Just supporting x86 would be fine, as my use case would be just to reproduce build warnings.
[1] https://mirrors.edge.kernel.org/pub/tools/crosstool/
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH 3/5] rtw88: add dump firmware fifo support
Quoted 21 lines · Kalle Valo
+ arnd
Quoted 8 lines · Nathan Chancellor
drivers/net/wireless/realtek/rtw88/fw.c int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev, · line 1485
Quoted 4 lines
drivers/net/wireless/realtek/rtw88/fw.c +4
-0+int rtw_fw_dump_fifo (struct rtw_dev *rtwdev,u8 fifo_sel,u32 addr,u32 size, +u32 *buffer) +{ +if (!rtwdev->chip->fw_fifo_addr) {This causes a clang warning, which points out it is probably not doing what you think it is:
Quoted 8 lines
drivers/net/wireless/realtek/rtw88/fw.c:1485:21: warning: address of array 'rtwdev->chip->fw_fifo_addr' will always evaluate to 'true' [-Wpointer-bool-conversion]if (!rtwdev->chip->fw_fifo_addr) { ~~~~~~~~~~~~~~~^~~~~~~~~~~~1 warning generated.
Was fw_fifo_addr[0] intended or should the check just be deleted?
Quoted 13 lines
BTW what is the easiest way to install clang for build testing the kernel? For GCC I use crosstool[1] which is awesome as it makes the installation so simple, do we have something similar for clang?
Just supporting x86 would be fine, as my use case would be just to reproduce build warnings.
[1] https://mirrors.edge.kernel.org/pub/tools/crosstool/
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Unfortunately, we do not have anything for clang right now. It is on my TODO list but being a hobbyist, I have less time than I would like...
If you do not mind building it from source, I maintain a Python script that tries to optimize building LLVM as much as possible by turning off things that the kernel does not care about so that the build is quick and it does not intrude or interfere with the host environment.
Something like this should work to give you a stable clang toolchain that should work well for compiling the kernel:
$ git clone https://github.com/ClangBuiltLinux/tc-build $ tc-build/build-llvm.py \ --branch llvmorg-11.0.0-rc5 \ --projects "clang;lld" $ tc-build/install/bin/clang --version | head -1 ClangBuiltLinux clang version 11.0.0 (https://github.com/llvm/llvm-project 60a25202a7dd1e00067fcfce512086ebf3788537)
The script by default does a 2-stage build for optimization purposes; if you cannot spare many cycles, feel free to add
--build-stage1-only --install-stage1-only
to the build-llvm.py invocation. The toolchain is installed to "install" within the tc-build repo and it only requires a few external dependencies (outlined in the README) that it lets you know about before doing anything. Feel free to give it a shot and let me know if anything is broken. Otherwise, as long as your distribution has clang 10.0.1 or newer, it should be fine for compiling the kernel.
Cheers,
Nathan
Re: [PATCH 3/5] rtw88: add dump firmware fifo support
Quoted 59 lines · Nathan Chancellor
Quoted 21 lines · Kalle Valo
+ arnd
Quoted 8 lines · Nathan Chancellor
drivers/net/wireless/realtek/rtw88/fw.c int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev, · line 1485
Quoted 4 lines
drivers/net/wireless/realtek/rtw88/fw.c +4
-0+int rtw_fw_dump_fifo (struct rtw_dev *rtwdev,u8 fifo_sel,u32 addr,u32 size, +u32 *buffer) +{ +if (!rtwdev->chip->fw_fifo_addr) {This causes a clang warning, which points out it is probably not doing what you think it is:
Quoted 8 lines
drivers/net/wireless/realtek/rtw88/fw.c:1485:21: warning: address of array 'rtwdev->chip->fw_fifo_addr' will always evaluate to 'true' [-Wpointer-bool-conversion]if (!rtwdev->chip->fw_fifo_addr) { ~~~~~~~~~~~~~~~^~~~~~~~~~~~1 warning generated.
Was fw_fifo_addr[0] intended or should the check just be deleted?
Quoted 13 lines
BTW what is the easiest way to install clang for build testing the kernel? For GCC I use crosstool[1] which is awesome as it makes the installation so simple, do we have something similar for clang?
Just supporting x86 would be fine, as my use case would be just to reproduce build warnings.
[1] https://mirrors.edge.kernel.org/pub/tools/crosstool/
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatchesUnfortunately, we do not have anything for clang right now. It is on my TODO list but being a hobbyist, I have less time than I would like...
If you do not mind building it from source, I maintain a Python script that tries to optimize building LLVM as much as possible by turning off things that the kernel does not care about so that the build is quick and it does not intrude or interfere with the host environment.
Something like this should work to give you a stable clang toolchain that should work well for compiling the kernel:
$ git clone https://github.com/ClangBuiltLinux/tc-build $ tc-build/build-llvm.py \ --branch llvmorg-11.0.0-rc5 \ --projects "clang;lld" $ tc-build/install/bin/clang --version | head -1 ClangBuiltLinux clang version 11.0.0 (https://github.com/llvm/llvm-project 60a25202a7dd1e00067fcfce512086ebf3788537)The script by default does a 2-stage build for optimization purposes; if you cannot spare many cycles, feel free to add
Quoted 7 lines
--build-stage1-only --install-stage1-only
to the
build-llvm.pyinvocation. The toolchain is installed to "install" within the tc-build repo and it only requires a few external dependencies (outlined in the README) that it lets you know about before doing anything. Feel free to give it a shot and let me know if anything is broken.
Thanks, I'll try that when I have some free time.
Quoted 2 lines
Otherwise, as long as your distribution has clang 10.0.1 or newer, it should be fine for compiling the kernel.
Good to know. My distro is old so I only have clang-8 available :)
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 4/5 rtw88: add dump fw crash log
In reply to [email protected]From: Tzu-En Huang <[email protected]>
This patch adds a function which is able to dump firmware fifo when firmware crashes. If firmware needs more than one time to dump all logs, it will set a bit called "more bit" in the header of the first log, and driver needs to set a register to inform firmware that it is ready for the next dump.
--- drivers/net/wireless/realtek/rtw88/fw.h | 14 ++++++ drivers/net/wireless/realtek/rtw88/main.c | 61 +++++++++++++++++++++++ drivers/net/wireless/realtek/rtw88/main.h | 4 ++ drivers/net/wireless/realtek/rtw88/reg.h | 2 + 4 files changed, 81 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.h +14 -0
@@ -507,6 +507,20 @@ static inline void rtw_h2c_pkt_set_header(u8 *h2c_pkt, u8 sub_id)#define SET_NLO_LOC_NLO_INFO (h2c_pkt, value) \ le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16)) +#define GET_FW_DUMP_LEN (_header) \ + le32_get_bits(*((__le32 *)(_header) + 0x00), GENMASK(15, 0)) +#define GET_FW_DUMP_SEQ (_header) \ + le32_get_bits(*((__le32 *)(_header) + 0x00), GENMASK(22, 16)) +#define GET_FW_DUMP_MORE (_header) \ + le32_get_bits(*((__le32 *)(_header) + 0x00), BIT(23)) +#define GET_FW_DUMP_VERSION (_header) \ + le32_get_bits(*((__le32 *)(_header) + 0x00), GENMASK(31, 24)) +#define GET_FW_DUMP_TLV_TYPE (_header) \ + le32_get_bits(*((__le32 *)(_header) + 0x01), GENMASK(15, 0)) +#define GET_FW_DUMP_TLV_LEN (_header) \ + le32_get_bits(*((__le32 *)(_header) + 0x01), GENMASK(31, 16)) +#define GET_FW_DUMP_TLV_VAL (_header) \ + le32_get_bits(*((__le32 *)(_header) + 0x02), GENMASK(31, 0))static inline struct rtw_c2h_cmd *get_c2h_from_skb (struct sk_buff *skb) {u32 pkt_offset;
drivers/net/wireless/realtek/rtw88/main.c +61 -0
73 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/main.h +4 -0
@@ -1621,6 +1621,9 @@ struct rtw_fifo_conf {const struct rtw_rqpn *rqpn; }; +#define FW_CD_TYPE 0xffff +#define FW_CD_LEN 4 +#define FW_CD_VAL 0xaabbccddstruct rtw_fw_state {const struct firmware *firmware;struct rtw_dev *rtwdev;
@@ -1629,6 +1632,7 @@ struct rtw_fw_state {u8 sub_version;u8 sub_index;u16 h2c_version; +u8 prev_dump_seq; };struct rtw_hal {
drivers/net/wireless/realtek/rtw88/reg.h +2 -0
@@ -619,6 +619,8 @@#define BIT_ANAPAR_BTPS BIT(22)#define REG_RSTB_SEL 0x1c38 +#define REG_HRCV_MSG 0x1cf +#define REG_IGN_GNTBT4 0x4160#define RF_MODE 0x00
Signature · 1 line
2.17.1
PATCH 5/5 rtw88: show current regulatory in tx power table
In reply to [email protected]From: Tzu-En Huang <[email protected]>
In the transmit power table, it is important to know what the regulatory currently is. For different regulatories, there are different transmit power limits. Show which regulatory the driver is currently using.
--- drivers/net/wireless/realtek/rtw88/debug.c | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/net/wireless/realtek/rtw88/debug.c +23 -0
@@ -544,6 +544,28 @@ static void rtw_print_rate(struct seq_file *m, u8 rate) } } +#define case_REGD (src) \ + case RTW_REGD_##src: return #src + +static const char *rtw_get_regd_string (u8 regd) +{ +switch (regd) { +case_REGD (FCC ); +case_REGD (MKK ); +case_REGD (ETSI ); +case_REGD (IC ); +case_REGD (KCC ); +case_REGD (ACMA ); +case_REGD (CHILE ); +case_REGD (UKRAINE ); +case_REGD (MEXICO ); +case_REGD (CN ); +case_REGD (WW ); +default : +return "Unknown" ; + } +} +static int rtw_debugfs_get_tx_pwr_tbl (struct seq_file *m,void *v) {struct rtw_debugfs_priv *debugfs_priv = m->private;
@@ -555,6 +577,7 @@ static int rtw_debugfs_get_tx_pwr_tbl(struct seq_file *m, void *v)u8 ch = hal->current_channel;u8 regd = rtwdev->regd.txpwr_regd; +seq_printf (m,"regulatory: %s\n" ,rtw_get_regd_string (regd));seq_printf (m,"%-4s %-10s %-3s%6s %-4s %4s (%-4s %-4s) %-4s\n" ,"path" ,"rate" ,"pwr" ,"" ,"base" ,"" ,"byr" ,"lmt" ,"rem" );
Signature · 1 line
2.17.1
Re: [PATCH 5/5] rtw88: show current regulatory in tx power table
Quoted 8 lines · <[email protected]> writes:
From: Tzu-En Huang <[email protected]>
In the transmit power table, it is important to know what the regulatory currently is. For different regulatories, there are different transmit power limits. Show which regulatory the driver is currently using.
Change-Id: Id92aa6a833053fbf0b065c9ff946d7d4722897fd
No Change-Id tags, but I can remove it during commit. No need to resend just because of this.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches