From 762fd1aec588f71873c75b6473eb1736b3a21f4d Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 27 Oct 2020 14:38:07 +0200 Subject: [PATCH 001/180] ath10k: remove repeated words in comments Found by latest checkpatch. Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1603802288-21158-1-git-send-email-kvalo@codeaurora.org --- drivers/net/wireless/ath/ath10k/core.c | 2 +- drivers/net/wireless/ath/ath10k/debug.c | 2 +- drivers/net/wireless/ath/ath10k/mac.c | 2 +- drivers/net/wireless/ath/ath10k/rx_desc.h | 2 +- drivers/net/wireless/ath/ath10k/sdio.c | 2 +- drivers/net/wireless/ath/ath10k/wmi.h | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index d73ad60b571c..419b06b974c5 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -2636,7 +2636,7 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode, if (status) goto err; - /* Some of of qca988x solutions are having global reset issue + /* Some of qca988x solutions are having global reset issue * during target initialization. Bypassing PLL setting before * downloading firmware and letting the SoC run on REF_CLK is * fixing the problem. Corresponding firmware change is also diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index e8250a665433..b72cd81fdc79 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -1764,7 +1764,7 @@ static ssize_t ath10k_write_simulate_radar(struct file *file, struct ath10k *ar = file->private_data; struct ath10k_vif *arvif; - /* Just check for for the first vif alone, as all the vifs will be + /* Just check for the first vif alone, as all the vifs will be * sharing the same channel and if the channel is disabled, all the * vifs will share the same 'is_started' state. */ diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 2e3eb5bbe49c..c857cf46832d 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -5457,7 +5457,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, /* Some firmware revisions don't wait for beacon tx completion before * sending another SWBA event. This could lead to hardware using old * (freed) beacon data in some cases, e.g. tx credit starvation - * combined with missed TBTT. This is very very rare. + * combined with missed TBTT. This is very rare. * * On non-IOMMU-enabled hosts this could be a possible security issue * because hw could beacon some random data on the air. On diff --git a/drivers/net/wireless/ath/ath10k/rx_desc.h b/drivers/net/wireless/ath/ath10k/rx_desc.h index dec1582005b9..f2b6bf8f0d60 100644 --- a/drivers/net/wireless/ath/ath10k/rx_desc.h +++ b/drivers/net/wireless/ath/ath10k/rx_desc.h @@ -68,7 +68,7 @@ struct rx_attention { * first_msdu is set. * * peer_idx_invalid - * Indicates no matching entries within the the max search + * Indicates no matching entries within the max search * count. Only set when first_msdu is set. * * peer_idx_timeout diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index 81ddaafb6721..59043ec44ca3 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -1248,7 +1248,7 @@ static int ath10k_sdio_bmi_exchange_msg(struct ath10k *ar, * Wait for first 4 bytes to be in FIFO * If CONSERVATIVE_BMI_READ is enabled, also wait for * a BMI command credit, which indicates that the ENTIRE - * response is available in the the FIFO + * response is available in the FIFO * * CASE 3: length > 128 * Wait for the first 4 bytes to be in FIFO diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index 4898e19b0af6..11300b1320a9 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h @@ -3832,7 +3832,7 @@ enum wmi_pdev_param { WMI_PDEV_PARAM_BEACON_TX_MODE, /* * Resource manager off chan mode . - * 0: turn off off chan mode. 1: turn on offchan mode + * 0: turn off offchan mode. 1: turn on offchan mode */ WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE, /* @@ -3936,7 +3936,7 @@ enum wmi_10x_pdev_param { WMI_10X_PDEV_PARAM_BEACON_TX_MODE, /* * Resource manager off chan mode . - * 0: turn off off chan mode. 1: turn on offchan mode + * 0: turn off offchan mode. 1: turn on offchan mode */ WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE, /* From d2f3f68864a463c138b27bf2ed81f6aae2233ef8 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 27 Oct 2020 14:38:08 +0200 Subject: [PATCH 002/180] ath10k: ath10k_pci_init_irq(): workaround for checkpatch fallthrough warning Latest checkpatch complains about use of fall-through comment. But as this is a switch statement just reword the comment to workaround the problem. Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1603802288-21158-2-git-send-email-kvalo@codeaurora.org --- drivers/net/wireless/ath/ath10k/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 36426efdb2ea..8ab262931dce 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -3236,7 +3236,7 @@ static int ath10k_pci_init_irq(struct ath10k *ar) if (ret == 0) return 0; - /* fall-through */ + /* MHI failed, try legacy irq next */ } /* Try legacy irq From 16f283f0a4bbc4cc84be574882706fa0d244186e Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 27 Oct 2020 15:01:45 +0200 Subject: [PATCH 003/180] ath11k: remove repeated words in comments and warnings Found by latest checkpatch. Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1603803705-22447-1-git-send-email-kvalo@codeaurora.org --- drivers/net/wireless/ath/ath11k/dp.c | 2 +- drivers/net/wireless/ath/ath11k/dp.h | 2 +- drivers/net/wireless/ath/ath11k/dp_rx.c | 6 +++--- drivers/net/wireless/ath/ath11k/hal_desc.h | 2 +- drivers/net/wireless/ath/ath11k/rx_desc.h | 2 +- drivers/net/wireless/ath/ath11k/testmode.c | 4 ++-- drivers/net/wireless/ath/ath11k/wmi.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/ath/ath11k/dp.c index 59dd185a0cfc..f977056ae5e8 100644 --- a/drivers/net/wireless/ath/ath11k/dp.c +++ b/drivers/net/wireless/ath/ath11k/dp.c @@ -381,7 +381,7 @@ static int ath11k_dp_srng_common_setup(struct ath11k_base *ab) HAL_WBM2SW_RELEASE, i, 0, DP_TX_COMP_RING_SIZE); if (ret) { - ath11k_warn(ab, "failed to set up tcl_comp ring ring (%d) :%d\n", + ath11k_warn(ab, "failed to set up tcl_comp ring (%d) :%d\n", i, ret); goto err; } diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/ath/ath11k/dp.h index ee8db812589b..d4fd02375fad 100644 --- a/drivers/net/wireless/ath/ath11k/dp.h +++ b/drivers/net/wireless/ath/ath11k/dp.h @@ -423,7 +423,7 @@ enum htt_srng_ring_id { * Used only by Consumer ring to generate ring_sw_int_p. * Ring entries low threshold water mark, that is used * in combination with the interrupt timer as well as - * the the clearing of the level interrupt. + * the clearing of the level interrupt. * b'16:18 - prefetch_timer_cfg: * Used only by Consumer ring to set timer mode to * support Application prefetch handling. diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 01625327eef7..571722baa0b3 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -377,7 +377,7 @@ static int ath11k_dp_rxdma_buf_ring_free(struct ath11k *ar, spin_lock_bh(&rx_ring->idr_lock); idr_for_each_entry(&rx_ring->bufs_idr, skb, buf_id) { idr_remove(&rx_ring->bufs_idr, buf_id); - /* TODO: Understand where internal driver does this dma_unmap of + /* TODO: Understand where internal driver does this dma_unmap * of rxdma_buffer. */ dma_unmap_single(ar->ab->dev, ATH11K_SKB_RXCB(skb)->paddr, @@ -399,7 +399,7 @@ static int ath11k_dp_rxdma_buf_ring_free(struct ath11k *ar, spin_lock_bh(&rx_ring->idr_lock); idr_for_each_entry(&rx_ring->bufs_idr, skb, buf_id) { idr_remove(&rx_ring->bufs_idr, buf_id); - /* XXX: Understand where internal driver does this dma_unmap of + /* XXX: Understand where internal driver does this dma_unmap * of rxdma_buffer. */ dma_unmap_single(ar->ab->dev, ATH11K_SKB_RXCB(skb)->paddr, @@ -960,7 +960,7 @@ int ath11k_peer_rx_tid_setup(struct ath11k *ar, const u8 *peer_mac, int vdev_id, rx_tid->ba_win_sz = ba_win_sz; - /* TODO: Optimize the memory allocation for qos tid based on the + /* TODO: Optimize the memory allocation for qos tid based on * the actual BA window size in REO tid update path. */ if (tid == HAL_DESC_REO_NON_QOS_TID) diff --git a/drivers/net/wireless/ath/ath11k/hal_desc.h b/drivers/net/wireless/ath/ath11k/hal_desc.h index 8a592814efa0..ceebdc28ddeb 100644 --- a/drivers/net/wireless/ath/ath11k/hal_desc.h +++ b/drivers/net/wireless/ath/ath11k/hal_desc.h @@ -716,7 +716,7 @@ struct hal_reo_dest_ring { * * rx_msdu_info * General information related to the MSDU that is passed - * on from RXDMA all the way to to the REO destination ring. + * on from RXDMA all the way to the REO destination ring. * * queue_addr_lo * Address (lower 32 bits) of the REO queue descriptor. diff --git a/drivers/net/wireless/ath/ath11k/rx_desc.h b/drivers/net/wireless/ath/ath11k/rx_desc.h index 1c4264637a41..86494da1069a 100644 --- a/drivers/net/wireless/ath/ath11k/rx_desc.h +++ b/drivers/net/wireless/ath/ath11k/rx_desc.h @@ -170,7 +170,7 @@ struct rx_attention { * * ast_index_not_found * Only valid when first_msdu is set. Indicates no AST matching - * entries within the the max search count. + * entries within the max search count. * * ast_index_timeout * Only valid when first_msdu is set. Indicates an unsuccessful diff --git a/drivers/net/wireless/ath/ath11k/testmode.c b/drivers/net/wireless/ath/ath11k/testmode.c index d2dc9db01491..4bf1931adbaa 100644 --- a/drivers/net/wireless/ath/ath11k/testmode.c +++ b/drivers/net/wireless/ath/ath11k/testmode.c @@ -51,7 +51,7 @@ bool ath11k_tm_event_wmi(struct ath11k *ar, u32 cmd_id, struct sk_buff *skb) ret = nla_put_u32(nl_skb, ATH11K_TM_ATTR_CMD, ATH11K_TM_CMD_WMI); if (ret) { ath11k_warn(ar->ab, - "failed to to put testmode wmi event cmd attribute: %d\n", + "failed to put testmode wmi event cmd attribute: %d\n", ret); kfree_skb(nl_skb); goto out; @@ -60,7 +60,7 @@ bool ath11k_tm_event_wmi(struct ath11k *ar, u32 cmd_id, struct sk_buff *skb) ret = nla_put_u32(nl_skb, ATH11K_TM_ATTR_WMI_CMDID, cmd_id); if (ret) { ath11k_warn(ar->ab, - "failed to to put testmode wmi even cmd_id: %d\n", + "failed to put testmode wmi even cmd_id: %d\n", ret); kfree_skb(nl_skb); goto out; diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 8eca92520837..6e173737c0eb 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -362,7 +362,7 @@ ath11k_pull_mac_phy_cap_svc_ready_ext(struct ath11k_pdev_wmi *wmi_handle, * For example, for 4x4 capable macphys, first 4 chains can be used for first * mac and the remaing 4 chains can be used for the second mac or vice-versa. * In this case, tx/rx chainmask 0xf will be advertised for first mac and 0xf0 - * will be advertised for second mac or vice-versa. Compute the shift value for + * will be advertised for second mac or vice-versa. Compute the shift value * for tx/rx chainmask which will be used to advertise supported ht/vht rates to * mac80211. */ From dbeb101d28eb89a9138055b50d5ce7a9f7a663cf Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Wed, 28 Oct 2020 15:54:30 +0200 Subject: [PATCH 004/180] ath10k: sdio: remove redundant check in for loop The for loop checks whether cur_section is NULL on every iteration, but we know it can never be NULL as there is another check towards the bottom of the loop body. Refactor to avoid this unnecessary check. Also, increment the variable i inline for clarity Addresses-Coverity: 1496984 ("Null pointer dereferences) Suggested-by: Saeed Mahameed Signed-off-by: Alex Dewar Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20200916165748.20927-1-alex.dewar90@gmail.com --- drivers/net/wireless/ath/ath10k/sdio.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index 59043ec44ca3..3e09802cfb6e 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -2307,8 +2307,8 @@ static int ath10k_sdio_dump_memory_section(struct ath10k *ar, } count = 0; - - for (i = 0; cur_section; i++) { + i = 0; + for (; cur_section; cur_section = next_section) { section_size = cur_section->end - cur_section->start; if (section_size <= 0) { @@ -2318,7 +2318,7 @@ static int ath10k_sdio_dump_memory_section(struct ath10k *ar, break; } - if ((i + 1) == mem_region->section_table.size) { + if (++i == mem_region->section_table.size) { /* last section */ next_section = NULL; skip_size = 0; @@ -2361,12 +2361,6 @@ static int ath10k_sdio_dump_memory_section(struct ath10k *ar, } count += skip_size; - - if (!next_section) - /* this was the last section */ - break; - - cur_section = next_section; } return count; From 047679e366b9842a9da3ab82dca26fcaad8020eb Mon Sep 17 00:00:00 2001 From: Aloka Dixit Date: Wed, 28 Oct 2020 15:54:32 +0200 Subject: [PATCH 005/180] ath11k: FILS discovery and unsolicited broadcast probe response support This patch adds driver support for FILS discovery and unsolicited broadcast probe response transmission features which are used for in-band discovery in 6GHz band. Currently this support is enabled only in 6GHz by setting hardware flags. Changes include WMI commands to enable transmission, set packet interval, set template, and handle events. Signed-off-by: Aloka Dixit Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201007204036.19780-1-alokad@codeaurora.org --- drivers/net/wireless/ath/ath11k/mac.c | 57 ++++++++ drivers/net/wireless/ath/ath11k/wmi.c | 203 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/wmi.h | 47 ++++++ 3 files changed, 307 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 7f8dd47d2333..591dcebcc5d1 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -1850,6 +1850,52 @@ static void ath11k_recalculate_mgmt_rate(struct ath11k *ar, ath11k_warn(ar->ab, "failed to set beacon tx rate %d\n", ret); } +static int ath11k_mac_fils_discovery(struct ath11k_vif *arvif, + struct ieee80211_bss_conf *info) +{ + struct ath11k *ar = arvif->ar; + struct sk_buff *tmpl; + int ret; + u32 interval; + bool unsol_bcast_probe_resp_enabled = false; + + if (info->fils_discovery.max_interval) { + interval = info->fils_discovery.max_interval; + + tmpl = ieee80211_get_fils_discovery_tmpl(ar->hw, arvif->vif); + if (tmpl) + ret = ath11k_wmi_fils_discovery_tmpl(ar, arvif->vdev_id, + tmpl); + } else if (info->unsol_bcast_probe_resp_interval) { + unsol_bcast_probe_resp_enabled = 1; + interval = info->unsol_bcast_probe_resp_interval; + + tmpl = ieee80211_get_unsol_bcast_probe_resp_tmpl(ar->hw, + arvif->vif); + if (tmpl) + ret = ath11k_wmi_probe_resp_tmpl(ar, arvif->vdev_id, + tmpl); + } else { /* Disable */ + return ath11k_wmi_fils_discovery(ar, arvif->vdev_id, 0, false); + } + + if (!tmpl) { + ath11k_warn(ar->ab, + "mac vdev %i failed to retrieve %s template\n", + arvif->vdev_id, (unsol_bcast_probe_resp_enabled ? + "unsolicited broadcast probe response" : + "FILS discovery")); + return -EPERM; + } + kfree_skb(tmpl); + + if (!ret) + ret = ath11k_wmi_fils_discovery(ar, arvif->vdev_id, interval, + unsol_bcast_probe_resp_enabled); + + return ret; +} + static void ath11k_mac_op_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *info, @@ -2111,6 +2157,10 @@ static void ath11k_mac_op_bss_info_changed(struct ieee80211_hw *hw, } } + if (changed & BSS_CHANGED_FILS_DISCOVERY || + changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP) + ath11k_mac_fils_discovery(arvif, info); + mutex_unlock(&ar->conf_mutex); } @@ -6258,6 +6308,13 @@ static int __ath11k_mac_register(struct ath11k *ar) ar->hw->wiphy->num_iftype_ext_capab = ARRAY_SIZE(ath11k_iftypes_ext_capa); + if (ar->supports_6ghz) { + wiphy_ext_feature_set(ar->hw->wiphy, + NL80211_EXT_FEATURE_FILS_DISCOVERY); + wiphy_ext_feature_set(ar->hw->wiphy, + NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP); + } + ath11k_reg_init(ar); if (!test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags)) { diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 6e173737c0eb..8049c96744b2 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -122,6 +122,10 @@ static const struct wmi_tlv_policy wmi_tlv_policies[] = { = { .min_len = sizeof(struct wmi_stats_event) }, [WMI_TAG_PDEV_CTL_FAILSAFE_CHECK_EVENT] = { .min_len = sizeof(struct wmi_pdev_ctl_failsafe_chk_event) }, + [WMI_TAG_HOST_SWFDA_EVENT] = { + .min_len = sizeof(struct wmi_fils_discovery_event) }, + [WMI_TAG_OFFLOAD_PRB_RSP_TX_STATUS_EVENT] = { + .min_len = sizeof(struct wmi_probe_resp_tx_status_event) }, }; #define PRIMAP(_hw_mode_) \ @@ -3064,6 +3068,137 @@ int ath11k_wmi_send_bss_color_change_enable_cmd(struct ath11k *ar, u32 vdev_id, return ret; } +int ath11k_wmi_fils_discovery_tmpl(struct ath11k *ar, u32 vdev_id, + struct sk_buff *tmpl) +{ + struct wmi_tlv *tlv; + struct sk_buff *skb; + void *ptr; + int ret, len; + size_t aligned_len; + struct wmi_fils_discovery_tmpl_cmd *cmd; + + aligned_len = roundup(tmpl->len, 4); + len = sizeof(*cmd) + TLV_HDR_SIZE + aligned_len; + + ath11k_dbg(ar->ab, ATH11K_DBG_WMI, + "WMI vdev %i set FILS discovery template\n", vdev_id); + + skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_fils_discovery_tmpl_cmd *)skb->data; + cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, + WMI_TAG_FILS_DISCOVERY_TMPL_CMD) | + FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); + cmd->vdev_id = vdev_id; + cmd->buf_len = tmpl->len; + ptr = skb->data + sizeof(*cmd); + + tlv = ptr; + tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | + FIELD_PREP(WMI_TLV_LEN, aligned_len); + memcpy(tlv->value, tmpl->data, tmpl->len); + + ret = ath11k_wmi_cmd_send(ar->wmi, skb, WMI_FILS_DISCOVERY_TMPL_CMDID); + if (ret) { + ath11k_warn(ar->ab, + "WMI vdev %i failed to send FILS discovery template command\n", + vdev_id); + dev_kfree_skb(skb); + } + return ret; +} + +int ath11k_wmi_probe_resp_tmpl(struct ath11k *ar, u32 vdev_id, + struct sk_buff *tmpl) +{ + struct wmi_probe_tmpl_cmd *cmd; + struct wmi_bcn_prb_info *probe_info; + struct wmi_tlv *tlv; + struct sk_buff *skb; + void *ptr; + int ret, len; + size_t aligned_len = roundup(tmpl->len, 4); + + ath11k_dbg(ar->ab, ATH11K_DBG_WMI, + "WMI vdev %i set probe response template\n", vdev_id); + + len = sizeof(*cmd) + sizeof(*probe_info) + TLV_HDR_SIZE + aligned_len; + + skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_probe_tmpl_cmd *)skb->data; + cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PRB_TMPL_CMD) | + FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); + cmd->vdev_id = vdev_id; + cmd->buf_len = tmpl->len; + + ptr = skb->data + sizeof(*cmd); + + probe_info = ptr; + len = sizeof(*probe_info); + probe_info->tlv_header = FIELD_PREP(WMI_TLV_TAG, + WMI_TAG_BCN_PRB_INFO) | + FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); + probe_info->caps = 0; + probe_info->erp = 0; + + ptr += sizeof(*probe_info); + + tlv = ptr; + tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | + FIELD_PREP(WMI_TLV_LEN, aligned_len); + memcpy(tlv->value, tmpl->data, tmpl->len); + + ret = ath11k_wmi_cmd_send(ar->wmi, skb, WMI_PRB_TMPL_CMDID); + if (ret) { + ath11k_warn(ar->ab, + "WMI vdev %i failed to send probe response template command\n", + vdev_id); + dev_kfree_skb(skb); + } + return ret; +} + +int ath11k_wmi_fils_discovery(struct ath11k *ar, u32 vdev_id, u32 interval, + bool unsol_bcast_probe_resp_enabled) +{ + struct sk_buff *skb; + int ret, len; + struct wmi_fils_discovery_cmd *cmd; + + ath11k_dbg(ar->ab, ATH11K_DBG_WMI, + "WMI vdev %i set %s interval to %u TU\n", + vdev_id, unsol_bcast_probe_resp_enabled ? + "unsolicited broadcast probe response" : "FILS discovery", + interval); + + len = sizeof(*cmd); + skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_fils_discovery_cmd *)skb->data; + cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ENABLE_FILS_CMD) | + FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); + cmd->vdev_id = vdev_id; + cmd->interval = interval; + cmd->config = unsol_bcast_probe_resp_enabled; + + ret = ath11k_wmi_cmd_send(ar->wmi, skb, WMI_ENABLE_FILS_CMDID); + if (ret) { + ath11k_warn(ar->ab, + "WMI vdev %i failed to send FILS discovery enable/disable command\n", + vdev_id); + dev_kfree_skb(skb); + } + return ret; +} + static void ath11k_fill_band_to_mac_param(struct ath11k_base *soc, struct wmi_host_pdev_band_to_mac *band_to_mac) @@ -6429,6 +6564,68 @@ ath11k_wmi_pdev_temperature_event(struct ath11k_base *ab, ath11k_thermal_event_temperature(ar, ev.temp); } +static void ath11k_fils_discovery_event(struct ath11k_base *ab, + struct sk_buff *skb) +{ + const void **tb; + const struct wmi_fils_discovery_event *ev; + int ret; + + tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); + if (IS_ERR(tb)) { + ret = PTR_ERR(tb); + ath11k_warn(ab, + "failed to parse FILS discovery event tlv %d\n", + ret); + return; + } + + ev = tb[WMI_TAG_HOST_SWFDA_EVENT]; + if (!ev) { + ath11k_warn(ab, "failed to fetch FILS discovery event\n"); + kfree(tb); + return; + } + + ath11k_warn(ab, + "FILS discovery frame expected from host for vdev_id: %u, transmission scheduled at %u, next TBTT: %u\n", + ev->vdev_id, ev->fils_tt, ev->tbtt); + + kfree(tb); +} + +static void ath11k_probe_resp_tx_status_event(struct ath11k_base *ab, + struct sk_buff *skb) +{ + const void **tb; + const struct wmi_probe_resp_tx_status_event *ev; + int ret; + + tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); + if (IS_ERR(tb)) { + ret = PTR_ERR(tb); + ath11k_warn(ab, + "failed to parse probe response transmission status event tlv: %d\n", + ret); + return; + } + + ev = tb[WMI_TAG_OFFLOAD_PRB_RSP_TX_STATUS_EVENT]; + if (!ev) { + ath11k_warn(ab, + "failed to fetch probe response transmission status event"); + kfree(tb); + return; + } + + if (ev->tx_status) + ath11k_warn(ab, + "Probe response transmission failed for vdev_id %u, status %u\n", + ev->vdev_id, ev->tx_status); + + kfree(tb); +} + static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb) { struct wmi_cmd_hdr *cmd_hdr; @@ -6515,6 +6712,12 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb) case WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID: ath11k_wmi_pdev_dma_ring_buf_release_event(ab, skb); break; + case WMI_HOST_FILS_DISCOVERY_EVENTID: + ath11k_fils_discovery_event(ab, skb); + break; + case WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID: + ath11k_probe_resp_tx_status_event(ab, skb); + break; /* add Unsupported events here */ case WMI_TBTTOFFSET_EXT_UPDATE_EVENTID: case WMI_VDEV_DELETE_RESP_EVENTID: diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h index 5a32ba0eb4f5..b722a87144b6 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.h +++ b/drivers/net/wireless/ath/ath11k/wmi.h @@ -319,6 +319,7 @@ enum wmi_tlv_cmd_id { WMI_BCN_OFFLOAD_CTRL_CMDID, WMI_BSS_COLOR_CHANGE_ENABLE_CMDID, WMI_VDEV_BCN_OFFLOAD_QUIET_CONFIG_CMDID, + WMI_FILS_DISCOVERY_TMPL_CMDID, WMI_ADDBA_CLEAR_RESP_CMDID = WMI_TLV_CMD(WMI_GRP_BA_NEG), WMI_ADDBA_SEND_CMDID, WMI_ADDBA_STATUS_CMDID, @@ -351,6 +352,8 @@ enum wmi_tlv_cmd_id { WMI_ROAM_CONFIGURE_MAWC_CMDID, WMI_ROAM_SET_MBO_PARAM_CMDID, WMI_ROAM_PER_CONFIG_CMDID, + WMI_ROAM_BTM_CONFIG_CMDID, + WMI_ENABLE_FILS_CMDID, WMI_OFL_SCAN_ADD_AP_PROFILE = WMI_TLV_CMD(WMI_GRP_OFL_SCAN), WMI_OFL_SCAN_REMOVE_AP_PROFILE, WMI_OFL_SCAN_PERIOD, @@ -642,6 +645,8 @@ enum wmi_tlv_event_id { WMI_MGMT_TX_COMPLETION_EVENTID, WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID, WMI_TBTTOFFSET_EXT_UPDATE_EVENTID, + WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID, + WMI_HOST_FILS_DISCOVERY_EVENTID, WMI_TX_DELBA_COMPLETE_EVENTID = WMI_TLV_CMD(WMI_GRP_BA_NEG), WMI_TX_ADDBA_COMPLETE_EVENTID, WMI_BA_RSP_SSN_EVENTID, @@ -1810,6 +1815,7 @@ enum wmi_tlv_tag { /* TODO add all the missing cmds */ WMI_TAG_PDEV_PEER_PKTLOG_FILTER_CMD = 0x301, WMI_TAG_PDEV_PEER_PKTLOG_FILTER_INFO, + WMI_TAG_FILS_DISCOVERY_TMPL_CMD = 0x344, WMI_TAG_MAX }; @@ -4076,6 +4082,17 @@ struct wmi_peer_assoc_conf_arg { const u8 *macaddr; }; +struct wmi_fils_discovery_event { + u32 vdev_id; + u32 fils_tt; + u32 tbtt; +} __packed; + +struct wmi_probe_resp_tx_status_event { + u32 vdev_id; + u32 tx_status; +} __packed; + /* * PDEV statistics */ @@ -4908,6 +4925,30 @@ struct wmi_dma_buf_release_meta_data { u32 ch_width; } __packed; +enum wmi_fils_discovery_cmd_type { + WMI_FILS_DISCOVERY_CMD, + WMI_UNSOL_BCAST_PROBE_RESP, +}; + +struct wmi_fils_discovery_cmd { + u32 tlv_header; + u32 vdev_id; + u32 interval; + u32 config; /* enum wmi_fils_discovery_cmd_type */ +} __packed; + +struct wmi_fils_discovery_tmpl_cmd { + u32 tlv_header; + u32 vdev_id; + u32 buf_len; +} __packed; + +struct wmi_probe_tmpl_cmd { + u32 tlv_header; + u32 vdev_id; + u32 buf_len; +} __packed; + struct target_resource_config { u32 num_vdevs; u32 num_peers; @@ -5121,4 +5162,10 @@ int ath11k_wmi_vdev_spectral_enable(struct ath11k *ar, u32 vdev_id, u32 trigger, u32 enable); int ath11k_wmi_vdev_spectral_conf(struct ath11k *ar, struct ath11k_wmi_vdev_spectral_conf_param *param); +int ath11k_wmi_fils_discovery_tmpl(struct ath11k *ar, u32 vdev_id, + struct sk_buff *tmpl); +int ath11k_wmi_fils_discovery(struct ath11k *ar, u32 vdev_id, u32 interval, + bool unsol_bcast_probe_resp_enabled); +int ath11k_wmi_probe_resp_tmpl(struct ath11k *ar, u32 vdev_id, + struct sk_buff *tmpl); #endif From b9162645117841978a3fb31546409271e007dd28 Mon Sep 17 00:00:00 2001 From: Tamizh Chelvam Date: Wed, 4 Nov 2020 22:07:17 +0530 Subject: [PATCH 006/180] ath10k: fix compilation warning This change fixes below compilation warning. smatch warnings: drivers/net/wireless/ath/ath10k/mac.c:9125 ath10k_mac_op_set_tid_config() error: uninitialized symbol 'ret'. No functional changes. Compile tested only. Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Tamizh Chelvam Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604507837-29361-1-git-send-email-tamizhr@codeaurora.org --- drivers/net/wireless/ath/ath10k/mac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index c857cf46832d..fad08c6caa04 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -9169,10 +9169,11 @@ static int ath10k_mac_op_set_tid_config(struct ieee80211_hw *hw, goto exit; } + ret = 0; + if (sta) goto exit; - ret = 0; arvif->tids_rst = 0; data.curr_vif = vif; data.ar = ar; From ee06fcb98dcdc2713c83c29e9101b007a825cd7f Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Tue, 22 Sep 2020 12:19:57 -0700 Subject: [PATCH 007/180] ath10k: Don't iterate over not-sdata-in-driver interfaces. This fixes possible crash scenario where interfaces that were not set up in the driver yet might still be iterated over. When originally debugged on the ath10k-ct driver, the crash looked like this: kernel BUG at /home/greearb/git/linux-4.7.dev.y/drivers/net/wireless/ath/ath10k/wmi.c:1781! invalid opcode: 0000 [#1] PREEMPT SMP KASAN Modules linked in: nf_conntrack_netlink nf_conntrack nfnetlink nf_defrag_ipv4 bridge carl9170 mac80211_hwsim ath10k_pci ath10k_core ath5k ath9k ath9k_common ath9k_hw ath mac80211 cfg80211 8021q garp mrp stp llc bnep bluetooth fuse macvlan pktgen rpcsec_gss_krb5 nfsv4 nfs fscache snd_hda_codec_hdmi coretemp hwmon intel_rapl x86_pkg_temp_thermal intel_powerclamp snd_hda_codec_realtek snd_hda_codec_generic kvm iTCO_wdt irqbypass iTCO_vendor_support joydev snd_hda_intel snd_hda_codec snd_hda_core snd_hwdep snd_seq snd_seq_device pcspkr snd_pcm snd_timer shpchp snd i2c_i801 lpc_ich soundcore tpm_tis tpm nfsd auth_rpcgss nfs_acl lockd grace sunrpc i915 serio_raw i2c_algo_bit drm_kms_helper ata_generic e1000e pata_acpi drm ptp pps_core i2c_core fjes video ipv6 [last unloaded: nf_conntrack] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.7.10+ #15 Hardware name: To be filled by O.E.M. To be filled by O.E.M./ChiefRiver, BIOS 4.6.5 06/07/2013 task: ffff8801d4f20000 ti: ffff8801d4f28000 task.ti: ffff8801d4f28000 RIP: 0010:[] [] ath10k_wmi_tx_beacons_iter+0x28b/0x290 [ath10k_core] RSP: 0018:ffff8801d6447a98 EFLAGS: 00010293 RAX: 0000000000000018 RBX: ffff8801ce97e1d8 RCX: 0000000000000000 RDX: 0000000000000018 RSI: 0000000000000003 RDI: ffffed003ac88f49 RBP: ffff8801d6447af0 R08: 0000000000000003 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000 R13: ffff8801ce97e320 R14: ffff8801ce97e378 R15: ffff8801ce97ca40 FS: 0000000000000000(0000) GS:ffff8801d6440000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007eff191ef1ab CR3: 000000000260a000 CR4: 00000000001406e0 Stack: 1ffff1003ac88f59 0000000041b58ab3 ffffffffa0f4d52a ffff8801d4f20000 0000000000000246 0000000000000002 ffff8801ce97e1d8 ffff8801bd5d39b8 0000000000000002 0000000000000001 ffff8801ce97ca40 ffff8801d6447b48 Call Trace: [] __iterate_interfaces+0xfc/0x1d0 [mac80211] [] ? ath10k_wmi_cmd_send_nowait+0x260/0x260 [ath10k_core] [] ? ath10k_wmi_cmd_send_nowait+0x260/0x260 [ath10k_core] [] ieee80211_iterate_active_interfaces_atomic+0x67/0x100 [mac80211] [] ? ieee80211_handle_reconfig_failure+0x140/0x140 [mac80211] [] ? ath10k_tpc_config_disp_tables+0x620/0x620 [ath10k_core] [] ath10k_wmi_op_ep_tx_credits+0x2b/0x50 [ath10k_core] [] ath10k_htc_rx_completion_handler+0x422/0x5c0 [ath10k_core] [] ath10k_pci_process_rx_cb+0x37e/0x430 [ath10k_pci] [] ? ath10k_htc_build_tx_ctrl_skb+0xc0/0xc0 [ath10k_core] [] ? ath10k_pci_rx_post_pipe+0x550/0x550 [ath10k_pci] [] ? debug_lockdep_rcu_enabled+0x35/0x40 [] ? mark_held_locks+0x23/0xc0 [] ? __local_bh_enable_ip+0x6a/0xd0 [] ? trace_hardirqs_on_caller+0x18b/0x290 [] ? trace_hardirqs_on+0xd/0x10 [] ? __local_bh_enable_ip+0x6a/0xd0 [] ? _raw_spin_unlock_bh+0x30/0x40 [] ? ath10k_ce_per_engine_service+0xee/0x100 [ath10k_pci] [] ath10k_pci_htt_htc_rx_cb+0x29/0x30 [ath10k_pci] [] ath10k_ce_per_engine_service+0xa6/0x100 [ath10k_pci] [] ath10k_ce_per_engine_service_any+0xd6/0xf0 [ath10k_pci] [] ? ath10k_pci_enable_legacy_irq+0xe0/0xe0 [ath10k_pci] [] ath10k_pci_tasklet+0x5f/0xb0 [ath10k_pci] [] tasklet_action+0x245/0x2b0 [] __do_softirq+0x181/0x595 [] irq_exit+0xbc/0xc0 [] do_IRQ+0x7c/0x150 [] common_interrupt+0x8c/0x8c [] ? trace_hardirqs_on_caller+0x18b/0x290 [] ? cpuidle_enter_state+0x1ae/0x4b0 [] ? cpuidle_enter_state+0x1a7/0x4b0 [] cpuidle_enter+0x12/0x20 [] call_cpuidle+0x4e/0x90 [] cpu_startup_entry+0x3f7/0x540 [] ? default_idle_call+0x50/0x50 [] ? clockevents_config_and_register+0x5f/0x70 [] ? setup_APIC_timer+0xfa/0x110 [] start_secondary+0x253/0x2b0 [] ? set_cpu_sibling_map+0x920/0x920 Code: 4d 49 e0 8b b3 48 01 00 00 48 c7 c7 a0 ee f3 a0 e8 d9 c2 3f e0 49 81 fd 3f 1f 00 00 76 0f 49 81 fc 3f 1f 00 00 0f 87 c0 fd ff ff <0f> 0b 0f 0b 90 55 48 89 e5 41 57 41 56 48 8d 85 58 ff ff ff 41 RIP [] ath10k_wmi_tx_beacons_iter+0x28b/0x290 [ath10k_core] RSP ---[ end trace 6588464714e5163a ]--- Similar logic was tested for years in ath10k-ct driver and various firmware. Also tested with stock kernel plus this patch, with firmware 10.2.4-1.0-00037 This test case was to bring up 5 vap on a radio and fake a firmware crash. Make sure ap interfaces continue to function properly. Signed-off-by: Ben Greear Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20200922191957.25257-2-greearb@candelatech.com --- drivers/net/wireless/ath/ath10k/core.h | 5 +++++ drivers/net/wireless/ath/ath10k/mac.c | 16 +++++++--------- drivers/net/wireless/ath/ath10k/p2p.c | 2 +- drivers/net/wireless/ath/ath10k/wmi.c | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index b50ab9e229dc..aa713d037c7f 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -84,6 +84,11 @@ #define ATH10K_MAX_RETRY_COUNT 30 +#define ATH10K_ITER_NORMAL_FLAGS (IEEE80211_IFACE_ITER_NORMAL | \ + IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER) +#define ATH10K_ITER_RESUME_FLAGS (IEEE80211_IFACE_ITER_RESUME_ALL |\ + IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER) + struct ath10k; static inline const char *ath10k_bus_str(enum ath10k_bus bus) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index fad08c6caa04..dc32c7852a24 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -2066,7 +2066,7 @@ static void ath10k_mac_handle_beacon_iter(void *data, u8 *mac, void ath10k_mac_handle_beacon(struct ath10k *ar, struct sk_buff *skb) { ieee80211_iterate_active_interfaces_atomic(ar->hw, - IEEE80211_IFACE_ITER_NORMAL, + ATH10K_ITER_NORMAL_FLAGS, ath10k_mac_handle_beacon_iter, skb); } @@ -2099,7 +2099,7 @@ static void ath10k_mac_handle_beacon_miss_iter(void *data, u8 *mac, void ath10k_mac_handle_beacon_miss(struct ath10k *ar, u32 vdev_id) { ieee80211_iterate_active_interfaces_atomic(ar->hw, - IEEE80211_IFACE_ITER_NORMAL, + ATH10K_ITER_NORMAL_FLAGS, ath10k_mac_handle_beacon_miss_iter, &vdev_id); } @@ -3433,7 +3433,7 @@ void ath10k_mac_tx_unlock(struct ath10k *ar, int reason) return; ieee80211_iterate_active_interfaces_atomic(ar->hw, - IEEE80211_IFACE_ITER_RESUME_ALL, + ATH10K_ITER_RESUME_FLAGS, ath10k_mac_tx_unlock_iter, ar); @@ -3522,7 +3522,7 @@ void ath10k_mac_handle_tx_pause_vdev(struct ath10k *ar, u32 vdev_id, spin_lock_bh(&ar->htt.tx_lock); ieee80211_iterate_active_interfaces_atomic(ar->hw, - IEEE80211_IFACE_ITER_RESUME_ALL, + ATH10K_ITER_RESUME_FLAGS, ath10k_mac_handle_tx_pause_iter, &arg); spin_unlock_bh(&ar->htt.tx_lock); @@ -8696,7 +8696,7 @@ ath10k_mac_op_change_chanctx(struct ieee80211_hw *hw, if (changed & IEEE80211_CHANCTX_CHANGE_WIDTH) { ieee80211_iterate_active_interfaces_atomic( hw, - IEEE80211_IFACE_ITER_NORMAL, + ATH10K_ITER_NORMAL_FLAGS, ath10k_mac_change_chanctx_cnt_iter, &arg); if (arg.n_vifs == 0) @@ -8709,7 +8709,7 @@ ath10k_mac_op_change_chanctx(struct ieee80211_hw *hw, ieee80211_iterate_active_interfaces_atomic( hw, - IEEE80211_IFACE_ITER_NORMAL, + ATH10K_ITER_NORMAL_FLAGS, ath10k_mac_change_chanctx_fill_iter, &arg); ath10k_mac_update_vif_chan(ar, arg.vifs, arg.n_vifs); @@ -9594,14 +9594,12 @@ static void ath10k_get_arvif_iter(void *data, u8 *mac, struct ath10k_vif *ath10k_get_arvif(struct ath10k *ar, u32 vdev_id) { struct ath10k_vif_iter arvif_iter; - u32 flags; memset(&arvif_iter, 0, sizeof(struct ath10k_vif_iter)); arvif_iter.vdev_id = vdev_id; - flags = IEEE80211_IFACE_ITER_RESUME_ALL; ieee80211_iterate_active_interfaces_atomic(ar->hw, - flags, + ATH10K_ITER_RESUME_FLAGS, ath10k_get_arvif_iter, &arvif_iter); if (!arvif_iter.arvif) { diff --git a/drivers/net/wireless/ath/ath10k/p2p.c b/drivers/net/wireless/ath/ath10k/p2p.c index 29c737b2f432..517b30f56b72 100644 --- a/drivers/net/wireless/ath/ath10k/p2p.c +++ b/drivers/net/wireless/ath/ath10k/p2p.c @@ -139,7 +139,7 @@ void ath10k_p2p_noa_update_by_vdev_id(struct ath10k *ar, u32 vdev_id, }; ieee80211_iterate_active_interfaces_atomic(ar->hw, - IEEE80211_IFACE_ITER_NORMAL, + ATH10K_ITER_NORMAL_FLAGS, ath10k_p2p_noa_update_vdev_iter, &arg); } diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index 1fa7107a5051..c521f0b27831 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -1894,7 +1894,7 @@ static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac, static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar) { ieee80211_iterate_active_interfaces_atomic(ar->hw, - IEEE80211_IFACE_ITER_NORMAL, + ATH10K_ITER_NORMAL_FLAGS, ath10k_wmi_tx_beacons_iter, NULL); } From 9501bc2b16b5850bcf6d87c985f1021d83cefab1 Mon Sep 17 00:00:00 2001 From: Wen Gong Date: Thu, 5 Nov 2020 14:33:56 +0800 Subject: [PATCH 008/180] ath10k: cancel rx worker in hif_stop for SDIO The rx worker of SDIO should be cancelled after disable interrupt, and release rx sk_buff in queue, otherwise the rx worker maybe still run after hif_stop. And it should be cancelled before napi_synchronize in hif_stop, because the rx worker of SDIO will call napi_schedule, it should have no napi_schedule before napi_synchronize, otherwise it lead napi_synchronize wait untill napi_complete. Tested-on: QCA6174 hw3.2 SDIO WLAN.RMH.4.4.1-00049 Signed-off-by: Wen Gong Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604558036-4056-1-git-send-email-wgong@codeaurora.org --- drivers/net/wireless/ath/ath10k/sdio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index 3e09802cfb6e..aa1f86028f01 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -1962,9 +1962,15 @@ static void ath10k_sdio_hif_stop(struct ath10k *ar) { struct ath10k_sdio_bus_request *req, *tmp_req; struct ath10k_sdio *ar_sdio = ath10k_sdio_priv(ar); + struct sk_buff *skb; ath10k_sdio_irq_disable(ar); + cancel_work_sync(&ar_sdio->async_work_rx); + + while ((skb = skb_dequeue(&ar_sdio->rx_head))) + dev_kfree_skb_any(skb); + cancel_work_sync(&ar_sdio->wr_async_work); spin_lock_bh(&ar_sdio->wr_async_lock); From 0f01dcb89b8b24b8d99d2ca25ed12676edae95ce Mon Sep 17 00:00:00 2001 From: Allen Pais Date: Wed, 7 Oct 2020 16:03:09 +0530 Subject: [PATCH 009/180] ath11k: convert tasklets to use new tasklet_setup() API In preparation for unconditionally passing the struct tasklet_struct pointer to all tasklet callbacks, switch to using the new tasklet_setup() and from_tasklet() to pass the tasklet pointer explicitly. Signed-off-by: Romain Perier Signed-off-by: Allen Pais Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201007103309.363737-4-allen.lkml@gmail.com --- drivers/net/wireless/ath/ath11k/pci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c index d7eb6b7160bb..b75f47dc36de 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -380,9 +380,9 @@ static void ath11k_pci_sync_ce_irqs(struct ath11k_base *ab) } } -static void ath11k_pci_ce_tasklet(unsigned long data) +static void ath11k_pci_ce_tasklet(struct tasklet_struct *t) { - struct ath11k_ce_pipe *ce_pipe = (struct ath11k_ce_pipe *)data; + struct ath11k_ce_pipe *ce_pipe = from_tasklet(ce_pipe, t, intr_tq); ath11k_ce_per_engine_service(ce_pipe->ab, ce_pipe->pipe_num); @@ -581,8 +581,7 @@ static int ath11k_pci_config_irq(struct ath11k_base *ab) irq_idx = ATH11K_PCI_IRQ_CE0_OFFSET + i; - tasklet_init(&ce_pipe->intr_tq, ath11k_pci_ce_tasklet, - (unsigned long)ce_pipe); + tasklet_setup(&ce_pipe->intr_tq, ath11k_pci_ce_tasklet); ret = request_irq(irq, ath11k_pci_ce_interrupt_handler, IRQF_SHARED, irq_name[irq_idx], From bafdbd79aae4c91f38caa43e5fb7abfd911f5bf6 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Thu, 15 Oct 2020 12:17:34 +0530 Subject: [PATCH 010/180] ath11k: Remove unnecessary data sync to cpu on monitor buffer Monitor ring Rx buffer is not really modified between dma map and unmap. So remove the unnecssary data sync before dma unmap. This does not fix any visible issue, found in code review. Compile tested only. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1602744454-22969-1-git-send-email-vthiagar@codeaurora.org --- drivers/net/wireless/ath/ath11k/dp_rx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 571722baa0b3..d23b152ddcdd 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -2856,10 +2856,6 @@ static int ath11k_dp_rx_reap_mon_status_ring(struct ath11k_base *ab, int mac_id, rxcb = ATH11K_SKB_RXCB(skb); - dma_sync_single_for_cpu(ab->dev, rxcb->paddr, - skb->len + skb_tailroom(skb), - DMA_FROM_DEVICE); - dma_unmap_single(ab->dev, rxcb->paddr, skb->len + skb_tailroom(skb), DMA_BIDIRECTIONAL); From 77581df8639faf28ae52fea170e48cdf9870468a Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Thu, 15 Oct 2020 15:15:00 +0200 Subject: [PATCH 011/180] dt: bindings: add new dt entry for ath11k calibration variant The bus + qmi-chip-id + qmi-board-id is not enough to identify the correct board data file on IPQ6018 based devices. Multiple different boards share the same values. Only the original reference designs can currently be identified and loaded from the board-2.bin. But these will not result in the correct calibration data when combined with the pre-calibration data from the device. An additional "variant" information has to be provided to select the correct board data for a design which was modified by an ODM. This follows the same approach as ath10k. Signed-off-by: Sven Eckelmann Reviewed-by: Rob Herring Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201015131501.1939685-1-sven@narfation.org --- .../devicetree/bindings/net/wireless/qcom,ath11k.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml b/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml index 4b365c9d9378..6af999191559 100644 --- a/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml +++ b/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml @@ -144,6 +144,12 @@ properties: * reg * reg-names + qcom,ath11k-calibration-variant: + $ref: /schemas/types.yaml#/definitions/string + description: + string to uniquely identify variant of the calibration data in the + board-2.bin for designs with colliding bus and device specific ids + required: - compatible - reg From 14f43c5fca57810e7a3788468aee482c85ab37a6 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Thu, 15 Oct 2020 15:15:01 +0200 Subject: [PATCH 012/180] ath11k: search DT for qcom,ath11k-calibration-variant Board Data File (BDF) is loaded upon driver boot-up procedure. The right board data file is identified on IPQ6018 using bus, qmi-chip-id and qmi-board-id. The problem, however, can occur when the (default) board data file cannot fulfill with the vendor requirements and it is necessary to use a different board data file. This problem was already solved on ath10k by adding a ",variant=.*" at the end of the board name. The same functionality must also be provided for ath11k. The device tree requires an additional string to define the variant name wifi@c000000 { status = "okay"; qcom,ath11k-calibration-variant = "Cigtech-WF-188"; }; This would create the boarddata identifier for the board-2.bin search * bus=ahb,qmi-chip-id=0,qmi-board-id=18,variant=Cigtech-WF-188 Signed-off-by: Sven Eckelmann Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201015131501.1939685-2-sven@narfation.org --- drivers/net/wireless/ath/ath11k/core.c | 35 ++++++++++++++++++++++++-- drivers/net/wireless/ath/ath11k/core.h | 1 + drivers/net/wireless/ath/ath11k/qmi.c | 5 ++++ drivers/net/wireless/ath/ath11k/qmi.h | 2 ++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c index ebd6886a8c18..c3af41226379 100644 --- a/drivers/net/wireless/ath/ath11k/core.c +++ b/drivers/net/wireless/ath/ath11k/core.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "core.h" #include "dp_tx.h" #include "dp_rx.h" @@ -141,14 +142,44 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { }, }; +int ath11k_core_check_dt(struct ath11k_base *ab) +{ + size_t max_len = sizeof(ab->qmi.target.bdf_ext); + const char *variant = NULL; + struct device_node *node; + + node = ab->dev->of_node; + if (!node) + return -ENOENT; + + of_property_read_string(node, "qcom,ath11k-calibration-variant", + &variant); + if (!variant) + return -ENODATA; + + if (strscpy(ab->qmi.target.bdf_ext, variant, max_len) < 0) + ath11k_dbg(ab, ATH11K_DBG_BOOT, + "bdf variant string is longer than the buffer can accommodate (variant: %s)\n", + variant); + + return 0; +} + static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name, size_t name_len) { + /* strlen(',variant=') + strlen(ab->qmi.target.bdf_ext) */ + char variant[9 + ATH11K_QMI_BDF_EXT_STR_LENGTH] = { 0 }; + + if (ab->qmi.target.bdf_ext[0] != '\0') + scnprintf(variant, sizeof(variant), ",variant=%s", + ab->qmi.target.bdf_ext); + scnprintf(name, name_len, - "bus=%s,qmi-chip-id=%d,qmi-board-id=%d", + "bus=%s,qmi-chip-id=%d,qmi-board-id=%d%s", ath11k_bus_str(ab->hif.bus), ab->qmi.target.chip_id, - ab->qmi.target.board_id); + ab->qmi.target.board_id, variant); ath11k_dbg(ab, ATH11K_DBG_BOOT, "boot using board name '%s'\n", name); diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 18b97420f0d8..18c961c9fd30 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -883,6 +883,7 @@ void ath11k_core_free(struct ath11k_base *ath11k); int ath11k_core_fetch_bdf(struct ath11k_base *ath11k, struct ath11k_board_data *bd); void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd); +int ath11k_core_check_dt(struct ath11k_base *ath11k); void ath11k_core_halt(struct ath11k *ar); diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index c2b165158225..9fb4dea149bf 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -1793,6 +1793,7 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab) struct qmi_wlanfw_cap_resp_msg_v01 resp; struct qmi_txn txn = {}; int ret = 0; + int r; memset(&req, 0, sizeof(req)); memset(&resp, 0, sizeof(resp)); @@ -1858,6 +1859,10 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab) ab->qmi.target.fw_build_timestamp, ab->qmi.target.fw_build_id); + r = ath11k_core_check_dt(ab); + if (r) + ath11k_dbg(ab, ATH11K_DBG_QMI, "DT bdf variant name not set.\n"); + out: return ret; } diff --git a/drivers/net/wireless/ath/ath11k/qmi.h b/drivers/net/wireless/ath/ath11k/qmi.h index b0a818f0401b..7b170bc9a913 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.h +++ b/drivers/net/wireless/ath/ath11k/qmi.h @@ -24,6 +24,7 @@ #define ATH11K_QMI_RESP_LEN_MAX 8192 #define ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01 32 #define ATH11K_QMI_CALDB_SIZE 0x480000 +#define ATH11K_QMI_BDF_EXT_STR_LENGTH 0x20 #define QMI_WLFW_REQUEST_MEM_IND_V01 0x0035 #define QMI_WLFW_FW_MEM_READY_IND_V01 0x0037 @@ -101,6 +102,7 @@ struct target_info { u32 fw_version; char fw_build_timestamp[ATH11K_QMI_WLANFW_MAX_TIMESTAMP_LEN_V01 + 1]; char fw_build_id[ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1]; + char bdf_ext[ATH11K_QMI_BDF_EXT_STR_LENGTH]; }; struct m3_mem_region { From 02f9d3c1b918a631be369350ffcaaab6cde95b22 Mon Sep 17 00:00:00 2001 From: Govindaraj Saminathan Date: Fri, 16 Oct 2020 20:58:31 +0530 Subject: [PATCH 013/180] ath11k: cold boot calibration support cold boot calibration is the process to calibrate all the channels during the boot-up to avoid the calibration delay during the channel change. During the boot-up, firmware started in cold boot calibration mode Firmware calibrate all channels and generate CalDb(DDR). Subsequent wifi bringup will reuse the same CalDb. Firmware is restarted in normal mode to continue the normal operation. caldb memory address send to firmware through the QMI message.Firmware use this address to store the caldb data and use it until next reboot. This will give the improvement during the channel change. But it is increasing the boot-up time(up to 15sec depend on number of radios). So if the user want to reduce the boot-up time and accepting for channel change delay, user can disable this feature using the module param cold_boot_cal=0. Tested-on: IPQ8074 WLAN.HK.2.4.0.1-01162-QCAHKSWPL_SILICONZ-1 Signed-off-by: Govindaraj Saminathan Co-developed-by: Sowmiya Sree Elavalagan Signed-off-by: Sowmiya Sree Elavalagan Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1602862111-14063-1-git-send-email-ssreeela@codeaurora.org --- drivers/net/wireless/ath/ath11k/ahb.c | 27 +++++++++++ drivers/net/wireless/ath/ath11k/core.c | 4 ++ drivers/net/wireless/ath/ath11k/core.h | 5 ++ drivers/net/wireless/ath/ath11k/hw.h | 1 + drivers/net/wireless/ath/ath11k/qmi.c | 67 +++++++++++++++++++++++--- drivers/net/wireless/ath/ath11k/qmi.h | 3 ++ 6 files changed, 100 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c index 430723c64adc..c7843f461dd2 100644 --- a/drivers/net/wireless/ath/ath11k/ahb.c +++ b/drivers/net/wireless/ath/ath11k/ahb.c @@ -340,6 +340,31 @@ static void ath11k_ahb_power_down(struct ath11k_base *ab) rproc_shutdown(ab_ahb->tgt_rproc); } +static int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab) +{ + int timeout; + + if (ath11k_cold_boot_cal == 0 || ab->qmi.cal_done || + ab->hw_params.cold_boot_calib == 0) + return 0; + + ath11k_dbg(ab, ATH11K_DBG_AHB, "wait for cold boot done\n"); + timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, + (ab->qmi.cal_done == 1), + ATH11K_COLD_BOOT_FW_RESET_DELAY); + if (timeout <= 0) { + ath11k_cold_boot_cal = 0; + ath11k_warn(ab, "Coldboot Calibration failed timed out\n"); + } + + /* reset the firmware */ + ath11k_ahb_power_down(ab); + ath11k_ahb_power_up(ab); + + ath11k_dbg(ab, ATH11K_DBG_AHB, "exited from cold boot mode\n"); + return 0; +} + static void ath11k_ahb_init_qmi_ce_config(struct ath11k_base *ab) { struct ath11k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg; @@ -700,6 +725,8 @@ static int ath11k_ahb_probe(struct platform_device *pdev) goto err_ce_free; } + ath11k_ahb_fwreset_from_cold_boot(ab); + return 0; err_ce_free: diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c index c3af41226379..c23a59a29792 100644 --- a/drivers/net/wireless/ath/ath11k/core.c +++ b/drivers/net/wireless/ath/ath11k/core.c @@ -66,6 +66,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { .supports_monitor = true, .supports_shadow_regs = false, .idle_ps = false, + .cold_boot_calib = true, }, { .hw_rev = ATH11K_HW_IPQ6018_HW10, @@ -103,6 +104,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { .supports_monitor = true, .supports_shadow_regs = false, .idle_ps = false, + .cold_boot_calib = true, }, { .name = "qca6390 hw2.0", @@ -139,6 +141,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { .supports_monitor = false, .supports_shadow_regs = true, .idle_ps = true, + .cold_boot_calib = false, }, }; @@ -954,6 +957,7 @@ struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size, INIT_LIST_HEAD(&ab->peers); init_waitqueue_head(&ab->peer_mapping_wq); init_waitqueue_head(&ab->wmi_ab.tx_credits_wq); + init_waitqueue_head(&ab->qmi.cold_boot_waitq); INIT_WORK(&ab->restart_work, ath11k_core_restart); timer_setup(&ab->rx_replenish_retry, ath11k_ce_rx_replenish_retry, 0); ab->dev = dev; diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 18c961c9fd30..79224ed703db 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -111,8 +111,13 @@ enum ath11k_firmware_mode { /* factory tests etc */ ATH11K_FIRMWARE_MODE_FTM, + + /* Cold boot calibration */ + ATH11K_FIRMWARE_MODE_COLD_BOOT = 7, }; +extern bool ath11k_cold_boot_cal; + #define ATH11K_IRQ_NUM_MAX 52 #define ATH11K_EXT_IRQ_NUM_MAX 16 diff --git a/drivers/net/wireless/ath/ath11k/hw.h b/drivers/net/wireless/ath/ath11k/hw.h index 1dda4257e6d7..17c4560b1c73 100644 --- a/drivers/net/wireless/ath/ath11k/hw.h +++ b/drivers/net/wireless/ath/ath11k/hw.h @@ -161,6 +161,7 @@ struct ath11k_hw_params { bool supports_monitor; bool supports_shadow_regs; bool idle_ps; + bool cold_boot_calib; }; struct ath11k_hw_ops { diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index 9fb4dea149bf..8529b3328d24 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -14,6 +14,12 @@ #define SLEEP_CLOCK_SELECT_INTERNAL_BIT 0x02 #define HOST_CSTATE_BIT 0x04 +bool ath11k_cold_boot_cal = 1; +EXPORT_SYMBOL(ath11k_cold_boot_cal); +module_param_named(cold_boot_cal, ath11k_cold_boot_cal, bool, 0644); +MODULE_PARM_DESC(cold_boot_cal, + "Decrease the channel switch time but increase the driver load time (Default: true)"); + static struct qmi_elem_info qmi_wlanfw_host_cap_req_msg_v01_ei[] = { { .data_type = QMI_OPT_FLAG, @@ -1769,9 +1775,16 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab) ath11k_warn(ab, "qmi mem size is low to load caldata\n"); return -EINVAL; } - /* TODO ath11k does not support cold boot calibration */ - ab->qmi.target_mem[idx].paddr = 0; - ab->qmi.target_mem[idx].vaddr = NULL; + + if (ath11k_cold_boot_cal && ab->hw_params.cold_boot_calib) { + ab->qmi.target_mem[idx].paddr = + ATH11K_QMI_CALDB_ADDRESS; + ab->qmi.target_mem[idx].vaddr = + (void *)ATH11K_QMI_CALDB_ADDRESS; + } else { + ab->qmi.target_mem[idx].paddr = 0; + ab->qmi.target_mem[idx].vaddr = NULL; + } ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; idx++; @@ -2357,6 +2370,32 @@ int ath11k_qmi_firmware_start(struct ath11k_base *ab, return 0; } +static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) +{ + int timeout; + int ret; + + ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_COLD_BOOT); + if (ret < 0) { + ath11k_warn(ab, "qmi failed to send wlan fw mode:%d\n", ret); + return ret; + } + + ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration wait started\n"); + + timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, + (ab->qmi.cal_done == 1), + ATH11K_COLD_BOOT_FW_RESET_DELAY); + if (timeout <= 0) { + ath11k_warn(ab, "Coldboot Calibration failed - wait ended\n"); + return 0; + } + + ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration done\n"); + + return 0; +} + static int ath11k_qmi_driver_event_post(struct ath11k_qmi *qmi, enum ath11k_qmi_event_type type, @@ -2506,11 +2545,18 @@ static void ath11k_qmi_msg_fw_ready_cb(struct qmi_handle *qmi_hdl, ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_FW_READY, NULL); } -static void ath11k_qmi_msg_cold_boot_cal_done_cb(struct qmi_handle *qmi, +static void ath11k_qmi_msg_cold_boot_cal_done_cb(struct qmi_handle *qmi_hdl, struct sockaddr_qrtr *sq, struct qmi_txn *txn, const void *decoded) { + struct ath11k_qmi *qmi = container_of(qmi_hdl, + struct ath11k_qmi, handle); + struct ath11k_base *ab = qmi->ab; + + ab->qmi.cal_done = 1; + wake_up(&ab->qmi.cold_boot_waitq); + ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi cold boot calibration done\n"); } static const struct qmi_msg_handler ath11k_qmi_msg_handlers[] = { @@ -2623,9 +2669,16 @@ static void ath11k_qmi_driver_event_work(struct work_struct *work) break; } - ath11k_core_qmi_firmware_ready(ab); - ab->qmi.cal_done = 1; - set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags); + if (ath11k_cold_boot_cal && ab->qmi.cal_done == 0 && + ab->hw_params.cold_boot_calib) { + ath11k_qmi_process_coldboot_calibration(ab); + } else { + clear_bit(ATH11K_FLAG_CRASH_FLUSH, + &ab->dev_flags); + clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); + ath11k_core_qmi_firmware_ready(ab); + set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags); + } break; case ATH11K_QMI_EVENT_COLD_BOOT_CAL_DONE: diff --git a/drivers/net/wireless/ath/ath11k/qmi.h b/drivers/net/wireless/ath/ath11k/qmi.h index 7b170bc9a913..92925c9eac67 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.h +++ b/drivers/net/wireless/ath/ath11k/qmi.h @@ -12,6 +12,7 @@ #define ATH11K_HOST_VERSION_STRING "WIN" #define ATH11K_QMI_WLANFW_TIMEOUT_MS 5000 #define ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE 64 +#define ATH11K_QMI_CALDB_ADDRESS 0x4BA00000 #define ATH11K_QMI_BDF_MAX_SIZE (256 * 1024) #define ATH11K_QMI_CALDATA_OFFSET (128 * 1024) #define ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 128 @@ -34,6 +35,7 @@ #define QMI_WLANFW_MAX_DATA_SIZE_V01 6144 #define ATH11K_FIRMWARE_MODE_OFF 4 #define ATH11K_QMI_TARGET_MEM_MODE_DEFAULT 0 +#define ATH11K_COLD_BOOT_FW_RESET_DELAY (40 * HZ) struct ath11k_base; @@ -127,6 +129,7 @@ struct ath11k_qmi { struct target_info target; struct m3_mem_region m3_mem; unsigned int service_ins_id; + wait_queue_head_t cold_boot_waitq; }; #define QMI_WLANFW_HOST_CAP_REQ_MSG_V01_MAX_LEN 189 From 383a32cde4172db19d4743d4c782c00af39ff275 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Wed, 21 Oct 2020 16:05:55 +0200 Subject: [PATCH 014/180] ath11k: Initialize complete alpha2 for regulatory change The function ath11k_wmi_send_init_country_cmd is taking 3 byte from alpha2 of the structure wmi_init_country_params. But the function ath11k_reg_notifier is only initializing 2 bytes. The third byte is therefore always an uninitialized value. The command can happen to look like 0c 00 87 02 01 00 00 00 00 00 00 00 43 41 f8 00 instead of 0c 00 87 02 01 00 00 00 00 00 00 00 43 41 00 00 Tested-on: IPQ8074 hw2.0 WLAN.HK.2.1.0.1-01161-QCAHKSWPL_SILICONZ-1 Tested-on: IPQ8074 hw2.0 WLAN.HK.2.1.0.1-01228-QCAHKSWPL_SILICONZ-1 Tested-on: IPQ8074 hw2.0 WLAN.HK.2.1.0.1-01238-QCAHKSWPL_SILICONZ-2 Tested-on: IPQ8074 hw2.0 WLAN.HK.2.4.0.1.r1-00019-QCAHKSWPL_SILICONZ-1 Tested-on: IPQ8074 hw2.0 WLAN.HK.2.4.0.1.r1-00026-QCAHKSWPL_SILICONZ-2 Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Sven Eckelmann Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201021140555.4114715-1-sven@narfation.org --- drivers/net/wireless/ath/ath11k/reg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/ath11k/reg.c b/drivers/net/wireless/ath/ath11k/reg.c index f6a1f0352989..83f75f8855eb 100644 --- a/drivers/net/wireless/ath/ath11k/reg.c +++ b/drivers/net/wireless/ath/ath11k/reg.c @@ -80,6 +80,7 @@ ath11k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) */ init_country_param.flags = ALPHA_IS_SET; memcpy(&init_country_param.cc_info.alpha2, request->alpha2, 2); + init_country_param.cc_info.alpha2[2] = 0; ret = ath11k_wmi_send_init_country_cmd(ar, init_country_param); if (ret) From ff34107c22243a8f43d8aa0f100e177a4d56e95a Mon Sep 17 00:00:00 2001 From: Govind Singh Date: Thu, 22 Oct 2020 09:29:35 +0530 Subject: [PATCH 015/180] ath11k: Remove unused param from wmi_mgmt_params qdf_ctx is not used in wmi_mgmt_params, remove this un-used variable. Compile tested only. Signed-off-by: Govind Singh Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1603339175-12706-1-git-send-email-govinds@codeaurora.org --- drivers/net/wireless/ath/ath11k/wmi.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h index b722a87144b6..e4cc15904795 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.h +++ b/drivers/net/wireless/ath/ath11k/wmi.h @@ -3354,7 +3354,6 @@ struct wmi_mgmt_params { void *pdata; u16 desc_id; u8 *macaddr; - void *qdf_ctx; }; enum wmi_sta_ps_mode { From 6189be7d145c3a2d48514eb8755483602ff5a4b4 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Fri, 30 Oct 2020 11:19:40 +0100 Subject: [PATCH 016/180] ath11k: Fix number of rules in filtered ETSI regdomain The ath11k code will try to insert wheather rader related limits when the DFS region is set to ETSI. For this reason, it will add two more entries in the array of reg_rules. But the 2.4.0.1 firmware is prefiltering the list of reg rules it returns for 2.4GHz PHYs. They will then not contain the list of 5GHz rules and thus no wheather radar band rules were inserted by this code. But the code didn't fix the n_reg_rules for this regulatory domain and PHY when this happened. This resulted in a rejection by is_valid_rd because it found rules which start and end at 0khz. This resulted in a splat like: Invalid regulatory domain detected ------------[ cut here ]------------ WARNING: at backports-20200628-4.4.60-9a94b73e75/net/wireless/reg.c:3721 [...] ath11k c000000.wifi1: failed to perform regd update : -22 The number of rules must therefore be saved after they were converted from the ath11k format to the ieee80211_regdomain format and not before. Tested with IPQ8074 WLAN.HK.2.4.0.1.r1-00019-QCAHKSWPL_SILICONZ-1 Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Sven Eckelmann Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201030101940.2387952-1-sven@narfation.org --- drivers/net/wireless/ath/ath11k/reg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/reg.c b/drivers/net/wireless/ath/ath11k/reg.c index 83f75f8855eb..678d0885fcee 100644 --- a/drivers/net/wireless/ath/ath11k/reg.c +++ b/drivers/net/wireless/ath/ath11k/reg.c @@ -585,7 +585,6 @@ ath11k_reg_build_regd(struct ath11k_base *ab, if (!tmp_regd) goto ret; - tmp_regd->n_reg_rules = num_rules; memcpy(tmp_regd->alpha2, reg_info->alpha2, REG_ALPHA2_LEN + 1); memcpy(alpha2, reg_info->alpha2, REG_ALPHA2_LEN + 1); alpha2[2] = '\0'; @@ -598,7 +597,7 @@ ath11k_reg_build_regd(struct ath11k_base *ab, /* Update reg_rules[] below. Firmware is expected to * send these rules in order(2G rules first and then 5G) */ - for (; i < tmp_regd->n_reg_rules; i++) { + for (; i < num_rules; i++) { if (reg_info->num_2g_reg_rules && (i < reg_info->num_2g_reg_rules)) { reg_rule = reg_info->reg_rules_2g_ptr + i; @@ -653,6 +652,8 @@ ath11k_reg_build_regd(struct ath11k_base *ab, flags); } + tmp_regd->n_reg_rules = i; + if (intersect) { default_regd = ab->default_regd[reg_info->phy_id]; From 9fb13b81e1456c3911b86167470fc05dc9114a07 Mon Sep 17 00:00:00 2001 From: Karthikeyan Periyasamy Date: Wed, 4 Nov 2020 23:05:31 +0530 Subject: [PATCH 017/180] ath11k: Fix single phy hw mode driver not able to bootup in the single radio configured board. single phy hw mode is converted to invalid hw mode and sent to FW through wmi init cmd. In that case driver is not receiving wmi ready event which leads to driver bootup fail. single phy hw mode is a valid for single radio configured board. so removed the conversion logic. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.1.0.1-01238-QCAHKSWPL_SILICONZ-2 Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604511331-22477-1-git-send-email-periyasa@codeaurora.org --- drivers/net/wireless/ath/ath11k/wmi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 8049c96744b2..40032c2b4975 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -3486,9 +3486,6 @@ int ath11k_wmi_cmd_init(struct ath11k_base *ab) init_param.hw_mode_id = wmi_sc->preferred_hw_mode; init_param.mem_chunks = wmi_sc->mem_chunks; - if (wmi_sc->preferred_hw_mode == WMI_HOST_HW_MODE_SINGLE) - init_param.hw_mode_id = WMI_HOST_HW_MODE_MAX; - if (ab->hw_params.needs_band_to_mac) { init_param.num_band_to_mac = ab->num_radios; ath11k_fill_band_to_mac_param(ab, init_param.band_to_mac); From ab041d060ee655be528fa4ee6ee8f8c3f52a7056 Mon Sep 17 00:00:00 2001 From: Karthikeyan Periyasamy Date: Wed, 4 Nov 2020 23:15:21 +0530 Subject: [PATCH 018/180] ath11k: Fix the hal descriptor mask Below listed hal descriptor mask are incorrect, so modify it to correct one - CE destination status description meta info mask is increased from 8 bits to 16 bits from the 0th bit position - Rx Reo queue duplicate count mask is decreased from 22 bits to 16 bits - Reo threshold status counter sum mask is increased from 24 bits to 26 bits No functionality impact, these descriptors are currently not used in any supported platform. But in future if someone referred these descriptor then ended with wrong values. Found this during code review. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.1.0.1-01238-QCAHKSWPL_SILICONZ-2 Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604511921-24840-1-git-send-email-periyasa@codeaurora.org --- drivers/net/wireless/ath/ath11k/hal_desc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/hal_desc.h b/drivers/net/wireless/ath/ath11k/hal_desc.h index ceebdc28ddeb..1b713cb13b90 100644 --- a/drivers/net/wireless/ath/ath11k/hal_desc.h +++ b/drivers/net/wireless/ath/ath11k/hal_desc.h @@ -1425,7 +1425,7 @@ struct hal_ce_srng_dest_desc { #define HAL_CE_DST_STATUS_DESC_FLAGS_GATHER BIT(11) #define HAL_CE_DST_STATUS_DESC_FLAGS_LEN GENMASK(31, 16) -#define HAL_CE_DST_STATUS_DESC_META_INFO_DATA GENMASK(7, 0) +#define HAL_CE_DST_STATUS_DESC_META_INFO_DATA GENMASK(15, 0) #define HAL_CE_DST_STATUS_DESC_META_INFO_RING_ID GENMASK(27, 20) #define HAL_CE_DST_STATUS_DESC_META_INFO_LOOP_CNT HAL_SRNG_DESC_LOOP_CNT @@ -1946,7 +1946,7 @@ enum hal_rx_reo_queue_pn_size { #define HAL_RX_REO_QUEUE_INFO3_TIMEOUT_COUNT GENMASK(9, 4) #define HAL_RX_REO_QUEUE_INFO3_FWD_DUE_TO_BAR_CNT GENMASK(15, 10) -#define HAL_RX_REO_QUEUE_INFO3_DUPLICATE_COUNT GENMASK(31, 10) +#define HAL_RX_REO_QUEUE_INFO3_DUPLICATE_COUNT GENMASK(31, 16) #define HAL_RX_REO_QUEUE_INFO4_FRAME_IN_ORD_COUNT GENMASK(23, 0) #define HAL_RX_REO_QUEUE_INFO4_BAR_RECVD_COUNT GENMASK(31, 24) @@ -2432,7 +2432,7 @@ struct hal_reo_flush_timeout_list_status { #define HAL_REO_DESC_THRESH_STATUS_INFO1_LINK_DESC_COUNTER0 GENMASK(23, 0) #define HAL_REO_DESC_THRESH_STATUS_INFO2_LINK_DESC_COUNTER1 GENMASK(23, 0) #define HAL_REO_DESC_THRESH_STATUS_INFO3_LINK_DESC_COUNTER2 GENMASK(23, 0) -#define HAL_REO_DESC_THRESH_STATUS_INFO4_LINK_DESC_COUNTER_SUM GENMASK(23, 0) +#define HAL_REO_DESC_THRESH_STATUS_INFO4_LINK_DESC_COUNTER_SUM GENMASK(25, 0) struct hal_reo_desc_thresh_reached_status { struct hal_reo_status_hdr hdr; From 36c7c640ffeb87168e5ff79b7a36ae3a020bd378 Mon Sep 17 00:00:00 2001 From: Karthikeyan Periyasamy Date: Wed, 4 Nov 2020 23:17:00 +0530 Subject: [PATCH 019/180] ath11k: fix wmi init configuration Assign the correct hw_op ath11k_init_wmi_config_ipq8074 to the hw IPQ8074. Also update the correct TWT radio count. Incorrect TWT radio count cause TWT feature fails on radio2 because physical device count is hardcoded to 2. so set the value dynamically. Found this during code review. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.1.0.1-01238-QCAHKSWPL_SILICONZ-2 Fixes: 2d4bcbed5b7d53e1 ("ath11k: initialize wmi config based on hw_params") Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604512020-25197-1-git-send-email-periyasa@codeaurora.org --- drivers/net/wireless/ath/ath11k/hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/hw.c b/drivers/net/wireless/ath/ath11k/hw.c index 11a411b76fe4..66331da35012 100644 --- a/drivers/net/wireless/ath/ath11k/hw.c +++ b/drivers/net/wireless/ath/ath11k/hw.c @@ -127,7 +127,7 @@ static void ath11k_init_wmi_config_ipq8074(struct ath11k_base *ab, config->beacon_tx_offload_max_vdev = ab->num_radios * TARGET_MAX_BCN_OFFLD; config->rx_batchmode = TARGET_RX_BATCHMODE; config->peer_map_unmap_v2_support = 1; - config->twt_ap_pdev_count = 2; + config->twt_ap_pdev_count = ab->num_radios; config->twt_ap_sta_count = 1000; } @@ -157,7 +157,7 @@ static int ath11k_hw_mac_id_to_srng_id_qca6390(struct ath11k_hw_params *hw, const struct ath11k_hw_ops ipq8074_ops = { .get_hw_mac_from_pdev_id = ath11k_hw_ipq8074_mac_from_pdev_id, - .wmi_init_config = ath11k_init_wmi_config_qca6390, + .wmi_init_config = ath11k_init_wmi_config_ipq8074, .mac_id_to_pdev_id = ath11k_hw_mac_id_to_pdev_id_ipq8074, .mac_id_to_srng_id = ath11k_hw_mac_id_to_srng_id_ipq8074, }; From 47f1a84e2451d4fbf2904e71b56fbcc18114afba Mon Sep 17 00:00:00 2001 From: Lavanya Suresh Date: Thu, 5 Nov 2020 13:34:35 +0530 Subject: [PATCH 020/180] ath11k: Add new dfs region name for JP Japan has new Radar types as per latest regulatory, included under MKK_N in FW. So adding new enum in ath11k to support it. Tested-on: IPQ8074 hw2.0 PCI WLAN.HK.2.4.0.1-00041-QCAHKSWPL_SILICONZ-1 Signed-off-by: Lavanya Suresh Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604563475-5782-1-git-send-email-lavaks@codeaurora.org --- drivers/net/wireless/ath/ath11k/reg.c | 1 + drivers/net/wireless/ath/ath11k/reg.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/reg.c b/drivers/net/wireless/ath/ath11k/reg.c index 678d0885fcee..b876fec7fa1b 100644 --- a/drivers/net/wireless/ath/ath11k/reg.c +++ b/drivers/net/wireless/ath/ath11k/reg.c @@ -278,6 +278,7 @@ ath11k_map_fw_dfs_region(enum ath11k_dfs_region dfs_region) case ATH11K_DFS_REG_KR: return NL80211_DFS_ETSI; case ATH11K_DFS_REG_MKK: + case ATH11K_DFS_REG_MKK_N: return NL80211_DFS_JP; default: return NL80211_DFS_UNSET; diff --git a/drivers/net/wireless/ath/ath11k/reg.h b/drivers/net/wireless/ath/ath11k/reg.h index 39b7fc943541..65d56d44796f 100644 --- a/drivers/net/wireless/ath/ath11k/reg.h +++ b/drivers/net/wireless/ath/ath11k/reg.h @@ -20,6 +20,7 @@ enum ath11k_dfs_region { ATH11K_DFS_REG_MKK, ATH11K_DFS_REG_CN, ATH11K_DFS_REG_KR, + ATH11K_DFS_REG_MKK_N, ATH11K_DFS_REG_UNDEF, }; From aed7ee049a3e92a1f2b64da199cf93df3e6bfeb6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:48 +0000 Subject: [PATCH 021/180] ath: regd: Provide description for ath_reg_apply_ir_flags's 'reg' param Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/regd.c:378: warning: Function parameter or member 'reg' not described in 'ath_reg_apply_ir_flags' Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-20-lee.jones@linaro.org --- drivers/net/wireless/ath/regd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c index bee9110b91f3..b2400e2417a5 100644 --- a/drivers/net/wireless/ath/regd.c +++ b/drivers/net/wireless/ath/regd.c @@ -360,6 +360,7 @@ ath_reg_apply_beaconing_flags(struct wiphy *wiphy, /** * ath_reg_apply_ir_flags() * @wiphy: the wiphy to use + * @reg: regulatory structure - used for country selection * @initiator: the regulatory hint initiator * * If no country IE has been received always enable passive scan From 206cd5800d8c7893b69bde0e607321e934815a54 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:50 +0000 Subject: [PATCH 022/180] ath: dfs_pattern_detector: Fix some function kernel-doc headers Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/dfs_pattern_detector.c:34: warning: Function parameter or member 'region' not described in 'radar_types' drivers/net/wireless/ath/dfs_pattern_detector.c:141: warning: Function parameter or member 'region' not described in 'get_dfs_domain_radar_types' drivers/net/wireless/ath/dfs_pattern_detector.c:239: warning: Function parameter or member 'dpd' not described in 'channel_detector_get' drivers/net/wireless/ath/dfs_pattern_detector.c:239: warning: Function parameter or member 'freq' not described in 'channel_detector_get' Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-22-lee.jones@linaro.org --- drivers/net/wireless/ath/dfs_pattern_detector.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/dfs_pattern_detector.c b/drivers/net/wireless/ath/dfs_pattern_detector.c index 0813473793df..80390495ea25 100644 --- a/drivers/net/wireless/ath/dfs_pattern_detector.c +++ b/drivers/net/wireless/ath/dfs_pattern_detector.c @@ -23,7 +23,7 @@ /** * struct radar_types - contains array of patterns defined for one DFS domain - * @domain: DFS regulatory domain + * @region: regulatory DFS region * @num_radar_types: number of radar types to follow * @radar_types: radar types array */ @@ -133,8 +133,9 @@ static const struct radar_types *dfs_domains[] = { /** * get_dfs_domain_radar_types() - get radar types for a given DFS domain - * @param domain DFS domain - * @return radar_types ptr on success, NULL if DFS domain is not supported + * @region: regulatory DFS region + * + * Return value: radar_types ptr on success, NULL if DFS domain is not supported */ static const struct radar_types * get_dfs_domain_radar_types(enum nl80211_dfs_regions region) @@ -227,9 +228,10 @@ channel_detector_create(struct dfs_pattern_detector *dpd, u16 freq) /** * channel_detector_get() - get channel detector for given frequency - * @param dpd instance pointer - * @param freq frequency in MHz - * @return pointer to channel detector on success, NULL otherwise + * @dpd: DPD instance pointer + * @freq: freq frequency in MHz + * + * Return value: pointer to channel detector on success, NULL otherwise * * Return existing channel detector for the given frequency or return a * newly create one. From 748d250777e6eb461eb2279005e8deab4cff2845 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:51 +0000 Subject: [PATCH 023/180] ath: dfs_pri_detector: Demote zero/half completed kernel-doc headers There are only a couple of these and none of them are conformant. Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/dfs_pri_detector.c:39: warning: Function parameter or member 'head' not described in 'pulse_elem' drivers/net/wireless/ath/dfs_pri_detector.c:46: warning: Function parameter or member 'val' not described in 'pde_get_multiple' drivers/net/wireless/ath/dfs_pri_detector.c:46: warning: Function parameter or member 'fraction' not described in 'pde_get_multiple' drivers/net/wireless/ath/dfs_pri_detector.c:46: warning: Function parameter or member 'tolerance' not described in 'pde_get_multiple' Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-23-lee.jones@linaro.org --- drivers/net/wireless/ath/dfs_pri_detector.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/dfs_pri_detector.c b/drivers/net/wireless/ath/dfs_pri_detector.c index 05b0464c6b92..d07c454c9c00 100644 --- a/drivers/net/wireless/ath/dfs_pri_detector.c +++ b/drivers/net/wireless/ath/dfs_pri_detector.c @@ -29,18 +29,17 @@ struct ath_dfs_pool_stats global_dfs_pool_stats = {}; (MIN + PRI_TOLERANCE == MAX - PRI_TOLERANCE ? \ MIN + PRI_TOLERANCE : RUNTIME) -/** +/* * struct pulse_elem - elements in pulse queue - * @ts: time stamp in usecs */ struct pulse_elem { struct list_head head; u64 ts; }; -/** +/* * pde_get_multiple() - get number of multiples considering a given tolerance - * @return factor if abs(val - factor*fraction) <= tolerance, 0 otherwise + * Return value: factor if abs(val - factor*fraction) <= tolerance, 0 otherwise */ static u32 pde_get_multiple(u32 val, u32 fraction, u32 tolerance) { @@ -70,7 +69,7 @@ static u32 pde_get_multiple(u32 val, u32 fraction, u32 tolerance) return factor; } -/** +/* * DOC: Singleton Pulse and Sequence Pools * * Instances of pri_sequence and pulse_elem are kept in singleton pools to From 3fc95aacc6fa62a623ae727fe631c03180efc206 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:39 +0000 Subject: [PATCH 024/180] ath9k: ar9330_1p1_initvals: Remove unused const variable 'ar9331_common_tx_gain_offset1_1' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/ath9k/ar9330_1p1_initvals.h:1013:18: warning: ‘ar9331_common_tx_gain_offset1_1’ defined but not used [-Wunused-const-variable=] Cc: QCA ath9k Development Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-11-lee.jones@linaro.org --- drivers/net/wireless/ath/ath9k/ar9330_1p1_initvals.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9330_1p1_initvals.h b/drivers/net/wireless/ath/ath9k/ar9330_1p1_initvals.h index 29479afbc4f1..3e783fc13553 100644 --- a/drivers/net/wireless/ath/ath9k/ar9330_1p1_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9330_1p1_initvals.h @@ -1010,11 +1010,4 @@ static const u32 ar9331_common_rx_gain_1p1[][2] = { {0x0000a1fc, 0x00000296}, }; -static const u32 ar9331_common_tx_gain_offset1_1[][1] = { - {0x00000000}, - {0x00000003}, - {0x00000000}, - {0x00000000}, -}; - #endif /* INITVALS_9330_1P1_H */ From 30c2751b845865cfc3619620b81f21db306a0033 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:40 +0000 Subject: [PATCH 025/180] ath9k: ar9340_initvals: Remove unused const variable 'ar9340Modes_ub124_tx_gain_table_1p0' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/ath9k/ar9340_initvals.h:624:18: warning: ‘ar9340Modes_ub124_tx_gain_table_1p0’ defined but not used [-Wunused-const-variable=] Cc: QCA ath9k Development Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-12-lee.jones@linaro.org --- .../net/wireless/ath/ath9k/ar9340_initvals.h | 101 ------------------ 1 file changed, 101 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9340_initvals.h b/drivers/net/wireless/ath/ath9k/ar9340_initvals.h index 2eb163fc1c18..3da4ea564148 100644 --- a/drivers/net/wireless/ath/ath9k/ar9340_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9340_initvals.h @@ -621,107 +621,6 @@ static const u32 ar9340Modes_high_ob_db_tx_gain_table_1p0[][5] = { {0x00016448, 0x8e481666, 0x8e481666, 0x8e481266, 0x8e481266}, }; -static const u32 ar9340Modes_ub124_tx_gain_table_1p0[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8005, 0xd00a8005}, - {0x00009820, 0x206a022e, 0x206a022e, 0x206a00ae, 0x206a00ae}, - {0x00009830, 0x0000059c, 0x0000059c, 0x0000059c, 0x0000059c}, - {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec82d2e, 0x7ec82d2e}, - {0x0000a2dc, 0xfef5d402, 0xfef5d402, 0xfdab5b52, 0xfdab5b52}, - {0x0000a2e0, 0xfe896600, 0xfe896600, 0xfd339c84, 0xfd339c84}, - {0x0000a2e4, 0xff01f800, 0xff01f800, 0xfec3e000, 0xfec3e000}, - {0x0000a2e8, 0xfffe0000, 0xfffe0000, 0xfffc0000, 0xfffc0000}, - {0x0000a410, 0x000050d8, 0x000050d8, 0x000050d9, 0x000050d9}, - {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000}, - {0x0000a504, 0x04002222, 0x04002222, 0x04000002, 0x04000002}, - {0x0000a508, 0x09002421, 0x09002421, 0x08000004, 0x08000004}, - {0x0000a50c, 0x0d002621, 0x0d002621, 0x0b000200, 0x0b000200}, - {0x0000a510, 0x13004620, 0x13004620, 0x0f000202, 0x0f000202}, - {0x0000a514, 0x19004a20, 0x19004a20, 0x11000400, 0x11000400}, - {0x0000a518, 0x1d004e20, 0x1d004e20, 0x15000402, 0x15000402}, - {0x0000a51c, 0x21005420, 0x21005420, 0x19000404, 0x19000404}, - {0x0000a520, 0x26005e20, 0x26005e20, 0x1b000603, 0x1b000603}, - {0x0000a524, 0x2b005e40, 0x2b005e40, 0x1f000a02, 0x1f000a02}, - {0x0000a528, 0x2f005e42, 0x2f005e42, 0x23000a04, 0x23000a04}, - {0x0000a52c, 0x33005e44, 0x33005e44, 0x26000a20, 0x26000a20}, - {0x0000a530, 0x38005e65, 0x38005e65, 0x2a000e20, 0x2a000e20}, - {0x0000a534, 0x3c005e69, 0x3c005e69, 0x2e000e22, 0x2e000e22}, - {0x0000a538, 0x40005e6b, 0x40005e6b, 0x31000e24, 0x31000e24}, - {0x0000a53c, 0x44005e6d, 0x44005e6d, 0x34001640, 0x34001640}, - {0x0000a540, 0x49005e72, 0x49005e72, 0x38001660, 0x38001660}, - {0x0000a544, 0x4e005eb2, 0x4e005eb2, 0x3b001861, 0x3b001861}, - {0x0000a548, 0x53005f12, 0x53005f12, 0x3e001a81, 0x3e001a81}, - {0x0000a54c, 0x59025eb5, 0x59025eb5, 0x42001a83, 0x42001a83}, - {0x0000a550, 0x5e025f12, 0x5e025f12, 0x44001c84, 0x44001c84}, - {0x0000a554, 0x61027f12, 0x61027f12, 0x48001ce3, 0x48001ce3}, - {0x0000a558, 0x6702bf12, 0x6702bf12, 0x4c001ce5, 0x4c001ce5}, - {0x0000a55c, 0x6b02bf14, 0x6b02bf14, 0x50001ce9, 0x50001ce9}, - {0x0000a560, 0x6f02bf16, 0x6f02bf16, 0x54001ceb, 0x54001ceb}, - {0x0000a564, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec}, - {0x0000a568, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec}, - {0x0000a56c, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec}, - {0x0000a570, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec}, - {0x0000a574, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec}, - {0x0000a578, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec}, - {0x0000a57c, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec}, - {0x0000a580, 0x00802220, 0x00802220, 0x00800000, 0x00800000}, - {0x0000a584, 0x04802222, 0x04802222, 0x04800002, 0x04800002}, - {0x0000a588, 0x09802421, 0x09802421, 0x08800004, 0x08800004}, - {0x0000a58c, 0x0d802621, 0x0d802621, 0x0b800200, 0x0b800200}, - {0x0000a590, 0x13804620, 0x13804620, 0x0f800202, 0x0f800202}, - {0x0000a594, 0x19804a20, 0x19804a20, 0x11800400, 0x11800400}, - {0x0000a598, 0x1d804e20, 0x1d804e20, 0x15800402, 0x15800402}, - {0x0000a59c, 0x21805420, 0x21805420, 0x19800404, 0x19800404}, - {0x0000a5a0, 0x26805e20, 0x26805e20, 0x1b800603, 0x1b800603}, - {0x0000a5a4, 0x2b805e40, 0x2b805e40, 0x1f800a02, 0x1f800a02}, - {0x0000a5a8, 0x2f805e42, 0x2f805e42, 0x23800a04, 0x23800a04}, - {0x0000a5ac, 0x33805e44, 0x33805e44, 0x26800a20, 0x26800a20}, - {0x0000a5b0, 0x38805e65, 0x38805e65, 0x2a800e20, 0x2a800e20}, - {0x0000a5b4, 0x3c805e69, 0x3c805e69, 0x2e800e22, 0x2e800e22}, - {0x0000a5b8, 0x40805e6b, 0x40805e6b, 0x31800e24, 0x31800e24}, - {0x0000a5bc, 0x44805e6d, 0x44805e6d, 0x34801640, 0x34801640}, - {0x0000a5c0, 0x49805e72, 0x49805e72, 0x38801660, 0x38801660}, - {0x0000a5c4, 0x4e805eb2, 0x4e805eb2, 0x3b801861, 0x3b801861}, - {0x0000a5c8, 0x53805f12, 0x53805f12, 0x3e801a81, 0x3e801a81}, - {0x0000a5cc, 0x59825eb2, 0x59825eb2, 0x42801a83, 0x42801a83}, - {0x0000a5d0, 0x5e825f12, 0x5e825f12, 0x44801c84, 0x44801c84}, - {0x0000a5d4, 0x61827f12, 0x61827f12, 0x48801ce3, 0x48801ce3}, - {0x0000a5d8, 0x6782bf12, 0x6782bf12, 0x4c801ce5, 0x4c801ce5}, - {0x0000a5dc, 0x6b82bf14, 0x6b82bf14, 0x50801ce9, 0x50801ce9}, - {0x0000a5e0, 0x6f82bf16, 0x6f82bf16, 0x54801ceb, 0x54801ceb}, - {0x0000a5e4, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, - {0x0000a5e8, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, - {0x0000a5ec, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, - {0x0000a5f0, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, - {0x0000a5f4, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, - {0x0000a5f8, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, - {0x0000a5fc, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec}, - {0x00016044, 0x03b6d2e4, 0x03b6d2e4, 0x03b6d2e4, 0x03b6d2e4}, - {0x00016048, 0x8e480086, 0x8e480086, 0x8e480086, 0x8e480086}, - {0x00016444, 0x03b6d2e4, 0x03b6d2e4, 0x03b6d2e4, 0x03b6d2e4}, - {0x00016448, 0x8e480086, 0x8e480086, 0x8e480086, 0x8e480086}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00804000, 0x00804000, 0x00000000, 0x00000000}, - {0x0000a614, 0x00804201, 0x00804201, 0x01404000, 0x01404000}, - {0x0000a618, 0x0280c802, 0x0280c802, 0x01404501, 0x01404501}, - {0x0000a61c, 0x0280ca03, 0x0280ca03, 0x02008501, 0x02008501}, - {0x0000a620, 0x04c15104, 0x04c15104, 0x0280ca03, 0x0280ca03}, - {0x0000a624, 0x04c15305, 0x04c15305, 0x03010c04, 0x03010c04}, - {0x0000a628, 0x04c15305, 0x04c15305, 0x04014c04, 0x04014c04}, - {0x0000a62c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a630, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a634, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a638, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a63c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000b2dc, 0xfef5d402, 0xfef5d402, 0xfdab5b52, 0xfdab5b52}, - {0x0000b2e0, 0xfe896600, 0xfe896600, 0xfd339c84, 0xfd339c84}, - {0x0000b2e4, 0xff01f800, 0xff01f800, 0xfec3e000, 0xfec3e000}, - {0x0000b2e8, 0xfffe0000, 0xfffe0000, 0xfffc0000, 0xfffc0000}, -}; - static const u32 ar9340Modes_low_ob_db_tx_gain_table_1p0[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352}, From 9190c64e4720f6ed06be4d69d8d6b8d7fe68fe37 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:41 +0000 Subject: [PATCH 026/180] ath9k: ar9485_initvals: Remove unused const variable 'ar9485_fast_clock_1_1_baseband_postamble' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/ath9k/ar9485_initvals.h:1009:18: warning: ‘ar9485_fast_clock_1_1_baseband_postamble’ defined but not used [-Wunused-const-variable=] Cc: QCA ath9k Development Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-13-lee.jones@linaro.org --- drivers/net/wireless/ath/ath9k/ar9485_initvals.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9485_initvals.h b/drivers/net/wireless/ath/ath9k/ar9485_initvals.h index bdf6f107f6f1..4afe52c0456e 100644 --- a/drivers/net/wireless/ath/ath9k/ar9485_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9485_initvals.h @@ -1006,13 +1006,6 @@ static const u32 ar9485_1_1_soc_preamble[][2] = { {0x00007048, 0x00000002}, }; -static const u32 ar9485_fast_clock_1_1_baseband_postamble[][3] = { - /* Addr 5G_HT20 5G_HT40 */ - {0x00009e00, 0x03721821, 0x03721821}, - {0x0000a230, 0x0000400b, 0x00004016}, - {0x0000a254, 0x00000898, 0x00001130}, -}; - static const u32 ar9485_1_1_baseband_postamble[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8005, 0xd00a8005}, From b5cafcb16f458f989e47448770d59384b879d19e Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:42 +0000 Subject: [PATCH 027/180] ath9k: ar9003_2p2_initvals: Remove unused const variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h:1734:18: warning: ‘ar9300PciePhy_clkreq_disable_L1_2p2’ defined but not used [-Wunused-const-variable=] drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h:1727:18: warning: ‘ar9300PciePhy_clkreq_enable_L1_2p2’ defined but not used [-Wunused-const-variable=] Cc: QCA ath9k Development Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-14-lee.jones@linaro.org --- .../net/wireless/ath/ath9k/ar9003_2p2_initvals.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h index c07866a2fdf9..16d5c0c5e2a8 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h @@ -1724,20 +1724,6 @@ static const u32 ar9300PciePhy_pll_on_clkreq_disable_L1_2p2[][2] = { {0x00004044, 0x00000000}, }; -static const u32 ar9300PciePhy_clkreq_enable_L1_2p2[][2] = { - /* Addr allmodes */ - {0x00004040, 0x0825365e}, - {0x00004040, 0x0008003b}, - {0x00004044, 0x00000000}, -}; - -static const u32 ar9300PciePhy_clkreq_disable_L1_2p2[][2] = { - /* Addr allmodes */ - {0x00004040, 0x0821365e}, - {0x00004040, 0x0008003b}, - {0x00004044, 0x00000000}, -}; - static const u32 ar9300_2p2_baseband_core_txfir_coeff_japan_2484[][2] = { /* Addr allmodes */ {0x0000a398, 0x00000000}, From 8cc107b57109245630cde66909c995949562155d Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:49 +0000 Subject: [PATCH 028/180] ath9k: ar5008_phy: Demote half completed function headers Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/ath9k/ar5008_phy.c:119: warning: Function parameter or member 'rfBuf' not described in 'ar5008_hw_phy_modify_rx_buffer' drivers/net/wireless/ath/ath9k/ar5008_phy.c:119: warning: Function parameter or member 'reg32' not described in 'ar5008_hw_phy_modify_rx_buffer' drivers/net/wireless/ath/ath9k/ar5008_phy.c:119: warning: Function parameter or member 'numBits' not described in 'ar5008_hw_phy_modify_rx_buffer' drivers/net/wireless/ath/ath9k/ar5008_phy.c:119: warning: Function parameter or member 'firstBit' not described in 'ar5008_hw_phy_modify_rx_buffer' Cc: QCA ath9k Development Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-21-lee.jones@linaro.org --- drivers/net/wireless/ath/ath9k/ar5008_phy.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c index 2fa30834a88d..6610d76131fa 100644 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c @@ -102,13 +102,8 @@ static void ar5008_write_bank6(struct ath_hw *ah, unsigned int *writecnt) REGWRITE_BUFFER_FLUSH(ah); } -/** +/* * ar5008_hw_phy_modify_rx_buffer() - perform analog swizzling of parameters - * @rfbuf: - * @reg32: - * @numBits: - * @firstBit: - * @column: * * Performs analog "swizzling" of parameters into their location. * Used on external AR2133/AR5133 radios. @@ -198,10 +193,8 @@ static void ar5008_hw_force_bias(struct ath_hw *ah, u16 synth_freq) ar5008_write_bank6(ah, ®_writes); } -/** +/* * ar5008_hw_set_channel - tune to a channel on the external AR2133/AR5133 radios - * @ah: atheros hardware structure - * @chan: * * For the external AR2133/AR5133 radios, takes the MHz channel value and set * the channel value. Assumes writes enabled to analog bus and bank6 register @@ -430,10 +423,8 @@ void ar5008_hw_cmn_spur_mitigate(struct ath_hw *ah, REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask); } -/** +/* * ar5008_hw_spur_mitigate - convert baseband spur frequency for external radios - * @ah: atheros hardware structure - * @chan: * * For non single-chip solutions. Converts to baseband spur frequency given the * input channel frequency and compute register settings below. From cd64cae3efd42340b274ccaf42588cca3be6a246 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:24:08 +0000 Subject: [PATCH 029/180] ath9k: dynack: Demote non-compliant function header Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/ath9k/dynack.c:52: warning: Function parameter or member 'old' not described in 'ath_dynack_ewma' drivers/net/wireless/ath/ath9k/dynack.c:52: warning: Function parameter or member 'new' not described in 'ath_dynack_ewma' Cc: QCA ath9k Development Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Lorenzo Bianconi Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-40-lee.jones@linaro.org --- drivers/net/wireless/ath/ath9k/dynack.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c index fbeb4a739d32..3219715174a2 100644 --- a/drivers/net/wireless/ath/ath9k/dynack.c +++ b/drivers/net/wireless/ath/ath9k/dynack.c @@ -44,9 +44,8 @@ static u32 ath_dynack_get_max_to(struct ath_hw *ah) return 600; } -/** +/* * ath_dynack_ewma - EWMA (Exponentially Weighted Moving Average) calculation - * */ static inline int ath_dynack_ewma(int old, int new) { From ce54bf5e9554073d41eac3b2832cf3144f891d32 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 26 Oct 2020 22:29:56 +0100 Subject: [PATCH 030/180] ath6kl: fix enum-conversion warning gcc -Wextra points out a type mismatch drivers/net/wireless/ath/ath6kl/wmi.c: In function 'ath6kl_wmi_cmd_send': drivers/net/wireless/ath/ath6kl/wmi.c:1825:19: warning: implicit conversion from 'enum ' to 'enum wmi_data_hdr_data_type' [-Wenum-conversion] 1825 | false, false, 0, NULL, if_idx); | ^~~~~ As far as I can tell, the numeric value is current here, so just use the correct enum literal instead of 'false'. Fixes: bdcd81707973 ("Add ath6kl cleaned up driver") Signed-off-by: Arnd Bergmann Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201026213040.3889546-9-arnd@kernel.org --- drivers/net/wireless/ath/ath6kl/wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index dbc47702a268..b137e7f34397 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -1821,8 +1821,8 @@ int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, /* Only for OPT_TX_CMD, use BE endpoint. */ if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { - ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, - false, false, 0, NULL, if_idx); + ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, false, + WMI_DATA_HDR_DATA_TYPE_802_3, 0, NULL, if_idx); if (ret) { dev_kfree_skb(skb); return ret; From e24eedc09f14a533439f7f2b92273238b9ac5096 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 3 Nov 2020 12:17:33 +0000 Subject: [PATCH 031/180] wcn36xx: Set LINK_FAIL_TX_CNT to 1000 on all wcn36xx The firmware parameter LINK_FAIL_TX_CNT maps to the prima configuration file parameter gLinkFailTxCnt and is described as: quote: " If within gLinkFailTimeout period(values is mentioned in msec) if FW doesn't receive acks for gLinkFailTxCnt number of packets, then link will be disconnected." The downstream description sets a minimum value of 1000 a maximum value of 60000 and a default value of 6000, however it appears that unless we actually set this value deliberately firmware defaults it to 0. Setting this value to non-zero results in the firmware doing link monitoring. The working example from downstream paradoxically sets the value to 200, here we opt to set the value to the minimum stipulated in the configuration file 1000. In conjunction with ieee80211_hw_set(wcn->hw, CONNECTION_MONITOR); this change effects offload of link monitoring to the firmware. Tested with: 'CNSS-PR-2-0-1-2-c1-74-130449-3' wcn3620 'CNSS-PR-2-0-1-2-c1-00083' wcn3680 Signed-off-by: Bryan O'Donoghue Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201103121735.291324-2-bryan.odonoghue@linaro.org --- drivers/net/wireless/ath/wcn36xx/smd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c index 766400f7b61c..8ff1eda8f942 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.c +++ b/drivers/net/wireless/ath/wcn36xx/smd.c @@ -78,6 +78,7 @@ static struct wcn36xx_cfg_val wcn36xx_cfg_vals[] = { WCN36XX_CFG_VAL(MAX_ASSOC_LIMIT, 10), WCN36XX_CFG_VAL(ENABLE_MCC_ADAPTIVE_SCHEDULER, 0), WCN36XX_CFG_VAL(ENABLE_DYNAMIC_RA_START_RATE, 133), /* MCS 5 */ + WCN36XX_CFG_VAL(LINK_FAIL_TX_CNT, 1000), }; static struct wcn36xx_cfg_val wcn3680_cfg_vals[] = { @@ -162,7 +163,7 @@ static struct wcn36xx_cfg_val wcn3680_cfg_vals[] = { WCN36XX_CFG_VAL(ENABLE_RTSCTS_HTVHT, 0), WCN36XX_CFG_VAL(BTC_STATIC_OPP_WLAN_IDLE_WLAN_LEN, 30000), WCN36XX_CFG_VAL(BTC_STATIC_OPP_WLAN_IDLE_BT_LEN, 120000), - WCN36XX_CFG_VAL(LINK_FAIL_TX_CNT, 200), + WCN36XX_CFG_VAL(LINK_FAIL_TX_CNT, 1000), WCN36XX_CFG_VAL(TOGGLE_ARP_BDRATES, 0), WCN36XX_CFG_VAL(OPTIMIZE_CA_EVENT, 0), WCN36XX_CFG_VAL(EXT_SCAN_CONC_MODE, 0), From 8def9ec46a5fafc0abcf34489a9e8a787bca984d Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 3 Nov 2020 12:17:34 +0000 Subject: [PATCH 032/180] wcn36xx: Enable firmware link monitoring This patch switches on CONNECTION_MONITOR. Once done it is up to the firmware to send keep alive and to monitor the link state. Signed-off-by: Bryan O'Donoghue Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201103121735.291324-3-bryan.odonoghue@linaro.org --- drivers/net/wireless/ath/wcn36xx/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index 706728fba72d..e924cc4acde0 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -1246,6 +1246,7 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn) ieee80211_hw_set(wcn->hw, HAS_RATE_CONTROL); ieee80211_hw_set(wcn->hw, SINGLE_SCAN_ON_ALL_BANDS); ieee80211_hw_set(wcn->hw, REPORTS_TX_ACK_STATUS); + ieee80211_hw_set(wcn->hw, CONNECTION_MONITOR); wcn->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | From 5336fad96e8f8c36a3b7faef765f69efa9fafd35 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 3 Nov 2020 12:17:35 +0000 Subject: [PATCH 033/180] wcn36xx: Enable firmware offloaded keepalive This patch calls wcn36xx_smd_keep_alive_req() on the STA patch immediately after associating with an AP. This will cause the firmware to send a NULL packet out to the AP every 30 seconds, thus offloading keep-alive processing from the SoC to the firmware. Signed-off-by: Bryan O'Donoghue Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201103121735.291324-4-bryan.odonoghue@linaro.org --- drivers/net/wireless/ath/wcn36xx/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index e924cc4acde0..5867bd9c2f64 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -910,6 +910,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw, * place where AID is available. */ wcn36xx_smd_config_sta(wcn, vif, sta); + wcn36xx_enable_keep_alive_null_packet(wcn, vif); } else { wcn36xx_dbg(WCN36XX_DBG_MAC, "disassociated bss %pM vif %pM AID=%d\n", From c9621dd21e3b86c5235545ed8eb27e1647cc7da4 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:30 +0000 Subject: [PATCH 034/180] wil6210: wmi: Correct misnamed function parameter 'ptr_' Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ath/wil6210/wmi.c:279: warning: Function parameter or member 'ptr_' not described in 'wmi_buffer_block' drivers/net/wireless/ath/wil6210/wmi.c:279: warning: Excess function parameter 'ptr' description in 'wmi_buffer_block' Cc: Maya Erez Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: wil6210@qti.qualcomm.com Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-2-lee.jones@linaro.org --- drivers/net/wireless/ath/wil6210/wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c index 421aebbb49e5..8699f8279a8b 100644 --- a/drivers/net/wireless/ath/wil6210/wmi.c +++ b/drivers/net/wireless/ath/wil6210/wmi.c @@ -262,7 +262,7 @@ struct fw_map *wil_find_fw_mapping(const char *section) /** * Check address validity for WMI buffer; remap if needed * @wil: driver data - * @ptr: internal (linker) fw/ucode address + * @ptr_: internal (linker) fw/ucode address * @size: if non zero, validate the block does not * exceed the device memory (bar) * From fa7572c2cfe081dff82f884fa05f1b067d4beaaa Mon Sep 17 00:00:00 2001 From: Carl Huang Date: Fri, 6 Nov 2020 08:55:48 +0200 Subject: [PATCH 035/180] ath11k: fix ZERO address in probe request Host needs to pass at least on bssid with all 0xff to firmware in WMI_START_SCAN_CMDID, otherwise the bssid and receiver address in probe requeste are all ZEROs. This also fixed some hidden AP connection issue because some AP doesn't respond to probe request which receiver address are all ZEROs. Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1 Signed-off-by: Carl Huang Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201012101733.24137-1-cjhuang@codeaurora.org --- drivers/net/wireless/ath/ath11k/wmi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 40032c2b4975..bca66c1d47ad 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -1950,6 +1950,11 @@ void ath11k_wmi_start_scan_init(struct ath11k *ar, WMI_SCAN_EVENT_DEQUEUED; arg->scan_flags |= WMI_SCAN_CHAN_STAT_EVENT; arg->num_bssid = 1; + + /* fill bssid_list[0] with 0xff, otherwise bssid and RA will be + * ZEROs in probe request + */ + eth_broadcast_addr(arg->bssid_list[0].addr); } static inline void From 7eae05184f3a89b1491061432830416ed71d09e2 Mon Sep 17 00:00:00 2001 From: Allen Pais Date: Wed, 7 Oct 2020 16:03:08 +0530 Subject: [PATCH 036/180] wireless: mt7601u: convert tasklets to use new tasklet_setup() API In preparation for unconditionally passing the struct tasklet_struct pointer to all tasklet callbacks, switch to using the new tasklet_setup() and from_tasklet() to pass the tasklet pointer explicitly. Signed-off-by: Romain Perier Signed-off-by: Allen Pais Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201007103309.363737-3-allen.lkml@gmail.com --- drivers/net/wireless/mediatek/mt7601u/dma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c b/drivers/net/wireless/mediatek/mt7601u/dma.c index 09f931d4598c..5f99054f535b 100644 --- a/drivers/net/wireless/mediatek/mt7601u/dma.c +++ b/drivers/net/wireless/mediatek/mt7601u/dma.c @@ -212,9 +212,9 @@ static void mt7601u_complete_rx(struct urb *urb) spin_unlock_irqrestore(&dev->rx_lock, flags); } -static void mt7601u_rx_tasklet(unsigned long data) +static void mt7601u_rx_tasklet(struct tasklet_struct *t) { - struct mt7601u_dev *dev = (struct mt7601u_dev *) data; + struct mt7601u_dev *dev = from_tasklet(dev, t, rx_tasklet); struct mt7601u_dma_buf_rx *e; while ((e = mt7601u_rx_get_pending_entry(dev))) { @@ -266,9 +266,9 @@ static void mt7601u_complete_tx(struct urb *urb) spin_unlock_irqrestore(&dev->tx_lock, flags); } -static void mt7601u_tx_tasklet(unsigned long data) +static void mt7601u_tx_tasklet(struct tasklet_struct *t) { - struct mt7601u_dev *dev = (struct mt7601u_dev *) data; + struct mt7601u_dev *dev = from_tasklet(dev, t, tx_tasklet); struct sk_buff_head skbs; unsigned long flags; @@ -507,8 +507,8 @@ int mt7601u_dma_init(struct mt7601u_dev *dev) { int ret = -ENOMEM; - tasklet_init(&dev->tx_tasklet, mt7601u_tx_tasklet, (unsigned long) dev); - tasklet_init(&dev->rx_tasklet, mt7601u_rx_tasklet, (unsigned long) dev); + tasklet_setup(&dev->tx_tasklet, mt7601u_tx_tasklet); + tasklet_setup(&dev->rx_tasklet, mt7601u_rx_tasklet); ret = mt7601u_alloc_tx(dev); if (ret) From 256ff2ef6c14bcb4bf9707e4547b77c582753c00 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 8 Oct 2020 17:04:22 -0500 Subject: [PATCH 037/180] ray_cs: Use fallthrough pseudo-keyword In order to enable -Wimplicit-fallthrough for Clang[1], replace the existing /* fall through */ comments with the new pseudo-keyword macro fallthrough[2]. [1] https://git.kernel.org/linus/e2079e93f562c7f7a030eb7642017ee5eabaaa10 [2] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201008220422.GA6926@embeddedor --- drivers/net/wireless/ray_cs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index bf3fbd14eda3..590bd974d94f 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -877,10 +877,10 @@ static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev, switch (ccsindex = get_free_tx_ccs(local)) { case ECCSBUSY: pr_debug("ray_hw_xmit tx_ccs table busy\n"); - /* fall through */ + fallthrough; case ECCSFULL: pr_debug("ray_hw_xmit No free tx ccs\n"); - /* fall through */ + fallthrough; case ECARDGONE: netif_stop_queue(dev); return XMIT_NO_CCS; @@ -1272,7 +1272,7 @@ static int ray_set_mode(struct net_device *dev, struct iw_request_info *info, switch (wrqu->mode) { case IW_MODE_ADHOC: card_mode = 0; - /* Fall through */ + fallthrough; case IW_MODE_INFRA: local->sparm.b5.a_network_type = card_mode; break; From a821e3858e4dec2d6505258fea46e020af8532c6 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 8 Oct 2020 17:09:05 -0500 Subject: [PATCH 038/180] wlcore: Use fallthrough pseudo-keyword In order to enable -Wimplicit-fallthrough for Clang[1], replace the existing /* fall-through */ comments with the new pseudo-keyword macro fallthrough[2]. [1] https://git.kernel.org/linus/e2079e93f562c7f7a030eb7642017ee5eabaaa10 [2] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201008220905.GA8040@embeddedor --- drivers/net/wireless/ti/wlcore/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index 6863fd552d5e..122c7a4b374f 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -2227,7 +2227,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) switch (ieee80211_vif_type_p2p(vif)) { case NL80211_IFTYPE_P2P_CLIENT: wlvif->p2p = 1; - /* fall-through */ + fallthrough; case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_P2P_DEVICE: wlvif->bss_type = BSS_TYPE_STA_BSS; @@ -2237,7 +2237,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) break; case NL80211_IFTYPE_P2P_GO: wlvif->p2p = 1; - /* fall-through */ + fallthrough; case NL80211_IFTYPE_AP: case NL80211_IFTYPE_MESH_POINT: wlvif->bss_type = BSS_TYPE_AP_BSS; From 65277100caa2f2c62b6f3c4648b90d6f0435f3bc Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Thu, 15 Oct 2020 13:16:16 +0200 Subject: [PATCH 039/180] rsi: Fix TX EAPOL packet handling against iwlwifi AP In case RSI9116 SDIO WiFi operates in STA mode against Intel 9260 in AP mode, the association fails. The former is using wpa_supplicant during association, the later is set up using hostapd: iwl$ cat hostapd.conf interface=wlp1s0 ssid=test country_code=DE hw_mode=g channel=1 wpa=2 wpa_passphrase=test wpa_key_mgmt=WPA-PSK iwl$ hostapd -d hostapd.conf rsi$ wpa_supplicant -i wlan0 -c <(wpa_passphrase test test) The problem is that the TX EAPOL data descriptor RSI_DESC_REQUIRE_CFM_TO_HOST flag and extended descriptor EAPOL4_CONFIRM frame type are not set in case the AP is iwlwifi, because in that case the TX EAPOL packet is 2 bytes shorter. The downstream vendor driver has this change in place already [1], however there is no explanation for it, neither is there any commit history from which such explanation could be obtained. [1] https://github.com/SiliconLabs/RS911X-nLink-OSD/blob/master/rsi/rsi_91x_hal.c#L238 Signed-off-by: Marek Vasut Cc: Angus Ainslie Cc: David S. Miller Cc: Jakub Kicinski Cc: Kalle Valo Cc: Lee Jones Cc: Martin Kepplinger Cc: Sebastian Krzyszkowiak Cc: Siva Rebbagondla Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201015111616.429220-1-marex@denx.de --- drivers/net/wireless/rsi/rsi_91x_hal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c b/drivers/net/wireless/rsi/rsi_91x_hal.c index 3f7e3cfb6f00..ce9892152f4d 100644 --- a/drivers/net/wireless/rsi/rsi_91x_hal.c +++ b/drivers/net/wireless/rsi/rsi_91x_hal.c @@ -248,7 +248,8 @@ int rsi_prepare_data_desc(struct rsi_common *common, struct sk_buff *skb) rsi_set_len_qno(&data_desc->len_qno, (skb->len - FRAME_DESC_SZ), RSI_WIFI_MGMT_Q); - if ((skb->len - header_size) == EAPOL4_PACKET_LEN) { + if (((skb->len - header_size) == EAPOL4_PACKET_LEN) || + ((skb->len - header_size) == EAPOL4_PACKET_LEN - 2)) { data_desc->misc_flags |= RSI_DESC_REQUIRE_CFM_TO_HOST; xtend_desc->confirm_frame_type = EAPOL4_CONFIRM; From 3287953b03994870c249ec57f55967cd1f7afbb8 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Tue, 20 Oct 2020 05:58:41 -0700 Subject: [PATCH 040/180] wireless: remove unneeded break A break is not needed if it is preceded by a return Signed-off-by: Tom Rix Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201020125841.26791-1-trix@redhat.com --- drivers/net/wireless/ath/ath10k/htt_rx.c | 1 - drivers/net/wireless/ath/ath6kl/testmode.c | 1 - drivers/net/wireless/ath/ath9k/hw.c | 1 - drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 2 -- drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c | 1 - drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c | 1 - drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c | 3 --- 7 files changed, 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index 5c1af2021883..9c4e6cf2137a 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -3878,7 +3878,6 @@ bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb) return ath10k_htt_rx_proc_rx_frag_ind(htt, &resp->rx_frag_ind, skb); - break; } case HTT_T2H_MSG_TYPE_TEST: break; diff --git a/drivers/net/wireless/ath/ath6kl/testmode.c b/drivers/net/wireless/ath/ath6kl/testmode.c index f3906dbe5495..89c7c4e25169 100644 --- a/drivers/net/wireless/ath/ath6kl/testmode.c +++ b/drivers/net/wireless/ath/ath6kl/testmode.c @@ -94,7 +94,6 @@ int ath6kl_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev, return 0; - break; case ATH6KL_TM_CMD_RX_REPORT: default: return -EOPNOTSUPP; diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 6609ce122e6e..b66eeb577272 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2308,7 +2308,6 @@ void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period) ath_dbg(ath9k_hw_common(ah), BEACON, "%s: unsupported opmode: %d\n", __func__, ah->opmode); return; - break; } REG_WRITE(ah, AR_BEACON_PERIOD, beacon_period); diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c index cbdebefb854a..8698ca4d30de 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c @@ -1202,13 +1202,11 @@ static int iwl_mvm_mac_ctx_send(struct iwl_mvm *mvm, struct ieee80211_vif *vif, return iwl_mvm_mac_ctxt_cmd_sta(mvm, vif, action, force_assoc_off, bssid_override); - break; case NL80211_IFTYPE_AP: if (!vif->p2p) return iwl_mvm_mac_ctxt_cmd_ap(mvm, vif, action); else return iwl_mvm_mac_ctxt_cmd_go(mvm, vif, action); - break; case NL80211_IFTYPE_MONITOR: return iwl_mvm_mac_ctxt_cmd_listener(mvm, vif, action); case NL80211_IFTYPE_P2P_DEVICE: diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c index 63f9ea21962f..bd9160b166c5 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c @@ -1226,7 +1226,6 @@ static int _rtl88ee_set_media_status(struct ieee80211_hw *hw, default: pr_err("Network type %d not support!\n", type); return 1; - break; } /* MSR_INFRA == Link in infrastructure network; diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c index a36dc6e726d2..f8a1de6e9849 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c @@ -1132,7 +1132,6 @@ static int _rtl8723e_set_media_status(struct ieee80211_hw *hw, default: pr_err("Network type %d not support!\n", type); return 1; - break; } /* MSR_INFRA == Link in infrastructure network; diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c index f41a7643b9c4..225b8cd44f23 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c @@ -2085,12 +2085,10 @@ bool rtl8812ae_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, return __rtl8821ae_phy_config_with_headerfile(hw, radioa_array_table_a, radioa_arraylen_a, _rtl8821ae_config_rf_radio_a); - break; case RF90_PATH_B: return __rtl8821ae_phy_config_with_headerfile(hw, radioa_array_table_b, radioa_arraylen_b, _rtl8821ae_config_rf_radio_b); - break; case RF90_PATH_C: case RF90_PATH_D: pr_err("switch case %#x not processed\n", rfpath); @@ -2116,7 +2114,6 @@ bool rtl8821ae_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, return __rtl8821ae_phy_config_with_headerfile(hw, radioa_array_table, radioa_arraylen, _rtl8821ae_config_rf_radio_a); - break; case RF90_PATH_B: case RF90_PATH_C: From 9fdd02aa59886300b60e1cc0a4af3653796d9bd8 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 26 Oct 2020 22:29:49 +0100 Subject: [PATCH 041/180] net: hostap: fix function cast warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc -Wextra complains about the function type cast: drivers/net/wireless/intersil/hostap/hostap_hw.c:3173:48: warning: cast between incompatible function types from ‘void (*)(struct tasklet_struct *)’ to ‘void (*)(long unsigned int)’ [-Wcast-function-type] Avoid this by just using the regular tasklet_setup() function instead of the incorrect homegrown version. Fixes: 7433c9690318 ("intersil: convert tasklets to use new tasklet_setup() API") Signed-off-by: Arnd Bergmann Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201026213040.3889546-2-arnd@kernel.org --- .../net/wireless/intersil/hostap/hostap_hw.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/intersil/hostap/hostap_hw.c b/drivers/net/wireless/intersil/hostap/hostap_hw.c index 22cfb6452644..9a19046217df 100644 --- a/drivers/net/wireless/intersil/hostap/hostap_hw.c +++ b/drivers/net/wireless/intersil/hostap/hostap_hw.c @@ -3169,22 +3169,15 @@ prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx, /* Initialize tasklets for handling hardware IRQ related operations * outside hw IRQ handler */ -#define HOSTAP_TASKLET_INIT(q, f, d) \ -do { memset((q), 0, sizeof(*(q))); (q)->func = (void(*)(unsigned long))(f); } \ -while (0) - HOSTAP_TASKLET_INIT(&local->bap_tasklet, hostap_bap_tasklet, - (unsigned long) local); - - HOSTAP_TASKLET_INIT(&local->info_tasklet, hostap_info_tasklet, - (unsigned long) local); + tasklet_setup(&local->bap_tasklet, hostap_bap_tasklet); + tasklet_setup(&local->info_tasklet, hostap_info_tasklet); hostap_info_init(local); - HOSTAP_TASKLET_INIT(&local->rx_tasklet, - hostap_rx_tasklet, (unsigned long) local); + tasklet_setup(&local->rx_tasklet, hostap_rx_tasklet); skb_queue_head_init(&local->rx_list); - HOSTAP_TASKLET_INIT(&local->sta_tx_exc_tasklet, - hostap_sta_tx_exc_tasklet, (unsigned long) local); + tasklet_setup(&local->sta_tx_exc_tasklet, + hostap_sta_tx_exc_tasklet); skb_queue_head_init(&local->sta_tx_exc_list); INIT_LIST_HEAD(&local->cmd_queue); From ef41937631bfee855e2b406e1d536efdaa9ce512 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 26 Oct 2020 22:29:53 +0100 Subject: [PATCH 042/180] rtlwifi: fix -Wpointer-sign warning There are thousands of warnings in a W=2 build from just one file: drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.c:3788:15: warning: pointer targets in initialization of 'u8 *' {aka 'unsigned char *'} from 'char *' differ in signedness [-Wpointer-sign] Change the types to consistently use 'const char *' for the strings. Signed-off-by: Arnd Bergmann Acked-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201026213040.3889546-6-arnd@kernel.org --- .../wireless/realtek/rtlwifi/rtl8821ae/phy.c | 81 ++++++++++--------- .../realtek/rtlwifi/rtl8821ae/table.c | 4 +- .../realtek/rtlwifi/rtl8821ae/table.h | 4 +- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c index 225b8cd44f23..11e709813c8c 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c @@ -1581,7 +1581,7 @@ static void _rtl8821ae_phy_txpower_by_rate_configuration(struct ieee80211_hw *hw } /* string is in decimal */ -static bool _rtl8812ae_get_integer_from_string(char *str, u8 *pint) +static bool _rtl8812ae_get_integer_from_string(const char *str, u8 *pint) { u16 i = 0; *pint = 0; @@ -1599,7 +1599,7 @@ static bool _rtl8812ae_get_integer_from_string(char *str, u8 *pint) return true; } -static bool _rtl8812ae_eq_n_byte(u8 *str1, u8 *str2, u32 num) +static bool _rtl8812ae_eq_n_byte(const char *str1, const char *str2, u32 num) { if (num == 0) return false; @@ -1637,10 +1637,11 @@ static s8 _rtl8812ae_phy_get_chnl_idx_of_txpwr_lmt(struct ieee80211_hw *hw, return channel_index; } -static void _rtl8812ae_phy_set_txpower_limit(struct ieee80211_hw *hw, u8 *pregulation, - u8 *pband, u8 *pbandwidth, - u8 *prate_section, u8 *prf_path, - u8 *pchannel, u8 *ppower_limit) +static void _rtl8812ae_phy_set_txpower_limit(struct ieee80211_hw *hw, + const char *pregulation, + const char *pband, const char *pbandwidth, + const char *prate_section, const char *prf_path, + const char *pchannel, const char *ppower_limit) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_phy *rtlphy = &rtlpriv->phy; @@ -1648,8 +1649,8 @@ static void _rtl8812ae_phy_set_txpower_limit(struct ieee80211_hw *hw, u8 *pregul u8 channel_index; s8 power_limit = 0, prev_power_limit, ret; - if (!_rtl8812ae_get_integer_from_string((char *)pchannel, &channel) || - !_rtl8812ae_get_integer_from_string((char *)ppower_limit, + if (!_rtl8812ae_get_integer_from_string(pchannel, &channel) || + !_rtl8812ae_get_integer_from_string(ppower_limit, &power_limit)) { rtl_dbg(rtlpriv, COMP_INIT, DBG_TRACE, "Illegal index of pwr_lmt table [chnl %d][val %d]\n", @@ -1659,42 +1660,42 @@ static void _rtl8812ae_phy_set_txpower_limit(struct ieee80211_hw *hw, u8 *pregul power_limit = power_limit > MAX_POWER_INDEX ? MAX_POWER_INDEX : power_limit; - if (_rtl8812ae_eq_n_byte(pregulation, (u8 *)("FCC"), 3)) + if (_rtl8812ae_eq_n_byte(pregulation, "FCC", 3)) regulation = 0; - else if (_rtl8812ae_eq_n_byte(pregulation, (u8 *)("MKK"), 3)) + else if (_rtl8812ae_eq_n_byte(pregulation, "MKK", 3)) regulation = 1; - else if (_rtl8812ae_eq_n_byte(pregulation, (u8 *)("ETSI"), 4)) + else if (_rtl8812ae_eq_n_byte(pregulation, "ETSI", 4)) regulation = 2; - else if (_rtl8812ae_eq_n_byte(pregulation, (u8 *)("WW13"), 4)) + else if (_rtl8812ae_eq_n_byte(pregulation, "WW13", 4)) regulation = 3; - if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("CCK"), 3)) + if (_rtl8812ae_eq_n_byte(prate_section, "CCK", 3)) rate_section = 0; - else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("OFDM"), 4)) + else if (_rtl8812ae_eq_n_byte(prate_section, "OFDM", 4)) rate_section = 1; - else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("HT"), 2) && - _rtl8812ae_eq_n_byte(prf_path, (u8 *)("1T"), 2)) + else if (_rtl8812ae_eq_n_byte(prate_section, "HT", 2) && + _rtl8812ae_eq_n_byte(prf_path, "1T", 2)) rate_section = 2; - else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("HT"), 2) && - _rtl8812ae_eq_n_byte(prf_path, (u8 *)("2T"), 2)) + else if (_rtl8812ae_eq_n_byte(prate_section, "HT", 2) && + _rtl8812ae_eq_n_byte(prf_path, "2T", 2)) rate_section = 3; - else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("VHT"), 3) && - _rtl8812ae_eq_n_byte(prf_path, (u8 *)("1T"), 2)) + else if (_rtl8812ae_eq_n_byte(prate_section, "VHT", 3) && + _rtl8812ae_eq_n_byte(prf_path, "1T", 2)) rate_section = 4; - else if (_rtl8812ae_eq_n_byte(prate_section, (u8 *)("VHT"), 3) && - _rtl8812ae_eq_n_byte(prf_path, (u8 *)("2T"), 2)) + else if (_rtl8812ae_eq_n_byte(prate_section, "VHT", 3) && + _rtl8812ae_eq_n_byte(prf_path, "2T", 2)) rate_section = 5; - if (_rtl8812ae_eq_n_byte(pbandwidth, (u8 *)("20M"), 3)) + if (_rtl8812ae_eq_n_byte(pbandwidth, "20M", 3)) bandwidth = 0; - else if (_rtl8812ae_eq_n_byte(pbandwidth, (u8 *)("40M"), 3)) + else if (_rtl8812ae_eq_n_byte(pbandwidth, "40M", 3)) bandwidth = 1; - else if (_rtl8812ae_eq_n_byte(pbandwidth, (u8 *)("80M"), 3)) + else if (_rtl8812ae_eq_n_byte(pbandwidth, "80M", 3)) bandwidth = 2; - else if (_rtl8812ae_eq_n_byte(pbandwidth, (u8 *)("160M"), 4)) + else if (_rtl8812ae_eq_n_byte(pbandwidth, "160M", 4)) bandwidth = 3; - if (_rtl8812ae_eq_n_byte(pband, (u8 *)("2.4G"), 4)) { + if (_rtl8812ae_eq_n_byte(pband, "2.4G", 4)) { ret = _rtl8812ae_phy_get_chnl_idx_of_txpwr_lmt(hw, BAND_ON_2_4G, channel); @@ -1718,7 +1719,7 @@ static void _rtl8812ae_phy_set_txpower_limit(struct ieee80211_hw *hw, u8 *pregul regulation, bandwidth, rate_section, channel_index, rtlphy->txpwr_limit_2_4g[regulation][bandwidth] [rate_section][channel_index][RF90_PATH_A]); - } else if (_rtl8812ae_eq_n_byte(pband, (u8 *)("5G"), 2)) { + } else if (_rtl8812ae_eq_n_byte(pband, "5G", 2)) { ret = _rtl8812ae_phy_get_chnl_idx_of_txpwr_lmt(hw, BAND_ON_5G, channel); @@ -1749,10 +1750,10 @@ static void _rtl8812ae_phy_set_txpower_limit(struct ieee80211_hw *hw, u8 *pregul } static void _rtl8812ae_phy_config_bb_txpwr_lmt(struct ieee80211_hw *hw, - u8 *regulation, u8 *band, - u8 *bandwidth, u8 *rate_section, - u8 *rf_path, u8 *channel, - u8 *power_limit) + const char *regulation, const char *band, + const char *bandwidth, const char *rate_section, + const char *rf_path, const char *channel, + const char *power_limit) { _rtl8812ae_phy_set_txpower_limit(hw, regulation, band, bandwidth, rate_section, rf_path, channel, @@ -1765,7 +1766,7 @@ static void _rtl8821ae_phy_read_and_config_txpwr_lmt(struct ieee80211_hw *hw) struct rtl_hal *rtlhal = rtl_hal(rtlpriv); u32 i = 0; u32 array_len; - u8 **array; + const char **array; if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) { array_len = RTL8812AE_TXPWR_LMT_ARRAY_LEN; @@ -1778,13 +1779,13 @@ static void _rtl8821ae_phy_read_and_config_txpwr_lmt(struct ieee80211_hw *hw) rtl_dbg(rtlpriv, COMP_INIT, DBG_TRACE, "\n"); for (i = 0; i < array_len; i += 7) { - u8 *regulation = array[i]; - u8 *band = array[i+1]; - u8 *bandwidth = array[i+2]; - u8 *rate = array[i+3]; - u8 *rf_path = array[i+4]; - u8 *chnl = array[i+5]; - u8 *val = array[i+6]; + const char *regulation = array[i]; + const char *band = array[i+1]; + const char *bandwidth = array[i+2]; + const char *rate = array[i+3]; + const char *rf_path = array[i+4]; + const char *chnl = array[i+5]; + const char *val = array[i+6]; _rtl8812ae_phy_config_bb_txpwr_lmt(hw, regulation, band, bandwidth, rate, rf_path, diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.c index 85093b3e5373..27c8a5d96520 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.c @@ -2654,7 +2654,7 @@ u32 RTL8821AE_AGC_TAB_1TARRAYLEN = ARRAY_SIZE(RTL8821AE_AGC_TAB_ARRAY); * TXPWR_LMT.TXT ******************************************************************************/ -u8 *RTL8812AE_TXPWR_LMT[] = { +const char *RTL8812AE_TXPWR_LMT[] = { "FCC", "2.4G", "20M", "CCK", "1T", "01", "36", "ETSI", "2.4G", "20M", "CCK", "1T", "01", "32", "MKK", "2.4G", "20M", "CCK", "1T", "01", "32", @@ -3223,7 +3223,7 @@ u8 *RTL8812AE_TXPWR_LMT[] = { u32 RTL8812AE_TXPWR_LMT_ARRAY_LEN = ARRAY_SIZE(RTL8812AE_TXPWR_LMT); -u8 *RTL8821AE_TXPWR_LMT[] = { +const char *RTL8821AE_TXPWR_LMT[] = { "FCC", "2.4G", "20M", "CCK", "1T", "01", "32", "ETSI", "2.4G", "20M", "CCK", "1T", "01", "32", "MKK", "2.4G", "20M", "CCK", "1T", "01", "32", diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.h b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.h index 540159c25078..76c62b7c0fb2 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.h +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/table.h @@ -28,7 +28,7 @@ extern u32 RTL8821AE_AGC_TAB_ARRAY[]; extern u32 RTL8812AE_AGC_TAB_1TARRAYLEN; extern u32 RTL8812AE_AGC_TAB_ARRAY[]; extern u32 RTL8812AE_TXPWR_LMT_ARRAY_LEN; -extern u8 *RTL8812AE_TXPWR_LMT[]; +extern const char *RTL8812AE_TXPWR_LMT[]; extern u32 RTL8821AE_TXPWR_LMT_ARRAY_LEN; -extern u8 *RTL8821AE_TXPWR_LMT[]; +extern const char *RTL8821AE_TXPWR_LMT[]; #endif From 6ac6546973013b4b368cd3d3515f1e853658b6ce Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 26 Oct 2020 22:29:54 +0100 Subject: [PATCH 043/180] rtw88: remove extraneous 'const' qualifier clang -Wextra warns about functions returning a 'const' integer: drivers/net/wireless/realtek/rtw88/rtw8822b.c:90:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] static const u8 rtw8822b_get_swing_index(struct rtw_dev *rtwdev) Remove the extra qualifier here. Fixes: c97ee3e0bea2 ("rtw88: add power tracking support") Signed-off-by: Arnd Bergmann Reviewed-by: Nathan Chancellor Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201026213040.3889546-7-arnd@kernel.org --- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index 22d0dd640ac9..b420eb914879 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -87,7 +87,7 @@ static const u32 rtw8822b_txscale_tbl[RTW_TXSCALE_SIZE] = { 0x2d3, 0x2fe, 0x32b, 0x35c, 0x38e, 0x3c4, 0x3fe }; -static const u8 rtw8822b_get_swing_index(struct rtw_dev *rtwdev) +static u8 rtw8822b_get_swing_index(struct rtw_dev *rtwdev) { u8 i = 0; u32 swing, table_value; From d56fd83cf99c5e4b257f5be46531420509ba5066 Mon Sep 17 00:00:00 2001 From: Remi Depommier Date: Tue, 20 Oct 2020 13:46:39 -0400 Subject: [PATCH 044/180] brcmfmac: fix SDIO access for big-endian host These full-mac chips use little-endian byte ordering. This patch adds a few missing conversions to/from little-endian so that the driver may be used with a big-endian host. Signed-off-by: Remi Depommier Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201020174639.28892-1-rde@setrix.com --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index 99987a789e7e..e5b6033fab33 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -1340,7 +1340,7 @@ static void brcmf_sdio_free_glom(struct brcmf_sdio *bus) static inline u8 brcmf_sdio_getdatoffset(u8 *swheader) { u32 hdrvalue; - hdrvalue = *(u32 *)swheader; + hdrvalue = le32_to_cpu(*(__le32 *)swheader); return (u8)((hdrvalue & SDPCM_DOFFSET_MASK) >> SDPCM_DOFFSET_SHIFT); } @@ -1349,7 +1349,7 @@ static inline bool brcmf_sdio_fromevntchan(u8 *swheader) u32 hdrvalue; u8 ret; - hdrvalue = *(u32 *)swheader; + hdrvalue = le32_to_cpu(*(__le32 *)swheader); ret = (u8)((hdrvalue & SDPCM_CHANNEL_MASK) >> SDPCM_CHANNEL_SHIFT); return (ret == SDPCM_EVENT_CHANNEL); @@ -3544,7 +3544,7 @@ static int brcmf_sdio_bus_preinit(struct device *dev) /* otherwise, set txglomalign */ value = sdiodev->settings->bus.sdio.sd_sgentry_align; /* SDIO ADMA requires at least 32 bit alignment */ - value = max_t(u32, value, ALIGNMENT); + value = cpu_to_le32(max_t(u32, value, ALIGNMENT)); err = brcmf_iovar_data_set(dev, "bus:txglomalign", &value, sizeof(u32)); } @@ -3555,7 +3555,7 @@ static int brcmf_sdio_bus_preinit(struct device *dev) bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN; if (sdiodev->sg_support) { bus->txglom = false; - value = 1; + value = cpu_to_le32(1); err = brcmf_iovar_data_set(bus->sdiodev->dev, "bus:rxglom", &value, sizeof(u32)); if (err < 0) { From c521d7e0ff05257bb9128ab7e68b8e2c084ed361 Mon Sep 17 00:00:00 2001 From: WeitaoWangoc Date: Tue, 27 Oct 2020 11:16:20 +0800 Subject: [PATCH 045/180] rtlwifi: Fix non-canonical address access issues During realtek USB wireless NIC initialization, it's unexpected disconnection will cause urb sumbmit fail. On the one hand, _rtl_usb_cleanup_rx will be called to clean up rx stuff, especially for rtl_wq. On the other hand, disconnection will cause rtl_usb_disconnect and _rtl_usb_cleanup_rx to be called. So, rtl_wq will be flush/destroy twice, which will cause non-canonical address 0xdead000000000122 access and general protection fault. Fixed this issue by remove _rtl_usb_cleanup_rx when urb sumbmit fail. Signed-off-by: WeitaoWangoc Acked-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1603768580-2798-1-git-send-email-WeitaoWang-oc@zhaoxin.com --- drivers/net/wireless/realtek/rtlwifi/usb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c index 06e073defad6..d62b87f010c9 100644 --- a/drivers/net/wireless/realtek/rtlwifi/usb.c +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c @@ -731,7 +731,6 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw) err_out: usb_kill_anchored_urbs(&rtlusb->rx_submitted); - _rtl_usb_cleanup_rx(hw); return err; } From 842280da81a95b7bd2804eb77fa8750e189c93e0 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Fri, 30 Oct 2020 13:55:06 +0800 Subject: [PATCH 046/180] rtw88: coex: separate BLE HID profile from BLE profile BT firmware will report BLE-HID and BLE-RCU in different profile. We can distinguish the two profile from BT info now. Add the coexistence for BLE-HID coexistence, it can make BLE HID work more smoothly. BLE-HID need to Tx/Rx packet more frequently to respond user operation, but RCU doesn't. In the case of RCU coexistence, it will make Wi-Fi have a higher priority to earn more Wi-Fi throughput. If BLE-HID go for the same case, it will make user feel mouse is lagging. Desired BT firmware BT-COEX version: 0x1c Desired WL firmware version: 9.9 Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201030055506.6560-1-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 31 ++++++++++++++++--- drivers/net/wireless/realtek/rtw88/main.h | 1 + drivers/net/wireless/realtek/rtw88/rtw8723d.c | 5 ++- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 5 ++- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 9 ++++-- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index aa08fd7d9fcd..51eef8d0a8e5 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -1470,11 +1470,17 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) } else { /* for 4/18 HID */ if (coex_stat->bt_418_hid_exist && - coex_stat->wl_gl_busy) + coex_stat->wl_gl_busy) { table_case = 12; - else + tdma_case = 4; + } else if (coex_stat->bt_ble_hid_exist && + coex_stat->wl_gl_busy) { + table_case = 32; + tdma_case = 9; + } else { table_case = 10; - tdma_case = 4; + tdma_case = 4; + } } } } else { @@ -2388,6 +2394,23 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) 4 * HZ); } coex_stat->bt_acl_busy = ((coex_stat->bt_info_lb2 & BIT(3)) == BIT(3)); + if (coex_stat->bt_info_lb2 & BIT(5)) { + if (coex_stat->bt_info_hb1 & BIT(0)) { + /*BLE HID*/ + coex_stat->bt_ble_hid_exist = true; + } else { + coex_stat->bt_ble_hid_exist = false; + } + coex_stat->bt_ble_exist = false; + } else if (coex_stat->bt_info_hb1 & BIT(0)) { + /*RCU*/ + coex_stat->bt_ble_hid_exist = false; + coex_stat->bt_ble_exist = true; + } else { + coex_stat->bt_ble_hid_exist = false; + coex_stat->bt_ble_exist = false; + } + coex_stat->cnt_bt[COEX_CNT_BT_RETRY] = coex_stat->bt_info_lb3 & 0xf; if (coex_stat->cnt_bt[COEX_CNT_BT_RETRY] >= 1) coex_stat->cnt_bt[COEX_CNT_BT_POPEVENT]++; @@ -2422,7 +2445,6 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) coex_stat->bt_rssi = 0; } - coex_stat->bt_ble_exist = ((coex_stat->bt_info_hb1 & BIT(0)) == BIT(0)); if (coex_stat->bt_info_hb1 & BIT(1)) coex_stat->cnt_bt[COEX_CNT_BT_REINIT]++; @@ -2965,6 +2987,7 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) coex_stat->bt_hid_exist ? (coex_stat->bt_ble_exist ? "HID(RCU)," : coex_stat->bt_hid_slot >= 2 ? "HID(4/18)" : + coex_stat->bt_ble_hid_exist ? "HID(BLE)" : "HID(2/18),") : "", coex_stat->bt_pan_exist ? coex_stat->bt_opp_exist ? "OPP," : "PAN," : "", diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index ffb02e614217..fb2b1d46e8a9 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1305,6 +1305,7 @@ struct rtw_coex_stat { bool bt_init_scan; bool bt_slave; bool bt_418_hid_exist; + bool bt_ble_hid_exist; bool bt_mailbox_reply; bool wl_under_lps; diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c b/drivers/net/wireless/realtek/rtw88/rtw8723d.c index 3ddd170f1651..832dc8e98bee 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c @@ -1976,7 +1976,10 @@ static const struct coex_table_para table_sant_8723d[] = { {0x55555555, 0x5a5a5a5a}, {0x55555555, 0xaaaaaaaa}, {0x55555555, 0x6a6a6a6a}, - {0x656a656a, 0x656a656a} + {0x656a656a, 0x656a656a}, + {0x66556aaa, 0x6a5a6aaa}, /* case-30 */ + {0xffffffff, 0x5aaa5aaa}, + {0x56555555, 0x5a5a5aaa}, }; /* Non-Shared-Antenna Coex Table */ diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index b420eb914879..ffcb580e8dce 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -2164,7 +2164,10 @@ static const struct coex_table_para table_sant_8822b[] = { {0x55555555, 0x5a5a5a5a}, {0x55555555, 0xaaaaaaaa}, {0x55555555, 0x6a5a6a5a}, - {0x66556655, 0x66556655} + {0x66556655, 0x66556655}, + {0x66556aaa, 0x6a5a6aaa}, /* case-30 */ + {0xffffffff, 0x5aaa5aaa}, + {0x56555555, 0x5a5a5aaa}, }; /* Non-Shared-Antenna Coex Table */ diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index e37300e98517..1e2f680f2b90 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -4006,7 +4006,10 @@ static const struct coex_table_para table_sant_8822c[] = { {0x55555555, 0x5a5a5a5a}, {0x55555555, 0xaaaaaaaa}, {0x55555555, 0x6a5a6a5a}, - {0x66556655, 0x66556655} + {0x66556655, 0x66556655}, + {0x66556aaa, 0x6a5a6aaa}, /* case-30 */ + {0xffffffff, 0x5aaa5aaa}, + {0x56555555, 0x5a5a5aaa}, }; /* Non-Shared-Antenna Coex Table */ @@ -4337,8 +4340,8 @@ struct rtw_chip_info rtw8822c_hw_spec = { .wowlan_stub = &rtw_wowlan_stub_8822c, .max_sched_scan_ssids = 4, #endif - .coex_para_ver = 0x20070217, - .bt_desired_ver = 0x17, + .coex_para_ver = 0x201029, + .bt_desired_ver = 0x1c, .scbd_support = true, .new_scbd10_def = true, .pstdma_type = COEX_PSTDMA_FORCE_LPSOFF, From 690390d841d262134ea12f0cd5e208de24c99ae8 Mon Sep 17 00:00:00 2001 From: Chin-Yen Lee Date: Fri, 30 Oct 2020 16:48:23 +0800 Subject: [PATCH 047/180] rtw88: sync the power state between driver and firmware In current flow, driver issues power requests to firmware for entering or leaving deep power mode. But driver does not wait for an ack from firmware via reading CPWM register when driver requests to enter deep power mode. The behavior will lead to unsynchronized state between firmware and driver. Furthermore, consecutive same power requests may confuse firmware and leads to unexpected value of CPWM register. This patch ensures that the power request will wait for an ack from firmware and only send one power request each time. Signed-off-by: Chin-Yen Lee Signed-off-by: Tzu-En Huang Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201030084826.9034-2-tehuang@realtek.com --- drivers/net/wireless/realtek/rtw88/ps.c | 67 +++++++++++-------------- 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c index 7a189a9926fe..8ed243628dcb 100644 --- a/drivers/net/wireless/realtek/rtw88/ps.c +++ b/drivers/net/wireless/realtek/rtw88/ps.c @@ -68,48 +68,39 @@ int rtw_leave_ips(struct rtw_dev *rtwdev) void rtw_power_mode_change(struct rtw_dev *rtwdev, bool enter) { u8 request, confirm, polling; - u8 polling_cnt; - u8 retry_cnt = 0; + int ret; - for (retry_cnt = 0; retry_cnt < 3; retry_cnt++) { - request = rtw_read8(rtwdev, rtwdev->hci.rpwm_addr); - confirm = rtw_read8(rtwdev, rtwdev->hci.cpwm_addr); + request = rtw_read8(rtwdev, rtwdev->hci.rpwm_addr); + confirm = rtw_read8(rtwdev, rtwdev->hci.cpwm_addr); - /* toggle to request power mode, others remain 0 */ - request ^= request | BIT_RPWM_TOGGLE; - if (!enter) { - request |= POWER_MODE_ACK; - } else { - request |= POWER_MODE_LCLK; - if (rtw_fw_lps_deep_mode == LPS_DEEP_MODE_PG) - request |= POWER_MODE_PG; - } - - rtw_write8(rtwdev, rtwdev->hci.rpwm_addr, request); - - if (enter) - return; - - /* check confirm power mode has left power save state */ - for (polling_cnt = 0; polling_cnt < 50; polling_cnt++) { - polling = rtw_read8(rtwdev, rtwdev->hci.cpwm_addr); - if ((polling ^ confirm) & BIT_RPWM_TOGGLE) - return; - udelay(100); - } - - /* in case of fw/hw missed the request, retry */ - rtw_warn(rtwdev, "failed to leave deep PS, retry=%d\n", - retry_cnt); + /* toggle to request power mode, others remain 0 */ + request ^= request | BIT_RPWM_TOGGLE; + if (enter) { + request |= POWER_MODE_LCLK; + if (rtw_fw_lps_deep_mode == LPS_DEEP_MODE_PG) + request |= POWER_MODE_PG; } + /* Each request require an ack from firmware */ + request |= POWER_MODE_ACK; - /* Hit here means that driver failed to change hardware power mode to - * active state after retry 3 times. If the power state is locked at - * Deep sleep, most of the hardware circuits is not working, even - * register read/write. It should be treated as fatal error and - * requires an entire analysis about the firmware/hardware - */ - WARN(1, "Hardware power state locked\n"); + rtw_write8(rtwdev, rtwdev->hci.rpwm_addr, request); + + /* Check firmware get the power requset and ack via cpwm register */ + ret = read_poll_timeout_atomic(rtw_read8, polling, + (polling ^ confirm) & BIT_RPWM_TOGGLE, + 100, 15000, true, rtwdev, + rtwdev->hci.cpwm_addr); + if (ret) { + /* Hit here means that driver failed to get an ack from firmware. + * The reason could be that hardware is locked at Deep sleep, + * so most of the hardware circuits are not working, even + * register read/write; or firmware is locked in some state and + * cannot get the request. It should be treated as fatal error + * and requires an entire analysis about the firmware/hardware. + */ + WARN(1, "firmware failed to ack driver for %s Deep Power mode\n", + enter ? "entering" : "leaving"); + } } EXPORT_SYMBOL(rtw_power_mode_change); From a95949606828e1c9d91e5b05171b39ff147ced58 Mon Sep 17 00:00:00 2001 From: Chin-Yen Lee Date: Fri, 30 Oct 2020 16:48:24 +0800 Subject: [PATCH 048/180] rtw88: store firmware feature in firmware header Some functions need the support of firmware with special version. In order to get the feature of current firmware, we store the information in firmware header and parse after firmware is loaded. The current feature list in firmware header includes checking leave lps via C2H and supported lps deep mode. Signed-off-by: Chin-Yen Lee Signed-off-by: Tzu-En Huang Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201030084826.9034-3-tehuang@realtek.com --- drivers/net/wireless/realtek/rtw88/fw.h | 10 +++++++++- drivers/net/wireless/realtek/rtw88/main.c | 13 +++++++++++++ drivers/net/wireless/realtek/rtw88/main.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h index 08644540d259..5b74830c4d2c 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.h +++ b/drivers/net/wireless/realtek/rtw88/fw.h @@ -72,6 +72,14 @@ enum rtw_fw_rf_type { FW_RF_MAX_TYPE = 0xF, }; +enum rtw_fw_feature { + FW_FEATURE_SIG = BIT(0), + FW_FEATURE_LPS_C2H = BIT(1), + FW_FEATURE_LCLK = BIT(2), + FW_FEATURE_PG = BIT(3), + FW_FEATURE_MAX = BIT(31), +}; + struct rtw_coex_info_req { u8 seq; u8 op_code; @@ -177,7 +185,7 @@ struct rtw_fw_hdr { u8 subversion; u8 subindex; __le32 rsvd; /* 0x08 */ - __le32 rsvd2; /* 0x0C */ + __le32 feature; /* 0x0C */ u8 month; /* 0x10 */ u8 day; u8 hour; diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 565efd880624..259ad849af93 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -1259,6 +1259,17 @@ static void rtw_unset_supported_band(struct ieee80211_hw *hw, kfree(hw->wiphy->bands[NL80211_BAND_5GHZ]); } +static void __update_firmware_feature(struct rtw_dev *rtwdev, + struct rtw_fw_state *fw) +{ + u32 feature; + const struct rtw_fw_hdr *fw_hdr = + (const struct rtw_fw_hdr *)fw->firmware->data; + + feature = le32_to_cpu(fw_hdr->feature); + fw->feature = feature & FW_FEATURE_SIG ? feature : 0; +} + static void __update_firmware_info(struct rtw_dev *rtwdev, struct rtw_fw_state *fw) { @@ -1269,6 +1280,8 @@ static void __update_firmware_info(struct rtw_dev *rtwdev, fw->version = le16_to_cpu(fw_hdr->version); fw->sub_version = fw_hdr->subversion; fw->sub_index = fw_hdr->subindex; + + __update_firmware_feature(rtwdev, fw); } static void __update_firmware_info_legacy(struct rtw_dev *rtwdev, diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index fb2b1d46e8a9..82d4645afd4c 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1634,6 +1634,7 @@ struct rtw_fw_state { u8 sub_index; u16 h2c_version; u8 prev_dump_seq; + u32 feature; }; struct rtw_hal { From f31e039fab38fb29104ef35c6c7d29e66a37adea Mon Sep 17 00:00:00 2001 From: Chin-Yen Lee Date: Fri, 30 Oct 2020 16:48:25 +0800 Subject: [PATCH 049/180] rtw88: add C2H response for checking firmware leave lps Originally driver checks if firmware has left lps via reading the setting of REG_TCR register. But this way may fail when firmware is frequently changing power state. Therefore, firmware provides a safer option for driver. When firmware leaves lps successfully, it sends a C2H response to inform driver. Signed-off-by: Chin-Yen Lee Signed-off-by: Tzu-En Huang Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201030084826.9034-4-tehuang@realtek.com --- drivers/net/wireless/realtek/rtw88/fw.c | 3 ++ drivers/net/wireless/realtek/rtw88/fw.h | 1 + drivers/net/wireless/realtek/rtw88/main.c | 1 + drivers/net/wireless/realtek/rtw88/main.h | 1 + drivers/net/wireless/realtek/rtw88/ps.c | 52 ++++++++++++++++++++--- drivers/net/wireless/realtek/rtw88/ps.h | 1 + 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c index 042015bc8055..29fffacf4085 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c @@ -183,6 +183,9 @@ void rtw_fw_c2h_cmd_rx_irqsafe(struct rtw_dev *rtwdev, u32 pkt_offset, case C2H_BT_MP_INFO: rtw_coex_info_response(rtwdev, skb); break; + case C2H_WLAN_RFON: + complete(&rtwdev->lps_leave_check); + break; default: /* pass offset for further operation */ *((u32 *)skb->cb) = pkt_offset; diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h index 5b74830c4d2c..39c905c1b1d8 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.h +++ b/drivers/net/wireless/realtek/rtw88/fw.h @@ -31,6 +31,7 @@ enum rtw_c2h_cmd_id { C2H_RA_RPT = 0x0c, C2H_HW_FEATURE_REPORT = 0x19, C2H_WLAN_INFO = 0x27, + C2H_WLAN_RFON = 0x32, C2H_HW_FEATURE_DUMP = 0xfd, C2H_HALMAC = 0xff, }; diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 259ad849af93..5c46f5d2e87c 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -1652,6 +1652,7 @@ int rtw_core_init(struct rtw_dev *rtwdev) mutex_init(&rtwdev->hal.tx_power_mutex); init_waitqueue_head(&rtwdev->coex.wait); + init_completion(&rtwdev->lps_leave_check); rtwdev->sec.total_cam_num = 32; rtwdev->hal.current_channel = 1; diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index 82d4645afd4c..b635e1876680 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1741,6 +1741,7 @@ struct rtw_dev { /* lps power state & handler work */ struct rtw_lps_conf lps_conf; bool ps_enabled; + struct completion lps_leave_check; struct dentry *debugfs; diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c index 8ed243628dcb..233b3df264b3 100644 --- a/drivers/net/wireless/realtek/rtw88/ps.c +++ b/drivers/net/wireless/realtek/rtw88/ps.c @@ -109,7 +109,7 @@ static void __rtw_leave_lps_deep(struct rtw_dev *rtwdev) rtw_hci_deep_ps(rtwdev, false); } -static void rtw_fw_leave_lps_state_check(struct rtw_dev *rtwdev) +static int __rtw_fw_leave_lps_check_reg(struct rtw_dev *rtwdev) { int i; @@ -127,12 +127,53 @@ static void rtw_fw_leave_lps_state_check(struct rtw_dev *rtwdev) */ for (i = 0 ; i < LEAVE_LPS_TRY_CNT; i++) { if (rtw_read32_mask(rtwdev, REG_TCR, BIT_PWRMGT_HWDATA_EN) == 0) - return; + return 0; msleep(20); } - rtw_write32_mask(rtwdev, REG_TCR, BIT_PWRMGT_HWDATA_EN, 0); - rtw_warn(rtwdev, "firmware failed to restore hardware setting\n"); + return -EBUSY; +} + +static int __rtw_fw_leave_lps_check_c2h(struct rtw_dev *rtwdev) +{ + if (wait_for_completion_timeout(&rtwdev->lps_leave_check, + LEAVE_LPS_TIMEOUT)) + return 0; + return -EBUSY; +} + +static void rtw_fw_leave_lps_check(struct rtw_dev *rtwdev) +{ + bool ret = false; + struct rtw_fw_state *fw; + + if (test_bit(RTW_FLAG_WOWLAN, rtwdev->flags)) + fw = &rtwdev->wow_fw; + else + fw = &rtwdev->fw; + + if (fw->feature & FW_FEATURE_LPS_C2H) + ret = __rtw_fw_leave_lps_check_c2h(rtwdev); + else + ret = __rtw_fw_leave_lps_check_reg(rtwdev); + + if (ret) { + rtw_write32_clr(rtwdev, REG_TCR, BIT_PWRMGT_HWDATA_EN); + rtw_warn(rtwdev, "firmware failed to leave lps state\n"); + } +} + +static void rtw_fw_leave_lps_check_prepare(struct rtw_dev *rtwdev) +{ + struct rtw_fw_state *fw; + + if (test_bit(RTW_FLAG_WOWLAN, rtwdev->flags)) + fw = &rtwdev->wow_fw; + else + fw = &rtwdev->fw; + + if (fw->feature & FW_FEATURE_LPS_C2H) + reinit_completion(&rtwdev->lps_leave_check); } static void rtw_leave_lps_core(struct rtw_dev *rtwdev) @@ -145,8 +186,9 @@ static void rtw_leave_lps_core(struct rtw_dev *rtwdev) conf->smart_ps = 0; rtw_hci_link_ps(rtwdev, false); + rtw_fw_leave_lps_check_prepare(rtwdev); rtw_fw_set_pwr_mode(rtwdev); - rtw_fw_leave_lps_state_check(rtwdev); + rtw_fw_leave_lps_check(rtwdev); clear_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags); diff --git a/drivers/net/wireless/realtek/rtw88/ps.h b/drivers/net/wireless/realtek/rtw88/ps.h index 19afceca7d0e..915b200081fc 100644 --- a/drivers/net/wireless/realtek/rtw88/ps.h +++ b/drivers/net/wireless/realtek/rtw88/ps.h @@ -12,6 +12,7 @@ #define POWER_MODE_LCLK BIT(0) #define LEAVE_LPS_TRY_CNT 5 +#define LEAVE_LPS_TIMEOUT msecs_to_jiffies(100) int rtw_enter_ips(struct rtw_dev *rtwdev); int rtw_leave_ips(struct rtw_dev *rtwdev); From fc3ac64a3a28682f856c920b97f8359c6a5ebd2c Mon Sep 17 00:00:00 2001 From: Chin-Yen Lee Date: Fri, 30 Oct 2020 16:48:26 +0800 Subject: [PATCH 050/180] rtw88: decide lps deep mode from firmware feature. This patch checks the supported lps deep mode from firmware feature, and allows different firmware have different deep power mode. Original module parameter rtw_fw_lps_deep_mode is replaced with rtw_disable_lps_deep_mode for user to disable lps deep mode. Signed-off-by: Chin-Yen Lee Signed-off-by: Tzu-En Huang Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201030084826.9034-5-tehuang@realtek.com --- drivers/net/wireless/realtek/rtw88/fw.c | 3 +- drivers/net/wireless/realtek/rtw88/mac80211.c | 2 +- drivers/net/wireless/realtek/rtw88/main.c | 36 ++++++++++++++----- drivers/net/wireless/realtek/rtw88/main.h | 3 +- drivers/net/wireless/realtek/rtw88/ps.c | 14 ++++++-- drivers/net/wireless/realtek/rtw88/ps.h | 2 +- drivers/net/wireless/realtek/rtw88/wow.c | 5 +-- 7 files changed, 48 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c index 29fffacf4085..3cd46759802c 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c @@ -13,6 +13,7 @@ #include "debug.h" #include "util.h" #include "wow.h" +#include "ps.h" static void rtw_fw_c2h_cmd_handle_ext(struct rtw_dev *rtwdev, struct sk_buff *skb) @@ -631,7 +632,7 @@ void rtw_fw_set_nlo_info(struct rtw_dev *rtwdev, bool enable) SET_NLO_FUN_EN(h2c_pkt, enable); if (enable) { - if (rtw_fw_lps_deep_mode) + if (rtw_get_lps_deep_mode(rtwdev) != LPS_DEEP_MODE_NONE) SET_NLO_PS_32K(h2c_pkt, enable); SET_NLO_IGNORE_SECURITY(h2c_pkt, enable); SET_NLO_LOC_NLO_INFO(h2c_pkt, loc_nlo); diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c index c92fba2fa480..c69397719fdf 100644 --- a/drivers/net/wireless/realtek/rtw88/mac80211.c +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c @@ -519,7 +519,7 @@ static int rtw_ops_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, } /* download new cam settings for PG to backup */ - if (rtw_fw_lps_deep_mode == LPS_DEEP_MODE_PG) + if (rtw_get_lps_deep_mode(rtwdev) == LPS_DEEP_MODE_PG) rtw_fw_download_rsvd_page(rtwdev); out: diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 5c46f5d2e87c..71d90b98d6f1 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -16,17 +16,17 @@ #include "debug.h" #include "bf.h" -unsigned int rtw_fw_lps_deep_mode; -EXPORT_SYMBOL(rtw_fw_lps_deep_mode); +bool rtw_disable_lps_deep_mode; +EXPORT_SYMBOL(rtw_disable_lps_deep_mode); bool rtw_bf_support = true; unsigned int rtw_debug_mask; EXPORT_SYMBOL(rtw_debug_mask); -module_param_named(lps_deep_mode, rtw_fw_lps_deep_mode, uint, 0644); +module_param_named(disable_lps_deep, rtw_disable_lps_deep_mode, bool, 0644); module_param_named(support_bf, rtw_bf_support, bool, 0644); module_param_named(debug_mask, rtw_debug_mask, uint, 0644); -MODULE_PARM_DESC(lps_deep_mode, "Deeper PS mode. If 0, deep PS is disabled"); +MODULE_PARM_DESC(disable_lps_deep, "Set Y to disable Deep PS"); MODULE_PARM_DESC(support_bf, "Set Y to enable beamformee support"); MODULE_PARM_DESC(debug_mask, "Debugging mask"); @@ -1023,6 +1023,26 @@ static int rtw_wait_firmware_completion(struct rtw_dev *rtwdev) return 0; } +static enum rtw_lps_deep_mode rtw_update_lps_deep_mode(struct rtw_dev *rtwdev, + struct rtw_fw_state *fw) +{ + struct rtw_chip_info *chip = rtwdev->chip; + + if (rtw_disable_lps_deep_mode || !chip->lps_deep_mode_supported || + !fw->feature) + return LPS_DEEP_MODE_NONE; + + if ((chip->lps_deep_mode_supported & BIT(LPS_DEEP_MODE_PG)) && + (fw->feature & FW_FEATURE_PG)) + return LPS_DEEP_MODE_PG; + + if ((chip->lps_deep_mode_supported & BIT(LPS_DEEP_MODE_LCLK)) && + (fw->feature & FW_FEATURE_LCLK)) + return LPS_DEEP_MODE_LCLK; + + return LPS_DEEP_MODE_NONE; +} + static int rtw_power_on(struct rtw_dev *rtwdev) { struct rtw_chip_info *chip = rtwdev->chip; @@ -1097,6 +1117,9 @@ int rtw_core_start(struct rtw_dev *rtwdev) rtw_sec_enable_sec_engine(rtwdev); + rtwdev->lps_conf.deep_mode = rtw_update_lps_deep_mode(rtwdev, &rtwdev->fw); + rtwdev->lps_conf.wow_deep_mode = rtw_update_lps_deep_mode(rtwdev, &rtwdev->wow_fw); + /* rcr reset after powered on */ rtw_write32(rtwdev, REG_RCR, rtwdev->hal.rcr); @@ -1657,10 +1680,6 @@ int rtw_core_init(struct rtw_dev *rtwdev) rtwdev->sec.total_cam_num = 32; rtwdev->hal.current_channel = 1; set_bit(RTW_BC_MC_MACID, rtwdev->mac_id_map); - if (!(BIT(rtw_fw_lps_deep_mode) & chip->lps_deep_mode_supported)) - rtwdev->lps_conf.deep_mode = LPS_DEEP_MODE_NONE; - else - rtwdev->lps_conf.deep_mode = rtw_fw_lps_deep_mode; rtw_stats_init(rtwdev); @@ -1685,6 +1704,7 @@ int rtw_core_init(struct rtw_dev *rtwdev) return ret; } } + return 0; } EXPORT_SYMBOL(rtw_core_init); diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index b635e1876680..8d11d56c83f2 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -37,7 +37,7 @@ #define RTW_TP_SHIFT 18 /* bytes/2s --> Mbps */ extern bool rtw_bf_support; -extern unsigned int rtw_fw_lps_deep_mode; +extern bool rtw_disable_lps_deep_mode; extern unsigned int rtw_debug_mask; extern const struct ieee80211_ops rtw_ops; @@ -664,6 +664,7 @@ enum rtw_pwr_state { struct rtw_lps_conf { enum rtw_lps_mode mode; enum rtw_lps_deep_mode deep_mode; + enum rtw_lps_deep_mode wow_deep_mode; enum rtw_pwr_state state; u8 awake_interval; u8 rlbm; diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c index 233b3df264b3..3bead34c3d10 100644 --- a/drivers/net/wireless/realtek/rtw88/ps.c +++ b/drivers/net/wireless/realtek/rtw88/ps.c @@ -77,7 +77,7 @@ void rtw_power_mode_change(struct rtw_dev *rtwdev, bool enter) request ^= request | BIT_RPWM_TOGGLE; if (enter) { request |= POWER_MODE_LCLK; - if (rtw_fw_lps_deep_mode == LPS_DEEP_MODE_PG) + if (rtw_get_lps_deep_mode(rtwdev) == LPS_DEEP_MODE_PG) request |= POWER_MODE_PG; } /* Each request require an ack from firmware */ @@ -195,9 +195,17 @@ static void rtw_leave_lps_core(struct rtw_dev *rtwdev) rtw_coex_lps_notify(rtwdev, COEX_LPS_DISABLE); } +enum rtw_lps_deep_mode rtw_get_lps_deep_mode(struct rtw_dev *rtwdev) +{ + if (test_bit(RTW_FLAG_WOWLAN, rtwdev->flags)) + return rtwdev->lps_conf.wow_deep_mode; + else + return rtwdev->lps_conf.deep_mode; +} + static void __rtw_enter_lps_deep(struct rtw_dev *rtwdev) { - if (rtwdev->lps_conf.deep_mode == LPS_DEEP_MODE_NONE) + if (rtw_get_lps_deep_mode(rtwdev) == LPS_DEEP_MODE_NONE) return; if (!test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags)) { @@ -206,7 +214,7 @@ static void __rtw_enter_lps_deep(struct rtw_dev *rtwdev) return; } - if (rtw_fw_lps_deep_mode == LPS_DEEP_MODE_PG) + if (rtw_get_lps_deep_mode(rtwdev) == LPS_DEEP_MODE_PG) rtw_fw_set_pg_info(rtwdev); rtw_hci_deep_ps(rtwdev, true); diff --git a/drivers/net/wireless/realtek/rtw88/ps.h b/drivers/net/wireless/realtek/rtw88/ps.h index 915b200081fc..7819391c8663 100644 --- a/drivers/net/wireless/realtek/rtw88/ps.h +++ b/drivers/net/wireless/realtek/rtw88/ps.h @@ -21,5 +21,5 @@ void rtw_power_mode_change(struct rtw_dev *rtwdev, bool enter); void rtw_enter_lps(struct rtw_dev *rtwdev, u8 port_id); void rtw_leave_lps(struct rtw_dev *rtwdev); void rtw_leave_lps_deep(struct rtw_dev *rtwdev); - +enum rtw_lps_deep_mode rtw_get_lps_deep_mode(struct rtw_dev *rtwdev); #endif diff --git a/drivers/net/wireless/realtek/rtw88/wow.c b/drivers/net/wireless/realtek/rtw88/wow.c index 2fcdf70a3a77..b419bc28861f 100644 --- a/drivers/net/wireless/realtek/rtw88/wow.c +++ b/drivers/net/wireless/realtek/rtw88/wow.c @@ -555,7 +555,7 @@ static int rtw_wow_leave_no_link_ps(struct rtw_dev *rtwdev) int ret = 0; if (test_bit(RTW_FLAG_WOWLAN, rtwdev->flags)) { - if (rtw_fw_lps_deep_mode) + if (rtw_get_lps_deep_mode(rtwdev) != LPS_DEEP_MODE_NONE) rtw_leave_lps_deep(rtwdev); } else { if (test_bit(RTW_FLAG_INACTIVE_PS, rtwdev->flags)) { @@ -616,7 +616,8 @@ static int rtw_wow_enter_ps(struct rtw_dev *rtwdev) if (rtw_wow_mgd_linked(rtwdev)) ret = rtw_wow_enter_linked_ps(rtwdev); - else if (rtw_wow_no_link(rtwdev) && rtw_fw_lps_deep_mode) + else if (rtw_wow_no_link(rtwdev) && + rtw_get_lps_deep_mode(rtwdev) != LPS_DEEP_MODE_NONE) ret = rtw_wow_enter_no_link_ps(rtwdev); return ret; From 28606150768a20b291a35dbbbb0ab4dd7d4739db Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Mon, 2 Nov 2020 02:32:36 +0900 Subject: [PATCH 051/180] rtl8xxxu: Add Buffalo WI-U3-866D to list of supported devices Buffalo WI-U3-866D is supported by the rtl8812au driver. Also RTL8812AU software supports the product RTL8192EU also. So add Buffalo WI-U3-866D with the RTL8192EU driver info. Signed-off-by: Tokunori Ikegami Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201101173236.7851-1-ikegami.t@gmail.com --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 5cd7ef3625c5..40291d594ade 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -6761,6 +6761,9 @@ static const struct usb_device_id dev_table[] = { /* Tested by Myckel Habets */ {USB_DEVICE_AND_INTERFACE_INFO(0x2357, 0x0109, 0xff, 0xff, 0xff), .driver_info = (unsigned long)&rtl8192eu_fops}, +/* Buffalo WI-U3-866D */ +{USB_DEVICE_AND_INTERFACE_INFO(0x0411, 0x025d, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192eu_fops}, {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0xb720, 0xff, 0xff, 0xff), .driver_info = (unsigned long)&rtl8723bu_fops}, {USB_DEVICE_AND_INTERFACE_INFO(0x7392, 0xa611, 0xff, 0xff, 0xff), From ce4dd05cbba697c748d9b665bd05467910318811 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 1 Nov 2020 22:15:29 +0100 Subject: [PATCH 052/180] orinoco: Remove BUG_ON(in_interrupt/irq()) The usage of in_irq()/in_interrupt() in drivers is phased out and the BUG_ON()'s based on those are not covering all contexts in which these functions cannot be called. Aside of that BUG_ON() should only be used as last resort, which is clearly not the case here. A broad variety of checks in the invoked functions (always enabled or debug option dependent) cover these conditions already, so the BUG_ON()'s do not really provide additional value. Just remove them. Signed-off-by: Sebastian Andrzej Siewior Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201101211536.2966644-2-bigeasy@linutronix.de --- drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index b849d27bd741..046f2453ad5d 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -859,8 +859,6 @@ static int ezusb_access_ltv(struct ezusb_priv *upriv, int retval = 0; enum ezusb_state state; - BUG_ON(in_irq()); - if (!upriv->udev) { retval = -ENODEV; goto exit; @@ -1349,7 +1347,6 @@ static int ezusb_init(struct hermes *hw) struct ezusb_priv *upriv = hw->priv; int retval; - BUG_ON(in_interrupt()); if (!upriv) return -EINVAL; @@ -1448,7 +1445,6 @@ static inline void ezusb_delete(struct ezusb_priv *upriv) struct list_head *tmp_item; unsigned long flags; - BUG_ON(in_interrupt()); BUG_ON(!upriv); mutex_lock(&upriv->mtx); From 24bf941f2c96d889df8b892adae25c68b6678787 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 1 Nov 2020 22:15:30 +0100 Subject: [PATCH 053/180] airo: Invoke airo_read_wireless_stats() directly airo_get_wireless_stats() is the iw_handler_if::get_wireless_stats() callback of this driver. This callback was not allowed to sleep until commit a160ee69c6a46 ("wext: let get_wireless_stats() sleep") in v2.6.32. airo still delegates the readout to a thread, which is not longer necessary. Invoke airo_read_wireless_stats() directly from the callback and remove the now unused JOB_WSTATS handling. Signed-off-by: Sebastian Andrzej Siewior Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201101211536.2966644-3-bigeasy@linutronix.de --- drivers/net/wireless/cisco/airo.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index 87b9398b03fd..ca423f3b6b3e 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -1144,7 +1144,6 @@ static int airo_thread(void *data); static void timer_func(struct net_device *dev); static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev); -static void airo_read_wireless_stats(struct airo_info *local); #ifdef CISCO_EXT static int readrids(struct net_device *dev, aironet_ioctl *comp); static int writerids(struct net_device *dev, aironet_ioctl *comp); @@ -1200,7 +1199,6 @@ struct airo_info { #define JOB_MIC 5 #define JOB_EVENT 6 #define JOB_AUTOWEP 7 -#define JOB_WSTATS 8 #define JOB_SCAN_RESULTS 9 unsigned long jobs; int (*bap_read)(struct airo_info*, __le16 *pu16Dst, int bytelen, @@ -3155,8 +3153,6 @@ static int airo_thread(void *data) airo_end_xmit11(dev); else if (test_bit(JOB_STATS, &ai->jobs)) airo_read_stats(dev); - else if (test_bit(JOB_WSTATS, &ai->jobs)) - airo_read_wireless_stats(ai); else if (test_bit(JOB_PROMISC, &ai->jobs)) airo_set_promisc(ai); else if (test_bit(JOB_MIC, &ai->jobs)) @@ -7732,15 +7728,12 @@ static void airo_read_wireless_stats(struct airo_info *local) __le32 *vals = stats_rid.vals; /* Get stats out of the card */ - clear_bit(JOB_WSTATS, &local->jobs); - if (local->power.event) { - up(&local->sem); + if (local->power.event) return; - } + readCapabilityRid(local, &cap_rid, 0); readStatusRid(local, &status_rid, 0); readStatsRid(local, &stats_rid, RID_STATS, 0); - up(&local->sem); /* The status */ local->wstats.status = le16_to_cpu(status_rid.mode); @@ -7783,15 +7776,10 @@ static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev) { struct airo_info *local = dev->ml_priv; - if (!test_bit(JOB_WSTATS, &local->jobs)) { - /* Get stats out of the card if available */ - if (down_trylock(&local->sem) != 0) { - set_bit(JOB_WSTATS, &local->jobs); - wake_up_interruptible(&local->thr_wait); - } else - airo_read_wireless_stats(local); + if (!down_interruptible(&local->sem)) { + airo_read_wireless_stats(local); + up(&local->sem); } - return &local->wstats; } From 49eb01995285361a398352d2ac403dd21f5e0c62 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 1 Nov 2020 22:15:31 +0100 Subject: [PATCH 054/180] airo: Always use JOB_STATS and JOB_EVENT issuecommand() is using in_atomic() to decide if it is safe to invoke schedule() while waiting for the command to be accepted. Usage of in_atomic() for this is only half correct as it can not detect all condition where it is not allowed to schedule(). Also Linus clearly requested that code which changes behaviour depending on context should either be seperated or the context be conveyed in an argument passed by the caller, which usually knows the context. Chasing the call chains leading up to issuecommand() is straight forward, but airo_link() and airo_get_stats() would require to pass the context through a quite large amount of functions. As this is ancient hardware, avoid the churn and enforce the invocation of those functions through the JOB machinery. Signed-off-by: Sebastian Andrzej Siewior Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201101211536.2966644-4-bigeasy@linutronix.de --- drivers/net/wireless/cisco/airo.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index ca423f3b6b3e..369a6ca44d1f 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -2286,12 +2286,8 @@ static struct net_device_stats *airo_get_stats(struct net_device *dev) struct airo_info *local = dev->ml_priv; if (!test_bit(JOB_STATS, &local->jobs)) { - /* Get stats out of the card if available */ - if (down_trylock(&local->sem) != 0) { - set_bit(JOB_STATS, &local->jobs); - wake_up_interruptible(&local->thr_wait); - } else - airo_read_stats(dev); + set_bit(JOB_STATS, &local->jobs); + wake_up_interruptible(&local->thr_wait); } return &dev->stats; @@ -3277,11 +3273,9 @@ static void airo_handle_link(struct airo_info *ai) set_bit(FLAG_UPDATE_UNI, &ai->flags); set_bit(FLAG_UPDATE_MULTI, &ai->flags); - if (down_trylock(&ai->sem) != 0) { - set_bit(JOB_EVENT, &ai->jobs); - wake_up_interruptible(&ai->thr_wait); - } else - airo_send_event(ai->dev); + set_bit(JOB_EVENT, &ai->jobs); + wake_up_interruptible(&ai->thr_wait); + netif_carrier_on(ai->dev); } else if (!scan_forceloss) { if (auto_wep && !ai->expires) { From 494e46d08d355294689a5811b54ae4ad01cdb95b Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 1 Nov 2020 22:15:32 +0100 Subject: [PATCH 055/180] airo: Replace in_atomic() usage. issuecommand() is using in_atomic() to decide if it is safe to invoke schedule() while waiting for the command to be accepted. Usage of in_atomic() for this is only half correct as it can not detect all condition where it is not allowed to schedule(). Also Linus clearly requested that code which changes behaviour depending on context should either be seperated or the context be conveyed in an argument passed by the caller, which usually knows the context. Add an may_sleep argument to issuecommand() indicating when it is save to sleep and change schedule() to cond_resched() because it's pointless to invoke schedule() if there is no request to reschedule. Pass the may_sleep condition through the various call chains leading to issuecommand(). Signed-off-by: Sebastian Andrzej Siewior Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201101211536.2966644-5-bigeasy@linutronix.de --- drivers/net/wireless/cisco/airo.c | 86 +++++++++++++++++-------------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index 369a6ca44d1f..74acf9af2adb 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -1115,7 +1115,8 @@ static int enable_MAC(struct airo_info *ai, int lock); static void disable_MAC(struct airo_info *ai, int lock); static void enable_interrupts(struct airo_info*); static void disable_interrupts(struct airo_info*); -static u16 issuecommand(struct airo_info*, Cmd *pCmd, Resp *pRsp); +static u16 issuecommand(struct airo_info*, Cmd *pCmd, Resp *pRsp, + bool may_sleep); static int bap_setup(struct airo_info*, u16 rid, u16 offset, int whichbap); static int aux_bap_read(struct airo_info*, __le16 *pu16Dst, int bytelen, int whichbap); @@ -1130,8 +1131,10 @@ static int PC4500_writerid(struct airo_info*, u16 rid, const void static int do_writerid(struct airo_info*, u16 rid, const void *rid_data, int len, int dummy); static u16 transmit_allocate(struct airo_info*, int lenPayload, int raw); -static int transmit_802_3_packet(struct airo_info*, int len, char *pPacket); -static int transmit_802_11_packet(struct airo_info*, int len, char *pPacket); +static int transmit_802_3_packet(struct airo_info*, int len, char *pPacket, + bool may_sleep); +static int transmit_802_11_packet(struct airo_info*, int len, char *pPacket, + bool may_sleep); static int mpi_send_packet(struct net_device *dev); static void mpi_unmap_card(struct pci_dev *pci); @@ -1753,7 +1756,7 @@ static int readBSSListRid(struct airo_info *ai, int first, if (down_interruptible(&ai->sem)) return -ERESTARTSYS; ai->list_bss_task = current; - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); up(&ai->sem); /* Let the command take effect */ schedule_timeout_uninterruptible(3 * HZ); @@ -2096,7 +2099,7 @@ static void get_tx_error(struct airo_info *ai, s32 fid) } } -static void airo_end_xmit(struct net_device *dev) +static void airo_end_xmit(struct net_device *dev, bool may_sleep) { u16 status; int i; @@ -2107,7 +2110,7 @@ static void airo_end_xmit(struct net_device *dev) clear_bit(JOB_XMIT, &priv->jobs); clear_bit(FLAG_PENDING_XMIT, &priv->flags); - status = transmit_802_3_packet (priv, fids[fid], skb->data); + status = transmit_802_3_packet(priv, fids[fid], skb->data, may_sleep); up(&priv->sem); i = 0; @@ -2164,11 +2167,11 @@ static netdev_tx_t airo_start_xmit(struct sk_buff *skb, set_bit(JOB_XMIT, &priv->jobs); wake_up_interruptible(&priv->thr_wait); } else - airo_end_xmit(dev); + airo_end_xmit(dev, false); return NETDEV_TX_OK; } -static void airo_end_xmit11(struct net_device *dev) +static void airo_end_xmit11(struct net_device *dev, bool may_sleep) { u16 status; int i; @@ -2179,7 +2182,7 @@ static void airo_end_xmit11(struct net_device *dev) clear_bit(JOB_XMIT11, &priv->jobs); clear_bit(FLAG_PENDING_XMIT11, &priv->flags); - status = transmit_802_11_packet (priv, fids[fid], skb->data); + status = transmit_802_11_packet(priv, fids[fid], skb->data, may_sleep); up(&priv->sem); i = MAX_FIDS / 2; @@ -2243,7 +2246,7 @@ static netdev_tx_t airo_start_xmit11(struct sk_buff *skb, set_bit(JOB_XMIT11, &priv->jobs); wake_up_interruptible(&priv->thr_wait); } else - airo_end_xmit11(dev); + airo_end_xmit11(dev, false); return NETDEV_TX_OK; } @@ -2293,7 +2296,7 @@ static struct net_device_stats *airo_get_stats(struct net_device *dev) return &dev->stats; } -static void airo_set_promisc(struct airo_info *ai) +static void airo_set_promisc(struct airo_info *ai, bool may_sleep) { Cmd cmd; Resp rsp; @@ -2302,7 +2305,7 @@ static void airo_set_promisc(struct airo_info *ai) cmd.cmd = CMD_SETMODE; clear_bit(JOB_PROMISC, &ai->jobs); cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, may_sleep); up(&ai->sem); } @@ -2316,7 +2319,7 @@ static void airo_set_multicast_list(struct net_device *dev) set_bit(JOB_PROMISC, &ai->jobs); wake_up_interruptible(&ai->thr_wait); } else - airo_set_promisc(ai); + airo_set_promisc(ai, false); } if ((dev->flags&IFF_ALLMULTI) || !netdev_mc_empty(dev)) { @@ -2476,7 +2479,7 @@ static int mpi_init_descriptors (struct airo_info *ai) cmd.parm0 = FID_RX; cmd.parm1 = (ai->rxfids[0].card_ram_off - ai->pciaux); cmd.parm2 = MPI_MAX_FIDS; - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rc != SUCCESS) { airo_print_err(ai->dev->name, "Couldn't allocate RX FID"); return rc; @@ -2504,7 +2507,7 @@ static int mpi_init_descriptors (struct airo_info *ai) } ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rc != SUCCESS) { airo_print_err(ai->dev->name, "Couldn't allocate TX FID"); return rc; @@ -2518,7 +2521,7 @@ static int mpi_init_descriptors (struct airo_info *ai) cmd.parm0 = RID_RW; cmd.parm1 = (ai->config_desc.card_ram_off - ai->pciaux); cmd.parm2 = 1; /* Magic number... */ - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rc != SUCCESS) { airo_print_err(ai->dev->name, "Couldn't allocate RID"); return rc; @@ -3144,13 +3147,13 @@ static int airo_thread(void *data) } if (test_bit(JOB_XMIT, &ai->jobs)) - airo_end_xmit(dev); + airo_end_xmit(dev, true); else if (test_bit(JOB_XMIT11, &ai->jobs)) - airo_end_xmit11(dev); + airo_end_xmit11(dev, true); else if (test_bit(JOB_STATS, &ai->jobs)) airo_read_stats(dev); else if (test_bit(JOB_PROMISC, &ai->jobs)) - airo_set_promisc(ai); + airo_set_promisc(ai, true); else if (test_bit(JOB_MIC, &ai->jobs)) micinit(ai); else if (test_bit(JOB_EVENT, &ai->jobs)) @@ -3599,7 +3602,7 @@ static int enable_MAC(struct airo_info *ai, int lock) if (!test_bit(FLAG_ENABLED, &ai->flags)) { memset(&cmd, 0, sizeof(cmd)); cmd.cmd = MAC_ENABLE; - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rc == SUCCESS) set_bit(FLAG_ENABLED, &ai->flags); } else @@ -3631,7 +3634,7 @@ static void disable_MAC(struct airo_info *ai, int lock) netif_carrier_off(ai->dev); memset(&cmd, 0, sizeof(cmd)); cmd.cmd = MAC_DISABLE; // disable in case already enabled - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); clear_bit(FLAG_ENABLED, &ai->flags); } if (lock == 1) @@ -3834,7 +3837,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) cmd.parm0 = cmd.parm1 = cmd.parm2 = 0; if (lock && down_interruptible(&ai->sem)) return ERROR; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) { + if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) { if (lock) up(&ai->sem); return ERROR; @@ -3844,7 +3847,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) // Let's figure out if we need to use the AUX port if (!test_bit(FLAG_MPI,&ai->flags)) { cmd.cmd = CMD_ENABLEAUX; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) { + if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) { if (lock) up(&ai->sem); airo_print_err(ai->dev->name, "Error checking for AUX port"); @@ -3956,7 +3959,8 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) return SUCCESS; } -static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) +static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp, + bool may_sleep) { // Im really paranoid about letting it run forever! int max_tries = 600000; @@ -3973,8 +3977,8 @@ static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) if ((IN4500(ai, COMMAND)) == pCmd->cmd) // PC4500 didn't notice command, try again OUT4500(ai, COMMAND, pCmd->cmd); - if (!in_atomic() && (max_tries & 255) == 0) - schedule(); + if (may_sleep && (max_tries & 255) == 0) + cond_resched(); } if (max_tries == -1) { @@ -4131,7 +4135,7 @@ static int PC4500_accessrid(struct airo_info *ai, u16 rid, u16 accmd) memset(&cmd, 0, sizeof(cmd)); cmd.cmd = accmd; cmd.parm0 = rid; - status = issuecommand(ai, &cmd, &rsp); + status = issuecommand(ai, &cmd, &rsp, true); if (status != 0) return status; if ((rsp.status & 0x7F00) != 0) { return (accmd << 8) + (rsp.rsp0 & 0xFF); @@ -4167,7 +4171,7 @@ static int PC4500_readrid(struct airo_info *ai, u16 rid, void *pBuf, int len, in memcpy_toio(ai->config_desc.card_ram_off, &ai->config_desc.rid_desc, sizeof(Rid)); - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rsp.status & 0x7f00) rc = rsp.rsp0; @@ -4246,7 +4250,7 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid, memcpy(ai->config_desc.virtual_host_addr, pBuf, len); - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if ((rc & 0xff00) != 0) { airo_print_err(ai->dev->name, "%s: Write rid Error %d", __func__, rc); @@ -4292,7 +4296,7 @@ static u16 transmit_allocate(struct airo_info *ai, int lenPayload, int raw) cmd.parm0 = lenPayload; if (down_interruptible(&ai->sem)) return ERROR; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) { + if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) { txFid = ERROR; goto done; } @@ -4338,7 +4342,8 @@ static u16 transmit_allocate(struct airo_info *ai, int lenPayload, int raw) /* In general BAP1 is dedicated to transmiting packets. However, since we need a BAP when accessing RIDs, we also use BAP1 for that. Make sure the BAP1 spinlock is held when this is called. */ -static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket) +static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket, + bool may_sleep) { __le16 payloadLen; Cmd cmd; @@ -4376,12 +4381,14 @@ static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket) memset(&cmd, 0, sizeof(cmd)); cmd.cmd = CMD_TRANSMIT; cmd.parm0 = txFid; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR; + if (issuecommand(ai, &cmd, &rsp, may_sleep) != SUCCESS) + return ERROR; if ((rsp.status & 0xFF00) != 0) return ERROR; return SUCCESS; } -static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket) +static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket, + bool may_sleep) { __le16 fc, payloadLen; Cmd cmd; @@ -4416,7 +4423,8 @@ static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket) memset(&cmd, 0, sizeof(cmd)); cmd.cmd = CMD_TRANSMIT; cmd.parm0 = txFid; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR; + if (issuecommand(ai, &cmd, &rsp, may_sleep) != SUCCESS) + return ERROR; if ((rsp.status & 0xFF00) != 0) return ERROR; return SUCCESS; } @@ -5480,7 +5488,7 @@ static int proc_BSSList_open(struct inode *inode, struct file *file) kfree(file->private_data); return -ERESTARTSYS; } - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); up(&ai->sem); data->readlen = 0; return 0; @@ -5617,7 +5625,7 @@ static int __maybe_unused airo_pci_suspend(struct device *dev_d) netif_device_detach(dev); ai->power = PMSG_SUSPEND; cmd.cmd = HOSTSLEEP; - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); device_wakeup_enable(dev_d); return 0; @@ -5960,7 +5968,7 @@ static int airo_set_wap(struct net_device *dev, cmd.cmd = CMD_LOSE_SYNC; if (down_interruptible(&local->sem)) return -ERESTARTSYS; - issuecommand(local, &cmd, &rsp); + issuecommand(local, &cmd, &rsp, true); up(&local->sem); } else { memset(APList_rid, 0, sizeof(*APList_rid)); @@ -7258,7 +7266,7 @@ static int airo_set_scan(struct net_device *dev, ai->scan_timeout = RUN_AT(3*HZ); memset(&cmd, 0, sizeof(cmd)); cmd.cmd = CMD_LISTBSS; - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); wake = 1; out: @@ -7525,7 +7533,7 @@ static int airo_config_commit(struct net_device *dev, writeConfigRid(local, 0); enable_MAC(local, 0); if (test_bit (FLAG_RESET, &local->flags)) - airo_set_promisc(local); + airo_set_promisc(local, true); else up(&local->sem); From 7534fd5e58349d74550ba7e7d492e415c3ed9368 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 1 Nov 2020 22:15:33 +0100 Subject: [PATCH 056/180] hostap: Remove in_atomic() check. hostap_get_wireless_stats() is the iw_handler_if::get_wireless_stats() callback of this driver. This callback was not allowed to sleep until commit a160ee69c6a46 ("wext: let get_wireless_stats() sleep") in v2.6.32. Remove the therefore pointless in_atomic() check. Signed-off-by: Sebastian Andrzej Siewior Cc: Jouni Malinen Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201101211536.2966644-6-bigeasy@linutronix.de --- drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c index 514c7b01dbf6..49766b285230 100644 --- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c @@ -44,19 +44,8 @@ static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev) if (local->iw_mode != IW_MODE_MASTER && local->iw_mode != IW_MODE_REPEAT) { - int update = 1; -#ifdef in_atomic - /* RID reading might sleep and it must not be called in - * interrupt context or while atomic. However, this - * function seems to be called while atomic (at least in Linux - * 2.5.59). Update signal quality values only if in suitable - * context. Otherwise, previous values read from tick timer - * will be used. */ - if (in_atomic()) - update = 0; -#endif /* in_atomic */ - if (update && prism2_update_comms_qual(dev) == 0) + if (prism2_update_comms_qual(dev) == 0) wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; From abcda807d8681923fd7b79ea08b78f684e6cb570 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 1 Nov 2020 22:15:34 +0100 Subject: [PATCH 057/180] zd1211rw: Remove in_atomic() usage. The usage of in_atomic() in driver code is deprecated as it can not always detect all states where it is not allowed to sleep. All callers are in premptible thread context and all functions invoke core functions which have checks for invalid calling contexts already. Signed-off-by: Sebastian Andrzej Siewior Cc: Ulrich Kunitz Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201101211536.2966644-7-bigeasy@linutronix.de --- drivers/net/wireless/zydas/zd1211rw/zd_usb.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/net/wireless/zydas/zd1211rw/zd_usb.c b/drivers/net/wireless/zydas/zd1211rw/zd_usb.c index 66367ab7e4c1..5c4cd0e1adeb 100644 --- a/drivers/net/wireless/zydas/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zydas/zd1211rw/zd_usb.c @@ -1711,11 +1711,6 @@ int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, count, USB_MAX_IOREAD16_COUNT); return -EINVAL; } - if (in_atomic()) { - dev_dbg_f(zd_usb_dev(usb), - "error: io in atomic context not supported\n"); - return -EWOULDBLOCK; - } if (!usb_int_enabled(usb)) { dev_dbg_f(zd_usb_dev(usb), "error: usb interrupt not enabled\n"); @@ -1882,11 +1877,6 @@ int zd_usb_iowrite16v_async(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs, count, USB_MAX_IOWRITE16_COUNT); return -EINVAL; } - if (in_atomic()) { - dev_dbg_f(zd_usb_dev(usb), - "error: io in atomic context not supported\n"); - return -EWOULDBLOCK; - } udev = zd_usb_to_usbdev(usb); @@ -1966,11 +1956,6 @@ int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits) int i, req_len, actual_req_len; u16 bit_value_template; - if (in_atomic()) { - dev_dbg_f(zd_usb_dev(usb), - "error: io in atomic context not supported\n"); - return -EWOULDBLOCK; - } if (bits < USB_MIN_RFWRITE_BIT_COUNT) { dev_dbg_f(zd_usb_dev(usb), "error: bits %d are smaller than" From 317f688b0a541808104de9a6e8cff88c602e00cf Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 1 Nov 2020 22:15:35 +0100 Subject: [PATCH 058/180] rtlwifi: Remove in_interrupt() usage in is_any_client_connect_to_ap(). is_any_client_connect_to_ap() is using in_interrupt() to determine whether it should acquire the lock prior accessing the list. The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. The function is called from: - halbtc_get() - halbtc_get() halbtc_get_wifi_link_status() - halbtc_display_dbg_msg() halbtc_display_wifi_status() halbtc_get_wifi_link_status() All top level callers are part of the btc_coexist callback inferface and are never invoked from a context which can hold the lock already. The contexts which hold the lock are either protecting list add/del operations or list walks which never call into any of the btc_coexist interfaces. In fact the conditional is outright dangerous because if this function would be invoked from a BH disabled context the check would avoid taking the lock while on another CPU the list could be manipulated under the lock. Remove the in_interrupt() check and always acquire the lock. To simplify the code further use list_empty() instead of walking the list and counting the entries just to check the count for > 0 at the end. Signed-off-by: Sebastian Andrzej Siewior Cc: Ping-Ke Shih Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201101211536.2966644-8-bigeasy@linutronix.de --- .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c index 2c05369b79e4..2155a6699ef8 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c @@ -47,30 +47,17 @@ static bool is_any_client_connect_to_ap(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv = btcoexist->adapter; struct rtl_mac *mac = rtl_mac(rtlpriv); - struct rtl_sta_info *drv_priv; - u8 cnt = 0; + bool ret = false; if (mac->opmode == NL80211_IFTYPE_ADHOC || mac->opmode == NL80211_IFTYPE_MESH_POINT || mac->opmode == NL80211_IFTYPE_AP) { - if (in_interrupt() > 0) { - list_for_each_entry(drv_priv, &rtlpriv->entry_list, - list) { - cnt++; - } - } else { - spin_lock_bh(&rtlpriv->locks.entry_list_lock); - list_for_each_entry(drv_priv, &rtlpriv->entry_list, - list) { - cnt++; - } - spin_unlock_bh(&rtlpriv->locks.entry_list_lock); - } + spin_lock_bh(&rtlpriv->locks.entry_list_lock); + if (!list_empty(&rtlpriv->entry_list)) + ret = true; + spin_unlock_bh(&rtlpriv->locks.entry_list_lock); } - if (cnt > 0) - return true; - else - return false; + return ret; } static bool halbtc_legacy(struct rtl_priv *adapter) From 50c61ae15865ea008b38d25b5c0c88556a662547 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 1 Nov 2020 22:15:36 +0100 Subject: [PATCH 059/180] rtlwifi: Remove in_interrupt() usage in halbtc_send_bt_mp_operation() halbtc_send_bt_mp_operation() uses in_interrupt() to determine if it is safe to invoke wait_for_completion(). The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. Aside of that in_interrupt() is not correct as it does not catch preempt disabled regions which neither can sleep. halbtc_send_bt_mp_operation() is called from: rtl_watchdog_wq_callback() rtl_btc_periodical() halbtc_get() case BTC_GET_U4_BT_PATCH_VER: halbtc_get_bt_patch_version() which is preemtible context. rtl_c2h_content_parsing() btc_ops->btc_btinfo_notify() rtl_btc_btinfo_notify() exhalbtc_bt_info_notify() ex_btc8723b1ant_bt_info_notify() ex_btc8821a1ant_bt_info_notify() ex_btc8821a2ant_bt_info_notify() btcoexist->btc_set_bt_reg() halbtc_set_bt_reg() rtl_c2h_content_parsing() is in turn called from: rtl_c2hcmd_wq_callback() rtl_c2hcmd_launcher() which is preemptible context and from: _rtl_pci_rx_interrupt rtl_c2hcmd_enqueue() which is obviously not preemptible but limited to C2H_BT_MP commands which does invoke rtl_c2h_content_parsing(). Aside of that it can be reached from: halbtc_get() case BTC_GET_U4_SUPPORTED_FEATURE: halbtc_get_bt_coex_supported_feature() case BTC_GET_U4_BT_FORBIDDEN_SLOT_VAL: halbtc_get_bt_forbidden_slot_val() case BTC_GET_U4_BT_DEVICE_INFO: halbtc_get_bt_device_info() case BTC_GET_U4_SUPPORTED_VERSION: halbtc_get_bt_coex_supported_version() case BTC_GET_U4_SUPPORTED_FEATURE: halbtc_get_bt_coex_supported_feature() btcoexist->btc_get_bt_afh_map_from_bt() halbtc_get_bt_afh_map_from_bt() btcoexist->btc_get_ble_scan_para_from_bt() halbtc_get_ble_scan_para_from_bt() btcoexist->btc_get_ble_scan_type_from_bt() halbtc_get_ble_scan_type_from_bt() btcoexist->btc_get_ant_det_val_from_bt() halbtc_get_ant_det_val_from_bt() btcoexist->btc_get_bt_coex_supported_version() halbtc_get_bt_coex_supported_version() btcoexist->btc_get_bt_coex_supported_feature() halbtc_get_bt_coex_supported_feature() None of these have a caller. Welcome to the wonderful world of HALs and onion layers. Remove in_interrupt() check. Signed-off-by: Sebastian Andrzej Siewior Cc: Ping-Ke Shih Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201101211536.2966644-9-bigeasy@linutronix.de --- drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c index 2155a6699ef8..be4c0e60d44d 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c @@ -240,9 +240,6 @@ bool halbtc_send_bt_mp_operation(struct btc_coexist *btcoexist, u8 op_code, rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, "btmpinfo wait req_num=%d wait=%ld\n", req_num, wait_ms); - if (in_interrupt()) - return false; - if (wait_for_completion_timeout(&btcoexist->bt_mp_comp, msecs_to_jiffies(wait_ms)) == 0) { rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG, From 5447626910f5b8d964761ed4fa4feaf1a3ac47d0 Mon Sep 17 00:00:00 2001 From: Markov Mikhail Date: Wed, 4 Nov 2020 15:25:24 +0100 Subject: [PATCH 060/180] rt2x00: save survey for every channel visited rt2800 only gives you survey for current channel. Survey-based ACS algorithms are failing to perform their job when working with rt2800. Make rt2800 save survey for every channel visited and be able to give away that information. There is a bug registered https://dev.archive.openwrt.org/ticket/19081 and this patch solves the issue. Signed-off-by: Markov Mikhail sgruszka: remove unused variable Signed-off-by: Stanislaw Gruszka Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201104142524.94375-1-stf_xl@wp.pl --- .../net/wireless/ralink/rt2x00/rt2800lib.c | 62 ++++++++++++++----- drivers/net/wireless/ralink/rt2x00/rt2x00.h | 10 +++ 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c index fed6d21cd6ce..5264b0a1f098 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -1228,6 +1228,17 @@ static int rt2800_check_hung(struct data_queue *queue) return queue->wd_count > 16; } +static void rt2800_update_survey(struct rt2x00_dev *rt2x00dev) +{ + struct ieee80211_channel *chan = rt2x00dev->hw->conf.chandef.chan; + struct rt2x00_chan_survey *chan_survey = + &rt2x00dev->chan_survey[chan->hw_value]; + + chan_survey->time_idle += rt2800_register_read(rt2x00dev, CH_IDLE_STA); + chan_survey->time_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA); + chan_survey->time_ext_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC); +} + void rt2800_watchdog(struct rt2x00_dev *rt2x00dev) { struct data_queue *queue; @@ -1237,6 +1248,8 @@ void rt2800_watchdog(struct rt2x00_dev *rt2x00dev) if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) return; + rt2800_update_survey(rt2x00dev); + queue_for_each(rt2x00dev, queue) { switch (queue->qid) { case QID_AC_VO: @@ -5553,6 +5566,12 @@ void rt2800_config(struct rt2x00_dev *rt2x00dev, rt2800_config_lna_gain(rt2x00dev, libconf); if (flags & IEEE80211_CONF_CHANGE_CHANNEL) { + /* + * To provide correct survey data for survey-based ACS algorithm + * we have to save survey data for current channel before switching. + */ + rt2800_update_survey(rt2x00dev); + rt2800_config_channel(rt2x00dev, libconf->conf, &libconf->rf, &libconf->channel); rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, @@ -10111,12 +10130,20 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) } /* - * Create channel information array + * Create channel information and survey arrays */ info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; + rt2x00dev->chan_survey = + kcalloc(spec->num_channels, sizeof(struct rt2x00_chan_survey), + GFP_KERNEL); + if (!rt2x00dev->chan_survey) { + kfree(info); + return -ENOMEM; + } + spec->channels_info = info; default_power1 = rt2800_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1); @@ -10503,27 +10530,30 @@ int rt2800_get_survey(struct ieee80211_hw *hw, int idx, struct survey_info *survey) { struct rt2x00_dev *rt2x00dev = hw->priv; - struct ieee80211_conf *conf = &hw->conf; - u32 idle, busy, busy_ext; + struct rt2x00_chan_survey *chan_survey = + &rt2x00dev->chan_survey[idx]; + enum nl80211_band band = NL80211_BAND_2GHZ; - if (idx != 0) + if (idx >= rt2x00dev->bands[band].n_channels) { + idx -= rt2x00dev->bands[band].n_channels; + band = NL80211_BAND_5GHZ; + } + + if (idx >= rt2x00dev->bands[band].n_channels) return -ENOENT; - survey->channel = conf->chandef.chan; + if (idx == 0) + rt2800_update_survey(rt2x00dev); - idle = rt2800_register_read(rt2x00dev, CH_IDLE_STA); - busy = rt2800_register_read(rt2x00dev, CH_BUSY_STA); - busy_ext = rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC); + survey->channel = &rt2x00dev->bands[band].channels[idx]; - if (idle || busy) { - survey->filled = SURVEY_INFO_TIME | - SURVEY_INFO_TIME_BUSY | - SURVEY_INFO_TIME_EXT_BUSY; + survey->filled = SURVEY_INFO_TIME | + SURVEY_INFO_TIME_BUSY | + SURVEY_INFO_TIME_EXT_BUSY; - survey->time = (idle + busy) / 1000; - survey->time_busy = busy / 1000; - survey->time_ext_busy = busy_ext / 1000; - } + survey->time = div_u64(chan_survey->time_idle + chan_survey->time_busy, 1000); + survey->time_busy = div_u64(chan_survey->time_busy, 1000); + survey->time_ext_busy = div_u64(chan_survey->time_ext_busy, 1000); if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) survey->filled |= SURVEY_INFO_IN_USE; diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h index 780be81863b6..9f6fc40649be 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h @@ -181,6 +181,15 @@ struct rf_channel { u32 rf4; }; +/* + * Information structure for channel survey. + */ +struct rt2x00_chan_survey { + u64 time_idle; + u64 time_busy; + u64 time_ext_busy; +}; + /* * Channel information structure */ @@ -752,6 +761,7 @@ struct rt2x00_dev { */ struct ieee80211_hw *hw; struct ieee80211_supported_band bands[NUM_NL80211_BANDS]; + struct rt2x00_chan_survey *chan_survey; enum nl80211_band curr_band; int curr_freq; From f21e6c5822f27a5f4dfb76dde9e1e7f7220b24d5 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:31 +0000 Subject: [PATCH 061/180] rsi: rsi_91x_usb: Fix some basic kernel-doc issues Fixes the following W=1 kernel build warning(s): drivers/net/wireless/rsi/rsi_91x_usb.c:26: warning: cannot understand function prototype: 'u16 dev_oper_mode = DEV_OPMODE_STA_BT_DUAL; ' drivers/net/wireless/rsi/rsi_91x_usb.c:88: warning: Function parameter or member 'endpoint' not described in 'rsi_write_multiple' drivers/net/wireless/rsi/rsi_91x_usb.c:88: warning: Excess function parameter 'addr' description in 'rsi_write_multiple' drivers/net/wireless/rsi/rsi_91x_usb.c:320: warning: Function parameter or member 'ep_num' not described in 'rsi_rx_urb_submit' drivers/net/wireless/rsi/rsi_91x_usb.c:320: warning: Function parameter or member 'mem_flags' not described in 'rsi_rx_urb_submit' Cc: Amitkumar Karwar Cc: Siva Rebbagondla Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-3-lee.jones@linaro.org --- drivers/net/wireless/rsi/rsi_91x_usb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c index a62d41c0ccbc..8928e1467151 100644 --- a/drivers/net/wireless/rsi/rsi_91x_usb.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb.c @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014 Redpine Signals Inc. * * Permission to use, copy, modify, and/or distribute this software for any @@ -75,7 +75,7 @@ static int rsi_usb_card_write(struct rsi_hw *adapter, * rsi_write_multiple() - This function writes multiple bytes of information * to the USB card. * @adapter: Pointer to the adapter structure. - * @addr: Address of the register. + * @endpoint: Type of endpoint. * @data: Pointer to the data that has to be written. * @count: Number of multiple bytes to be written. * @@ -313,6 +313,8 @@ static void rsi_rx_urb_kill(struct rsi_hw *adapter, u8 ep_num) /** * rsi_rx_urb_submit() - This function submits the given URB to the USB stack. * @adapter: Pointer to the adapter structure. + * @ep_num: Endpoint number. + * @mem_flags: The type of memory to allocate. * * Return: 0 on success, a negative error code on failure. */ From 63636b385e39e0ef1beba89cfb5c494360335196 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:33 +0000 Subject: [PATCH 062/180] rsi: rsi_91x_usb_ops: Source file headers are not good candidates for kernel-doc Fixes the following W=1 kernel build warning(s): drivers/net/wireless/rsi/rsi_91x_usb_ops.c:22: warning: Incorrect use of kernel-doc format: * rsi_usb_rx_thread() - This is a kernel thread to receive the packets from drivers/net/wireless/rsi/rsi_91x_usb_ops.c:29: warning: Function parameter or member 'common' not described in 'rsi_usb_rx_thread' Cc: Amitkumar Karwar Cc: Siva Rebbagondla Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-5-lee.jones@linaro.org --- drivers/net/wireless/rsi/rsi_91x_usb_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_usb_ops.c b/drivers/net/wireless/rsi/rsi_91x_usb_ops.c index b1687d22f73f..4ffcdde1acb1 100644 --- a/drivers/net/wireless/rsi/rsi_91x_usb_ops.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb_ops.c @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014 Redpine Signals Inc. * * Permission to use, copy, modify, and/or distribute this software for any From 6f0d044fc82e304930ec0fd12ad396351c900f84 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:35 +0000 Subject: [PATCH 063/180] brcmfmac: bcmsdh: Fix description for function parameter 'pktlist' Fixes the following W=1 kernel build warning(s): drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c:380: warning: Function parameter or member 'pktlist' not described in 'brcmf_sdiod_sglist_rw' drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c:380: warning: Excess function parameter 'pkt' description in 'brcmf_sdiod_sglist_rw' Cc: Arend van Spriel Cc: Franky Lin Cc: Hante Meuleman Cc: Chi-Hsien Lin Cc: Wright Feng Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list.pdl@broadcom.com Cc: brcm80211-dev-list@cypress.com Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-7-lee.jones@linaro.org --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c index f9ebb98b0e3c..ce8c102df7b3 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c @@ -367,7 +367,7 @@ static int mmc_submit_one(struct mmc_data *md, struct mmc_request *mr, * @func: SDIO function * @write: direction flag * @addr: dongle memory address as source/destination - * @pkt: skb pointer + * @pktlist: skb buffer head pointer * * This function takes the respbonsibility as the interface function to MMC * stack for block data access. It assumes that the skb passed down by the From 05cefa989e8bf9f058943a5a6a45f95cf87cf936 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:36 +0000 Subject: [PATCH 064/180] brcmfmac: pcie: Provide description for missing function parameter 'devinfo' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:766: warning: Function parameter or member 'devinfo' not described in 'brcmf_pcie_bus_console_read' Cc: Arend van Spriel Cc: Franky Lin Cc: Hante Meuleman Cc: Chi-Hsien Lin Cc: Wright Feng Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Sumit Semwal Cc: "Christian König" Cc: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list.pdl@broadcom.com Cc: brcm80211-dev-list@cypress.com Cc: netdev@vger.kernel.org Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linaro-mm-sig@lists.linaro.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-8-lee.jones@linaro.org --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 39381cbde89e..1d3cc1c7c9c5 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -759,6 +759,7 @@ static void brcmf_pcie_bus_console_init(struct brcmf_pciedev_info *devinfo) /** * brcmf_pcie_bus_console_read - reads firmware messages * + * @devinfo: pointer to the device data structure * @error: specifies if error has occurred (prints messages unconditionally) */ static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo, From 9bd28c6607babb92888ba42f5deb6b0d5000a376 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:47 +0000 Subject: [PATCH 065/180] brcmfmac: fweh: Add missing description for 'gfp' Fixes the following W=1 kernel build warning(s): drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c:394: warning: Function parameter or member 'gfp' not described in 'brcmf_fweh_process_event' Cc: Arend van Spriel Cc: Franky Lin Cc: Hante Meuleman Cc: Chi-Hsien Lin Cc: Wright Feng Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list.pdl@broadcom.com Cc: brcm80211-dev-list@cypress.com Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-19-lee.jones@linaro.org --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c index 430d2cca98b3..bc3f4e4edcdf 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c @@ -384,6 +384,7 @@ int brcmf_fweh_activate_events(struct brcmf_if *ifp) * @drvr: driver information object. * @event_packet: event packet to process. * @packet_len: length of the packet + * @gfp: memory allocation flags. * * If the packet buffer contains a firmware event message it will * dispatch the event to a registered handler (using worker). From 641291eca88c0209a0dba1eb32413101e0002352 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:38 +0000 Subject: [PATCH 066/180] wl1251: cmd: Rename 'len' to 'buf_len' in the documentation Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ti/wl1251/cmd.c:70: warning: Function parameter or member 'buf_len' not described in 'wl1251_cmd_test' drivers/net/wireless/ti/wl1251/cmd.c:70: warning: Excess function parameter 'len' description in 'wl1251_cmd_test' Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-10-lee.jones@linaro.org --- drivers/net/wireless/ti/wl1251/cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ti/wl1251/cmd.c b/drivers/net/wireless/ti/wl1251/cmd.c index 9547aea01b0f..e1095b8de2bd 100644 --- a/drivers/net/wireless/ti/wl1251/cmd.c +++ b/drivers/net/wireless/ti/wl1251/cmd.c @@ -63,7 +63,7 @@ int wl1251_cmd_send(struct wl1251 *wl, u16 id, void *buf, size_t len) * * @wl: wl struct * @buf: buffer containing the command, with all headers, must work with dma - * @len: length of the buffer + * @buf_len: length of the buffer * @answer: is answer needed */ int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer) From 9afcf32236751779f1bb2e043605de6201268cf0 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:43 +0000 Subject: [PATCH 067/180] prism54: isl_ioctl: Fix one function header and demote another MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): from drivers/net/wireless/intersil/prism54/isl_ioctl.c:22: inlined from ‘prism54_get_name’ at drivers/net/wireless/intersil/prism54/isl_ioctl.c:283:2: drivers/net/wireless/intersil/prism54/isl_ioctl.c:68: warning: Function parameter or member 'priv' not described in 'prism54_mib_mode_helper' drivers/net/wireless/intersil/prism54/isl_ioctl.c:68: warning: Excess function parameter 'mib' description in 'prism54_mib_mode_helper' drivers/net/wireless/intersil/prism54/isl_ioctl.c:127: warning: Function parameter or member 'priv' not described in 'prism54_mib_init' Cc: Luis Chamberlain Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Aurelien Alleaume Cc: Valerio Riedel Cc: "Luis R. Rodriguez" Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-15-lee.jones@linaro.org --- drivers/net/wireless/intersil/prism54/isl_ioctl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intersil/prism54/isl_ioctl.c b/drivers/net/wireless/intersil/prism54/isl_ioctl.c index 2076f449b6e2..5e5ceafe098b 100644 --- a/drivers/net/wireless/intersil/prism54/isl_ioctl.c +++ b/drivers/net/wireless/intersil/prism54/isl_ioctl.c @@ -54,7 +54,7 @@ static const unsigned char scan_rate_list[] = { 2, 4, 11, 22, /** * prism54_mib_mode_helper - MIB change mode helper function - * @mib: the &struct islpci_mib object to modify + * @priv: the &struct islpci_private object to modify * @iw_mode: new mode (%IW_MODE_*) * * This is a helper function, hence it does not lock. Make sure @@ -114,14 +114,13 @@ prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode) return 0; } -/** +/* * prism54_mib_init - fill MIB cache with defaults * * this function initializes the struct given as @mib with defaults, * of which many are retrieved from the global module parameter * variables. */ - void prism54_mib_init(islpci_private *priv) { From 8b8a6f8c3b50193d161c598a6784e721128d6dc3 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:53 +0000 Subject: [PATCH 068/180] wl3501_cs: Fix misspelling and provide missing documentation Fixes the following W=1 kernel build warning(s): In file included from drivers/net/wireless/wl3501_cs.c:57: drivers/net/wireless/wl3501_cs.c:143: warning: Function parameter or member 'reg_domain' not described in 'iw_valid_channel' drivers/net/wireless/wl3501_cs.c:143: warning: Excess function parameter 'reg_comain' description in 'iw_valid_channel' drivers/net/wireless/wl3501_cs.c:469: warning: Function parameter or member 'data' not described in 'wl3501_send_pkt' drivers/net/wireless/wl3501_cs.c:469: warning: Function parameter or member 'len' not described in 'wl3501_send_pkt' Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Fox Chen Cc: de Melo Cc: Gustavo Niemeyer Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-25-lee.jones@linaro.org --- drivers/net/wireless/wl3501_cs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 026e88b80bfc..8ca5789c7b37 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -134,7 +134,7 @@ static const struct { /** * iw_valid_channel - validate channel in regulatory domain - * @reg_comain: regulatory domain + * @reg_domain: regulatory domain * @channel: channel to validate * * Returns 0 if invalid in the specified regulatory domain, non-zero if valid. @@ -458,11 +458,9 @@ static int wl3501_pwr_mgmt(struct wl3501_card *this, int suspend) /** * wl3501_send_pkt - Send a packet. * @this: Card - * - * Send a packet. - * - * data = Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr, + * @data: Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr, * data[6] - data[11] is Src MAC Addr) + * @len: Packet length * Ref: IEEE 802.11 */ static int wl3501_send_pkt(struct wl3501_card *this, u8 *data, u16 len) From 5e43d496cd8ee4a1c2ddf8831321ee2e0e018492 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:24:00 +0000 Subject: [PATCH 069/180] mwifiex: pcie: Remove a couple of unchecked 'ret's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/marvell/mwifiex/pcie.c: In function ‘mwifiex_pcie_remove’: drivers/net/wireless/marvell/mwifiex/pcie.c:432:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/marvell/mwifiex/pcie.c: In function ‘mwifiex_cleanup_pcie’: drivers/net/wireless/marvell/mwifiex/pcie.c:3142:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable] Cc: Amitkumar Karwar Cc: Ganapathi Bhat Cc: Xinming Hu Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-32-lee.jones@linaro.org --- drivers/net/wireless/marvell/mwifiex/pcie.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 6a10ff0377a2..67e0247ebaa6 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -429,7 +429,6 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev) struct mwifiex_private *priv; const struct mwifiex_pcie_card_reg *reg; u32 fw_status; - int ret; card = pci_get_drvdata(pdev); @@ -441,7 +440,7 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev) reg = card->pcie.reg; if (reg) - ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status); + mwifiex_read_reg(adapter, reg->fw_status, &fw_status); else fw_status = -1; @@ -3139,12 +3138,11 @@ static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter) struct pcie_service_card *card = adapter->card; struct pci_dev *pdev = card->dev; const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; - int ret; u32 fw_status; cancel_work_sync(&card->work); - ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status); + mwifiex_read_reg(adapter, reg->fw_status, &fw_status); if (fw_status == FIRMWARE_READY_PCIE) { mwifiex_dbg(adapter, INFO, "Clearing driver ready signature\n"); From 409d1c82bf89415495e8ec1fc2268fa8e9fbe0f1 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:24:04 +0000 Subject: [PATCH 070/180] wlcore: spi: Demote a non-compliant function header, fix another Fixes the following W=1 kernel build warning(s): drivers/net/wireless/ti/wlcore/spi.c:403: warning: Function parameter or member 'child' not described in 'wl12xx_spi_set_block_size' drivers/net/wireless/ti/wlcore/spi.c:403: warning: Function parameter or member 'blksz' not described in 'wl12xx_spi_set_block_size' drivers/net/wireless/ti/wlcore/spi.c:440: warning: Excess function parameter 'res' description in 'wlcore_probe_of' Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Geert Uytterhoeven Cc: Luciano Coelho Cc: Juuso Oikarinen Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-36-lee.jones@linaro.org Link: https://lore.kernel.org/r/20201102112410.1049272-37-lee.jones@linaro.org --- drivers/net/wireless/ti/wlcore/spi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c index 18c4d998ce4b..f26fc150ecd0 100644 --- a/drivers/net/wireless/ti/wlcore/spi.c +++ b/drivers/net/wireless/ti/wlcore/spi.c @@ -391,7 +391,7 @@ static int wl12xx_spi_set_power(struct device *child, bool enable) return ret; } -/** +/* * wl12xx_spi_set_block_size * * This function is not needed for spi mode, but need to be present. @@ -431,7 +431,6 @@ MODULE_DEVICE_TABLE(of, wlcore_spi_of_match_table); /** * wlcore_probe_of - DT node parsing. * @spi: SPI slave device parameters. - * @res: resource parameters. * @glue: wl12xx SPI bus to slave device glue parameters. * @pdev_data: wlcore device parameters */ From dff07dda8eb55b68e81629a01d8677b250fd2a66 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:24:07 +0000 Subject: [PATCH 071/180] rtw88: rtw8822c: Remove unused variable 'corr_val' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtw88/rtw8822c.c: In function ‘rtw8822c_dpk_dc_corr_check’: drivers/net/wireless/realtek/rtw88/rtw8822c.c:2445:5: warning: variable ‘corr_val’ set but not used [-Wunused-but-set-variable] Cc: Yan-Hsuan Chuang Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-39-lee.jones@linaro.org Link: https://lore.kernel.org/r/20201102112410.1049272-39-lee.jones@linaro.org --- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index 1e2f680f2b90..f58722a49ec6 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -2442,7 +2442,7 @@ static void rtw8822c_dpk_rxbb_dc_cal(struct rtw_dev *rtwdev, u8 path) static u8 rtw8822c_dpk_dc_corr_check(struct rtw_dev *rtwdev, u8 path) { u16 dc_i, dc_q; - u8 corr_val, corr_idx; + u8 corr_idx; rtw_write32(rtwdev, REG_RXSRAM_CTL, 0x000900f0); dc_i = (u16)rtw_read32_mask(rtwdev, REG_STAT_RPT, GENMASK(27, 16)); @@ -2455,7 +2455,7 @@ static u8 rtw8822c_dpk_dc_corr_check(struct rtw_dev *rtwdev, u8 path) rtw_write32(rtwdev, REG_RXSRAM_CTL, 0x000000f0); corr_idx = (u8)rtw_read32_mask(rtwdev, REG_STAT_RPT, GENMASK(7, 0)); - corr_val = (u8)rtw_read32_mask(rtwdev, REG_STAT_RPT, GENMASK(15, 8)); + rtw_read32_mask(rtwdev, REG_STAT_RPT, GENMASK(15, 8)); if (dc_i > 200 || dc_q > 200 || corr_idx < 40 || corr_idx > 65) return 1; From 230f874e4d955d7541c7ebf1e4e493a27f2094f7 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:32 +0000 Subject: [PATCH 072/180] rtlwifi: rtl8192cu: mac: Fix some missing/ill-documented function parameters Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c:124: warning: Function parameter or member 'hw' not described in 'rtl92c_llt_write' drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c:124: warning: Excess function parameter 'io' description in 'rtl92c_llt_write' drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c:155: warning: Function parameter or member 'hw' not described in 'rtl92c_init_llt_table' drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c:155: warning: Excess function parameter 'io' description in 'rtl92c_init_llt_table' Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-4-lee.jones@linaro.org --- drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c index 2890a495a23e..8d2c6d8d32d9 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/mac.c @@ -113,7 +113,7 @@ void rtl92c_read_chip_version(struct ieee80211_hw *hw) /** * writeLLT - LLT table write access - * @io: io callback + * @hw: Pointer to the ieee80211_hw structure. * @address: LLT logical address. * @data: LLT data content * @@ -145,11 +145,10 @@ bool rtl92c_llt_write(struct ieee80211_hw *hw, u32 address, u32 data) /** * rtl92c_init_LLT_table - Init LLT table - * @io: io callback - * @boundary: + * @hw: Pointer to the ieee80211_hw structure. + * @boundary: Page boundary. * * Realtek hardware access function. - * */ bool rtl92c_init_llt_table(struct ieee80211_hw *hw, u32 boundary) { From 906a1b4f81a32492e38aedf6d6ee91675e32d83f Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:34 +0000 Subject: [PATCH 073/180] rtlwifi: rtl8192cu: trx: Demote clear abuse of kernel-doc format Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:455: warning: Function parameter or member 'txdesc' not described in '_rtl_tx_desc_checksum' Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-6-lee.jones@linaro.org --- drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c index 1ad0cf37f60b..87f959d5d861 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c @@ -448,7 +448,7 @@ static void _rtl_fill_usb_tx_desc(__le32 *txdesc) set_tx_desc_first_seg(txdesc, 1); } -/** +/* * For HW recovery information */ static void _rtl_tx_desc_checksum(__le32 *txdesc) From bb053d0251a2c4a7418f0b2ff65472cf2dd17a95 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:54 +0000 Subject: [PATCH 074/180] rtlwifi: halbtc8723b2ant: Remove a bunch of set but unused variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_wifi_idle_process’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:1631:40: warning: variable ‘bt_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:1631:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_sco’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:2767:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_hid’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:2810:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_a2dp’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:2855:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_a2dp_pan_hs’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:2929:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_pan_edr’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:2976:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_pan_hs’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:3028:22: warning: variable ‘wifi_rssi_state1’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:3028:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_pan_edr_a2dp’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:3066:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_pan_edr_hid’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:3121:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_hid_a2dp_pan_edr’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:3185:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c: In function ‘btc8723b2ant_action_hid_a2dp’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:3244:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-26-lee.jones@linaro.org --- .../rtlwifi/btcoexist/halbtc8723b2ant.c | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c index fb57cc8b2e47..7a71f063015a 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c @@ -1628,17 +1628,17 @@ static void btc8723b2ant_action_wifi_link_process(struct btc_coexist static bool btc8723b2ant_action_wifi_idle_process(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv = btcoexist->adapter; - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state1; u8 ap_num = 0; u8 tmp = BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, tmp, 0); tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset - coex_dm->switch_thres_offset; - bt_rssi_state = btc8723b2ant_bt_rssi_state(btcoexist, 2, tmp, 0); + btc8723b2ant_bt_rssi_state(btcoexist, 2, tmp, 0); btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num); @@ -2764,10 +2764,10 @@ static void btc8723b2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, /* SCO only or SCO+PAN(HS) */ static void btc8723b2ant_action_sco(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, bt_rssi_state; + u8 bt_rssi_state; u32 wifi_bw; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); bt_rssi_state = btc8723b2ant_bt_rssi_state( btcoexist, 2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset, @@ -2807,12 +2807,12 @@ static void btc8723b2ant_action_sco(struct btc_coexist *btcoexist) static void btc8723b2ant_action_hid(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, bt_rssi_state; + u8 bt_rssi_state; u32 wifi_bw; u8 tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); bt_rssi_state = btc8723b2ant_bt_rssi_state(btcoexist, 2, tmp, 0); btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); @@ -2852,13 +2852,13 @@ static void btc8723b2ant_action_hid(struct btc_coexist *btcoexist) /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ static void btc8723b2ant_action_a2dp(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state1, bt_rssi_state; u32 wifi_bw; u8 ap_num = 0; u8 tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, 40, 0); bt_rssi_state = btc8723b2ant_bt_rssi_state(btcoexist, 2, tmp, 0); @@ -2926,12 +2926,12 @@ static void btc8723b2ant_action_a2dp(struct btc_coexist *btcoexist) static void btc8723b2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state1, bt_rssi_state; u32 wifi_bw; u8 tmp = BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, tmp, 0); tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - @@ -2973,12 +2973,12 @@ static void btc8723b2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) static void btc8723b2ant_action_pan_edr(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state1, bt_rssi_state; u32 wifi_bw; u8 tmp = BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, tmp, 0); tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - @@ -3025,13 +3025,13 @@ static void btc8723b2ant_action_pan_edr(struct btc_coexist *btcoexist) /* PAN(HS) only */ static void btc8723b2ant_action_pan_hs(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 bt_rssi_state; u32 wifi_bw; u8 tmp = BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); - wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, tmp, 0); tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; @@ -3063,12 +3063,12 @@ static void btc8723b2ant_action_pan_hs(struct btc_coexist *btcoexist) /* PAN(EDR) + A2DP */ static void btc8723b2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state1, bt_rssi_state; u32 wifi_bw; u8 tmp = BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, tmp, 0); tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - @@ -3118,12 +3118,12 @@ static void btc8723b2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) static void btc8723b2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state1, bt_rssi_state; u32 wifi_bw; u8 tmp = BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, tmp, 0); tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - @@ -3182,12 +3182,12 @@ static void btc8723b2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) /* HID + A2DP + PAN(EDR) */ static void btc8723b2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state1, bt_rssi_state; u32 wifi_bw; u8 tmp = BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, tmp, 0); tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - @@ -3241,13 +3241,13 @@ static void btc8723b2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) static void btc8723b2ant_action_hid_a2dp(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state1, bt_rssi_state; u32 wifi_bw; u8 ap_num = 0; u8 tmp = BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES - coex_dm->switch_thres_offset; - wifi_rssi_state = btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8723b2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); wifi_rssi_state1 = btc8723b2ant_wifi_rssi_state(btcoexist, 1, 2, tmp, 0); tmp = BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES - From 87b08d1ecb93b0625e31403bc2fd30572f7e9aba Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:55 +0000 Subject: [PATCH 075/180] rtlwifi: phy: Remove set but unused variable 'bbvalue' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c: In function ‘_rtl8723e_phy_iq_calibrate’: drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c:1150:6: warning: variable ‘bbvalue’ set but not used [-Wunused-but-set-variable] Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-27-lee.jones@linaro.org --- drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c index fa0eed434d4f..fe9b407dc2af 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c @@ -1147,10 +1147,8 @@ static void _rtl8723e_phy_iq_calibrate(struct ieee80211_hw *hw, const u32 retrycount = 2; - u32 bbvalue; - if (t == 0) { - bbvalue = rtl_get_bbreg(hw, 0x800, MASKDWORD); + rtl_get_bbreg(hw, 0x800, MASKDWORD); rtl8723_save_adda_registers(hw, adda_reg, rtlphy->adda_backup, 16); From 0c73dab72f53a75aaa6a315c7982123101581a51 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:56 +0000 Subject: [PATCH 076/180] rtlwifi: halbtc8821a1ant: Remove set but unused variable 'wifi_rssi_state' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c: In function ‘btc8821a1ant_run_coexist_mechanism’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c:1904:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-28-lee.jones@linaro.org --- .../net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c index 9f5e85be9764..a18dffc8753a 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c @@ -1901,7 +1901,6 @@ static void btc8821a1ant_run_coexist_mechanism(struct btc_coexist *btcoexist) bool increase_scan_dev_num = false; bool bt_ctrl_agg_buf_size = false; u8 agg_buf_size = 5; - u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_link_status = 0; u32 num_of_wifi_link = 0; bool wifi_under_5g = false; @@ -1962,8 +1961,7 @@ static void btc8821a1ant_run_coexist_mechanism(struct btc_coexist *btcoexist) btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); } else { if (wifi_connected) { - wifi_rssi_state = - btc8821a1ant_wifi_rssi_state(btcoexist, 1, 2, + btc8821a1ant_wifi_rssi_state(btcoexist, 1, 2, 30, 0); btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 1, 1, From 0a43d993ee7ecd2c512cb529f02103616e4551c6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:57 +0000 Subject: [PATCH 077/180] rtlwifi: rtl8723be: Remove set but unused variable 'lc_cal' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c: In function ‘_rtl8723be_phy_lc_calibrate’: drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c:2181:36: warning: variable ‘lc_cal’ set but not used [-Wunused-but-set-variable] Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-29-lee.jones@linaro.org --- drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c index f09f55b0468a..2b9313cb93db 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/phy.c @@ -2178,7 +2178,7 @@ static u8 _get_right_chnl_place_for_iqk(u8 chnl) static void _rtl8723be_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) { u8 tmpreg; - u32 rf_a_mode = 0, rf_b_mode = 0, lc_cal; + u32 rf_a_mode = 0, rf_b_mode = 0; struct rtl_priv *rtlpriv = rtl_priv(hw); tmpreg = rtl_read_byte(rtlpriv, 0xd03); @@ -2202,7 +2202,7 @@ static void _rtl8723be_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) rtl_set_rfreg(hw, RF90_PATH_B, 0x00, MASK12BITS, (rf_b_mode & 0x8FFFF) | 0x10000); } - lc_cal = rtl_get_rfreg(hw, RF90_PATH_A, 0x18, MASK12BITS); + rtl_get_rfreg(hw, RF90_PATH_A, 0x18, MASK12BITS); rtl_set_rfreg(hw, RF90_PATH_A, 0xb0, RFREG_OFFSET_MASK, 0xdfbe0); rtl_set_rfreg(hw, RF90_PATH_A, 0x18, MASK12BITS, 0x8c0a); From 6c75eab0417b9e5b05a18dbfc373e27a8ef876d8 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:58 +0000 Subject: [PATCH 078/180] rtlwifi: rtl8188ee: Remove set but unused variable 'reg_ea4' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c: In function ‘_rtl88e_phy_path_a_iqk’: drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c:1351:33: warning: variable ‘reg_ea4’ set but not used [-Wunused-but-set-variable] Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-30-lee.jones@linaro.org --- drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c index 9be032e8ec95..12d0b3a87af7 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c @@ -1348,7 +1348,7 @@ static bool _rtl88e_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, static u8 _rtl88e_phy_path_a_iqk(struct ieee80211_hw *hw, bool config_pathb) { - u32 reg_eac, reg_e94, reg_e9c, reg_ea4; + u32 reg_eac, reg_e94, reg_e9c; u8 result = 0x00; rtl_set_bbreg(hw, 0xe30, MASKDWORD, 0x10008c1c); @@ -1365,7 +1365,7 @@ static u8 _rtl88e_phy_path_a_iqk(struct ieee80211_hw *hw, bool config_pathb) reg_eac = rtl_get_bbreg(hw, 0xeac, MASKDWORD); reg_e94 = rtl_get_bbreg(hw, 0xe94, MASKDWORD); reg_e9c = rtl_get_bbreg(hw, 0xe9c, MASKDWORD); - reg_ea4 = rtl_get_bbreg(hw, 0xea4, MASKDWORD); + rtl_get_bbreg(hw, 0xea4, MASKDWORD); if (!(reg_eac & BIT(28)) && (((reg_e94 & 0x03FF0000) >> 16) != 0x142) && From 28f8118762624624770784c19cef99f633ccb13b Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:23:59 +0000 Subject: [PATCH 079/180] rtlwifi: halbtc8821a2ant: Remove a bunch of unused variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c: In function ‘btc8821a2ant_action_bt_inquiry’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:1451:40: warning: variable ‘bt_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:1451:22: warning: variable ‘wifi_rssi_state1’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:1451:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c: In function ‘btc8821a2ant_action_wifi_idle_process’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:1519:40: warning: variable ‘bt_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:1519:5: warning: variable ‘wifi_rssi_state’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c: In function ‘btc8821a2ant_action_pan_hs’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:2990:22: warning: variable ‘wifi_rssi_state1’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c: In function ‘btc8821a2ant_action_hid_a2dp’: drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:3277:22: warning: variable ‘wifi_rssi_state1’ set but not used [-Wunused-but-set-variable] Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-31-lee.jones@linaro.org --- .../rtlwifi/btcoexist/halbtc8821a2ant.c | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c index e53789f11b08..447caa4aad32 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c @@ -1448,17 +1448,15 @@ static void btc8821a2ant_init_coex_dm(struct btc_coexist *btcoexist) static void btc8821a2ant_action_bt_inquiry(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv = btcoexist->adapter; - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; bool wifi_connected = false; bool low_pwr_disable = true; bool scan = false, link = false, roam = false; - wifi_rssi_state = - btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); - wifi_rssi_state1 = btc8821a2ant_wifi_rssi_state(btcoexist, 1, 2, + btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8821a2ant_wifi_rssi_state(btcoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, - 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); + btc8821a2ant_bt_rssi_state(btcoexist, + 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &low_pwr_disable); @@ -1516,15 +1514,14 @@ static void btc8821a2ant_action_wifi_link_process(struct btc_coexist *btcoexist) static bool btc8821a2ant_action_wifi_idle_process(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv = btcoexist->adapter; - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state1; u8 ap_num = 0; - wifi_rssi_state = - btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); + btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); wifi_rssi_state1 = btc8821a2ant_wifi_rssi_state(btcoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES - 20, 0); - bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, - 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); + btc8821a2ant_bt_rssi_state(btcoexist, + 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num); @@ -2987,11 +2984,11 @@ static void btc8821a2ant_action_pan_edr(struct btc_coexist *btcoexist) /* PAN(HS) only */ static void btc8821a2ant_action_pan_hs(struct btc_coexist *btcoexist) { - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); - wifi_rssi_state1 = btc8821a2ant_wifi_rssi_state(btcoexist, 1, 2, + btc8821a2ant_wifi_rssi_state(btcoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); @@ -3274,11 +3271,11 @@ static void btc8821a2ant_act_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) static void btc8821a2ant_action_hid_a2dp(struct btc_coexist *btcoexist) { u32 wifi_bw; - u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u8 wifi_rssi_state, bt_rssi_state; u8 ap_num = 0; wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0); - wifi_rssi_state1 = btc8821a2ant_wifi_rssi_state(btcoexist, 1, 2, + btc8821a2ant_wifi_rssi_state(btcoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 3, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 37); From 44ec6d9df96ddd5b5b18a58c8bb9b45fe843bfb7 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:24:01 +0000 Subject: [PATCH 080/180] rtlwifi: rtl8723be: Remove set but unused variable 'cck_highpwr' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/rtl8723be/trx.c: In function ‘_rtl8723be_query_rxphystatus’: drivers/net/wireless/realtek/rtlwifi/rtl8723be/trx.c:53:6: warning: variable ‘cck_highpwr’ set but not used [-Wunused-but-set-variable] Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-33-lee.jones@linaro.org --- drivers/net/wireless/realtek/rtlwifi/rtl8723be/trx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/trx.c index 559ab78687c3..5a7cd270575a 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/trx.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/trx.c @@ -50,7 +50,6 @@ static void _rtl8723be_query_rxphystatus(struct ieee80211_hw *hw, pstatus->rx_mimo_signalquality[1] = -1; if (is_cck) { - u8 cck_highpwr; u8 cck_agc_rpt; cck_agc_rpt = p_phystrpt->cck_agc_rpt_ofdm_cfosho_a; @@ -59,8 +58,7 @@ static void _rtl8723be_query_rxphystatus(struct ieee80211_hw *hw, /* (2)PWDB, Average PWDB cacluated by * hardware (for rate adaptive) */ - cck_highpwr = (u8)rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, - BIT(9)); + rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, BIT(9)); lan_idx = ((cck_agc_rpt & 0xE0) >> 5); vga_idx = (cck_agc_rpt & 0x1f); From 29c6099a38903ee5db7581af0ef4a507eaab3aa9 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:24:02 +0000 Subject: [PATCH 081/180] rtlwifi: rtl8821ae: phy: Remove a couple of unused variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c: In function ‘rtl8821ae_phy_switch_wirelessband’: drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c:597:14: warning: variable ‘rxpath’ set but not used [-Wunused-but-set-variable] drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c:597:6: warning: variable ‘txpath’ set but not used [-Wunused-but-set-variable] Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-34-lee.jones@linaro.org --- drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c index 11e709813c8c..404a4eeaea98 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c @@ -594,11 +594,10 @@ void rtl8821ae_phy_switch_wirelessband(struct ieee80211_hw *hw, u8 band) struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); struct rtl_dm *rtldm = rtl_dm(rtlpriv); u8 current_band = rtlhal->current_bandtype; - u32 txpath, rxpath; s8 bb_diff_between_band; - txpath = rtl8821ae_phy_query_bb_reg(hw, RTXPATH, 0xf0); - rxpath = rtl8821ae_phy_query_bb_reg(hw, RCCK_RX, 0x0f000000); + rtl8821ae_phy_query_bb_reg(hw, RTXPATH, 0xf0); + rtl8821ae_phy_query_bb_reg(hw, RCCK_RX, 0x0f000000); rtlhal->current_bandtype = (enum band_type) band; /* reconfig BB/RF according to wireless mode */ if (rtlhal->current_bandtype == BAND_ON_2_4G) { From 398d816a64eb3614c7a7b58291292ce2c756b6a1 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 2 Nov 2020 11:24:03 +0000 Subject: [PATCH 082/180] rtlwifi: rtl8821ae: Place braces around empty if() body MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c: In function ‘_rtl8812ae_phy_get_txpower_limit’: drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c:2453:3: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201102112410.1049272-35-lee.jones@linaro.org --- drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c index 404a4eeaea98..f39c035b9e4b 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c @@ -2446,8 +2446,9 @@ static s8 _rtl8812ae_phy_get_txpower_limit(struct ieee80211_hw *hw, else if (band == BAND_ON_5G) channel_temp = _rtl8812ae_phy_get_chnl_idx_of_txpwr_lmt(hw, BAND_ON_5G, channel); - else if (band == BAND_ON_BOTH) + else if (band == BAND_ON_BOTH) { ;/* BAND_ON_BOTH don't care temporarily */ + } if (band_temp == -1 || regulation == -1 || bandwidth_temp == -1 || rate_section == -1 || channel_temp == -1) { From 9db946284e07bb27309dd546b7fee528664ba82a Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 28 Oct 2020 10:52:47 +0900 Subject: [PATCH 083/180] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free} There are missig brcmf_free() for brcmf_alloc(). Fix memory leak by adding missed brcmf_free(). Reported-by: Jaehoon Chung Fixes: a1f5aac1765a ("brcmfmac: don't realloc wiphy during PCIe reset") Signed-off-by: Seung-Woo Kim Reviewed-by: Arend van Spriel Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1603849967-22817-1-git-send-email-sw0312.kim@samsung.com --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 6 ++++-- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 1d3cc1c7c9c5..45bc502fcb34 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -1937,16 +1937,18 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) fwreq = brcmf_pcie_prepare_fw_request(devinfo); if (!fwreq) { ret = -ENOMEM; - goto fail_bus; + goto fail_brcmf; } ret = brcmf_fw_get_firmwares(bus->dev, fwreq, brcmf_pcie_setup); if (ret < 0) { kfree(fwreq); - goto fail_bus; + goto fail_brcmf; } return 0; +fail_brcmf: + brcmf_free(&devinfo->pdev->dev); fail_bus: kfree(bus->msgbuf); kfree(bus); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index e5b6033fab33..f58a96fa4eb5 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -4541,6 +4541,7 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus) brcmf_sdiod_intr_unregister(bus->sdiodev); brcmf_detach(bus->sdiodev->dev); + brcmf_free(bus->sdiodev->dev); cancel_work_sync(&bus->datawork); if (bus->brcmf_wq) From b96fab4e36023ee37ed1aad331ddd11b77c46c42 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sat, 7 Nov 2020 10:16:27 +0200 Subject: [PATCH 084/180] ath9k: work around false-positive gcc warning gcc-10 shows a false-positive warning with CONFIG_KASAN: drivers/net/wireless/ath/ath9k/dynack.c: In function 'ath_dynack_sample_tx_ts': include/linux/etherdevice.h:290:14: warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=] 290 | *(u32 *)dst = *(const u32 *)src; | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ Until gcc is fixed, work around this by using memcpy() in place of ether_addr_copy(). Hopefully gcc-11 will not have this problem. Link: https://godbolt.org/z/sab1MK Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490 Signed-off-by: Arnd Bergmann [kvalo@codeaurora.org: remove ifdef and add a comment] Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201026213040.3889546-8-arnd@kernel.org --- drivers/net/wireless/ath/ath9k/dynack.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c index 3219715174a2..321ff54fdb42 100644 --- a/drivers/net/wireless/ath/ath9k/dynack.c +++ b/drivers/net/wireless/ath/ath9k/dynack.c @@ -246,8 +246,12 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb, ridx = ts->ts_rateindex; da->st_rbf.ts[da->st_rbf.t_rb].tstamp = ts->ts_tstamp; - ether_addr_copy(da->st_rbf.addr[da->st_rbf.t_rb].h_dest, hdr->addr1); - ether_addr_copy(da->st_rbf.addr[da->st_rbf.t_rb].h_src, hdr->addr2); + + /* ether_addr_copy() gives a false warning on gcc-10 so use memcpy() + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490 + */ + memcpy(da->st_rbf.addr[da->st_rbf.t_rb].h_dest, hdr->addr1, ETH_ALEN); + memcpy(da->st_rbf.addr[da->st_rbf.t_rb].h_src, hdr->addr2, ETH_ALEN); if (!(info->status.rates[ridx].flags & IEEE80211_TX_RC_MCS)) { const struct ieee80211_rate *rate; From c134d1f8c436d96b3f62896c630278e3ec001280 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Sat, 7 Nov 2020 10:16:29 +0200 Subject: [PATCH 085/180] ath11k: Handle errors if peer creation fails ath11k_peer_create() is called without its return value being checked, meaning errors will be unhandled. Add missing check and, as the mutex is unconditionally unlocked on leaving this function, simplify the exit path. Addresses-Coverity-ID: 1497531 ("Code maintainability issues") Fixes: 701e48a43e15 ("ath11k: add packet log support for QCA6390") Signed-off-by: Alex Dewar Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201004100218.311653-1-alex.dewar90@gmail.com --- drivers/net/wireless/ath/ath11k/mac.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 591dcebcc5d1..f4aedd5aefaf 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -5275,20 +5275,26 @@ ath11k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw, arvif->vdev_type != WMI_VDEV_TYPE_AP && arvif->vdev_type != WMI_VDEV_TYPE_MONITOR) { memcpy(&arvif->chanctx, ctx, sizeof(*ctx)); - mutex_unlock(&ar->conf_mutex); - return 0; + ret = 0; + goto out; } if (WARN_ON(arvif->is_started)) { - mutex_unlock(&ar->conf_mutex); - return -EBUSY; + ret = -EBUSY; + goto out; } if (ab->hw_params.vdev_start_delay) { param.vdev_id = arvif->vdev_id; param.peer_type = WMI_PEER_TYPE_DEFAULT; param.peer_addr = ar->mac_addr; + ret = ath11k_peer_create(ar, arvif, NULL, ¶m); + if (ret) { + ath11k_warn(ab, "failed to create peer after vdev start delay: %d", + ret); + goto out; + } } ret = ath11k_mac_vdev_start(arvif, &ctx->def); @@ -5296,23 +5302,21 @@ ath11k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw, ath11k_warn(ab, "failed to start vdev %i addr %pM on freq %d: %d\n", arvif->vdev_id, vif->addr, ctx->def.chan->center_freq, ret); - goto err; + goto out; } if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { ret = ath11k_monitor_vdev_up(ar, arvif->vdev_id); if (ret) - goto err; + goto out; } arvif->is_started = true; /* TODO: Setup ps and cts/rts protection */ - mutex_unlock(&ar->conf_mutex); + ret = 0; - return 0; - -err: +out: mutex_unlock(&ar->conf_mutex); return ret; From fa74cb1dc0f4da46c441b735ca865ac52de42c0e Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto Date: Wed, 28 Oct 2020 23:21:09 +0900 Subject: [PATCH 086/180] mwifiex: fix mwifiex_shutdown_sw() causing sw reset failure When a PCIe function level reset (FLR) is performed but without fw reset for some reasons (e.g., on Microsoft Surface devices, fw reset requires other quirks), it fails to reset wifi properly. You can trigger the issue on such devices via debugfs entry for reset: $ echo 1 | sudo tee /sys/kernel/debug/mwifiex/mlan0/reset and the resulting dmesg log: [ 45.740508] mwifiex_pcie 0000:03:00.0: Resetting per request [ 45.742937] mwifiex_pcie 0000:03:00.0: info: successfully disconnected from [BSSID]: reason code 3 [ 45.744666] mwifiex_pcie 0000:03:00.0: info: shutdown mwifiex... [ 45.751530] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed [ 45.751539] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed [ 45.771691] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed [ 45.771695] mwifiex_pcie 0000:03:00.0: deleting the crypto keys [ 45.771697] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed [ 45.771698] mwifiex_pcie 0000:03:00.0: deleting the crypto keys [ 45.771699] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed [ 45.771701] mwifiex_pcie 0000:03:00.0: deleting the crypto keys [ 45.771702] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed [ 45.771703] mwifiex_pcie 0000:03:00.0: deleting the crypto keys [ 45.771704] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed [ 45.771705] mwifiex_pcie 0000:03:00.0: deleting the crypto keys [ 45.771707] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed [ 45.771708] mwifiex_pcie 0000:03:00.0: deleting the crypto keys [ 53.099343] mwifiex_pcie 0000:03:00.0: info: trying to associate to '[SSID]' bssid [BSSID] [ 53.241870] mwifiex_pcie 0000:03:00.0: info: associated to bssid [BSSID] successfully [ 75.377942] mwifiex_pcie 0000:03:00.0: cmd_wait_q terminated: -110 [ 85.385491] mwifiex_pcie 0000:03:00.0: info: successfully disconnected from [BSSID]: reason code 15 [ 87.539408] mwifiex_pcie 0000:03:00.0: cmd_wait_q terminated: -110 [ 87.539412] mwifiex_pcie 0000:03:00.0: deleting the crypto keys [ 99.699917] mwifiex_pcie 0000:03:00.0: cmd_wait_q terminated: -110 [ 99.699925] mwifiex_pcie 0000:03:00.0: deleting the crypto keys [ 111.859802] mwifiex_pcie 0000:03:00.0: cmd_wait_q terminated: -110 [ 111.859808] mwifiex_pcie 0000:03:00.0: deleting the crypto keys [...] When comparing mwifiex_shutdown_sw() with mwifiex_pcie_remove(), it lacks mwifiex_init_shutdown_fw(). This commit fixes mwifiex_shutdown_sw() by adding the missing mwifiex_init_shutdown_fw(). Fixes: 4c5dae59d2e9 ("mwifiex: add PCIe function level reset support") Signed-off-by: Tsuchiya Yuto Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201028142110.18144-2-kitakar@gmail.com --- drivers/net/wireless/marvell/mwifiex/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index 9ba8a8f64976..6283df5aaaf8 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -1471,6 +1471,8 @@ int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); mwifiex_deauthenticate(priv, NULL); + mwifiex_init_shutdown_fw(priv, MWIFIEX_FUNC_SHUTDOWN); + mwifiex_uninit_sw(adapter); adapter->is_up = false; From 566b4cb9587eb6dae2294989b5f1c35c0694dd15 Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto Date: Wed, 28 Oct 2020 23:21:10 +0900 Subject: [PATCH 087/180] mwifiex: update comment for shutdown_sw()/reinit_sw() to reflect current state The functions mwifiex_shutdown_sw() and mwifiex_reinit_sw() can be used for more general purposes than the PCIe function level reset. Also, these are even not PCIe-specific. So, let's update the comments at the top of each function accordingly. Signed-off-by: Tsuchiya Yuto Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201028142110.18144-3-kitakar@gmail.com --- drivers/net/wireless/marvell/mwifiex/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index 6283df5aaaf8..ee52fb839ef7 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -1455,7 +1455,7 @@ static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter) } /* - * This function gets called during PCIe function level reset. + * This function can be used for shutting down the adapter SW. */ int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) { @@ -1483,7 +1483,7 @@ int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) } EXPORT_SYMBOL_GPL(mwifiex_shutdown_sw); -/* This function gets called during PCIe function level reset. Required +/* This function can be used for reinitting the adapter SW. Required * code is extracted from mwifiex_add_card() */ int From 4add4d988f95f47493500a7a19c623827061589b Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto Date: Wed, 28 Oct 2020 23:23:46 +0900 Subject: [PATCH 088/180] mwifiex: pcie: skip cancel_work_sync() on reset failure path If a reset is performed, but even the reset fails for some reasons (e.g., on Surface devices, the fw reset requires another quirks), cancel_work_sync() hangs in mwifiex_cleanup_pcie(). # firmware went into a bad state [...] [ 1608.281690] mwifiex_pcie 0000:03:00.0: info: shutdown mwifiex... [ 1608.282724] mwifiex_pcie 0000:03:00.0: rx_pending=0, tx_pending=1, cmd_pending=0 [ 1608.292400] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed [ 1608.292405] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed # reset performed after firmware went into a bad state [ 1609.394320] mwifiex_pcie 0000:03:00.0: WLAN FW already running! Skip FW dnld [ 1609.394335] mwifiex_pcie 0000:03:00.0: WLAN FW is active # but even the reset failed [ 1619.499049] mwifiex_pcie 0000:03:00.0: mwifiex_cmd_timeout_func: Timeout cmd id = 0xfa, act = 0xe000 [ 1619.499094] mwifiex_pcie 0000:03:00.0: num_data_h2c_failure = 0 [ 1619.499103] mwifiex_pcie 0000:03:00.0: num_cmd_h2c_failure = 0 [ 1619.499110] mwifiex_pcie 0000:03:00.0: is_cmd_timedout = 1 [ 1619.499117] mwifiex_pcie 0000:03:00.0: num_tx_timeout = 0 [ 1619.499124] mwifiex_pcie 0000:03:00.0: last_cmd_index = 0 [ 1619.499133] mwifiex_pcie 0000:03:00.0: last_cmd_id: fa 00 07 01 07 01 07 01 07 01 [ 1619.499140] mwifiex_pcie 0000:03:00.0: last_cmd_act: 00 e0 00 00 00 00 00 00 00 00 [ 1619.499147] mwifiex_pcie 0000:03:00.0: last_cmd_resp_index = 3 [ 1619.499155] mwifiex_pcie 0000:03:00.0: last_cmd_resp_id: 07 81 07 81 07 81 07 81 07 81 [ 1619.499162] mwifiex_pcie 0000:03:00.0: last_event_index = 2 [ 1619.499169] mwifiex_pcie 0000:03:00.0: last_event: 58 00 58 00 58 00 58 00 58 00 [ 1619.499177] mwifiex_pcie 0000:03:00.0: data_sent=0 cmd_sent=1 [ 1619.499185] mwifiex_pcie 0000:03:00.0: ps_mode=0 ps_state=0 [ 1619.499215] mwifiex_pcie 0000:03:00.0: info: _mwifiex_fw_dpc: unregister device # mwifiex_pcie_work hang happening [ 1823.233923] INFO: task kworker/3:1:44 blocked for more than 122 seconds. [ 1823.233932] Tainted: G WC OE 5.10.0-rc1-1-mainline #1 [ 1823.233935] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 1823.233940] task:kworker/3:1 state:D stack: 0 pid: 44 ppid: 2 flags:0x00004000 [ 1823.233960] Workqueue: events mwifiex_pcie_work [mwifiex_pcie] [ 1823.233965] Call Trace: [ 1823.233981] __schedule+0x292/0x820 [ 1823.233990] schedule+0x45/0xe0 [ 1823.233995] schedule_timeout+0x11c/0x160 [ 1823.234003] wait_for_completion+0x9e/0x100 [ 1823.234012] __flush_work.isra.0+0x156/0x210 [ 1823.234018] ? flush_workqueue_prep_pwqs+0x130/0x130 [ 1823.234026] __cancel_work_timer+0x11e/0x1a0 [ 1823.234035] mwifiex_cleanup_pcie+0x28/0xd0 [mwifiex_pcie] [ 1823.234049] mwifiex_free_adapter+0x24/0xe0 [mwifiex] [ 1823.234060] _mwifiex_fw_dpc+0x294/0x560 [mwifiex] [ 1823.234074] mwifiex_reinit_sw+0x15d/0x300 [mwifiex] [ 1823.234080] mwifiex_pcie_reset_done+0x50/0x80 [mwifiex_pcie] [ 1823.234087] pci_try_reset_function+0x5c/0x90 [ 1823.234094] process_one_work+0x1d6/0x3a0 [ 1823.234100] worker_thread+0x4d/0x3d0 [ 1823.234107] ? rescuer_thread+0x410/0x410 [ 1823.234112] kthread+0x142/0x160 [ 1823.234117] ? __kthread_bind_mask+0x60/0x60 [ 1823.234124] ret_from_fork+0x22/0x30 [...] This is a deadlock caused by calling cancel_work_sync() in mwifiex_cleanup_pcie(): - Device resets are done via mwifiex_pcie_card_reset() - which schedules card->work to call mwifiex_pcie_card_reset_work() - which calls pci_try_reset_function(). - This leads to mwifiex_pcie_reset_done() be called on the same workqueue, which in turn calls - mwifiex_reinit_sw() and that calls - _mwifiex_fw_dpc(). The problem is now that _mwifiex_fw_dpc() calls mwifiex_free_adapter() in case firmware initialization fails. That ends up calling mwifiex_cleanup_pcie(). Note that all those calls are still running on the workqueue. So when mwifiex_cleanup_pcie() now calls cancel_work_sync(), it's really waiting on itself to complete, causing a deadlock. This commit fixes the deadlock by skipping cancel_work_sync() on a reset failure path. After this commit, when reset fails, the following output is expected to be shown: kernel: mwifiex_pcie 0000:03:00.0: info: _mwifiex_fw_dpc: unregister device kernel: mwifiex: Failed to bring up adapter: -5 kernel: mwifiex_pcie 0000:03:00.0: reinit failed: -5 To reproduce this issue, for example, try putting the root port of wifi into D3 (replace "00:1d.3" with your setup). # put into D3 (root port) sudo setpci -v -s 00:1d.3 CAP_PM+4.b=0b Cc: Maximilian Luz Signed-off-by: Tsuchiya Yuto Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201028142346.18355-1-kitakar@gmail.com --- drivers/net/wireless/marvell/mwifiex/pcie.c | 18 +++++++++++++++++- drivers/net/wireless/marvell/mwifiex/pcie.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 67e0247ebaa6..5f0a61b974ee 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -525,6 +525,8 @@ static void mwifiex_pcie_reset_prepare(struct pci_dev *pdev) clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags); clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags); mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); + + card->pci_reset_ongoing = true; } /* @@ -553,6 +555,8 @@ static void mwifiex_pcie_reset_done(struct pci_dev *pdev) dev_err(&pdev->dev, "reinit failed: %d\n", ret); else mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); + + card->pci_reset_ongoing = false; } static const struct pci_error_handlers mwifiex_pcie_err_handler = { @@ -3140,7 +3144,19 @@ static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter) const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; u32 fw_status; - cancel_work_sync(&card->work); + /* Perform the cancel_work_sync() only when we're not resetting + * the card. It's because that function never returns if we're + * in reset path. If we're here when resetting the card, it means + * that we failed to reset the card (reset failure path). + */ + if (!card->pci_reset_ongoing) { + mwifiex_dbg(adapter, MSG, "performing cancel_work_sync()...\n"); + cancel_work_sync(&card->work); + mwifiex_dbg(adapter, MSG, "cancel_work_sync() done\n"); + } else { + mwifiex_dbg(adapter, MSG, + "skipped cancel_work_sync() because we're in card reset failure path\n"); + } mwifiex_read_reg(adapter, reg->fw_status, &fw_status); if (fw_status == FIRMWARE_READY_PCIE) { diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.h b/drivers/net/wireless/marvell/mwifiex/pcie.h index 843d57eda820..5ed613d65709 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.h +++ b/drivers/net/wireless/marvell/mwifiex/pcie.h @@ -242,6 +242,8 @@ struct pcie_service_card { struct mwifiex_msix_context share_irq_ctx; struct work_struct work; unsigned long work_flags; + + bool pci_reset_ongoing; }; static inline int From 287431463e786766e05e4dc26d0a11d5f8ac8815 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Tue, 3 Nov 2020 19:09:40 +0100 Subject: [PATCH 089/180] rsi: Move card interrupt handling to RX thread The interrupt handling of the RS911x is particularly heavy. For each RX packet, the card does three SDIO transactions, one to read interrupt status register, one to RX buffer length, one to read the RX packet(s). This translates to ~330 uS per one cycle of interrupt handler. In case there is more incoming traffic, this will be more. The drivers/mmc/core/sdio_irq.c has the following comment, quote "Just like traditional hard IRQ handlers, we expect SDIO IRQ handlers to be quick and to the point, so that the holding of the host lock does not cover too much work that doesn't require that lock to be held." The RS911x interrupt handler does not fit that. This patch therefore changes it such that the entire IRQ handler is moved to the RX thread instead, and the interrupt handler only wakes the RX thread. This is OK, because the interrupt handler only does things which can also be done in the RX thread, that is, it checks for firmware loading error(s), it checks buffer status, it checks whether a packet arrived and if so, reads out the packet and passes it to network stack. Moreover, this change permits removal of a code which allocated an skbuff only to get 4-byte-aligned buffer, read up to 8kiB of data into the skbuff, queue this skbuff into local private queue, then in RX thread, this buffer is dequeued, the data in the skbuff as passed to the RSI driver core, and the skbuff is deallocated. All this is replaced by directly calling the RSI driver core with local buffer. Signed-off-by: Marek Vasut Cc: Angus Ainslie Cc: David S. Miller Cc: Jakub Kicinski Cc: Kalle Valo Cc: Lee Jones Cc: Martin Kepplinger Cc: Sebastian Krzyszkowiak Cc: Siva Rebbagondla Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Tested-by: Martin Kepplinger Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201103180941.443528-1-marex@denx.de --- drivers/net/wireless/rsi/rsi_91x_sdio.c | 6 +-- drivers/net/wireless/rsi/rsi_91x_sdio_ops.c | 52 ++++++--------------- drivers/net/wireless/rsi/rsi_sdio.h | 8 +--- 3 files changed, 15 insertions(+), 51 deletions(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c index a7b8684143f4..592e9dadcb55 100644 --- a/drivers/net/wireless/rsi/rsi_91x_sdio.c +++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c @@ -153,9 +153,7 @@ static void rsi_handle_interrupt(struct sdio_func *function) if (adapter->priv->fsm_state == FSM_FW_NOT_LOADED) return; - dev->sdio_irq_task = current; - rsi_interrupt_handler(adapter); - dev->sdio_irq_task = NULL; + rsi_set_event(&dev->rx_thread.event); } /** @@ -1058,8 +1056,6 @@ static int rsi_probe(struct sdio_func *pfunction, rsi_dbg(ERR_ZONE, "%s: Unable to init rx thrd\n", __func__); goto fail_kill_thread; } - skb_queue_head_init(&sdev->rx_q.head); - sdev->rx_q.num_rx_pkts = 0; sdio_claim_host(pfunction); if (sdio_claim_irq(pfunction, rsi_handle_interrupt)) { diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c index 7825c9a889d3..23e709aabd1f 100644 --- a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c +++ b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c @@ -60,39 +60,20 @@ int rsi_sdio_master_access_msword(struct rsi_hw *adapter, u16 ms_word) return status; } +static void rsi_rx_handler(struct rsi_hw *adapter); + void rsi_sdio_rx_thread(struct rsi_common *common) { struct rsi_hw *adapter = common->priv; struct rsi_91x_sdiodev *sdev = adapter->rsi_dev; - struct sk_buff *skb; - int status; do { rsi_wait_event(&sdev->rx_thread.event, EVENT_WAIT_FOREVER); rsi_reset_event(&sdev->rx_thread.event); + rsi_rx_handler(adapter); + } while (!atomic_read(&sdev->rx_thread.thread_done)); - while (true) { - if (atomic_read(&sdev->rx_thread.thread_done)) - goto out; - - skb = skb_dequeue(&sdev->rx_q.head); - if (!skb) - break; - if (sdev->rx_q.num_rx_pkts > 0) - sdev->rx_q.num_rx_pkts--; - status = rsi_read_pkt(common, skb->data, skb->len); - if (status) { - rsi_dbg(ERR_ZONE, "Failed to read the packet\n"); - dev_kfree_skb(skb); - break; - } - dev_kfree_skb(skb); - } - } while (1); - -out: rsi_dbg(INFO_ZONE, "%s: Terminated SDIO RX thread\n", __func__); - skb_queue_purge(&sdev->rx_q.head); atomic_inc(&sdev->rx_thread.thread_done); complete_and_exit(&sdev->rx_thread.completion, 0); } @@ -113,10 +94,6 @@ static int rsi_process_pkt(struct rsi_common *common) u32 rcv_pkt_len = 0; int status = 0; u8 value = 0; - struct sk_buff *skb; - - if (dev->rx_q.num_rx_pkts >= RSI_MAX_RX_PKTS) - return 0; num_blks = ((adapter->interrupt_status & 1) | ((adapter->interrupt_status >> RECV_NUM_BLOCKS) << 1)); @@ -144,22 +121,19 @@ static int rsi_process_pkt(struct rsi_common *common) rcv_pkt_len = (num_blks * 256); - skb = dev_alloc_skb(rcv_pkt_len); - if (!skb) - return -ENOMEM; - - status = rsi_sdio_host_intf_read_pkt(adapter, skb->data, rcv_pkt_len); + status = rsi_sdio_host_intf_read_pkt(adapter, dev->pktbuffer, + rcv_pkt_len); if (status) { rsi_dbg(ERR_ZONE, "%s: Failed to read packet from card\n", __func__); - dev_kfree_skb(skb); return status; } - skb_put(skb, rcv_pkt_len); - skb_queue_tail(&dev->rx_q.head, skb); - dev->rx_q.num_rx_pkts++; - rsi_set_event(&dev->rx_thread.event); + status = rsi_read_pkt(common, dev->pktbuffer, rcv_pkt_len); + if (status) { + rsi_dbg(ERR_ZONE, "Failed to read the packet\n"); + return status; + } return 0; } @@ -251,12 +225,12 @@ int rsi_init_sdio_slave_regs(struct rsi_hw *adapter) } /** - * rsi_interrupt_handler() - This function read and process SDIO interrupts. + * rsi_rx_handler() - Read and process SDIO interrupts. * @adapter: Pointer to the adapter structure. * * Return: None. */ -void rsi_interrupt_handler(struct rsi_hw *adapter) +static void rsi_rx_handler(struct rsi_hw *adapter) { struct rsi_common *common = adapter->priv; struct rsi_91x_sdiodev *dev = diff --git a/drivers/net/wireless/rsi/rsi_sdio.h b/drivers/net/wireless/rsi/rsi_sdio.h index 9afc1d0d2684..1c756263cf15 100644 --- a/drivers/net/wireless/rsi/rsi_sdio.h +++ b/drivers/net/wireless/rsi/rsi_sdio.h @@ -107,11 +107,6 @@ struct receive_info { u32 buf_available_counter; }; -struct rsi_sdio_rx_q { - u8 num_rx_pkts; - struct sk_buff_head head; -}; - struct rsi_91x_sdiodev { struct sdio_func *pfunction; struct task_struct *sdio_irq_task; @@ -124,11 +119,10 @@ struct rsi_91x_sdiodev { u16 tx_blk_size; u8 write_fail; bool buff_status_updated; - struct rsi_sdio_rx_q rx_q; struct rsi_thread rx_thread; + u8 pktbuffer[8192] __aligned(4); }; -void rsi_interrupt_handler(struct rsi_hw *adapter); int rsi_init_sdio_slave_regs(struct rsi_hw *adapter); int rsi_sdio_read_register(struct rsi_hw *adapter, u32 addr, u8 *data); int rsi_sdio_host_intf_read_pkt(struct rsi_hw *adapter, u8 *pkt, u32 length); From abd131a19f6b862dac3eacba153e472ffc96b8f7 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Tue, 3 Nov 2020 19:09:41 +0100 Subject: [PATCH 090/180] rsi: Clean up loop in the interrupt handler The inner do { ... } while loop is completely useless, all it does is iterate over a switch-case statement, one bit at a time. This can easily be replaced by simple if (status & bit) { ... } tests for each bit. No functional change. Signed-off-by: Marek Vasut Cc: Angus Ainslie Cc: David S. Miller Cc: Jakub Kicinski Cc: Kalle Valo Cc: Lee Jones Cc: Martin Kepplinger Cc: Sebastian Krzyszkowiak Cc: Siva Rebbagondla Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201103180941.443528-2-marex@denx.de --- drivers/net/wireless/rsi/rsi_91x_sdio_ops.c | 121 ++++++++++---------- 1 file changed, 58 insertions(+), 63 deletions(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c index 23e709aabd1f..8ace1874e5cb 100644 --- a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c +++ b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c @@ -236,7 +236,6 @@ static void rsi_rx_handler(struct rsi_hw *adapter) struct rsi_91x_sdiodev *dev = (struct rsi_91x_sdiodev *)adapter->rsi_dev; int status; - enum sdio_interrupt_type isr_type; u8 isr_status = 0; u8 fw_status = 0; @@ -267,73 +266,69 @@ static void rsi_rx_handler(struct rsi_hw *adapter) __func__, isr_status, (1 << MSDU_PKT_PENDING), (1 << FW_ASSERT_IND)); - do { - RSI_GET_SDIO_INTERRUPT_TYPE(isr_status, isr_type); - - switch (isr_type) { - case BUFFER_AVAILABLE: - status = rsi_sdio_check_buffer_status(adapter, - 0); - if (status < 0) - rsi_dbg(ERR_ZONE, - "%s: Failed to check buffer status\n", - __func__); - rsi_sdio_ack_intr(common->priv, - (1 << PKT_BUFF_AVAILABLE)); - rsi_set_event(&common->tx_thread.event); - - rsi_dbg(ISR_ZONE, - "%s: ==> BUFFER_AVAILABLE <==\n", - __func__); - dev->buff_status_updated = true; - break; - - case FIRMWARE_ASSERT_IND: + if (isr_status & BIT(PKT_BUFF_AVAILABLE)) { + status = rsi_sdio_check_buffer_status(adapter, 0); + if (status < 0) rsi_dbg(ERR_ZONE, - "%s: ==> FIRMWARE Assert <==\n", + "%s: Failed to check buffer status\n", __func__); - status = rsi_sdio_read_register(common->priv, + rsi_sdio_ack_intr(common->priv, + BIT(PKT_BUFF_AVAILABLE)); + rsi_set_event(&common->tx_thread.event); + + rsi_dbg(ISR_ZONE, "%s: ==> BUFFER_AVAILABLE <==\n", + __func__); + dev->buff_status_updated = true; + + isr_status &= ~BIT(PKT_BUFF_AVAILABLE); + } + + if (isr_status & BIT(FW_ASSERT_IND)) { + rsi_dbg(ERR_ZONE, "%s: ==> FIRMWARE Assert <==\n", + __func__); + status = rsi_sdio_read_register(common->priv, SDIO_FW_STATUS_REG, &fw_status); - if (status) { - rsi_dbg(ERR_ZONE, - "%s: Failed to read f/w reg\n", - __func__); - } else { - rsi_dbg(ERR_ZONE, - "%s: Firmware Status is 0x%x\n", - __func__ , fw_status); - rsi_sdio_ack_intr(common->priv, - (1 << FW_ASSERT_IND)); - } - - common->fsm_state = FSM_CARD_NOT_READY; - break; - - case MSDU_PACKET_PENDING: - rsi_dbg(ISR_ZONE, "Pkt pending interrupt\n"); - dev->rx_info.total_sdio_msdu_pending_intr++; - - status = rsi_process_pkt(common); - if (status) { - rsi_dbg(ERR_ZONE, - "%s: Failed to read pkt\n", - __func__); - mutex_unlock(&common->rx_lock); - return; - } - break; - default: - rsi_sdio_ack_intr(common->priv, isr_status); - dev->rx_info.total_sdio_unknown_intr++; - isr_status = 0; - rsi_dbg(ISR_ZONE, - "Unknown Interrupt %x\n", - isr_status); - break; + if (status) { + rsi_dbg(ERR_ZONE, + "%s: Failed to read f/w reg\n", + __func__); + } else { + rsi_dbg(ERR_ZONE, + "%s: Firmware Status is 0x%x\n", + __func__, fw_status); + rsi_sdio_ack_intr(common->priv, + BIT(FW_ASSERT_IND)); } - isr_status ^= BIT(isr_type - 1); - } while (isr_status); + + common->fsm_state = FSM_CARD_NOT_READY; + + isr_status &= ~BIT(FW_ASSERT_IND); + } + + if (isr_status & BIT(MSDU_PKT_PENDING)) { + rsi_dbg(ISR_ZONE, "Pkt pending interrupt\n"); + dev->rx_info.total_sdio_msdu_pending_intr++; + + status = rsi_process_pkt(common); + if (status) { + rsi_dbg(ERR_ZONE, "%s: Failed to read pkt\n", + __func__); + mutex_unlock(&common->rx_lock); + return; + } + + isr_status &= ~BIT(MSDU_PKT_PENDING); + } + + if (isr_status) { + rsi_sdio_ack_intr(common->priv, isr_status); + dev->rx_info.total_sdio_unknown_intr++; + isr_status = 0; + rsi_dbg(ISR_ZONE, "Unknown Interrupt %x\n", + isr_status); + } + mutex_unlock(&common->rx_lock); } while (1); } From dd90fc4630d285db429e393522d7b3844fbf79e9 Mon Sep 17 00:00:00 2001 From: Wang Qing Date: Sat, 7 Nov 2020 16:40:37 +0800 Subject: [PATCH 091/180] rtlwifi: fix spelling typo of workaround workarould -> workaround Signed-off-by: Wang Qing Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604738439-24794-1-git-send-email-wangqing@vivo.com --- drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c index f39c035b9e4b..372d6f8caf06 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c @@ -62,7 +62,7 @@ static void rtl8812ae_fixspur(struct ieee80211_hw *hw, rtl_set_bbreg(hw, RRFMOD, 0xC00, 0x2); /* 0x8AC[11:10] = 2'b10*/ - /* <20120914, Kordan> A workarould to resolve + /* <20120914, Kordan> A workaround to resolve * 2480Mhz spur by setting ADC clock as 160M. (Asked by Binson) */ if (band_width == HT_CHANNEL_WIDTH_20 && @@ -82,7 +82,7 @@ static void rtl8812ae_fixspur(struct ieee80211_hw *hw, /*0x8C4[30] = 0*/ } } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) { - /* <20120914, Kordan> A workarould to resolve + /* <20120914, Kordan> A workaround to resolve * 2480Mhz spur by setting ADC clock as 160M. */ if (band_width == HT_CHANNEL_WIDTH_20 && From 3f3fef5f6a8ff96f1bd7fc65a76fbe4ccc87b14a Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:58:59 +0800 Subject: [PATCH 092/180] rtw88: coex: fixed some wrong register definition and setting Some register definition and bit definition were incorrect. e.g. REG_BT_COEX_V2 should be word alignment to meet the coding style. e.g. set REG_BT_TDMA_TIME[5:0]=0x5, But the original is to set REG_BT_TDMA_TIME[7:0]=0x5. This will cause unexpected hardware behavior. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-2-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/reg.h | 7 ++++--- drivers/net/wireless/realtek/rtw88/rtw8723d.c | 4 ++-- drivers/net/wireless/realtek/rtw88/rtw8821c.c | 3 +-- drivers/net/wireless/realtek/rtw88/rtw8821c.h | 2 -- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 6 +++--- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 10 +++++----- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h index 86b94c008a27..b3df09ff01b3 100644 --- a/drivers/net/wireless/realtek/rtw88/reg.h +++ b/drivers/net/wireless/realtek/rtw88/reg.h @@ -60,7 +60,7 @@ #define REG_GPIO_MUXCFG 0x0040 #define BIT_FSPI_EN BIT(19) #define BIT_EN_SIC BIT(12) -#define BIT_BT_AOD_GPIO3 BIT(9) + #define BIT_PO_BT_PTA_PINS BIT(9) #define BIT_BT_PTA_EN BIT(5) #define BIT_WLRFE_4_5_EN BIT(2) @@ -463,11 +463,12 @@ #define REG_BT_COEX_TABLE_H3 0x06CF #define REG_BBPSF_CTRL 0x06DC -#define REG_BT_COEX_V2 0x0763 -#define BIT_GNT_BT_POLARITY BIT(4) +#define REG_BT_COEX_V2 0x0762 +#define BIT_GNT_BT_POLARITY BIT(12) #define BIT_LTE_COEX_EN BIT(7) #define REG_BT_STAT_CTRL 0x0778 #define REG_BT_TDMA_TIME 0x0790 +#define BIT_MASK_SAMPLE_RATE GENMASK(5, 0) #define REG_LTR_IDLE_LATENCY 0x0798 #define REG_LTR_ACTIVE_LATENCY 0x079C #define REG_LTR_CTRL_BASIC 0x07A4 diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c b/drivers/net/wireless/realtek/rtw88/rtw8723d.c index 832dc8e98bee..84d66b5c2733 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c @@ -1506,14 +1506,14 @@ static void rtw8723d_coex_cfg_init(struct rtw_dev *rtwdev) /* BT report packet sample rate */ /* 0x790[5:0]=0x5 */ - rtw_write8_set(rtwdev, REG_BT_TDMA_TIME, 0x05); + rtw_write8_mask(rtwdev, REG_BT_TDMA_TIME, BIT_MASK_SAMPLE_RATE, 0x5); /* enable BT counter statistics */ rtw_write8(rtwdev, REG_BT_STAT_CTRL, 0x1); /* enable PTA (3-wire function form BT side) */ rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_PTA_EN); - rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_AOD_GPIO3); + rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_PO_BT_PTA_PINS); /* enable PTA (tx/rx signal form WiFi side) */ rtw_write8_set(rtwdev, REG_QUEUE_CTRL, BIT_PTA_WL_TX_EN); diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c index da2e7415be8f..64b14f9ea4a9 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c @@ -656,8 +656,7 @@ static void rtw8821c_coex_cfg_init(struct rtw_dev *rtwdev) rtw_write8_set(rtwdev, REG_BCN_CTRL, BIT_EN_BCN_FUNCTION); /* BT report packet sample rate */ - rtw_write8_mask(rtwdev, REG_BT_TDMA_TIME, SAMPLE_RATE_MASK, - SAMPLE_RATE); + rtw_write8_mask(rtwdev, REG_BT_TDMA_TIME, BIT_MASK_SAMPLE_RATE, 0x5); /* enable BT counter statistics */ rtw_write8(rtwdev, REG_BT_STAT_CTRL, BT_CNT_ENABLE); diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.h b/drivers/net/wireless/realtek/rtw88/rtw8821c.h index bd01e82b6bcd..e11e3fc41c95 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.h @@ -231,8 +231,6 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data) #define REG_IQKFAILMSK 0x1bf0 #define BIT_MASK_R_RFE_SEL_15 GENMASK(31, 28) #define BIT_SDIO_INT BIT(18) -#define SAMPLE_RATE_MASK GENMASK(5, 0) -#define SAMPLE_RATE 0x5 #define BT_CNT_ENABLE 0x1 #define BIT_BCN_QUEUE BIT(3) #define BCN_PRI_EN 0x1 diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index ffcb580e8dce..d562f7324e6a 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -1120,21 +1120,21 @@ static void rtw8822b_coex_cfg_init(struct rtw_dev *rtwdev) /* BT report packet sample rate */ /* 0x790[5:0]=0x5 */ - rtw_write8_set(rtwdev, REG_BT_TDMA_TIME, 0x05); + rtw_write8_mask(rtwdev, REG_BT_TDMA_TIME, BIT_MASK_SAMPLE_RATE, 0x5); /* enable BT counter statistics */ rtw_write8(rtwdev, REG_BT_STAT_CTRL, 0x1); /* enable PTA (3-wire function form BT side) */ rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_PTA_EN); - rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_AOD_GPIO3); + rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_PO_BT_PTA_PINS); /* enable PTA (tx/rx signal form WiFi side) */ rtw_write8_set(rtwdev, REG_QUEUE_CTRL, BIT_PTA_WL_TX_EN); /* wl tx signal to PTA not case EDCCA */ rtw_write8_clr(rtwdev, REG_QUEUE_CTRL, BIT_PTA_EDCCA_EN); /* GNT_BT=1 while select both */ - rtw_write8_set(rtwdev, REG_BT_COEX_V2, BIT_GNT_BT_POLARITY); + rtw_write16_set(rtwdev, REG_BT_COEX_V2, BIT_GNT_BT_POLARITY); } static void rtw8822b_coex_cfg_ant_switch(struct rtw_dev *rtwdev, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index f58722a49ec6..56c403d628fd 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -2132,24 +2132,24 @@ static void rtw8822c_coex_cfg_init(struct rtw_dev *rtwdev) /* enable TBTT nterrupt */ rtw_write8_set(rtwdev, REG_BCN_CTRL, BIT_EN_BCN_FUNCTION); - /* BT report packet sample rate */ + /* BT report packet sample rate */ /* 0x790[5:0]=0x5 */ - rtw_write8_set(rtwdev, REG_BT_TDMA_TIME, 0x05); + rtw_write8_mask(rtwdev, REG_BT_TDMA_TIME, BIT_MASK_SAMPLE_RATE, 0x5); /* enable BT counter statistics */ rtw_write8(rtwdev, REG_BT_STAT_CTRL, 0x1); /* enable PTA (3-wire function form BT side) */ rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_PTA_EN); - rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_AOD_GPIO3); + rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_PO_BT_PTA_PINS); /* enable PTA (tx/rx signal form WiFi side) */ rtw_write8_set(rtwdev, REG_QUEUE_CTRL, BIT_PTA_WL_TX_EN); /* wl tx signal to PTA not case EDCCA */ rtw_write8_clr(rtwdev, REG_QUEUE_CTRL, BIT_PTA_EDCCA_EN); /* GNT_BT=1 while select both */ - rtw_write8_set(rtwdev, REG_BT_COEX_V2, BIT_GNT_BT_POLARITY); - /* BT_CCA = ~GNT_WL_BB, (not or GNT_BT_BB, LTE_Rx */ + rtw_write16_set(rtwdev, REG_BT_COEX_V2, BIT_GNT_BT_POLARITY); + /* BT_CCA = ~GNT_WL_BB, not or GNT_BT_BB, LTE_Rx */ rtw_write8_clr(rtwdev, REG_DUMMY_PAGE4_V1, BIT_BTCCA_CTRL); /* to avoid RF parameter error */ From 19ecd61d2c3c5afbc90c2694821c1ac0302f4fd5 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:00 +0800 Subject: [PATCH 093/180] rtw88: coex: update coex parameter to improve A2DP quality Update COEX parameters and logic to enhance WL/BT performance while WL_Busy + A2DP in a less interference environment. It can avoid the interference comes cross from each other and earned more performance. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-3-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw8723d.c | 58 +++++++++---------- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 17 +++--- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 25 ++++---- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 51eef8d0a8e5..6dedc38dd5b9 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -1523,7 +1523,7 @@ static void rtw_coex_action_bt_a2dp(struct rtw_dev *rtwdev) slot_type = TDMA_4SLOT; if (coex_stat->wl_gl_busy && coex_stat->wl_noisy_level == 0) - table_case = 10; + table_case = 11; else table_case = 9; diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c b/drivers/net/wireless/realtek/rtw88/rtw8723d.c index 84d66b5c2733..4ed38681c97d 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c @@ -1949,19 +1949,19 @@ static struct rtw_chip_ops rtw8723d_ops = { static const struct coex_table_para table_sant_8723d[] = { {0xffffffff, 0xffffffff}, /* case-0 */ {0x55555555, 0x55555555}, - {0x65555555, 0x65555555}, + {0x66555555, 0x66555555}, {0xaaaaaaaa, 0xaaaaaaaa}, {0x5a5a5a5a, 0x5a5a5a5a}, {0xfafafafa, 0xfafafafa}, /* case-5 */ - {0xa5555555, 0xaaaa5aaa}, - {0x6a5a5a5a, 0x5a5a5a5a}, + {0x6a5a5555, 0xaaaaaaaa}, + {0x6a5a56aa, 0x6a5a56aa}, {0x6a5a5a5a, 0x6a5a5a5a}, {0x66555555, 0x5a5a5a5a}, - {0x65555555, 0x6a5a5a5a}, /* case-10 */ - {0x65555555, 0xfafafafa}, + {0x66555555, 0x6a5a5a5a}, /* case-10 */ + {0x66555555, 0x6a5a5aaa}, {0x66555555, 0x5a5a5aaa}, - {0x65555555, 0x5aaa5aaa}, - {0x65555555, 0xaaaa5aaa}, + {0x66555555, 0x6aaa5aaa}, + {0x66555555, 0xaaaa5aaa}, {0x66555555, 0xaaaaaaaa}, /* case-15 */ {0xffff55ff, 0xfafafafa}, {0xffff55ff, 0x6afa5afa}, @@ -1970,13 +1970,13 @@ static const struct coex_table_para table_sant_8723d[] = { {0xaa5555aa, 0x6a5a5a5a}, /* case-20 */ {0xaa5555aa, 0xaaaaaaaa}, {0xffffffff, 0x5a5a5a5a}, - {0xffffffff, 0x6a5a5a5a}, + {0xffffffff, 0x5a5a5a5a}, {0xffffffff, 0x55555555}, - {0xffffffff, 0x6a5a5aaa}, /* case-25 */ + {0xffffffff, 0x5a5a5aaa}, /* case-25 */ {0x55555555, 0x5a5a5a5a}, {0x55555555, 0xaaaaaaaa}, - {0x55555555, 0x6a6a6a6a}, - {0x656a656a, 0x656a656a}, + {0x55555555, 0x6a5a6a5a}, + {0x66556655, 0x66556655}, {0x66556aaa, 0x6a5a6aaa}, /* case-30 */ {0xffffffff, 0x5aaa5aaa}, {0x56555555, 0x5a5a5aaa}, @@ -1986,25 +1986,25 @@ static const struct coex_table_para table_sant_8723d[] = { static const struct coex_table_para table_nsant_8723d[] = { {0xffffffff, 0xffffffff}, /* case-100 */ {0x55555555, 0x55555555}, - {0x65555555, 0x65555555}, + {0x66555555, 0x66555555}, {0xaaaaaaaa, 0xaaaaaaaa}, {0x5a5a5a5a, 0x5a5a5a5a}, {0xfafafafa, 0xfafafafa}, /* case-105 */ {0x5afa5afa, 0x5afa5afa}, {0x55555555, 0xfafafafa}, - {0x65555555, 0xfafafafa}, - {0x65555555, 0x5a5a5a5a}, - {0x65555555, 0x6a5a5a5a}, /* case-110 */ - {0x65555555, 0xaaaaaaaa}, + {0x66555555, 0xfafafafa}, + {0x66555555, 0x5a5a5a5a}, + {0x66555555, 0x6a5a5a5a}, /* case-110 */ + {0x66555555, 0xaaaaaaaa}, {0xffff55ff, 0xfafafafa}, {0xffff55ff, 0x5afa5afa}, {0xffff55ff, 0xaaaaaaaa}, - {0xaaffffaa, 0xfafafafa}, /* case-115 */ + {0xffff55ff, 0xffff55ff}, /* case-115 */ {0xaaffffaa, 0x5afa5afa}, {0xaaffffaa, 0xaaaaaaaa}, {0xffffffff, 0xfafafafa}, {0xffffffff, 0x5afa5afa}, - {0xffffffff, 0xaaaaaaaa},/* case-120 */ + {0xffffffff, 0xaaaaaaaa}, /* case-120 */ {0x55ff55ff, 0x5afa5afa}, {0x55ff55ff, 0xaaaaaaaa}, {0x55ff55ff, 0x55ff55ff} @@ -2012,31 +2012,31 @@ static const struct coex_table_para table_nsant_8723d[] = { /* Shared-Antenna TDMA */ static const struct coex_tdma_para tdma_sant_8723d[] = { - { {0x08, 0x00, 0x00, 0x00, 0x00} }, /* case-0 */ + { {0x00, 0x00, 0x00, 0x00, 0x00} }, /* case-0 */ { {0x61, 0x45, 0x03, 0x11, 0x11} }, /* case-1 */ { {0x61, 0x3a, 0x03, 0x11, 0x11} }, - { {0x61, 0x20, 0x03, 0x11, 0x11} }, { {0x61, 0x30, 0x03, 0x11, 0x11} }, + { {0x61, 0x20, 0x03, 0x11, 0x11} }, { {0x61, 0x10, 0x03, 0x11, 0x11} }, /* case-5 */ - { {0x61, 0x48, 0x03, 0x11, 0x10} }, + { {0x61, 0x45, 0x03, 0x11, 0x10} }, { {0x61, 0x3a, 0x03, 0x11, 0x10} }, { {0x61, 0x30, 0x03, 0x11, 0x10} }, { {0x61, 0x20, 0x03, 0x11, 0x10} }, { {0x61, 0x10, 0x03, 0x11, 0x10} }, /* case-10 */ - { {0x61, 0x10, 0x03, 0x11, 0x14} }, + { {0x61, 0x08, 0x03, 0x11, 0x14} }, { {0x61, 0x08, 0x03, 0x10, 0x14} }, - { {0x51, 0x10, 0x03, 0x10, 0x54} }, - { {0x51, 0x10, 0x03, 0x10, 0x55} }, - { {0x51, 0x10, 0x07, 0x10, 0x54} }, /* case-15 */ + { {0x51, 0x08, 0x03, 0x10, 0x54} }, + { {0x51, 0x08, 0x03, 0x10, 0x55} }, + { {0x51, 0x08, 0x07, 0x10, 0x54} }, /* case-15 */ { {0x51, 0x45, 0x03, 0x10, 0x50} }, { {0x51, 0x3a, 0x03, 0x10, 0x50} }, { {0x51, 0x30, 0x03, 0x10, 0x50} }, { {0x51, 0x20, 0x03, 0x10, 0x50} }, - { {0x51, 0x15, 0x03, 0x10, 0x50} }, /* case-20 */ + { {0x51, 0x10, 0x03, 0x10, 0x50} }, /* case-20 */ { {0x51, 0x4a, 0x03, 0x10, 0x50} }, { {0x51, 0x0c, 0x03, 0x10, 0x54} }, { {0x55, 0x08, 0x03, 0x10, 0x54} }, - { {0x65, 0x10, 0x03, 0x11, 0x11} }, + { {0x65, 0x10, 0x03, 0x11, 0x10} }, { {0x51, 0x10, 0x03, 0x10, 0x51} }, /* case-25 */ { {0x51, 0x08, 0x03, 0x10, 0x50} }, { {0x61, 0x08, 0x03, 0x11, 0x11} } @@ -2044,7 +2044,7 @@ static const struct coex_tdma_para tdma_sant_8723d[] = { /* Non-Shared-Antenna TDMA */ static const struct coex_tdma_para tdma_nsant_8723d[] = { - { {0x00, 0x00, 0x00, 0x40, 0x01} }, /* case-100 */ + { {0x00, 0x00, 0x00, 0x00, 0x01} }, /* case-100 */ { {0x61, 0x45, 0x03, 0x11, 0x11} }, /* case-101 */ { {0x61, 0x3a, 0x03, 0x11, 0x11} }, { {0x61, 0x30, 0x03, 0x11, 0x11} }, @@ -2065,7 +2065,7 @@ static const struct coex_tdma_para tdma_nsant_8723d[] = { { {0x51, 0x30, 0x03, 0x10, 0x50} }, { {0x51, 0x20, 0x03, 0x10, 0x50} }, { {0x51, 0x10, 0x03, 0x10, 0x50} }, /* case-120 */ - { {0x51, 0x08, 0x03, 0x10, 0x50} }, + { {0x51, 0x08, 0x03, 0x10, 0x50} } }; /* rssi in percentage % (dbm = % - 100) */ diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index d562f7324e6a..c1a96c7fe67d 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -2141,14 +2141,14 @@ static const struct coex_table_para table_sant_8822b[] = { {0xaaaaaaaa, 0xaaaaaaaa}, {0x5a5a5a5a, 0x5a5a5a5a}, {0xfafafafa, 0xfafafafa}, /* case-5 */ - {0x6a5a6a5a, 0xaaaaaaaa}, + {0x6a5a5555, 0xaaaaaaaa}, {0x6a5a56aa, 0x6a5a56aa}, {0x6a5a5a5a, 0x6a5a5a5a}, {0x66555555, 0x5a5a5a5a}, {0x66555555, 0x6a5a5a5a}, /* case-10 */ {0x66555555, 0xfafafafa}, {0x66555555, 0x5a5a5aaa}, - {0x66555555, 0x5aaa5aaa}, + {0x66555555, 0x6aaa5aaa}, {0x66555555, 0xaaaa5aaa}, {0x66555555, 0xaaaaaaaa}, /* case-15 */ {0xffff55ff, 0xfafafafa}, @@ -2158,7 +2158,7 @@ static const struct coex_table_para table_sant_8822b[] = { {0xaa5555aa, 0x6a5a5a5a}, /* case-20 */ {0xaa5555aa, 0xaaaaaaaa}, {0xffffffff, 0x5a5a5a5a}, - {0xffffffff, 0x6a5a5a5a}, + {0xffffffff, 0x5a5a5a5a}, {0xffffffff, 0x55555555}, {0xffffffff, 0x6a5a5aaa}, /* case-25 */ {0x55555555, 0x5a5a5a5a}, @@ -2187,7 +2187,7 @@ static const struct coex_table_para table_nsant_8822b[] = { {0xffff55ff, 0xfafafafa}, {0xffff55ff, 0x5afa5afa}, {0xffff55ff, 0xaaaaaaaa}, - {0xaaffffaa, 0xfafafafa}, /* case-115 */ + {0xffff55ff, 0xffff55ff}, /* case-115 */ {0xaaffffaa, 0x5afa5afa}, {0xaaffffaa, 0xaaaaaaaa}, {0xffffffff, 0xfafafafa}, @@ -2216,7 +2216,7 @@ static const struct coex_tdma_para tdma_sant_8822b[] = { { {0x51, 0x08, 0x03, 0x10, 0x54} }, { {0x51, 0x08, 0x03, 0x10, 0x55} }, { {0x51, 0x08, 0x07, 0x10, 0x54} }, /* case-15 */ - { {0x51, 0x45, 0x03, 0x10, 0x10} }, + { {0x51, 0x45, 0x03, 0x10, 0x50} }, { {0x51, 0x3a, 0x03, 0x10, 0x50} }, { {0x51, 0x30, 0x03, 0x10, 0x50} }, { {0x51, 0x20, 0x03, 0x10, 0x50} }, @@ -2224,7 +2224,7 @@ static const struct coex_tdma_para tdma_sant_8822b[] = { { {0x51, 0x4a, 0x03, 0x10, 0x50} }, { {0x51, 0x0c, 0x03, 0x10, 0x54} }, { {0x55, 0x08, 0x03, 0x10, 0x54} }, - { {0x65, 0x10, 0x03, 0x11, 0x11} }, + { {0x65, 0x10, 0x03, 0x11, 0x10} }, { {0x51, 0x10, 0x03, 0x10, 0x51} }, /* case-25 */ { {0x51, 0x08, 0x03, 0x10, 0x50} }, { {0x61, 0x08, 0x03, 0x11, 0x11} } @@ -2233,7 +2233,7 @@ static const struct coex_tdma_para tdma_sant_8822b[] = { /* Non-Shared-Antenna TDMA */ static const struct coex_tdma_para tdma_nsant_8822b[] = { { {0x00, 0x00, 0x00, 0x00, 0x00} }, /* case-100 */ - { {0x61, 0x45, 0x03, 0x11, 0x11} }, + { {0x61, 0x45, 0x03, 0x11, 0x11} }, /* case-101 */ { {0x61, 0x3a, 0x03, 0x11, 0x11} }, { {0x61, 0x30, 0x03, 0x11, 0x11} }, { {0x61, 0x20, 0x03, 0x11, 0x11} }, @@ -2252,7 +2252,8 @@ static const struct coex_tdma_para tdma_nsant_8822b[] = { { {0x51, 0x3a, 0x03, 0x10, 0x50} }, { {0x51, 0x30, 0x03, 0x10, 0x50} }, { {0x51, 0x20, 0x03, 0x10, 0x50} }, - { {0x51, 0x10, 0x03, 0x10, 0x50} } /* case-120 */ + { {0x51, 0x10, 0x03, 0x10, 0x50} }, /* case-120 */ + { {0x51, 0x08, 0x03, 0x10, 0x50} } }; /* rssi in percentage % (dbm = % - 100) */ diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index 56c403d628fd..db80682b358e 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -3983,14 +3983,14 @@ static const struct coex_table_para table_sant_8822c[] = { {0xaaaaaaaa, 0xaaaaaaaa}, {0x5a5a5a5a, 0x5a5a5a5a}, {0xfafafafa, 0xfafafafa}, /* case-5 */ - {0x6a5a6a5a, 0xaaaaaaaa}, + {0x6a5a5555, 0xaaaaaaaa}, {0x6a5a56aa, 0x6a5a56aa}, {0x6a5a5a5a, 0x6a5a5a5a}, {0x66555555, 0x5a5a5a5a}, {0x66555555, 0x6a5a5a5a}, /* case-10 */ - {0x66555555, 0xfafafafa}, + {0x66555555, 0x6a5a5aaa}, {0x66555555, 0x5a5a5aaa}, - {0x66555555, 0x5aaa5aaa}, + {0x66555555, 0x6aaa5aaa}, {0x66555555, 0xaaaa5aaa}, {0x66555555, 0xaaaaaaaa}, /* case-15 */ {0xffff55ff, 0xfafafafa}, @@ -4000,14 +4000,14 @@ static const struct coex_table_para table_sant_8822c[] = { {0xaa5555aa, 0x6a5a5a5a}, /* case-20 */ {0xaa5555aa, 0xaaaaaaaa}, {0xffffffff, 0x5a5a5a5a}, - {0xffffffff, 0x6a5a5a5a}, + {0xffffffff, 0x5a5a5a5a}, {0xffffffff, 0x55555555}, - {0xffffffff, 0x6a5a5aaa}, /* case-25 */ + {0xffffffff, 0x5a5a5aaa}, /* case-25 */ {0x55555555, 0x5a5a5a5a}, {0x55555555, 0xaaaaaaaa}, {0x55555555, 0x6a5a6a5a}, {0x66556655, 0x66556655}, - {0x66556aaa, 0x6a5a6aaa}, /* case-30 */ + {0x66556aaa, 0x6a5a6aaa}, /*case-30*/ {0xffffffff, 0x5aaa5aaa}, {0x56555555, 0x5a5a5aaa}, }; @@ -4029,12 +4029,12 @@ static const struct coex_table_para table_nsant_8822c[] = { {0xffff55ff, 0xfafafafa}, {0xffff55ff, 0x5afa5afa}, {0xffff55ff, 0xaaaaaaaa}, - {0xaaffffaa, 0xfafafafa}, /* case-115 */ + {0xffff55ff, 0xffff55ff}, /* case-115 */ {0xaaffffaa, 0x5afa5afa}, {0xaaffffaa, 0xaaaaaaaa}, {0xffffffff, 0xfafafafa}, {0xffffffff, 0x5afa5afa}, - {0xffffffff, 0xaaaaaaaa},/* case-120 */ + {0xffffffff, 0xaaaaaaaa}, /* case-120 */ {0x55ff55ff, 0x5afa5afa}, {0x55ff55ff, 0xaaaaaaaa}, {0x55ff55ff, 0x55ff55ff} @@ -4043,7 +4043,7 @@ static const struct coex_table_para table_nsant_8822c[] = { /* Shared-Antenna TDMA */ static const struct coex_tdma_para tdma_sant_8822c[] = { { {0x00, 0x00, 0x00, 0x00, 0x00} }, /* case-0 */ - { {0x61, 0x45, 0x03, 0x11, 0x11} }, + { {0x61, 0x45, 0x03, 0x11, 0x11} }, /* case-1 */ { {0x61, 0x3a, 0x03, 0x11, 0x11} }, { {0x61, 0x30, 0x03, 0x11, 0x11} }, { {0x61, 0x20, 0x03, 0x11, 0x11} }, @@ -4058,7 +4058,7 @@ static const struct coex_tdma_para tdma_sant_8822c[] = { { {0x51, 0x08, 0x03, 0x10, 0x54} }, { {0x51, 0x08, 0x03, 0x10, 0x55} }, { {0x51, 0x08, 0x07, 0x10, 0x54} }, /* case-15 */ - { {0x51, 0x45, 0x03, 0x10, 0x10} }, + { {0x51, 0x45, 0x03, 0x10, 0x50} }, { {0x51, 0x3a, 0x03, 0x10, 0x50} }, { {0x51, 0x30, 0x03, 0x10, 0x50} }, { {0x51, 0x20, 0x03, 0x10, 0x50} }, @@ -4066,7 +4066,7 @@ static const struct coex_tdma_para tdma_sant_8822c[] = { { {0x51, 0x4a, 0x03, 0x10, 0x50} }, { {0x51, 0x0c, 0x03, 0x10, 0x54} }, { {0x55, 0x08, 0x03, 0x10, 0x54} }, - { {0x65, 0x10, 0x03, 0x11, 0x11} }, + { {0x65, 0x10, 0x03, 0x11, 0x10} }, { {0x51, 0x10, 0x03, 0x10, 0x51} }, /* case-25 */ { {0x51, 0x08, 0x03, 0x10, 0x50} }, { {0x61, 0x08, 0x03, 0x11, 0x11} } @@ -4094,7 +4094,8 @@ static const struct coex_tdma_para tdma_nsant_8822c[] = { { {0x51, 0x3a, 0x03, 0x10, 0x50} }, { {0x51, 0x30, 0x03, 0x10, 0x50} }, { {0x51, 0x20, 0x03, 0x10, 0x50} }, - { {0x51, 0x10, 0x03, 0x10, 0x50} } /* case-120 */ + { {0x51, 0x10, 0x03, 0x10, 0x50} }, /* case-120 */ + { {0x51, 0x08, 0x03, 0x10, 0x50} } }; /* rssi in percentage % (dbm = % - 100) */ From 1d82c49764aa606ceb769585a23ccb7bf3a863ab Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:01 +0800 Subject: [PATCH 094/180] rtw88: coex: reduce magic number Use macro definition to replace magic number. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-4-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 30 +++++----- drivers/net/wireless/realtek/rtw88/reg.h | 8 +++ drivers/net/wireless/realtek/rtw88/rtw8822c.c | 60 +++++++++++-------- 3 files changed, 58 insertions(+), 40 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 6dedc38dd5b9..82188dfc90c5 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -145,13 +145,13 @@ static void rtw_coex_wl_ccklock_action(struct rtw_dev *rtwdev) coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; if (coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] == 7) { - para[1] = 0x1; /* disable 5ms extend */ + para[1] = PARA1_H2C69_DIS_5MS; rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); coex_stat->wl_slot_extend = false; coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; } } else if (!coex_stat->wl_slot_extend && coex_stat->wl_cck_lock) { - para[1] = 0x0; /* enable 5ms extend */ + para[1] = PARA1_H2C69_EN_5MS; rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); coex_stat->wl_slot_extend = true; } @@ -777,14 +777,14 @@ static void rtw_coex_coex_ctrl_owner(struct rtw_dev *rtwdev, bool wifi_control) static void rtw_coex_set_gnt_bt(struct rtw_dev *rtwdev, u8 state) { - rtw_coex_write_indirect_reg(rtwdev, 0x38, 0xc000, state); - rtw_coex_write_indirect_reg(rtwdev, 0x38, 0x0c00, state); + rtw_coex_write_indirect_reg(rtwdev, LTE_COEX_CTRL, 0xc000, state); + rtw_coex_write_indirect_reg(rtwdev, LTE_COEX_CTRL, 0x0c00, state); } static void rtw_coex_set_gnt_wl(struct rtw_dev *rtwdev, u8 state) { - rtw_coex_write_indirect_reg(rtwdev, 0x38, 0x3000, state); - rtw_coex_write_indirect_reg(rtwdev, 0x38, 0x0300, state); + rtw_coex_write_indirect_reg(rtwdev, LTE_COEX_CTRL, 0x3000, state); + rtw_coex_write_indirect_reg(rtwdev, LTE_COEX_CTRL, 0x0300, state); } static void rtw_coex_set_table(struct rtw_dev *rtwdev, u32 table0, u32 table1) @@ -2916,14 +2916,16 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) score_board_BW = rtw_coex_read_scbd(rtwdev); score_board_WB = coex_stat->score_board; - wl_reg_6c0 = rtw_read32(rtwdev, 0x6c0); - wl_reg_6c4 = rtw_read32(rtwdev, 0x6c4); - wl_reg_6c8 = rtw_read32(rtwdev, 0x6c8); - wl_reg_6cc = rtw_read32(rtwdev, 0x6cc); - wl_reg_778 = rtw_read32(rtwdev, 0x778); - bt_hi_pri = rtw_read32(rtwdev, 0x770); - bt_lo_pri = rtw_read32(rtwdev, 0x774); - rtw_write8(rtwdev, 0x76e, 0xc); + wl_reg_6c0 = rtw_read32(rtwdev, REG_BT_COEX_TABLE0); + wl_reg_6c4 = rtw_read32(rtwdev, REG_BT_COEX_TABLE1); + wl_reg_6c8 = rtw_read32(rtwdev, REG_BT_COEX_BRK_TABLE); + wl_reg_6cc = rtw_read32(rtwdev, REG_BT_COEX_TABLE_H); + wl_reg_778 = rtw_read8(rtwdev, REG_BT_STAT_CTRL); + + bt_hi_pri = rtw_read32(rtwdev, REG_BT_ACT_STATISTICS); + bt_lo_pri = rtw_read32(rtwdev, REG_BT_ACT_STATISTICS_1); + rtw_write8(rtwdev, REG_BT_COEX_ENH_INTR_CTRL, + BIT_R_GRANTALL_WLMASK | BIT_STATIS_BT_EN); sys_lte = rtw_read8(rtwdev, 0x73); lte_coex = rtw_coex_read_indirect_reg(rtwdev, 0x38); bt_coex = rtw_coex_read_indirect_reg(rtwdev, 0x54); diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h index b3df09ff01b3..2a4275f3d851 100644 --- a/drivers/net/wireless/realtek/rtw88/reg.h +++ b/drivers/net/wireless/realtek/rtw88/reg.h @@ -466,6 +466,11 @@ #define REG_BT_COEX_V2 0x0762 #define BIT_GNT_BT_POLARITY BIT(12) #define BIT_LTE_COEX_EN BIT(7) +#define REG_BT_COEX_ENH_INTR_CTRL 0x76E +#define BIT_R_GRANTALL_WLMASK BIT(3) +#define BIT_STATIS_BT_EN BIT(2) +#define REG_BT_ACT_STATISTICS 0x0770 +#define REG_BT_ACT_STATISTICS_1 0x0774 #define REG_BT_STAT_CTRL 0x0778 #define REG_BT_TDMA_TIME 0x0790 #define BIT_MASK_SAMPLE_RATE GENMASK(5, 0) @@ -619,6 +624,9 @@ #define REG_ANAPAR 0x1c30 #define BIT_ANAPAR_BTPS BIT(22) #define REG_RSTB_SEL 0x1c38 +#define BIT_DAC_OFF_ENABLE BIT(4) +#define BIT_PI_IGNORE_GNT_BT BIT(3) +#define BIT_NOMASK_TXBT_ENABLE BIT(3) #define REG_HRCV_MSG 0x1cf diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index db80682b358e..965b77645f2e 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -2153,7 +2153,7 @@ static void rtw8822c_coex_cfg_init(struct rtw_dev *rtwdev) rtw_write8_clr(rtwdev, REG_DUMMY_PAGE4_V1, BIT_BTCCA_CTRL); /* to avoid RF parameter error */ - rtw_write_rf(rtwdev, RF_PATH_B, 0x1, 0xfffff, 0x40000); + rtw_write_rf(rtwdev, RF_PATH_B, RF_MODOPT, 0xfffff, 0x40000); } static void rtw8822c_coex_cfg_gnt_fix(struct rtw_dev *rtwdev) @@ -2190,10 +2190,10 @@ static void rtw8822c_coex_cfg_gnt_fix(struct rtw_dev *rtwdev) * disable WL-S1 BB chage RF mode if GNT_BT * since RF TRx mask can do it */ - rtw_write8_mask(rtwdev, 0x1c32, BIT(6), 1); - rtw_write8_mask(rtwdev, 0x1c39, BIT(4), 0); - rtw_write8_mask(rtwdev, 0x1c3b, BIT(4), 1); - rtw_write8_mask(rtwdev, 0x4160, BIT(3), 1); + rtw_write8_mask(rtwdev, REG_ANAPAR + 2, BIT_ANAPAR_BTPS >> 16, 1); + rtw_write8_mask(rtwdev, REG_RSTB_SEL + 1, BIT_DAC_OFF_ENABLE, 0); + rtw_write8_mask(rtwdev, REG_RSTB_SEL + 3, BIT_DAC_OFF_ENABLE, 1); + rtw_write8_mask(rtwdev, REG_IGN_GNTBT4, BIT_PI_IGNORE_GNT_BT, 1); /* disable WL-S0 BB chage RF mode if wifi is at 5G, * or antenna path is separated @@ -2201,26 +2201,32 @@ static void rtw8822c_coex_cfg_gnt_fix(struct rtw_dev *rtwdev) if (coex_stat->wl_coex_mode == COEX_WLINK_5G || coex->under_5g || !efuse->share_ant) { if (coex_stat->kt_ver >= 3) { - rtw_write8_mask(rtwdev, 0x1860, BIT(3), 0); - rtw_write8_mask(rtwdev, 0x1ca7, BIT(3), 1); + rtw_write8_mask(rtwdev, REG_IGN_GNT_BT1, + BIT_PI_IGNORE_GNT_BT, 0); + rtw_write8_mask(rtwdev, REG_NOMASK_TXBT, + BIT_NOMASK_TXBT_ENABLE, 1); } else { - rtw_write8_mask(rtwdev, 0x1860, BIT(3), 1); + rtw_write8_mask(rtwdev, REG_IGN_GNT_BT1, + BIT_PI_IGNORE_GNT_BT, 1); } } else { /* shared-antenna */ - rtw_write8_mask(rtwdev, 0x1860, BIT(3), 0); - if (coex_stat->kt_ver >= 3) - rtw_write8_mask(rtwdev, 0x1ca7, BIT(3), 0); + rtw_write8_mask(rtwdev, REG_IGN_GNT_BT1, + BIT_PI_IGNORE_GNT_BT, 0); + if (coex_stat->kt_ver >= 3) { + rtw_write8_mask(rtwdev, REG_NOMASK_TXBT, + BIT_NOMASK_TXBT_ENABLE, 0); + } } } static void rtw8822c_coex_cfg_gnt_debug(struct rtw_dev *rtwdev) { - rtw_write8_mask(rtwdev, 0x66, BIT(4), 0); - rtw_write8_mask(rtwdev, 0x67, BIT(0), 0); - rtw_write8_mask(rtwdev, 0x42, BIT(3), 0); - rtw_write8_mask(rtwdev, 0x65, BIT(7), 0); - rtw_write8_mask(rtwdev, 0x73, BIT(3), 0); + rtw_write8_mask(rtwdev, REG_PAD_CTRL1 + 2, BIT_BTGP_SPI_EN >> 16, 0); + rtw_write8_mask(rtwdev, REG_PAD_CTRL1 + 3, BIT_BTGP_JTAG_EN >> 24, 0); + rtw_write8_mask(rtwdev, REG_GPIO_MUXCFG + 2, BIT_FSPI_EN >> 16, 0); + rtw_write8_mask(rtwdev, REG_PAD_CTRL1 + 1, BIT_LED1DIS >> 8, 0); + rtw_write8_mask(rtwdev, REG_SYS_SDIO_CTRL + 3, BIT_DBG_GNT_WL_BT >> 24, 0); } static void rtw8822c_coex_cfg_rfe_type(struct rtw_dev *rtwdev) @@ -2241,9 +2247,9 @@ static void rtw8822c_coex_cfg_rfe_type(struct rtw_dev *rtwdev) coex_rfe->wlg_at_btg = false; /* disable LTE coex in wifi side */ - rtw_coex_write_indirect_reg(rtwdev, 0x38, BIT_LTE_COEX_EN, 0x0); - rtw_coex_write_indirect_reg(rtwdev, 0xa0, MASKLWORD, 0xffff); - rtw_coex_write_indirect_reg(rtwdev, 0xa4, MASKLWORD, 0xffff); + rtw_coex_write_indirect_reg(rtwdev, LTE_COEX_CTRL, BIT_LTE_COEX_EN, 0x0); + rtw_coex_write_indirect_reg(rtwdev, LTE_WL_TRX_CTRL, MASKLWORD, 0xffff); + rtw_coex_write_indirect_reg(rtwdev, LTE_BT_TRX_CTRL, MASKLWORD, 0xffff); } static void rtw8822c_coex_cfg_wl_tx_power(struct rtw_dev *rtwdev, u8 wl_pwr) @@ -2269,15 +2275,17 @@ static void rtw8822c_coex_cfg_wl_rx_gain(struct rtw_dev *rtwdev, bool low_gain) if (coex_dm->cur_wl_rx_low_gain_en) { /* set Rx filter corner RCK offset */ - rtw_write_rf(rtwdev, RF_PATH_A, 0xde, 0xfffff, 0x22); - rtw_write_rf(rtwdev, RF_PATH_A, 0x1d, 0xfffff, 0x36); - rtw_write_rf(rtwdev, RF_PATH_B, 0xde, 0xfffff, 0x22); - rtw_write_rf(rtwdev, RF_PATH_B, 0x1d, 0xfffff, 0x36); + rtw_write_rf(rtwdev, RF_PATH_A, RF_RCKD, RFREG_MASK, 0x22); + rtw_write_rf(rtwdev, RF_PATH_A, RF_RCK, RFREG_MASK, 0x36); + rtw_write_rf(rtwdev, RF_PATH_B, RF_RCKD, RFREG_MASK, 0x22); + rtw_write_rf(rtwdev, RF_PATH_B, RF_RCK, RFREG_MASK, 0x36); + } else { /* set Rx filter corner RCK offset */ - rtw_write_rf(rtwdev, RF_PATH_A, 0xde, 0xfffff, 0x20); - rtw_write_rf(rtwdev, RF_PATH_A, 0x1d, 0xfffff, 0x0); - rtw_write_rf(rtwdev, RF_PATH_B, 0x1d, 0xfffff, 0x0); + rtw_write_rf(rtwdev, RF_PATH_A, RF_RCKD, RFREG_MASK, 0x20); + rtw_write_rf(rtwdev, RF_PATH_A, RF_RCK, RFREG_MASK, 0x0); + rtw_write_rf(rtwdev, RF_PATH_B, RF_RCKD, RFREG_MASK, 0x20); + rtw_write_rf(rtwdev, RF_PATH_B, RF_RCK, RFREG_MASK, 0x0); } } From d8350768d629acaa009b32580e603fb4df4539df Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:02 +0800 Subject: [PATCH 095/180] rtw88: coex: coding style adjustment Adjust space and comments, and fix "line over 80 characters" warnings reported by checkpatch. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-5-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 42 +++++++++++++---------- drivers/net/wireless/realtek/rtw88/coex.h | 10 +++--- drivers/net/wireless/realtek/rtw88/main.c | 2 +- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 82188dfc90c5..4f4477c8262a 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -337,6 +337,11 @@ static void rtw_coex_query_bt_info(struct rtw_dev *rtwdev) rtw_fw_query_bt_info(rtwdev); } +static void rtw_coex_gnt_workaround(struct rtw_dev *rtwdev, bool force, u8 mode) +{ + rtw_coex_set_gnt_fix(rtwdev); +} + static void rtw_coex_monitor_bt_enable(struct rtw_dev *rtwdev) { struct rtw_chip_info *chip = rtwdev->chip; @@ -551,8 +556,8 @@ static void rtw_coex_update_bt_link_info(struct rtw_dev *rtwdev) rssi_state = coex_dm->bt_rssi_state[i]; rssi_step = chip->bt_rssi_step[i]; rssi = coex_stat->bt_rssi; - rssi_state = rtw_coex_next_rssi_state(rtwdev, rssi_state, - rssi, rssi_step); + rssi_state = rtw_coex_next_rssi_state(rtwdev, rssi_state, rssi, + rssi_step); coex_dm->bt_rssi_state[i] = rssi_state; } @@ -765,11 +770,13 @@ static void rtw_coex_coex_ctrl_owner(struct rtw_dev *rtwdev, bool wifi_control) const struct rtw_hw_reg *btg_reg = chip->btg_reg; if (wifi_control) { - rtw_write32_set(rtwdev, REG_SYS_SDIO_CTRL, BIT_LTE_MUX_CTRL_PATH); + rtw_write8_set(rtwdev, REG_SYS_SDIO_CTRL + 3, + BIT_LTE_MUX_CTRL_PATH >> 24); if (btg_reg) rtw_write8_set(rtwdev, btg_reg->addr, btg_reg->mask); } else { - rtw_write32_clr(rtwdev, REG_SYS_SDIO_CTRL, BIT_LTE_MUX_CTRL_PATH); + rtw_write8_clr(rtwdev, REG_SYS_SDIO_CTRL + 3, + BIT_LTE_MUX_CTRL_PATH >> 24); if (btg_reg) rtw_write8_clr(rtwdev, btg_reg->addr, btg_reg->mask); } @@ -789,7 +796,7 @@ static void rtw_coex_set_gnt_wl(struct rtw_dev *rtwdev, u8 state) static void rtw_coex_set_table(struct rtw_dev *rtwdev, u32 table0, u32 table1) { -#define DEF_BRK_TABLE_VAL 0xf0ffffff +#define DEF_BRK_TABLE_VAL 0xf0ffffff rtw_write32(rtwdev, REG_BT_COEX_TABLE0, table0); rtw_write32(rtwdev, REG_BT_COEX_TABLE1, table1); rtw_write32(rtwdev, REG_BT_COEX_BRK_TABLE, DEF_BRK_TABLE_VAL); @@ -1012,7 +1019,7 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) /* set GNT_BT to SW Low */ rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_SW_LOW); - /* Set GNT_WL to SW high */ + /* set GNT_WL to SW high */ rtw_coex_set_gnt_wl(rtwdev, COEX_GNT_SET_SW_HIGH); /* set path control owner to wl at initial step */ @@ -1068,10 +1075,10 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) pos_type = COEX_SWITCH_TO_WLG_BT; break; case COEX_SET_ANT_2G_WLBT: - /* set GNT_BT to SW high */ + /* set GNT_BT to HW PTA */ rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_HW_PTA); - /* Set GNT_WL to SW high */ + /* Set GNT_WL to HW PTA */ rtw_coex_set_gnt_wl(rtwdev, COEX_GNT_SET_HW_PTA); /* set path control owner to wl at runtime step */ @@ -1308,7 +1315,7 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) table_case = 112; tdma_case = 104; } else if ((coex_stat->bt_ble_scan_type & 0x2) && - coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { + coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { table_case = 114; tdma_case = 103; } else { @@ -1637,11 +1644,10 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev) else table_case = 9; - if (coex_stat->wl_gl_busy) { + if (coex_stat->wl_gl_busy) tdma_case = 13; - } else { + else tdma_case = 14; - } } else { /* Non-Shared-Ant */ if (coex_stat->bt_ble_exist) @@ -2027,7 +2033,7 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason) rtw_coex_action_wl_not_connected(rtwdev); exit: - rtw_coex_set_gnt_fix(rtwdev); + rtw_coex_gnt_workaround(rtwdev, false, coex_stat->wl_coex_mode); rtw_coex_limited_wl(rtwdev); } @@ -2106,7 +2112,8 @@ void rtw_coex_power_on_setting(struct rtw_dev *rtwdev) coex->wl_rf_off = false; /* enable BB, we can write 0x948 */ - rtw_write8_set(rtwdev, REG_SYS_FUNC_EN, BIT(0) | BIT(1)); + rtw_write8_set(rtwdev, REG_SYS_FUNC_EN, + BIT_FEN_BB_GLB_RST | BIT_FEN_BB_RSTB); rtw_coex_monitor_bt_enable(rtwdev); rtw_coex_set_rfe_type(rtwdev); @@ -2144,7 +2151,6 @@ void rtw_coex_ips_notify(struct rtw_dev *rtwdev, u8 type) /* run init hw config (exclude wifi only) */ __rtw_coex_init_hw_config(rtwdev, false); - /* sw all off */ coex_stat->wl_under_ips = false; } @@ -2310,7 +2316,7 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; struct rtw_chip_info *chip = rtwdev->chip; - unsigned long bt_relink_time; + u32 bt_relink_time; u8 i, rsp_source = 0, type; bool inq_page = false; @@ -2436,7 +2442,7 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) /* unit: % (value-100 to translate to unit: dBm in coex info) */ if (chip->bt_rssi_type == COEX_BTRSSI_RATIO) { coex_stat->bt_rssi = coex_stat->bt_info_hb0 * 2 + 10; - } else { /* original unit: dbm -> unit: % -> value-100 in coex info */ + } else { if (coex_stat->bt_info_hb0 <= 127) coex_stat->bt_rssi = 100; else if (256 - coex_stat->bt_info_hb0 <= 100) @@ -2536,7 +2542,7 @@ void rtw_coex_wl_fwdbginfo_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) rtw_coex_wl_ccklock_detect(rtwdev); } -void rtw_coex_wl_status_change_notify(struct rtw_dev *rtwdev) +void rtw_coex_wl_status_change_notify(struct rtw_dev *rtwdev, u32 type) { struct rtw_coex *coex = &rtwdev->coex; diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h index 44720fdfc053..e0d0be3f0dcf 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.h +++ b/drivers/net/wireless/realtek/rtw88/coex.h @@ -31,6 +31,7 @@ #define TDMA_4SLOT BIT(8) #define COEX_RSSI_STEP 4 + #define COEX_RSSI_HIGH(rssi) \ ({ typeof(rssi) __rssi__ = rssi; \ (__rssi__ == COEX_RSSI_STATE_HIGH || \ @@ -371,13 +372,12 @@ void rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only); void rtw_coex_ips_notify(struct rtw_dev *rtwdev, u8 type); void rtw_coex_lps_notify(struct rtw_dev *rtwdev, u8 type); void rtw_coex_scan_notify(struct rtw_dev *rtwdev, u8 type); -void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 action); -void rtw_coex_media_status_notify(struct rtw_dev *rtwdev, u8 status); -void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 len); +void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type); +void rtw_coex_media_status_notify(struct rtw_dev *rtwdev, u8 type); +void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length); void rtw_coex_wl_fwdbginfo_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length); void rtw_coex_switchband_notify(struct rtw_dev *rtwdev, u8 type); -void rtw_coex_wl_status_change_notify(struct rtw_dev *rtwdev); - +void rtw_coex_wl_status_change_notify(struct rtw_dev *rtwdev, u32 type); void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m); #endif diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 71d90b98d6f1..670202e3ff9e 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -196,7 +196,7 @@ static void rtw_watch_dog_work(struct work_struct *work) clear_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); if (busy_traffic != test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags)) - rtw_coex_wl_status_change_notify(rtwdev); + rtw_coex_wl_status_change_notify(rtwdev, 0); if (stats->tx_cnt > RTW_LPS_THRESHOLD || stats->rx_cnt > RTW_LPS_THRESHOLD) From ae8732d7673d455a2f4c64c7628fc36605ba6921 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:03 +0800 Subject: [PATCH 096/180] rtw88: coex: Modify the timing of set_ant_path/set_rf_para To make sure the related ANT/RF_PARA setting will be expected result in COEX. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-6-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 91 ++++++++++++++--------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 4f4477c8262a..af7e692137ba 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -1165,6 +1165,8 @@ static void rtw_coex_action_coex_all_off(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ table_case = 2; @@ -1175,7 +1177,6 @@ static void rtw_coex_action_coex_all_off(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1228,6 +1229,9 @@ static void rtw_coex_action_bt_whql_test(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ table_case = 2; @@ -1238,8 +1242,6 @@ static void rtw_coex_action_bt_whql_test(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1250,6 +1252,9 @@ static void rtw_coex_action_bt_relink(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ table_case = 1; @@ -1260,8 +1265,6 @@ static void rtw_coex_action_bt_relink(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1276,6 +1279,8 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) struct rtw_coex_rfe *coex_rfe = &coex->rfe; u8 table_case = 0xff, tdma_case = 0xff; + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (coex_rfe->ant_switch_with_bt && coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { if (efuse->share_ant && @@ -1324,7 +1329,6 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) } } - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1339,6 +1343,9 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 slot_type = 0; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (coex_stat->wl_linkscan_proc || coex_stat->wl_hi_pri_task1 || coex_stat->wl_hi_pri_task2) wl_hi_pri = true; @@ -1404,8 +1411,6 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) rtw_dbg(rtwdev, RTW_DBG_COEX, "coex: wifi hi(%d), bt page(%d)\n", wl_hi_pri, coex_stat->bt_page); - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } @@ -1418,6 +1423,9 @@ static void rtw_coex_action_bt_hfp(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ if (coex_stat->bt_multi_link) { @@ -1438,8 +1446,6 @@ static void rtw_coex_action_bt_hfp(struct rtw_dev *rtwdev) } } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1453,6 +1459,9 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 wl_bw; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + wl_bw = rtwdev->hal.current_band_width; if (efuse->share_ant) { @@ -1509,8 +1518,6 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) } } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1525,6 +1532,9 @@ static void rtw_coex_action_bt_a2dp(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 slot_type = 0; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ slot_type = TDMA_4SLOT; @@ -1548,8 +1558,6 @@ static void rtw_coex_action_bt_a2dp(struct rtw_dev *rtwdev) tdma_case = 113; } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } @@ -1563,6 +1571,9 @@ static void rtw_coex_action_bt_a2dpsink(struct rtw_dev *rtwdev) u8 table_case, tdma_case; bool ap_enable = false; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ if (ap_enable) { table_case = 2; @@ -1584,8 +1595,6 @@ static void rtw_coex_action_bt_a2dpsink(struct rtw_dev *rtwdev) } } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1598,6 +1607,9 @@ static void rtw_coex_action_bt_pan(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ if (coex_stat->wl_gl_busy && coex_stat->wl_noisy_level == 0) @@ -1619,8 +1631,6 @@ static void rtw_coex_action_bt_pan(struct rtw_dev *rtwdev) tdma_case = 119; } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1635,6 +1645,9 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 slot_type = 0; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ slot_type = TDMA_4SLOT; @@ -1661,8 +1674,6 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev) tdma_case = 113; } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } @@ -1675,6 +1686,9 @@ static void rtw_coex_action_bt_a2dp_pan(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ if (coex_stat->wl_gl_busy && @@ -1697,8 +1711,6 @@ static void rtw_coex_action_bt_a2dp_pan(struct rtw_dev *rtwdev) tdma_case = 120; } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1711,6 +1723,9 @@ static void rtw_coex_action_bt_pan_hid(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ table_case = 9; @@ -1729,8 +1744,6 @@ static void rtw_coex_action_bt_pan_hid(struct rtw_dev *rtwdev) tdma_case = 119; } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1743,6 +1756,9 @@ static void rtw_coex_action_bt_a2dp_pan_hid(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ table_case = 10; @@ -1761,8 +1777,6 @@ static void rtw_coex_action_bt_a2dp_pan_hid(struct rtw_dev *rtwdev) tdma_case = 120; } - rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1773,6 +1787,9 @@ static void rtw_coex_action_wl_under5g(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_5G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + rtw_coex_write_scbd(rtwdev, COEX_SCBD_FIX2M, false); if (efuse->share_ant) { @@ -1785,8 +1802,6 @@ static void rtw_coex_action_wl_under5g(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_5G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1797,6 +1812,9 @@ static void rtw_coex_action_wl_only(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ table_case = 2; @@ -1807,8 +1825,6 @@ static void rtw_coex_action_wl_only(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1823,6 +1839,9 @@ static void rtw_coex_action_wl_native_lps(struct rtw_dev *rtwdev) if (coex->under_5g) return; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ table_case = 28; @@ -1833,8 +1852,6 @@ static void rtw_coex_action_wl_native_lps(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1848,6 +1865,9 @@ static void rtw_coex_action_wl_linkscan(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 slot_type = 0; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ if (coex_stat->bt_a2dp_exist) { @@ -1869,8 +1889,6 @@ static void rtw_coex_action_wl_linkscan(struct rtw_dev *rtwdev) } } - rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } @@ -1881,6 +1899,9 @@ static void rtw_coex_action_wl_not_connected(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + if (efuse->share_ant) { /* Shared-Ant */ table_case = 1; @@ -1891,8 +1912,6 @@ static void rtw_coex_action_wl_not_connected(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_2G); - rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); rtw_coex_table(rtwdev, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } From 32c3a8c7d91f1de83d570b9f0f8ceb20a7c8a270 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:04 +0800 Subject: [PATCH 097/180] rtw88: coex: add separate flag for manual control The original stop_dm flag is shared with the wifi and coexistence mechanism internal usage, which represent two meanings, and makes developers hard to debug. Add a new flag manual_control for coexistence mechanism usage only. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-7-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 18 +++++++++--------- drivers/net/wireless/realtek/rtw88/debug.c | 4 ++-- drivers/net/wireless/realtek/rtw88/main.h | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index af7e692137ba..6de98414e3bf 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -124,7 +124,7 @@ static void rtw_coex_wl_ccklock_action(struct rtw_dev *rtwdev) struct rtw_coex_stat *coex_stat = &coex->stat; u8 para[6] = {0}; - if (coex->stop_dm) + if (coex->manual_control || coex->stop_dm) return; para[0] = COEX_H2C69_WL_LEAKAP; @@ -829,7 +829,7 @@ static void rtw_coex_ignore_wlan_act(struct rtw_dev *rtwdev, bool enable) { struct rtw_coex *coex = &rtwdev->coex; - if (coex->stop_dm) + if (coex->manual_control || coex->stop_dm) return; rtw_fw_bt_ignore_wlan_action(rtwdev, enable); @@ -1987,7 +1987,7 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason) rtw_coex_monitor_bt_enable(rtwdev); - if (coex->stop_dm) + if (coex->manual_control || coex->stop_dm) return; if (coex_stat->wl_under_ips) @@ -2154,7 +2154,7 @@ void rtw_coex_ips_notify(struct rtw_dev *rtwdev, u8 type) struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; - if (coex->stop_dm) + if (coex->manual_control || coex->stop_dm) return; if (type == COEX_IPS_ENTER) { @@ -2180,7 +2180,7 @@ void rtw_coex_lps_notify(struct rtw_dev *rtwdev, u8 type) struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; - if (coex->stop_dm) + if (coex->manual_control || coex->stop_dm) return; if (type == COEX_LPS_ENABLE) { @@ -2211,7 +2211,7 @@ void rtw_coex_scan_notify(struct rtw_dev *rtwdev, u8 type) struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; - if (coex->stop_dm) + if (coex->manual_control || coex->stop_dm) return; coex->freeze = false; @@ -2239,7 +2239,7 @@ void rtw_coex_switchband_notify(struct rtw_dev *rtwdev, u8 type) { struct rtw_coex *coex = &rtwdev->coex; - if (coex->stop_dm) + if (coex->manual_control || coex->stop_dm) return; if (type == COEX_SWITCH_TO_5G) @@ -2255,7 +2255,7 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; - if (coex->stop_dm) + if (coex->manual_control || coex->stop_dm) return; rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_SCAN | @@ -2296,7 +2296,7 @@ void rtw_coex_media_status_notify(struct rtw_dev *rtwdev, u8 type) struct rtw_coex_stat *coex_stat = &coex->stat; u8 para[6] = {0}; - if (coex->stop_dm) + if (coex->manual_control || coex->stop_dm) return; if (type == COEX_MEDIA_CONNECT_5G) { diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c index 3852c4f0ac0b..5974a8ef8b34 100644 --- a/drivers/net/wireless/realtek/rtw88/debug.c +++ b/drivers/net/wireless/realtek/rtw88/debug.c @@ -775,7 +775,7 @@ static ssize_t rtw_debugfs_set_coex_enable(struct file *filp, } mutex_lock(&rtwdev->mutex); - coex->stop_dm = enable == 0; + coex->manual_control = enable == 0; mutex_unlock(&rtwdev->mutex); return count; @@ -788,7 +788,7 @@ static int rtw_debugfs_get_coex_enable(struct seq_file *m, void *v) struct rtw_coex *coex = &rtwdev->coex; seq_printf(m, "coex mechanism %s\n", - coex->stop_dm ? "disabled" : "enabled"); + coex->manual_control ? "disabled" : "enabled"); return 0; } diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index 8d11d56c83f2..632d14683b61 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1379,6 +1379,7 @@ struct rtw_coex { bool freeze; bool freerun; bool wl_rf_off; + bool manual_control; struct rtw_coex_stat stat; struct rtw_coex_dm dm; From 37a59b940fc61cd47ea178079d12060ea60f8239 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:05 +0800 Subject: [PATCH 098/180] rtw88: coex: modified for BT info notify Add counter to count BT info C2H command for debug usage. It could present the C2H channel situation. Fix BT IQK state decision condition for counting. The original condition is wrong, it would cause coexistence mechanism going to the wrong strategy. New format supports getting TDMA parameter from WL firmware, since coexistence needs current TDMA parameter to decide strategy. Remove unnecessary operations about scoreboard, it is not a must for current version. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-8-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 43 ++++++++++++----------- drivers/net/wireless/realtek/rtw88/main.h | 10 +++++- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 6de98414e3bf..c47771f7020a 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -2335,17 +2335,19 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; struct rtw_chip_info *chip = rtwdev->chip; + struct rtw_coex_dm *coex_dm = &coex->dm; u32 bt_relink_time; u8 i, rsp_source = 0, type; bool inq_page = false; rsp_source = buf[0] & 0xf; if (rsp_source >= COEX_BTINFO_SRC_MAX) - rsp_source = COEX_BTINFO_SRC_WL_FW; + return; + coex_stat->cnt_bt_info_c2h[rsp_source]++; if (rsp_source == COEX_BTINFO_SRC_BT_IQK) { coex_stat->bt_iqk_state = buf[1]; - if (coex_stat->bt_iqk_state == 1) + if (coex_stat->bt_iqk_state == 0) coex_stat->cnt_bt[COEX_CNT_BT_IQK]++; else if (coex_stat->bt_iqk_state == 2) coex_stat->cnt_bt[COEX_CNT_BT_IQKFAIL]++; @@ -2362,6 +2364,17 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) return; } + if (rsp_source == COEX_BTINFO_SRC_H2C60) { + for (i = 1; i <= COEX_WL_TDMA_PARA_LENGTH; i++) + coex_dm->fw_tdma_para[i - 1] = buf[i]; + return; + } + + if (rsp_source == COEX_BTINFO_SRC_WL_FW) { + rtw_coex_update_bt_link_info(rtwdev); + return; + } + if (rsp_source == COEX_BTINFO_SRC_BT_RSP || rsp_source == COEX_BTINFO_SRC_BT_ACT) { if (coex_stat->bt_disabled) { @@ -2373,19 +2386,16 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) } } - for (i = 0; i < length; i++) { - if (i < COEX_BTINFO_LENGTH_MAX) - coex_stat->bt_info_c2h[rsp_source][i] = buf[i]; - else - break; - } + if (length != COEX_BTINFO_LENGTH) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], Bt_info length = %d invalid!!\n", length); - if (rsp_source == COEX_BTINFO_SRC_WL_FW) { - rtw_coex_update_bt_link_info(rtwdev); - rtw_coex_run_coex(rtwdev, COEX_RSN_BTINFO); return; } + for (i = 0; i < COEX_BTINFO_LENGTH; i++) + coex_stat->bt_info_c2h[rsp_source][i] = buf[i]; + /* get the same info from bt, skip it */ if (coex_stat->bt_info_c2h[rsp_source][1] == coex_stat->bt_info_lb2 && coex_stat->bt_info_c2h[rsp_source][2] == coex_stat->bt_info_lb3 && @@ -2446,17 +2456,8 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) coex_stat->cnt_bt[COEX_CNT_BT_INQ]++; coex_stat->bt_page = ((coex_stat->bt_info_lb3 & BIT(7)) == BIT(7)); - if (coex_stat->bt_page) { + if (coex_stat->bt_page) coex_stat->cnt_bt[COEX_CNT_BT_PAGE]++; - if (coex_stat->wl_linkscan_proc || - coex_stat->wl_hi_pri_task1 || - coex_stat->wl_hi_pri_task2 || coex_stat->wl_gl_busy) - rtw_coex_write_scbd(rtwdev, COEX_SCBD_SCAN, true); - else - rtw_coex_write_scbd(rtwdev, COEX_SCBD_SCAN, false); - } else { - rtw_coex_write_scbd(rtwdev, COEX_SCBD_SCAN, false); - } /* unit: % (value-100 to translate to unit: dBm in coex info) */ if (chip->bt_rssi_type == COEX_BTRSSI_RATIO) { diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index 632d14683b61..97f75a99d0a4 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1241,6 +1241,8 @@ struct rtw_coex_rfe { bool wlg_at_btg; }; +#define COEX_WL_TDMA_PARA_LENGTH 5 + struct rtw_coex_dm { bool cur_ps_tdma_on; bool cur_wl_rx_low_gain_en; @@ -1260,6 +1262,7 @@ struct rtw_coex_dm { u32 cur_ant_pos_type; u32 cur_switch_status; u32 setting_tdma; + u8 fw_tdma_para[COEX_WL_TDMA_PARA_LENGTH]; }; #define COEX_BTINFO_SRC_WL_FW 0x0 @@ -1267,7 +1270,8 @@ struct rtw_coex_dm { #define COEX_BTINFO_SRC_BT_ACT 0x2 #define COEX_BTINFO_SRC_BT_IQK 0x3 #define COEX_BTINFO_SRC_BT_SCBD 0x4 -#define COEX_BTINFO_SRC_MAX 0x5 +#define COEX_BTINFO_SRC_H2C60 0x5 +#define COEX_BTINFO_SRC_MAX 0x6 #define COEX_INFO_FTP BIT(7) #define COEX_INFO_A2DP BIT(6) @@ -1278,6 +1282,7 @@ struct rtw_coex_dm { #define COEX_INFO_SCO_ESCO BIT(1) #define COEX_INFO_CONNECTION BIT(0) #define COEX_BTINFO_LENGTH_MAX 10 +#define COEX_BTINFO_LENGTH 7 struct rtw_coex_stat { bool bt_disabled; @@ -1364,6 +1369,9 @@ struct rtw_coex_stat { /* counters to record wifi states */ u32 cnt_wl[COEX_CNT_WL_MAX]; + /* counters to record bt c2h data */ + u32 cnt_bt_info_c2h[COEX_BTINFO_SRC_MAX]; + u32 darfrc; u32 darfrch; }; From 150ce8e34a45e6ebe1f3343b8a7bcce5bb9eab39 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:06 +0800 Subject: [PATCH 099/180] rtw88: coex: change the parameter for A2DP when WLAN connecting The original mechanism may cause A2DP glitch during WiFi connecting AP. Because the original TDMA may decrease too much A2DP slot. This patch add a timer and variable to let the case A2DP + WL_Connecting performed more well. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-9-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 26 ++++++++++++++++++++--- drivers/net/wireless/realtek/rtw88/coex.h | 1 + drivers/net/wireless/realtek/rtw88/main.c | 2 ++ drivers/net/wireless/realtek/rtw88/main.h | 2 ++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index c47771f7020a..777955d5ed1b 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -1544,10 +1544,10 @@ static void rtw_coex_action_bt_a2dp(struct rtw_dev *rtwdev) else table_case = 9; - if (coex_stat->wl_gl_busy) - tdma_case = 13; - else + if (coex_stat->wl_connecting || !coex_stat->wl_gl_busy) tdma_case = 14; + else + tdma_case = 13; } else { /* Non-Shared-Ant */ table_case = 112; @@ -2270,6 +2270,11 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) } else if (type == COEX_ASSOCIATE_START) { coex_stat->wl_hi_pri_task1 = true; coex_stat->cnt_wl[COEX_CNT_WL_CONNPKT] = 2; + coex_stat->wl_connecting = true; + ieee80211_queue_delayed_work(rtwdev->hw, + &coex->wl_connecting_work, 2 * HZ); + + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], 2G start\n"); /* Force antenna setup for no scan result issue */ rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_2G); @@ -2286,6 +2291,8 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) coex_stat->wl_hi_pri_task1 = false; coex->freeze = false; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], 2G finish\n"); + rtw_coex_run_coex(rtwdev, COEX_RSN_2GCONFINISH); } } @@ -2633,6 +2640,19 @@ void rtw_coex_bt_remain_work(struct work_struct *work) mutex_unlock(&rtwdev->mutex); } +void rtw_coex_wl_connecting_work(struct work_struct *work) +{ + struct rtw_dev *rtwdev = container_of(work, struct rtw_dev, + coex.wl_connecting_work.work); + struct rtw_coex_stat *coex_stat = &rtwdev->coex.stat; + + mutex_lock(&rtwdev->mutex); + coex_stat->wl_connecting = false; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], WL connecting stop!!\n"); + rtw_coex_run_coex(rtwdev, COEX_RSN_WLSTATUS); + mutex_unlock(&rtwdev->mutex); +} + #ifdef CONFIG_RTW88_DEBUGFS #define INFO_SIZE 80 diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h index e0d0be3f0dcf..712a3adb5d16 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.h +++ b/drivers/net/wireless/realtek/rtw88/coex.h @@ -366,6 +366,7 @@ void rtw_coex_bt_reenable_work(struct work_struct *work); void rtw_coex_defreeze_work(struct work_struct *work); void rtw_coex_wl_remain_work(struct work_struct *work); void rtw_coex_bt_remain_work(struct work_struct *work); +void rtw_coex_wl_connecting_work(struct work_struct *work); void rtw_coex_power_on_setting(struct rtw_dev *rtwdev); void rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only); diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 670202e3ff9e..6290ecc97f5b 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -1153,6 +1153,7 @@ void rtw_core_stop(struct rtw_dev *rtwdev) cancel_delayed_work_sync(&coex->defreeze_work); cancel_delayed_work_sync(&coex->wl_remain_work); cancel_delayed_work_sync(&coex->bt_remain_work); + cancel_delayed_work_sync(&coex->wl_connecting_work); mutex_lock(&rtwdev->mutex); @@ -1658,6 +1659,7 @@ int rtw_core_init(struct rtw_dev *rtwdev) INIT_DELAYED_WORK(&coex->defreeze_work, rtw_coex_defreeze_work); INIT_DELAYED_WORK(&coex->wl_remain_work, rtw_coex_wl_remain_work); INIT_DELAYED_WORK(&coex->bt_remain_work, rtw_coex_bt_remain_work); + INIT_DELAYED_WORK(&coex->wl_connecting_work, rtw_coex_wl_connecting_work); INIT_WORK(&rtwdev->c2h_work, rtw_c2h_work); INIT_WORK(&rtwdev->fw_recovery_work, rtw_fw_recovery_work); INIT_WORK(&rtwdev->ba_work, rtw_txq_ba_work); diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index 97f75a99d0a4..a3a687a63734 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1329,6 +1329,7 @@ struct rtw_coex_stat { bool wl_cck_lock; bool wl_cck_lock_pre; bool wl_cck_lock_ever; + bool wl_connecting; u32 bt_supported_version; u32 bt_supported_feature; @@ -1398,6 +1399,7 @@ struct rtw_coex { struct delayed_work defreeze_work; struct delayed_work wl_remain_work; struct delayed_work bt_remain_work; + struct delayed_work wl_connecting_work; }; #define DPK_RF_REG_NUM 7 From ec06c4adac960eb22a400cd7658e9da495fd8de4 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:07 +0800 Subject: [PATCH 100/180] rtw88: coex: update WLAN 5G AFH parameter for 8822b Adaptive Frequency Hopping(AFH) is a method of transmitting radio signals by rapidly changing the carrier frequency among many distinct frequencies, which can avoid interference. Add this feature to update AFH parameter for 8822b. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-10-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index c1a96c7fe67d..eeb0a658e712 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -2259,7 +2259,6 @@ static const struct coex_tdma_para tdma_nsant_8822b[] = { /* rssi in percentage % (dbm = % - 100) */ static const u8 wl_rssi_step_8822b[] = {60, 50, 44, 30}; static const u8 bt_rssi_step_8822b[] = {30, 30, 30, 30}; -static const struct coex_5g_afh_map afh_5g_8822b[] = { {0, 0, 0} }; /* wl_tx_dec_power, bt_tx_dec_power, wl_rx_gain, bt_rx_lna_constrain */ static const struct coex_rf_para rf_para_tx_8822b[] = { @@ -2280,6 +2279,27 @@ static const struct coex_rf_para rf_para_rx_8822b[] = { {1, 13, true, 1} }; +static const struct coex_5g_afh_map afh_5g_8822b[] = { + {120, 2, 4}, + {124, 8, 8}, + {128, 17, 8}, + {132, 26, 10}, + {136, 34, 8}, + {140, 42, 10}, + {144, 51, 8}, + {149, 62, 8}, + {153, 71, 10}, + {157, 77, 4}, + {118, 2, 4}, + {126, 12, 16}, + {134, 29, 16}, + {142, 46, 16}, + {151, 66, 16}, + {159, 76, 4}, + {122, 10, 20}, + {138, 37, 34}, + {155, 68, 20} +}; static_assert(ARRAY_SIZE(rf_para_tx_8822b) == ARRAY_SIZE(rf_para_rx_8822b)); static const u8 From 21020fc80d3bad1400cc0b7df347a5a67ce7ffe4 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:08 +0800 Subject: [PATCH 101/180] rtw88: coex: add debug message Since coexistence issue is related to WL/BT and each digital/analog/rf, and these issues are often critical with low failure rate, add more debugging information is helpful to clarify issues. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-11-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 409 ++++++++++++++++-- drivers/net/wireless/realtek/rtw88/coex.h | 25 +- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 2 + drivers/net/wireless/realtek/rtw88/rtw8822c.c | 4 + 4 files changed, 399 insertions(+), 41 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 777955d5ed1b..ad21fba48808 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -130,6 +130,9 @@ static void rtw_coex_wl_ccklock_action(struct rtw_dev *rtwdev) para[0] = COEX_H2C69_WL_LEAKAP; if (coex_stat->tdma_timer_base == 3 && coex_stat->wl_slot_extend) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], set h2c 0x69 opcode 12 to turn off 5ms WL slot extend!!\n"); + para[1] = PARA1_H2C69_DIS_5MS; /* disable 5ms extend */ rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); coex_stat->wl_slot_extend = false; @@ -144,13 +147,23 @@ static void rtw_coex_wl_ccklock_action(struct rtw_dev *rtwdev) else coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], 5ms WL slot extend cnt = %d!!\n", + coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND]); + if (coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] == 7) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], set h2c 0x69 opcode 12 to turn off 5ms WL slot extend!!\n"); + para[1] = PARA1_H2C69_DIS_5MS; rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); coex_stat->wl_slot_extend = false; coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; } } else if (!coex_stat->wl_slot_extend && coex_stat->wl_cck_lock) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], set h2c 0x69 opcode 12 to turn on 5ms WL slot extend!!\n"); + para[1] = PARA1_H2C69_EN_5MS; rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); coex_stat->wl_slot_extend = true; @@ -211,6 +224,9 @@ static void rtw_coex_wl_noisy_detect(struct rtw_dev *rtwdev) coex_stat->wl_noisy_level = 1; else coex_stat->wl_noisy_level = 0; + + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], wl_noisy_level = %d\n", + coex_stat->wl_noisy_level); } } @@ -234,6 +250,9 @@ static void rtw_coex_tdma_timer_base(struct rtw_dev *rtwdev, u8 type) rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): h2c_0x69 = 0x%x\n", + __func__, para[1]); + /* no 5ms_wl_slot_extend for 4-slot mode */ if (coex_stat->tdma_timer_base == 3) rtw_coex_wl_ccklock_action(rtwdev); @@ -307,6 +326,9 @@ static void rtw_coex_check_rfk(struct rtw_dev *rtwdev) if (coex_rfe->wlg_at_btg && chip->scbd_support && coex_stat->bt_iqk_state != 0xff) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], (Before Ant Setup) Delay by IQK\n"); + wait_cnt = COEX_RFK_TIMEOUT / COEX_MIN_DELAY; do { /* BT RFK */ @@ -334,6 +356,8 @@ static void rtw_coex_query_bt_info(struct rtw_dev *rtwdev) if (coex_stat->bt_disabled) return; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_fw_query_bt_info(rtwdev); } @@ -357,7 +381,8 @@ static void rtw_coex_monitor_bt_enable(struct rtw_dev *rtwdev) } if (coex_stat->bt_disabled != bt_disabled) { - rtw_dbg(rtwdev, RTW_DBG_COEX, "coex: BT state changed (%d) -> (%d)\n", + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], BT state changed (%d) -> (%d)\n", coex_stat->bt_disabled, bt_disabled); coex_stat->bt_disabled = bt_disabled; @@ -540,6 +565,23 @@ static bool rtw_coex_set_lna_constrain_level(struct rtw_dev *rtwdev, return ret; } +#define case_BTSTATUS(src) \ + case COEX_BTSTATUS_##src: return #src + +static const char *rtw_coex_get_bt_status_string(u8 bt_status) +{ + switch (bt_status) { + case_BTSTATUS(NCON_IDLE); + case_BTSTATUS(CON_IDLE); + case_BTSTATUS(INQ_PAGE); + case_BTSTATUS(ACL_BUSY); + case_BTSTATUS(SCO_BUSY); + case_BTSTATUS(ACL_SCO_BUSY); + default: + return "Unknown"; + } +} + static void rtw_coex_update_bt_link_info(struct rtw_dev *rtwdev) { struct rtw_coex *coex = &rtwdev->coex; @@ -644,7 +686,8 @@ static void rtw_coex_update_bt_link_info(struct rtw_dev *rtwdev) coex_stat->cnt_bt[COEX_CNT_BT_INFOUPDATE]++; - rtw_dbg(rtwdev, RTW_DBG_COEX, "coex: bt status(%d)\n", coex_dm->bt_status); + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(), %s!!!\n", __func__, + rtw_coex_get_bt_status_string(coex_dm->bt_status)); } static void rtw_coex_update_wl_ch_info(struct rtw_dev *rtwdev, u8 type) @@ -664,6 +707,8 @@ static void rtw_coex_update_wl_ch_info(struct rtw_dev *rtwdev, u8 type) if (center_chan == 0 || (efuse->share_ant && center_chan <= 14)) { link = 0; + center_chan = 0; + bw = 0; } else if (center_chan <= 14) { link = 0x1; @@ -687,6 +732,9 @@ static void rtw_coex_update_wl_ch_info(struct rtw_dev *rtwdev, u8 type) coex_dm->wl_ch_info[2] = bw; rtw_fw_wl_ch_info(rtwdev, link, center_chan, bw); + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s: para[0:2] = 0x%x 0x%x 0x%x\n", __func__, link, + center_chan, bw); } static void rtw_coex_set_bt_tx_power(struct rtw_dev *rtwdev, u8 bt_pwr_dec_lvl) @@ -719,6 +767,8 @@ static void rtw_coex_set_bt_rx_gain(struct rtw_dev *rtwdev, u8 bt_lna_lvl) } else { rtw_coex_write_scbd(rtwdev, COEX_SCBD_RXGAIN, false); } + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): bt_rx_LNA_level = %d\n", + __func__, bt_lna_lvl); } static void rtw_coex_set_rf_para(struct rtw_dev *rtwdev, @@ -800,6 +850,10 @@ static void rtw_coex_set_table(struct rtw_dev *rtwdev, u32 table0, u32 table1) rtw_write32(rtwdev, REG_BT_COEX_TABLE0, table0); rtw_write32(rtwdev, REG_BT_COEX_TABLE1, table1); rtw_write32(rtwdev, REG_BT_COEX_BRK_TABLE, DEF_BRK_TABLE_VAL); + + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s(): 0x6c0 = %x, 0x6c4 = %x\n", __func__, table0, + table1); } static void rtw_coex_table(struct rtw_dev *rtwdev, u8 type) @@ -811,6 +865,8 @@ static void rtw_coex_table(struct rtw_dev *rtwdev, u8 type) coex_dm->cur_table = type; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], Coex_Table - %d\n", type); + if (efuse->share_ant) { if (type < chip->table_sant_num) rtw_coex_set_table(rtwdev, @@ -848,7 +904,8 @@ static void rtw_coex_power_save_state(struct rtw_dev *rtwdev, u8 ps_type, case COEX_PS_WIFI_NATIVE: /* recover to original 32k low power setting */ coex_stat->wl_force_lps_ctrl = false; - + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s(): COEX_PS_WIFI_NATIVE\n", __func__); rtw_leave_lps(rtwdev); break; case COEX_PS_LPS_OFF: @@ -857,6 +914,8 @@ static void rtw_coex_power_save_state(struct rtw_dev *rtwdev, u8 ps_type, rtw_fw_coex_tdma_type(rtwdev, 0x8, 0, 0, 0, 0); rtw_leave_lps(rtwdev); + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s(): COEX_PS_LPS_OFF\n", __func__); break; default: break; @@ -873,6 +932,9 @@ static void rtw_coex_set_tdma(struct rtw_dev *rtwdev, u8 byte1, u8 byte2, bool ap_enable = false; if (ap_enable && (byte1 & BIT(4) && !(byte1 & BIT(5)))) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): AP mode\n", + __func__); + byte1 &= ~BIT(4); byte1 |= BIT(5); @@ -882,12 +944,20 @@ static void rtw_coex_set_tdma(struct rtw_dev *rtwdev, u8 byte1, u8 byte2, ps_type = COEX_PS_WIFI_NATIVE; rtw_coex_power_save_state(rtwdev, ps_type, 0x0, 0x0); } else if (byte1 & BIT(4) && !(byte1 & BIT(5))) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s(): Force LPS (byte1 = 0x%x)\n", __func__, + byte1); + if (chip->pstdma_type == COEX_PSTDMA_FORCE_LPSOFF) ps_type = COEX_PS_LPS_OFF; else ps_type = COEX_PS_LPS_ON; rtw_coex_power_save_state(rtwdev, ps_type, 0x50, 0x4); } else { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s(): native power save (byte1 = 0x%x)\n", + __func__, byte1); + ps_type = COEX_PS_WIFI_NATIVE; rtw_coex_power_save_state(rtwdev, ps_type, 0x0, 0x0); } @@ -921,11 +991,14 @@ static void rtw_coex_tdma(struct rtw_dev *rtwdev, bool force, u32 tcase) turn_on = (type == 0 || type == 100) ? false : true; - if (!force) { - if (turn_on == coex_dm->cur_ps_tdma_on && - type == coex_dm->cur_ps_tdma) { - return; - } + if (!force && turn_on == coex_dm->cur_ps_tdma_on && + type == coex_dm->cur_ps_tdma) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], Skip TDMA because no change TDMA(%s, %d)\n", + (coex_dm->cur_ps_tdma_on ? "on" : "off"), + coex_dm->cur_ps_tdma); + + return; } /* enable TBTT interrupt */ @@ -964,7 +1037,7 @@ static void rtw_coex_tdma(struct rtw_dev *rtwdev, bool force, u32 tcase) coex_dm->cur_ps_tdma_on = turn_on; coex_dm->cur_ps_tdma = type; - rtw_dbg(rtwdev, RTW_DBG_COEX, "coex: coex tdma type (%d)\n", type); + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], coex tdma type (%d)\n", type); } static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) @@ -983,8 +1056,14 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) /* avoid switch coex_ctrl_owner during BT IQK */ rtw_coex_check_rfk(rtwdev); + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], coex_stat->bt_disabled = 0x%x\n", + coex_stat->bt_disabled); + switch (phase) { case COEX_SET_ANT_POWERON: + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s() - PHASE_COEX_POWERON\n", __func__); /* set path control owner to BT at power-on */ if (coex_stat->bt_disabled) rtw_coex_coex_ctrl_owner(rtwdev, true); @@ -995,6 +1074,8 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) pos_type = COEX_SWITCH_TO_BT; break; case COEX_SET_ANT_INIT: + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s() - PHASE_COEX_INIT\n", __func__); if (coex_stat->bt_disabled) { /* set GNT_BT to SW low */ rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_SW_LOW); @@ -1016,6 +1097,8 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) pos_type = COEX_SWITCH_TO_BT; break; case COEX_SET_ANT_WONLY: + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s() - PHASE_WLANONLY_INIT\n", __func__); /* set GNT_BT to SW Low */ rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_SW_LOW); @@ -1029,6 +1112,8 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) pos_type = COEX_SWITCH_TO_WLG; break; case COEX_SET_ANT_WOFF: + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s() - PHASE_WLAN_OFF\n", __func__); /* set path control owner to BT */ rtw_coex_coex_ctrl_owner(rtwdev, false); @@ -1036,6 +1121,8 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) pos_type = COEX_SWITCH_TO_NOCARE; break; case COEX_SET_ANT_2G: + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s() - PHASE_2G_RUNTIME\n", __func__); /* set GNT_BT to PTA */ rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_HW_PTA); @@ -1049,6 +1136,9 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) pos_type = COEX_SWITCH_TO_NOCARE; break; case COEX_SET_ANT_5G: + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s() - PHASE_5G_RUNTIME\n", __func__); + /* set GNT_BT to PTA */ rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_SW_HIGH); @@ -1062,6 +1152,9 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) pos_type = COEX_SWITCH_TO_WLA; break; case COEX_SET_ANT_2G_FREERUN: + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s() - PHASE_2G_FREERUN\n", __func__); + /* set GNT_BT to SW high */ rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_SW_HIGH); @@ -1075,6 +1168,8 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) pos_type = COEX_SWITCH_TO_WLG_BT; break; case COEX_SET_ANT_2G_WLBT: + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s() - PHASE_2G_WLBT\n", __func__); /* set GNT_BT to HW PTA */ rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_HW_PTA); @@ -1096,6 +1191,53 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) rtw_coex_set_ant_switch(rtwdev, ctrl_type, pos_type); } +#define case_ALGO(src) \ + case COEX_ALGO_##src: return #src + +static const char *rtw_coex_get_algo_string(u8 algo) +{ + switch (algo) { + case_ALGO(NOPROFILE); + case_ALGO(HFP); + case_ALGO(HID); + case_ALGO(A2DP); + case_ALGO(PAN); + case_ALGO(A2DP_HID); + case_ALGO(A2DP_PAN); + case_ALGO(PAN_HID); + case_ALGO(A2DP_PAN_HID); + default: + return "Unknown"; + } +} + +#define case_BT_PROFILE(src) \ + case BPM_##src: return #src + +static const char *rtw_coex_get_bt_profile_string(u8 bt_profile) +{ + switch (bt_profile) { + case_BT_PROFILE(NOPROFILE); + case_BT_PROFILE(HFP); + case_BT_PROFILE(HID); + case_BT_PROFILE(A2DP); + case_BT_PROFILE(PAN); + case_BT_PROFILE(HID_HFP); + case_BT_PROFILE(A2DP_HFP); + case_BT_PROFILE(A2DP_HID); + case_BT_PROFILE(A2DP_HID_HFP); + case_BT_PROFILE(PAN_HFP); + case_BT_PROFILE(PAN_HID); + case_BT_PROFILE(PAN_HID_HFP); + case_BT_PROFILE(PAN_A2DP); + case_BT_PROFILE(PAN_A2DP_HFP); + case_BT_PROFILE(PAN_A2DP_HID); + case_BT_PROFILE(PAN_A2DP_HID_HFP); + default: + return "Unknown"; + } +} + static u8 rtw_coex_algorithm(struct rtw_dev *rtwdev) { struct rtw_coex *coex = &rtwdev->coex; @@ -1156,6 +1298,10 @@ static u8 rtw_coex_algorithm(struct rtw_dev *rtwdev) break; } + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], BT Profile = %s => Algorithm = %s\n", + rtw_coex_get_bt_profile_string(profile_map), + rtw_coex_get_algo_string(algorithm)); return algorithm; } @@ -1165,6 +1311,7 @@ static void rtw_coex_action_coex_all_off(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); if (efuse->share_ant) { @@ -1190,6 +1337,8 @@ static void rtw_coex_action_freerun(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 level = 0; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + if (efuse->share_ant) return; @@ -1229,6 +1378,8 @@ static void rtw_coex_action_bt_whql_test(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1252,6 +1403,8 @@ static void rtw_coex_action_bt_relink(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1279,6 +1432,7 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) struct rtw_coex_rfe *coex_rfe = &coex->rfe; u8 table_case = 0xff, tdma_case = 0xff; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); if (coex_rfe->ant_switch_with_bt && @@ -1343,6 +1497,7 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 slot_type = 0; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1353,6 +1508,8 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) if (efuse->share_ant) { /* Shared-Ant */ if (wl_hi_pri) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], bt inq/page + wifi hi-pri task\n"); table_case = 15; if (coex_stat->bt_profile_num > 0) tdma_case = 10; @@ -1377,15 +1534,21 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) tdma_case = 26; } } else if (coex_stat->wl_connected) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], bt inq/page + wifi connected\n"); table_case = 9; tdma_case = 27; } else { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], bt inq/page + wifi not-connected\n"); table_case = 1; tdma_case = 0; } } else { /* Non_Shared-Ant */ if (wl_hi_pri) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], bt inq/page + wifi hi-pri task\n"); table_case = 113; if (coex_stat->bt_a2dp_exist && !coex_stat->bt_pan_exist) @@ -1400,15 +1563,19 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) table_case = 114; tdma_case = 121; } else if (coex_stat->wl_connected) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], bt inq/page + wifi connected\n"); table_case = 100; tdma_case = 100; } else { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], bt inq/page + wifi not-connected\n"); table_case = 101; tdma_case = 100; } } - rtw_dbg(rtwdev, RTW_DBG_COEX, "coex: wifi hi(%d), bt page(%d)\n", + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], wifi hi(%d), bt page(%d)\n", wl_hi_pri, coex_stat->bt_page); rtw_coex_table(rtwdev, table_case); @@ -1423,6 +1590,7 @@ static void rtw_coex_action_bt_hfp(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1459,6 +1627,7 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 wl_bw; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1532,6 +1701,8 @@ static void rtw_coex_action_bt_a2dp(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 slot_type = 0; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1571,6 +1742,8 @@ static void rtw_coex_action_bt_a2dpsink(struct rtw_dev *rtwdev) u8 table_case, tdma_case; bool ap_enable = false; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1607,6 +1780,7 @@ static void rtw_coex_action_bt_pan(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1645,6 +1819,7 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 slot_type = 0; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1686,9 +1861,10 @@ static void rtw_coex_action_bt_a2dp_pan(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); - if (efuse->share_ant) { /* Shared-Ant */ if (coex_stat->wl_gl_busy && @@ -1723,6 +1899,8 @@ static void rtw_coex_action_bt_pan_hid(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1756,6 +1934,7 @@ static void rtw_coex_action_bt_a2dp_pan_hid(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1787,6 +1966,8 @@ static void rtw_coex_action_wl_under5g(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_5G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1812,6 +1993,7 @@ static void rtw_coex_action_wl_only(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1839,6 +2021,8 @@ static void rtw_coex_action_wl_native_lps(struct rtw_dev *rtwdev) if (coex->under_5g) return; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1865,6 +2049,7 @@ static void rtw_coex_action_wl_linkscan(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 slot_type = 0; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1899,6 +2084,7 @@ static void rtw_coex_action_wl_not_connected(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); @@ -1932,6 +2118,8 @@ static void rtw_coex_action_wl_connected(struct rtw_dev *rtwdev) return; } + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + algorithm = rtw_coex_algorithm(rtwdev); switch (algorithm) { @@ -1982,20 +2170,38 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason) coex_dm->reason = reason; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): reason = %d\n", __func__, + reason); + /* update wifi_link_info_ext variable */ rtw_coex_update_wl_link_info(rtwdev, reason); rtw_coex_monitor_bt_enable(rtwdev); - if (coex->manual_control || coex->stop_dm) + if (coex->manual_control) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], return for Manual CTRL!!\n"); return; + } - if (coex_stat->wl_under_ips) + if (coex->stop_dm) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], return for Stop Coex DM!!\n"); return; + } + + if (coex_stat->wl_under_ips) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], return for wifi is under IPS!!\n"); + return; + } if (coex->freeze && coex_dm->reason == COEX_RSN_BTINFO && - !coex_stat->bt_setup_link) + !coex_stat->bt_setup_link) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], return for coex_freeze!!\n"); return; + } coex_stat->cnt_wl[COEX_CNT_WL_COEXRUN]++; coex->freerun = false; @@ -2007,6 +2213,7 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason) goto exit; } + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], WiFi is single-port 2G!!\n"); coex_stat->wl_coex_mode = COEX_WLINK_2G1PORT; rtw_coex_write_scbd(rtwdev, COEX_SCBD_FIX2M, false); if (coex_stat->bt_disabled) { @@ -2085,6 +2292,8 @@ static void __rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only) { struct rtw_coex *coex = &rtwdev->coex; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + rtw_coex_init_coex_var(rtwdev); rtw_coex_monitor_bt_enable(rtwdev); rtw_coex_set_rfe_type(rtwdev); @@ -2104,6 +2313,9 @@ static void __rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only) rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_WOFF); rtw_coex_write_scbd(rtwdev, COEX_SCBD_ALL, false); coex->stop_dm = true; + + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): RF Off\n", + __func__); } else if (wifi_only) { rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_WONLY); rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_SCAN, @@ -2127,6 +2339,8 @@ void rtw_coex_power_on_setting(struct rtw_dev *rtwdev) { struct rtw_coex *coex = &rtwdev->coex; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + coex->stop_dm = true; coex->wl_rf_off = false; @@ -2158,6 +2372,8 @@ void rtw_coex_ips_notify(struct rtw_dev *rtwdev, u8 type) return; if (type == COEX_IPS_ENTER) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], IPS ENTER notify\n"); + coex_stat->wl_under_ips = true; /* for lps off */ @@ -2166,8 +2382,9 @@ void rtw_coex_ips_notify(struct rtw_dev *rtwdev, u8 type) rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_WOFF); rtw_coex_action_coex_all_off(rtwdev); } else if (type == COEX_IPS_LEAVE) { - rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_ONOFF, true); + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], IPS LEAVE notify\n"); + rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_ONOFF, true); /* run init hw config (exclude wifi only) */ __rtw_coex_init_hw_config(rtwdev, false); @@ -2184,6 +2401,8 @@ void rtw_coex_lps_notify(struct rtw_dev *rtwdev, u8 type) return; if (type == COEX_LPS_ENABLE) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], LPS ENABLE notify\n"); + coex_stat->wl_under_lps = true; if (coex_stat->wl_force_lps_ctrl) { @@ -2196,6 +2415,8 @@ void rtw_coex_lps_notify(struct rtw_dev *rtwdev, u8 type) rtw_coex_run_coex(rtwdev, COEX_RSN_LPS); } } else if (type == COEX_LPS_DISABLE) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], LPS DISABLE notify\n"); + coex_stat->wl_under_lps = false; /* for lps off */ @@ -2221,9 +2442,15 @@ void rtw_coex_scan_notify(struct rtw_dev *rtwdev, u8 type) COEX_SCBD_ONOFF, true); if (type == COEX_SCAN_START_5G) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], SCAN START notify (5G)\n"); + rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_5G); rtw_coex_run_coex(rtwdev, COEX_RSN_5GSCANSTART); } else if ((type == COEX_SCAN_START_2G) || (type == COEX_SCAN_START)) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], SCAN START notify (2G)\n"); + coex_stat->wl_hi_pri_task2 = true; /* Force antenna setup for no scan result issue */ @@ -2242,6 +2469,17 @@ void rtw_coex_switchband_notify(struct rtw_dev *rtwdev, u8 type) if (coex->manual_control || coex->stop_dm) return; + if (type == COEX_SWITCH_TO_5G) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): TO_5G\n", + __func__); + } else if (type == COEX_SWITCH_TO_24G_NOFORSCAN) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s(): TO_24G_NOFORSCAN\n", __func__); + } else { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): TO_2G\n", + __func__); + } + if (type == COEX_SWITCH_TO_5G) rtw_coex_run_coex(rtwdev, COEX_RSN_5GSWITCHBAND); else if (type == COEX_SWITCH_TO_24G_NOFORSCAN) @@ -2262,9 +2500,15 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) COEX_SCBD_ONOFF, true); if (type == COEX_ASSOCIATE_5G_START) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): 5G start\n", + __func__); + rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_5G); rtw_coex_run_coex(rtwdev, COEX_RSN_5GCONSTART); } else if (type == COEX_ASSOCIATE_5G_FINISH) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): 5G finish\n", + __func__); + rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_5G); rtw_coex_run_coex(rtwdev, COEX_RSN_5GCONFINISH); } else if (type == COEX_ASSOCIATE_START) { @@ -2274,8 +2518,8 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) ieee80211_queue_delayed_work(rtwdev->hw, &coex->wl_connecting_work, 2 * HZ); - rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], 2G start\n"); - + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): 2G start\n", + __func__); /* Force antenna setup for no scan result issue */ rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_2G); @@ -2291,8 +2535,8 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) coex_stat->wl_hi_pri_task1 = false; coex->freeze = false; - rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], 2G finish\n"); - + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): 2G finish\n", + __func__); rtw_coex_run_coex(rtwdev, COEX_RSN_2GCONFINISH); } } @@ -2307,11 +2551,15 @@ void rtw_coex_media_status_notify(struct rtw_dev *rtwdev, u8 type) return; if (type == COEX_MEDIA_CONNECT_5G) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): 5G\n", __func__); + rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE, true); rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_5G); rtw_coex_run_coex(rtwdev, COEX_RSN_5GMEDIA); } else if (type == COEX_MEDIA_CONNECT) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): 2G\n", __func__); + rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE, true); /* Force antenna setup for no scan result issue */ @@ -2328,9 +2576,9 @@ void rtw_coex_media_status_notify(struct rtw_dev *rtwdev, u8 type) rtw_coex_run_coex(rtwdev, COEX_RSN_2GMEDIA); } else { rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE, false); - + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): disconnect!!\n", + __func__); rtw_coex_set_wl_pri_mask(rtwdev, COEX_WLPRI_RX_CCK, 0); - rtw_coex_run_coex(rtwdev, COEX_RSN_MEDIADISCON); } @@ -2359,10 +2607,18 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) else if (coex_stat->bt_iqk_state == 2) coex_stat->cnt_bt[COEX_CNT_BT_IQKFAIL]++; + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], BT IQK by bt_info, data0 = 0x%02x\n", + buf[1]); + return; } if (rsp_source == COEX_BTINFO_SRC_BT_SCBD) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], BT Scoreboard change notify by WL FW c2h, 0xaa = 0x%02x, 0xab = 0x%02x\n", + buf[1], buf[2]); + rtw_coex_monitor_bt_enable(rtwdev); if (coex_stat->bt_disabled != coex_stat->bt_disabled_pre) { coex_stat->bt_disabled_pre = coex_stat->bt_disabled; @@ -2372,12 +2628,19 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) } if (rsp_source == COEX_BTINFO_SRC_H2C60) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], H2C 0x60 content replied by WL FW: H2C_0x60 = [%02x %02x %02x %02x %02x]\n", + buf[1], buf[2], buf[3], buf[4], buf[5]); + for (i = 1; i <= COEX_WL_TDMA_PARA_LENGTH; i++) coex_dm->fw_tdma_para[i - 1] = buf[i]; return; } if (rsp_source == COEX_BTINFO_SRC_WL_FW) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], bt_info reply by WL FW\n"); + rtw_coex_update_bt_link_info(rtwdev); return; } @@ -2390,6 +2653,8 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) ieee80211_queue_delayed_work(rtwdev->hw, &coex->bt_reenable_work, 15 * HZ); + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], BT enable detected by bt_info\n"); } } @@ -2400,6 +2665,10 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) return; } + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], Bt_info[%d], len=%d, data=[%02x %02x %02x %02x %02x %02x]\n", + buf[0], length, buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); + for (i = 0; i < COEX_BTINFO_LENGTH; i++) coex_stat->bt_info_c2h[rsp_source][i] = buf[i]; @@ -2409,8 +2678,11 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) coex_stat->bt_info_c2h[rsp_source][3] == coex_stat->bt_info_hb0 && coex_stat->bt_info_c2h[rsp_source][4] == coex_stat->bt_info_hb1 && coex_stat->bt_info_c2h[rsp_source][5] == coex_stat->bt_info_hb2 && - coex_stat->bt_info_c2h[rsp_source][6] == coex_stat->bt_info_hb3) + coex_stat->bt_info_c2h[rsp_source][6] == coex_stat->bt_info_hb3) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], Return because Btinfo duplicate!!\n"); return; + } coex_stat->bt_info_lb2 = coex_stat->bt_info_c2h[rsp_source][1]; coex_stat->bt_info_lb3 = coex_stat->bt_info_c2h[rsp_source][2]; @@ -2492,6 +2764,9 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) ieee80211_queue_delayed_work(rtwdev->hw, &coex->bt_relink_work, bt_relink_time); + + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], Re-Link start in BT info!!\n"); } if (coex_stat->bt_info_hb1 & BIT(3)) @@ -2504,7 +2779,10 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) coex_stat->bt_multi_link = ((coex_stat->bt_info_hb1 & BIT(7)) == BIT(7)); /* resend wifi info to bt, it is reset and lost the info */ - if ((coex_stat->bt_info_hb1 & BIT(1))) { + if (coex_stat->bt_info_hb1 & BIT(1)) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], BT Re-init, send wifi BW & Chnl to BT!!\n"); + if (coex_stat->wl_connected) type = COEX_MEDIA_CONNECT; else @@ -2514,8 +2792,11 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) /* if ignore_wlan_act && not set_up_link */ if ((coex_stat->bt_info_hb1 & BIT(3)) && - (!(coex_stat->bt_info_hb1 & BIT(2)))) + (!(coex_stat->bt_info_hb1 & BIT(2)))) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"); rtw_coex_ignore_wlan_act(rtwdev, false); + } coex_stat->bt_opp_exist = ((coex_stat->bt_info_hb2 & BIT(0)) == BIT(0)); if (coex_stat->bt_info_hb2 & BIT(1)) @@ -2548,6 +2829,9 @@ void rtw_coex_wl_fwdbginfo_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) u8 val; int i; + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], WiFi Fw Dbg info = %8ph (len = %d)\n", + buf, length); if (WARN(length < 8, "invalid wl info c2h length\n")) return; @@ -2941,6 +3225,19 @@ static void rtw_coex_vif_stat_iter(void *data, u8 *mac, &sta_iter_data); } +#define case_WLINK(src) \ + case COEX_WLINK_##src: return #src + +static const char *rtw_coex_get_wl_coex_mode(u8 coex_wl_link_mode) +{ + switch (coex_wl_link_mode) { + case_WLINK(2G1PORT); + case_WLINK(5G); + default: + return "Unknown"; + } +} + void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) { struct rtw_chip_info *chip = rtwdev->chip; @@ -2989,9 +3286,24 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) coex_stat->bt_mailbox_reply = true; } + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); seq_printf(m, "**********************************************\n"); seq_printf(m, "\t\tBT Coexist info %x\n", chip->id); seq_printf(m, "**********************************************\n"); + + if (coex->manual_control) { + seq_puts(m, "============[Under Manual Control]============\n"); + seq_puts(m, "==========================================\n"); + + } else if (coex->stop_dm) { + seq_puts(m, "============[Coex is STOPPED]============\n"); + seq_puts(m, "==========================================\n"); + + } else if (coex->freeze) { + seq_puts(m, "============[coex_freeze]============\n"); + seq_puts(m, "==========================================\n"); + } + seq_printf(m, "%-40s = %s/ %d\n", "Mech/ RFE", efuse->share_ant ? "Shared" : "Non-Shared", @@ -3086,20 +3398,41 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) vif_iter_data.file = m; rtw_iterate_vifs_atomic(rtwdev, rtw_coex_vif_stat_iter, &vif_iter_data); - seq_printf(m, "**********************************************\n"); - seq_printf(m, "\t\tMechanism\n"); - seq_printf(m, "**********************************************\n"); - seq_printf(m, "%-40s = %5ph (case-%d)\n", - "TDMA", - coex_dm->ps_tdma_para, coex_dm->cur_ps_tdma); - seq_printf(m, "%-40s = %d\n", - "Timer base", coex_stat->tdma_timer_base); + if (coex->manual_control) { + seq_printf(m, "**********************************************\n"); + seq_printf(m, "\t\tMechanism (Under Manual)\n"); + seq_printf(m, "**********************************************\n"); + seq_printf(m, "%-40s = %5ph\n", + "TDMA Now", + coex_dm->fw_tdma_para); + } else { + seq_printf(m, "**********************************************\n"); + seq_printf(m, "\t\tMechanism\n"); + seq_printf(m, "**********************************************\n"); + seq_printf(m, "%-40s = %5ph (case-%d)\n", + "TDMA", + coex_dm->ps_tdma_para, coex_dm->cur_ps_tdma); + } + seq_printf(m, "%-40s = %s/ %s/ %d\n", + "Coex Mode/Free Run/Timer base", + rtw_coex_get_wl_coex_mode(coex_stat->wl_coex_mode), + coex->freerun ? "Yes" : "No", + coex_stat->tdma_timer_base); seq_printf(m, "%-40s = %d/ 0x%08x/ 0x%08x/ 0x%08x\n", "Table/ 0x6c0/ 0x6c4/ 0x6c8", coex_dm->cur_table, wl_reg_6c0, wl_reg_6c4, wl_reg_6c8); - seq_printf(m, "%-40s = 0x%08x/ 0x%08x/ reason (%s)\n", - "0x778/ 0x6cc/ Reason", - wl_reg_778, wl_reg_6cc, rtw_coex_get_reason_string(reason)); + seq_printf(m, "%-40s = 0x%08x/ 0x%08x/ %d/ reason (%s)\n", + "0x778/ 0x6cc/ Run Count/ Reason", + wl_reg_778, wl_reg_6cc, + coex_stat->cnt_wl[COEX_CNT_WL_COEXRUN], + rtw_coex_get_reason_string(reason)); + seq_printf(m, "%-40s = %3ph\n", + "AFH Map to BT", + coex_dm->wl_ch_info); + seq_printf(m, "%-40s = %s/ %d\n", + "AntDiv/ BtCtrlLPS/ g_busy", + coex_stat->wl_force_lps_ctrl ? "On" : "Off", + coex_stat->wl_gl_busy); seq_printf(m, "%-40s = %u/ %u/ %u/ %u/ %u\n", "Null All/ Retry/ Ack/ BT Empty/ BT Late", coex_stat->wl_fw_dbg_info[1], coex_stat->wl_fw_dbg_info[2], @@ -3111,6 +3444,12 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) coex_stat->wl_fw_dbg_info[7], coex_stat->wl_slot_extend ? "Yes" : "No", coex_stat->cnt_wl[COEX_CNT_WL_FW_NOTIFY]); + seq_printf(m, "%-40s = %d/ %d/ %s/ %d\n", + "WL_TxPw/ BT_TxPw/ WL_Rx/ BT_LNA_Lvl", + coex_dm->cur_wl_pwr_lvl, + coex_dm->cur_bt_pwr_lvl, + coex_dm->cur_wl_rx_low_gain_en ? "On" : "Off", + coex_dm->cur_bt_lna_lvl); seq_printf(m, "**********************************************\n"); seq_printf(m, "\t\tHW setting\n"); diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h index 712a3adb5d16..9b305fc6c984 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.h +++ b/drivers/net/wireless/realtek/rtw88/coex.h @@ -5,12 +5,6 @@ #ifndef __RTW_COEX_H__ #define __RTW_COEX_H__ -/* BT profile map bit definition */ -#define BPM_HFP BIT(0) -#define BPM_HID BIT(1) -#define BPM_A2DP BIT(2) -#define BPM_PAN BIT(3) - #define COEX_RESP_ACK_BY_WL_FW 0x1 #define COEX_REQUEST_TIMEOUT msecs_to_jiffies(10) @@ -147,6 +141,25 @@ enum coex_algorithm { COEX_ALGO_MAX }; +enum coex_bt_profile { + BPM_NOPROFILE = 0, + BPM_HFP = BIT(0), + BPM_HID = BIT(1), + BPM_A2DP = BIT(2), + BPM_PAN = BIT(3), + BPM_HID_HFP = BPM_HID | BPM_HFP, + BPM_A2DP_HFP = BPM_A2DP | BPM_HFP, + BPM_A2DP_HID = BPM_A2DP | BPM_HID, + BPM_A2DP_HID_HFP = BPM_A2DP | BPM_HID | BPM_HFP, + BPM_PAN_HFP = BPM_PAN | BPM_HFP, + BPM_PAN_HID = BPM_PAN | BPM_HID, + BPM_PAN_HID_HFP = BPM_PAN | BPM_HID | BPM_HFP, + BPM_PAN_A2DP = BPM_PAN | BPM_A2DP, + BPM_PAN_A2DP_HFP = BPM_PAN | BPM_A2DP | BPM_HFP, + BPM_PAN_A2DP_HID = BPM_PAN | BPM_A2DP | BPM_HID, + BPM_PAN_A2DP_HID_HFP = BPM_PAN | BPM_A2DP | BPM_HID | BPM_HFP, +}; + enum coex_wl_link_mode { COEX_WLINK_2G1PORT = 0x0, COEX_WLINK_5G = 0x3, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index eeb0a658e712..9c73937c9dde 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -1341,6 +1341,7 @@ static void rtw8822b_coex_cfg_wl_rx_gain(struct rtw_dev *rtwdev, bool low_gain) coex_dm->cur_wl_rx_low_gain_en = low_gain; if (coex_dm->cur_wl_rx_low_gain_en) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], Hi-Li Table On!\n"); for (i = 0; i < ARRAY_SIZE(wl_rx_low_gain_on); i++) rtw_write32(rtwdev, REG_RX_GAIN_EN, wl_rx_low_gain_on[i]); @@ -1350,6 +1351,7 @@ static void rtw8822b_coex_cfg_wl_rx_gain(struct rtw_dev *rtwdev, bool low_gain) rtw_write_rf(rtwdev, RF_PATH_B, RF_RCKD, 0x2, 0x1); rtw_write_rf(rtwdev, RF_PATH_B, RF_RCK, 0x3f, 0x3f); } else { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], Hi-Li Table Off!\n"); for (i = 0; i < ARRAY_SIZE(wl_rx_low_gain_off); i++) rtw_write32(rtwdev, 0x81c, wl_rx_low_gain_off[i]); diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index 965b77645f2e..3313f18838c1 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -2274,6 +2274,8 @@ static void rtw8822c_coex_cfg_wl_rx_gain(struct rtw_dev *rtwdev, bool low_gain) coex_dm->cur_wl_rx_low_gain_en = low_gain; if (coex_dm->cur_wl_rx_low_gain_en) { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], Hi-Li Table On!\n"); + /* set Rx filter corner RCK offset */ rtw_write_rf(rtwdev, RF_PATH_A, RF_RCKD, RFREG_MASK, 0x22); rtw_write_rf(rtwdev, RF_PATH_A, RF_RCK, RFREG_MASK, 0x36); @@ -2281,6 +2283,8 @@ static void rtw8822c_coex_cfg_wl_rx_gain(struct rtw_dev *rtwdev, bool low_gain) rtw_write_rf(rtwdev, RF_PATH_B, RF_RCK, RFREG_MASK, 0x36); } else { + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], Hi-Li Table Off!\n"); + /* set Rx filter corner RCK offset */ rtw_write_rf(rtwdev, RF_PATH_A, RF_RCKD, RFREG_MASK, 0x20); rtw_write_rf(rtwdev, RF_PATH_A, RF_RCK, RFREG_MASK, 0x0); From 1ccaa898868d1971a6480d7d55668de522f5847f Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Mon, 9 Nov 2020 16:59:09 +0800 Subject: [PATCH 102/180] rtw88: coex: simplify the setting and condition about WLAN TX limitation Life time related setting is related to WLAN active port number, not its mode. The original setting may cause poor WLAN performance. In most case, WLAN TX limitation is helpful for BT in coexistence scenario, especially for A2DP quality. So this is necessary to fix the setting and constraint it. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109085909.9143-12-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 24 +++++++---------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index ad21fba48808..61e91565cd7d 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -38,7 +38,7 @@ static void rtw_coex_limited_tx(struct rtw_dev *rtwdev, struct rtw_chip_info *chip = rtwdev->chip; struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; - bool wifi_under_b_mode = false; + u8 num_of_active_port = 1; if (!chip->scbd_support) return; @@ -70,17 +70,13 @@ static void rtw_coex_limited_tx(struct rtw_dev *rtwdev, /* set queue life time to avoid can't reach tx retry limit * if tx is always broken by GNT_BT */ - rtw_write8_set(rtwdev, REG_LIFETIME_EN, 0xf); + if (num_of_active_port <= 1) + rtw_write8_set(rtwdev, REG_LIFETIME_EN, 0xf); rtw_write16(rtwdev, REG_RETRY_LIMIT, 0x0808); /* auto rate fallback step within 8 retries */ - if (wifi_under_b_mode) { - rtw_write32(rtwdev, REG_DARFRC, 0x1000000); - rtw_write32(rtwdev, REG_DARFRCH, 0x1010101); - } else { - rtw_write32(rtwdev, REG_DARFRC, 0x1000000); - rtw_write32(rtwdev, REG_DARFRCH, 0x4030201); - } + rtw_write32(rtwdev, REG_DARFRC, 0x1000000); + rtw_write32(rtwdev, REG_DARFRCH, 0x4030201); } else { rtw_write8_clr(rtwdev, REG_TX_HANG_CTRL, BIT_EN_GNT_BT_AWAKE); rtw_write8_clr(rtwdev, REG_LIFETIME_EN, 0xf); @@ -101,18 +97,12 @@ static void rtw_coex_limited_wl(struct rtw_dev *rtwdev) { struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_dm *coex_dm = &coex->dm; - struct rtw_coex_stat *coex_stat = &coex->stat; bool tx_limit = false; bool tx_agg_ctrl = false; - if (coex->under_5g || - coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { - /* no need to limit tx */ - } else { + if (!coex->under_5g && coex_dm->bt_status != COEX_BTSTATUS_NCON_IDLE) { tx_limit = true; - if (coex_stat->bt_hid_exist || coex_stat->bt_hfp_exist || - coex_stat->bt_hid_pair_num > 0) - tx_agg_ctrl = true; + tx_agg_ctrl = true; } rtw_coex_limited_tx(rtwdev, tx_limit, tx_agg_ctrl); From ed5298c7d500abaf34ed7783969e953a1f028e5b Mon Sep 17 00:00:00 2001 From: Loic Poulain Date: Mon, 28 Sep 2020 09:39:50 +0530 Subject: [PATCH 103/180] bus: mhi: Remove auto-start option There is really no point having an auto-start for channels. This is confusing for the device drivers, some have to enable the channels, others don't have... and waste resources (e.g. pre allocated buffers) that may never be used. This is really up to the MHI device(channel) driver to manage the state of its channels. While at it, let's also remove the auto-start option from ath11k mhi controller. Signed-off-by: Loic Poulain Acked-by: Kalle Valo Reviewed-by: Manivannan Sadhasivam [mani: clubbed ath11k change] Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/init.c | 9 --------- drivers/bus/mhi/core/internal.h | 1 - drivers/net/wireless/ath/ath11k/mhi.c | 4 ---- include/linux/mhi.h | 2 -- 4 files changed, 16 deletions(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index 0ffdebde8265..381fdea2eb9f 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -758,7 +758,6 @@ static int parse_ch_cfg(struct mhi_controller *mhi_cntrl, mhi_chan->offload_ch = ch_cfg->offload_channel; mhi_chan->db_cfg.reset_req = ch_cfg->doorbell_mode_switch; mhi_chan->pre_alloc = ch_cfg->auto_queue; - mhi_chan->auto_start = ch_cfg->auto_start; /* * If MHI host allocates buffers, then the channel direction @@ -1160,11 +1159,6 @@ static int mhi_driver_probe(struct device *dev) goto exit_probe; ul_chan->xfer_cb = mhi_drv->ul_xfer_cb; - if (ul_chan->auto_start) { - ret = mhi_prepare_channel(mhi_cntrl, ul_chan); - if (ret) - goto exit_probe; - } } ret = -EINVAL; @@ -1198,9 +1192,6 @@ static int mhi_driver_probe(struct device *dev) if (ret) goto exit_probe; - if (dl_chan && dl_chan->auto_start) - mhi_prepare_channel(mhi_cntrl, dl_chan); - mhi_device_put(mhi_dev); return ret; diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h index 7989269ddd96..33c23203c531 100644 --- a/drivers/bus/mhi/core/internal.h +++ b/drivers/bus/mhi/core/internal.h @@ -563,7 +563,6 @@ struct mhi_chan { bool configured; bool offload_ch; bool pre_alloc; - bool auto_start; bool wake_capable; }; diff --git a/drivers/net/wireless/ath/ath11k/mhi.c b/drivers/net/wireless/ath/ath11k/mhi.c index aded9a719d51..47a1ce1bee4f 100644 --- a/drivers/net/wireless/ath/ath11k/mhi.c +++ b/drivers/net/wireless/ath/ath11k/mhi.c @@ -24,7 +24,6 @@ static struct mhi_channel_config ath11k_mhi_channels[] = { .offload_channel = false, .doorbell_mode_switch = false, .auto_queue = false, - .auto_start = false, }, { .num = 1, @@ -39,7 +38,6 @@ static struct mhi_channel_config ath11k_mhi_channels[] = { .offload_channel = false, .doorbell_mode_switch = false, .auto_queue = false, - .auto_start = false, }, { .num = 20, @@ -54,7 +52,6 @@ static struct mhi_channel_config ath11k_mhi_channels[] = { .offload_channel = false, .doorbell_mode_switch = false, .auto_queue = false, - .auto_start = true, }, { .num = 21, @@ -69,7 +66,6 @@ static struct mhi_channel_config ath11k_mhi_channels[] = { .offload_channel = false, .doorbell_mode_switch = false, .auto_queue = true, - .auto_start = true, }, }; diff --git a/include/linux/mhi.h b/include/linux/mhi.h index d4841e5a5f45..6522a4adc794 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -214,7 +214,6 @@ enum mhi_db_brst_mode { * @offload_channel: The client manages the channel completely * @doorbell_mode_switch: Channel switches to doorbell mode on M0 transition * @auto_queue: Framework will automatically queue buffers for DL traffic - * @auto_start: Automatically start (open) this channel * @wake-capable: Channel capable of waking up the system */ struct mhi_channel_config { @@ -232,7 +231,6 @@ struct mhi_channel_config { bool offload_channel; bool doorbell_mode_switch; bool auto_queue; - bool auto_start; bool wake_capable; }; From a2e2cc0dbb1121dfa875da1c04f3dff966fec162 Mon Sep 17 00:00:00 2001 From: Loic Poulain Date: Mon, 28 Sep 2020 09:39:51 +0530 Subject: [PATCH 104/180] net: qrtr: Start MHI channels during init Start MHI device channels so that transfers can be performed. The MHI stack does not auto-start channels anymore. Signed-off-by: Loic Poulain Reviewed-by: Manivannan Sadhasivam Acked-by: David S. Miller Signed-off-by: Manivannan Sadhasivam --- net/qrtr/mhi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c index ff0c41467fc1..7100f0bac4c6 100644 --- a/net/qrtr/mhi.c +++ b/net/qrtr/mhi.c @@ -76,6 +76,11 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, struct qrtr_mhi_dev *qdev; int rc; + /* start channels */ + rc = mhi_prepare_for_transfer(mhi_dev); + if (rc) + return rc; + qdev = devm_kzalloc(&mhi_dev->dev, sizeof(*qdev), GFP_KERNEL); if (!qdev) return -ENOMEM; From 2ca7e30d3b1ee370c96201e58f8c05ba2bdcd6d2 Mon Sep 17 00:00:00 2001 From: Bhaumik Bhatt Date: Wed, 18 Nov 2020 10:20:25 -0800 Subject: [PATCH 105/180] net: qrtr: Unprepare MHI channels during remove Reset MHI device channels when driver remove is called due to module unload or any crash scenario. This will make sure that MHI channels no longer remain enabled for transfers since the MHI stack does not take care of this anymore after the auto-start channels feature was removed. Signed-off-by: Bhaumik Bhatt Acked-by: Jakub Kicinski Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- net/qrtr/mhi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c index 7100f0bac4c6..2bf2b1943e61 100644 --- a/net/qrtr/mhi.c +++ b/net/qrtr/mhi.c @@ -104,6 +104,7 @@ static void qcom_mhi_qrtr_remove(struct mhi_device *mhi_dev) struct qrtr_mhi_dev *qdev = dev_get_drvdata(&mhi_dev->dev); qrtr_endpoint_unregister(&qdev->ep); + mhi_unprepare_from_transfer(mhi_dev); dev_set_drvdata(&mhi_dev->dev, NULL); } From 0eaa4c1d34c5635e293b7068ae170152ce0d60ff Mon Sep 17 00:00:00 2001 From: P Praneesh Date: Mon, 9 Nov 2020 15:11:55 +0530 Subject: [PATCH 106/180] ath11k: add processor_id based ring_selector logic Current ring selector logic follows round-robin scheduling, when a process switch from one processor to another each time, the data in the cache would have to be invalidated and re-loaded from RAM leads to poor cache utilization. Therefore smp_processor_id() attempt to keep processes on the same processor via processor affinity which improves cache utilization. Also, ring selection could be chosen round robin when the processor_id based ring selection does not have the resources. Tested-on : IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-00874-QCAHKSWPL_SILICONZ-1 Signed-off-by: P Praneesh Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604914915-12831-1-git-send-email-ppranees@codeaurora.org --- drivers/net/wireless/ath/ath11k/core.h | 3 --- drivers/net/wireless/ath/ath11k/dp_tx.c | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 79224ed703db..8851cf80ac96 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -728,9 +728,6 @@ struct ath11k_base { } stats; u32 pktlog_defs_checksum; - /* Round robbin based TCL ring selector */ - atomic_t tcl_ring_selector; - struct ath11k_dbring_cap *db_caps; u32 num_db_cap; diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c index 3d962eee4d61..6ea65533a119 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -105,14 +105,14 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif, pool_id = skb_get_queue_mapping(skb) & (ATH11K_HW_MAX_QUEUES - 1); - /* Let the default ring selection be based on a round robin - * fashion where one of the 3 tcl rings are selected based on - * the tcl_ring_selector counter. In case that ring + /* Let the default ring selection be based on current processor + * number, where one of the 3 tcl rings are selected based on + * the smp_processor_id(). In case that ring * is full/busy, we resort to other available rings. * If all rings are full, we drop the packet. * //TODO Add throttling logic when all rings are full */ - ring_selector = atomic_inc_return(&ab->tcl_ring_selector); + ring_selector = smp_processor_id(); tcl_ring_sel: tcl_ring_retry = false; From 1057db1b8b7661c5031caa0244dfa6bee9adc938 Mon Sep 17 00:00:00 2001 From: Ramya Gnanasekar Date: Mon, 9 Nov 2020 20:17:09 +0530 Subject: [PATCH 107/180] ath11k: Fix beamformee STS in HE cap STS Beamformee capability sent from firmware is overwritten as num_tx_chains - 1. When num_tx_chains is 2, then STS is set to invalid value 1. Since STS is not limited by number of TX chain, not overwriting the capability received from firmware. Tested on: IPQ6018 WLAN.HK.2.4.0.1-00303-QCAHKSWPL_SILICONZ-1 Signed-off-by: Ramya Gnanasekar Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604933229-15815-1-git-send-email-rgnanase@codeaurora.org --- drivers/net/wireless/ath/ath11k/mac.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index f4aedd5aefaf..25846bd6d02d 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -3779,11 +3779,6 @@ static int ath11k_mac_copy_he_cap(struct ath11k *ar, he_cap_elem->mac_cap_info[1] &= IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK; - he_cap_elem->phy_cap_info[4] &= - ~IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK; - he_cap_elem->phy_cap_info[4] &= - ~IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK; - he_cap_elem->phy_cap_info[4] |= (ar->num_tx_chains - 1) << 2; he_cap_elem->phy_cap_info[5] &= ~IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK; From 9af7c32ceca85da27867dd863697d2aafc80a3f8 Mon Sep 17 00:00:00 2001 From: Venkateswara Naralasetty Date: Fri, 6 Nov 2020 15:40:42 +0530 Subject: [PATCH 108/180] ath10k: add target IRAM recovery feature support This target IRAM recovery feature support is to copy target IRAM contents available at ATH10K_MEM_REGION_TYPE_REG to host memory for back up after firmware loaded. Target IRAM contents are copied to wmi memory chunks allocated for the WMI_IRAM_RECOVERY_HOST_MEM_REQ_ID and provide the wmi chunks address to the firmware through wmi init command. If firmware detects andy IRAM corruption through periodic checksum validation, It will download the IRAM contents back from the provided wmi memory chunks address using hif_memcpy. This IRAM recovery feature prevent target assert in case of unexpected target IRAM corruptions. This patch also introduce a new feature flag 'iram-recovery' for backward compatibility. Tested-on: QCA9888 10.4-3.9.0.2-00094 Signed-off-by: Venkateswara Naralasetty Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604657442-23674-1-git-send-email-vnaralas@codeaurora.org --- drivers/net/wireless/ath/ath10k/core.c | 83 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/core.h | 3 + drivers/net/wireless/ath/ath10k/wmi.h | 2 + 3 files changed, 88 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 419b06b974c5..796107b14d9f 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -651,6 +651,7 @@ static const char *const ath10k_core_fw_feature_str[] = { [ATH10K_FW_FEATURE_NON_BMI] = "non-bmi", [ATH10K_FW_FEATURE_SINGLE_CHAN_INFO_PER_CHANNEL] = "single-chan-info-per-channel", [ATH10K_FW_FEATURE_PEER_FIXED_RATE] = "peer-fixed-rate", + [ATH10K_FW_FEATURE_IRAM_RECOVERY] = "iram-recovery", }; static unsigned int ath10k_core_get_fw_feature_str(char *buf, @@ -2604,6 +2605,78 @@ static int ath10k_core_compat_services(struct ath10k *ar) return 0; } +#define TGT_IRAM_READ_PER_ITR (8 * 1024) + +static int ath10k_core_copy_target_iram(struct ath10k *ar) +{ + const struct ath10k_hw_mem_layout *hw_mem; + const struct ath10k_mem_region *tmp, *mem_region = NULL; + dma_addr_t paddr; + void *vaddr = NULL; + u8 num_read_itr; + int i, ret; + u32 len, remaining_len; + + hw_mem = ath10k_coredump_get_mem_layout(ar); + if (!hw_mem) + return -ENOMEM; + + for (i = 0; i < hw_mem->region_table.size; i++) { + tmp = &hw_mem->region_table.regions[i]; + if (tmp->type == ATH10K_MEM_REGION_TYPE_REG) { + mem_region = tmp; + break; + } + } + + if (!mem_region) + return -ENOMEM; + + for (i = 0; i < ar->wmi.num_mem_chunks; i++) { + if (ar->wmi.mem_chunks[i].req_id == + WMI_IRAM_RECOVERY_HOST_MEM_REQ_ID) { + vaddr = ar->wmi.mem_chunks[i].vaddr; + len = ar->wmi.mem_chunks[i].len; + break; + } + } + + if (!vaddr || !len) { + ath10k_warn(ar, "No allocated memory for IRAM back up"); + return -ENOMEM; + } + + len = (len < mem_region->len) ? len : mem_region->len; + paddr = mem_region->start; + num_read_itr = len / TGT_IRAM_READ_PER_ITR; + remaining_len = len % TGT_IRAM_READ_PER_ITR; + for (i = 0; i < num_read_itr; i++) { + ret = ath10k_hif_diag_read(ar, paddr, vaddr, + TGT_IRAM_READ_PER_ITR); + if (ret) { + ath10k_warn(ar, "failed to copy firmware IRAM contents: %d", + ret); + return ret; + } + + paddr += TGT_IRAM_READ_PER_ITR; + vaddr += TGT_IRAM_READ_PER_ITR; + } + + if (remaining_len) { + ret = ath10k_hif_diag_read(ar, paddr, vaddr, remaining_len); + if (ret) { + ath10k_warn(ar, "failed to copy firmware IRAM contents: %d", + ret); + return ret; + } + } + + ath10k_dbg(ar, ATH10K_DBG_BOOT, "target IRAM back up completed\n"); + + return 0; +} + int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode, const struct ath10k_fw_components *fw) { @@ -2765,6 +2838,16 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode, ath10k_dbg(ar, ATH10K_DBG_BOOT, "firmware %s booted\n", ar->hw->wiphy->fw_version); + if (test_bit(ATH10K_FW_FEATURE_IRAM_RECOVERY, + ar->running_fw->fw_file.fw_features)) { + status = ath10k_core_copy_target_iram(ar); + if (status) { + ath10k_warn(ar, "failed to copy target iram contents: %d", + status); + goto err_hif_stop; + } + } + if (test_bit(WMI_SERVICE_EXT_RES_CFG_SUPPORT, ar->wmi.svc_map) && mode == ATH10K_FIRMWARE_MODE_NORMAL) { val = 0; diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index aa713d037c7f..f3853bd26275 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -834,6 +834,9 @@ enum ath10k_fw_features { /* Firmware allows setting peer fixed rate */ ATH10K_FW_FEATURE_PEER_FIXED_RATE = 21, + /* Firmware support IRAM recovery */ + ATH10K_FW_FEATURE_IRAM_RECOVERY = 22, + /* keep last */ ATH10K_FW_FEATURE_COUNT, }; diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index 11300b1320a9..c32aabea8293 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h @@ -3060,6 +3060,8 @@ struct host_memory_chunk { __le32 size; } __packed; +#define WMI_IRAM_RECOVERY_HOST_MEM_REQ_ID 8 + struct wmi_host_mem_chunks { __le32 count; /* some fw revisions require at least 1 chunk regardless of count */ From 11af6de4799ee6eeae3730f18fd417414d212e2d Mon Sep 17 00:00:00 2001 From: Maharaja Kennadyrajan Date: Wed, 11 Nov 2020 16:08:37 +0530 Subject: [PATCH 109/180] ath11k: Fix the rx_filter flag setting for peer rssi stats Set the rx_filter in ath11k_mac_config_mon_status_default(), only when the rx_filter value exists in ath11k_debug_rx_filter(). Without this change, rx_filter gets set to 0 and peer rssi stats aren't updating properly from firmware. Tested-on: IPQ8074 WLAN.HK.2.1.0.1-01230-QCAHKSWPL_SILICONZ-4 Fixes: ec48d28ba291 ("ath11k: Fix rx_filter flags setting for per peer rx_stats") Signed-off-by: Maharaja Kennadyrajan Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1605091117-11005-1-git-send-email-mkenna@codeaurora.org --- drivers/net/wireless/ath/ath11k/mac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 25846bd6d02d..70fc253de8ef 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -4139,7 +4139,8 @@ static int ath11k_mac_config_mon_status_default(struct ath11k *ar, bool enable) if (enable) { tlv_filter = ath11k_mac_mon_status_filter_default; - tlv_filter.rx_filter = ath11k_debugfs_rx_filter(ar); + if (ath11k_debugfs_rx_filter(ar)) + tlv_filter.rx_filter = ath11k_debugfs_rx_filter(ar); } for (i = 0; i < ab->hw_params.num_rxmda_per_pdev; i++) { From 8f0cb24ceefec6744cad2103e92de314598d7626 Mon Sep 17 00:00:00 2001 From: Ping-Ke Shih Date: Mon, 9 Nov 2020 17:01:22 +0800 Subject: [PATCH 110/180] rtw88: 8723d: add cck pd seetings CCK PD can reduce the number of false alarm of the CCK rates. It dynamically adjusts the power threshold and CS ratio. The values are compared to the values of the previous level, if the level is changed, set new values of power threshold and CS ratio. Implement rtw_chip_ops::cck_pd_set() for 8723d. Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109090123.9254-1-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/rtw8723d.c | 18 ++++++++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8723d.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c b/drivers/net/wireless/realtek/rtw88/rtw8723d.c index 4ed38681c97d..0d5cfb6bbef1 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c @@ -192,6 +192,7 @@ static void rtw8723d_phy_set_param(struct rtw_dev *rtwdev) rtw_write32(rtwdev, REG_LTR_CTRL_BASIC + 4, WLAN_LTR_CTRL2); rtw_phy_init(rtwdev); + rtwdev->dm_info.cck_pd_default = rtw_read8(rtwdev, REG_CSRATIO) & 0x1f; rtw_write16_set(rtwdev, REG_TXDMA_OFFSET_CHK, BIT_DROP_DATA_EN); @@ -1498,6 +1499,22 @@ static void rtw8723d_phy_calibration(struct rtw_dev *rtwdev) rtw_dbg(rtwdev, RTW_DBG_RFK, "[IQK] finished\n"); } +static void rtw8723d_phy_cck_pd_set(struct rtw_dev *rtwdev, u8 new_lvl) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + u8 pd[CCK_PD_LV_MAX] = {3, 7, 13, 13, 13}; + + if (dm_info->cck_pd_lv[RTW_CHANNEL_WIDTH_20][RF_PATH_A] == new_lvl) + return; + + dm_info->cck_fa_avg = CCK_FA_AVG_RESET; + + dm_info->cck_pd_lv[RTW_CHANNEL_WIDTH_20][RF_PATH_A] = new_lvl; + rtw_write32_mask(rtwdev, REG_PWRTH, 0x3f0000, pd[new_lvl]); + rtw_write32_mask(rtwdev, REG_PWRTH2, 0x1f0000, + dm_info->cck_pd_default + new_lvl * 2); +} + /* for coex */ static void rtw8723d_coex_cfg_init(struct rtw_dev *rtwdev) { @@ -1931,6 +1948,7 @@ static struct rtw_chip_ops rtw8723d_ops = { .efuse_grant = rtw8723d_efuse_grant, .false_alarm_statistics = rtw8723d_false_alarm_statistics, .phy_calibration = rtw8723d_phy_calibration, + .cck_pd_set = rtw8723d_phy_cck_pd_set, .pwr_track = rtw8723d_pwr_track, .config_bfee = NULL, .set_gid_table = NULL, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.h b/drivers/net/wireless/realtek/rtw88/rtw8723d.h index 7894d321cd7e..41d35174a542 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.h @@ -163,6 +163,7 @@ static inline s32 iqk_mult(s32 x, s32 y, s32 *ext) #define REG_CCK0_SYS 0x0a00 #define BIT_CCK_SIDE_BAND BIT(4) #define REG_CCK_ANT_SEL_11N 0x0a04 +#define REG_PWRTH 0x0a08 #define REG_CCK_FA_RST_11N 0x0a2c #define BIT_MASK_CCK_CNT_KEEP BIT(12) #define BIT_MASK_CCK_CNT_EN BIT(13) @@ -175,6 +176,8 @@ static inline s32 iqk_mult(s32 x, s32 y, s32 *ext) #define REG_CCK_CCA_CNT_11N 0x0a60 #define BIT_MASK_CCK_FA_MSB GENMASK(7, 0) #define BIT_MASK_CCK_FA_LSB GENMASK(15, 8) +#define REG_PWRTH2 0x0aa8 +#define REG_CSRATIO 0x0aaa #define REG_OFDM_FA_HOLDC_11N 0x0c00 #define BIT_MASK_OFDM_FA_KEEP BIT(31) #define REG_BB_RX_PATH_11N 0x0c04 From 760bb2abfef252a0a2bed5aba2f4ab56dec50b72 Mon Sep 17 00:00:00 2001 From: Ping-Ke Shih Date: Mon, 9 Nov 2020 17:01:23 +0800 Subject: [PATCH 111/180] rtw88: add CCK_PD debug log In order to help debugging in field, we add some log messages. Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201109090123.9254-2-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/phy.c | 6 ++++++ drivers/net/wireless/realtek/rtw88/reg.h | 2 ++ drivers/net/wireless/realtek/rtw88/rtw8723d.c | 12 ++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8821c.c | 12 ++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8822c.c | 8 ++++++++ 5 files changed, 40 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c index 5cd9cc42648e..d44960cd940c 100644 --- a/drivers/net/wireless/realtek/rtw88/phy.c +++ b/drivers/net/wireless/realtek/rtw88/phy.c @@ -541,6 +541,12 @@ static void rtw_phy_cck_pd(struct rtw_dev *rtwdev) else dm_info->cck_fa_avg = (dm_info->cck_fa_avg * 3 + cck_fa) >> 2; + rtw_dbg(rtwdev, RTW_DBG_PHY, "IGI=0x%x, rssi_min=%d, cck_fa=%d\n", + dm_info->igi_history[0], dm_info->min_rssi, + dm_info->fa_history[0]); + rtw_dbg(rtwdev, RTW_DBG_PHY, "cck_fa_avg=%d, cck_pd_default=%d\n", + dm_info->cck_fa_avg, dm_info->cck_pd_default); + level = rtw_phy_cck_pd_lv(rtwdev); if (level >= CCK_PD_LV_MAX) diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h index 2a4275f3d851..cf9a3b674d30 100644 --- a/drivers/net/wireless/realtek/rtw88/reg.h +++ b/drivers/net/wireless/realtek/rtw88/reg.h @@ -489,6 +489,8 @@ #define REG_2ND_CCA_CTRL 0x0976 #define REG_CCK0_FAREPORT 0xa2c +#define BIT_CCK0_2RX BIT(18) +#define BIT_CCK0_MRC BIT(22) #define REG_DIS_DPD 0x0a70 #define DIS_DPD_MASK GENMASK(9, 0) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c b/drivers/net/wireless/realtek/rtw88/rtw8723d.c index 0d5cfb6bbef1..92652b808578 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c @@ -1503,10 +1503,22 @@ static void rtw8723d_phy_cck_pd_set(struct rtw_dev *rtwdev, u8 new_lvl) { struct rtw_dm_info *dm_info = &rtwdev->dm_info; u8 pd[CCK_PD_LV_MAX] = {3, 7, 13, 13, 13}; + u8 cck_n_rx; + + rtw_dbg(rtwdev, RTW_DBG_PHY, "lv: (%d) -> (%d)\n", + dm_info->cck_pd_lv[RTW_CHANNEL_WIDTH_20][RF_PATH_A], new_lvl); if (dm_info->cck_pd_lv[RTW_CHANNEL_WIDTH_20][RF_PATH_A] == new_lvl) return; + cck_n_rx = (rtw_read8_mask(rtwdev, REG_CCK0_FAREPORT, BIT_CCK0_2RX) && + rtw_read8_mask(rtwdev, REG_CCK0_FAREPORT, BIT_CCK0_MRC)) ? 2 : 1; + rtw_dbg(rtwdev, RTW_DBG_PHY, + "is_linked=%d, lv=%d, n_rx=%d, cs_ratio=0x%x, pd_th=0x%x, cck_fa_avg=%d\n", + rtw_is_assoc(rtwdev), new_lvl, cck_n_rx, + dm_info->cck_pd_default + new_lvl * 2, + pd[new_lvl], dm_info->cck_fa_avg); + dm_info->cck_fa_avg = CCK_FA_AVG_RESET; dm_info->cck_pd_lv[RTW_CHANNEL_WIDTH_20][RF_PATH_A] = new_lvl; diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c index 64b14f9ea4a9..3f4b2898cedc 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c @@ -1020,6 +1020,7 @@ static void rtw8821c_phy_cck_pd_set(struct rtw_dev *rtwdev, u8 new_lvl) { struct rtw_dm_info *dm_info = &rtwdev->dm_info; u8 pd[CCK_PD_LV_MAX] = {3, 7, 13, 13, 13}; + u8 cck_n_rx; if (dm_info->min_rssi > 60) { new_lvl = 4; @@ -1027,9 +1028,20 @@ static void rtw8821c_phy_cck_pd_set(struct rtw_dev *rtwdev, u8 new_lvl) goto set_cck_pd; } + rtw_dbg(rtwdev, RTW_DBG_PHY, "lv: (%d) -> (%d)\n", + dm_info->cck_pd_lv[RTW_CHANNEL_WIDTH_20][RF_PATH_A], new_lvl); + if (dm_info->cck_pd_lv[RTW_CHANNEL_WIDTH_20][RF_PATH_A] == new_lvl) return; + cck_n_rx = (rtw_read8_mask(rtwdev, REG_CCK0_FAREPORT, BIT_CCK0_2RX) && + rtw_read8_mask(rtwdev, REG_CCK0_FAREPORT, BIT_CCK0_MRC)) ? 2 : 1; + rtw_dbg(rtwdev, RTW_DBG_PHY, + "is_linked=%d, lv=%d, n_rx=%d, cs_ratio=0x%x, pd_th=0x%x, cck_fa_avg=%d\n", + rtw_is_assoc(rtwdev), new_lvl, cck_n_rx, + dm_info->cck_pd_default + new_lvl * 2, + pd[new_lvl], dm_info->cck_fa_avg); + dm_info->cck_fa_avg = CCK_FA_AVG_RESET; set_cck_pd: diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index 3313f18838c1..06cefe384f34 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -3454,6 +3454,10 @@ rtw8822c_phy_cck_pd_set_reg(struct rtw_dev *rtwdev, rtw8822c_cck_pd_reg[bw][nrx].reg_cs, rtw8822c_cck_pd_reg[bw][nrx].mask_cs, cs); + + rtw_dbg(rtwdev, RTW_DBG_PHY, + "is_linked=%d, bw=%d, nrx=%d, cs_ratio=0x%x, pd_th=0x%x\n", + rtw_is_assoc(rtwdev), bw, nrx, cs, pd); } static void rtw8822c_phy_cck_pd_set(struct rtw_dev *rtwdev, u8 new_lvl) @@ -3467,6 +3471,10 @@ static void rtw8822c_phy_cck_pd_set(struct rtw_dev *rtwdev, u8 new_lvl) nrx = (u8)rtw_read32_mask(rtwdev, 0x1a2c, 0x60000); bw = (u8)rtw_read32_mask(rtwdev, 0x9b0, 0xc); + rtw_dbg(rtwdev, RTW_DBG_PHY, "lv: (%d) -> (%d) bw=%d nr=%d cck_fa_avg=%d\n", + dm_info->cck_pd_lv[bw][nrx], new_lvl, bw, nrx, + dm_info->cck_fa_avg); + if (dm_info->cck_pd_lv[bw][nrx] == new_lvl) return; From 7ed9e062178ddb7c630fbdc698f3718345dcb39b Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:20 +0800 Subject: [PATCH 112/180] rtw88: coex: update TDMA settings for different beacon interval Add considering for different WLAN beacon interval in coexistence mechanism. Because the WLAN beacon period may be not 100 ms, so it's necessary to consider any beacon period and set timer according to the interval. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-2-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 27 ++++++++++++++++--- drivers/net/wireless/realtek/rtw88/coex.h | 5 ++++ drivers/net/wireless/realtek/rtw88/mac80211.c | 7 +++++ drivers/net/wireless/realtek/rtw88/main.h | 1 + 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 61e91565cd7d..50df2e1b4842 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -225,6 +225,8 @@ static void rtw_coex_tdma_timer_base(struct rtw_dev *rtwdev, u8 type) struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; u8 para[2] = {0}; + u8 times; + u16 tbtt_interval = coex_stat->wl_beacon_interval; if (coex_stat->tdma_timer_base == type) return; @@ -233,10 +235,27 @@ static void rtw_coex_tdma_timer_base(struct rtw_dev *rtwdev, u8 type) para[0] = COEX_H2C69_TDMA_SLOT; - if (type == 3) /* 4-slot */ + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], tbtt_interval = %d\n", + tbtt_interval); + + if (type == TDMA_TIMER_TYPE_4SLOT) { para[1] = PARA1_H2C69_TDMA_4SLOT; /* 4-slot */ - else /* 2-slot */ + } else if (tbtt_interval < 80 && tbtt_interval > 0) { + times = 100 / tbtt_interval; + if (100 % tbtt_interval != 0) + times++; + + para[1] = FIELD_PREP(PARA1_H2C69_TBTT_TIMES, times); + } else if (tbtt_interval >= 180) { + times = tbtt_interval / 100; + if (tbtt_interval % 100 <= 80) + times--; + + para[1] = FIELD_PREP(PARA1_H2C69_TBTT_TIMES, times) | + FIELD_PREP(PARA1_H2C69_TBTT_DIV100, 1); + } else { para[1] = PARA1_H2C69_TDMA_2SLOT; + } rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); @@ -973,9 +992,9 @@ static void rtw_coex_tdma(struct rtw_dev *rtwdev, bool force, u32 tcase) bool wl_busy = false; if (tcase & TDMA_4SLOT)/* 4-slot (50ms) mode */ - rtw_coex_tdma_timer_base(rtwdev, 3); + rtw_coex_tdma_timer_base(rtwdev, TDMA_TIMER_TYPE_4SLOT); else - rtw_coex_tdma_timer_base(rtwdev, 0); + rtw_coex_tdma_timer_base(rtwdev, TDMA_TIMER_TYPE_2SLOT); type = (u8)(tcase & 0xff); diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h index 9b305fc6c984..73f1bbc68490 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.h +++ b/drivers/net/wireless/realtek/rtw88/coex.h @@ -21,9 +21,14 @@ #define COEX_H2C69_TDMA_SLOT 0xb #define PARA1_H2C69_TDMA_4SLOT 0xc1 #define PARA1_H2C69_TDMA_2SLOT 0x1 +#define PARA1_H2C69_TBTT_TIMES GENMASK(5, 0) +#define PARA1_H2C69_TBTT_DIV100 BIT(7) #define TDMA_4SLOT BIT(8) +#define TDMA_TIMER_TYPE_2SLOT 0 +#define TDMA_TIMER_TYPE_4SLOT 3 + #define COEX_RSSI_STEP 4 #define COEX_RSSI_HIGH(rssi) \ diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c index c69397719fdf..1f1b639cd124 100644 --- a/drivers/net/wireless/realtek/rtw88/mac80211.c +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c @@ -351,6 +351,8 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw, { struct rtw_dev *rtwdev = hw->priv; struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; + struct rtw_coex *coex = &rtwdev->coex; + struct rtw_coex_stat *coex_stat = &coex->stat; u32 config = 0; mutex_lock(&rtwdev->mutex); @@ -381,6 +383,11 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw, config |= PORT_SET_BSSID; } + if (changed & BSS_CHANGED_BEACON_INT) { + if (ieee80211_vif_type_p2p(vif) == NL80211_IFTYPE_STATION) + coex_stat->wl_beacon_interval = conf->beacon_int; + } + if (changed & BSS_CHANGED_BEACON) rtw_fw_download_rsvd_page(rtwdev); diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index a3a687a63734..3941aea51f9c 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1354,6 +1354,7 @@ struct rtw_coex_stat { u8 bt_a2dp_bitpool; u8 bt_iqk_state; + u16 wl_beacon_interval; u8 wl_noisy_level; u8 wl_fw_dbg_info[10]; u8 wl_fw_dbg_info_pre[10]; From ca30905b1d6a3c461c600442ad007c24aa2e388a Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:21 +0800 Subject: [PATCH 113/180] rtw88: coex: remove unnecessary feature/function Because the WLAN RSSI report feature had been implemented at WLAN link info update function, it is redundant to update WLAN RSSI while BT is updating link info, so remove the update WLAN RSSI part. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-3-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 33 +++++++---------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 50df2e1b4842..f0d300e197b7 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -397,15 +397,16 @@ static void rtw_coex_monitor_bt_enable(struct rtw_dev *rtwdev) coex_stat->bt_disabled = bt_disabled; coex_stat->bt_ble_scan_type = 0; coex_dm->cur_bt_lna_lvl = 0; - } - if (!coex_stat->bt_disabled) { - coex_stat->bt_reenable = true; - ieee80211_queue_delayed_work(rtwdev->hw, - &coex->bt_reenable_work, 15 * HZ); - } else { - coex_stat->bt_mailbox_reply = false; - coex_stat->bt_reenable = false; + if (!coex_stat->bt_disabled) { + coex_stat->bt_reenable = true; + ieee80211_queue_delayed_work(rtwdev->hw, + &coex->bt_reenable_work, + 15 * HZ); + } else { + coex_stat->bt_mailbox_reply = false; + coex_stat->bt_reenable = false; + } } } @@ -612,15 +613,6 @@ static void rtw_coex_update_bt_link_info(struct rtw_dev *rtwdev) coex_dm->bt_rssi_state[i] = rssi_state; } - for (i = 0; i < COEX_RSSI_STEP; i++) { - rssi_state = coex_dm->wl_rssi_state[i]; - rssi_step = chip->wl_rssi_step[i]; - rssi = rtwdev->dm_info.min_rssi; - rssi_state = rtw_coex_next_rssi_state(rtwdev, rssi_state, - rssi, rssi_step); - coex_dm->wl_rssi_state[i] = rssi_state; - } - if (coex_stat->bt_ble_scan_en && coex_stat->cnt_bt[COEX_CNT_BT_INFOUPDATE] % 3 == 0) { u8 scan_type; @@ -991,7 +983,7 @@ static void rtw_coex_tdma(struct rtw_dev *rtwdev, bool force, u32 tcase) bool turn_on; bool wl_busy = false; - if (tcase & TDMA_4SLOT)/* 4-slot (50ms) mode */ + if (tcase & TDMA_4SLOT) /* 4-slot (50ms) mode */ rtw_coex_tdma_timer_base(rtwdev, TDMA_TIMER_TYPE_4SLOT); else rtw_coex_tdma_timer_base(rtwdev, TDMA_TIMER_TYPE_2SLOT); @@ -2864,11 +2856,6 @@ void rtw_coex_wl_fwdbginfo_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) void rtw_coex_wl_status_change_notify(struct rtw_dev *rtwdev, u32 type) { - struct rtw_coex *coex = &rtwdev->coex; - - if (coex->stop_dm) - return; - rtw_coex_run_coex(rtwdev, COEX_RSN_WLSTATUS); } From 513fb27f6a52ca352c148062fcf246ecf707642f Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:22 +0800 Subject: [PATCH 114/180] rtw88: coex: add write scoreboard action when WLAN in critical procedure When WLAN in critical procedure, such as connecting, scan and so on, coexistence will notify BT by scoreboard. While BT firmware received the scoreboard interrupt, it will adjust BT page priority lower to avoid WLAN critical procedure suffering impact. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-4-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index f0d300e197b7..cbc0b7417887 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -460,6 +460,12 @@ static void rtw_coex_update_wl_link_info(struct rtw_dev *rtwdev, u8 reason) coex_dm->wl_rssi_state[i] = rssi_state; } + if (coex_stat->wl_linkscan_proc || coex_stat->wl_hi_pri_task1 || + coex_stat->wl_hi_pri_task2 || coex_stat->wl_gl_busy) + rtw_coex_write_scbd(rtwdev, COEX_SCBD_SCAN, true); + else + rtw_coex_write_scbd(rtwdev, COEX_SCBD_SCAN, false); + switch (reason) { case COEX_RSN_5GSCANSTART: case COEX_RSN_5GSWITCHBAND: From 3a6616f96624febe9053b8b9e94434f7482e563a Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:23 +0800 Subject: [PATCH 115/180] rtw88: coex: Add force flag for coexistence table function Because sometimes hardware action may be unpredictable. (Ex: after WLAN LPS...etc) Add a check mechanism if the action is triggered by some concerned case, it can force to write the table again. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-5-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 62 +++++++++++++---------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index cbc0b7417887..d098a0c2c099 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -851,9 +851,19 @@ static void rtw_coex_set_gnt_wl(struct rtw_dev *rtwdev, u8 state) rtw_coex_write_indirect_reg(rtwdev, LTE_COEX_CTRL, 0x0300, state); } -static void rtw_coex_set_table(struct rtw_dev *rtwdev, u32 table0, u32 table1) +static void rtw_coex_set_table(struct rtw_dev *rtwdev, bool force, u32 table0, + u32 table1) { #define DEF_BRK_TABLE_VAL 0xf0ffffff + struct rtw_coex *coex = &rtwdev->coex; + struct rtw_coex_dm *coex_dm = &coex->dm; + + /* If last tdma is wl slot toggle, force write table*/ + if (!force && coex_dm->reason != COEX_RSN_LPS) { + if (table0 == rtw_read32(rtwdev, REG_BT_COEX_TABLE0) && + table1 == rtw_read32(rtwdev, REG_BT_COEX_TABLE1)) + return; + } rtw_write32(rtwdev, REG_BT_COEX_TABLE0, table0); rtw_write32(rtwdev, REG_BT_COEX_TABLE1, table1); rtw_write32(rtwdev, REG_BT_COEX_BRK_TABLE, DEF_BRK_TABLE_VAL); @@ -863,7 +873,7 @@ static void rtw_coex_set_table(struct rtw_dev *rtwdev, u32 table0, u32 table1) table1); } -static void rtw_coex_table(struct rtw_dev *rtwdev, u8 type) +static void rtw_coex_table(struct rtw_dev *rtwdev, bool force, u8 type) { struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_dm *coex_dm = &coex->dm; @@ -876,13 +886,13 @@ static void rtw_coex_table(struct rtw_dev *rtwdev, u8 type) if (efuse->share_ant) { if (type < chip->table_sant_num) - rtw_coex_set_table(rtwdev, + rtw_coex_set_table(rtwdev, force, chip->table_sant[type].bt, chip->table_sant[type].wl); } else { type = type - 100; if (type < chip->table_nsant_num) - rtw_coex_set_table(rtwdev, + rtw_coex_set_table(rtwdev, force, chip->table_nsant[type].bt, chip->table_nsant[type].wl); } @@ -1331,7 +1341,7 @@ static void rtw_coex_action_coex_all_off(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1375,7 +1385,7 @@ static void rtw_coex_action_freerun(struct rtw_dev *rtwdev) else rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[level]); - rtw_coex_table(rtwdev, 100); + rtw_coex_table(rtwdev, false, 100); rtw_coex_tdma(rtwdev, false, 100); } @@ -1400,7 +1410,7 @@ static void rtw_coex_action_bt_whql_test(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1425,7 +1435,7 @@ static void rtw_coex_action_bt_relink(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1456,7 +1466,7 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) if (table_case != 0xff && tdma_case != 0xff) { rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G_FREERUN); - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); return; } @@ -1490,7 +1500,7 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) } } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1585,7 +1595,7 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], wifi hi(%d), bt page(%d)\n", wl_hi_pri, coex_stat->bt_page); - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } @@ -1621,7 +1631,7 @@ static void rtw_coex_action_bt_hfp(struct rtw_dev *rtwdev) } } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1694,7 +1704,7 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) } } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1736,7 +1746,7 @@ static void rtw_coex_action_bt_a2dp(struct rtw_dev *rtwdev) tdma_case = 113; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } @@ -1775,7 +1785,7 @@ static void rtw_coex_action_bt_a2dpsink(struct rtw_dev *rtwdev) } } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1812,7 +1822,7 @@ static void rtw_coex_action_bt_pan(struct rtw_dev *rtwdev) tdma_case = 119; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1856,7 +1866,7 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev) tdma_case = 113; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } @@ -1894,7 +1904,7 @@ static void rtw_coex_action_bt_a2dp_pan(struct rtw_dev *rtwdev) tdma_case = 120; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1929,7 +1939,7 @@ static void rtw_coex_action_bt_pan_hid(struct rtw_dev *rtwdev) tdma_case = 119; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1963,7 +1973,7 @@ static void rtw_coex_action_bt_a2dp_pan_hid(struct rtw_dev *rtwdev) tdma_case = 120; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1990,7 +2000,7 @@ static void rtw_coex_action_wl_under5g(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -2014,7 +2024,7 @@ static void rtw_coex_action_wl_only(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -2043,7 +2053,7 @@ static void rtw_coex_action_wl_native_lps(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -2081,7 +2091,7 @@ static void rtw_coex_action_wl_linkscan(struct rtw_dev *rtwdev) } } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } @@ -2105,7 +2115,7 @@ static void rtw_coex_action_wl_not_connected(struct rtw_dev *rtwdev) tdma_case = 100; } - rtw_coex_table(rtwdev, table_case); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -2337,7 +2347,7 @@ static void __rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only) } /* PTA parameter */ - rtw_coex_table(rtwdev, 0); + rtw_coex_table(rtwdev, false, 0); rtw_coex_tdma(rtwdev, true, 0); rtw_coex_query_bt_info(rtwdev); } From a9359faaa47d22301437336cc8c46d4bcf8ec8a5 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:24 +0800 Subject: [PATCH 116/180] rtw88: coex: add the mechanism for RF4CE Add the related coexistence mechanism about RF4CE and WLAN connected flag to decide control packet is whether higher or normal priority. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-6-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 33 ++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index d098a0c2c099..9ab31fbcb593 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -1389,6 +1389,31 @@ static void rtw_coex_action_freerun(struct rtw_dev *rtwdev) rtw_coex_tdma(rtwdev, false, 100); } +static void rtw_coex_action_rf4ce(struct rtw_dev *rtwdev) +{ + struct rtw_efuse *efuse = &rtwdev->efuse; + struct rtw_chip_info *chip = rtwdev->chip; + u8 table_case, tdma_case; + + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); + + rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + + if (efuse->share_ant) { + /* Shared-Ant */ + table_case = 9; + tdma_case = 16; + } else { + /* Non-Shared-Ant */ + table_case = 100; + tdma_case = 100; + } + + rtw_coex_table(rtwdev, false, table_case); + rtw_coex_tdma(rtwdev, false, tdma_case); +} + static void rtw_coex_action_bt_whql_test(struct rtw_dev *rtwdev) { struct rtw_efuse *efuse = &rtwdev->efuse; @@ -2179,6 +2204,7 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason) struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_dm *coex_dm = &coex->dm; struct rtw_coex_stat *coex_stat = &coex->stat; + bool rf4ce_en = false; lockdep_assert_held(&rtwdev->mutex); @@ -2234,7 +2260,12 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason) coex_stat->wl_coex_mode = COEX_WLINK_2G1PORT; rtw_coex_write_scbd(rtwdev, COEX_SCBD_FIX2M, false); if (coex_stat->bt_disabled) { - rtw_coex_action_wl_only(rtwdev); + if (coex_stat->wl_connected && rf4ce_en) + rtw_coex_action_rf4ce(rtwdev); + else if (!coex_stat->wl_connected) + rtw_coex_action_wl_not_connected(rtwdev); + else + rtw_coex_action_wl_only(rtwdev); goto exit; } From 22a9dc720f106715e76546db8268fd6e99bdeb93 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:25 +0800 Subject: [PATCH 117/180] rtw88: coex: update the TDMA parameter when leave LPS The updated parameter and original parameter all means TDMA-OFF. The original setting write 0x8 to firmware, but it only works for some old IC series. To avoid the confusing, update a proper parameter. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-7-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 9ab31fbcb593..57b7776cf263 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -928,7 +928,7 @@ static void rtw_coex_power_save_state(struct rtw_dev *rtwdev, u8 ps_type, case COEX_PS_LPS_OFF: coex_stat->wl_force_lps_ctrl = true; if (lps_mode) - rtw_fw_coex_tdma_type(rtwdev, 0x8, 0, 0, 0, 0); + rtw_fw_coex_tdma_type(rtwdev, 0, 0, 0, 0, 0); rtw_leave_lps(rtwdev); rtw_dbg(rtwdev, RTW_DBG_COEX, From 65c6861f6382391149605631432af4bf8d7e8c9a Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:26 +0800 Subject: [PATCH 118/180] rtw88: coex: Change antenna setting to enhance free-run performance While the mechanism goes to 2G_free_run or WL5G_BT2G, set BT to hardware PTA mode to get a more efficiently performance. Add a flag to indicate antenna switch is supported or not so that the IC serials which has different antenna structure can set antenna correctly. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-8-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 57b7776cf263..d3432e6eb284 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -1061,6 +1061,7 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) { struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; + struct rtw_coex_rfe *coex_rfe = &coex->rfe; struct rtw_coex_dm *coex_dm = &coex->dm; u8 ctrl_type = COEX_SWITCH_CTRL_MAX; u8 pos_type = COEX_SWITCH_TO_MAX; @@ -1156,8 +1157,8 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s() - PHASE_5G_RUNTIME\n", __func__); - /* set GNT_BT to PTA */ - rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_SW_HIGH); + /* set GNT_BT to HW PTA */ + rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_HW_PTA); /* set GNT_WL to SW high */ rtw_coex_set_gnt_wl(rtwdev, COEX_GNT_SET_SW_HIGH); @@ -1172,8 +1173,8 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s() - PHASE_2G_FREERUN\n", __func__); - /* set GNT_BT to SW high */ - rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_SW_HIGH); + /* set GNT_BT to HW PTA */ + rtw_coex_set_gnt_bt(rtwdev, COEX_GNT_SET_HW_PTA); /* Set GNT_WL to SW high */ rtw_coex_set_gnt_wl(rtwdev, COEX_GNT_SET_SW_HIGH); @@ -1204,7 +1205,8 @@ static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) return; } - if (ctrl_type < COEX_SWITCH_CTRL_MAX && pos_type < COEX_SWITCH_TO_MAX) + if (ctrl_type < COEX_SWITCH_CTRL_MAX && pos_type < COEX_SWITCH_TO_MAX && + coex_rfe->ant_switch_exist) rtw_coex_set_ant_switch(rtwdev, ctrl_type, pos_type); } From e098c3c3314eba7a80d439c91cc07ac10621b1ba Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:27 +0800 Subject: [PATCH 119/180] rtw88: coex: fix BT performance drop during initial/power-on step Force set the coexistence to BT high priority during WLAN initial/power-on step. Since the duration the related setting may be not ready yet. The score board is not related to scan when initialing, remove the scan parameter. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-9-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index d3432e6eb284..2911367019b0 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -2368,19 +2368,19 @@ static void __rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only) __func__); } else if (wifi_only) { rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_WONLY); - rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_SCAN, + rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_ONOFF, true); coex->stop_dm = true; } else { rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_INIT); - rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_SCAN, + rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_ONOFF, true); coex->stop_dm = false; coex->freeze = true; } /* PTA parameter */ - rtw_coex_table(rtwdev, false, 0); + rtw_coex_table(rtwdev, true, 1); rtw_coex_tdma(rtwdev, true, 0); rtw_coex_query_bt_info(rtwdev); } @@ -2388,6 +2388,7 @@ static void __rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only) void rtw_coex_power_on_setting(struct rtw_dev *rtwdev) { struct rtw_coex *coex = &rtwdev->coex; + u8 table_case = 1; rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); @@ -2404,6 +2405,7 @@ void rtw_coex_power_on_setting(struct rtw_dev *rtwdev) /* set antenna path to BT */ rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_POWERON); + rtw_coex_table(rtwdev, true, table_case); /* red x issue */ rtw_write8(rtwdev, 0xff1a, 0x0); } From 72b14be751117c0250d37b8df34b01dcf52c43a6 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:28 +0800 Subject: [PATCH 120/180] rtw88: coex: remove write scan bit to scoreboard in scan and connect notify Remove some action which were writing scan bit to scoreboard, since these behaviors are redundant. It is already done in WLAN info notify. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-10-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 2911367019b0..31589021104a 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -2488,10 +2488,7 @@ void rtw_coex_scan_notify(struct rtw_dev *rtwdev, u8 type) return; coex->freeze = false; - - if (type != COEX_SCAN_FINISH) - rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_SCAN | - COEX_SCBD_ONOFF, true); + rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_ONOFF, true); if (type == COEX_SCAN_START_5G) { rtw_dbg(rtwdev, RTW_DBG_COEX, @@ -2548,8 +2545,7 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) if (coex->manual_control || coex->stop_dm) return; - rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_SCAN | - COEX_SCBD_ONOFF, true); + rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE | COEX_SCBD_ONOFF, true); if (type == COEX_ASSOCIATE_5G_START) { rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): 5G start\n", From 2485bc7c781694b5a367cb70a6d2da81301310d2 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:29 +0800 Subject: [PATCH 121/180] rtw88: coex: remove unnecessary WLAN slot extend Remove extend 5 ms related operation at WLAN media status notify. The mechanism should be enable only while DUT connect to a AP that it doesn't follow our power save control or its rate is decreasing unusually sensitive. So we extend a extra slot to save the transmission rate. The original logic will always extend WLAN slot. It will lead to BT slot always decrease 5 ms. Remove write scoreboard action at WLAN media status notify. It has already done in WLAN info notify. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-11-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 31589021104a..322b13c9150e 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -2592,8 +2592,6 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) void rtw_coex_media_status_notify(struct rtw_dev *rtwdev, u8 type) { struct rtw_coex *coex = &rtwdev->coex; - struct rtw_coex_stat *coex_stat = &coex->stat; - u8 para[6] = {0}; if (coex->manual_control || coex->stop_dm) return; @@ -2615,15 +2613,8 @@ void rtw_coex_media_status_notify(struct rtw_dev *rtwdev, u8 type) /* Set CCK Rx high Pri */ rtw_coex_set_wl_pri_mask(rtwdev, COEX_WLPRI_RX_CCK, 1); - - /* always enable 5ms extend if connect */ - para[0] = COEX_H2C69_WL_LEAKAP; - para[1] = PARA1_H2C69_EN_5MS; /* enable 5ms extend */ - rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); - coex_stat->wl_slot_extend = true; rtw_coex_run_coex(rtwdev, COEX_RSN_2GMEDIA); } else { - rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE, false); rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): disconnect!!\n", __func__); rtw_coex_set_wl_pri_mask(rtwdev, COEX_WLPRI_RX_CCK, 0); From 362c4a5cc886e9c369bf2106ab648c2ad076abb6 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 12 Nov 2020 11:14:30 +0800 Subject: [PATCH 122/180] rtw88: coex: change the decode method from firmware Fix sometimes FW information will be parsed as wrong value, do a correction of sign bit to show the correct information. (Ex, Value should be 20, but it shows 236.) Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112031430.4846-12-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 322b13c9150e..4bb0d373c862 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -2882,7 +2882,7 @@ void rtw_coex_wl_fwdbginfo_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) if (buf[i] >= val) coex_stat->wl_fw_dbg_info[i] = buf[i] - val; else - coex_stat->wl_fw_dbg_info[i] = val - buf[i]; + coex_stat->wl_fw_dbg_info[i] = 255 - val + buf[i]; coex_stat->wl_fw_dbg_info_pre[i] = buf[i]; } From 8d201d368aaa2b90a364cbd351a4e5f52b49cd55 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Thu, 12 Nov 2020 10:14:32 -0800 Subject: [PATCH 123/180] rtw88: wow: print key type when failing It's much easier to spot what went wrong when you print out the unhandled key type. Signed-off-by: Brian Norris Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201112181432.2958021-1-briannorris@chromium.org --- drivers/net/wireless/realtek/rtw88/wow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/wow.c b/drivers/net/wireless/realtek/rtw88/wow.c index b419bc28861f..fc9544f4e5e4 100644 --- a/drivers/net/wireless/realtek/rtw88/wow.c +++ b/drivers/net/wireless/realtek/rtw88/wow.c @@ -332,7 +332,8 @@ static void rtw_wow_fw_security_type_iter(struct ieee80211_hw *hw, key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX; break; default: - rtw_err(rtwdev, "Unsupported key type for wowlan mode\n"); + rtw_err(rtwdev, "Unsupported key type for wowlan mode: %#x\n", + key->cipher); hw_key_type = 0; break; } From 07f995ca1951604755cd9e76c8129222d6300120 Mon Sep 17 00:00:00 2001 From: Yejune Deng Date: Tue, 10 Nov 2020 14:58:11 +0800 Subject: [PATCH 124/180] cw1200: replace a set of atomic_add() a set of atomic_inc() looks more readable Signed-off-by: Yejune Deng Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1604991491-27908-1-git-send-email-yejune.deng@gmail.com --- drivers/net/wireless/st/cw1200/bh.c | 10 +++++----- drivers/net/wireless/st/cw1200/wsm.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/st/cw1200/bh.c b/drivers/net/wireless/st/cw1200/bh.c index 02efe8483cba..c364a3987618 100644 --- a/drivers/net/wireless/st/cw1200/bh.c +++ b/drivers/net/wireless/st/cw1200/bh.c @@ -85,7 +85,7 @@ int cw1200_register_bh(struct cw1200_common *priv) void cw1200_unregister_bh(struct cw1200_common *priv) { - atomic_add(1, &priv->bh_term); + atomic_inc(&priv->bh_term); wake_up(&priv->bh_wq); flush_workqueue(priv->bh_workqueue); @@ -107,7 +107,7 @@ void cw1200_irq_handler(struct cw1200_common *priv) if (/* WARN_ON */(priv->bh_error)) return; - if (atomic_add_return(1, &priv->bh_rx) == 1) + if (atomic_inc_return(&priv->bh_rx) == 1) wake_up(&priv->bh_wq); } EXPORT_SYMBOL_GPL(cw1200_irq_handler); @@ -120,7 +120,7 @@ void cw1200_bh_wakeup(struct cw1200_common *priv) return; } - if (atomic_add_return(1, &priv->bh_tx) == 1) + if (atomic_inc_return(&priv->bh_tx) == 1) wake_up(&priv->bh_wq); } @@ -382,7 +382,7 @@ static int cw1200_bh_tx_helper(struct cw1200_common *priv, BUG_ON(tx_len < sizeof(*wsm)); BUG_ON(__le16_to_cpu(wsm->len) != tx_len); - atomic_add(1, &priv->bh_tx); + atomic_inc(&priv->bh_tx); tx_len = priv->hwbus_ops->align_size( priv->hwbus_priv, tx_len); @@ -537,7 +537,7 @@ static int cw1200_bh(void *arg) pr_debug("[BH] Device resume.\n"); atomic_set(&priv->bh_suspend, CW1200_BH_RESUMED); wake_up(&priv->bh_evt_wq); - atomic_add(1, &priv->bh_rx); + atomic_inc(&priv->bh_rx); goto done; } diff --git a/drivers/net/wireless/st/cw1200/wsm.c b/drivers/net/wireless/st/cw1200/wsm.c index d9b6147bbb52..99624dd34886 100644 --- a/drivers/net/wireless/st/cw1200/wsm.c +++ b/drivers/net/wireless/st/cw1200/wsm.c @@ -1139,7 +1139,7 @@ static int wsm_cmd_send(struct cw1200_common *priv, pr_err("Outstanding outgoing frames: %d\n", priv->hw_bufs_used); /* Kill BH thread to report the error to the top layer. */ - atomic_add(1, &priv->bh_term); + atomic_inc(&priv->bh_term); wake_up(&priv->bh_wq); ret = -ETIMEDOUT; } @@ -1160,7 +1160,7 @@ static int wsm_cmd_send(struct cw1200_common *priv, void wsm_lock_tx(struct cw1200_common *priv) { wsm_cmd_lock(priv); - if (atomic_add_return(1, &priv->tx_lock) == 1) { + if (atomic_inc_return(&priv->tx_lock) == 1) { if (wsm_flush_tx(priv)) pr_debug("[WSM] TX is locked.\n"); } @@ -1169,7 +1169,7 @@ void wsm_lock_tx(struct cw1200_common *priv) void wsm_lock_tx_async(struct cw1200_common *priv) { - if (atomic_add_return(1, &priv->tx_lock) == 1) + if (atomic_inc_return(&priv->tx_lock) == 1) pr_debug("[WSM] TX is locked (async).\n"); } @@ -1223,7 +1223,7 @@ bool wsm_flush_tx(struct cw1200_common *priv) void wsm_unlock_tx(struct cw1200_common *priv) { int tx_lock; - tx_lock = atomic_sub_return(1, &priv->tx_lock); + tx_lock = atomic_dec_return(&priv->tx_lock); BUG_ON(tx_lock < 0); if (tx_lock == 0) { From 37ff144d29acd7bca3d465ce2fc4cb5c7072a7e5 Mon Sep 17 00:00:00 2001 From: Zhang Changzhong Date: Fri, 13 Nov 2020 14:28:16 +0800 Subject: [PATCH 125/180] brcmfmac: fix error return code in brcmf_cfg80211_connect() Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Fixes: 3b1e0a7bdfee ("brcmfmac: add support for SAE authentication offload") Reported-by: Hulk Robot Signed-off-by: Zhang Changzhong Reviewed-by: Chi-hsien Lin Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1605248896-16812-1-git-send-email-zhangchangzhong@huawei.com --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index a2dbbb977d0c..0ee421f30aa2 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -2137,7 +2137,8 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev, BRCMF_WSEC_MAX_PSK_LEN); else if (profile->use_fwsup == BRCMF_PROFILE_FWSUP_SAE) { /* clean up user-space RSNE */ - if (brcmf_fil_iovar_data_set(ifp, "wpaie", NULL, 0)) { + err = brcmf_fil_iovar_data_set(ifp, "wpaie", NULL, 0); + if (err) { bphy_err(drvr, "failed to clean up user-space RSNE\n"); goto done; } From a31eb615646a63370aa1da1053c45439c7653d83 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:43 +0100 Subject: [PATCH 126/180] orinoco: Move context allocation after processing the skb ezusb_xmit() allocates a context which is leaked if orinoco_process_xmit_skb() returns an error. Move ezusb_alloc_ctx() after the invocation of orinoco_process_xmit_skb() because the context is not needed so early. ezusb_access_ltv() will cleanup the context in case of an error. Fixes: bac6fafd4d6a0 ("orinoco: refactor xmit path") Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-2-bigeasy@linutronix.de --- .../net/wireless/intersil/orinoco/orinoco_usb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index 046f2453ad5d..8419e13a79e2 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -1221,13 +1221,6 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev) if (skb->len < ETH_HLEN) goto drop; - ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0); - if (!ctx) - goto busy; - - memset(ctx->buf, 0, BULK_BUF_SIZE); - buf = ctx->buf->data; - tx_control = 0; err = orinoco_process_xmit_skb(skb, dev, priv, &tx_control, @@ -1235,6 +1228,13 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev) if (err) goto drop; + ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0); + if (!ctx) + goto drop; + + memset(ctx->buf, 0, BULK_BUF_SIZE); + buf = ctx->buf->data; + { __le16 *tx_cntl = (__le16 *)buf; *tx_cntl = cpu_to_le16(tx_control); From 915fd9db418f3f99c002dcca8a089923c96ec80a Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:44 +0100 Subject: [PATCH 127/180] orinoco: Prepare stubs for in_interrupt() removal ezusb_access_ltv() sends the prepared request to the USB device. Requests which have ->in_rid set expect an answer from the USB device and the function has to wait until the URB with the answer arrives. The function uses in_interrupt() to determine if it can simply sleep on the completion and be woken up once the answer arrives or if it needs to poll on the completion. The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. Aside of that in_interrupt() is not correct as it does not catch preempt disabled regions in which sleeping is also not allowed. Provide stubs which can be used as a replacement. The current default is the current behaviour which sleeps/polls depending on in_interrupt(). The goal is to audit all callers and use either the poll or sleep version. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-3-bigeasy@linutronix.de --- .../wireless/intersil/orinoco/orinoco_usb.c | 81 ++++++++++++++++--- 1 file changed, 69 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index 8419e13a79e2..6642948809e1 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -665,6 +665,7 @@ static void ezusb_request_in_callback(struct ezusb_priv *upriv, } /* switch */ } +typedef void (*ezusb_ctx_wait)(struct ezusb_priv *, struct request_context *); static void ezusb_req_ctx_wait(struct ezusb_priv *upriv, struct request_context *ctx) @@ -692,6 +693,54 @@ static void ezusb_req_ctx_wait(struct ezusb_priv *upriv, } } +static void ezusb_req_ctx_wait_compl(struct ezusb_priv *upriv, + struct request_context *ctx) +{ + switch (ctx->state) { + case EZUSB_CTX_QUEUED: + case EZUSB_CTX_REQ_SUBMITTED: + case EZUSB_CTX_REQ_COMPLETE: + case EZUSB_CTX_RESP_RECEIVED: + wait_for_completion(&ctx->done); + break; + default: + /* Done or failed - nothing to wait for */ + break; + } +} + +static void ezusb_req_ctx_wait_poll(struct ezusb_priv *upriv, + struct request_context *ctx) +{ + int msecs; + + switch (ctx->state) { + case EZUSB_CTX_QUEUED: + case EZUSB_CTX_REQ_SUBMITTED: + case EZUSB_CTX_REQ_COMPLETE: + case EZUSB_CTX_RESP_RECEIVED: + /* If we get called from a timer or with our lock acquired, then + * we can't wait for the completion and have to poll. This won't + * happen if the USB controller completes the URB requests in + * BH. + */ + msecs = DEF_TIMEOUT * (1000 / HZ); + + while (!try_wait_for_completion(&ctx->done) && msecs--) + udelay(1000); + break; + default: + /* Done or failed - nothing to wait for */ + break; + } +} + +static void ezusb_req_ctx_wait_skip(struct ezusb_priv *upriv, + struct request_context *ctx) +{ + WARN(1, "Shouldn't be invoked for in_rid\n"); +} + static inline u16 build_crc(struct ezusb_packet *data) { u16 crc = 0; @@ -853,7 +902,8 @@ static int ezusb_firmware_download(struct ezusb_priv *upriv, static int ezusb_access_ltv(struct ezusb_priv *upriv, struct request_context *ctx, u16 length, const void *data, u16 frame_type, - void *ans_buff, unsigned ans_size, u16 *ans_length) + void *ans_buff, unsigned ans_size, u16 *ans_length, + ezusb_ctx_wait ezusb_ctx_wait_func) { int req_size; int retval = 0; @@ -883,7 +933,7 @@ static int ezusb_access_ltv(struct ezusb_priv *upriv, spin_unlock_bh(&upriv->reply_count_lock); if (ctx->in_rid) - ezusb_req_ctx_wait(upriv, ctx); + ezusb_ctx_wait_func(upriv, ctx); state = ctx->state; switch (state) { @@ -971,7 +1021,7 @@ static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid, frame_type = EZUSB_FRAME_CONTROL; return ezusb_access_ltv(upriv, ctx, length, data, frame_type, - NULL, 0, NULL); + NULL, 0, NULL, ezusb_req_ctx_wait); } static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid, @@ -988,7 +1038,7 @@ static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid, return -ENOMEM; return ezusb_access_ltv(upriv, ctx, 0, NULL, EZUSB_FRAME_CONTROL, - buf, bufsize, length); + buf, bufsize, length, ezusb_req_ctx_wait); } static int ezusb_doicmd_wait(struct hermes *hw, u16 cmd, u16 parm0, u16 parm1, @@ -1011,7 +1061,8 @@ static int ezusb_doicmd_wait(struct hermes *hw, u16 cmd, u16 parm0, u16 parm1, return -ENOMEM; return ezusb_access_ltv(upriv, ctx, sizeof(data), &data, - EZUSB_FRAME_CONTROL, NULL, 0, NULL); + EZUSB_FRAME_CONTROL, NULL, 0, NULL, + ezusb_req_ctx_wait); } static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, @@ -1032,7 +1083,8 @@ static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, return -ENOMEM; return ezusb_access_ltv(upriv, ctx, sizeof(data), &data, - EZUSB_FRAME_CONTROL, NULL, 0, NULL); + EZUSB_FRAME_CONTROL, NULL, 0, NULL, + ezusb_req_ctx_wait); } static int ezusb_bap_pread(struct hermes *hw, int bap, @@ -1090,7 +1142,7 @@ static int ezusb_read_pda(struct hermes *hw, __le16 *pda, return ezusb_access_ltv(upriv, ctx, sizeof(data), &data, EZUSB_FRAME_CONTROL, &pda[2], pda_len - 4, - NULL); + NULL, ezusb_req_ctx_wait); } static int ezusb_program_init(struct hermes *hw, u32 entry_point) @@ -1104,7 +1156,8 @@ static int ezusb_program_init(struct hermes *hw, u32 entry_point) return -ENOMEM; return ezusb_access_ltv(upriv, ctx, sizeof(data), &data, - EZUSB_FRAME_CONTROL, NULL, 0, NULL); + EZUSB_FRAME_CONTROL, NULL, 0, NULL, + ezusb_req_ctx_wait); } static int ezusb_program_end(struct hermes *hw) @@ -1117,7 +1170,8 @@ static int ezusb_program_end(struct hermes *hw) return -ENOMEM; return ezusb_access_ltv(upriv, ctx, 0, NULL, - EZUSB_FRAME_CONTROL, NULL, 0, NULL); + EZUSB_FRAME_CONTROL, NULL, 0, NULL, + ezusb_req_ctx_wait); } static int ezusb_program_bytes(struct hermes *hw, const char *buf, @@ -1133,7 +1187,8 @@ static int ezusb_program_bytes(struct hermes *hw, const char *buf, return -ENOMEM; err = ezusb_access_ltv(upriv, ctx, sizeof(data), &data, - EZUSB_FRAME_CONTROL, NULL, 0, NULL); + EZUSB_FRAME_CONTROL, NULL, 0, NULL, + ezusb_req_ctx_wait); if (err) return err; @@ -1142,7 +1197,8 @@ static int ezusb_program_bytes(struct hermes *hw, const char *buf, return -ENOMEM; return ezusb_access_ltv(upriv, ctx, len, buf, - EZUSB_FRAME_CONTROL, NULL, 0, NULL); + EZUSB_FRAME_CONTROL, NULL, 0, NULL, + ezusb_req_ctx_wait); } static int ezusb_program(struct hermes *hw, const char *buf, @@ -1262,7 +1318,8 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev) tx_size = ALIGN(buf - ctx->buf->data, 2); err = ezusb_access_ltv(upriv, ctx, tx_size, NULL, - EZUSB_FRAME_DATA, NULL, 0, NULL); + EZUSB_FRAME_DATA, NULL, 0, NULL, + ezusb_req_ctx_wait); if (err) { netif_start_queue(dev); From 29b2fe3f6f2071ba5b0dab709e3ffbf0eaa2a1e4 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:45 +0100 Subject: [PATCH 128/180] orinoco: Annotate ezusb_xmit() ezusb_xmit() sets ->in_rid in its request which means it does not wait for an answer. Use the ezusb_req_ctx_wait_skip() to denote that an answer is not expected. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-4-bigeasy@linutronix.de --- drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index 6642948809e1..66d77af91d22 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -1319,7 +1319,7 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev) err = ezusb_access_ltv(upriv, ctx, tx_size, NULL, EZUSB_FRAME_DATA, NULL, 0, NULL, - ezusb_req_ctx_wait); + ezusb_req_ctx_wait_skip); if (err) { netif_start_queue(dev); From 46233f77860480f34de658aa785e2b4b8fef6fdf Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:46 +0100 Subject: [PATCH 129/180] orinoco: Annotate ezusb_init() ezusb_init() is always invoked in preemptible context during device probe. Only orinoco_up() -> orinoco_reinit_firmware() may invoke the function from atomic context but this is never used for the USB interface. Use ezusb_req_ctx_wait_compl() for the ezusb_write_ltv() and ezusb_docmd_wait() invocations from within ezusb_init(). Preserve the generic versions which have still other user via the callback. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-5-bigeasy@linutronix.de --- .../wireless/intersil/orinoco/orinoco_usb.c | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index 66d77af91d22..3f49e15967a4 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -994,8 +994,9 @@ static int ezusb_access_ltv(struct ezusb_priv *upriv, return retval; } -static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid, - u16 length, const void *data) +static int __ezusb_write_ltv(struct hermes *hw, int bap, u16 rid, + u16 length, const void *data, + ezusb_ctx_wait ezusb_ctx_wait_func) { struct ezusb_priv *upriv = hw->priv; u16 frame_type; @@ -1021,7 +1022,14 @@ static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid, frame_type = EZUSB_FRAME_CONTROL; return ezusb_access_ltv(upriv, ctx, length, data, frame_type, - NULL, 0, NULL, ezusb_req_ctx_wait); + NULL, 0, NULL, ezusb_ctx_wait_func); +} + +static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid, + u16 length, const void *data) +{ + return __ezusb_write_ltv(hw, bap, rid, length, data, + ezusb_req_ctx_wait); } static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid, @@ -1065,8 +1073,9 @@ static int ezusb_doicmd_wait(struct hermes *hw, u16 cmd, u16 parm0, u16 parm1, ezusb_req_ctx_wait); } -static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, - struct hermes_response *resp) +static int __ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, + struct hermes_response *resp, + ezusb_ctx_wait ezusb_ctx_wait_func) { struct ezusb_priv *upriv = hw->priv; struct request_context *ctx; @@ -1084,7 +1093,13 @@ static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, return ezusb_access_ltv(upriv, ctx, sizeof(data), &data, EZUSB_FRAME_CONTROL, NULL, 0, NULL, - ezusb_req_ctx_wait); + ezusb_ctx_wait_func); +} + +static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, + struct hermes_response *resp) +{ + return __ezusb_docmd_wait(hw, cmd, parm0, resp, ezusb_req_ctx_wait); } static int ezusb_bap_pread(struct hermes *hw, int bap, @@ -1416,14 +1431,16 @@ static int ezusb_init(struct hermes *hw) usb_kill_urb(upriv->read_urb); ezusb_submit_in_urb(upriv); - retval = ezusb_write_ltv(hw, 0, EZUSB_RID_INIT1, - HERMES_BYTES_TO_RECLEN(2), "\x10\x00"); + retval = __ezusb_write_ltv(hw, 0, EZUSB_RID_INIT1, + HERMES_BYTES_TO_RECLEN(2), "\x10\x00", + ezusb_req_ctx_wait_compl); if (retval < 0) { printk(KERN_ERR PFX "EZUSB_RID_INIT1 error %d\n", retval); return retval; } - retval = ezusb_docmd_wait(hw, HERMES_CMD_INIT, 0, NULL); + retval = __ezusb_docmd_wait(hw, HERMES_CMD_INIT, 0, NULL, + ezusb_req_ctx_wait_compl); if (retval < 0) { printk(KERN_ERR PFX "HERMES_CMD_INIT error %d\n", retval); return retval; From 69476b25a4bac1186e9b6f091d5e3e9377a01f43 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:47 +0100 Subject: [PATCH 130/180] orinoco: Annotate firmware loading The ezusb_program() is invoked via ->program() in preemptible context during firmware loading. This is also true for the ->program_init() and ->program_end() callback. Use ezusb_req_ctx_wait_compl() in ezusb_program_init(), ezusb_program_bytes(), ezusb_program_end() which are part of firmware loading during device probe. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-6-bigeasy@linutronix.de --- drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index 3f49e15967a4..2c9c55569e8f 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -1172,7 +1172,7 @@ static int ezusb_program_init(struct hermes *hw, u32 entry_point) return ezusb_access_ltv(upriv, ctx, sizeof(data), &data, EZUSB_FRAME_CONTROL, NULL, 0, NULL, - ezusb_req_ctx_wait); + ezusb_req_ctx_wait_compl); } static int ezusb_program_end(struct hermes *hw) @@ -1186,7 +1186,7 @@ static int ezusb_program_end(struct hermes *hw) return ezusb_access_ltv(upriv, ctx, 0, NULL, EZUSB_FRAME_CONTROL, NULL, 0, NULL, - ezusb_req_ctx_wait); + ezusb_req_ctx_wait_compl); } static int ezusb_program_bytes(struct hermes *hw, const char *buf, @@ -1203,7 +1203,7 @@ static int ezusb_program_bytes(struct hermes *hw, const char *buf, err = ezusb_access_ltv(upriv, ctx, sizeof(data), &data, EZUSB_FRAME_CONTROL, NULL, 0, NULL, - ezusb_req_ctx_wait); + ezusb_req_ctx_wait_compl); if (err) return err; @@ -1213,7 +1213,7 @@ static int ezusb_program_bytes(struct hermes *hw, const char *buf, return ezusb_access_ltv(upriv, ctx, len, buf, EZUSB_FRAME_CONTROL, NULL, 0, NULL, - ezusb_req_ctx_wait); + ezusb_req_ctx_wait_compl); } static int ezusb_program(struct hermes *hw, const char *buf, From 154f2bae9bed3b07c4f328739361d9317122d199 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:48 +0100 Subject: [PATCH 131/180] orinoco: Annotate ezusb_read_pda() ezusb_read_pda() is invoked via ->read_pda() while firmware is loaded in preemtible context. Use ezusb_req_ctx_wait_compl() in ezusb_read_pda(). Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-7-bigeasy@linutronix.de --- drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index 2c9c55569e8f..7178889f9ec4 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -1157,7 +1157,7 @@ static int ezusb_read_pda(struct hermes *hw, __le16 *pda, return ezusb_access_ltv(upriv, ctx, sizeof(data), &data, EZUSB_FRAME_CONTROL, &pda[2], pda_len - 4, - NULL, ezusb_req_ctx_wait); + NULL, ezusb_req_ctx_wait_compl); } static int ezusb_program_init(struct hermes *hw, u32 entry_point) From 39628fe48cb36b89955eb78e9247eb674155bc59 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:49 +0100 Subject: [PATCH 132/180] orinoco: Annotate ezusb_write_ltv() All invocation of ezusb_write_ltv() happen via ->write_ltv() and are performed under the orinoco_lock() which disables BH. Use ezusb_req_ctx_wait_poll() for ezusb_write_ltv() because it must not sleep. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-8-bigeasy@linutronix.de --- drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index 7178889f9ec4..d12bd5be4cde 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -1029,7 +1029,7 @@ static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid, u16 length, const void *data) { return __ezusb_write_ltv(hw, bap, rid, length, data, - ezusb_req_ctx_wait); + ezusb_req_ctx_wait_poll); } static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid, From 47ab2a951eb9bdd532f3db89f64445058e37de34 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:50 +0100 Subject: [PATCH 133/180] orinoco: Remove ezusb_doicmd_wait() ezusb_doicmd_wait() is invoked via ->init_cmd_wait() callback. This callback is only invoked hermesi_program_init() and hermesi_program_end() which are the ->program_init() and ->program_end() callbacks as assigned by `hermes_ops_local'. They are never used by the USB interface since the USB interface provides its own set of callbacks by `ezusb_ops'. Replace ezusb_doicmd_wait() with a warning in case I missed the obvious. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-9-bigeasy@linutronix.de --- .../wireless/intersil/orinoco/orinoco_usb.c | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index d12bd5be4cde..c8508a3d652b 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -1052,25 +1052,8 @@ static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid, static int ezusb_doicmd_wait(struct hermes *hw, u16 cmd, u16 parm0, u16 parm1, u16 parm2, struct hermes_response *resp) { - struct ezusb_priv *upriv = hw->priv; - struct request_context *ctx; - - __le16 data[4] = { - cpu_to_le16(cmd), - cpu_to_le16(parm0), - cpu_to_le16(parm1), - cpu_to_le16(parm2), - }; - netdev_dbg(upriv->dev, - "0x%04X, parm0 0x%04X, parm1 0x%04X, parm2 0x%04X\n", cmd, - parm0, parm1, parm2); - ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK); - if (!ctx) - return -ENOMEM; - - return ezusb_access_ltv(upriv, ctx, sizeof(data), &data, - EZUSB_FRAME_CONTROL, NULL, 0, NULL, - ezusb_req_ctx_wait); + WARN_ON_ONCE(1); + return -EINVAL; } static int __ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, From a9a2678abacbcae902b4fb4bc5585a621099cc06 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:51 +0100 Subject: [PATCH 134/180] orinoco: Annotate ezusb_docmd_wait() All invocations of ezusb_docmd_wait() happen via ->cmd_wait(). This callback is always invoked under the orinoco_lock() which disables BH. Use ezusb_req_ctx_wait_poll() for ezusb_docmd_wait() because it must not sleep. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-10-bigeasy@linutronix.de --- drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index c8508a3d652b..4c60b4821463 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -1082,7 +1082,7 @@ static int __ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, struct hermes_response *resp) { - return __ezusb_docmd_wait(hw, cmd, parm0, resp, ezusb_req_ctx_wait); + return __ezusb_docmd_wait(hw, cmd, parm0, resp, ezusb_req_ctx_wait_poll); } static int ezusb_bap_pread(struct hermes *hw, int bap, From a3d8a2599d47164a52af0d8ae2b50e60d41b2d75 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 13 Nov 2020 22:22:52 +0100 Subject: [PATCH 135/180] orinoco: Annotate ezusb_read_ltv() ezusb_read_ltv() is always invoked via the ->read_ltv() callback. This callback is mostly invoked under orinoco_lock() which disables BH. There are a few invocations during probe which occur in preemptible context via: ezusb_probe() -> orinoco_init() -> determine_fw_capabilities() Extend `hermes_ops' with the ->read_ltv_pr callback which is implemented with the same callback like ->read_ltv on `hermes_ops_local'. On `ezusb_ops' ->read_ltv is used for callbacks under the lock which need to poll. The new ->read_ltv_pr() is used in the preemptible context in which it is possible to wait for the completion. Provide HERMES_READ_RECORD_PR() and hermes_read_wordrec_pr() which behave like their non _pr equivalents and invoke ->read_ltv_pr(). This removes the last user of ezusb_req_ctx_wait() and can now be removed. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201113212252.2243570-11-bigeasy@linutronix.de --- .../net/wireless/intersil/orinoco/hermes.c | 1 + .../net/wireless/intersil/orinoco/hermes.h | 15 ++++++ drivers/net/wireless/intersil/orinoco/hw.c | 32 ++++++------ .../wireless/intersil/orinoco/orinoco_usb.c | 49 ++++++++----------- 4 files changed, 52 insertions(+), 45 deletions(-) diff --git a/drivers/net/wireless/intersil/orinoco/hermes.c b/drivers/net/wireless/intersil/orinoco/hermes.c index 43790fbea0e0..6d4b7f64efcf 100644 --- a/drivers/net/wireless/intersil/orinoco/hermes.c +++ b/drivers/net/wireless/intersil/orinoco/hermes.c @@ -763,6 +763,7 @@ static const struct hermes_ops hermes_ops_local = { .init_cmd_wait = hermes_doicmd_wait, .allocate = hermes_allocate, .read_ltv = hermes_read_ltv, + .read_ltv_pr = hermes_read_ltv, .write_ltv = hermes_write_ltv, .bap_pread = hermes_bap_pread, .bap_pwrite = hermes_bap_pwrite, diff --git a/drivers/net/wireless/intersil/orinoco/hermes.h b/drivers/net/wireless/intersil/orinoco/hermes.h index 9f668185b7d2..3dc561a5cb7a 100644 --- a/drivers/net/wireless/intersil/orinoco/hermes.h +++ b/drivers/net/wireless/intersil/orinoco/hermes.h @@ -386,6 +386,8 @@ struct hermes_ops { int (*allocate)(struct hermes *hw, u16 size, u16 *fid); int (*read_ltv)(struct hermes *hw, int bap, u16 rid, unsigned buflen, u16 *length, void *buf); + int (*read_ltv_pr)(struct hermes *hw, int bap, u16 rid, + unsigned buflen, u16 *length, void *buf); int (*write_ltv)(struct hermes *hw, int bap, u16 rid, u16 length, const void *value); int (*bap_pread)(struct hermes *hw, int bap, void *buf, int len, @@ -494,6 +496,8 @@ static inline void hermes_clear_words(struct hermes *hw, int off, #define HERMES_READ_RECORD(hw, bap, rid, buf) \ (hw->ops->read_ltv((hw), (bap), (rid), sizeof(*buf), NULL, (buf))) +#define HERMES_READ_RECORD_PR(hw, bap, rid, buf) \ + (hw->ops->read_ltv_pr((hw), (bap), (rid), sizeof(*buf), NULL, (buf))) #define HERMES_WRITE_RECORD(hw, bap, rid, buf) \ (hw->ops->write_ltv((hw), (bap), (rid), \ HERMES_BYTES_TO_RECLEN(sizeof(*buf)), (buf))) @@ -509,6 +513,17 @@ static inline int hermes_read_wordrec(struct hermes *hw, int bap, u16 rid, return err; } +static inline int hermes_read_wordrec_pr(struct hermes *hw, int bap, u16 rid, + u16 *word) +{ + __le16 rec; + int err; + + err = HERMES_READ_RECORD_PR(hw, bap, rid, &rec); + *word = le16_to_cpu(rec); + return err; +} + static inline int hermes_write_wordrec(struct hermes *hw, int bap, u16 rid, u16 word) { diff --git a/drivers/net/wireless/intersil/orinoco/hw.c b/drivers/net/wireless/intersil/orinoco/hw.c index 61af5a28f269..2c7adb4be100 100644 --- a/drivers/net/wireless/intersil/orinoco/hw.c +++ b/drivers/net/wireless/intersil/orinoco/hw.c @@ -78,7 +78,7 @@ int determine_fw_capabilities(struct orinoco_private *priv, char tmp[SYMBOL_MAX_VER_LEN + 1] __attribute__((aligned(2))); /* Get the hardware version */ - err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id); + err = HERMES_READ_RECORD_PR(hw, USER_BAP, HERMES_RID_NICID, &nic_id); if (err) { dev_err(dev, "Cannot read hardware identity: error %d\n", err); @@ -101,7 +101,7 @@ int determine_fw_capabilities(struct orinoco_private *priv, priv->firmware_type = determine_firmware_type(&nic_id); /* Get the firmware version */ - err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_STAID, &sta_id); + err = HERMES_READ_RECORD_PR(hw, USER_BAP, HERMES_RID_STAID, &sta_id); if (err) { dev_err(dev, "Cannot read station identity: error %d\n", err); @@ -177,7 +177,7 @@ int determine_fw_capabilities(struct orinoco_private *priv, /* 3Com MAC : 00:50:DA:* */ memset(tmp, 0, sizeof(tmp)); /* Get the Symbol firmware version */ - err = hw->ops->read_ltv(hw, USER_BAP, + err = hw->ops->read_ltv_pr(hw, USER_BAP, HERMES_RID_SECONDARYVERSION_SYMBOL, SYMBOL_MAX_VER_LEN, NULL, &tmp); if (err) { @@ -286,7 +286,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) u16 reclen; /* Get the MAC address */ - err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, + err = hw->ops->read_ltv_pr(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, ETH_ALEN, NULL, dev_addr); if (err) { dev_warn(dev, "Failed to read MAC address!\n"); @@ -296,7 +296,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) dev_dbg(dev, "MAC address %pM\n", dev_addr); /* Get the station name */ - err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, + err = hw->ops->read_ltv_pr(hw, USER_BAP, HERMES_RID_CNFOWNNAME, sizeof(nickbuf), &reclen, &nickbuf); if (err) { dev_err(dev, "failed to read station name\n"); @@ -312,7 +312,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) dev_dbg(dev, "Station name \"%s\"\n", priv->nick); /* Get allowed channels */ - err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CHANNELLIST, &priv->channel_mask); if (err) { dev_err(dev, "Failed to read channel list!\n"); @@ -320,13 +320,13 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) } /* Get initial AP density */ - err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFSYSTEMSCALE, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CNFSYSTEMSCALE, &priv->ap_density); if (err || priv->ap_density < 1 || priv->ap_density > 3) priv->has_sensitivity = 0; /* Get initial RTS threshold */ - err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD, &priv->rts_thresh); if (err) { dev_err(dev, "Failed to read RTS threshold!\n"); @@ -335,11 +335,11 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) /* Get initial fragmentation settings */ if (priv->has_mwo) - err = hermes_read_wordrec(hw, USER_BAP, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CNFMWOROBUST_AGERE, &priv->mwo_robust); else - err = hermes_read_wordrec(hw, USER_BAP, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, &priv->frag_thresh); if (err) { @@ -351,7 +351,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) if (priv->has_pm) { priv->pm_on = 0; priv->pm_mcast = 1; - err = hermes_read_wordrec(hw, USER_BAP, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CNFMAXSLEEPDURATION, &priv->pm_period); if (err) { @@ -359,7 +359,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) "period!\n"); goto out; } - err = hermes_read_wordrec(hw, USER_BAP, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CNFPMHOLDOVERDURATION, &priv->pm_timeout); if (err) { @@ -371,7 +371,7 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) /* Preamble setup */ if (priv->has_preamble) { - err = hermes_read_wordrec(hw, USER_BAP, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CNFPREAMBLE_SYMBOL, &priv->preamble); if (err) { @@ -381,21 +381,21 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) } /* Retry settings */ - err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_SHORTRETRYLIMIT, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_SHORTRETRYLIMIT, &priv->short_retry_limit); if (err) { dev_err(dev, "Failed to read short retry limit\n"); goto out; } - err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_LONGRETRYLIMIT, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_LONGRETRYLIMIT, &priv->long_retry_limit); if (err) { dev_err(dev, "Failed to read long retry limit\n"); goto out; } - err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_MAXTRANSMITLIFETIME, + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_MAXTRANSMITLIFETIME, &priv->retry_lifetime); if (err) { dev_err(dev, "Failed to read max retry lifetime\n"); diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index 4c60b4821463..dd31929261ab 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -667,32 +667,6 @@ static void ezusb_request_in_callback(struct ezusb_priv *upriv, typedef void (*ezusb_ctx_wait)(struct ezusb_priv *, struct request_context *); -static void ezusb_req_ctx_wait(struct ezusb_priv *upriv, - struct request_context *ctx) -{ - switch (ctx->state) { - case EZUSB_CTX_QUEUED: - case EZUSB_CTX_REQ_SUBMITTED: - case EZUSB_CTX_REQ_COMPLETE: - case EZUSB_CTX_RESP_RECEIVED: - if (in_softirq()) { - /* If we get called from a timer, timeout timers don't - * get the chance to run themselves. So we make sure - * that we don't sleep for ever */ - int msecs = DEF_TIMEOUT * (1000 / HZ); - - while (!try_wait_for_completion(&ctx->done) && msecs--) - udelay(1000); - } else { - wait_for_completion(&ctx->done); - } - break; - default: - /* Done or failed - nothing to wait for */ - break; - } -} - static void ezusb_req_ctx_wait_compl(struct ezusb_priv *upriv, struct request_context *ctx) { @@ -1032,8 +1006,10 @@ static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid, ezusb_req_ctx_wait_poll); } -static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid, - unsigned bufsize, u16 *length, void *buf) +static int __ezusb_read_ltv(struct hermes *hw, int bap, u16 rid, + unsigned bufsize, u16 *length, void *buf, + ezusb_ctx_wait ezusb_ctx_wait_func) + { struct ezusb_priv *upriv = hw->priv; struct request_context *ctx; @@ -1046,7 +1022,21 @@ static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid, return -ENOMEM; return ezusb_access_ltv(upriv, ctx, 0, NULL, EZUSB_FRAME_CONTROL, - buf, bufsize, length, ezusb_req_ctx_wait); + buf, bufsize, length, ezusb_req_ctx_wait_poll); +} + +static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid, + unsigned bufsize, u16 *length, void *buf) +{ + return __ezusb_read_ltv(hw, bap, rid, bufsize, length, buf, + ezusb_req_ctx_wait_poll); +} + +static int ezusb_read_ltv_preempt(struct hermes *hw, int bap, u16 rid, + unsigned bufsize, u16 *length, void *buf) +{ + return __ezusb_read_ltv(hw, bap, rid, bufsize, length, buf, + ezusb_req_ctx_wait_compl); } static int ezusb_doicmd_wait(struct hermes *hw, u16 cmd, u16 parm0, u16 parm1, @@ -1586,6 +1576,7 @@ static const struct hermes_ops ezusb_ops = { .init_cmd_wait = ezusb_doicmd_wait, .allocate = ezusb_allocate, .read_ltv = ezusb_read_ltv, + .read_ltv_pr = ezusb_read_ltv_preempt, .write_ltv = ezusb_write_ltv, .bap_pread = ezusb_bap_pread, .read_pda = ezusb_read_pda, From 0409d504aa6c621629855f8ac72c29ac6fcebbf0 Mon Sep 17 00:00:00 2001 From: Kaixu Xia Date: Sat, 14 Nov 2020 13:45:35 +0800 Subject: [PATCH 136/180] rtlwifi: rtl8192de: remove the useless value assignment The variable u4tmp is overwritten by the following call and the assignment is useless, so remove it. Reported-by: Tosk Robot Signed-off-by: Kaixu Xia Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1605332735-9648-1-git-send-email-kaixuxia@tencent.com --- drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c index e34d33e73e52..68ec009ea157 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c @@ -2566,7 +2566,7 @@ static void _rtl92d_phy_lc_calibrate_sw(struct ieee80211_hw *hw, bool is2t) } RTPRINT(rtlpriv, FINIT, INIT_IQK, "PHY_LCK finish delay for %d ms=2\n", timecount); - u4tmp = rtl_get_rfreg(hw, index, RF_SYN_G4, RFREG_OFFSET_MASK); + rtl_get_rfreg(hw, index, RF_SYN_G4, RFREG_OFFSET_MASK); if (index == 0 && rtlhal->interfaceindex == 0) { RTPRINT(rtlpriv, FINIT, INIT_IQK, "path-A / 5G LCK\n"); From 31e07aa33fa7cdc93fa91c3f78f031e8d38862c2 Mon Sep 17 00:00:00 2001 From: Wang Hai Date: Sat, 14 Nov 2020 20:33:47 +0800 Subject: [PATCH 137/180] qtnfmac: fix error return code in qtnf_pcie_probe() Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Fixes: b7da53cd6cd1 ("qtnfmac_pcie: use single PCIe driver for all platforms") Reported-by: Hulk Robot Signed-off-by: Wang Hai Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201114123347.29632-1-wanghai38@huawei.com --- drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c index 5337e67092ca..0f328ce47fee 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c +++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c @@ -299,19 +299,19 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) sysctl_bar = qtnf_map_bar(pdev, QTN_SYSCTL_BAR); if (IS_ERR(sysctl_bar)) { pr_err("failed to map BAR%u\n", QTN_SYSCTL_BAR); - return ret; + return PTR_ERR(sysctl_bar); } dmareg_bar = qtnf_map_bar(pdev, QTN_DMA_BAR); if (IS_ERR(dmareg_bar)) { pr_err("failed to map BAR%u\n", QTN_DMA_BAR); - return ret; + return PTR_ERR(dmareg_bar); } epmem_bar = qtnf_map_bar(pdev, QTN_SHMEM_BAR); if (IS_ERR(epmem_bar)) { pr_err("failed to map BAR%u\n", QTN_SHMEM_BAR); - return ret; + return PTR_ERR(epmem_bar); } chipid = qtnf_chip_id_get(sysctl_bar); From fa3622bbea10c5083ce4f84da79248d4e22fea4b Mon Sep 17 00:00:00 2001 From: Remi Depommier Date: Sun, 15 Nov 2020 19:16:39 -0500 Subject: [PATCH 138/180] brcmfmac: Fix incorrect type in assignment The left-hand side of the assignment from cpu_to_le32() should be of type __le32. This commit clears the warning reported by sparse when building with C=1 CF="-D__CHECK_ENDIAN__". Fixes: d56fd83cf99c ("brcmfmac: fix SDIO access for big-endian host") Reported-by: kernel test robot Signed-off-by: Remi Depommier Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201116001639.31958-1-rde@setrix.com --- .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index f58a96fa4eb5..805e8d121d00 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -3517,6 +3517,7 @@ static int brcmf_sdio_bus_preinit(struct device *dev) struct brcmf_sdio *bus = sdiodev->bus; struct brcmf_core *core = bus->sdio_core; u32 value; + __le32 iovar; int err; /* maxctl provided by common layer */ @@ -3537,16 +3538,16 @@ static int brcmf_sdio_bus_preinit(struct device *dev) */ if (core->rev < 12) { /* for sdio core rev < 12, disable txgloming */ - value = 0; - err = brcmf_iovar_data_set(dev, "bus:txglom", &value, - sizeof(u32)); + iovar = 0; + err = brcmf_iovar_data_set(dev, "bus:txglom", &iovar, + sizeof(iovar)); } else { /* otherwise, set txglomalign */ value = sdiodev->settings->bus.sdio.sd_sgentry_align; /* SDIO ADMA requires at least 32 bit alignment */ - value = cpu_to_le32(max_t(u32, value, ALIGNMENT)); - err = brcmf_iovar_data_set(dev, "bus:txglomalign", &value, - sizeof(u32)); + iovar = cpu_to_le32(max_t(u32, value, ALIGNMENT)); + err = brcmf_iovar_data_set(dev, "bus:txglomalign", &iovar, + sizeof(iovar)); } if (err < 0) @@ -3555,9 +3556,9 @@ static int brcmf_sdio_bus_preinit(struct device *dev) bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN; if (sdiodev->sg_support) { bus->txglom = false; - value = cpu_to_le32(1); + iovar = cpu_to_le32(1); err = brcmf_iovar_data_set(bus->sdiodev->dev, "bus:rxglom", - &value, sizeof(u32)); + &iovar, sizeof(iovar)); if (err < 0) { /* bus:rxglom is allowed to fail */ err = 0; From 01c195de620bb6c3ecda0dbf295fe685d8232e10 Mon Sep 17 00:00:00 2001 From: Dmitry Safonov Date: Mon, 16 Nov 2020 03:06:35 +0000 Subject: [PATCH 139/180] brcmsmac: ampdu: Check BA window size before checking block ack bindex can be out of BA window (64): tid 0 seq 2983, start_seq 2915, bindex 68, index 39 tid 0 seq 2984, start_seq 2915, bindex 69, index 40 tid 0 seq 2985, start_seq 2915, bindex 70, index 41 tid 0 seq 2986, start_seq 2915, bindex 71, index 42 tid 0 seq 2879, start_seq 2915, bindex 4060, index 63 tid 0 seq 2854, start_seq 2915, bindex 4035, index 38 tid 0 seq 2795, start_seq 2915, bindex 3976, index 43 tid 0 seq 2989, start_seq 2924, bindex 65, index 45 tid 0 seq 2992, start_seq 2924, bindex 68, index 48 tid 0 seq 2993, start_seq 2924, bindex 69, index 49 tid 0 seq 2994, start_seq 2924, bindex 70, index 50 tid 0 seq 2997, start_seq 2924, bindex 73, index 53 tid 0 seq 2795, start_seq 2941, bindex 3950, index 43 tid 0 seq 2921, start_seq 2941, bindex 4076, index 41 tid 0 seq 2929, start_seq 2941, bindex 4084, index 49 tid 0 seq 3011, start_seq 2946, bindex 65, index 3 tid 0 seq 3012, start_seq 2946, bindex 66, index 4 tid 0 seq 3013, start_seq 2946, bindex 67, index 5 In result isset() will try to dereference something on the stack, causing panics: BUG: unable to handle page fault for address: ffffa742800ed01f #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 6a4e9067 P4D 6a4e9067 PUD 6a4ec067 PMD 6a4ed067 PTE 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 1 PID: 0 Comm: swapper/1 Kdump: loaded Not tainted 5.8.5-arch1-1-kdump #1 Hardware name: Apple Inc. MacBookAir3,1/Mac-942452F5819B1C1B, BIOS MBA31.88Z.0061.B07.1201241641 01/24/12 RIP: 0010:brcms_c_ampdu_dotxstatus+0x343/0x9f0 [brcmsmac] Code: 54 24 20 66 81 e2 ff 0f 41 83 e4 07 89 d1 0f b7 d2 66 c1 e9 03 0f b7 c9 4c 8d 5c 0c 48 49 8b 4d 10 48 8b 79 68 41 57 44 89 e1 <41> 0f b6 33 41 d3 e0 48 c7 c1 38 e0 ea c0 48 83 c7 10 44 21 c6 4c RSP: 0018:ffffa742800ecdd0 EFLAGS: 00010207 RAX: 0000000000000019 RBX: 000000000000000b RCX: 0000000000000006 RDX: 0000000000000ffe RSI: 0000000000000004 RDI: ffff8fc6ad776800 RBP: ffff8fc6855acb00 R08: 0000000000000001 R09: 00000000000005d9 R10: 00000000fffffffe R11: ffffa742800ed01f R12: 0000000000000006 R13: ffff8fc68d75a000 R14: 00000000000005db R15: 0000000000000019 FS: 0000000000000000(0000) GS:ffff8fc6aad00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffa742800ed01f CR3: 000000002480a000 CR4: 00000000000406e0 Call Trace: brcms_c_dpc+0xb46/0x1020 [brcmsmac] ? wlc_intstatus+0xc8/0x180 [brcmsmac] ? __raise_softirq_irqoff+0x1a/0x80 brcms_dpc+0x37/0xd0 [brcmsmac] tasklet_action_common.constprop.0+0x51/0xb0 __do_softirq+0xff/0x340 ? handle_level_irq+0x1a0/0x1a0 asm_call_on_stack+0x12/0x20 do_softirq_own_stack+0x5f/0x80 irq_exit_rcu+0xcb/0x120 common_interrupt+0xd1/0x200 asm_common_interrupt+0x1e/0x40 RIP: 0010:cpuidle_enter_state+0xb3/0x420 Check if the block is within BA window and only then check block's status. Otherwise as Behan wrote: "When I came back to Dublin I was courtmartialed in my absence and sentenced to death in my absence, so I said they could shoot me in my absence." Also reported: https://bbs.archlinux.org/viewtopic.php?id=258428 https://lore.kernel.org/linux-wireless/87tuwgi92n.fsf@yujinakao.com/ Reported-by: Yuji Nakao Signed-off-by: Dmitry Safonov Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201116030635.645811-1-dima@arista.com --- .../net/wireless/broadcom/brcm80211/brcmsmac/ampdu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/ampdu.c index c9fb4b0cffaf..2631eb7569eb 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/ampdu.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/ampdu.c @@ -942,14 +942,19 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, index = TX_SEQ_TO_INDEX(seq); ack_recd = false; if (ba_recd) { + int block_acked; + bindex = MODSUB_POW2(seq, start_seq, SEQNUM_MAX); + if (bindex < AMPDU_TX_BA_MAX_WSIZE) + block_acked = isset(bitmap, bindex); + else + block_acked = 0; brcms_dbg_ht(wlc->hw->d11core, "tid %d seq %d, start_seq %d, bindex %d set %d, index %d\n", tid, seq, start_seq, bindex, - isset(bitmap, bindex), index); + block_acked, index); /* if acked then clear bit and free packet */ - if ((bindex < AMPDU_TX_BA_MAX_WSIZE) - && isset(bitmap, bindex)) { + if (block_acked) { ini->txretry[index] = 0; /* From fb21d14694bd46a538258d86498736490b3ba855 Mon Sep 17 00:00:00 2001 From: Zhang Changzhong Date: Tue, 17 Nov 2020 11:07:34 +0800 Subject: [PATCH 140/180] rsi: fix error return code in rsi_reset_card() Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Fixes: 17ff2c794f39 ("rsi: reset device changes for 9116") Reported-by: Hulk Robot Signed-off-by: Zhang Changzhong Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1605582454-39649-1-git-send-email-zhangchangzhong@huawei.com --- drivers/net/wireless/rsi/rsi_91x_usb.c | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c index 8928e1467151..a4a533c2a783 100644 --- a/drivers/net/wireless/rsi/rsi_91x_usb.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb.c @@ -743,24 +743,24 @@ static int rsi_reset_card(struct rsi_hw *adapter) if (ret < 0) goto fail; } else { - if ((rsi_usb_master_reg_write(adapter, - NWP_WWD_INTERRUPT_TIMER, - NWP_WWD_INT_TIMER_CLKS, - RSI_9116_REG_SIZE)) < 0) { + ret = rsi_usb_master_reg_write(adapter, + NWP_WWD_INTERRUPT_TIMER, + NWP_WWD_INT_TIMER_CLKS, + RSI_9116_REG_SIZE); + if (ret < 0) goto fail; - } - if ((rsi_usb_master_reg_write(adapter, - NWP_WWD_SYSTEM_RESET_TIMER, - NWP_WWD_SYS_RESET_TIMER_CLKS, - RSI_9116_REG_SIZE)) < 0) { + ret = rsi_usb_master_reg_write(adapter, + NWP_WWD_SYSTEM_RESET_TIMER, + NWP_WWD_SYS_RESET_TIMER_CLKS, + RSI_9116_REG_SIZE); + if (ret < 0) goto fail; - } - if ((rsi_usb_master_reg_write(adapter, - NWP_WWD_MODE_AND_RSTART, - NWP_WWD_TIMER_DISABLE, - RSI_9116_REG_SIZE)) < 0) { + ret = rsi_usb_master_reg_write(adapter, + NWP_WWD_MODE_AND_RSTART, + NWP_WWD_TIMER_DISABLE, + RSI_9116_REG_SIZE); + if (ret < 0) goto fail; - } } rsi_dbg(INFO_ZONE, "Reset card done\n"); From 00331758137245fd3478404ee81de40dfcb3b7de Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 17 Nov 2020 10:09:58 -0600 Subject: [PATCH 141/180] mwifiex: Fix fall-through warnings for Clang In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of letting the code fall through to the next case. Link: https://github.com/KSPP/linux/issues/115 Signed-off-by: Gustavo A. R. Silva Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201117160958.GA18807@embeddedor --- drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c | 2 ++ drivers/net/wireless/marvell/mwifiex/sta_event.c | 1 + drivers/net/wireless/marvell/mwifiex/uap_cmd.c | 1 + drivers/net/wireless/marvell/mwifiex/wmm.c | 1 + 4 files changed, 5 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c index 119ccacd1fcc..6b5d35d9e69f 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c @@ -201,6 +201,7 @@ static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv, mwifiex_dbg(priv->adapter, INFO, "info: SNMP_RESP: DTIM period=%u\n", ul_temp); + break; default: break; } @@ -1393,6 +1394,7 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, break; case HostCmd_CMD_TDLS_OPER: ret = mwifiex_ret_tdls_oper(priv, resp); + break; case HostCmd_CMD_MC_POLICY: break; case HostCmd_CMD_CHAN_REPORT_REQUEST: diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c b/drivers/net/wireless/marvell/mwifiex/sta_event.c index bc79ca4cb803..68c63268e2e6 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_event.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c @@ -99,6 +99,7 @@ static int mwifiex_check_ibss_peer_capabilities(struct mwifiex_private *priv, case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895: sta_ptr->max_amsdu = MWIFIEX_TX_DATA_BUF_SIZE_4K; + break; default: break; } diff --git a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c index b48a85d791f6..18e89777b784 100644 --- a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c +++ b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c @@ -108,6 +108,7 @@ int mwifiex_set_secure_params(struct mwifiex_private *priv, if (params->crypto.wpa_versions & NL80211_WPA_VERSION_2) bss_config->wpa_cfg.pairwise_cipher_wpa2 |= CIPHER_AES_CCMP; + break; default: break; } diff --git a/drivers/net/wireless/marvell/mwifiex/wmm.c b/drivers/net/wireless/marvell/mwifiex/wmm.c index b8f19ca73414..0b375608df7d 100644 --- a/drivers/net/wireless/marvell/mwifiex/wmm.c +++ b/drivers/net/wireless/marvell/mwifiex/wmm.c @@ -1396,6 +1396,7 @@ mwifiex_send_processed_packet(struct mwifiex_private *priv, break; case 0: mwifiex_write_data_complete(adapter, skb, 0, ret); + break; default: break; } From 6df3c293d284655c72c1a72356ce4d32217a9c54 Mon Sep 17 00:00:00 2001 From: Jia-Ju Bai Date: Thu, 19 Nov 2020 09:51:27 +0800 Subject: [PATCH 142/180] rtlwifi: rtl8188ee: avoid accessing the data mapped to streaming DMA In rtl88ee_tx_fill_cmddesc(), skb->data is mapped to streaming DMA on line 677: dma_addr_t mapping = dma_map_single(..., skb->data, ...); On line 680, skb->data is assigned to hdr after cast: struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); Then hdr->frame_control is accessed on line 681: __le16 fc = hdr->frame_control; This DMA access may cause data inconsistency between CPU and hardwre. To fix this bug, hdr->frame_control is accessed before the DMA mapping. Signed-off-by: Jia-Ju Bai Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201119015127.12033-1-baijiaju1990@gmail.com --- drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c index b9775eec4c54..c948dafa0c80 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c @@ -674,12 +674,12 @@ void rtl88ee_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 fw_queue = QSLT_BEACON; __le32 *pdesc = (__le32 *)pdesc8; - dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, - skb->len, DMA_TO_DEVICE); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); __le16 fc = hdr->frame_control; + dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, + skb->len, DMA_TO_DEVICE); + if (dma_mapping_error(&rtlpci->pdev->dev, mapping)) { rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, "DMA mapping error\n"); From c7ba0ea0df370975a484c30e711e8a483c1b96a4 Mon Sep 17 00:00:00 2001 From: Jia-Ju Bai Date: Thu, 19 Nov 2020 09:51:51 +0800 Subject: [PATCH 143/180] rtlwifi: rtl8192ce: avoid accessing the data mapped to streaming DMA In rtl92ce_tx_fill_cmddesc(), skb->data is mapped to streaming DMA on line 530: dma_addr_t mapping = dma_map_single(..., skb->data, ...); On line 533, skb->data is assigned to hdr after cast: struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); Then hdr->frame_control is accessed on line 534: __le16 fc = hdr->frame_control; This DMA access may cause data inconsistency between CPU and hardwre. To fix this bug, hdr->frame_control is accessed before the DMA mapping. Signed-off-by: Jia-Ju Bai Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201119015151.12110-1-baijiaju1990@gmail.com --- drivers/net/wireless/realtek/rtlwifi/rtl8192ce/trx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/trx.c index c0635309a92d..4165175cf5c0 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/trx.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/trx.c @@ -527,12 +527,12 @@ void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 fw_queue = QSLT_BEACON; __le32 *pdesc = (__le32 *)pdesc8; - dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, - skb->len, DMA_TO_DEVICE); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); __le16 fc = hdr->frame_control; + dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, + skb->len, DMA_TO_DEVICE); + if (dma_mapping_error(&rtlpci->pdev->dev, mapping)) { rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, "DMA mapping error\n"); From ff76548338947c2c45b7aaf1d182e331398279b7 Mon Sep 17 00:00:00 2001 From: Jia-Ju Bai Date: Thu, 19 Nov 2020 09:52:05 +0800 Subject: [PATCH 144/180] rtlwifi: rtl8192de: avoid accessing the data mapped to streaming DMA In rtl92de_tx_fill_cmddesc(), skb->data is mapped to streaming DMA on line 667: dma_addr_t mapping = dma_map_single(..., skb->data, ...); On line 669, skb->data is assigned to hdr after cast: struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); Then hdr->frame_control is accessed on line 670: __le16 fc = hdr->frame_control; This DMA access may cause data inconsistency between CPU and hardwre. To fix this bug, hdr->frame_control is accessed before the DMA mapping. Signed-off-by: Jia-Ju Bai Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201119015205.12162-1-baijiaju1990@gmail.com --- drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c index 8944712274b5..c02813fba934 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c @@ -664,12 +664,14 @@ void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw, struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); struct rtl_hal *rtlhal = rtl_hal(rtlpriv); u8 fw_queue = QSLT_BEACON; - dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, - skb->len, DMA_TO_DEVICE); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); __le16 fc = hdr->frame_control; __le32 *pdesc = (__le32 *)pdesc8; + dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, + skb->len, DMA_TO_DEVICE); + if (dma_mapping_error(&rtlpci->pdev->dev, mapping)) { rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, "DMA mapping error\n"); From 8b2c13b2e5dab8f2ace44cc775096c6fae0a6f72 Mon Sep 17 00:00:00 2001 From: Jia-Ju Bai Date: Thu, 19 Nov 2020 09:52:18 +0800 Subject: [PATCH 145/180] rtlwifi: rtl8723ae: avoid accessing the data mapped to streaming DMA In rtl8723e_tx_fill_cmddesc(), skb->data is mapped to streaming DMA on line 531: dma_addr_t mapping = dma_map_single(..., skb->data, ...); On line 534, skb->data is assigned to hdr after cast: struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); Then hdr->frame_control is accessed on line 535: __le16 fc = hdr->frame_control; This DMA access may cause data inconsistency between CPU and hardwre. To fix this bug, hdr->frame_control is accessed before the DMA mapping. Signed-off-by: Jia-Ju Bai Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201119015218.12220-1-baijiaju1990@gmail.com --- drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c index e3ee91b7ea8d..340b3d68a54e 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c @@ -528,12 +528,12 @@ void rtl8723e_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 fw_queue = QSLT_BEACON; __le32 *pdesc = (__le32 *)pdesc8; - dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, - skb->len, DMA_TO_DEVICE); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); __le16 fc = hdr->frame_control; + dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, + skb->len, DMA_TO_DEVICE); + if (dma_mapping_error(&rtlpci->pdev->dev, mapping)) { rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, "DMA mapping error\n"); From 3c72d3843e223abdb3fc0f923a85238bd782df29 Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Thu, 19 Nov 2020 10:12:04 +0800 Subject: [PATCH 146/180] mwifiex: Remove duplicated REG_PORT definition The REG_PORT is defined twice, so remove one of them. Signed-off-by: Jisheng Zhang Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201119101204.72fd5f0a@xhacker.debian --- drivers/net/wireless/marvell/mwifiex/sdio.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.h b/drivers/net/wireless/marvell/mwifiex/sdio.h index dec534a6ddb1..5648512c9300 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.h +++ b/drivers/net/wireless/marvell/mwifiex/sdio.h @@ -43,8 +43,6 @@ #define BLOCK_MODE 1 #define BYTE_MODE 0 -#define REG_PORT 0 - #define MWIFIEX_SDIO_IO_PORT_MASK 0xfffff #define MWIFIEX_SDIO_BYTE_MODE_MASK 0x80000000 From 7ec8a926188eb8e7a3cbaca43ec44f2d7146d71b Mon Sep 17 00:00:00 2001 From: Qinglang Miao Date: Thu, 19 Nov 2020 15:08:42 +0800 Subject: [PATCH 147/180] cw1200: fix missing destroy_workqueue() on error in cw1200_init_common Add the missing destroy_workqueue() before return from cw1200_init_common in the error handling case. Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201119070842.1011-1-miaoqinglang@huawei.com --- drivers/net/wireless/st/cw1200/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/st/cw1200/main.c b/drivers/net/wireless/st/cw1200/main.c index f7fe56affbcd..326b1cc1d2bc 100644 --- a/drivers/net/wireless/st/cw1200/main.c +++ b/drivers/net/wireless/st/cw1200/main.c @@ -381,6 +381,7 @@ static struct ieee80211_hw *cw1200_init_common(const u8 *macaddr, CW1200_LINK_ID_MAX, cw1200_skb_dtor, priv)) { + destroy_workqueue(priv->workqueue); ieee80211_free_hw(hw); return NULL; } @@ -392,6 +393,7 @@ static struct ieee80211_hw *cw1200_init_common(const u8 *macaddr, for (; i > 0; i--) cw1200_queue_deinit(&priv->tx_queue[i - 1]); cw1200_queue_stats_deinit(&priv->tx_queue_stats); + destroy_workqueue(priv->workqueue); ieee80211_free_hw(hw); return NULL; } From 3cbbdfbed1408ba55e2deeaf913c0e735086589b Mon Sep 17 00:00:00 2001 From: Ritesh Singh Date: Tue, 24 Nov 2020 17:59:13 +0200 Subject: [PATCH 148/180] ath11k: vdev delete synchronization with firmware When the interface is added immediately after removing the interface, vdev deletion in firmware might not have been completed. Hence, add vdev_delete_resp_event and wait_event_timeout to synchronize with firmware. Signed-off-by: Ritesh Singh Signed-off-by: Maharaja Kennadyrajan Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1605514143-17652-2-git-send-email-mkenna@codeaurora.org --- drivers/net/wireless/ath/ath11k/core.c | 1 + drivers/net/wireless/ath/ath11k/core.h | 2 + drivers/net/wireless/ath/ath11k/mac.c | 29 +++++++++--- drivers/net/wireless/ath/ath11k/wmi.c | 62 +++++++++++++++++++++++++- drivers/net/wireless/ath/ath11k/wmi.h | 4 ++ 5 files changed, 90 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c index c23a59a29792..f792825850b8 100644 --- a/drivers/net/wireless/ath/ath11k/core.c +++ b/drivers/net/wireless/ath/ath11k/core.c @@ -810,6 +810,7 @@ static void ath11k_core_restart(struct work_struct *work) complete(&ar->peer_assoc_done); complete(&ar->install_key_done); complete(&ar->vdev_setup_done); + complete(&ar->vdev_delete_done); complete(&ar->bss_survey_done); complete(&ar->thermal.wmi_sync); diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 8851cf80ac96..b1b8afecec3a 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -430,6 +430,7 @@ struct ath11k_per_peer_tx_stats { }; #define ATH11K_FLUSH_TIMEOUT (5 * HZ) +#define ATH11K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ) struct ath11k_vdev_stop_status { bool stop_in_progress; @@ -512,6 +513,7 @@ struct ath11k { int last_wmi_vdev_start_status; struct ath11k_vdev_stop_status vdev_stop_status; struct completion vdev_setup_done; + struct completion vdev_delete_done; int num_peers; int max_num_peers; diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 70fc253de8ef..566e2a498a82 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -4660,6 +4660,7 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw, struct ath11k *ar = hw->priv; struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); struct ath11k_base *ab = ar->ab; + unsigned long time_left; int ret; int i; @@ -4668,10 +4669,6 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw, ath11k_dbg(ab, ATH11K_DBG_MAC, "mac remove interface (vdev %d)\n", arvif->vdev_id); - spin_lock_bh(&ar->data_lock); - list_del(&arvif->list); - spin_unlock_bh(&ar->data_lock); - if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { ret = ath11k_peer_delete(ar, arvif->vdev_id, vif->addr); if (ret) @@ -4679,16 +4676,33 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw, arvif->vdev_id, ret); } + reinit_completion(&ar->vdev_delete_done); + ret = ath11k_wmi_vdev_delete(ar, arvif->vdev_id); - if (ret) + if (ret) { ath11k_warn(ab, "failed to delete WMI vdev %d: %d\n", arvif->vdev_id, ret); + goto err_vdev_del; + } + time_left = wait_for_completion_timeout(&ar->vdev_delete_done, + ATH11K_VDEV_DELETE_TIMEOUT_HZ); + if (time_left == 0) { + ath11k_warn(ab, "Timeout in receiving vdev delete response\n"); + goto err_vdev_del; + } + + ab->free_vdev_map |= 1LL << (arvif->vdev_id); + ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); ar->num_created_vdevs--; + ath11k_dbg(ab, ATH11K_DBG_MAC, "vdev %pM deleted, vdev_id %d\n", vif->addr, arvif->vdev_id); - ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); - ab->free_vdev_map |= 1LL << (arvif->vdev_id); + +err_vdev_del: + spin_lock_bh(&ar->data_lock); + list_del(&arvif->list); + spin_unlock_bh(&ar->data_lock); ath11k_peer_cleanup(ar, arvif->vdev_id); @@ -6454,6 +6468,7 @@ int ath11k_mac_allocate(struct ath11k_base *ab) INIT_LIST_HEAD(&ar->ppdu_stats_info); mutex_init(&ar->conf_mutex); init_completion(&ar->vdev_setup_done); + init_completion(&ar->vdev_delete_done); init_completion(&ar->peer_assoc_done); init_completion(&ar->install_key_done); init_completion(&ar->bss_survey_done); diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index bca66c1d47ad..d1175a1c4de3 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -126,6 +126,8 @@ static const struct wmi_tlv_policy wmi_tlv_policies[] = { .min_len = sizeof(struct wmi_fils_discovery_event) }, [WMI_TAG_OFFLOAD_PRB_RSP_TX_STATUS_EVENT] = { .min_len = sizeof(struct wmi_probe_resp_tx_status_event) }, + [WMI_TAG_VDEV_DELETE_RESP_EVENT] = { + .min_len = sizeof(struct wmi_vdev_delete_resp_event) }, }; #define PRIMAP(_hw_mode_) \ @@ -4379,6 +4381,34 @@ static int ath11k_pull_peer_del_resp_ev(struct ath11k_base *ab, struct sk_buff * return 0; } +static int ath11k_pull_vdev_del_resp_ev(struct ath11k_base *ab, + struct sk_buff *skb, + u32 *vdev_id) +{ + const void **tb; + const struct wmi_vdev_delete_resp_event *ev; + int ret; + + tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); + if (IS_ERR(tb)) { + ret = PTR_ERR(tb); + ath11k_warn(ab, "failed to parse tlv: %d\n", ret); + return ret; + } + + ev = tb[WMI_TAG_VDEV_DELETE_RESP_EVENT]; + if (!ev) { + ath11k_warn(ab, "failed to fetch vdev delete resp ev"); + kfree(tb); + return -EPROTO; + } + + *vdev_id = ev->vdev_id; + + kfree(tb); + return 0; +} + static int ath11k_pull_bcn_tx_status_ev(struct ath11k_base *ab, void *evt_buf, u32 len, u32 *vdev_id, u32 *tx_status) @@ -5711,6 +5741,34 @@ static void ath11k_peer_delete_resp_event(struct ath11k_base *ab, struct sk_buff */ } +static void ath11k_vdev_delete_resp_event(struct ath11k_base *ab, + struct sk_buff *skb) +{ + struct ath11k *ar; + u32 vdev_id = 0; + + if (ath11k_pull_vdev_del_resp_ev(ab, skb, &vdev_id) != 0) { + ath11k_warn(ab, "failed to extract vdev delete resp"); + return; + } + + rcu_read_lock(); + ar = ath11k_mac_get_ar_by_vdev_id(ab, vdev_id); + if (!ar) { + ath11k_warn(ab, "invalid vdev id in vdev delete resp ev %d", + vdev_id); + rcu_read_unlock(); + return; + } + + complete(&ar->vdev_delete_done); + + rcu_read_unlock(); + + ath11k_dbg(ab, ATH11K_DBG_WMI, "vdev delete resp for vdev id %d\n", + vdev_id); +} + static inline const char *ath11k_wmi_vdev_resp_print(u32 vdev_resp_status) { switch (vdev_resp_status) { @@ -6722,7 +6780,6 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb) break; /* add Unsupported events here */ case WMI_TBTTOFFSET_EXT_UPDATE_EVENTID: - case WMI_VDEV_DELETE_RESP_EVENTID: case WMI_PEER_OPER_MODE_CHANGE_EVENTID: case WMI_TWT_ENABLE_EVENTID: case WMI_TWT_DISABLE_EVENTID: @@ -6733,6 +6790,9 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb) case WMI_PDEV_DFS_RADAR_DETECTION_EVENTID: ath11k_wmi_pdev_dfs_radar_detected_event(ab, skb); break; + case WMI_VDEV_DELETE_RESP_EVENTID: + ath11k_vdev_delete_resp_event(ab, skb); + break; /* TODO: Add remaining events */ default: ath11k_dbg(ab, ATH11K_DBG_WMI, "Unknown eventid: 0x%x\n", id); diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h index e4cc15904795..4c802c51b3d9 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.h +++ b/drivers/net/wireless/ath/ath11k/wmi.h @@ -4018,6 +4018,10 @@ struct wmi_regulatory_rule_struct { u32 flag_info; }; +struct wmi_vdev_delete_resp_event { + u32 vdev_id; +} __packed; + struct wmi_peer_delete_resp_event { u32 vdev_id; struct wmi_mac_addr peer_macaddr; From 690ace20ff790f443c3cbaf12e1769e4eb0072db Mon Sep 17 00:00:00 2001 From: Ritesh Singh Date: Tue, 24 Nov 2020 17:59:14 +0200 Subject: [PATCH 149/180] ath11k: peer delete synchronization with firmware Peer creation in firmware fails, if last peer deletion is still in progress. Hence, add wait for the event after deleting every peer from host driver to synchronize with firmware. Signed-off-by: Ritesh Singh Signed-off-by: Maharaja Kennadyrajan Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1605514143-17652-3-git-send-email-mkenna@codeaurora.org --- drivers/net/wireless/ath/ath11k/core.c | 1 + drivers/net/wireless/ath/ath11k/core.h | 1 + drivers/net/wireless/ath/ath11k/mac.c | 17 +++++++++- drivers/net/wireless/ath/ath11k/peer.c | 44 ++++++++++++++++++++++++-- drivers/net/wireless/ath/ath11k/peer.h | 2 ++ drivers/net/wireless/ath/ath11k/wmi.c | 17 ++++++++-- 6 files changed, 75 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c index f792825850b8..da20ed752ca5 100644 --- a/drivers/net/wireless/ath/ath11k/core.c +++ b/drivers/net/wireless/ath/ath11k/core.c @@ -808,6 +808,7 @@ static void ath11k_core_restart(struct work_struct *work) complete(&ar->scan.started); complete(&ar->scan.completed); complete(&ar->peer_assoc_done); + complete(&ar->peer_delete_done); complete(&ar->install_key_done); complete(&ar->vdev_setup_done); complete(&ar->vdev_delete_done); diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index b1b8afecec3a..88e5a9b9f52d 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -506,6 +506,7 @@ struct ath11k { u8 lmac_id; struct completion peer_assoc_done; + struct completion peer_delete_done; int install_key_status; struct completion install_key_done; diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 566e2a498a82..f97d22d7f923 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -4624,8 +4624,22 @@ static int ath11k_mac_op_add_interface(struct ieee80211_hw *hw, err_peer_del: if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { + reinit_completion(&ar->peer_delete_done); + + ret = ath11k_wmi_send_peer_delete_cmd(ar, vif->addr, + arvif->vdev_id); + if (ret) { + ath11k_warn(ar->ab, "failed to delete peer vdev_id %d addr %pM\n", + arvif->vdev_id, vif->addr); + return ret; + } + + ret = ath11k_wait_for_peer_delete_done(ar, arvif->vdev_id, + vif->addr); + if (ret) + return ret; + ar->num_peers--; - ath11k_wmi_send_peer_delete_cmd(ar, vif->addr, arvif->vdev_id); } err_vdev_del: @@ -6470,6 +6484,7 @@ int ath11k_mac_allocate(struct ath11k_base *ab) init_completion(&ar->vdev_setup_done); init_completion(&ar->vdev_delete_done); init_completion(&ar->peer_assoc_done); + init_completion(&ar->peer_delete_done); init_completion(&ar->install_key_done); init_completion(&ar->bss_survey_done); init_completion(&ar->scan.started); diff --git a/drivers/net/wireless/ath/ath11k/peer.c b/drivers/net/wireless/ath/ath11k/peer.c index 61ad9300eafb..1866d82678fa 100644 --- a/drivers/net/wireless/ath/ath11k/peer.c +++ b/drivers/net/wireless/ath/ath11k/peer.c @@ -177,12 +177,36 @@ static int ath11k_wait_for_peer_deleted(struct ath11k *ar, int vdev_id, const u8 return ath11k_wait_for_peer_common(ar->ab, vdev_id, addr, false); } +int ath11k_wait_for_peer_delete_done(struct ath11k *ar, u32 vdev_id, + const u8 *addr) +{ + int ret; + unsigned long time_left; + + ret = ath11k_wait_for_peer_deleted(ar, vdev_id, addr); + if (ret) { + ath11k_warn(ar->ab, "failed wait for peer deleted"); + return ret; + } + + time_left = wait_for_completion_timeout(&ar->peer_delete_done, + 3 * HZ); + if (time_left == 0) { + ath11k_warn(ar->ab, "Timeout in receiving peer delete response\n"); + return -ETIMEDOUT; + } + + return 0; +} + int ath11k_peer_delete(struct ath11k *ar, u32 vdev_id, u8 *addr) { int ret; lockdep_assert_held(&ar->conf_mutex); + reinit_completion(&ar->peer_delete_done); + ret = ath11k_wmi_send_peer_delete_cmd(ar, addr, vdev_id); if (ret) { ath11k_warn(ar->ab, @@ -191,7 +215,7 @@ int ath11k_peer_delete(struct ath11k *ar, u32 vdev_id, u8 *addr) return ret; } - ret = ath11k_wait_for_peer_deleted(ar, vdev_id, addr); + ret = ath11k_wait_for_peer_delete_done(ar, vdev_id, addr); if (ret) return ret; @@ -247,8 +271,22 @@ int ath11k_peer_create(struct ath11k *ar, struct ath11k_vif *arvif, spin_unlock_bh(&ar->ab->base_lock); ath11k_warn(ar->ab, "failed to find peer %pM on vdev %i after creation\n", param->peer_addr, param->vdev_id); - ath11k_wmi_send_peer_delete_cmd(ar, param->peer_addr, - param->vdev_id); + + reinit_completion(&ar->peer_delete_done); + + ret = ath11k_wmi_send_peer_delete_cmd(ar, param->peer_addr, + param->vdev_id); + if (ret) { + ath11k_warn(ar->ab, "failed to delete peer vdev_id %d addr %pM\n", + param->vdev_id, param->peer_addr); + return ret; + } + + ret = ath11k_wait_for_peer_delete_done(ar, param->vdev_id, + param->peer_addr); + if (ret) + return ret; + return -ENOENT; } diff --git a/drivers/net/wireless/ath/ath11k/peer.h b/drivers/net/wireless/ath/ath11k/peer.h index 5d125ce8984e..bba2e00b6944 100644 --- a/drivers/net/wireless/ath/ath11k/peer.h +++ b/drivers/net/wireless/ath/ath11k/peer.h @@ -41,5 +41,7 @@ void ath11k_peer_cleanup(struct ath11k *ar, u32 vdev_id); int ath11k_peer_delete(struct ath11k *ar, u32 vdev_id, u8 *addr); int ath11k_peer_create(struct ath11k *ar, struct ath11k_vif *arvif, struct ieee80211_sta *sta, struct peer_create_params *param); +int ath11k_wait_for_peer_delete_done(struct ath11k *ar, u32 vdev_id, + const u8 *addr); #endif /* _PEER_H_ */ diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index d1175a1c4de3..e374270b6937 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -5730,15 +5730,26 @@ static int ath11k_ready_event(struct ath11k_base *ab, struct sk_buff *skb) static void ath11k_peer_delete_resp_event(struct ath11k_base *ab, struct sk_buff *skb) { struct wmi_peer_delete_resp_event peer_del_resp; + struct ath11k *ar; if (ath11k_pull_peer_del_resp_ev(ab, skb, &peer_del_resp) != 0) { ath11k_warn(ab, "failed to extract peer delete resp"); return; } - /* TODO: Do we need to validate whether ath11k_peer_find() return NULL - * Why this is needed when there is HTT event for peer delete - */ + rcu_read_lock(); + ar = ath11k_mac_get_ar_by_vdev_id(ab, peer_del_resp.vdev_id); + if (!ar) { + ath11k_warn(ab, "invalid vdev id in peer delete resp ev %d", + peer_del_resp.vdev_id); + rcu_read_unlock(); + return; + } + + complete(&ar->peer_delete_done); + rcu_read_unlock(); + ath11k_dbg(ab, ATH11K_DBG_WMI, "peer delete resp for vdev id %d addr %pM\n", + peer_del_resp.vdev_id, peer_del_resp.peer_macaddr.addr); } static void ath11k_vdev_delete_resp_event(struct ath11k_base *ab, From fae0385b29679a13523b3d14f570f0fdc46cd48d Mon Sep 17 00:00:00 2001 From: Ritesh Singh Date: Tue, 24 Nov 2020 17:59:14 +0200 Subject: [PATCH 150/180] ath11k: remove "ath11k_mac_get_ar_vdev_stop_status" references Unused structure ath11k_vdev_stop_status is removed. 'ath11k_mac_get_ar_vdev_stop_status' api has been replaced with 'ath11k_mac_get_ar_by_vdev_id' inside vdev_stopped_event. Signed-off-by: Ritesh Singh Signed-off-by: Maharaja Kennadyrajan Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1605514143-17652-4-git-send-email-mkenna@codeaurora.org --- drivers/net/wireless/ath/ath11k/core.h | 6 ----- drivers/net/wireless/ath/ath11k/mac.c | 36 -------------------------- drivers/net/wireless/ath/ath11k/mac.h | 2 -- drivers/net/wireless/ath/ath11k/wmi.c | 2 +- 4 files changed, 1 insertion(+), 45 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 88e5a9b9f52d..3a71180ffe5a 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -432,11 +432,6 @@ struct ath11k_per_peer_tx_stats { #define ATH11K_FLUSH_TIMEOUT (5 * HZ) #define ATH11K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ) -struct ath11k_vdev_stop_status { - bool stop_in_progress; - u32 vdev_id; -}; - struct ath11k { struct ath11k_base *ab; struct ath11k_pdev *pdev; @@ -512,7 +507,6 @@ struct ath11k { struct completion install_key_done; int last_wmi_vdev_start_status; - struct ath11k_vdev_stop_status vdev_stop_status; struct completion vdev_setup_done; struct completion vdev_delete_done; diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index f97d22d7f923..c68fa8eebe33 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -537,31 +537,6 @@ struct ath11k *ath11k_mac_get_ar_by_pdev_id(struct ath11k_base *ab, u32 pdev_id) return NULL; } -struct ath11k *ath11k_mac_get_ar_vdev_stop_status(struct ath11k_base *ab, - u32 vdev_id) -{ - int i; - struct ath11k_pdev *pdev; - struct ath11k *ar; - - for (i = 0; i < ab->num_radios; i++) { - pdev = rcu_dereference(ab->pdevs_active[i]); - if (pdev && pdev->ar) { - ar = pdev->ar; - - spin_lock_bh(&ar->data_lock); - if (ar->vdev_stop_status.stop_in_progress && - ar->vdev_stop_status.vdev_id == vdev_id) { - ar->vdev_stop_status.stop_in_progress = false; - spin_unlock_bh(&ar->data_lock); - return ar; - } - spin_unlock_bh(&ar->data_lock); - } - } - return NULL; -} - static void ath11k_pdev_caps_update(struct ath11k *ar) { struct ath11k_base *ab = ar->ab; @@ -5020,13 +4995,6 @@ static int ath11k_mac_vdev_stop(struct ath11k_vif *arvif) reinit_completion(&ar->vdev_setup_done); - spin_lock_bh(&ar->data_lock); - - ar->vdev_stop_status.stop_in_progress = true; - ar->vdev_stop_status.vdev_id = arvif->vdev_id; - - spin_unlock_bh(&ar->data_lock); - ret = ath11k_wmi_vdev_stop(ar, arvif->vdev_id); if (ret) { ath11k_warn(ar->ab, "failed to stop WMI vdev %i: %d\n", @@ -5055,10 +5023,6 @@ static int ath11k_mac_vdev_stop(struct ath11k_vif *arvif) return 0; err: - spin_lock_bh(&ar->data_lock); - ar->vdev_stop_status.stop_in_progress = false; - spin_unlock_bh(&ar->data_lock); - return ret; } diff --git a/drivers/net/wireless/ath/ath11k/mac.h b/drivers/net/wireless/ath/ath11k/mac.h index 0607479774a9..597104a9078d 100644 --- a/drivers/net/wireless/ath/ath11k/mac.h +++ b/drivers/net/wireless/ath/ath11k/mac.h @@ -137,8 +137,6 @@ struct ath11k_vif *ath11k_mac_get_arvif_by_vdev_id(struct ath11k_base *ab, u32 vdev_id); struct ath11k *ath11k_mac_get_ar_by_vdev_id(struct ath11k_base *ab, u32 vdev_id); struct ath11k *ath11k_mac_get_ar_by_pdev_id(struct ath11k_base *ab, u32 pdev_id); -struct ath11k *ath11k_mac_get_ar_vdev_stop_status(struct ath11k_base *ab, - u32 vdev_id); void ath11k_mac_drain_tx(struct ath11k *ar); void ath11k_mac_peer_cleanup_all(struct ath11k *ar); diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index e374270b6937..f6f726979710 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -5856,7 +5856,7 @@ static void ath11k_vdev_stopped_event(struct ath11k_base *ab, struct sk_buff *sk } rcu_read_lock(); - ar = ath11k_mac_get_ar_vdev_stop_status(ab, vdev_id); + ar = ath11k_mac_get_ar_by_vdev_id(ab, vdev_id); if (!ar) { ath11k_warn(ab, "invalid vdev id in vdev stopped ev %d", vdev_id); From f4d291b43f809b74c66b21f5190cd578af43070b Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 24 Nov 2020 17:59:15 +0200 Subject: [PATCH 151/180] ath11k: Don't cast ath11k_skb_cb to ieee80211_tx_info.control The driver_data area of ieee80211_tx_info is used in ath11k for ath11k_skb_cb. The first function in the TX patch which rewrites it to ath11k_skb_cb is already ath11k_mac_op_tx. No one else in the code path must use it for something else before it reinitializes it. Otherwise the data has to be considered uninitialized or corrupt. But the ieee80211_tx_info.control shares exactly the same area as ieee80211_tx_info.driver_data and ath11k is still using it. This results in best case in a ath11k c000000.wifi1: no vif found for mgmt frame, flags 0x0 or (slightly worse) in a kernel oops. Instead, the interesting data must be moved first into the ath11k_skb_cb and ieee80211_tx_info.control must then not be used anymore. Tested-on: IPQ8074 hw2.0 WLAN.HK.2.4.0.1.r1-00026-QCAHKSWPL_SILICONZ-2 Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Sven Eckelmann Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201119154235.263250-1-sven@narfation.org --- drivers/net/wireless/ath/ath11k/core.h | 2 ++ drivers/net/wireless/ath/ath11k/dp_tx.c | 5 ++--- drivers/net/wireless/ath/ath11k/mac.c | 26 ++++++++++++++++--------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 3a71180ffe5a..25609ff300a5 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -75,12 +75,14 @@ static inline enum wme_ac ath11k_tid_to_ac(u32 tid) enum ath11k_skb_flags { ATH11K_SKB_HW_80211_ENCAP = BIT(0), + ATH11K_SKB_CIPHER_SET = BIT(1), }; struct ath11k_skb_cb { dma_addr_t paddr; u8 eid; u8 flags; + u32 cipher; struct ath11k *ar; struct ieee80211_vif *vif; } __packed; diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c index 6ea65533a119..6a3fcea6c233 100644 --- a/drivers/net/wireless/ath/ath11k/dp_tx.c +++ b/drivers/net/wireless/ath/ath11k/dp_tx.c @@ -84,7 +84,6 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif, struct ath11k_dp *dp = &ab->dp; struct hal_tx_info ti = {0}; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct ieee80211_key_conf *key = info->control.hw_key; struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB(skb); struct hal_srng *tcl_ring; struct ieee80211_hdr *hdr = (void *)skb->data; @@ -149,9 +148,9 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif, ti.meta_data_flags = arvif->tcl_metadata; if (ti.encap_type == HAL_TCL_ENCAP_TYPE_RAW) { - if (key) { + if (skb_cb->flags & ATH11K_SKB_CIPHER_SET) { ti.encrypt_type = - ath11k_dp_tx_get_encrypt_type(key->cipher); + ath11k_dp_tx_get_encrypt_type(skb_cb->cipher); if (ieee80211_has_protected(hdr->frame_control)) skb_put(skb, IEEE80211_CCMP_MIC_LEN); diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index c68fa8eebe33..c172f7919b0b 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -3997,21 +3997,20 @@ static void ath11k_mgmt_over_wmi_tx_purge(struct ath11k *ar) static void ath11k_mgmt_over_wmi_tx_work(struct work_struct *work) { struct ath11k *ar = container_of(work, struct ath11k, wmi_mgmt_tx_work); - struct ieee80211_tx_info *info; + struct ath11k_skb_cb *skb_cb; struct ath11k_vif *arvif; struct sk_buff *skb; int ret; while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) { - info = IEEE80211_SKB_CB(skb); - if (!info->control.vif) { - ath11k_warn(ar->ab, "no vif found for mgmt frame, flags 0x%x\n", - info->control.flags); + skb_cb = ATH11K_SKB_CB(skb); + if (!skb_cb->vif) { + ath11k_warn(ar->ab, "no vif found for mgmt frame\n"); ieee80211_free_txskb(ar->hw, skb); continue; } - arvif = ath11k_vif_to_arvif(info->control.vif); + arvif = ath11k_vif_to_arvif(skb_cb->vif); if (ar->allocated_vdev_map & (1LL << arvif->vdev_id) && arvif->is_started) { ret = ath11k_mac_mgmt_tx_wmi(ar, arvif, skb); @@ -4024,8 +4023,8 @@ static void ath11k_mgmt_over_wmi_tx_work(struct work_struct *work) } } else { ath11k_warn(ar->ab, - "dropping mgmt frame for vdev %d, flags 0x%x is_started %d\n", - arvif->vdev_id, info->control.flags, + "dropping mgmt frame for vdev %d, is_started %d\n", + arvif->vdev_id, arvif->is_started); ieee80211_free_txskb(ar->hw, skb); } @@ -4073,10 +4072,19 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif = info->control.vif; struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ieee80211_key_conf *key = info->control.hw_key; + u32 info_flags = info->flags; bool is_prb_rsp; int ret; - if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { + skb_cb->vif = vif; + + if (key) { + skb_cb->cipher = key->cipher; + skb_cb->flags |= ATH11K_SKB_CIPHER_SET; + } + + if (info_flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { skb_cb->flags |= ATH11K_SKB_HW_80211_ENCAP; } else if (ieee80211_is_mgmt(hdr->frame_control)) { is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control); From 5da7acfec5ec55aa0b69b8760f1d2116b4e2ad26 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 24 Nov 2020 17:59:15 +0200 Subject: [PATCH 152/180] ath11k: Reset ath11k_skb_cb before setting new flags It was observed that the codepath for the ATH11K_SKB_HW_80211_ENCAP was used even when the IEEE80211_TX_CTRL_HW_80211_ENCAP was not enabled for a an skbuff. This became even more prominent when the QCAs wlan-open patchset for ath11k [1] was applied and a sane looking fix just caused crashes when injecting frames via a monitor interface (for example with ratechecker): [ 86.963152] Unable to handle kernel NULL pointer dereference at virtual address 00000338 [ 86.963192] pgd = ffffffc0008f0000 [ 86.971034] [00000338] *pgd=0000000051706003, *pud=0000000051706003, *pmd=0000000051707003, *pte=00e800000b000707 [ 86.984292] Internal error: Oops: 96000006 [#1] PREEMPT SMP [...] [ 87.713339] [] ieee80211_tx_status_8023+0xf8/0x220 [mac80211] [ 87.715654] [] ath11k_dp_tx_completion_handler+0x42c/0xa10 [ath11k] [ 87.722924] [] ath11k_dp_service_srng+0x70/0x3c8 [ath11k] [ 87.730831] [] 0xffffffbffca03460 [ 87.737599] [] net_rx_action+0xf8/0x288 [ 87.742462] [] __do_softirq+0xfc/0x220 [ 87.748014] [] irq_exit+0x98/0xe8 [ 87.753396] [] __handle_domain_irq+0x90/0xb8 [ 87.757999] [] gic_handle_irq+0x6c/0xc8 [ 87.763899] Exception stack(0xffffffc00081bdc0 to 0xffffffc00081bef0) Problem is that the state of ath11k_skb_cb->flags must be considered unknown and could contain anything when it is not manually initialized. So it could also contain ATH11K_SKB_HW_80211_ENCAP. And this can result in the code to assume that the ath11k_skb_cb->vif is set - even when this is not always the case for non ATH11K_SKB_HW_80211_ENCAP transmissions. Tested-on: IPQ8074 hw2.0 WLAN.HK.2.4.0.1.r1-00026-QCAHKSWPL_SILICONZ-2 [1] https://source.codeaurora.org/quic/qsdk/oss/system/feeds/wlan-open/tree/mac80211/patches?h=NHSS.QSDK.11.4.r3 (162 patches at the moment which are often not upstreamed but essential to get ath11k working) Fixes: e7f33e0c52c0 ("ath11k: add tx hw 802.11 encapsulation offloading support") Signed-off-by: Sven Eckelmann Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201119154235.263250-2-sven@narfation.org --- drivers/net/wireless/ath/ath11k/mac.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index c172f7919b0b..ebed24ec7368 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -4077,6 +4077,7 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw, bool is_prb_rsp; int ret; + memset(skb_cb, 0, sizeof(*skb_cb)); skb_cb->vif = vif; if (key) { From d35d1375493b0f962a5da5aef015b8bd215e059d Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 24 Nov 2020 17:59:16 +0200 Subject: [PATCH 153/180] ath11k: Build check size of ath11k_skb_cb It is rather easy to add more entries to ath11k_skb_cb while forgetting the size limit of ieee80211_tx_info->driver_data. So just check this during the build to reduce the change of accidental buffer overflow in the skbuff->cb. Signed-off-by: Sven Eckelmann Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201119154235.263250-3-sven@narfation.org --- drivers/net/wireless/ath/ath11k/core.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 25609ff300a5..317b15e333d3 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -909,6 +909,8 @@ static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state) static inline struct ath11k_skb_cb *ATH11K_SKB_CB(struct sk_buff *skb) { + BUILD_BUG_ON(sizeof(struct ath11k_skb_cb) > + IEEE80211_TX_INFO_DRIVER_DATA_SIZE); return (struct ath11k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data; } From e7bcc145bcd035e56da7b97b033c463b32a5ff80 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Tue, 24 Nov 2020 17:59:16 +0200 Subject: [PATCH 154/180] ath11k: Fix an error handling path If 'kzalloc' fails, we must return an error code. While at it, remove a useless initialization of 'err' which could hide the issue. Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Christophe JAILLET Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201122173943.1366167-1-christophe.jaillet@wanadoo.fr --- drivers/net/wireless/ath/ath11k/qmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index 8529b3328d24..d128c335bf5b 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -1591,15 +1591,17 @@ static int ath11k_qmi_fw_ind_register_send(struct ath11k_base *ab) struct qmi_wlanfw_ind_register_resp_msg_v01 *resp; struct qmi_handle *handle = &ab->qmi.handle; struct qmi_txn txn; - int ret = 0; + int ret; req = kzalloc(sizeof(*req), GFP_KERNEL); if (!req) return -ENOMEM; resp = kzalloc(sizeof(*resp), GFP_KERNEL); - if (!resp) + if (!resp) { + ret = -ENOMEM; goto resp_out; + } req->client_id_valid = 1; req->client_id = QMI_WLANFW_CLIENT_ID; From c7cee9c0f499f27ec6de06bea664b61320534768 Mon Sep 17 00:00:00 2001 From: Rakesh Pillai Date: Tue, 24 Nov 2020 17:59:17 +0200 Subject: [PATCH 155/180] ath10k: Fix the parsing error in service available event The wmi service available event has been extended to contain extra 128 bit for new services to be indicated by firmware. Currently the presence of any optional TLVs in the wmi service available event leads to a parsing error with the below error message: ath10k_snoc 18800000.wifi: failed to parse svc_avail tlv: -71 The wmi service available event parsing should not return error for the newly added optional TLV. Fix this parsing for service available event message. Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.2.2-00720-QCAHLSWMTPL-1 Fixes: cea19a6ce8bf ("ath10k: add WMI_SERVICE_AVAILABLE_EVENT support") Signed-off-by: Rakesh Pillai Reviewed-by: Douglas Anderson Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1605501291-23040-1-git-send-email-pillair@codeaurora.org --- drivers/net/wireless/ath/ath10k/wmi-tlv.c | 4 +++- drivers/net/wireless/ath/ath10k/wmi.c | 9 +++++++-- drivers/net/wireless/ath/ath10k/wmi.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c index 932266d1111b..7b5834157fe5 100644 --- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c +++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c @@ -1401,13 +1401,15 @@ static int ath10k_wmi_tlv_svc_avail_parse(struct ath10k *ar, u16 tag, u16 len, switch (tag) { case WMI_TLV_TAG_STRUCT_SERVICE_AVAILABLE_EVENT: + arg->service_map_ext_valid = true; arg->service_map_ext_len = *(__le32 *)ptr; arg->service_map_ext = ptr + sizeof(__le32); return 0; default: break; } - return -EPROTO; + + return 0; } static int ath10k_wmi_tlv_op_pull_svc_avail(struct ath10k *ar, diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index c521f0b27831..c491acebdb46 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -5751,8 +5751,13 @@ void ath10k_wmi_event_service_available(struct ath10k *ar, struct sk_buff *skb) ret); } - ath10k_wmi_map_svc_ext(ar, arg.service_map_ext, ar->wmi.svc_map, - __le32_to_cpu(arg.service_map_ext_len)); + /* + * Initialization of "arg.service_map_ext_valid" to ZERO is necessary + * for the below logic to work. + */ + if (arg.service_map_ext_valid) + ath10k_wmi_map_svc_ext(ar, arg.service_map_ext, ar->wmi.svc_map, + __le32_to_cpu(arg.service_map_ext_len)); } static int ath10k_wmi_event_temperature(struct ath10k *ar, struct sk_buff *skb) diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index c32aabea8293..d870f7067cb7 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h @@ -6919,6 +6919,7 @@ struct wmi_svc_rdy_ev_arg { }; struct wmi_svc_avail_ev_arg { + bool service_map_ext_valid; __le32 service_map_ext_len; const __le32 *service_map_ext; }; From ed3573bc3943c27d2d8e405a242f87ed14572ca1 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Tue, 24 Nov 2020 17:59:18 +0200 Subject: [PATCH 156/180] ath10k: Fix an error handling path If 'ath10k_usb_create()' fails, we should release some resources and report an error instead of silently continuing. Fixes: 4db66499df91 ("ath10k: add initial USB support") Signed-off-by: Christophe JAILLET Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201122170342.1346011-1-christophe.jaillet@wanadoo.fr --- drivers/net/wireless/ath/ath10k/usb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/usb.c b/drivers/net/wireless/ath/ath10k/usb.c index 05a620ff6fe2..0b47c3a09794 100644 --- a/drivers/net/wireless/ath/ath10k/usb.c +++ b/drivers/net/wireless/ath/ath10k/usb.c @@ -997,6 +997,8 @@ static int ath10k_usb_probe(struct usb_interface *interface, ar_usb = ath10k_usb_priv(ar); ret = ath10k_usb_create(ar, interface); + if (ret) + goto err; ar_usb->ar = ar; ar->dev_id = product_id; From 6364e693f4a7a89a2fb3dd2cbd6cc06d5fd6e26d Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Tue, 24 Nov 2020 17:59:18 +0200 Subject: [PATCH 157/180] ath10k: Release some resources in an error handling path Should an error occur after calling 'ath10k_usb_create()', it should be undone by a corresponding 'ath10k_usb_destroy()' call Fixes: 4db66499df91 ("ath10k: add initial USB support") Signed-off-by: Christophe JAILLET Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201122170358.1346065-1-christophe.jaillet@wanadoo.fr --- drivers/net/wireless/ath/ath10k/usb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/usb.c b/drivers/net/wireless/ath/ath10k/usb.c index 0b47c3a09794..19b9c27e30e2 100644 --- a/drivers/net/wireless/ath/ath10k/usb.c +++ b/drivers/net/wireless/ath/ath10k/usb.c @@ -1011,7 +1011,7 @@ static int ath10k_usb_probe(struct usb_interface *interface, ret = ath10k_core_register(ar, &bus_params); if (ret) { ath10k_warn(ar, "failed to register driver core: %d\n", ret); - goto err; + goto err_usb_destroy; } /* TODO: remove this once USB support is fully implemented */ @@ -1019,6 +1019,9 @@ static int ath10k_usb_probe(struct usb_interface *interface, return 0; +err_usb_destroy: + ath10k_usb_destroy(ar); + err: ath10k_core_destroy(ar); From ad37a46e8cb5e108ddb564ca431d05c4ba7cf052 Mon Sep 17 00:00:00 2001 From: Rikard Falkeborn Date: Tue, 24 Nov 2020 17:59:18 +0200 Subject: [PATCH 158/180] ath10k: Constify static qmi structs qmi_msg_handler[] and ath10k_qmi_ops are only used as input arguments to qmi_handle_init() which accepts const pointers to both qmi_ops and qmi_msg_handler. Make them const to allow the compiler to put them in read-only memory. Signed-off-by: Rikard Falkeborn Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201122234031.33432-3-rikard.falkeborn@gmail.com --- drivers/net/wireless/ath/ath10k/qmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c index ae6b1f402adf..07e478f9a808 100644 --- a/drivers/net/wireless/ath/ath10k/qmi.c +++ b/drivers/net/wireless/ath/ath10k/qmi.c @@ -917,7 +917,7 @@ static void ath10k_qmi_msa_ready_ind(struct qmi_handle *qmi_hdl, ath10k_qmi_driver_event_post(qmi, ATH10K_QMI_EVENT_MSA_READY_IND, NULL); } -static struct qmi_msg_handler qmi_msg_handler[] = { +static const struct qmi_msg_handler qmi_msg_handler[] = { { .type = QMI_INDICATION, .msg_id = QMI_WLFW_FW_READY_IND_V01, @@ -981,7 +981,7 @@ static void ath10k_qmi_del_server(struct qmi_handle *qmi_hdl, NULL); } -static struct qmi_ops ath10k_qmi_ops = { +static const struct qmi_ops ath10k_qmi_ops = { .new_server = ath10k_qmi_new_server, .del_server = ath10k_qmi_del_server, }; From 9bc3a55f4ae5c1c32b4b0b028b423833f1565c62 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Nov 2020 17:59:19 +0200 Subject: [PATCH 159/180] wcn36xx: Send NULL data packet when exiting BMPS This commit updates the BMPS exit path to be consistent with downstream in terms of exiting BMPS mode. Downstream sets the flag to send a NULL data frame to the host on exiting BMPS. This will tell the AP to send any queued frames to the STA immediately. Verified the relevant bit toggle in wireshark. Signed-off-by: Bryan O'Donoghue Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201120021403.2646574-2-bryan.odonoghue@linaro.org --- drivers/net/wireless/ath/wcn36xx/smd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c index 8ff1eda8f942..acf533fae46a 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.c +++ b/drivers/net/wireless/ath/wcn36xx/smd.c @@ -2176,6 +2176,7 @@ int wcn36xx_smd_exit_bmps(struct wcn36xx *wcn, struct ieee80211_vif *vif) INIT_HAL_MSG(msg_body, WCN36XX_HAL_EXIT_BMPS_REQ); msg_body.bss_index = vif_priv->bss_index; + msg_body.send_data_null = 1; PREPARE_HAL_BUF(wcn->hal_buf, msg_body); From cd6181ff7e93808fbb7b6330e3ee8bc8d722a9ba Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 24 Nov 2020 17:59:20 +0200 Subject: [PATCH 160/180] ath11k: dp_rx: fix monitor status dma unmap direction After enabling CONFIG_DMA_API_DEBUG there was a warning about using dma_unmap_single() in wrong direction from ath11k_dp_rx_process_mon_status(). [ 140.279477] ------------[ cut here ]------------ [ 140.279908] DMA-API: ath11k_pci 0000:06:00.0: device driver syncs DMA memory with different direction [device address=0x00000000fac08a40] [size=2176 bytes] [mapped with DMA_FROM_DEVICE] [s [ 140.279925] WARNING: CPU: 7 PID: 97 at kernel/dma/debug.c:1120 check_sync+0x494/0x730 [ 140.279939] Modules linked in: ath11k_pci ath11k mac80211 libarc4 cfg80211 qmi_helpers qrtr_mhi mhi qrtr ns nvme nvme_core [ 140.279958] CPU: 7 PID: 97 Comm: kworker/u16:1 Not tainted 5.10.0-rc4+ #262 [ 140.279968] Hardware name: Intel(R) Client Systems NUC8i7HVK/NUC8i7HVB, BIOS HNKBLi70.86A.0049.2018.0801.1601 08/01/2018 [ 140.279995] Workqueue: phy0 ieee80211_scan_work [mac80211] [ 140.280009] RIP: 0010:check_sync+0x494/0x730 [ 140.280022] Code: 8b 4c 24 10 4c 8b 44 24 18 4c 8b 54 24 20 48 89 c6 4c 89 54 24 10 4c 89 f9 4c 89 ea 48 c7 c7 40 b9 74 9c 41 56 e8 2f a0 ab 00 <0f> 0b 48 89 ef e8 e5 17 ac 00 41 58 4c 8b [ 140.280033] RSP: 0018:ffff9f588024cbd8 EFLAGS: 00010086 [ 140.280046] RAX: 0000000000000000 RBX: ffff9f588024cc40 RCX: ffff8eed18dd9f98 [ 140.280057] RDX: 00000000ffffffd8 RSI: 0000000000000027 RDI: ffff8eed18dd9f90 [ 140.280067] RBP: ffff8eebc1407800 R08: 00000000ffffffea R09: 0000000000000000 [ 140.280082] R10: 0000000000000003 R11: 3fffffffffffffff R12: ffffffff9e081060 [ 140.280093] R13: ffff8eebc43908b0 R14: ffffffff9c74c104 R15: 00000000fac08a40 [ 140.280104] FS: 0000000000000000(0000) GS:ffff8eed18c00000(0000) knlGS:0000000000000000 [ 140.280115] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 140.280127] CR2: 00007f6feafb12a0 CR3: 00000001604ca001 CR4: 00000000003706e0 [ 140.280138] Call Trace: [ 140.280149] [ 140.280161] debug_dma_sync_single_for_cpu+0x79/0x80 [ 140.280173] ? mark_held_locks+0x50/0x80 [ 140.280185] ? lockdep_hardirqs_on_prepare.part.0+0x65/0x130 [ 140.280197] ? __local_bh_enable_ip+0x6f/0xb0 [ 140.280215] ? ath11k_dp_rx_reap_mon_status_ring+0x202/0x340 [ath11k] [ 140.280231] ath11k_dp_rx_reap_mon_status_ring+0x22c/0x340 [ath11k] [ 140.280249] ? ath11k_dp_rx_process_mon_rings+0x1a0/0x1a0 [ath11k] [ 140.280265] ath11k_dp_rx_process_mon_status+0x83/0x3c0 [ath11k] [ 140.280278] ? __lock_acquire+0x3bd/0x6d0 [ 140.280296] ? ath11k_dp_rx_process_mon_rings+0x1a0/0x1a0 [ath11k] [ 140.280311] ? ath11k_dp_rx_process_mon_rings+0x1a0/0x1a0 [ath11k] [ 140.280326] ? ath11k_hw_mac_id_to_srng_id_qca6390+0x10/0x10 [ath11k] [ 140.280341] ? ath11k_dp_rx_process_mon_rings+0x4a/0x1a0 [ath11k] [ 140.280353] ? timer_fixup_init+0x30/0x30 [ 140.280367] ? ath11k_dp_rx_process_mon_rings+0x1a0/0x1a0 [ath11k] [ 140.280385] ath11k_dp_service_mon_ring+0x2b/0x50 [ath11k] [ 140.280400] ? ath11k_dp_rx_process_mon_rings+0x1a0/0x1a0 [ath11k] [ 140.280413] call_timer_fn+0xb1/0x2d0 [ 140.280426] __run_timers.part.0+0x205/0x2f0 [ 140.280439] run_timer_softirq+0x21/0x50 [ 140.280450] __do_softirq+0xc2/0x454 [ 140.280463] asm_call_irq_on_stack+0x12/0x20 [ 140.280476] [ 140.280488] do_softirq_own_stack+0x56/0x60 [ 140.280500] irq_exit_rcu+0x9a/0xd0 [ 140.280511] sysvec_apic_timer_interrupt+0x43/0xa0 [ 140.280526] asm_sysvec_apic_timer_interrupt+0x12/0x20 [ 140.280540] RIP: 0010:_raw_spin_unlock_irqrestore+0x25/0x40 [ 140.280551] Code: 80 00 00 00 00 55 48 89 fd 48 83 c7 18 53 48 89 f3 48 8b 74 24 10 e8 ca 8f 4b ff 48 89 ef e8 22 dc 4b ff f6 c7 02 75 0c 53 9d <65> ff 0d 04 51 20 64 5b 5d c3 e8 9c 08 56 [ 140.280563] RSP: 0018:ffff9f58802e7878 EFLAGS: 00000246 [ 140.280578] RAX: 00000000000435ef RBX: 0000000000000246 RCX: 0000000000000040 [ 140.280592] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff9be13e84 [ 140.280603] RBP: ffff8eed18dde480 R08: 0000000000000001 R09: ffff8eebc2292760 [ 140.280614] R10: 0000000000000005 R11: ffff8eebc2292760 R12: 0000000000000000 [ 140.280625] R13: ffff9f58802e7900 R14: ffff8eed18dde480 R15: ffff8eed18dde480 [ 140.280637] ? _raw_spin_unlock_irqrestore+0x34/0x40 [ 140.280649] __mod_timer+0x274/0x400 [ 140.280661] ? wait_for_completion_timeout+0x76/0x110 [ 140.280675] schedule_timeout+0xa8/0x140 [ 140.280687] ? __next_timer_interrupt+0x100/0x100 [ 140.280698] wait_for_completion_timeout+0xa2/0x110 [ 140.280714] ath11k_start_scan+0x4c/0xf0 [ath11k] [ 140.280730] ath11k_mac_op_hw_scan+0x1e9/0x2c0 [ath11k] [ 140.280763] drv_hw_scan+0x79/0x260 [mac80211] [ 140.280789] __ieee80211_scan_completed+0x379/0x440 [mac80211] [ 140.280816] ieee80211_scan_work+0x12f/0x330 [mac80211] [ 140.280830] process_one_work+0x279/0x5b0 [ 140.280842] worker_thread+0x49/0x300 [ 140.280854] ? process_one_work+0x5b0/0x5b0 [ 140.280868] kthread+0x135/0x150 [ 140.280880] ? __kthread_bind_mask+0x60/0x60 [ 140.280891] ret_from_fork+0x22/0x30 [ 140.280903] irq event stamp: 275961 [ 140.280918] hardirqs last enabled at (275960): [] __local_bh_enable_ip+0x6f/0xb0 [ 140.280931] hardirqs last disabled at (275961): [] _raw_spin_lock_irqsave+0x63/0x80 [ 140.280946] softirqs last enabled at (275944): [] ath11k_ce_send+0x14d/0x260 [ath11k] [ 140.280958] softirqs last disabled at (275953): [] asm_call_irq_on_stack+0x12/0x20 [ 140.280971] ---[ end trace 31cb94e18d401398 ]--- Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1 Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1606156046-24764-1-git-send-email-kvalo@codeaurora.org --- drivers/net/wireless/ath/ath11k/dp_rx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index d23b152ddcdd..5de619d5c4e2 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -2715,7 +2715,7 @@ static struct sk_buff *ath11k_dp_rx_alloc_mon_status_buf(struct ath11k_base *ab, paddr = dma_map_single(ab->dev, skb->data, skb->len + skb_tailroom(skb), - DMA_BIDIRECTIONAL); + DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(ab->dev, paddr))) goto fail_free_skb; @@ -2731,7 +2731,7 @@ static struct sk_buff *ath11k_dp_rx_alloc_mon_status_buf(struct ath11k_base *ab, fail_dma_unmap: dma_unmap_single(ab->dev, paddr, skb->len + skb_tailroom(skb), - DMA_BIDIRECTIONAL); + DMA_FROM_DEVICE); fail_free_skb: dev_kfree_skb_any(skb); fail_alloc_skb: @@ -2795,7 +2795,7 @@ int ath11k_dp_rx_mon_status_bufs_replenish(struct ath11k_base *ab, int mac_id, idr_remove(&rx_ring->bufs_idr, buf_id); spin_unlock_bh(&rx_ring->idr_lock); dma_unmap_single(ab->dev, paddr, skb->len + skb_tailroom(skb), - DMA_BIDIRECTIONAL); + DMA_FROM_DEVICE); dev_kfree_skb_any(skb); ath11k_hal_srng_access_end(ab, srng); spin_unlock_bh(&srng->lock); @@ -2858,7 +2858,7 @@ static int ath11k_dp_rx_reap_mon_status_ring(struct ath11k_base *ab, int mac_id, dma_unmap_single(ab->dev, rxcb->paddr, skb->len + skb_tailroom(skb), - DMA_BIDIRECTIONAL); + DMA_FROM_DEVICE); tlv = (struct hal_tlv_hdr *)skb->data; if (FIELD_GET(HAL_TLV_HDR_TAG, tlv->tl) != From e220332c3a1a26c3f2adc58984fb627728c2f8d2 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sat, 21 Nov 2020 09:34:11 +0900 Subject: [PATCH 161/180] Revert "rtl8xxxu: Add Buffalo WI-U3-866D to list of supported devices" This reverts commit 28606150768a20b291a35dbbbb0ab4dd7d4739db. Since actually Buffalo WI-U3-866D is falied to power on with the change. The rtl8812au driver code to power on is same with the rtl8821a code. But the rtl8821ae included rtl8821a does not support USB interface. So seems that rtl8812au should be supported by rt1l8821a code with USB. Signed-off-by: Tokunori Ikegami Cc: linux-wireless@vger.kernel.org Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201121003411.9450-1-ikegami.t@gmail.com --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 40291d594ade..5cd7ef3625c5 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -6761,9 +6761,6 @@ static const struct usb_device_id dev_table[] = { /* Tested by Myckel Habets */ {USB_DEVICE_AND_INTERFACE_INFO(0x2357, 0x0109, 0xff, 0xff, 0xff), .driver_info = (unsigned long)&rtl8192eu_fops}, -/* Buffalo WI-U3-866D */ -{USB_DEVICE_AND_INTERFACE_INFO(0x0411, 0x025d, 0xff, 0xff, 0xff), - .driver_info = (unsigned long)&rtl8192eu_fops}, {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0xb720, 0xff, 0xff, 0xff), .driver_info = (unsigned long)&rtl8723bu_fops}, {USB_DEVICE_AND_INTERFACE_INFO(0x7392, 0xa611, 0xff, 0xff, 0xff), From 1329c0dbd485a48979c386088166ee2c3e28ddb8 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:50 +0800 Subject: [PATCH 162/180] rtw88: coex: run coexistence when WLAN entering/leaving LPS When WLAN entering or leaving, it's necessary to run coexistence mechanism to ensure the setting matched current status. Without calling rtw_coex_run_coex(), WLAN poor throughput or bad A2DP quality may happen. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-2-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 4bb0d373c862..7b69c7b01e22 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -2476,6 +2476,8 @@ void rtw_coex_lps_notify(struct rtw_dev *rtwdev, u8 type) if (!coex_stat->wl_force_lps_ctrl) rtw_coex_query_bt_info(rtwdev); + + rtw_coex_run_coex(rtwdev, COEX_RSN_LPS); } } From 1a589bd5be9260f59adf34e0a6dc21644f3cf74b Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:51 +0800 Subject: [PATCH 163/180] rtw88: coex: add debug message Add message for debugging usage and the program flow is no change. Add a variable reserved for WLAN firmware synchronize. Add a group of variable to save BT packet counter, it will be assigned as mechanism judgment in the future. Now it is just for debug usage. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-3-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 131 +++++++++++++++++++-- drivers/net/wireless/realtek/rtw88/debug.c | 23 ++++ drivers/net/wireless/realtek/rtw88/debug.h | 1 + drivers/net/wireless/realtek/rtw88/main.h | 5 + 4 files changed, 150 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 7b69c7b01e22..33fef8530db7 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -8,6 +8,7 @@ #include "ps.h" #include "debug.h" #include "reg.h" +#include "phy.h" static u8 rtw_coex_next_rssi_state(struct rtw_dev *rtwdev, u8 pre_state, u8 rssi, u8 rssi_thresh) @@ -349,6 +350,10 @@ static void rtw_coex_check_rfk(struct rtw_dev *rtwdev) if (!btk && !wlk) break; + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], (Before Ant Setup) wlk = %d, btk = %d\n", + wlk, btk); + mdelay(COEX_MIN_DELAY); } while (++cnt < wait_cnt); @@ -1054,7 +1059,8 @@ static void rtw_coex_tdma(struct rtw_dev *rtwdev, bool force, u32 tcase) coex_dm->cur_ps_tdma_on = turn_on; coex_dm->cur_ps_tdma = type; - rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], coex tdma type (%d)\n", type); + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], coex tdma type(%s, %d)\n", + turn_on ? "on" : "off", type); } static void rtw_coex_set_ant_path(struct rtw_dev *rtwdev, bool force, u8 phase) @@ -3016,6 +3022,81 @@ static const char *rtw_coex_get_reason_string(u8 reason) } } +static u8 rtw_coex_get_table_index(struct rtw_dev *rtwdev, u32 wl_reg_6c0, + u32 wl_reg_6c4) +{ + struct rtw_chip_info *chip = rtwdev->chip; + struct rtw_efuse *efuse = &rtwdev->efuse; + u8 ans = 0xFF; + u8 n, i; + u32 load_bt_val; + u32 load_wl_val; + bool share_ant = efuse->share_ant; + + if (share_ant) + n = chip->table_sant_num; + else + n = chip->table_nsant_num; + + for (i = 0; i < n; i++) { + if (share_ant) { + load_bt_val = chip->table_sant[i].bt; + load_wl_val = chip->table_sant[i].wl; + } else { + load_bt_val = chip->table_nsant[i].bt; + load_wl_val = chip->table_nsant[i].wl; + } + + if (wl_reg_6c0 == load_bt_val && + wl_reg_6c4 == load_wl_val) { + ans = i; + if (!share_ant) + ans += 100; + break; + } + } + + return ans; +} + +static u8 rtw_coex_get_tdma_index(struct rtw_dev *rtwdev, u8 *tdma_para) +{ + struct rtw_efuse *efuse = &rtwdev->efuse; + struct rtw_chip_info *chip = rtwdev->chip; + u8 ans = 0xFF; + u8 n, i, j; + u8 load_cur_tab_val; + bool valid = false; + bool share_ant = efuse->share_ant; + + if (share_ant) + n = chip->tdma_sant_num; + else + n = chip->tdma_nsant_num; + + for (i = 0; i < n; i++) { + valid = false; + for (j = 0; j < 5; j++) { + if (share_ant) + load_cur_tab_val = chip->tdma_sant[i].para[j]; + else + load_cur_tab_val = chip->tdma_nsant[i].para[j]; + + if (*(tdma_para + j) != load_cur_tab_val) + break; + + if (j == 4) + valid = true; + } + if (valid) { + ans = i; + break; + } + } + + return ans; +} + static int rtw_coex_addr_info(struct rtw_dev *rtwdev, const struct rtw_reg_domain *reg, char addr_info[], int n) @@ -3305,6 +3386,13 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) bt_lo_pri = rtw_read32(rtwdev, REG_BT_ACT_STATISTICS_1); rtw_write8(rtwdev, REG_BT_COEX_ENH_INTR_CTRL, BIT_R_GRANTALL_WLMASK | BIT_STATIS_BT_EN); + + coex_stat->hi_pri_tx = FIELD_GET(MASKLWORD, bt_hi_pri); + coex_stat->hi_pri_rx = FIELD_GET(MASKHWORD, bt_hi_pri); + + coex_stat->lo_pri_tx = FIELD_GET(MASKLWORD, bt_lo_pri); + coex_stat->lo_pri_rx = FIELD_GET(MASKHWORD, bt_lo_pri); + sys_lte = rtw_read8(rtwdev, 0x73); lte_coex = rtw_coex_read_indirect_reg(rtwdev, 0x38); bt_coex = rtw_coex_read_indirect_reg(rtwdev, 0x54); @@ -3356,15 +3444,17 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) coex_stat->bt_slave ? "Slave" : "Master", coex_stat->cnt_bt[COEX_CNT_BT_ROLESWITCH], coex_dm->ignore_wl_act); - seq_printf(m, "%-40s = %u.%u/ 0x%x/ %c\n", - "WL FW/ BT FW/ KT", + seq_printf(m, "%-40s = %u.%u/ 0x%x/ 0x%x/ %c\n", + "WL FW/ BT FW/ BT FW Desired/ KT", fw->version, fw->sub_version, - coex_stat->patch_ver, coex_stat->kt_ver + 65); + coex_stat->patch_ver, + chip->wl_fw_desired_ver, coex_stat->kt_ver + 65); seq_printf(m, "%-40s = %u/ %u/ %u/ ch-(%u)\n", "AFH Map", coex_dm->wl_ch_info[0], coex_dm->wl_ch_info[1], coex_dm->wl_ch_info[2], hal->current_channel); + rtw_debugfs_get_simple_phy_info(m); seq_printf(m, "**********************************************\n"); seq_printf(m, "\t\tBT Status\n"); seq_printf(m, "**********************************************\n"); @@ -3408,8 +3498,8 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) score_board_WB, score_board_BW); seq_printf(m, "%-40s = %u/%u, %u/%u\n", "Hi-Pri TX/RX, Lo-Pri TX/RX", - bt_hi_pri & 0xffff, bt_hi_pri >> 16, - bt_lo_pri & 0xffff, bt_lo_pri >> 16); + coex_stat->hi_pri_tx, coex_stat->hi_pri_rx, + coex_stat->lo_pri_tx, coex_stat->lo_pri_rx); for (i = 0; i < COEX_BTINFO_SRC_BT_IQK; i++) seq_printf(m, "%-40s = %7ph\n", rtw_coex_get_bt_info_src_string(i), @@ -3438,9 +3528,11 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) seq_printf(m, "**********************************************\n"); seq_printf(m, "\t\tMechanism (Under Manual)\n"); seq_printf(m, "**********************************************\n"); - seq_printf(m, "%-40s = %5ph\n", + seq_printf(m, "%-40s = %5ph (%d)\n", "TDMA Now", - coex_dm->fw_tdma_para); + coex_dm->fw_tdma_para, + rtw_coex_get_tdma_index(rtwdev, + &coex_dm->fw_tdma_para[0])); } else { seq_printf(m, "**********************************************\n"); seq_printf(m, "\t\tMechanism\n"); @@ -3454,9 +3546,11 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) rtw_coex_get_wl_coex_mode(coex_stat->wl_coex_mode), coex->freerun ? "Yes" : "No", coex_stat->tdma_timer_base); - seq_printf(m, "%-40s = %d/ 0x%08x/ 0x%08x/ 0x%08x\n", + seq_printf(m, "%-40s = %d(%d)/ 0x%08x/ 0x%08x/ 0x%08x\n", "Table/ 0x6c0/ 0x6c4/ 0x6c8", - coex_dm->cur_table, wl_reg_6c0, wl_reg_6c4, wl_reg_6c8); + coex_dm->cur_table, + rtw_coex_get_table_index(rtwdev, wl_reg_6c0, wl_reg_6c4), + wl_reg_6c0, wl_reg_6c4, wl_reg_6c8); seq_printf(m, "%-40s = 0x%08x/ 0x%08x/ %d/ reason (%s)\n", "0x778/ 0x6cc/ Run Count/ Reason", wl_reg_778, wl_reg_6cc, @@ -3520,5 +3614,22 @@ void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m) coex_stat->wl_noisy_level); rtw_coex_set_coexinfo_hw(rtwdev, m); + seq_printf(m, "%-40s = %d/ %d/ %d/ %d\n", + "EVM A/ EVM B/ SNR A/ SNR B", + -dm_info->rx_evm_dbm[RF_PATH_A], + -dm_info->rx_evm_dbm[RF_PATH_B], + -dm_info->rx_snr[RF_PATH_A], + -dm_info->rx_snr[RF_PATH_B]); + seq_printf(m, "%-40s = %d/ %d/ %d/ %d\n", + "CCK-CCA/CCK-FA/OFDM-CCA/OFDM-FA", + dm_info->cck_cca_cnt, dm_info->cck_fa_cnt, + dm_info->ofdm_cca_cnt, dm_info->ofdm_fa_cnt); + seq_printf(m, "%-40s = %d/ %d/ %d/ %d\n", "CRC OK CCK/11g/11n/11ac", + dm_info->cck_ok_cnt, dm_info->ofdm_ok_cnt, + dm_info->ht_ok_cnt, dm_info->vht_ok_cnt); + seq_printf(m, "%-40s = %d/ %d/ %d/ %d\n", "CRC Err CCK/11g/11n/11ac", + dm_info->cck_err_cnt, dm_info->ofdm_err_cnt, + dm_info->ht_err_cnt, dm_info->vht_err_cnt); + } #endif /* CONFIG_RTW88_DEBUGFS */ diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c index 5974a8ef8b34..3344ac92a094 100644 --- a/drivers/net/wireless/realtek/rtw88/debug.c +++ b/drivers/net/wireless/realtek/rtw88/debug.c @@ -617,6 +617,29 @@ static int rtw_debugfs_get_tx_pwr_tbl(struct seq_file *m, void *v) return 0; } +void rtw_debugfs_get_simple_phy_info(struct seq_file *m) +{ + struct rtw_debugfs_priv *debugfs_priv = m->private; + struct rtw_dev *rtwdev = debugfs_priv->rtwdev; + struct rtw_hal *hal = &rtwdev->hal; + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_traffic_stats *stats = &rtwdev->stats; + + seq_printf(m, "%-40s = %ddBm/ %d\n", "RSSI/ STA Channel", + dm_info->rssi[RF_PATH_A] - 100, hal->current_channel); + + seq_printf(m, "TP {Tx, Rx} = {%u, %u}Mbps\n", + stats->tx_throughput, stats->rx_throughput); + + seq_puts(m, "[Tx Rate] = "); + rtw_print_rate(m, dm_info->tx_rate); + seq_printf(m, "(0x%x)\n", dm_info->tx_rate); + + seq_puts(m, "[Rx Rate] = "); + rtw_print_rate(m, dm_info->curr_rx_rate); + seq_printf(m, "(0x%x)\n", dm_info->curr_rx_rate); +} + static int rtw_debugfs_get_phy_info(struct seq_file *m, void *v) { struct rtw_debugfs_priv *debugfs_priv = m->private; diff --git a/drivers/net/wireless/realtek/rtw88/debug.h b/drivers/net/wireless/realtek/rtw88/debug.h index a0f36f29b4a6..e16e0da26e77 100644 --- a/drivers/net/wireless/realtek/rtw88/debug.h +++ b/drivers/net/wireless/realtek/rtw88/debug.h @@ -26,6 +26,7 @@ enum rtw_debug_mask { #ifdef CONFIG_RTW88_DEBUGFS void rtw_debugfs_init(struct rtw_dev *rtwdev); +void rtw_debugfs_get_simple_phy_info(struct seq_file *m); #else diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index 3941aea51f9c..af5f2024251b 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1198,6 +1198,7 @@ struct rtw_chip_info { const struct coex_5g_afh_map *afh_5g; const struct rtw_hw_reg *btg_reg; const struct rtw_reg_domain *coex_info_hw_regs; + u32 wl_fw_desired_ver; }; enum rtw_coex_bt_state_cnt { @@ -1333,6 +1334,10 @@ struct rtw_coex_stat { u32 bt_supported_version; u32 bt_supported_feature; + u32 hi_pri_tx; + u32 hi_pri_rx; + u32 lo_pri_tx; + u32 lo_pri_rx; u32 patch_ver; u16 bt_reg_vendor_ae; u16 bt_reg_vendor_ac; From 76f631cb401fbfb5993c6958a8032db4f87881cb Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:52 +0800 Subject: [PATCH 164/180] rtw88: coex: update the mechanism for A2DP + PAN Update A2DP+PAN+WL mechanism for CPT(Coexistence Performance Test) to enhance WL/BT performance at the environment that some specific AP are existing. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-4-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 37 +++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 33fef8530db7..c0dbc8a2f913 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -1910,6 +1910,7 @@ static void rtw_coex_action_bt_a2dp_pan(struct rtw_dev *rtwdev) struct rtw_efuse *efuse = &rtwdev->efuse; struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; + bool wl_cpt_test = false, bt_cpt_test = false; rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); @@ -1917,16 +1918,29 @@ static void rtw_coex_action_bt_a2dp_pan(struct rtw_dev *rtwdev) rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); if (efuse->share_ant) { /* Shared-Ant */ - if (coex_stat->wl_gl_busy && - coex_stat->wl_noisy_level == 0) - table_case = 14; - else - table_case = 10; + if (wl_cpt_test) { + if (coex_stat->wl_gl_busy) { + table_case = 20; + tdma_case = 17; + } else { + table_case = 10; + tdma_case = 15; + } + } else if (bt_cpt_test) { + table_case = 26; + tdma_case = 26; + } else { + if (coex_stat->wl_gl_busy && + coex_stat->wl_noisy_level == 0) + table_case = 14; + else + table_case = 10; - if (coex_stat->wl_gl_busy) - tdma_case = 15; - else - tdma_case = 20; + if (coex_stat->wl_gl_busy) + tdma_case = 15; + else + tdma_case = 20; + } } else { /* Non-Shared-Ant */ table_case = 112; @@ -1937,6 +1951,11 @@ static void rtw_coex_action_bt_a2dp_pan(struct rtw_dev *rtwdev) tdma_case = 120; } + if (wl_cpt_test) + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[1]); + else + rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } From 4d0087e763a856e537e07e8e8677cc1e902f86f0 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:53 +0800 Subject: [PATCH 165/180] rtw88: coex: update AFH information while in free-run mode In free run mode, this WLAN info updating is only related to AFH information, not related to the connection state, which is the current implementation. Always update WLAN info in free run mode now. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-5-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index c0dbc8a2f913..3a86b7191ba3 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -1361,6 +1361,7 @@ static void rtw_coex_action_freerun(struct rtw_dev *rtwdev) struct rtw_efuse *efuse = &rtwdev->efuse; struct rtw_chip_info *chip = rtwdev->chip; u8 level = 0; + bool bt_afh_loss = true; rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); @@ -1369,7 +1370,7 @@ static void rtw_coex_action_freerun(struct rtw_dev *rtwdev) coex->freerun = true; - if (coex_stat->wl_connected) + if (bt_afh_loss) rtw_coex_update_wl_ch_info(rtwdev, COEX_MEDIA_CONNECT); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G_FREERUN); From 6a910a2a7d5def5179b8251374299f9c5a8dc028 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:54 +0800 Subject: [PATCH 166/180] rtw88: coex: change the coexistence mechanism for HID Add TDMA slot type setting for later usage. Since the transmission of HID profile is very frequently, it may bring a big impact to WLAN performance. To change slot type, it can make mechanism be more flexible. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-6-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 3a86b7191ba3..8ea5e115a81e 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -1677,6 +1677,7 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; u32 wl_bw; + u32 slot_type = 0; rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); @@ -1739,7 +1740,7 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) } rtw_coex_table(rtwdev, false, table_case); - rtw_coex_tdma(rtwdev, false, tdma_case); + rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } static void rtw_coex_action_bt_a2dp(struct rtw_dev *rtwdev) From c404dbd4fbfc8f871158052d8554ae4fb4bcb090 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:55 +0800 Subject: [PATCH 167/180] rtw88: coex: change the coexistence mechanism for WLAN connected Add a flag to make decision whether the mechanism should go into free-run mode or not. For now, it is always false, the flag assignment will be implemented later. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-7-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 8ea5e115a81e..fc96641dd133 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -2179,6 +2179,7 @@ static void rtw_coex_action_wl_connected(struct rtw_dev *rtwdev) struct rtw_coex_stat *coex_stat = &coex->stat; struct rtw_coex_dm *coex_dm = &coex->dm; struct rtw_efuse *efuse = &rtwdev->efuse; + bool freerun_check = false; u8 algorithm; /* Non-Shared-Ant */ @@ -2198,10 +2199,15 @@ static void rtw_coex_action_wl_connected(struct rtw_dev *rtwdev) rtw_coex_action_bt_hfp(rtwdev); break; case COEX_ALGO_HID: - rtw_coex_action_bt_hid(rtwdev); + if (freerun_check) + rtw_coex_action_freerun(rtwdev); + else + rtw_coex_action_bt_hid(rtwdev); break; case COEX_ALGO_A2DP: - if (coex_stat->bt_a2dp_sink) + if (freerun_check) + rtw_coex_action_freerun(rtwdev); + else if (coex_stat->bt_a2dp_sink) rtw_coex_action_bt_a2dpsink(rtwdev); else rtw_coex_action_bt_a2dp(rtwdev); @@ -2210,7 +2216,10 @@ static void rtw_coex_action_wl_connected(struct rtw_dev *rtwdev) rtw_coex_action_bt_pan(rtwdev); break; case COEX_ALGO_A2DP_HID: - rtw_coex_action_bt_a2dp_hid(rtwdev); + if (freerun_check) + rtw_coex_action_freerun(rtwdev); + else + rtw_coex_action_bt_a2dp_hid(rtwdev); break; case COEX_ALGO_A2DP_PAN: rtw_coex_action_bt_a2dp_pan(rtwdev); From 8e6947dcb95d7721ffefff01a988145a4faee938 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:56 +0800 Subject: [PATCH 168/180] rtw88: coex: add function to avoid cck lock Some AP will not follow the power save request, or it cannot stop transmission until its queue is empty. It may bring the decreasing of data rate. WLAN firmware will count is the AP still leaked packet after power save handshake was done or not to enable WLAN slot extend mechanism. The extend WLAN slot mechanism will extend the WLAN slot after power save handshake, 5 ms per times, maximum is 5 times to received the leaked packet to avoid the rate lower down. And if the transmission was already locked at CCK rate. The extended WLAN slot can also increase the opportunity that we can received the CCK's long packet and be released from CCK rate. While BT multi-link status was finished, there is possible that it still has some packet remained for seconds. Add a timer to remain the multi-link mechanism to protect WLAN Rx. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-8-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 171 +++++++++++++++++----- drivers/net/wireless/realtek/rtw88/coex.h | 3 + drivers/net/wireless/realtek/rtw88/main.c | 5 + drivers/net/wireless/realtek/rtw88/main.h | 10 ++ 4 files changed, 155 insertions(+), 34 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index fc96641dd133..eab5529e6764 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -109,25 +109,73 @@ static void rtw_coex_limited_wl(struct rtw_dev *rtwdev) rtw_coex_limited_tx(rtwdev, tx_limit, tx_agg_ctrl); } -static void rtw_coex_wl_ccklock_action(struct rtw_dev *rtwdev) +static bool rtw_coex_freerun_check(struct rtw_dev *rtwdev) +{ + struct rtw_coex *coex = &rtwdev->coex; + struct rtw_coex_dm *coex_dm = &coex->dm; + struct rtw_coex_stat *coex_stat = &coex->stat; + struct rtw_efuse *efuse = &rtwdev->efuse; + u8 bt_rssi; + u8 ant_distance = 10; + + if (coex_stat->bt_disabled) + return false; + + if (efuse->share_ant || ant_distance <= 5 || !coex_stat->wl_gl_busy) + return false; + + if (ant_distance >= 40 || coex_stat->bt_hid_pair_num >= 2) + return true; + + /* ant_distance = 5 ~ 40 */ + if (COEX_RSSI_HIGH(coex_dm->wl_rssi_state[1]) && + COEX_RSSI_HIGH(coex_dm->bt_rssi_state[0])) + return true; + + if (coex_stat->wl_tput_dir == COEX_WL_TPUT_TX) + bt_rssi = coex_dm->bt_rssi_state[0]; + else + bt_rssi = coex_dm->bt_rssi_state[1]; + + if (COEX_RSSI_HIGH(coex_dm->wl_rssi_state[3]) && + COEX_RSSI_HIGH(bt_rssi) && + coex_stat->cnt_wl[COEX_CNT_WL_SCANAP] <= 5) + return true; + + return false; +} + +static void rtw_coex_wl_slot_extend(struct rtw_dev *rtwdev, bool enable) { struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; u8 para[6] = {0}; + para[0] = COEX_H2C69_WL_LEAKAP; + para[1] = PARA1_H2C69_DIS_5MS; + + if (enable) + para[1] = PARA1_H2C69_EN_5MS; + else + coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; + + coex_stat->wl_slot_extend = enable; + rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); +} + +static void rtw_coex_wl_ccklock_action(struct rtw_dev *rtwdev) +{ + struct rtw_coex *coex = &rtwdev->coex; + struct rtw_coex_stat *coex_stat = &coex->stat; + if (coex->manual_control || coex->stop_dm) return; - para[0] = COEX_H2C69_WL_LEAKAP; if (coex_stat->tdma_timer_base == 3 && coex_stat->wl_slot_extend) { rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], set h2c 0x69 opcode 12 to turn off 5ms WL slot extend!!\n"); - - para[1] = PARA1_H2C69_DIS_5MS; /* disable 5ms extend */ - rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); - coex_stat->wl_slot_extend = false; - coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; + rtw_coex_wl_slot_extend(rtwdev, false); return; } @@ -145,19 +193,13 @@ static void rtw_coex_wl_ccklock_action(struct rtw_dev *rtwdev) if (coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] == 7) { rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], set h2c 0x69 opcode 12 to turn off 5ms WL slot extend!!\n"); - - para[1] = PARA1_H2C69_DIS_5MS; - rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); - coex_stat->wl_slot_extend = false; - coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; + rtw_coex_wl_slot_extend(rtwdev, false); } } else if (!coex_stat->wl_slot_extend && coex_stat->wl_cck_lock) { rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], set h2c 0x69 opcode 12 to turn on 5ms WL slot extend!!\n"); - para[1] = PARA1_H2C69_EN_5MS; - rtw_fw_bt_wifi_control(rtwdev, para[0], ¶[1]); - coex_stat->wl_slot_extend = true; + rtw_coex_wl_slot_extend(rtwdev, true); } } @@ -165,11 +207,48 @@ static void rtw_coex_wl_ccklock_detect(struct rtw_dev *rtwdev) { struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; + struct rtw_coex_dm *coex_dm = &coex->dm; - /* TODO: wait for rx_rate_change_notify implement */ - coex_stat->wl_cck_lock = false; - coex_stat->wl_cck_lock_pre = false; - coex_stat->wl_cck_lock_ever = false; + bool is_cck_lock_rate = false; + + if (coex_dm->bt_status == COEX_BTSTATUS_INQ_PAGE || + coex_stat->bt_setup_link) { + coex_stat->wl_cck_lock = false; + coex_stat->wl_cck_lock_pre = false; + return; + } + + if (coex_stat->wl_rx_rate <= COEX_CCK_2 || + coex_stat->wl_rts_rx_rate <= COEX_CCK_2) + is_cck_lock_rate = true; + + if (coex_stat->wl_connected && coex_stat->wl_gl_busy && + COEX_RSSI_HIGH(coex_dm->wl_rssi_state[3]) && + (coex_dm->bt_status == COEX_BTSTATUS_ACL_BUSY || + coex_dm->bt_status == COEX_BTSTATUS_ACL_SCO_BUSY || + coex_dm->bt_status == COEX_BTSTATUS_SCO_BUSY)) { + if (is_cck_lock_rate) { + coex_stat->wl_cck_lock = true; + + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], cck locking...\n"); + + } else { + coex_stat->wl_cck_lock = false; + + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], cck unlock...\n"); + } + } else { + coex_stat->wl_cck_lock = false; + } + + /* CCK lock identification */ + if (coex_stat->wl_cck_lock && !coex_stat->wl_cck_lock_pre) + ieee80211_queue_delayed_work(rtwdev->hw, &coex->wl_ccklock_work, + 3 * HZ); + + coex_stat->wl_cck_lock_pre = coex_stat->wl_cck_lock; } static void rtw_coex_wl_noisy_detect(struct rtw_dev *rtwdev) @@ -178,11 +257,12 @@ static void rtw_coex_wl_noisy_detect(struct rtw_dev *rtwdev) struct rtw_coex_stat *coex_stat = &coex->stat; struct rtw_dm_info *dm_info = &rtwdev->dm_info; u32 cnt_cck; + bool wl_cck_lock = false; /* wifi noisy environment identification */ cnt_cck = dm_info->cck_ok_cnt + dm_info->cck_err_cnt; - if (!coex_stat->wl_gl_busy) { + if (!coex_stat->wl_gl_busy && !wl_cck_lock) { if (cnt_cck > 250) { if (coex_stat->cnt_wl[COEX_CNT_WL_NOISY2] < 5) coex_stat->cnt_wl[COEX_CNT_WL_NOISY2]++; @@ -2177,19 +2257,8 @@ static void rtw_coex_action_wl_connected(struct rtw_dev *rtwdev) { struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_stat *coex_stat = &coex->stat; - struct rtw_coex_dm *coex_dm = &coex->dm; - struct rtw_efuse *efuse = &rtwdev->efuse; - bool freerun_check = false; u8 algorithm; - /* Non-Shared-Ant */ - if (!efuse->share_ant && coex_stat->wl_gl_busy && - COEX_RSSI_HIGH(coex_dm->wl_rssi_state[3]) && - COEX_RSSI_HIGH(coex_dm->bt_rssi_state[0])) { - rtw_coex_action_freerun(rtwdev); - return; - } - rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); algorithm = rtw_coex_algorithm(rtwdev); @@ -2199,13 +2268,13 @@ static void rtw_coex_action_wl_connected(struct rtw_dev *rtwdev) rtw_coex_action_bt_hfp(rtwdev); break; case COEX_ALGO_HID: - if (freerun_check) + if (rtw_coex_freerun_check(rtwdev)) rtw_coex_action_freerun(rtwdev); else rtw_coex_action_bt_hid(rtwdev); break; case COEX_ALGO_A2DP: - if (freerun_check) + if (rtw_coex_freerun_check(rtwdev)) rtw_coex_action_freerun(rtwdev); else if (coex_stat->bt_a2dp_sink) rtw_coex_action_bt_a2dpsink(rtwdev); @@ -2216,7 +2285,7 @@ static void rtw_coex_action_wl_connected(struct rtw_dev *rtwdev) rtw_coex_action_bt_pan(rtwdev); break; case COEX_ALGO_A2DP_HID: - if (freerun_check) + if (rtw_coex_freerun_check(rtwdev)) rtw_coex_action_freerun(rtwdev); else rtw_coex_action_bt_a2dp_hid(rtwdev); @@ -2372,6 +2441,8 @@ static void rtw_coex_init_coex_var(struct rtw_dev *rtwdev) coex_dm->wl_rssi_state[i] = COEX_RSSI_STATE_LOW; coex_stat->wl_coex_mode = COEX_WLINK_MAX; + coex_stat->wl_rx_rate = DESC_RATE5_5M; + coex_stat->wl_rts_rx_rate = DESC_RATE5_5M; } static void __rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only) @@ -2855,6 +2926,16 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) coex_stat->cnt_bt[COEX_CNT_BT_ROLESWITCH]++; coex_stat->bt_multi_link = ((coex_stat->bt_info_hb1 & BIT(7)) == BIT(7)); + /* for multi_link = 0 but bt pkt remain exist */ + /* Use PS-TDMA to protect WL RX */ + if (!coex_stat->bt_multi_link && coex_stat->bt_multi_link_pre) { + coex_stat->bt_multi_link_remain = true; + ieee80211_queue_delayed_work(rtwdev->hw, + &coex->bt_multi_link_remain_work, + 3 * HZ); + } + coex_stat->bt_multi_link_pre = coex_stat->bt_multi_link; + /* resend wifi info to bt, it is reset and lost the info */ if (coex_stat->bt_info_hb1 & BIT(1)) { rtw_dbg(rtwdev, RTW_DBG_COEX, @@ -3009,6 +3090,28 @@ void rtw_coex_wl_connecting_work(struct work_struct *work) mutex_unlock(&rtwdev->mutex); } +void rtw_coex_bt_multi_link_remain_work(struct work_struct *work) +{ + struct rtw_dev *rtwdev = container_of(work, struct rtw_dev, + coex.bt_multi_link_remain_work.work); + struct rtw_coex_stat *coex_stat = &rtwdev->coex.stat; + + mutex_lock(&rtwdev->mutex); + coex_stat->bt_multi_link_remain = false; + mutex_unlock(&rtwdev->mutex); +} + +void rtw_coex_wl_ccklock_work(struct work_struct *work) +{ + struct rtw_dev *rtwdev = container_of(work, struct rtw_dev, + coex.wl_ccklock_work.work); + struct rtw_coex_stat *coex_stat = &rtwdev->coex.stat; + + mutex_lock(&rtwdev->mutex); + coex_stat->wl_cck_lock = false; + mutex_unlock(&rtwdev->mutex); +} + #ifdef CONFIG_RTW88_DEBUGFS #define INFO_SIZE 80 diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h index 73f1bbc68490..c4898132702f 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.h +++ b/drivers/net/wireless/realtek/rtw88/coex.h @@ -5,6 +5,7 @@ #ifndef __RTW_COEX_H__ #define __RTW_COEX_H__ +#define COEX_CCK_2 0x1 #define COEX_RESP_ACK_BY_WL_FW 0x1 #define COEX_REQUEST_TIMEOUT msecs_to_jiffies(10) @@ -385,6 +386,8 @@ void rtw_coex_defreeze_work(struct work_struct *work); void rtw_coex_wl_remain_work(struct work_struct *work); void rtw_coex_bt_remain_work(struct work_struct *work); void rtw_coex_wl_connecting_work(struct work_struct *work); +void rtw_coex_bt_multi_link_remain_work(struct work_struct *work); +void rtw_coex_wl_ccklock_work(struct work_struct *work); void rtw_coex_power_on_setting(struct rtw_dev *rtwdev); void rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only); diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 6290ecc97f5b..47969a6f957c 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -1154,6 +1154,8 @@ void rtw_core_stop(struct rtw_dev *rtwdev) cancel_delayed_work_sync(&coex->wl_remain_work); cancel_delayed_work_sync(&coex->bt_remain_work); cancel_delayed_work_sync(&coex->wl_connecting_work); + cancel_delayed_work_sync(&coex->bt_multi_link_remain_work); + cancel_delayed_work_sync(&coex->wl_ccklock_work); mutex_lock(&rtwdev->mutex); @@ -1660,6 +1662,9 @@ int rtw_core_init(struct rtw_dev *rtwdev) INIT_DELAYED_WORK(&coex->wl_remain_work, rtw_coex_wl_remain_work); INIT_DELAYED_WORK(&coex->bt_remain_work, rtw_coex_bt_remain_work); INIT_DELAYED_WORK(&coex->wl_connecting_work, rtw_coex_wl_connecting_work); + INIT_DELAYED_WORK(&coex->bt_multi_link_remain_work, + rtw_coex_bt_multi_link_remain_work); + INIT_DELAYED_WORK(&coex->wl_ccklock_work, rtw_coex_wl_ccklock_work); INIT_WORK(&rtwdev->c2h_work, rtw_c2h_work); INIT_WORK(&rtwdev->fw_recovery_work, rtw_fw_recovery_work); INIT_WORK(&rtwdev->ba_work, rtw_txq_ba_work); diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index af5f2024251b..ac6d78507904 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1220,6 +1220,7 @@ enum rtw_coex_bt_state_cnt { }; enum rtw_coex_wl_state_cnt { + COEX_CNT_WL_SCANAP, COEX_CNT_WL_CONNPKT, COEX_CNT_WL_COEXRUN, COEX_CNT_WL_NOISY0, @@ -1305,6 +1306,8 @@ struct rtw_coex_stat { bool bt_fix_2M; bool bt_setup_link; bool bt_multi_link; + bool bt_multi_link_pre; + bool bt_multi_link_remain; bool bt_a2dp_sink; bool bt_a2dp_active; bool bt_reenable; @@ -1363,7 +1366,11 @@ struct rtw_coex_stat { u8 wl_noisy_level; u8 wl_fw_dbg_info[10]; u8 wl_fw_dbg_info_pre[10]; + u8 wl_rx_rate; + u8 wl_tx_rate; + u8 wl_rts_rx_rate; u8 wl_coex_mode; + u8 wl_iot_peer; u8 ampdu_max_time; u8 wl_tput_dir; @@ -1406,6 +1413,9 @@ struct rtw_coex { struct delayed_work wl_remain_work; struct delayed_work bt_remain_work; struct delayed_work wl_connecting_work; + struct delayed_work bt_multi_link_remain_work; + struct delayed_work wl_ccklock_work; + }; #define DPK_RF_REG_NUM 7 From 79d06b20d00bda8daaefcdc8f8c78fd8a5c9376f Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:57 +0800 Subject: [PATCH 169/180] rtw88: coex: add action for coexistence in hardware initial The original setting misses some necessary configuration. Make coexistence slot align to beacon and check the connection situation to know if we need to extend WLAN slot or not. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-9-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index eab5529e6764..f1f12ff0797b 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -2448,11 +2448,19 @@ static void rtw_coex_init_coex_var(struct rtw_dev *rtwdev) static void __rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only) { struct rtw_coex *coex = &rtwdev->coex; + struct rtw_coex_stat *coex_stat = &coex->stat; rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_init_coex_var(rtwdev); + + coex_stat->kt_ver = u8_get_bits(rtw_read8(rtwdev, 0xf1), GENMASK(7, 4)); + rtw_coex_monitor_bt_enable(rtwdev); + rtw_coex_wl_slot_extend(rtwdev, coex_stat->wl_slot_extend); + + rtw_write8_set(rtwdev, REG_BCN_CTRL, BIT_EN_BCN_FUNCTION); + rtw_coex_set_rfe_type(rtwdev); rtw_coex_set_init(rtwdev); @@ -2515,6 +2523,7 @@ void rtw_coex_power_on_setting(struct rtw_dev *rtwdev) rtw_coex_table(rtwdev, true, table_case); /* red x issue */ rtw_write8(rtwdev, 0xff1a, 0x0); + rtw_coex_set_gnt_debug(rtwdev); } void rtw_coex_init_hw_config(struct rtw_dev *rtwdev, bool wifi_only) From 1a74daed6cef336d4afe482edb1e6cc785c65f7c Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:58 +0800 Subject: [PATCH 170/180] rtw88: coex: upgrade coexistence A2DP mechanism Add modifications for A2DP interoperability issue of TWS earphones. Some TWS earphones has low buffer size, so it's necessary to reduce the slot period to let it get data more frequently. (e.g. use 4-slot to replace the original 2-slot method). Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-10-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 257 +++++++++++------- drivers/net/wireless/realtek/rtw88/main.h | 1 + drivers/net/wireless/realtek/rtw88/rtw8723d.c | 1 + drivers/net/wireless/realtek/rtw88/rtw8821c.c | 1 + drivers/net/wireless/realtek/rtw88/rtw8822b.c | 1 + drivers/net/wireless/realtek/rtw88/rtw8822c.c | 1 + 6 files changed, 162 insertions(+), 100 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index f1f12ff0797b..4d921e9d8956 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -319,7 +319,7 @@ static void rtw_coex_tdma_timer_base(struct rtw_dev *rtwdev, u8 type) rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], tbtt_interval = %d\n", tbtt_interval); - if (type == TDMA_TIMER_TYPE_4SLOT) { + if (type == TDMA_TIMER_TYPE_4SLOT && tbtt_interval < 120) { para[1] = PARA1_H2C69_TDMA_4SLOT; /* 4-slot */ } else if (tbtt_interval < 80 && tbtt_interval > 0) { times = 100 / tbtt_interval; @@ -762,6 +762,7 @@ static void rtw_coex_update_bt_link_info(struct rtw_dev *rtwdev) coex_dm->bt_status = COEX_BTSTATUS_INQ_PAGE; } else if (!(coex_stat->bt_info_lb2 & COEX_INFO_CONNECTION)) { coex_dm->bt_status = COEX_BTSTATUS_NCON_IDLE; + coex_stat->bt_multi_link_remain = false; } else if (coex_stat->bt_info_lb2 == COEX_INFO_CONNECTION) { coex_dm->bt_status = COEX_BTSTATUS_CON_IDLE; } else if ((coex_stat->bt_info_lb2 & COEX_INFO_SCO_ESCO) || @@ -870,7 +871,7 @@ static void rtw_coex_set_rf_para(struct rtw_dev *rtwdev, struct rtw_coex_stat *coex_stat = &coex->stat; u8 offset = 0; - if (coex->freerun && coex_stat->wl_noisy_level <= 1) + if (coex->freerun && coex_stat->cnt_wl[COEX_CNT_WL_SCANAP] <= 5) offset = 3; rtw_coex_set_wl_tx_power(rtwdev, para.wl_pwr_dec_lvl); @@ -1102,11 +1103,6 @@ static void rtw_coex_tdma(struct rtw_dev *rtwdev, bool force, u32 tcase) return; } - - /* enable TBTT interrupt */ - if (turn_on) - rtw_write8_set(rtwdev, REG_BCN_CTRL, BIT_EN_BCN_FUNCTION); - wl_busy = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); if ((coex_stat->bt_a2dp_exist && @@ -1116,6 +1112,10 @@ static void rtw_coex_tdma(struct rtw_dev *rtwdev, bool force, u32 tcase) else rtw_coex_write_scbd(rtwdev, COEX_SCBD_TDMA, true); + /* update pre state */ + coex_dm->cur_ps_tdma_on = turn_on; + coex_dm->cur_ps_tdma = type; + if (efuse->share_ant) { if (type < chip->tdma_sant_num) rtw_coex_set_tdma(rtwdev, @@ -1135,9 +1135,6 @@ static void rtw_coex_tdma(struct rtw_dev *rtwdev, bool force, u32 tcase) chip->tdma_nsant[n].para[4]); } - /* update pre state */ - coex_dm->cur_ps_tdma_on = turn_on; - coex_dm->cur_ps_tdma = type; rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], coex tdma type(%s, %d)\n", turn_on ? "on" : "off", type); @@ -1530,6 +1527,8 @@ static void rtw_coex_action_bt_whql_test(struct rtw_dev *rtwdev) static void rtw_coex_action_bt_relink(struct rtw_dev *rtwdev) { + struct rtw_coex *coex = &rtwdev->coex; + struct rtw_coex_stat *coex_stat = &coex->stat; struct rtw_efuse *efuse = &rtwdev->efuse; struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; @@ -1539,13 +1538,24 @@ static void rtw_coex_action_bt_relink(struct rtw_dev *rtwdev) rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); - if (efuse->share_ant) { - /* Shared-Ant */ - table_case = 1; - tdma_case = 0; - } else { - /* Non-Shared-Ant */ - table_case = 100; + if (efuse->share_ant) { /* Shared-Ant */ + if (coex_stat->wl_gl_busy) { + table_case = 26; + if (coex_stat->bt_hid_exist && + coex_stat->bt_profile_num == 1) { + tdma_case = 20; + } else { + tdma_case = 20; + } + } else { + table_case = 1; + tdma_case = 0; + } + } else { /* Non-Shared-Ant */ + if (coex_stat->wl_gl_busy) + table_case = 115; + else + table_case = 100; tdma_case = 100; } @@ -1569,7 +1579,8 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) if (coex_rfe->ant_switch_with_bt && coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { if (efuse->share_ant && - COEX_RSSI_HIGH(coex_dm->wl_rssi_state[1])) { + COEX_RSSI_HIGH(coex_dm->wl_rssi_state[3]) && + coex_stat->wl_gl_busy) { table_case = 0; tdma_case = 0; } else if (!efuse->share_ant) { @@ -1580,9 +1591,7 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) if (table_case != 0xff && tdma_case != 0xff) { rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G_FREERUN); - rtw_coex_table(rtwdev, false, table_case); - rtw_coex_tdma(rtwdev, false, tdma_case); - return; + goto exit; } rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); @@ -1593,8 +1602,12 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) table_case = 10; tdma_case = 3; } else if (coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { - table_case = 6; - tdma_case = 7; + table_case = 11; + + if (coex_stat->lo_pri_rx + coex_stat->lo_pri_tx > 250) + tdma_case = 17; + else + tdma_case = 7; } else { table_case = 12; tdma_case = 7; @@ -1614,6 +1627,7 @@ static void rtw_coex_action_bt_idle(struct rtw_dev *rtwdev) } } +exit: rtw_coex_table(rtwdev, false, table_case); rtw_coex_tdma(rtwdev, false, tdma_case); } @@ -1642,6 +1656,7 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], bt inq/page + wifi hi-pri task\n"); table_case = 15; + if (coex_stat->bt_profile_num > 0) tdma_case = 10; else if (coex_stat->wl_hi_pri_task1) @@ -1651,6 +1666,8 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) else tdma_case = 9; } else if (coex_stat->wl_gl_busy) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], bt inq/page + wifi busy\n"); if (coex_stat->bt_profile_num == 0) { table_case = 12; tdma_case = 18; @@ -1680,23 +1697,25 @@ static void rtw_coex_action_bt_inquiry(struct rtw_dev *rtwdev) if (wl_hi_pri) { rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], bt inq/page + wifi hi-pri task\n"); - table_case = 113; - if (coex_stat->bt_a2dp_exist && - !coex_stat->bt_pan_exist) - tdma_case = 111; + table_case = 114; + + if (coex_stat->bt_profile_num > 0) + tdma_case = 110; else if (coex_stat->wl_hi_pri_task1) tdma_case = 106; else if (!coex_stat->bt_page) tdma_case = 108; else tdma_case = 109; - } else if (coex_stat->wl_gl_busy) { + } else if (coex_stat->wl_gl_busy) { + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], bt inq/page + wifi busy\n"); table_case = 114; tdma_case = 121; } else if (coex_stat->wl_connected) { rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], bt inq/page + wifi connected\n"); - table_case = 100; + table_case = 101; tdma_case = 100; } else { rtw_dbg(rtwdev, RTW_DBG_COEX, @@ -1756,63 +1775,66 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) struct rtw_efuse *efuse = &rtwdev->efuse; struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; - u32 wl_bw; u32 slot_type = 0; + bool bt_multi_link_remain = false; rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); - wl_bw = rtwdev->hal.current_band_width; - if (efuse->share_ant) { /* Shared-Ant */ if (coex_stat->bt_ble_exist) { /* RCU */ - if (!coex_stat->wl_gl_busy) - table_case = 14; - else - table_case = 15; - - if (coex_stat->bt_a2dp_active || wl_bw == 0) - tdma_case = 18; - else if (coex_stat->wl_gl_busy) - tdma_case = 8; - else - tdma_case = 4; - } else { - if (coex_stat->bt_a2dp_active || wl_bw == 0) { - table_case = 8; - tdma_case = 4; + if (coex_stat->cnt_wl[COEX_CNT_WL_SCANAP] > 5) { + table_case = 26; + tdma_case = 2; } else { - /* for 4/18 HID */ - if (coex_stat->bt_418_hid_exist && - coex_stat->wl_gl_busy) { - table_case = 12; - tdma_case = 4; - } else if (coex_stat->bt_ble_hid_exist && - coex_stat->wl_gl_busy) { - table_case = 32; - tdma_case = 9; - } else { - table_case = 10; - tdma_case = 4; - } + table_case = 27; + tdma_case = 9; + } + } else { + /* Legacy HID */ + if (coex_stat->bt_profile_num == 1 && + (coex_stat->bt_multi_link || + (coex_stat->lo_pri_rx + + coex_stat->lo_pri_tx > 360) || + coex_stat->bt_slave || + bt_multi_link_remain)) { + slot_type = TDMA_4SLOT; + table_case = 12; + tdma_case = 20; + } else if (coex_stat->bt_a2dp_active) { + table_case = 9; + tdma_case = 18; + } else if (coex_stat->bt_418_hid_exist && + coex_stat->wl_gl_busy) { + slot_type = TDMA_4SLOT; + table_case = 9; + tdma_case = 24; + } else if (coex_stat->bt_ble_hid_exist && + coex_stat->wl_gl_busy) { + table_case = 32; + tdma_case = 9; + } else { + table_case = 9; + tdma_case = 9; } } } else { /* Non-Shared-Ant */ - if (coex_stat->bt_a2dp_active) { + if (coex_stat->bt_ble_exist) { + /* BLE */ + if (coex_stat->cnt_wl[COEX_CNT_WL_SCANAP] > 5) { + table_case = 121; + tdma_case = 102; + } else { + table_case = 122; + tdma_case = 109; + } + } else if (coex_stat->bt_a2dp_active) { table_case = 113; tdma_case = 118; - } else if (coex_stat->bt_ble_exist) { - /* BLE */ - table_case = 113; - - if (coex_stat->wl_gl_busy) - tdma_case = 106; - else - tdma_case = 104; } else { table_case = 113; tdma_case = 104; @@ -1838,12 +1860,12 @@ static void rtw_coex_action_bt_a2dp(struct rtw_dev *rtwdev) rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); + slot_type = TDMA_4SLOT; + if (efuse->share_ant) { /* Shared-Ant */ - slot_type = TDMA_4SLOT; - if (coex_stat->wl_gl_busy && coex_stat->wl_noisy_level == 0) - table_case = 11; + table_case = 12; else table_case = 9; @@ -1926,7 +1948,7 @@ static void rtw_coex_action_bt_pan(struct rtw_dev *rtwdev) if (coex_stat->wl_gl_busy) tdma_case = 17; else - tdma_case = 19; + tdma_case = 20; } else { /* Non-Shared-Ant */ table_case = 112; @@ -1951,23 +1973,27 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev) u8 table_case, tdma_case; u32 slot_type = 0; + slot_type = TDMA_4SLOT; + rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); if (efuse->share_ant) { /* Shared-Ant */ - slot_type = TDMA_4SLOT; - if (coex_stat->bt_ble_exist) - table_case = 26; + table_case = 26; /* for RCU */ else table_case = 9; - if (coex_stat->wl_gl_busy) - tdma_case = 13; - else + if (coex_stat->wl_connecting || !coex_stat->wl_gl_busy) { tdma_case = 14; + } else if (coex_stat->bt_418_hid_exist || + coex_stat->bt_ble_hid_exist) { + tdma_case = 23; + } else { + tdma_case = 13; + } } else { /* Non-Shared-Ant */ if (coex_stat->bt_ble_exist) @@ -2204,8 +2230,7 @@ static void rtw_coex_action_wl_linkscan(struct rtw_dev *rtwdev) rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); - if (efuse->share_ant) { - /* Shared-Ant */ + if (efuse->share_ant) { /* Shared-Ant */ if (coex_stat->bt_a2dp_exist) { slot_type = TDMA_4SLOT; table_case = 9; @@ -2214,9 +2239,9 @@ static void rtw_coex_action_wl_linkscan(struct rtw_dev *rtwdev) table_case = 9; tdma_case = 7; } - } else { - /* Non-Shared-Ant */ + } else { /* Non-Shared-Ant */ if (coex_stat->bt_a2dp_exist) { + slot_type = TDMA_4SLOT; table_case = 112; tdma_case = 111; } else { @@ -2365,7 +2390,7 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason) rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], WiFi is single-port 2G!!\n"); coex_stat->wl_coex_mode = COEX_WLINK_2G1PORT; - rtw_coex_write_scbd(rtwdev, COEX_SCBD_FIX2M, false); + if (coex_stat->bt_disabled) { if (coex_stat->wl_connected && rf4ce_en) rtw_coex_action_rf4ce(rtwdev); @@ -2403,15 +2428,18 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason) goto exit; } - if (coex_stat->wl_linkscan_proc) { + if (coex_stat->wl_linkscan_proc && !coex->freerun) { rtw_coex_action_wl_linkscan(rtwdev); goto exit; } - if (coex_stat->wl_connected) + if (coex_stat->wl_connected) { rtw_coex_action_wl_connected(rtwdev); - else + goto exit; + } else { rtw_coex_action_wl_not_connected(rtwdev); + goto exit; + } exit: rtw_coex_gnt_workaround(rtwdev, false, coex_stat->wl_coex_mode); @@ -2579,6 +2607,7 @@ void rtw_coex_lps_notify(struct rtw_dev *rtwdev, u8 type) } else { /* for native ps */ rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE, false); + rtw_coex_write_scbd(rtwdev, COEX_SCBD_WLBUSY, false); rtw_coex_run_coex(rtwdev, COEX_RSN_LPS); } @@ -2624,6 +2653,12 @@ void rtw_coex_scan_notify(struct rtw_dev *rtwdev, u8 type) rtw_coex_set_ant_path(rtwdev, true, COEX_SET_ANT_2G); rtw_coex_run_coex(rtwdev, COEX_RSN_2GSCANSTART); } else { + coex_stat->cnt_wl[COEX_CNT_WL_SCANAP] = 30; /* To do */ + + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], SCAN FINISH notify (Scan-AP = %d)\n", + coex_stat->cnt_wl[COEX_CNT_WL_SCANAP]); + coex_stat->wl_hi_pri_task2 = false; rtw_coex_run_coex(rtwdev, COEX_RSN_SCANFINISH); } @@ -2679,6 +2714,7 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) rtw_coex_run_coex(rtwdev, COEX_RSN_5GCONFINISH); } else if (type == COEX_ASSOCIATE_START) { coex_stat->wl_hi_pri_task1 = true; + coex_stat->wl_connecting = true; coex_stat->cnt_wl[COEX_CNT_WL_CONNPKT] = 2; coex_stat->wl_connecting = true; ieee80211_queue_delayed_work(rtwdev->hw, @@ -2700,6 +2736,7 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) } else { coex_stat->wl_hi_pri_task1 = false; coex->freeze = false; + coex_stat->wl_connecting = false; rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): 2G finish\n", __func__); @@ -2710,6 +2747,7 @@ void rtw_coex_connect_notify(struct rtw_dev *rtwdev, u8 type) void rtw_coex_media_status_notify(struct rtw_dev *rtwdev, u8 type) { struct rtw_coex *coex = &rtwdev->coex; + struct rtw_coex_stat *coex_stat = &coex->stat; if (coex->manual_control || coex->stop_dm) return; @@ -2724,6 +2762,8 @@ void rtw_coex_media_status_notify(struct rtw_dev *rtwdev, u8 type) } else if (type == COEX_MEDIA_CONNECT) { rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s(): 2G\n", __func__); + coex_stat->wl_connecting = false; + rtw_coex_write_scbd(rtwdev, COEX_SCBD_ACTIVE, true); /* Force antenna setup for no scan result issue */ @@ -2865,21 +2905,38 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) 4 * HZ); } coex_stat->bt_acl_busy = ((coex_stat->bt_info_lb2 & BIT(3)) == BIT(3)); - if (coex_stat->bt_info_lb2 & BIT(5)) { - if (coex_stat->bt_info_hb1 & BIT(0)) { - /*BLE HID*/ - coex_stat->bt_ble_hid_exist = true; + if (chip->ble_hid_profile_support) { + if (coex_stat->bt_info_lb2 & BIT(5)) { + if (coex_stat->bt_info_hb1 & BIT(0)) { + /*BLE HID*/ + coex_stat->bt_ble_hid_exist = true; + } else { + coex_stat->bt_ble_hid_exist = false; + } + coex_stat->bt_ble_exist = false; + } else if (coex_stat->bt_info_hb1 & BIT(0)) { + /*RCU*/ + coex_stat->bt_ble_hid_exist = false; + coex_stat->bt_ble_exist = true; } else { coex_stat->bt_ble_hid_exist = false; + coex_stat->bt_ble_exist = false; } - coex_stat->bt_ble_exist = false; - } else if (coex_stat->bt_info_hb1 & BIT(0)) { - /*RCU*/ - coex_stat->bt_ble_hid_exist = false; - coex_stat->bt_ble_exist = true; } else { - coex_stat->bt_ble_hid_exist = false; - coex_stat->bt_ble_exist = false; + if (coex_stat->bt_info_hb1 & BIT(0)) { + if (coex_stat->bt_hid_slot == 1 && + coex_stat->hi_pri_rx + 100 < coex_stat->hi_pri_tx && + coex_stat->hi_pri_rx < 100) { + coex_stat->bt_ble_hid_exist = true; + coex_stat->bt_ble_exist = false; + } else { + coex_stat->bt_ble_hid_exist = false; + coex_stat->bt_ble_exist = true; + } + } else { + coex_stat->bt_ble_hid_exist = false; + coex_stat->bt_ble_exist = false; + } } coex_stat->cnt_bt[COEX_CNT_BT_RETRY] = coex_stat->bt_info_lb3 & 0xf; @@ -2916,7 +2973,7 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) if (coex_stat->bt_reenable) bt_relink_time = 6 * HZ; else - bt_relink_time = 2 * HZ; + bt_relink_time = 1 * HZ; ieee80211_queue_delayed_work(rtwdev->hw, &coex->bt_relink_work, @@ -2975,7 +3032,7 @@ void rtw_coex_bt_info_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length) coex_stat->bt_hid_pair_num = (coex_stat->bt_info_hb2 & 0xc0) >> 6; if (coex_stat->bt_hid_pair_num > 0 && coex_stat->bt_hid_slot >= 2) coex_stat->bt_418_hid_exist = true; - else if (coex_stat->bt_hid_pair_num == 0) + else if (coex_stat->bt_hid_pair_num == 0 || coex_stat->bt_hid_slot == 1) coex_stat->bt_418_hid_exist = false; if ((coex_stat->bt_info_lb2 & 0x49) == 0x49) diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index ac6d78507904..4e1369298a82 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1174,6 +1174,7 @@ struct rtw_chip_info { u8 bt_desired_ver; bool scbd_support; bool new_scbd10_def; /* true: fix 2M(8822c) */ + bool ble_hid_profile_support; u8 pstdma_type; /* 0: LPSoff, 1:LPSon */ u8 bt_rssi_type; u8 ant_isolation; diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c b/drivers/net/wireless/realtek/rtw88/rtw8723d.c index 92652b808578..9268ea8b6dda 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c @@ -2752,6 +2752,7 @@ struct rtw_chip_info rtw8723d_hw_spec = { .bt_desired_ver = 0x2f, .scbd_support = true, .new_scbd10_def = true, + .ble_hid_profile_support = false, .pstdma_type = COEX_PSTDMA_FORCE_LPSOFF, .bt_rssi_type = COEX_BTRSSI_RATIO, .ant_isolation = 15, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c index 3f4b2898cedc..fbfd85439d1f 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c @@ -1830,6 +1830,7 @@ struct rtw_chip_info rtw8821c_hw_spec = { .bt_desired_ver = 0x46, .scbd_support = true, .new_scbd10_def = false, + .ble_hid_profile_support = false, .pstdma_type = COEX_PSTDMA_FORCE_LPSOFF, .bt_rssi_type = COEX_BTRSSI_RATIO, .ant_isolation = 15, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index 9c73937c9dde..f1789155e901 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -2507,6 +2507,7 @@ struct rtw_chip_info rtw8822b_hw_spec = { .bt_desired_ver = 0x6, .scbd_support = true, .new_scbd10_def = false, + .ble_hid_profile_support = false, .pstdma_type = COEX_PSTDMA_FORCE_LPSOFF, .bt_rssi_type = COEX_BTRSSI_RATIO, .ant_isolation = 15, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index 06cefe384f34..7dd3ccb73793 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -4365,6 +4365,7 @@ struct rtw_chip_info rtw8822c_hw_spec = { .bt_desired_ver = 0x1c, .scbd_support = true, .new_scbd10_def = true, + .ble_hid_profile_support = true, .pstdma_type = COEX_PSTDMA_FORCE_LPSOFF, .bt_rssi_type = COEX_BTRSSI_DBM, .ant_isolation = 15, From 5b2e9a35e456619f9477eefb6aa029390b763f79 Mon Sep 17 00:00:00 2001 From: Ching-Te Ku Date: Thu, 26 Nov 2020 10:10:59 +0800 Subject: [PATCH 171/180] rtw88: coex: add feature to enhance HID coexistence performance Add toggle table related function to enhance WL throughput when WL coexist with 4/18 HID. The toggle table feature will toggle WL/BT priority table during WL slot, it can decrease the impact from HID's frequently packets and prevent HID lag. Signed-off-by: Ching-Te Ku Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201126021059.11981-11-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw88/coex.c | 102 ++++++++++++++++++++-- drivers/net/wireless/realtek/rtw88/coex.h | 3 + drivers/net/wireless/realtek/rtw88/main.h | 5 ++ 3 files changed, 104 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c index 4d921e9d8956..c704c6885a18 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c @@ -937,6 +937,69 @@ static void rtw_coex_set_gnt_wl(struct rtw_dev *rtwdev, u8 state) rtw_coex_write_indirect_reg(rtwdev, LTE_COEX_CTRL, 0x0300, state); } +static void rtw_btc_wltoggle_table_a(struct rtw_dev *rtwdev, bool force, + u8 table_case) +{ + struct rtw_chip_info *chip = rtwdev->chip; + struct rtw_efuse *efuse = &rtwdev->efuse; + u8 h2c_para[6] = {0}; + u32 table_wl = 0x5a5a5a5a; + + h2c_para[0] = COEX_H2C69_TOGGLE_TABLE_A; + /* no definition */ + h2c_para[1] = 0x1; + + if (efuse->share_ant) { + if (table_case < chip->table_sant_num) + table_wl = chip->table_sant[table_case].wl; + } else { + if (table_case < chip->table_nsant_num) + table_wl = chip->table_nsant[table_case].wl; + } + + /* tell WL FW WL slot toggle table-A*/ + h2c_para[2] = (u8)u32_get_bits(table_wl, GENMASK(7, 0)); + h2c_para[3] = (u8)u32_get_bits(table_wl, GENMASK(15, 8)); + h2c_para[4] = (u8)u32_get_bits(table_wl, GENMASK(23, 16)); + h2c_para[5] = (u8)u32_get_bits(table_wl, GENMASK(31, 24)); + + rtw_fw_bt_wifi_control(rtwdev, h2c_para[0], &h2c_para[1]); + + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s(): H2C = [%02x %02x %02x %02x %02x %02x]\n", + __func__, h2c_para[0], h2c_para[1], h2c_para[2], + h2c_para[3], h2c_para[4], h2c_para[5]); +} + +#define COEX_WL_SLOT_TOGLLE 0x5a5a5aaa +static void rtw_btc_wltoggle_table_b(struct rtw_dev *rtwdev, bool force, + u8 interval, u32 table) +{ + struct rtw_coex *coex = &rtwdev->coex; + struct rtw_coex_stat *coex_stat = &coex->stat; + u8 cur_h2c_para[6] = {0}; + u8 i; + + cur_h2c_para[0] = COEX_H2C69_TOGGLE_TABLE_B; + cur_h2c_para[1] = interval; + cur_h2c_para[2] = (u8)u32_get_bits(table, GENMASK(7, 0)); + cur_h2c_para[3] = (u8)u32_get_bits(table, GENMASK(15, 8)); + cur_h2c_para[4] = (u8)u32_get_bits(table, GENMASK(23, 16)); + cur_h2c_para[5] = (u8)u32_get_bits(table, GENMASK(31, 24)); + + coex_stat->wl_toggle_interval = interval; + + for (i = 0; i <= 5; i++) + coex_stat->wl_toggle_para[i] = cur_h2c_para[i]; + + rtw_fw_bt_wifi_control(rtwdev, cur_h2c_para[0], &cur_h2c_para[1]); + + rtw_dbg(rtwdev, RTW_DBG_COEX, + "[BTCoex], %s(): H2C = [%02x %02x %02x %02x %02x %02x]\n", + __func__, cur_h2c_para[0], cur_h2c_para[1], cur_h2c_para[2], + cur_h2c_para[3], cur_h2c_para[4], cur_h2c_para[5]); +} + static void rtw_coex_set_table(struct rtw_dev *rtwdev, bool force, u32 table0, u32 table1) { @@ -965,6 +1028,7 @@ static void rtw_coex_table(struct rtw_dev *rtwdev, bool force, u8 type) struct rtw_coex_dm *coex_dm = &coex->dm; struct rtw_chip_info *chip = rtwdev->chip; struct rtw_efuse *efuse = &rtwdev->efuse; + struct rtw_coex_stat *coex_stat = &coex->stat; coex_dm->cur_table = type; @@ -982,6 +1046,8 @@ static void rtw_coex_table(struct rtw_dev *rtwdev, bool force, u8 type) chip->table_nsant[type].bt, chip->table_nsant[type].wl); } + if (coex_stat->wl_slot_toggle_change) + rtw_btc_wltoggle_table_a(rtwdev, true, type); } static void rtw_coex_ignore_wlan_act(struct rtw_dev *rtwdev, bool enable) @@ -1031,6 +1097,7 @@ static void rtw_coex_set_tdma(struct rtw_dev *rtwdev, u8 byte1, u8 byte2, struct rtw_coex *coex = &rtwdev->coex; struct rtw_coex_dm *coex_dm = &coex->dm; struct rtw_chip_info *chip = rtwdev->chip; + struct rtw_coex_stat *coex_stat = &coex->stat; u8 ps_type = COEX_PS_WIFI_NATIVE; bool ap_enable = false; @@ -1072,6 +1139,14 @@ static void rtw_coex_set_tdma(struct rtw_dev *rtwdev, u8 byte1, u8 byte2, coex_dm->ps_tdma_para[4] = byte5; rtw_fw_coex_tdma_type(rtwdev, byte1, byte2, byte3, byte4, byte5); + + if (byte1 & BIT(2)) { + coex_stat->wl_slot_toggle = true; + coex_stat->wl_slot_toggle_change = false; + } else { + coex_stat->wl_slot_toggle_change = coex_stat->wl_slot_toggle; + coex_stat->wl_slot_toggle = false; + } } static void rtw_coex_tdma(struct rtw_dev *rtwdev, bool force, u32 tcase) @@ -1776,7 +1851,7 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) struct rtw_chip_info *chip = rtwdev->chip; u8 table_case, tdma_case; u32 slot_type = 0; - bool bt_multi_link_remain = false; + bool bt_multi_link_remain = false, is_toggle_table = false; rtw_dbg(rtwdev, RTW_DBG_COEX, "[BTCoex], %s()\n", __func__); rtw_coex_set_ant_path(rtwdev, false, COEX_SET_ANT_2G); @@ -1809,6 +1884,7 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) tdma_case = 18; } else if (coex_stat->bt_418_hid_exist && coex_stat->wl_gl_busy) { + is_toggle_table = true; slot_type = TDMA_4SLOT; table_case = 9; tdma_case = 24; @@ -1842,6 +1918,11 @@ static void rtw_coex_action_bt_hid(struct rtw_dev *rtwdev) } rtw_coex_table(rtwdev, false, table_case); + if (is_toggle_table) { + rtw_btc_wltoggle_table_a(rtwdev, true, table_case); + rtw_btc_wltoggle_table_b(rtwdev, false, 1, COEX_WL_SLOT_TOGLLE); + } + rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } @@ -1970,8 +2051,9 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev) struct rtw_coex_dm *coex_dm = &coex->dm; struct rtw_efuse *efuse = &rtwdev->efuse; struct rtw_chip_info *chip = rtwdev->chip; - u8 table_case, tdma_case; + u8 table_case, tdma_case, interval; u32 slot_type = 0; + bool is_toggle_table = false; slot_type = TDMA_4SLOT; @@ -1981,15 +2063,19 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev) if (efuse->share_ant) { /* Shared-Ant */ - if (coex_stat->bt_ble_exist) + if (coex_stat->bt_ble_exist) { table_case = 26; /* for RCU */ - else + } else if (coex_stat->bt_418_hid_exist) { table_case = 9; + interval = 1; + } else { + table_case = 9; + } if (coex_stat->wl_connecting || !coex_stat->wl_gl_busy) { tdma_case = 14; - } else if (coex_stat->bt_418_hid_exist || - coex_stat->bt_ble_hid_exist) { + } else if (coex_stat->bt_418_hid_exist) { + is_toggle_table = true; tdma_case = 23; } else { tdma_case = 13; @@ -2008,6 +2094,10 @@ static void rtw_coex_action_bt_a2dp_hid(struct rtw_dev *rtwdev) } rtw_coex_table(rtwdev, false, table_case); + if (is_toggle_table) { + rtw_btc_wltoggle_table_a(rtwdev, true, table_case); + rtw_btc_wltoggle_table_b(rtwdev, false, interval, COEX_WL_SLOT_TOGLLE); + } rtw_coex_tdma(rtwdev, false, tdma_case | slot_type); } diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h index c4898132702f..8ab9852ec9ed 100644 --- a/drivers/net/wireless/realtek/rtw88/coex.h +++ b/drivers/net/wireless/realtek/rtw88/coex.h @@ -25,6 +25,9 @@ #define PARA1_H2C69_TBTT_TIMES GENMASK(5, 0) #define PARA1_H2C69_TBTT_DIV100 BIT(7) +#define COEX_H2C69_TOGGLE_TABLE_A 0xd +#define COEX_H2C69_TOGGLE_TABLE_B 0x7 + #define TDMA_4SLOT BIT(8) #define TDMA_TIMER_TYPE_2SLOT 0 diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index 4e1369298a82..9a318dfd04f9 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -1335,6 +1335,8 @@ struct rtw_coex_stat { bool wl_cck_lock_pre; bool wl_cck_lock_ever; bool wl_connecting; + bool wl_slot_toggle; + bool wl_slot_toggle_change; /* if toggle to no-toggle */ u32 bt_supported_version; u32 bt_supported_feature; @@ -1375,6 +1377,9 @@ struct rtw_coex_stat { u8 ampdu_max_time; u8 wl_tput_dir; + u8 wl_toggle_para[6]; + u8 wl_toggle_interval; + u16 score_board; u16 retry_limit; From 3b52cf6242b49c86bba2b5753a43a4e5999c4171 Mon Sep 17 00:00:00 2001 From: Tian Tao Date: Mon, 23 Nov 2020 09:47:42 +0800 Subject: [PATCH 172/180] wlcore: Switch to using the new API kobj_to_dev() Switch to using the new API kobj_to_dev(). Signed-off-by: Tian Tao Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1606096062-32251-1-git-send-email-tiantao6@hisilicon.com --- drivers/net/wireless/ti/wlcore/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ti/wlcore/sysfs.c b/drivers/net/wireless/ti/wlcore/sysfs.c index 7ac1814182ba..5cf0379b88b6 100644 --- a/drivers/net/wireless/ti/wlcore/sysfs.c +++ b/drivers/net/wireless/ti/wlcore/sysfs.c @@ -100,7 +100,7 @@ static ssize_t wl1271_sysfs_read_fwlog(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buffer, loff_t pos, size_t count) { - struct device *dev = container_of(kobj, struct device, kobj); + struct device *dev = kobj_to_dev(kobj); struct wl1271 *wl = dev_get_drvdata(dev); ssize_t len; int ret; From 75729e110e680687668fd5b4bdd7b25c92e9c00d Mon Sep 17 00:00:00 2001 From: Matthias Brugger Date: Tue, 24 Nov 2020 13:00:18 +0100 Subject: [PATCH 173/180] brcmfmac: expose firmware config files through modinfo Apart from a firmware binary the chip needs a config file used by the FW. Add the config files to modinfo so that they can be read by userspace. Signed-off-by: Matthias Brugger Reviewed-by: Hans de Goede Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201124120018.31358-1-matthias.bgg@kernel.org --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index 805e8d121d00..16ed325795a8 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -625,6 +625,10 @@ BRCMF_FW_DEF(4359, "brcmfmac4359-sdio"); BRCMF_FW_DEF(4373, "brcmfmac4373-sdio"); BRCMF_FW_DEF(43012, "brcmfmac43012-sdio"); +/* firmware config files */ +MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcm/brcmfmac*-sdio.*.txt"); +MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcm/brcmfmac*-pcie.*.txt"); + static const struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = { BRCMF_FW_ENTRY(BRCM_CC_43143_CHIP_ID, 0xFFFFFFFF, 43143), BRCMF_FW_ENTRY(BRCM_CC_43241_CHIP_ID, 0x0000001F, 43241B0), From c04fabacb780b6d8dbc2e7258b383d7a91f69ad9 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 25 Nov 2020 11:41:08 +0000 Subject: [PATCH 174/180] wilc1000: added 'ndo_set_mac_address' callback support Added support for 'ndo_set_mac_address call' callback to allow change of interface MAC address. Signed-off-by: Ajay Singh Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201125114059.10006-2-ajay.kathat@microchip.com --- drivers/net/wireless/microchip/wilc1000/hif.c | 17 +++++++++ drivers/net/wireless/microchip/wilc1000/hif.h | 1 + .../net/wireless/microchip/wilc1000/netdev.c | 38 +++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c b/drivers/net/wireless/microchip/wilc1000/hif.c index d025a3093015..a133736a7821 100644 --- a/drivers/net/wireless/microchip/wilc1000/hif.c +++ b/drivers/net/wireless/microchip/wilc1000/hif.c @@ -1276,6 +1276,23 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) return result; } +int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr) +{ + struct wid wid; + int result; + + wid.id = WID_MAC_ADDR; + wid.type = WID_STR; + wid.size = ETH_ALEN; + wid.val = mac_addr; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to get mac address\n"); + + return result; +} + int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies, size_t ies_len) { diff --git a/drivers/net/wireless/microchip/wilc1000/hif.h b/drivers/net/wireless/microchip/wilc1000/hif.h index db9179171f05..58811911213b 100644 --- a/drivers/net/wireless/microchip/wilc1000/hif.h +++ b/drivers/net/wireless/microchip/wilc1000/hif.h @@ -168,6 +168,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, u8 cipher_mode); int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid); int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr); +int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr); int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies, size_t ies_len); int wilc_disconnect(struct wilc_vif *vif); diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c index 20615c7ec168..2a1fbbdd6a4b 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.c +++ b/drivers/net/wireless/microchip/wilc1000/netdev.c @@ -628,6 +628,43 @@ static struct net_device_stats *mac_stats(struct net_device *dev) return &vif->netstats; } +static int wilc_set_mac_addr(struct net_device *dev, void *p) +{ + int result; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + struct sockaddr *addr = (struct sockaddr *)p; + unsigned char mac_addr[ETH_ALEN]; + struct wilc_vif *tmp_vif; + int srcu_idx; + + if (!is_valid_ether_addr(addr->sa_data)) + return -EINVAL; + + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(tmp_vif, &wilc->vif_list, list) { + wilc_get_mac_address(tmp_vif, mac_addr); + if (ether_addr_equal(addr->sa_data, mac_addr)) { + if (vif != tmp_vif) { + srcu_read_unlock(&wilc->srcu, srcu_idx); + return -EINVAL; + } + srcu_read_unlock(&wilc->srcu, srcu_idx); + return 0; + } + } + srcu_read_unlock(&wilc->srcu, srcu_idx); + + result = wilc_set_mac_address(vif, (u8 *)addr->sa_data); + if (result) + return result; + + ether_addr_copy(vif->bssid, addr->sa_data); + ether_addr_copy(vif->ndev->dev_addr, addr->sa_data); + + return result; +} + static void wilc_set_multicast_list(struct net_device *dev) { struct netdev_hw_addr *ha; @@ -813,6 +850,7 @@ static const struct net_device_ops wilc_netdev_ops = { .ndo_init = mac_init_fn, .ndo_open = wilc_mac_open, .ndo_stop = wilc_mac_close, + .ndo_set_mac_address = wilc_set_mac_addr, .ndo_start_xmit = wilc_mac_xmit, .ndo_get_stats = mac_stats, .ndo_set_rx_mode = wilc_set_multicast_list, From dd460e2ac05ffa52db52a2ab9e64f82ce402eab9 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 25 Nov 2020 11:41:08 +0000 Subject: [PATCH 175/180] wilc1000: free resource in wilc_wlan_txq_add_net_pkt() for failure path Before returing from wilc_wlan_txq_add_net_pkt() invoke tx_complete_fn() callback to free up allocated memory for failure cases. Signed-off-by: Ajay Singh Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201125114059.10006-3-ajay.kathat@microchip.com --- drivers/net/wireless/microchip/wilc1000/wlan.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 6a82fb2f283e..f0cc2da7c9c7 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -284,13 +284,17 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, wilc = vif->wilc; - if (wilc->quit) + if (wilc->quit) { + tx_complete_fn(priv, 0); return 0; + } tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - if (!tqe) + if (!tqe) { + tx_complete_fn(priv, 0); return 0; + } tqe->type = WILC_NET_PKT; tqe->buffer = buffer; tqe->buffer_size = buffer_size; From 66aea5d198c3ad4434e6adfb66dcb574c9a14779 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 25 Nov 2020 11:41:09 +0000 Subject: [PATCH 176/180] wilc1000: free resource in wilc_wlan_txq_add_mgmt_pkt() for failure path Before returing from wilc_wlan_txq_add_mgmt_pkt() invoke tx_complete_fn() callback to free up allocated memory for failure case. Signed-off-by: Ajay Singh Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201125114059.10006-4-ajay.kathat@microchip.com --- drivers/net/wireless/microchip/wilc1000/wlan.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index f0cc2da7c9c7..42b5db4e2d81 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -319,13 +319,17 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, wilc = vif->wilc; - if (wilc->quit) + if (wilc->quit) { + tx_complete_fn(priv, 0); return 0; + } tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - if (!tqe) + if (!tqe) { + tx_complete_fn(priv, 0); return 0; + } tqe->type = WILC_MGMT_PKT; tqe->buffer = buffer; tqe->buffer_size = buffer_size; From 9c172f30b40bb2c50b357930e6a6b7950e610053 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 25 Nov 2020 11:41:10 +0000 Subject: [PATCH 177/180] wilc1000: call complete() for failure in wilc_wlan_txq_add_cfg_pkt() Added complete() call for failure case in wilc_wlan_txq_add_cfg_pkt(). Signed-off-by: Ajay Singh Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201125114059.10006-5-ajay.kathat@microchip.com --- drivers/net/wireless/microchip/wilc1000/wlan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 42b5db4e2d81..0ff4de28f622 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -258,8 +258,10 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, } tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - if (!tqe) + if (!tqe) { + complete(&wilc->cfg_event); return 0; + } tqe->type = WILC_CFG_PKT; tqe->buffer = buffer; From 339754ffdb928c212658fc3a43e6050f2fd79dab Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 25 Nov 2020 11:41:10 +0000 Subject: [PATCH 178/180] wilc1000: added queue support for WMM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added multiple queues[BK,BE,VI,VO] to handle different priority data packets. Before adding a packet to the queue, checked its priority from the header, and then add to the suitable queue. The limit for each queue is maintained separately. Also while passing the packets to the firmware via VMM take care to select data packets based on priority and available space. Signed-off-by: Ajay Singh Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201125114059.10006-6-ajay.kathat@microchip.com --- .../wireless/microchip/wilc1000/cfg80211.c | 7 +- .../net/wireless/microchip/wilc1000/netdev.h | 11 +- .../net/wireless/microchip/wilc1000/wlan.c | 311 ++++++++++++++---- .../net/wireless/microchip/wilc1000/wlan.h | 30 ++ 4 files changed, 300 insertions(+), 59 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c index c1ac1d84790f..e3dd205cbbe5 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1709,7 +1709,7 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, { struct wilc *wl; struct wilc_vif *vif; - int ret; + int ret, i; wl = wilc_create_wiphy(dev); if (!wl) @@ -1725,7 +1725,10 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, wl->io_type = io_type; wl->hif_func = ops; wl->chip_ps_state = WILC_CHIP_WAKEDUP; - INIT_LIST_HEAD(&wl->txq_head.list); + + for (i = 0; i < NQUEUES; i++) + INIT_LIST_HEAD(&wl->txq[i].txq_head.list); + INIT_LIST_HEAD(&wl->rxq_head.list); INIT_LIST_HEAD(&wl->vif_list); diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index d0a006b68d08..86209b391a3d 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -197,6 +197,14 @@ struct wilc_vif { struct cfg80211_bss *bss; }; +struct wilc_tx_queue_status { + u8 buffer[AC_BUFFER_SIZE]; + u16 end_index; + u16 cnt[NQUEUES]; + u16 sum; + bool initialized; +}; + struct wilc { struct wiphy *wiphy; const struct wilc_hif_func *hif_func; @@ -245,9 +253,10 @@ struct wilc { u32 rx_buffer_offset; u8 *tx_buffer; - struct txq_entry_t txq_head; + struct txq_handle txq[NQUEUES]; int txq_entries; + struct wilc_tx_queue_status tx_q_limit; struct rxq_entry_t rxq_head; const struct firmware *firmware; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 0ff4de28f622..993ea7c03429 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -6,6 +6,7 @@ #include #include +#include #include "cfg80211.h" #include "wlan_cfg.h" @@ -28,33 +29,34 @@ static inline void release_bus(struct wilc *wilc, enum bus_release release) mutex_unlock(&wilc->hif_cs); } -static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe) +static void wilc_wlan_txq_remove(struct wilc *wilc, u8 q_num, + struct txq_entry_t *tqe) { list_del(&tqe->list); wilc->txq_entries -= 1; + wilc->txq[q_num].count--; } static struct txq_entry_t * -wilc_wlan_txq_remove_from_head(struct net_device *dev) +wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_num) { struct txq_entry_t *tqe = NULL; unsigned long flags; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; spin_lock_irqsave(&wilc->txq_spinlock, flags); - if (!list_empty(&wilc->txq_head.list)) { - tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t, - list); + if (!list_empty(&wilc->txq[q_num].txq_head.list)) { + tqe = list_first_entry(&wilc->txq[q_num].txq_head.list, + struct txq_entry_t, list); list_del(&tqe->list); wilc->txq_entries -= 1; + wilc->txq[q_num].count--; } spin_unlock_irqrestore(&wilc->txq_spinlock, flags); return tqe; } -static void wilc_wlan_txq_add_to_tail(struct net_device *dev, +static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 q_num, struct txq_entry_t *tqe) { unsigned long flags; @@ -63,15 +65,16 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, spin_lock_irqsave(&wilc->txq_spinlock, flags); - list_add_tail(&tqe->list, &wilc->txq_head.list); + list_add_tail(&tqe->list, &wilc->txq[q_num].txq_head.list); wilc->txq_entries += 1; + wilc->txq[q_num].count++; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); complete(&wilc->txq_event); } -static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, +static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 q_num, struct txq_entry_t *tqe) { unsigned long flags; @@ -81,8 +84,9 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, spin_lock_irqsave(&wilc->txq_spinlock, flags); - list_add(&tqe->list, &wilc->txq_head.list); + list_add(&tqe->list, &wilc->txq[q_num].txq_head.list); wilc->txq_entries += 1; + wilc->txq[q_num].count++; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); mutex_unlock(&wilc->txq_add_to_head_cs); @@ -212,7 +216,7 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) tqe = f->pending_acks[i].txqe; if (tqe) { - wilc_wlan_txq_remove(wilc, tqe); + wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); tqe->status = 1; if (tqe->tx_complete_func) tqe->tx_complete_func(tqe->priv, @@ -268,10 +272,138 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, tqe->buffer_size = buffer_size; tqe->tx_complete_func = NULL; tqe->priv = NULL; + tqe->q_num = AC_VO_Q; tqe->ack_idx = NOT_TCP_ACK; tqe->vif = vif; - wilc_wlan_txq_add_to_head(vif, tqe); + wilc_wlan_txq_add_to_head(vif, AC_VO_Q, tqe); + + return 1; +} + +static bool is_ac_q_limit(struct wilc *wl, u8 q_num) +{ + u8 factors[NQUEUES] = {1, 1, 1, 1}; + u16 i; + unsigned long flags; + struct wilc_tx_queue_status *q = &wl->tx_q_limit; + u8 end_index; + u8 q_limit; + bool ret = false; + + spin_lock_irqsave(&wl->txq_spinlock, flags); + if (!q->initialized) { + for (i = 0; i < AC_BUFFER_SIZE; i++) + q->buffer[i] = i % NQUEUES; + + for (i = 0; i < NQUEUES; i++) { + q->cnt[i] = AC_BUFFER_SIZE * factors[i] / NQUEUES; + q->sum += q->cnt[i]; + } + q->end_index = AC_BUFFER_SIZE - 1; + q->initialized = 1; + } + + end_index = q->end_index; + q->cnt[q->buffer[end_index]] -= factors[q->buffer[end_index]]; + q->cnt[q_num] += factors[q_num]; + q->sum += (factors[q_num] - factors[q->buffer[end_index]]); + + q->buffer[end_index] = q_num; + if (end_index > 0) + q->end_index--; + else + q->end_index = AC_BUFFER_SIZE - 1; + + if (!q->sum) + q_limit = 1; + else + q_limit = (q->cnt[q_num] * FLOW_CONTROL_UPPER_THRESHOLD / q->sum) + 1; + + if (wl->txq[q_num].count <= q_limit) + ret = true; + + spin_unlock_irqrestore(&wl->txq_spinlock, flags); + + return ret; +} + +static inline u8 ac_classify(struct wilc *wilc, struct sk_buff *skb) +{ + u8 q_num = AC_BE_Q; + u8 dscp; + + switch (skb->protocol) { + case htons(ETH_P_IP): + dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc; + break; + case htons(ETH_P_IPV6): + dscp = ipv6_get_dsfield(ipv6_hdr(skb)) & 0xfc; + break; + default: + return q_num; + } + + switch (dscp) { + case 0x08: + case 0x20: + case 0x40: + q_num = AC_BK_Q; + break; + case 0x80: + case 0xA0: + case 0x28: + q_num = AC_VI_Q; + break; + case 0xC0: + case 0xD0: + case 0xE0: + case 0x88: + case 0xB8: + q_num = AC_VO_Q; + break; + } + + return q_num; +} + +static inline int ac_balance(struct wilc *wl, u8 *ratio) +{ + u8 i, max_count = 0; + + if (!ratio) + return -EINVAL; + + for (i = 0; i < NQUEUES; i++) + if (wl->txq[i].fw.count > max_count) + max_count = wl->txq[i].fw.count; + + for (i = 0; i < NQUEUES; i++) + ratio[i] = max_count - wl->txq[i].fw.count; + + return 0; +} + +static inline void ac_update_fw_ac_pkt_info(struct wilc *wl, u32 reg) +{ + wl->txq[AC_BK_Q].fw.count = FIELD_GET(BK_AC_COUNT_FIELD, reg); + wl->txq[AC_BE_Q].fw.count = FIELD_GET(BE_AC_COUNT_FIELD, reg); + wl->txq[AC_VI_Q].fw.count = FIELD_GET(VI_AC_COUNT_FIELD, reg); + wl->txq[AC_VO_Q].fw.count = FIELD_GET(VO_AC_COUNT_FIELD, reg); + + wl->txq[AC_BK_Q].fw.acm = FIELD_GET(BK_AC_ACM_STAT_FIELD, reg); + wl->txq[AC_BE_Q].fw.acm = FIELD_GET(BE_AC_ACM_STAT_FIELD, reg); + wl->txq[AC_VI_Q].fw.acm = FIELD_GET(VI_AC_ACM_STAT_FIELD, reg); + wl->txq[AC_VO_Q].fw.acm = FIELD_GET(VO_AC_ACM_STAT_FIELD, reg); +} + +static inline u8 ac_change(struct wilc *wilc, u8 *ac) +{ + do { + if (wilc->txq[*ac].fw.acm == 0) + return 0; + (*ac)++; + } while (*ac < NQUEUES); return 1; } @@ -283,6 +415,7 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, struct txq_entry_t *tqe; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc; + u8 q_num; wilc = vif->wilc; @@ -304,10 +437,24 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, tqe->priv = priv; tqe->vif = vif; - tqe->ack_idx = NOT_TCP_ACK; - if (vif->ack_filter.enabled) - tcp_process(dev, tqe); - wilc_wlan_txq_add_to_tail(dev, tqe); + q_num = ac_classify(wilc, priv); + tqe->q_num = q_num; + if (ac_change(wilc, &q_num)) { + tx_complete_fn(priv, 0); + kfree(tqe); + return 0; + } + + if (is_ac_q_limit(wilc, q_num)) { + tqe->ack_idx = NOT_TCP_ACK; + if (vif->ack_filter.enabled) + tcp_process(dev, tqe); + wilc_wlan_txq_add_to_tail(dev, q_num, tqe); + } else { + tx_complete_fn(priv, 0); + kfree(tqe); + } + return wilc->txq_entries; } @@ -337,22 +484,23 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, tqe->buffer_size = buffer_size; tqe->tx_complete_func = tx_complete_fn; tqe->priv = priv; + tqe->q_num = AC_BE_Q; tqe->ack_idx = NOT_TCP_ACK; tqe->vif = vif; - wilc_wlan_txq_add_to_tail(dev, tqe); + wilc_wlan_txq_add_to_tail(dev, AC_VO_Q, tqe); return 1; } -static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc) +static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc, u8 q_num) { struct txq_entry_t *tqe = NULL; unsigned long flags; spin_lock_irqsave(&wilc->txq_spinlock, flags); - if (!list_empty(&wilc->txq_head.list)) - tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t, - list); + if (!list_empty(&wilc->txq[q_num].txq_head.list)) + tqe = list_first_entry(&wilc->txq[q_num].txq_head.list, + struct txq_entry_t, list); spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -360,13 +508,14 @@ static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc) } static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc, - struct txq_entry_t *tqe) + struct txq_entry_t *tqe, + u8 q_num) { unsigned long flags; spin_lock_irqsave(&wilc->txq_spinlock, flags); - if (!list_is_last(&tqe->list, &wilc->txq_head.list)) + if (!list_is_last(&tqe->list, &wilc->txq[q_num].txq_head.list)) tqe = list_next_entry(tqe, list); else tqe = NULL; @@ -489,54 +638,92 @@ EXPORT_SYMBOL_GPL(host_sleep_notify); int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) { int i, entries = 0; + u8 k, ac; u32 sum; u32 reg; + u8 ac_desired_ratio[NQUEUES] = {0, 0, 0, 0}; + u8 ac_preserve_ratio[NQUEUES] = {1, 1, 1, 1}; + u8 *num_pkts_to_add; + u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; u32 offset = 0; + bool max_size_over = 0, ac_exist = 0; int vmm_sz = 0; - struct txq_entry_t *tqe; + struct txq_entry_t *tqe_q[NQUEUES]; int ret = 0; int counter; int timeout; u32 vmm_table[WILC_VMM_TBL_SIZE]; + u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0}; const struct wilc_hif_func *func; + int srcu_idx; u8 *txb = wilc->tx_buffer; - struct net_device *dev; struct wilc_vif *vif; if (wilc->quit) goto out_update_cnt; + if (ac_balance(wilc, ac_desired_ratio)) + return -EINVAL; + mutex_lock(&wilc->txq_add_to_head_cs); - tqe = wilc_wlan_txq_get_first(wilc); - if (!tqe) - goto out_unlock; - dev = tqe->vif->ndev; - wilc_wlan_txq_filter_dup_tcp_ack(dev); + + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) + wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); + srcu_read_unlock(&wilc->srcu, srcu_idx); + + for (ac = 0; ac < NQUEUES; ac++) + tqe_q[ac] = wilc_wlan_txq_get_first(wilc, ac); + i = 0; sum = 0; - while (tqe && (i < (WILC_VMM_TBL_SIZE - 1))) { - if (tqe->type == WILC_CFG_PKT) - vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET; - else if (tqe->type == WILC_NET_PKT) - vmm_sz = ETH_ETHERNET_HDR_OFFSET; - else - vmm_sz = HOST_HDR_OFFSET; + max_size_over = 0; + num_pkts_to_add = ac_desired_ratio; + do { + ac_exist = 0; + for (ac = 0; (ac < NQUEUES) && (!max_size_over); ac++) { + if (!tqe_q[ac]) + continue; - vmm_sz += tqe->buffer_size; - vmm_sz = ALIGN(vmm_sz, 4); + vif = tqe_q[ac]->vif; + ac_exist = 1; + for (k = 0; (k < num_pkts_to_add[ac]) && + (!max_size_over) && tqe_q[ac]; k++) { + if (i >= (WILC_VMM_TBL_SIZE - 1)) { + max_size_over = 1; + break; + } - if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) - break; + if (tqe_q[ac]->type == WILC_CFG_PKT) + vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET; + else if (tqe_q[ac]->type == WILC_NET_PKT) + vmm_sz = ETH_ETHERNET_HDR_OFFSET; + else + vmm_sz = HOST_HDR_OFFSET; - vmm_table[i] = vmm_sz / 4; - if (tqe->type == WILC_CFG_PKT) - vmm_table[i] |= BIT(10); - cpu_to_le32s(&vmm_table[i]); + vmm_sz += tqe_q[ac]->buffer_size; + vmm_sz = ALIGN(vmm_sz, 4); - i++; - sum += vmm_sz; - tqe = wilc_wlan_txq_get_next(wilc, tqe); - } + if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { + max_size_over = 1; + break; + } + vmm_table[i] = vmm_sz / 4; + if (tqe_q[ac]->type == WILC_CFG_PKT) + vmm_table[i] |= BIT(10); + + cpu_to_le32s(&vmm_table[i]); + vmm_entries_ac[i] = ac; + + i++; + sum += vmm_sz; + tqe_q[ac] = wilc_wlan_txq_get_next(wilc, + tqe_q[ac], + ac); + } + } + num_pkts_to_add = ac_preserve_ratio; + } while (!max_size_over && ac_exist); if (i == 0) goto out_unlock; @@ -550,8 +737,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) if (ret) break; - if ((reg & 0x1) == 0) + if ((reg & 0x1) == 0) { + ac_update_fw_ac_pkt_info(wilc, reg); break; + } counter++; if (counter > 200) { @@ -620,11 +809,13 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) offset = 0; i = 0; do { + struct txq_entry_t *tqe; u32 header, buffer_offset; char *bssid; u8 mgmt_ptk = 0; - tqe = wilc_wlan_txq_remove_from_head(dev); + tqe = wilc_wlan_txq_remove_from_head(wilc, vmm_entries_ac[i]); + ac_pkt_num_to_chip[vmm_entries_ac[i]]++; if (!tqe) break; @@ -649,8 +840,11 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) if (tqe->type == WILC_CFG_PKT) { buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; } else if (tqe->type == WILC_NET_PKT) { + int prio = tqe->q_num; + bssid = tqe->vif->bssid; buffer_offset = ETH_ETHERNET_HDR_OFFSET; + memcpy(&txb[offset + 4], &prio, sizeof(prio)); memcpy(&txb[offset + 8], bssid, 6); } else { buffer_offset = HOST_HDR_OFFSET; @@ -668,6 +862,8 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL; kfree(tqe); } while (--entries); + for (i = 0; i < NQUEUES; i++) + wilc->txq[i].fw.count += ac_pkt_num_to_chip[i]; acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); @@ -966,14 +1162,17 @@ void wilc_wlan_cleanup(struct net_device *dev) { struct txq_entry_t *tqe; struct rxq_entry_t *rqe; + u8 ac; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; wilc->quit = 1; - while ((tqe = wilc_wlan_txq_remove_from_head(dev))) { - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, 0); - kfree(tqe); + for (ac = 0; ac < NQUEUES; ac++) { + while ((tqe = wilc_wlan_txq_remove_from_head(wilc, ac))) { + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, 0); + kfree(tqe); + } } while ((rqe = wilc_wlan_rxq_remove(wilc))) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index 7689569cd82f..3d2104f19819 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -207,6 +207,18 @@ #define MODALIAS "WILC_SPI" +#define NQUEUES 4 +#define AC_BUFFER_SIZE 1000 + +#define VO_AC_COUNT_FIELD GENMASK(31, 25) +#define VO_AC_ACM_STAT_FIELD BIT(24) +#define VI_AC_COUNT_FIELD GENMASK(23, 17) +#define VI_AC_ACM_STAT_FIELD BIT(16) +#define BE_AC_COUNT_FIELD GENMASK(15, 9) +#define BE_AC_ACM_STAT_FIELD BIT(8) +#define BK_AC_COUNT_FIELD GENMASK(7, 3) +#define BK_AC_ACM_STAT_FIELD BIT(1) + #define WILC_PKT_HDR_CONFIG_FIELD BIT(31) #define WILC_PKT_HDR_OFFSET_FIELD GENMASK(30, 22) #define WILC_PKT_HDR_TOTAL_LEN_FIELD GENMASK(21, 11) @@ -295,10 +307,17 @@ * Tx/Rx Queue Structure * ********************************************/ +enum ip_pkt_priority { + AC_VO_Q = 0, + AC_VI_Q = 1, + AC_BE_Q = 2, + AC_BK_Q = 3 +}; struct txq_entry_t { struct list_head list; int type; + u8 q_num; int ack_idx; u8 *buffer; int buffer_size; @@ -308,6 +327,17 @@ struct txq_entry_t { void (*tx_complete_func)(void *priv, int status); }; +struct txq_fw_recv_queue_stat { + u8 acm; + u8 count; +}; + +struct txq_handle { + struct txq_entry_t txq_head; + u16 count; + struct txq_fw_recv_queue_stat fw; +}; + struct rxq_entry_t { struct list_head list; u8 *buffer; From a460b0e1bab831076b42b6027b1547953c209036 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Fri, 27 Nov 2020 09:58:21 -0800 Subject: [PATCH 179/180] airo: remove trailing semicolon in macro definition The macro use will already have a semicolon. Signed-off-by: Tom Rix Reviewed-by: Kieran Bingham Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201127175821.2756988-1-trix@redhat.com --- drivers/net/wireless/cisco/airo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index 74acf9af2adb..ba62bb2995d9 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -5785,7 +5785,7 @@ static int airo_get_quality (StatusRid *status_rid, CapabilityRid *cap_rid) } #define airo_get_max_quality(cap_rid) (memcmp((cap_rid)->prodName, "350", 3) ? 0x20 : 0xa0) -#define airo_get_avg_quality(cap_rid) (memcmp((cap_rid)->prodName, "350", 3) ? 0x10 : 0x50); +#define airo_get_avg_quality(cap_rid) (memcmp((cap_rid)->prodName, "350", 3) ? 0x10 : 0x50) /*------------------------------------------------------------------*/ /* From fc6877b87982defcacef96934b8aafa4a31c7d83 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Fri, 27 Nov 2020 10:08:35 -0800 Subject: [PATCH 180/180] wl1251: remove trailing semicolon in macro definition The macro use will already have a semicolon. Signed-off-by: Tom Rix Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201127180835.2769297-1-trix@redhat.com --- drivers/net/wireless/ti/wl1251/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ti/wl1251/debugfs.c b/drivers/net/wireless/ti/wl1251/debugfs.c index d48746e640cc..a1b778a0fda0 100644 --- a/drivers/net/wireless/ti/wl1251/debugfs.c +++ b/drivers/net/wireless/ti/wl1251/debugfs.c @@ -39,7 +39,7 @@ static const struct file_operations name## _ops = { \ #define DEBUGFS_ADD(name, parent) \ wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \ - wl, &name## _ops); \ + wl, &name## _ops) \ #define DEBUGFS_DEL(name) \ do { \