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

net: ipa: track completed transactions with an ID

Add a transaction ID field to track the first element in the
transaction array that has completed but has not yet been polled.

Advance the ID when we are processing a transaction in the NAPI
polling loop (where completed transactions become polled).

Temporarily add warnings that verify that the first completed
transaction tracked by the ID matches the first element on the
completed list, both when pending and completing.

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 eeff7c14
...@@ -87,6 +87,7 @@ struct gsi_trans_info { ...@@ -87,6 +87,7 @@ struct gsi_trans_info {
u16 allocated_id; /* first allocated transaction */ u16 allocated_id; /* first allocated transaction */
u16 committed_id; /* first committed transaction */ u16 committed_id; /* first committed transaction */
u16 pending_id; /* first pending transaction */ u16 pending_id; /* first pending transaction */
u16 completed_id; /* first completed 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 */
......
...@@ -272,18 +272,11 @@ static void gsi_trans_move_pending(struct gsi_trans *trans) ...@@ -272,18 +272,11 @@ 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(&trans_info->pending,
struct gsi_trans, links);
spin_unlock_bh(&trans_info->spinlock); spin_unlock_bh(&trans_info->spinlock);
/* These committed transactions are now pending */ /* These committed transactions are now pending */
delta = trans_index - trans_info->committed_id + 1; delta = trans_index - trans_info->committed_id + 1;
trans_info->committed_id += delta % channel->tre_count; trans_info->committed_id += delta % channel->tre_count;
WARN_ON(trans_info->pending_id == trans_info->committed_id);
trans_index = trans_info->pending_id % channel->tre_count;
WARN_ON(trans != &trans_info->trans[trans_index]);
} }
/* Move a transaction and all of its predecessors from the pending list /* Move a transaction and all of its predecessors from the pending list
...@@ -303,7 +296,7 @@ void gsi_trans_move_complete(struct gsi_trans *trans) ...@@ -303,7 +296,7 @@ void gsi_trans_move_complete(struct gsi_trans *trans)
list_cut_position(&list, &trans_info->pending, &trans->links); list_cut_position(&list, &trans_info->pending, &trans->links);
list_splice_tail(&list, &trans_info->complete); list_splice_tail(&list, &trans_info->complete);
trans = list_first_entry_or_null(&trans_info->pending, trans = list_first_entry(&trans_info->complete,
struct gsi_trans, links); struct gsi_trans, links);
spin_unlock_bh(&trans_info->spinlock); spin_unlock_bh(&trans_info->spinlock);
...@@ -313,13 +306,9 @@ void gsi_trans_move_complete(struct gsi_trans *trans) ...@@ -313,13 +306,9 @@ void gsi_trans_move_complete(struct gsi_trans *trans)
delta %= channel->tre_count; delta %= channel->tre_count;
trans_info->pending_id += delta; trans_info->pending_id += delta;
if (trans) { WARN_ON(trans_info->completed_id == trans_info->pending_id);
trans_index = trans_info->pending_id % channel->tre_count; trans_index = trans_info->completed_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->pending_id !=
trans_info->committed_id);
}
} }
/* Move a transaction from the completed list to the polled list */ /* Move a transaction from the completed list to the polled list */
...@@ -327,12 +316,27 @@ void gsi_trans_move_polled(struct gsi_trans *trans) ...@@ -327,12 +316,27 @@ void gsi_trans_move_polled(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;
spin_lock_bh(&trans_info->spinlock); spin_lock_bh(&trans_info->spinlock);
list_move_tail(&trans->links, &trans_info->polled); list_move_tail(&trans->links, &trans_info->polled);
trans = list_first_entry_or_null(&trans_info->complete,
struct gsi_trans, links);
spin_unlock_bh(&trans_info->spinlock); spin_unlock_bh(&trans_info->spinlock);
/* This completed transaction is now polled */
trans_info->completed_id++;
if (trans) {
trans_index = trans_info->completed_id % channel->tre_count;
WARN_ON(trans != &trans_info->trans[trans_index]);
} else {
WARN_ON(trans_info->completed_id !=
trans_info->pending_id);
}
} }
/* Reserve some number of TREs on a channel. Returns true if successful */ /* Reserve some number of TREs on a channel. Returns true if successful */
...@@ -443,12 +447,13 @@ void gsi_trans_free(struct gsi_trans *trans) ...@@ -443,12 +447,13 @@ void gsi_trans_free(struct gsi_trans *trans)
return; return;
/* Unused transactions are allocated but never committed, pending, /* Unused transactions are allocated but never committed, pending,
* or completed. * completed, or polled.
*/ */
if (!trans->used_count) { if (!trans->used_count) {
trans_info->allocated_id++; trans_info->allocated_id++;
trans_info->committed_id++; trans_info->committed_id++;
trans_info->pending_id++; trans_info->pending_id++;
trans_info->completed_id++;
} else { } else {
ipa_gsi_trans_release(trans); ipa_gsi_trans_release(trans);
} }
...@@ -790,6 +795,7 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id) ...@@ -790,6 +795,7 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id)
trans_info->allocated_id = 0; trans_info->allocated_id = 0;
trans_info->committed_id = 0; trans_info->committed_id = 0;
trans_info->pending_id = 0; trans_info->pending_id = 0;
trans_info->completed_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