Commit fc95d958 authored by Alex Elder's avatar Alex Elder Committed by David S. Miller

net: ipa: track committed transactions with an ID

Add a transaction ID field to track the first element in a channel's
transaction array that has been committed, but not yet passed to the
hardware.  Advance the ID when the hardware is notified via doorbell
that TREs from a transaction are ready for consumption.

Temporarily add warnings that verify that the first committed
transaction tracked by the ID matches the first element on the
committed list, both when committing and pending (at doorbell).

Remove the temporary warnings added by the previous commit.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 41e2a2c0
...@@ -85,6 +85,7 @@ struct gsi_trans_info { ...@@ -85,6 +85,7 @@ struct gsi_trans_info {
u16 free_id; /* first free trans in array */ u16 free_id; /* first free trans in array */
u16 allocated_id; /* first allocated transaction */ u16 allocated_id; /* first allocated transaction */
u16 committed_id; /* first committed transaction */
struct gsi_trans *trans; /* transaction array */ struct gsi_trans *trans; /* transaction array */
struct gsi_trans **map; /* TRE -> transaction map */ struct gsi_trans **map; /* TRE -> transaction map */
......
...@@ -252,20 +252,17 @@ static void gsi_trans_move_committed(struct gsi_trans *trans) ...@@ -252,20 +252,17 @@ static void gsi_trans_move_committed(struct gsi_trans *trans)
list_move_tail(&trans->links, &trans_info->committed); list_move_tail(&trans->links, &trans_info->committed);
trans = list_first_entry_or_null(&trans_info->alloc, trans = list_first_entry(&trans_info->committed,
struct gsi_trans, links); struct gsi_trans, links);
spin_unlock_bh(&trans_info->spinlock); spin_unlock_bh(&trans_info->spinlock);
/* This allocated transaction is now committed */ /* This allocated transaction is now committed */
trans_info->allocated_id++; trans_info->allocated_id++;
if (trans) { WARN_ON(trans_info->committed_id == trans_info->allocated_id);
trans_index = trans_info->allocated_id % channel->tre_count; trans_index = trans_info->committed_id % channel->tre_count;
WARN_ON(trans != &trans_info->trans[trans_index]); WARN_ON(trans != &trans_info->trans[trans_index]);
} else {
WARN_ON(trans_info->allocated_id != trans_info->free_id);
}
} }
/* Move transactions from the committed list to the pending list */ /* Move transactions from the committed list to the pending list */
...@@ -273,7 +270,9 @@ static void gsi_trans_move_pending(struct gsi_trans *trans) ...@@ -273,7 +270,9 @@ static void gsi_trans_move_pending(struct gsi_trans *trans)
{ {
struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id]; struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];
struct gsi_trans_info *trans_info = &channel->trans_info; struct gsi_trans_info *trans_info = &channel->trans_info;
u16 trans_index = trans - &trans_info->trans[0];
struct list_head list; struct list_head list;
u16 delta;
spin_lock_bh(&trans_info->spinlock); spin_lock_bh(&trans_info->spinlock);
...@@ -281,7 +280,22 @@ static void gsi_trans_move_pending(struct gsi_trans *trans) ...@@ -281,7 +280,22 @@ static void gsi_trans_move_pending(struct gsi_trans *trans)
list_cut_position(&list, &trans_info->committed, &trans->links); list_cut_position(&list, &trans_info->committed, &trans->links);
list_splice_tail(&list, &trans_info->pending); list_splice_tail(&list, &trans_info->pending);
trans = list_first_entry_or_null(&trans_info->committed,
struct gsi_trans, links);
spin_unlock_bh(&trans_info->spinlock); spin_unlock_bh(&trans_info->spinlock);
/* These committed transactions are now pending */
delta = trans_index - trans_info->committed_id + 1;
trans_info->committed_id += delta % channel->tre_count;
if (trans) {
trans_index = trans_info->committed_id % channel->tre_count;
WARN_ON(trans != &trans_info->trans[trans_index]);
} else {
WARN_ON(trans_info->committed_id !=
trans_info->allocated_id);
}
} }
/* Move a transaction and all of its predecessors from the pending list /* Move a transaction and all of its predecessors from the pending list
...@@ -392,14 +406,8 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, ...@@ -392,14 +406,8 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id,
list_add_tail(&trans->links, &trans_info->alloc); list_add_tail(&trans->links, &trans_info->alloc);
trans = list_first_entry(&trans_info->alloc, struct gsi_trans, links);
spin_unlock_bh(&trans_info->spinlock); spin_unlock_bh(&trans_info->spinlock);
WARN_ON(trans_info->allocated_id == trans_info->free_id);
trans_index = trans_info->allocated_id % channel->tre_count;
WARN_ON(trans != &trans_info->trans[trans_index]);
return trans; return trans;
} }
...@@ -428,11 +436,13 @@ void gsi_trans_free(struct gsi_trans *trans) ...@@ -428,11 +436,13 @@ void gsi_trans_free(struct gsi_trans *trans)
if (!last) if (!last)
return; return;
/* Unused transactions are allocated but never committed */ /* Unused transactions are allocated but never committed or pending */
if (!trans->used_count) if (!trans->used_count) {
trans_info->allocated_id++; trans_info->allocated_id++;
else trans_info->committed_id++;
} else {
ipa_gsi_trans_release(trans); ipa_gsi_trans_release(trans);
}
/* Releasing the reserved TREs implicitly frees the sgl[] and /* Releasing the reserved TREs implicitly frees the sgl[] and
* (if present) info[] arrays, plus the transaction itself. * (if present) info[] arrays, plus the transaction itself.
...@@ -769,6 +779,7 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id) ...@@ -769,6 +779,7 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id)
return -ENOMEM; return -ENOMEM;
trans_info->free_id = 0; /* all modulo channel->tre_count */ trans_info->free_id = 0; /* all modulo channel->tre_count */
trans_info->allocated_id = 0; trans_info->allocated_id = 0;
trans_info->committed_id = 0;
/* A completion event contains a pointer to the TRE that caused /* A completion event contains a pointer to the TRE that caused
* the event (which will be the last one used by the transaction). * the event (which will be the last one used by the transaction).
......
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