Skip to content

Commit

Permalink
net: ipa: track pending transactions with an ID
Browse files Browse the repository at this point in the history
Add a transaction ID field to track the first element in the
transaction array that is pending (sent to hardware) but not yet
complete.  Advance the ID when a completion event for a channel
indicates that transactions have completed.

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

Remove the temporary warnings added by the previous commit.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alex Elder authored and David S. Miller committed Sep 2, 2022
1 parent fc95d95 commit eeff7c1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
1 change: 1 addition & 0 deletions drivers/net/ipa/gsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct gsi_trans_info {
u16 free_id; /* first free trans in array */
u16 allocated_id; /* first allocated transaction */
u16 committed_id; /* first committed transaction */
u16 pending_id; /* first pending transaction */
struct gsi_trans *trans; /* transaction array */
struct gsi_trans **map; /* TRE -> transaction map */

Expand Down
46 changes: 28 additions & 18 deletions drivers/net/ipa/gsi_trans.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,23 +246,15 @@ static void gsi_trans_move_committed(struct gsi_trans *trans)
{
struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];
struct gsi_trans_info *trans_info = &channel->trans_info;
u16 trans_index;

spin_lock_bh(&trans_info->spinlock);

list_move_tail(&trans->links, &trans_info->committed);

trans = list_first_entry(&trans_info->committed,
struct gsi_trans, links);

spin_unlock_bh(&trans_info->spinlock);

/* This allocated transaction is now committed */
trans_info->allocated_id++;

WARN_ON(trans_info->committed_id == trans_info->allocated_id);
trans_index = trans_info->committed_id % channel->tre_count;
WARN_ON(trans != &trans_info->trans[trans_index]);
}

/* Move transactions from the committed list to the pending list */
Expand All @@ -280,22 +272,18 @@ static void gsi_trans_move_pending(struct gsi_trans *trans)
list_cut_position(&list, &trans_info->committed, &trans->links);
list_splice_tail(&list, &trans_info->pending);

trans = list_first_entry_or_null(&trans_info->committed,
struct gsi_trans, links);
trans = list_first_entry(&trans_info->pending,
struct gsi_trans, links);

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);
}
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
Expand All @@ -305,15 +293,33 @@ void gsi_trans_move_complete(struct gsi_trans *trans)
{
struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];
struct gsi_trans_info *trans_info = &channel->trans_info;
u16 trans_index = trans - trans_info->trans;
struct list_head list;
u16 delta;

spin_lock_bh(&trans_info->spinlock);

/* Move this transaction and all predecessors to completed list */
list_cut_position(&list, &trans_info->pending, &trans->links);
list_splice_tail(&list, &trans_info->complete);

trans = list_first_entry_or_null(&trans_info->pending,
struct gsi_trans, links);

spin_unlock_bh(&trans_info->spinlock);

/* These pending transactions are now completed */
delta = trans_index - trans_info->pending_id + 1;
delta %= channel->tre_count;
trans_info->pending_id += delta;

if (trans) {
trans_index = trans_info->pending_id % channel->tre_count;
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 */
Expand Down Expand Up @@ -436,10 +442,13 @@ void gsi_trans_free(struct gsi_trans *trans)
if (!last)
return;

/* Unused transactions are allocated but never committed or pending */
/* Unused transactions are allocated but never committed, pending,
* or completed.
*/
if (!trans->used_count) {
trans_info->allocated_id++;
trans_info->committed_id++;
trans_info->pending_id++;
} else {
ipa_gsi_trans_release(trans);
}
Expand Down Expand Up @@ -780,6 +789,7 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id)
trans_info->free_id = 0; /* all modulo channel->tre_count */
trans_info->allocated_id = 0;
trans_info->committed_id = 0;
trans_info->pending_id = 0;

/* A completion event contains a pointer to the TRE that caused
* the event (which will be the last one used by the transaction).
Expand Down

0 comments on commit eeff7c1

Please sign in to comment.