ath10k: pci cleanup
v2 cover ath10k: pci cleanup
Small PCI related code cleanup. Depends on Michal's CE clean patchset.
v2:
o remove unnecessary cast in patch 3 (from Gabor)
---
Kalle Valo (7):
ath10k: pci: make host_ce_config_wlan[] more readable
ath10k: make target_ce_config_wlan more readable
ath10k: remove void pointer from struct ath10k_pci_compl
ath10k: convert ath10k_pci_reg_read/write32() to take struct ath10k
ath10k: clean up ath10k_ce_completed_send_next_nolock()
ath10k: convert ath10k_pci_wake() to return
ath10k: simplify ath10k_ce_init() wake up handling
drivers/net/wireless/ath/ath10k/ce.c | 98 ++++++++++------ drivers/net/wireless/ath/ath10k/pci.c | 208 ++++++++++++++++++++++++--------- drivers/net/wireless/ath/ath10k/pci.h | 22 ++- 3 files changed, 227 insertions(+), 101 deletions(-)
PATCH v2 1/7 ath10k: pci: make host_ce_config_wlan[] more readable
It's much more readable if struct entries in host_ce_config_wlan are explicitly set.
--- drivers/net/wireless/ath/ath10k/pci.c | 81 ++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 18 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +63 -18
@@ -58,24 +58,69 @@ static int ath10k_pci_start_intr(struct ath10k *ar);static void ath10k_pci_stop_intr (struct ath10k *ar);static const struct ce_attr host_ce_config_wlan[] = { -/* host->target HTC control and raw streams */ - {/* CE0 */ CE_ATTR_FLAGS ,16 ,256 ,0 }, -/* could be moved to share CE3 */ -/* target->host HTT + HTC control */ - {/* CE1 */ CE_ATTR_FLAGS ,0 ,512 ,512 }, -/* target->host WMI */ - {/* CE2 */ CE_ATTR_FLAGS ,0 ,2048 ,32 }, -/* host->target WMI */ - {/* CE3 */ CE_ATTR_FLAGS ,32 ,2048 ,0 }, -/* host->target HTT */ - {/* CE4 */ CE_ATTR_FLAGS |CE_ATTR_DIS_INTR , -CE_HTT_H2T_MSG_SRC_NENTRIES ,256 ,0 }, -/* unused */ - {/* CE5 */ CE_ATTR_FLAGS ,0 ,0 ,0 }, -/* Target autonomous hif_memcpy */ - {/* CE6 */ CE_ATTR_FLAGS ,0 ,0 ,0 }, -/* ce_diag, the Diagnostic Window */ - {/* CE7 */ CE_ATTR_FLAGS ,2 ,DIAG_TRANSFER_LIMIT ,2 }, +/* CE0: host->target HTC control and raw streams */ + { + .flags =CE_ATTR_FLAGS , + .src_nentries =16 , + .src_sz_max =256 , + .dest_nentries =0 , + }, + +/* CE1: target->host HTT + HTC control */ + { + .flags =CE_ATTR_FLAGS , + .src_nentries =0 , + .src_sz_max =512 , + .dest_nentries =512 , + }, + +/* CE2: target->host WMI */ + { + .flags =CE_ATTR_FLAGS , + .src_nentries =0 , + .src_sz_max =2048 , + .dest_nentries =32 , + }, + +/* CE3: host->target WMI */ + { + .flags =CE_ATTR_FLAGS , + .src_nentries =32 , + .src_sz_max =2048 , + .dest_nentries =0 , + }, + +/* CE4: host->target HTT */ + { + .flags =CE_ATTR_FLAGS |CE_ATTR_DIS_INTR , + .src_nentries =CE_HTT_H2T_MSG_SRC_NENTRIES , + .src_sz_max =256 , + .dest_nentries =0 , + }, + +/* CE5: unused */ + { + .flags =CE_ATTR_FLAGS , + .src_nentries =0 , + .src_sz_max =0 , + .dest_nentries =0 , + }, + +/* CE6: target autonomous hif_memcpy */ + { + .flags =CE_ATTR_FLAGS , + .src_nentries =0 , + .src_sz_max =0 , + .dest_nentries =0 , + }, + +/* CE7: ce_diag, the Diagnostic Window */ + { + .flags =CE_ATTR_FLAGS , + .src_nentries =2 , + .src_sz_max =DIAG_TRANSFER_LIMIT , + .dest_nentries =2 , + }, };/* Target firmware's Copy Engine configuration. */
PATCH v2 2/7 ath10k: make target_ce_config_wlan more readable
In reply to Kalle ValoIt's easier to read t if the field names are visible.
--- drivers/net/wireless/ath/ath10k/pci.c | 85 ++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 14 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +71 -14
@@ -125,21 +125,78 @@ static const struct ce_attr host_ce_config_wlan[] = {/* Target firmware's Copy Engine configuration. */ static const struct ce_pipe_config target_ce_config_wlan[] = { -/* host->target HTC control and raw streams */ - {/* CE0 */ 0 ,PIPEDIR_OUT ,32 ,256 ,CE_ATTR_FLAGS ,0 ,}, -/* target->host HTT + HTC control */ - {/* CE1 */ 1 ,PIPEDIR_IN ,32 ,512 ,CE_ATTR_FLAGS ,0 ,}, -/* target->host WMI */ - {/* CE2 */ 2 ,PIPEDIR_IN ,32 ,2048 ,CE_ATTR_FLAGS ,0 ,}, -/* host->target WMI */ - {/* CE3 */ 3 ,PIPEDIR_OUT ,32 ,2048 ,CE_ATTR_FLAGS ,0 ,}, -/* host->target HTT */ - {/* CE4 */ 4 ,PIPEDIR_OUT ,256 ,256 ,CE_ATTR_FLAGS ,0 ,}, +/* CE0: host->target HTC control and raw streams */ + { + .pipenum =0 , + .pipedir =PIPEDIR_OUT , + .nentries =32 , + .nbytes_max =256 , + .flags =CE_ATTR_FLAGS , + .reserved =0 , + }, + +/* CE1: target->host HTT + HTC control */ + { + .pipenum =1 , + .pipedir =PIPEDIR_IN , + .nentries =32 , + .nbytes_max =512 , + .flags =CE_ATTR_FLAGS , + .reserved =0 , + }, + +/* CE2: target->host WMI */ + { + .pipenum =2 , + .pipedir =PIPEDIR_IN , + .nentries =32 , + .nbytes_max =2048 , + .flags =CE_ATTR_FLAGS , + .reserved =0 , + }, + +/* CE3: host->target WMI */ + { + .pipenum =3 , + .pipedir =PIPEDIR_OUT , + .nentries =32 , + .nbytes_max =2048 , + .flags =CE_ATTR_FLAGS , + .reserved =0 , + }, + +/* CE4: host->target HTT */ + { + .pipenum =4 , + .pipedir =PIPEDIR_OUT , + .nentries =256 , + .nbytes_max =256 , + .flags =CE_ATTR_FLAGS , + .reserved =0 , + }, +/* NB: 50% of src nentries, since tx has 2 frags */ -/* unused */ - {/* CE5 */ 5 ,PIPEDIR_OUT ,32 ,2048 ,CE_ATTR_FLAGS ,0 ,}, -/* Reserved for target autonomous hif_memcpy */ - {/* CE6 */ 6 ,PIPEDIR_INOUT ,32 ,4096 ,CE_ATTR_FLAGS ,0 ,}, + +/* CE5: unused */ + { + .pipenum =5 , + .pipedir =PIPEDIR_OUT , + .nentries =32 , + .nbytes_max =2048 , + .flags =CE_ATTR_FLAGS , + .reserved =0 , + }, + +/* CE6: Reserved for target autonomous hif_memcpy */ + { + .pipenum =6 , + .pipedir =PIPEDIR_INOUT , + .nentries =32 , + .nbytes_max =4096 , + .flags =CE_ATTR_FLAGS , + .reserved =0 , + }, +/* CE7 used only by Host */ };
PATCH v2 3/7 ath10k: remove void pointer from struct ath10k_pci_compl
In reply to Kalle ValoVoid pointers are bad, mmkay.
No functional changes.
--- drivers/net/wireless/ath/ath10k/pci.c | 12 ++++++------ drivers/net/wireless/ath/ath10k/pci.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +6 -6
@@ -643,7 +643,7 @@ static void ath10k_pci_ce_send_done(struct ath10k_ce_pipe *ce_state, compl->state =ATH10K_PCI_COMPL_SEND ; compl->ce_state = ce_state; compl->pipe_info = pipe_info; - compl->transfer_context = transfer_context; + compl->skb = transfer_context; compl->nbytes = nbytes; compl->transfer_id = transfer_id; compl->flags =0 ;
@@ -693,7 +693,7 @@ static void ath10k_pci_ce_recv_data(struct ath10k_ce_pipe *ce_state, compl->state =ATH10K_PCI_COMPL_RECV ; compl->ce_state = ce_state; compl->pipe_info = pipe_info; - compl->transfer_context = transfer_context; + compl->skb = transfer_context; compl->nbytes = nbytes; compl->transfer_id = transfer_id; compl->flags = flags;
@@ -939,7 +939,7 @@ static void ath10k_pci_stop_ce(struct ath10k *ar)* their associated resources */ spin_lock_bh (&ar_pci->compl_lock);list_for_each_entry (compl, &ar_pci->compl_process, list) { - skb = (struct sk_buff *)compl->transfer_context; + skb = compl->skb;ATH10K_SKB_CB (skb)->is_aborted = true; }spin_unlock_bh (&ar_pci->compl_lock);
@@ -960,7 +960,7 @@ static void ath10k_pci_cleanup_ce(struct ath10k *ar)list_for_each_entry_safe (compl, tmp, &ar_pci->compl_process, list) {list_del (&compl->list); - netbuf = (struct sk_buff *)compl->transfer_context; + netbuf = compl->skb;dev_kfree_skb_any (netbuf);kfree (compl); }
@@ -1014,7 +1014,7 @@ static void ath10k_pci_process_ce(struct ath10k *ar)switch (compl->state) {case ATH10K_PCI_COMPL_SEND : cb->tx_completion (ar, - compl->transfer_context, + compl->skb, compl->transfer_id); send_done =1 ;break ;
@@ -1026,7 +1026,7 @@ static void ath10k_pci_process_ce(struct ath10k *ar)break ; } - skb = (struct sk_buff *)compl->transfer_context; + skb = compl->skb; nbytes = compl->nbytes; ath10k_dbg(ATH10K_DBG_PCI,
drivers/net/wireless/ath/ath10k/pci.h +1 -1
@@ -54,7 +54,7 @@ struct ath10k_pci_compl {enum ath10k_pci_compl_state state;struct ath10k_ce_pipe *ce_state;struct ath10k_pci_pipe *pipe_info; -void *transfer_context; +struct sk_buff *skb;unsigned int nbytes;unsigned int transfer_id;unsigned int flags;
PATCH v2 4/7 ath10k: convert ath10k_pci_reg_read/write32() to take struct ath10k
In reply to Kalle ValoThis is consistent with all other functions.
--- drivers/net/wireless/ath/ath10k/pci.c | 19 +++++++------------ drivers/net/wireless/ath/ath10k/pci.h | 12 ++++++++---- 2 files changed, 15 insertions(+), 16 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +7 -12
@@ -2323,18 +2323,13 @@ static int ath10k_pci_reset_target(struct ath10k *ar)static void ath10k_pci_device_reset (struct ath10k *ar) { -struct ath10k_pci *ar_pci =ath10k_pci_priv (ar); -void __iomem *mem = ar_pci->mem;int i;u32 val;if (!SOC_GLOBAL_RESET_ADDRESS )return ; -if (!mem) -return ; - -ath10k_pci_reg_write32 (mem,PCIE_SOC_WAKE_ADDRESS , +ath10k_pci_reg_write32 (ar,PCIE_SOC_WAKE_ADDRESS ,PCIE_SOC_WAKE_V_MASK );for (i =0 ; i <ATH_PCI_RESET_WAIT_MAX ; i++) {if (ath10k_pci_target_is_awake (ar))
@@ -2343,12 +2338,12 @@ static void ath10k_pci_device_reset(struct ath10k *ar) }/* Put Target, including PCIe, into RESET. */ - val =ath10k_pci_reg_read32 (mem,SOC_GLOBAL_RESET_ADDRESS ); + val =ath10k_pci_reg_read32 (ar,SOC_GLOBAL_RESET_ADDRESS ); val |=1 ; -ath10k_pci_reg_write32 (mem,SOC_GLOBAL_RESET_ADDRESS , val); +ath10k_pci_reg_write32 (ar,SOC_GLOBAL_RESET_ADDRESS , val);for (i =0 ; i <ATH_PCI_RESET_WAIT_MAX ; i++) { -if (ath10k_pci_reg_read32 (mem,RTC_STATE_ADDRESS ) & +if (ath10k_pci_reg_read32 (ar,RTC_STATE_ADDRESS ) &RTC_STATE_COLD_RESET_MASK )break ;msleep (1 );
@@ -2356,16 +2351,16 @@ static void ath10k_pci_device_reset(struct ath10k *ar)/* Pull Target, including PCIe, out of RESET. */ val &= ~1 ; -ath10k_pci_reg_write32 (mem,SOC_GLOBAL_RESET_ADDRESS , val); +ath10k_pci_reg_write32 (ar,SOC_GLOBAL_RESET_ADDRESS , val);for (i =0 ; i <ATH_PCI_RESET_WAIT_MAX ; i++) { -if (!(ath10k_pci_reg_read32 (mem,RTC_STATE_ADDRESS ) & +if (!(ath10k_pci_reg_read32 (ar,RTC_STATE_ADDRESS ) &RTC_STATE_COLD_RESET_MASK ))break ;msleep (1 ); } -ath10k_pci_reg_write32 (mem,PCIE_SOC_WAKE_ADDRESS ,PCIE_SOC_WAKE_RESET ); +ath10k_pci_reg_write32 (ar,PCIE_SOC_WAKE_ADDRESS ,PCIE_SOC_WAKE_RESET ); }static void ath10k_pci_dump_features (struct ath10k_pci *ar_pci)
drivers/net/wireless/ath/ath10k/pci.h +8 -4
@@ -240,14 +240,18 @@ static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)return ar->hif.priv; } -static inline u32 ath10k_pci_reg_read32 (void __iomem *mem,u32 addr) +static inline u32 ath10k_pci_reg_read32 (struct ath10k *ar,u32 addr) { -return ioread32 (mem +PCIE_LOCAL_BASE_ADDRESS + addr); +struct ath10k_pci *ar_pci =ath10k_pci_priv (ar); + +return ioread32 (ar_pci->mem +PCIE_LOCAL_BASE_ADDRESS + addr); } -static inline void ath10k_pci_reg_write32 (void __iomem *mem,u32 addr,u32 val) +static inline void ath10k_pci_reg_write32 (struct ath10k *ar,u32 addr,u32 val) { -iowrite32 (val, mem +PCIE_LOCAL_BASE_ADDRESS + addr); +struct ath10k_pci *ar_pci =ath10k_pci_priv (ar); + +iowrite32 (val, ar_pci->mem +PCIE_LOCAL_BASE_ADDRESS + addr); }#define ATH_PCI_RESET_WAIT_MAX 10/* ms */
PATCH v2 5/7 ath10k: clean up ath10k_ce_completed_send_next_nolock()
In reply to Kalle ValoThe error handling was just weird, simplify it.
--- drivers/net/wireless/ath/ath10k/ce.c | 41 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +21 -20
@@ -594,8 +594,8 @@ static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,struct ath10k *ar = ce_state->ar;unsigned int nentries_mask = src_ring->nentries_mask;unsigned int sw_index = src_ring->sw_index; +struct ce_desc *sdesc, *sbase;unsigned int read_index; -int ret = -EIO ;if (src_ring->hw_index == sw_index) {/*
@@ -611,32 +611,33 @@ static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state, src_ring->hw_index &= nentries_mask;ath10k_pci_sleep (ar); } + read_index = src_ring->hw_index; -if ((read_index != sw_index) && (read_index !=0xffffffff )) { -struct ce_desc *sbase = src_ring->shadow_base; -struct ce_desc *sdesc =CE_SRC_RING_TO_DESC (sbase, sw_index); +if ((read_index == sw_index) || (read_index ==0xffffffff )) +return -EIO ; -/* Return data from completed source descriptor */ - *bufferp =__le32_to_cpu (sdesc->addr); - *nbytesp =__le16_to_cpu (sdesc->nbytes); - *transfer_idp =MS (__le16_to_cpu (sdesc->flags), -CE_DESC_FLAGS_META_DATA ); + sbase = src_ring->shadow_base; + sdesc =CE_SRC_RING_TO_DESC (sbase, sw_index); -if (per_transfer_contextp) - *per_transfer_contextp = - src_ring->per_transfer_context[sw_index]; +/* Return data from completed source descriptor */ + *bufferp =__le32_to_cpu (sdesc->addr); + *nbytesp =__le16_to_cpu (sdesc->nbytes); + *transfer_idp =MS (__le16_to_cpu (sdesc->flags), +CE_DESC_FLAGS_META_DATA ); -/* sanity */ - src_ring->per_transfer_context[sw_index] =NULL ; +if (per_transfer_contextp) + *per_transfer_contextp = + src_ring->per_transfer_context[sw_index]; -/* Update sw_index */ - sw_index =CE_RING_IDX_INCR (nentries_mask, sw_index); - src_ring->sw_index = sw_index; - ret =0 ; - } +/* sanity */ + src_ring->per_transfer_context[sw_index] =NULL ; -return ret; +/* Update sw_index */ + sw_index =CE_RING_IDX_INCR (nentries_mask, sw_index); + src_ring->sw_index = sw_index; + +return 0 ; }/* NB: Modeled after ath10k_ce_completed_send_next */
PATCH v2 6/7 ath10k: convert ath10k_pci_wake() to return
In reply to Kalle ValoWe should not try to access hw if wakeup fails so add proper error checking for that. Also add the timeout lenght to the warning message.
--- drivers/net/wireless/ath/ath10k/ce.c | 43 ++++++++++++++++++++++++++------- drivers/net/wireless/ath/ath10k/pci.c | 11 +++++--- drivers/net/wireless/ath/ath10k/pci.h | 8 ++++-- 3 files changed, 45 insertions(+), 17 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +34 -9
@@ -277,7 +277,9 @@ static int ath10k_ce_send_nolock(struct ath10k_ce_pipe *ce_state,ath10k_warn ("%s: send more we can (nbytes: %d, max: %d)\n" , __func__, nbytes, ce_state->src_sz_max); -ath10k_pci_wake (ar); + ret =ath10k_pci_wake (ar); +if (ret) +return ret;if (unlikely (CE_RING_DELTA (nentries_mask, write_index, sw_index -1 ) <=0 )) {
@@ -419,7 +421,9 @@ int ath10k_ce_recv_buf_enqueue(struct ath10k_ce_pipe *ce_state, write_index = dest_ring->write_index; sw_index = dest_ring->sw_index; -ath10k_pci_wake (ar); + ret =ath10k_pci_wake (ar); +if (ret) + goto out;if (CE_RING_DELTA (nentries_mask, write_index, sw_index -1 ) >0 ) {struct ce_desc *base = dest_ring->base_addr_owner_space;
@@ -441,6 +445,8 @@ int ath10k_ce_recv_buf_enqueue(struct ath10k_ce_pipe *ce_state, ret = -EIO ; }ath10k_pci_sleep (ar); + +out:spin_unlock_bh (&ar_pci->ce_lock);return ret;
@@ -596,6 +602,7 @@ static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,unsigned int sw_index = src_ring->sw_index;struct ce_desc *sdesc, *sbase;unsigned int read_index; +int ret;if (src_ring->hw_index == sw_index) {/*
@@ -605,10 +612,15 @@ static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,* the SW has really caught up to the HW, or if the cached * value of the HW index has become stale. */ -ath10k_pci_wake (ar); + + ret =ath10k_pci_wake (ar); +if (ret) +return ret; + src_ring->hw_index =ath10k_ce_src_ring_read_index_get (ar, ctrl_addr); src_ring->hw_index &= nentries_mask; +ath10k_pci_sleep (ar); }
@@ -735,8 +747,12 @@ void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id)unsigned int nbytes;unsigned int id;unsigned int flags; +int ret; + + ret =ath10k_pci_wake (ar); +if (ret) +return ; -ath10k_pci_wake (ar);spin_lock_bh (&ar_pci->ce_lock);/* Clear the copy-complete interrupts that will be handled here. */
@@ -795,10 +811,13 @@ void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id)void ath10k_ce_per_engine_service_any (struct ath10k *ar) {struct ath10k_pci *ar_pci =ath10k_pci_priv (ar); -int ce_id; +int ce_id, ret;u32 intr_summary; -ath10k_pci_wake (ar); + ret =ath10k_pci_wake (ar); +if (ret) +return ; + intr_summary =CE_INTERRUPT_SUMMARY (ar);for (ce_id =0 ; intr_summary && (ce_id < ar_pci->ce_count); ce_id++) {
@@ -826,8 +845,11 @@ static void ath10k_ce_per_engine_handler_adjust(struct ath10k_ce_pipe *ce_state, {u32 ctrl_addr = ce_state->ctrl_addr;struct ath10k *ar = ce_state->ar; +int ret; -ath10k_pci_wake (ar); + ret =ath10k_pci_wake (ar); +if (ret) +return ;if ((!disable_copy_compl_intr) && (ce_state->send_cb || ce_state->recv_cb))
@@ -843,9 +865,12 @@ static void ath10k_ce_per_engine_handler_adjust(struct ath10k_ce_pipe *ce_state,void ath10k_ce_disable_interrupts (struct ath10k *ar) {struct ath10k_pci *ar_pci =ath10k_pci_priv (ar); -int ce_id; +int ce_id, ret; + + ret =ath10k_pci_wake (ar); +if (ret) +return ; -ath10k_pci_wake (ar);for (ce_id =0 ; ce_id < ar_pci->ce_count; ce_id++) {struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];u32 ctrl_addr = ce_state->ctrl_addr;
drivers/net/wireless/ath/ath10k/pci.c +6 -5
@@ -537,7 +537,7 @@ static void ath10k_pci_wait(struct ath10k *ar)ath10k_warn ("Unable to wakeup target\n" ); } -void ath10k_do_pci_wake (struct ath10k *ar) +int ath10k_do_pci_wake (struct ath10k *ar) {struct ath10k_pci *ar_pci =ath10k_pci_priv (ar);void __iomem *pci_addr = ar_pci->mem;
@@ -553,18 +553,19 @@ void ath10k_do_pci_wake(struct ath10k *ar)atomic_inc (&ar_pci->keep_awake_count);if (ar_pci->verified_awake) -return ; +return 0 ;for (;;) {if (ath10k_pci_target_is_awake (ar)) { ar_pci->verified_awake = true; -break ; +return 0 ; }if (tot_delay >PCIE_WAKE_TIMEOUT ) { -ath10k_warn ("target takes too long to wake up (awake count %d)\n" , +ath10k_warn ("target took longer %d us to wake up (awake count %d)\n" , +PCIE_WAKE_TIMEOUT ,atomic_read (&ar_pci->keep_awake_count)); -break ; +return -ETIMEDOUT ; }udelay (curr_delay);
drivers/net/wireless/ath/ath10k/pci.h +5 -3
@@ -321,15 +321,17 @@ static inline u32 ath10k_pci_read32(struct ath10k *ar, u32 offset)return ioread32 (ar_pci->mem + offset); } -void ath10k_do_pci_wake (struct ath10k *ar); +int ath10k_do_pci_wake (struct ath10k *ar);void ath10k_do_pci_sleep (struct ath10k *ar); -static inline void ath10k_pci_wake (struct ath10k *ar) +static inline int ath10k_pci_wake (struct ath10k *ar) {struct ath10k_pci *ar_pci =ath10k_pci_priv (ar);if (test_bit (ATH10K_PCI_FEATURE_SOC_POWER_SAVE , ar_pci->features)) -ath10k_do_pci_wake (ar); +return ath10k_do_pci_wake (ar); + +return 0 ; }static inline void ath10k_pci_sleep (struct ath10k *ar)
PATCH v2 7/7 ath10k: simplify ath10k_ce_init() wake up handling
In reply to Kalle Valoath10k_ce_init() and the functions it calls wakeup the chip multiple times. Simplify that to call ath10k_pci_wake() only once. This also makes it easier to add error handling when wakeup fails.
--- drivers/net/wireless/ath/ath10k/ce.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +5 -9
@@ -946,7 +946,6 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar, src_ring->nentries = nentries; src_ring->nentries_mask = nentries -1 ; -ath10k_pci_wake (ar); src_ring->sw_index =ath10k_ce_src_ring_read_index_get (ar, ctrl_addr); src_ring->sw_index &= src_ring->nentries_mask; src_ring->hw_index = src_ring->sw_index;
@@ -954,7 +953,6 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar, src_ring->write_index =ath10k_ce_src_ring_write_index_get (ar, ctrl_addr); src_ring->write_index &= src_ring->nentries_mask; -ath10k_pci_sleep (ar); src_ring->per_transfer_context = (void **)ptr;
@@ -1004,7 +1002,6 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar, src_ring->shadow_base_unaligned, CE_DESC_RING_ALIGN); -ath10k_pci_wake (ar);ath10k_ce_src_ring_base_addr_set (ar, ctrl_addr, src_ring->base_addr_ce_space);ath10k_ce_src_ring_size_set (ar, ctrl_addr, nentries);
@@ -1012,7 +1009,6 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,ath10k_ce_src_ring_byte_swap_set (ar, ctrl_addr,0 );ath10k_ce_src_ring_lowmark_set (ar, ctrl_addr,0 );ath10k_ce_src_ring_highmark_set (ar, ctrl_addr, nentries); -ath10k_pci_sleep (ar);return 0 ; }
@@ -1049,13 +1045,11 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar, dest_ring->nentries = nentries; dest_ring->nentries_mask = nentries -1 ; -ath10k_pci_wake (ar); dest_ring->sw_index =ath10k_ce_dest_ring_read_index_get (ar, ctrl_addr); dest_ring->sw_index &= dest_ring->nentries_mask; dest_ring->write_index =ath10k_ce_dest_ring_write_index_get (ar, ctrl_addr); dest_ring->write_index &= dest_ring->nentries_mask; -ath10k_pci_sleep (ar); dest_ring->per_transfer_context = (void **)ptr;
@@ -1090,14 +1084,12 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar, dest_ring->base_addr_ce_space_unaligned, CE_DESC_RING_ALIGN); -ath10k_pci_wake (ar);ath10k_ce_dest_ring_base_addr_set (ar, ctrl_addr, dest_ring->base_addr_ce_space);ath10k_ce_dest_ring_size_set (ar, ctrl_addr, nentries);ath10k_ce_dest_ring_byte_swap_set (ar, ctrl_addr,0 );ath10k_ce_dest_ring_lowmark_set (ar, ctrl_addr,0 );ath10k_ce_dest_ring_highmark_set (ar, ctrl_addr, nentries); -ath10k_pci_sleep (ar);return 0 ; }
@@ -1138,6 +1130,10 @@ struct ath10k_ce_pipe *ath10k_ce_init(struct ath10k *ar,u32 ctrl_addr =ath10k_ce_base_address (ce_id);int ret; + ret =ath10k_pci_wake (ar); +if (ret) +return NULL ; + ce_state =ath10k_ce_init_state (ar, ce_id, attr);if (!ce_state) {ath10k_err ("Failed to initialize CE state for ID: %d\n" , ce_id);
@@ -1165,8 +1161,8 @@ struct ath10k_ce_pipe *ath10k_ce_init(struct ath10k *ar, }/* Enable CE error interrupts */ -ath10k_pci_wake (ar);ath10k_ce_error_intr_enable (ar, ctrl_addr); +ath10k_pci_sleep (ar);return ce_state;
Quoted 9 lines · Kalle Valo
Small PCI related code cleanup. Depends on Michal's CE clean patchset.
v2:
o remove unnecessary cast in patch 3 (from Gabor)
---
Quoted 8 lines
Kalle Valo (7):
ath10k: pci: make host_ce_config_wlan[] more readable
ath10k: maketarget_ce_config_wlanmore readable
ath10k: remove void pointer from structath10k_pci_compl
ath10k: convert ath10k_pci_reg_read/write32() to take struct ath10k
ath10k: clean upath10k_ce_completed_send_next_nolock()
ath10k: convertath10k_pci_wake()to return
ath10k: simplifyath10k_ce_init()wake up handling
All seven applied.
Signature · 1 line
Kalle Valo