Commit 39e4086a authored by Michal Kazior's avatar Michal Kazior Committed by Kalle Valo

ath10k: use inline ce_state structure

Simplifies memory managament of ce_state.
Signed-off-by: default avatarMichal Kazior <michal.kazior@tieto.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent e2951f7f
...@@ -727,7 +727,7 @@ int ath10k_ce_completed_send_next(struct ce_state *ce_state, ...@@ -727,7 +727,7 @@ int ath10k_ce_completed_send_next(struct ce_state *ce_state,
void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id) void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id)
{ {
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
struct ce_state *ce_state = ar_pci->ce_id_to_state[ce_id]; struct ce_state *ce_state = &ar_pci->ce_states[ce_id];
u32 ctrl_addr = ce_state->ctrl_addr; u32 ctrl_addr = ce_state->ctrl_addr;
void *transfer_context; void *transfer_context;
u32 buf; u32 buf;
...@@ -846,7 +846,7 @@ void ath10k_ce_disable_interrupts(struct ath10k *ar) ...@@ -846,7 +846,7 @@ void ath10k_ce_disable_interrupts(struct ath10k *ar)
ath10k_pci_wake(ar); ath10k_pci_wake(ar);
for (ce_id = 0; ce_id < ar_pci->ce_count; ce_id++) { for (ce_id = 0; ce_id < ar_pci->ce_count; ce_id++) {
struct ce_state *ce_state = ar_pci->ce_id_to_state[ce_id]; struct ce_state *ce_state = &ar_pci->ce_states[ce_id];
u32 ctrl_addr = ce_state->ctrl_addr; u32 ctrl_addr = ce_state->ctrl_addr;
ath10k_ce_copy_complete_intr_disable(ar, ctrl_addr); ath10k_ce_copy_complete_intr_disable(ar, ctrl_addr);
...@@ -1081,27 +1081,17 @@ static struct ce_state *ath10k_ce_init_state(struct ath10k *ar, ...@@ -1081,27 +1081,17 @@ static struct ce_state *ath10k_ce_init_state(struct ath10k *ar,
const struct ce_attr *attr) const struct ce_attr *attr)
{ {
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
struct ce_state *ce_state = NULL; struct ce_state *ce_state = &ar_pci->ce_states[ce_id];
u32 ctrl_addr = ath10k_ce_base_address(ce_id); u32 ctrl_addr = ath10k_ce_base_address(ce_id);
spin_lock_bh(&ar_pci->ce_lock); spin_lock_bh(&ar_pci->ce_lock);
if (!ar_pci->ce_id_to_state[ce_id]) { ce_state->ar = ar;
ce_state = kzalloc(sizeof(*ce_state), GFP_ATOMIC); ce_state->id = ce_id;
if (ce_state == NULL) { ce_state->ctrl_addr = ctrl_addr;
spin_unlock_bh(&ar_pci->ce_lock); ce_state->state = CE_RUNNING;
return NULL; ce_state->attr_flags = attr->flags;
} ce_state->src_sz_max = attr->src_sz_max;
ar_pci->ce_id_to_state[ce_id] = ce_state;
ce_state->ar = ar;
ce_state->id = ce_id;
ce_state->ctrl_addr = ctrl_addr;
ce_state->state = CE_RUNNING;
/* Save attribute flags */
ce_state->attr_flags = attr->flags;
ce_state->src_sz_max = attr->src_sz_max;
}
spin_unlock_bh(&ar_pci->ce_lock); spin_unlock_bh(&ar_pci->ce_lock);
...@@ -1159,13 +1149,9 @@ struct ce_state *ath10k_ce_init(struct ath10k *ar, ...@@ -1159,13 +1149,9 @@ struct ce_state *ath10k_ce_init(struct ath10k *ar,
void ath10k_ce_deinit(struct ce_state *ce_state) void ath10k_ce_deinit(struct ce_state *ce_state)
{ {
unsigned int ce_id = ce_state->id;
struct ath10k *ar = ce_state->ar; struct ath10k *ar = ce_state->ar;
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
ce_state->state = CE_UNUSED;
ar_pci->ce_id_to_state[ce_id] = NULL;
if (ce_state->src_ring) { if (ce_state->src_ring) {
kfree(ce_state->src_ring->shadow_base_unaligned); kfree(ce_state->src_ring->shadow_base_unaligned);
pci_free_consistent(ar_pci->pdev, pci_free_consistent(ar_pci->pdev,
...@@ -1186,5 +1172,8 @@ void ath10k_ce_deinit(struct ce_state *ce_state) ...@@ -1186,5 +1172,8 @@ void ath10k_ce_deinit(struct ce_state *ce_state)
ce_state->dest_ring->base_addr_ce_space); ce_state->dest_ring->base_addr_ce_space);
kfree(ce_state->dest_ring); kfree(ce_state->dest_ring);
} }
kfree(ce_state);
ce_state->state = CE_UNUSED;
ce_state->src_ring = NULL;
ce_state->dest_ring = NULL;
} }
...@@ -233,7 +233,7 @@ struct ath10k_pci { ...@@ -233,7 +233,7 @@ struct ath10k_pci {
spinlock_t ce_lock; spinlock_t ce_lock;
/* Map CE id to ce_state */ /* Map CE id to ce_state */
struct ce_state *ce_id_to_state[CE_COUNT_MAX]; struct ce_state ce_states[CE_COUNT_MAX];
}; };
static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar) static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment