ath6kl: don't use cfg80211_scan_request after cfg80211_scan_done()
PATCH 1/10 ath6kl: don't use cfg80211_scan_request after cfg80211_scan_done()
Use of cfg80211_scan_request is not valid after calling cfg80211_scan_done() but ath6kl_cfg80211_scan_complete_event() was doing exactly that. Change the function to call cfg80211_scan_done() last.
This was found during code review, I didn't see any visible problems due to this bug.
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +4 -2
@@ -874,6 +874,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,void ath6kl_cfg80211_scan_complete_event (struct ath6kl_vif *vif,int status) {struct ath6kl *ar = vif->ar; +bool aborted;int i;ath6kl_dbg (ATH6KL_DBG_WLAN_CFG ,"%s: status %d\n" , __func__, status);
@@ -882,11 +883,11 @@ void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, int status)return ;if ((status == -ECANCELED ) || (status == -EBUSY )) { -cfg80211_scan_done (vif->scan_req, true); + aborted = true; goto out; } -cfg80211_scan_done (vif->scan_req, false); + aborted = false;if (vif->scan_req->n_ssids && vif->scan_req->ssids[0 ].ssid_len) {for (i =0 ; i < vif->scan_req->n_ssids; i++) {
@@ -897,6 +898,7 @@ void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, int status) } out: +cfg80211_scan_done (vif->scan_req, aborted); vif->scan_req =NULL ; }
PATCH 2/10 ath6kl: rename ath6kl_wmi_qos_state_init() to _wmi_reset()
Just to make it more clear that this function is supposed to reset wmi related variables.
--- drivers/net/wireless/ath/ath6kl/wmi.c | 7 ++----- drivers/net/wireless/ath/ath6kl/wmi.h | 1 + 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath6kl/wmi.c +2 -5
@@ -3201,11 +3201,8 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)return ret; } -static void ath6kl_wmi_qos_state_init (struct wmi *wmi) +void ath6kl_wmi_reset (struct wmi *wmi) { -if (!wmi) -return ; -spin_lock_bh (&wmi->lock); wmi->fat_pipe_exist =0 ;
@@ -3228,7 +3225,7 @@ void *ath6kl_wmi_init(struct ath6kl *dev) wmi->pwr_mode =REC_POWER ; -ath6kl_wmi_qos_state_init (wmi); +ath6kl_wmi_reset (wmi);return wmi; }
drivers/net/wireless/ath/ath6kl/wmi.h +1 -0
@@ -2316,5 +2316,6 @@ int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type,struct ath6kl_vif *ath6kl_get_vif_by_index (struct ath6kl *ar,u8 if_idx);void *ath6kl_wmi_init (struct ath6kl *devt);void ath6kl_wmi_shutdown (struct wmi *wmi); +void ath6kl_wmi_reset (struct wmi *wmi);#endif /* WMI_H */
PATCH 3/10 ath6kl: move power control from sdio to core
In reply to Kalle ValoIn preparation for cutting down power from the chip on the fly.
--- drivers/net/wireless/ath/ath6kl/hif-ops.h | 15 +++++++++++++++ drivers/net/wireless/ath/ath6kl/hif.h | 2 ++ drivers/net/wireless/ath/ath6kl/init.c | 16 ++++++++++++---- drivers/net/wireless/ath/ath6kl/sdio.c | 20 ++++++++------------ 4 files changed, 37 insertions(+), 16 deletions(-)
drivers/net/wireless/ath/ath6kl/hif-ops.h +15 -0
@@ -96,4 +96,19 @@ static inline int ath6kl_hif_resume(struct ath6kl *ar) return ar->hif_ops->resume(ar); } + +static inline int ath6kl_hif_power_on (struct ath6kl *ar) +{ +ath6kl_dbg (ATH6KL_DBG_HIF ,"hif power on\n" ); + +return ar->hif_ops->power_on (ar); +} + +static inline int ath6kl_hif_power_off (struct ath6kl *ar) +{ +ath6kl_dbg (ATH6KL_DBG_HIF ,"hif power off\n" ); + +return ar->hif_ops->power_off (ar); +} +#endif
drivers/net/wireless/ath/ath6kl/hif.h +2 -0
@@ -242,6 +242,8 @@ struct ath6kl_hif_ops {void (*cleanup_scatter)(struct ath6kl *ar);int (*suspend)(struct ath6kl *ar);int (*resume)(struct ath6kl *ar); +int (*power_on)(struct ath6kl *ar); +int (*power_off)(struct ath6kl *ar); };int ath6kl_hif_setup (struct ath6kl_device *dev);
drivers/net/wireless/ath/ath6kl/init.c +12 -4
@@ -554,6 +554,8 @@ void ath6kl_core_free(struct ath6kl *ar)void ath6kl_core_cleanup (struct ath6kl *ar) { +ath6kl_hif_power_off (ar); +destroy_workqueue (ar->ath6kl_wq);if (ar->htc_target)
@@ -1601,27 +1603,31 @@ int ath6kl_core_init(struct ath6kl *ar)if (ret) goto err_wq; - ret =ath6kl_bmi_get_target_info (ar, &targ_info); + ret =ath6kl_hif_power_on (ar);if (ret) goto err_bmi_cleanup; + ret =ath6kl_bmi_get_target_info (ar, &targ_info); +if (ret) + goto err_power_off; + ar->version.target_ver =le32_to_cpu (targ_info.version); ar->target_type =le32_to_cpu (targ_info.type); ar->wiphy->hw_version =le32_to_cpu (targ_info.version); ret =ath6kl_init_hw_params (ar);if (ret) - goto err_bmi_cleanup; + goto err_power_off; ret =ath6kl_configure_target (ar);if (ret) - goto err_bmi_cleanup; + goto err_power_off; ar->htc_target =ath6kl_htc_create (ar);if (!ar->htc_target) { ret = -ENOMEM ; - goto err_bmi_cleanup; + goto err_power_off; } ret =ath6kl_fetch_firmwares (ar);
@@ -1640,6 +1646,8 @@ int ath6kl_core_init(struct ath6kl *ar) err_htc_cleanup:ath6kl_htc_cleanup (ar->htc_target); +err_power_off: +ath6kl_hif_power_off (ar); err_bmi_cleanup:ath6kl_bmi_cleanup (ar); err_wq:
drivers/net/wireless/ath/ath6kl/sdio.c +8 -12
@@ -463,8 +463,9 @@ static void ath6kl_sdio_irq_handler(struct sdio_func *func)WARN_ON (status && status != -ECANCELED ); } -static int ath6kl_sdio_power_on (struct ath6kl_sdio *ar_sdio) +static int ath6kl_sdio_power_on (struct ath6kl *ar) { +struct ath6kl_sdio *ar_sdio =ath6kl_sdio_priv (ar);struct sdio_func *func = ar_sdio->func;int ret =0 ;
@@ -495,8 +496,9 @@ static int ath6kl_sdio_power_on(struct ath6kl_sdio *ar_sdio)return ret; } -static int ath6kl_sdio_power_off (struct ath6kl_sdio *ar_sdio) +static int ath6kl_sdio_power_off (struct ath6kl *ar) { +struct ath6kl_sdio *ar_sdio =ath6kl_sdio_priv (ar);int ret;if (ar_sdio->is_disabled)
@@ -772,6 +774,8 @@ static const struct ath6kl_hif_ops ath6kl_sdio_ops = { .cleanup_scatter = ath6kl_sdio_cleanup_scatter, .suspend = ath6kl_sdio_suspend, .resume = ath6kl_sdio_resume, + .power_on = ath6kl_sdio_power_on, + .power_off = ath6kl_sdio_power_off, }; static int ath6kl_sdio_probe(struct sdio_func *func,
@@ -852,10 +856,6 @@ static int ath6kl_sdio_probe(struct sdio_func *func,sdio_release_host (func); - ret =ath6kl_sdio_power_on (ar_sdio); -if (ret) - goto err_core_alloc; -sdio_claim_host (func); ret =sdio_set_block_size (func,HIF_MBOX_BLOCK_SIZE );
@@ -863,7 +863,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func,ath6kl_err ("Set sdio block size %d failed: %d)\n" ,HIF_MBOX_BLOCK_SIZE , ret);sdio_release_host (func); - goto err_off; + goto err_hif; }sdio_release_host (func);
@@ -871,13 +871,11 @@ static int ath6kl_sdio_probe(struct sdio_func *func, ret =ath6kl_core_init (ar);if (ret) {ath6kl_err ("Failed to init ath6kl core\n" ); - goto err_off; + goto err_hif; }return ret; -err_off: -ath6kl_sdio_power_off (ar_sdio); err_core_alloc:ath6kl_core_free (ar_sdio->ar); err_dma:
@@ -903,8 +901,6 @@ static void ath6kl_sdio_remove(struct sdio_func *func)ath6kl_core_cleanup (ar_sdio->ar); -ath6kl_sdio_power_off (ar_sdio); -kfree (ar_sdio->dma_buffer);kfree (ar_sdio); }
PATCH 4/10 ath6kl: add a fixme to ath6kl_htc_wait_target()
In reply to Kalle ValoThis doesn't look right, but investigate it later.
--- drivers/net/wireless/ath/ath6kl/htc.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath6kl/htc.c +4 -0
@@ -2598,6 +2598,10 @@ int ath6kl_htc_wait_target(struct htc_target *target) status =ath6kl_htc_conn_service ((void *)target, &connect, &resp);if (status) +/* +* FIXME: this call doesn't make sense, the caller should +* call ath6kl_htc_cleanup() when it wants remove htc +*/ ath6kl_hif_cleanup_scatter (target->dev->ar); fail_wait_target:
PATCH 5/10 ath6kl: merge ath6kl_init() to ath6kl_core_init()
In reply to Kalle ValoIn preparation for splitting module initialisation and hardware boot code from each other.
--- drivers/net/wireless/ath/ath6kl/init.c | 148 ++++++++++++++------------------ 1 files changed, 65 insertions(+), 83 deletions(-)
drivers/net/wireless/ath/ath6kl/init.c +65 -83
@@ -1421,20 +1421,62 @@ static int ath6kl_init_hw_params(struct ath6kl *ar)return 0 ; } -static int ath6kl_init (struct ath6kl *ar) +int ath6kl_core_init (struct ath6kl *ar) { -int status =0 ; +struct ath6kl_bmi_target_info targ_info;s32 timeleft;struct net_device *ndev; -int i; +int i, ret =0 ; -if (!ar) -return -EIO ; + ar->ath6kl_wq =create_singlethread_workqueue ("ath6kl" ); +if (!ar->ath6kl_wq) +return -ENOMEM ; + + ret =ath6kl_bmi_init (ar); +if (ret) + goto err_wq; + + ret =ath6kl_hif_power_on (ar); +if (ret) + goto err_bmi_cleanup; + + ret =ath6kl_bmi_get_target_info (ar, &targ_info); +if (ret) + goto err_power_off; + + ar->version.target_ver =le32_to_cpu (targ_info.version); + ar->target_type =le32_to_cpu (targ_info.type); + ar->wiphy->hw_version =le32_to_cpu (targ_info.version); + + ret =ath6kl_init_hw_params (ar); +if (ret) + goto err_power_off; + + ret =ath6kl_configure_target (ar); +if (ret) + goto err_power_off; + + ar->htc_target =ath6kl_htc_create (ar); + +if (!ar->htc_target) { + ret = -ENOMEM ; + goto err_power_off; + } + + ret =ath6kl_fetch_firmwares (ar); +if (ret) + goto err_htc_cleanup; + +/* FIXME: we should free all firmwares in the error cases below */ + + ret =ath6kl_init_upload (ar); +if (ret) + goto err_htc_cleanup;/* Do we need to finish the BMI phase */ if (ath6kl_bmi_done (ar)) { - status = -EIO ; - goto ath6kl_init_done; + ret = -EIO ; + goto err_htc_cleanup; }/* Indicate that WMI is enabled (although not ready yet) */
@@ -1442,18 +1484,18 @@ static int ath6kl_init(struct ath6kl *ar) ar->wmi =ath6kl_wmi_init (ar);if (!ar->wmi) {ath6kl_err ("failed to initialize wmi\n" ); - status = -EIO ; - goto ath6kl_init_done; + ret = -EIO ; + goto err_htc_cleanup; }ath6kl_dbg (ATH6KL_DBG_TRC ,"%s: got wmi @ 0x%p.\n" , __func__, ar->wmi); - status =ath6kl_register_ieee80211_hw (ar); -if (status) + ret =ath6kl_register_ieee80211_hw (ar); +if (ret) goto err_node_cleanup; - status =ath6kl_debug_init (ar); -if (status) { + ret =ath6kl_debug_init (ar); +if (ret) {wiphy_unregister (ar->wiphy); goto err_node_cleanup; }
@@ -1471,7 +1513,7 @@ static int ath6kl_init(struct ath6kl *ar)if (!ndev) {ath6kl_err ("Failed to instantiate a network device\n" ); - status = -ENOMEM ; + ret = -ENOMEM ;wiphy_unregister (ar->wiphy); goto err_debug_init; }
@@ -1486,12 +1528,12 @@ static int ath6kl_init(struct ath6kl *ar)* size. */ if (ath6kl_htc_wait_target (ar->htc_target)) { - status = -EIO ; + ret = -EIO ; goto err_if_deinit; }if (ath6kl_init_service_ep (ar)) { - status = -EIO ; + ret = -EIO ; goto err_cleanup_scatter; }
@@ -1514,9 +1556,8 @@ static int ath6kl_init(struct ath6kl *ar)ath6kl_cookie_init (ar);/* start HTC */ - status =ath6kl_htc_start (ar->htc_target); - -if (status) { + ret =ath6kl_htc_start (ar->htc_target); +if (ret) {ath6kl_cookie_cleanup (ar); goto err_rxbuf_cleanup; }
@@ -1532,13 +1573,13 @@ static int ath6kl_init(struct ath6kl *ar)if (ar->version.abi_ver !=ATH6KL_ABI_VERSION ) {ath6kl_err ("abi version mismatch: host(0x%x), target(0x%x)\n" ,ATH6KL_ABI_VERSION , ar->version.abi_ver); - status = -EIO ; + ret = -EIO ; goto err_htc_stop; }if (!timeleft ||signal_pending (current)) {ath6kl_err ("wmi is not ready or wait was interrupted\n" ); - status = -EIO ; + ret = -EIO ; goto err_htc_stop; }
@@ -1554,8 +1595,8 @@ static int ath6kl_init(struct ath6kl *ar) ar->wiphy->flags |=WIPHY_FLAG_SUPPORTS_FW_ROAM ;for (i =0 ; i <MAX_NUM_VIF ; i++) { - status =ath6kl_target_config_wlan_params (ar, i); -if (status) + ret =ath6kl_target_config_wlan_params (ar, i); +if (ret) goto err_htc_stop; }
@@ -1565,7 +1606,7 @@ static int ath6kl_init(struct ath6kl *ar)*/ memcpy (ndev->dev_addr, ar->mac_addr,ETH_ALEN ); -return status; +return ret; err_htc_stop:ath6kl_htc_stop (ar->htc_target);
@@ -1585,65 +1626,6 @@ err_node_cleanup:ath6kl_wmi_shutdown (ar->wmi);clear_bit (WMI_ENABLED , &ar->flag); ar->wmi =NULL ; - -ath6kl_init_done: -return status; -} - -int ath6kl_core_init (struct ath6kl *ar) -{ -int ret =0 ; -struct ath6kl_bmi_target_info targ_info; - - ar->ath6kl_wq =create_singlethread_workqueue ("ath6kl" ); -if (!ar->ath6kl_wq) -return -ENOMEM ; - - ret =ath6kl_bmi_init (ar); -if (ret) - goto err_wq; - - ret =ath6kl_hif_power_on (ar); -if (ret) - goto err_bmi_cleanup; - - ret =ath6kl_bmi_get_target_info (ar, &targ_info); -if (ret) - goto err_power_off; - - ar->version.target_ver =le32_to_cpu (targ_info.version); - ar->target_type =le32_to_cpu (targ_info.type); - ar->wiphy->hw_version =le32_to_cpu (targ_info.version); - - ret =ath6kl_init_hw_params (ar); -if (ret) - goto err_power_off; - - ret =ath6kl_configure_target (ar); -if (ret) - goto err_power_off; - - ar->htc_target =ath6kl_htc_create (ar); - -if (!ar->htc_target) { - ret = -ENOMEM ; - goto err_power_off; - } - - ret =ath6kl_fetch_firmwares (ar); -if (ret) - goto err_htc_cleanup; - - ret =ath6kl_init_upload (ar); -if (ret) - goto err_htc_cleanup; - - ret =ath6kl_init (ar); -if (ret) - goto err_htc_cleanup; - -return ret; - err_htc_cleanup:ath6kl_htc_cleanup (ar->htc_target); err_power_off:
PATCH 6/10 ath6kl: separate hardware boot code from module initialisation code
In reply to Kalle ValoRefactor the code needed to boot the hardware to a separate function so that it will be easier boot and shutdown hardware.
No functional changes (hopefully).
--- drivers/net/wireless/ath/ath6kl/init.c | 183 +++++++++++++++++++------------- 1 files changed, 106 insertions(+), 77 deletions(-)
drivers/net/wireless/ath/ath6kl/init.c +106 -77
@@ -1421,12 +1421,107 @@ static int ath6kl_init_hw_params(struct ath6kl *ar)return 0 ; } +static int ath6kl_hw_start (struct ath6kl *ar) +{ +long timeleft; +int ret, i; + + ret =ath6kl_hif_power_on (ar); +if (ret) +return ret; + + ret =ath6kl_configure_target (ar); +if (ret) + goto err_power_off; + + ret =ath6kl_init_upload (ar); +if (ret) + goto err_power_off; + +/* Do we need to finish the BMI phase */ +/* FIXME: return error from ath6kl_bmi_done() */ +if (ath6kl_bmi_done (ar)) { + ret = -EIO ; + goto err_power_off; + } + +/* +* The reason we have to wait for the target here is that the +* driver layer has to init BMI in order to set the host block +* size. +*/ +if (ath6kl_htc_wait_target (ar->htc_target)) { + ret = -EIO ; + goto err_power_off; + } + +if (ath6kl_init_service_ep (ar)) { + ret = -EIO ; + goto err_cleanup_scatter; + } + +/* setup credit distribution */ +ath6kl_credit_setup (ar->htc_target, &ar->credit_state_info); + +/* start HTC */ + ret =ath6kl_htc_start (ar->htc_target); +if (ret) { +/* FIXME: call this */ +ath6kl_cookie_cleanup (ar); + goto err_cleanup_scatter; + } + +/* Wait for Wmi event to be ready */ + timeleft =wait_event_interruptible_timeout (ar->event_wq, +test_bit (WMI_READY , + &ar->flag), +WMI_TIMEOUT ); + +ath6kl_dbg (ATH6KL_DBG_BOOT ,"firmware booted\n" ); + +if (ar->version.abi_ver !=ATH6KL_ABI_VERSION ) { +ath6kl_err ("abi version mismatch: host(0x%x), target(0x%x)\n" , +ATH6KL_ABI_VERSION , ar->version.abi_ver); + ret = -EIO ; + goto err_htc_stop; + } + +if (!timeleft ||signal_pending (current)) { +ath6kl_err ("wmi is not ready or wait was interrupted\n" ); + ret = -EIO ; + goto err_htc_stop; + } + +ath6kl_dbg (ATH6KL_DBG_TRC ,"%s: wmi is ready\n" , __func__); + +/* communicate the wmi protocol verision to the target */ +/* FIXME: return error */ +if ((ath6kl_set_host_app_area (ar)) !=0 ) +ath6kl_err ("unable to set the host app area\n" ); + +for (i =0 ; i <MAX_NUM_VIF ; i++) { + ret =ath6kl_target_config_wlan_params (ar, i); +if (ret) + goto err_htc_stop; + } + +return 0 ; + +err_htc_stop: +ath6kl_htc_stop (ar->htc_target); +err_cleanup_scatter: +ath6kl_hif_cleanup_scatter (ar); +err_power_off: +ath6kl_hif_power_off (ar); + +return ret; +} +int ath6kl_core_init (struct ath6kl *ar) {struct ath6kl_bmi_target_info targ_info; -s32 timeleft;struct net_device *ndev; -int i, ret =0 ; +int ret =0 , i; ar->ath6kl_wq =create_singlethread_workqueue ("ath6kl" );if (!ar->ath6kl_wq)
@@ -1436,6 +1531,11 @@ int ath6kl_core_init(struct ath6kl *ar)if (ret) goto err_wq; +/* +* Turn on power to get hardware (target) version and leave power +* on delibrately as we will boot the hardware anyway within few +* seconds. +*/ ret =ath6kl_hif_power_on (ar);if (ret) goto err_bmi_cleanup;
@@ -1452,10 +1552,6 @@ int ath6kl_core_init(struct ath6kl *ar)if (ret) goto err_power_off; - ret =ath6kl_configure_target (ar); -if (ret) - goto err_power_off; - ar->htc_target =ath6kl_htc_create (ar);if (!ar->htc_target) {
@@ -1469,16 +1565,6 @@ int ath6kl_core_init(struct ath6kl *ar)/* FIXME: we should free all firmwares in the error cases below */ - ret =ath6kl_init_upload (ar); -if (ret) - goto err_htc_cleanup; - -/* Do we need to finish the BMI phase */ -if (ath6kl_bmi_done (ar)) { - ret = -EIO ; - goto err_htc_cleanup; - } -/* Indicate that WMI is enabled (although not ready yet) */ set_bit (WMI_ENABLED , &ar->flag); ar->wmi =ath6kl_wmi_init (ar);
@@ -1522,21 +1608,6 @@ int ath6kl_core_init(struct ath6kl *ar)ath6kl_dbg (ATH6KL_DBG_TRC ,"%s: name=%s dev=0x%p, ar=0x%p\n" , __func__, ndev->name, ndev, ar); -/* -* The reason we have to wait for the target here is that the -* driver layer has to init BMI in order to set the host block -* size. -*/ -if (ath6kl_htc_wait_target (ar->htc_target)) { - ret = -EIO ; - goto err_if_deinit; - } - -if (ath6kl_init_service_ep (ar)) { - ret = -EIO ; - goto err_cleanup_scatter; - } -/* setup access class priority mappings */ ar->ac_stream_pri_map[WMM_AC_BK ] =0 ;/* lowest */ ar->ac_stream_pri_map[WMM_AC_BE ] =1 ;
@@ -1550,54 +1621,17 @@ int ath6kl_core_init(struct ath6kl *ar)/* allocate some buffers that handle larger AMSDU frames */ ath6kl_refill_amsdu_rxbufs (ar,ATH6KL_MAX_AMSDU_RX_BUFFERS ); -/* setup credit distribution */ -ath6kl_credit_setup (ar->htc_target, &ar->credit_state_info); -ath6kl_cookie_init (ar); -/* start HTC */ - ret =ath6kl_htc_start (ar->htc_target); -if (ret) { -ath6kl_cookie_cleanup (ar); - goto err_rxbuf_cleanup; - } - -/* Wait for Wmi event to be ready */ - timeleft =wait_event_interruptible_timeout (ar->event_wq, -test_bit (WMI_READY , - &ar->flag), -WMI_TIMEOUT ); - -ath6kl_dbg (ATH6KL_DBG_BOOT ,"firmware booted\n" ); - -if (ar->version.abi_ver !=ATH6KL_ABI_VERSION ) { -ath6kl_err ("abi version mismatch: host(0x%x), target(0x%x)\n" , -ATH6KL_ABI_VERSION , ar->version.abi_ver); - ret = -EIO ; - goto err_htc_stop; - } - -if (!timeleft ||signal_pending (current)) { -ath6kl_err ("wmi is not ready or wait was interrupted\n" ); - ret = -EIO ; - goto err_htc_stop; - } - -ath6kl_dbg (ATH6KL_DBG_TRC ,"%s: wmi is ready\n" , __func__); - -/* communicate the wmi protocol verision to the target */ -if ((ath6kl_set_host_app_area (ar)) !=0 ) -ath6kl_err ("unable to set the host app area\n" ); - ar->conf_flags =ATH6KL_CONF_IGNORE_ERP_BARKER |ATH6KL_CONF_ENABLE_11N |ATH6KL_CONF_ENABLE_TX_BURST ; ar->wiphy->flags |=WIPHY_FLAG_SUPPORTS_FW_ROAM ; -for (i =0 ; i <MAX_NUM_VIF ; i++) { - ret =ath6kl_target_config_wlan_params (ar, i); -if (ret) - goto err_htc_stop; + ret =ath6kl_hw_start (ar); +if (ret) { +ath6kl_err ("Failed to boot hardware: %d\n" , ret); + goto err_rxbuf_cleanup; }/*
@@ -1608,14 +1642,9 @@ int ath6kl_core_init(struct ath6kl *ar)return ret; -err_htc_stop: -ath6kl_htc_stop (ar->htc_target); err_rxbuf_cleanup:ath6kl_htc_flush_rx_buf (ar->htc_target);ath6kl_cleanup_amsdu_rxbufs (ar); -err_cleanup_scatter: -ath6kl_hif_cleanup_scatter (ar); -err_if_deinit:rtnl_lock ();ath6kl_deinit_if_data (netdev_priv (ndev));rtnl_unlock ();
PATCH 7/10 ath6kl: remove useless cleanup call from ath6kl_bmi_done()
In reply to Kalle Valoaht6kl core code will call the cleanup function when the device is removed.
--- drivers/net/wireless/ath/ath6kl/bmi.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/bmi.c +0 -2
@@ -196,8 +196,6 @@ int ath6kl_bmi_done(struct ath6kl *ar)return ret; } -ath6kl_bmi_cleanup (ar); -return 0 ; }
PATCH 8/10 ath6kl: add a timeout to ath6kl_hif_intr_bh_handler()
In reply to Kalle ValoIt's possible to busyloop forever in ath6kl_hif_intr_bh_handler(). Add a check that it lasts only one second.
--- drivers/net/wireless/ath/ath6kl/hif.c | 4 +++- drivers/net/wireless/ath/ath6kl/hif.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletions(-)
drivers/net/wireless/ath/ath6kl/hif.c +3 -1
@@ -485,6 +485,7 @@ out:int ath6kl_hif_intr_bh_handler (struct ath6kl *ar) {struct ath6kl_device *dev = ar->htc_target->dev; +unsigned long timeout;int status =0 ;bool done = false;
@@ -498,7 +499,8 @@ int ath6kl_hif_intr_bh_handler(struct ath6kl *ar)* IRQ processing is synchronous, interrupt status registers can be * re-read. */ -while (!done) { + timeout = jiffies +msecs_to_jiffies (ATH6KL_HIF_COMMUNICATION_TIMEOUT ); +while (time_before (jiffies, timeout) && !done) { status =proc_pending_irqs (dev, &done);if (status)break ;
drivers/net/wireless/ath/ath6kl/hif.h +2 -0
@@ -69,6 +69,8 @@#define ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER (16 * 1024)#define ATH6KL_SCATTER_REQS 4 +#define ATH6KL_HIF_COMMUNICATION_TIMEOUT 1000 +struct bus_request {struct list_head list;
PATCH 9/10 ath6kl: create ath6kl_htc_reset()
In reply to Kalle ValoWhen rebooting hardware we need to reset the htc state in ath6kl_htc_stop().
--- drivers/net/wireless/ath/ath6kl/htc.c | 91 ++++++++++++++++++--------------- 1 files changed, 49 insertions(+), 42 deletions(-)
drivers/net/wireless/ath/ath6kl/htc.c +49 -42
@@ -2656,6 +2656,44 @@ int ath6kl_htc_start(struct htc_target *target)return status; } +static int ath6kl_htc_reset (struct htc_target *target) +{ +u32 block_size, ctrl_bufsz; +struct htc_packet *packet; +int i; + +reset_ep_state (target); + + block_size = target->dev->ar->mbox_info.block_size; + + ctrl_bufsz = (block_size >HTC_MAX_CTRL_MSG_LEN ) ? + (block_size +HTC_HDR_LENGTH ) : + (HTC_MAX_CTRL_MSG_LEN +HTC_HDR_LENGTH ); + +for (i =0 ; i <NUM_CONTROL_BUFFERS ; i++) { + packet =kzalloc (sizeof (*packet),GFP_KERNEL ); +if (!packet) +return -ENOMEM ; + + packet->buf_start =kzalloc (ctrl_bufsz,GFP_KERNEL ); +if (!packet->buf_start) { +kfree (packet); +return -ENOMEM ; + } + + packet->buf_len = ctrl_bufsz; +if (i <NUM_CONTROL_RX_BUFFERS ) { + packet->act_len =0 ; + packet->buf = packet->buf_start; + packet->endpoint =ENDPOINT_0 ; +list_add_tail (&packet->list, &target->free_ctrl_rxbuf); + }else +list_add_tail (&packet->list, &target->free_ctrl_txbuf); + } + +return 0 ; +} +/* htc_stop: stop interrupt reception, and flush all queued buffers */ void ath6kl_htc_stop (struct htc_target *target) {
@@ -2674,15 +2712,13 @@ void ath6kl_htc_stop(struct htc_target *target)ath6kl_htc_flush_rx_buf (target); -reset_ep_state (target); +ath6kl_htc_reset (target); }void *ath6kl_htc_create (struct ath6kl *ar) {struct htc_target *target =NULL ; -struct htc_packet *packet; -int status =0 , i =0 ; -u32 block_size, ctrl_bufsz; +int status =0 ; target =kzalloc (sizeof (*target),GFP_KERNEL );if (!target) {
@@ -2694,7 +2730,7 @@ void *ath6kl_htc_create(struct ath6kl *ar)if (!target->dev) {ath6kl_err ("unable to allocate memory\n" ); status = -ENOMEM ; - goto fail_create_htc; + goto err_htc_cleanup; }spin_lock_init (&target->htc_lock);
@@ -2709,49 +2745,20 @@ void *ath6kl_htc_create(struct ath6kl *ar) target->dev->htc_cnxt = target; target->ep_waiting =ENDPOINT_MAX ; -reset_ep_state (target); - status =ath6kl_hif_setup (target->dev); -if (status) - goto fail_create_htc; - - block_size = ar->mbox_info.block_size; - - ctrl_bufsz = (block_size >HTC_MAX_CTRL_MSG_LEN ) ? - (block_size +HTC_HDR_LENGTH ) : - (HTC_MAX_CTRL_MSG_LEN +HTC_HDR_LENGTH ); + goto err_htc_cleanup; -for (i =0 ; i <NUM_CONTROL_BUFFERS ; i++) { - packet =kzalloc (sizeof (*packet),GFP_KERNEL ); -if (!packet) -break ; - - packet->buf_start =kzalloc (ctrl_bufsz,GFP_KERNEL ); -if (!packet->buf_start) { -kfree (packet); -break ; - } + status =ath6kl_htc_reset (target); +if (status) + goto err_htc_cleanup; - packet->buf_len = ctrl_bufsz; -if (i <NUM_CONTROL_RX_BUFFERS ) { - packet->act_len =0 ; - packet->buf = packet->buf_start; - packet->endpoint =ENDPOINT_0 ; -list_add_tail (&packet->list, &target->free_ctrl_rxbuf); - }else -list_add_tail (&packet->list, &target->free_ctrl_txbuf); - } +return target; -fail_create_htc: -if (i !=NUM_CONTROL_BUFFERS || status) { -if (target) { -ath6kl_htc_cleanup (target); - target =NULL ; - } - } +err_htc_cleanup: +ath6kl_htc_cleanup (target); -return target; +return NULL ; }/* cleanup the HTC instance */
PATCH 10/10 ath6kl: don't print an error for canceled packets
In reply to Kalle Valoath6kl_tx_complete() was printing an error when packet was canceled. That causes unnecessary errors when hardware is powered off.
Also change the error to a warning and cleanup the message.
--- drivers/net/wireless/ath/ath6kl/txrx.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/txrx.c +3 -2
@@ -606,8 +606,9 @@ void ath6kl_tx_complete(void *context, struct list_head *packet_queue) vif->net_stats.tx_errors++; -if (status != -ENOSPC ) -ath6kl_err ("tx error, status: 0x%x\n" , status); +if (status != -ENOSPC && status != -ECANCELED ) +ath6kl_warn ("tx complete error: %d\n" , status); + ath6kl_dbg(ATH6KL_DBG_WLAN_TX, "%s: skb=0x%p data=0x%p len=0x%x eid=%d %s\n", __func__, skb, packet->buf, packet->act_len,
Quoted 6 lines · Kalle Valo
Use of
cfg80211_scan_requestis not valid after callingcfg80211_scan_done()butath6kl_cfg80211_scan_complete_event()was doing exactly that. Change the function to callcfg80211_scan_done()last.This was found during code review, I didn't see any visible problems due to this bug.
All 10 applied.
Kalle