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

net: ipa: kill all other transaction lists

None of the transaction lists are actually needed any more, because
transaction IDs (which have been shown to be equivalent) are used
instead.  So we can remove all of them, as well as the spinlock
that protects updates to them.

Not requiring a lock simplifies gsi_trans_free() as well; we only
need to check the reference count once to decide whether we've hit
the last reference.

This makes the links field in the gsi_trans structure unused, so get
rid of that as well.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 11902b41
...@@ -94,12 +94,6 @@ struct gsi_trans_info { ...@@ -94,12 +94,6 @@ struct gsi_trans_info {
struct gsi_trans_pool sg_pool; /* scatterlist pool */ struct gsi_trans_pool sg_pool; /* scatterlist pool */
struct gsi_trans_pool cmd_pool; /* command payload DMA pool */ struct gsi_trans_pool cmd_pool; /* command payload DMA pool */
spinlock_t spinlock; /* protects updates to the lists */
struct list_head committed; /* committed, awaiting doorbell */
struct list_head pending; /* pending, awaiting completion */
struct list_head complete; /* completed, awaiting poll */
struct list_head polled; /* returned by gsi_channel_poll_one() */
}; };
/* Hardware values signifying the state of a channel */ /* Hardware values signifying the state of a channel */
......
...@@ -252,75 +252,43 @@ static void gsi_trans_move_committed(struct gsi_trans *trans) ...@@ -252,75 +252,43 @@ static void gsi_trans_move_committed(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;
spin_lock_bh(&trans_info->spinlock);
list_add_tail(&trans->links, &trans_info->committed);
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++;
} }
/* Move transactions from the committed list to the pending list */ /* Move committed transactions to pending state */
static void gsi_trans_move_pending(struct gsi_trans *trans) 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]; u16 trans_index = trans - &trans_info->trans[0];
struct list_head list;
u16 delta; u16 delta;
spin_lock_bh(&trans_info->spinlock);
/* Move this transaction and all predecessors to the pending list */
list_cut_position(&list, &trans_info->committed, &trans->links);
list_splice_tail(&list, &trans_info->pending);
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;
} }
/* Move a transaction and all of its predecessors from the pending list /* Move pending transactions to completed state */
* to the completed list.
*/
void gsi_trans_move_complete(struct gsi_trans *trans) void gsi_trans_move_complete(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; u16 trans_index = trans - trans_info->trans;
struct list_head list;
u16 delta; 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);
spin_unlock_bh(&trans_info->spinlock);
/* These pending transactions are now completed */ /* These pending transactions are now completed */
delta = trans_index - trans_info->pending_id + 1; delta = trans_index - trans_info->pending_id + 1;
delta %= channel->tre_count; delta %= channel->tre_count;
trans_info->pending_id += delta; trans_info->pending_id += delta;
} }
/* Move a transaction from the completed list to the polled list */ /* Move a transaction from completed to polled state */
void gsi_trans_move_polled(struct gsi_trans *trans) 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;
spin_lock_bh(&trans_info->spinlock);
list_move_tail(&trans->links, &trans_info->polled);
spin_unlock_bh(&trans_info->spinlock);
/* This completed transaction is now polled */ /* This completed transaction is now polled */
trans_info->completed_id++; trans_info->completed_id++;
} }
...@@ -383,7 +351,6 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, ...@@ -383,7 +351,6 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id,
memset(trans, 0, sizeof(*trans)); memset(trans, 0, sizeof(*trans));
/* Initialize non-zero fields in the transaction */ /* Initialize non-zero fields in the transaction */
INIT_LIST_HEAD(&trans->links);
trans->gsi = gsi; trans->gsi = gsi;
trans->channel_id = channel_id; trans->channel_id = channel_id;
trans->rsvd_count = tre_count; trans->rsvd_count = tre_count;
...@@ -396,7 +363,7 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, ...@@ -396,7 +363,7 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id,
trans->direction = direction; trans->direction = direction;
refcount_set(&trans->refcount, 1); refcount_set(&trans->refcount, 1);
/* This free transaction will now be allocated */ /* This free transaction is now allocated */
trans_info->free_id++; trans_info->free_id++;
return trans; return trans;
...@@ -405,31 +372,15 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, ...@@ -405,31 +372,15 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id,
/* Free a previously-allocated transaction */ /* Free a previously-allocated transaction */
void gsi_trans_free(struct gsi_trans *trans) void gsi_trans_free(struct gsi_trans *trans)
{ {
refcount_t *refcount = &trans->refcount;
struct gsi_trans_info *trans_info; struct gsi_trans_info *trans_info;
bool last;
/* We must hold the lock to release the last reference */ if (!refcount_dec_and_test(&trans->refcount))
if (refcount_dec_not_one(refcount))
return;
trans_info = &trans->gsi->channel[trans->channel_id].trans_info;
spin_lock_bh(&trans_info->spinlock);
/* Reference might have been added before we got the lock */
last = refcount_dec_and_test(refcount);
if (last)
list_del(&trans->links);
spin_unlock_bh(&trans_info->spinlock);
if (!last)
return; return;
/* Unused transactions are allocated but never committed, pending, /* Unused transactions are allocated but never committed, pending,
* completed, or polled. * completed, or polled.
*/ */
trans_info = &trans->gsi->channel[trans->channel_id].trans_info;
if (!trans->used_count) { if (!trans->used_count) {
trans_info->allocated_id++; trans_info->allocated_id++;
trans_info->committed_id++; trans_info->committed_id++;
...@@ -692,11 +643,6 @@ void gsi_channel_trans_cancel_pending(struct gsi_channel *channel) ...@@ -692,11 +643,6 @@ void gsi_channel_trans_cancel_pending(struct gsi_channel *channel)
u16 trans_id = trans_info->pending_id; u16 trans_id = trans_info->pending_id;
/* channel->gsi->mutex is held by caller */ /* channel->gsi->mutex is held by caller */
spin_lock_bh(&trans_info->spinlock);
list_splice_tail_init(&trans_info->pending, &trans_info->complete);
spin_unlock_bh(&trans_info->spinlock);
/* If there are no pending transactions, we're done */ /* If there are no pending transactions, we're done */
if (trans_id == trans_info->committed_id) if (trans_id == trans_info->committed_id)
...@@ -815,11 +761,6 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id) ...@@ -815,11 +761,6 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id)
if (ret) if (ret)
goto err_map_free; goto err_map_free;
spin_lock_init(&trans_info->spinlock);
INIT_LIST_HEAD(&trans_info->committed);
INIT_LIST_HEAD(&trans_info->pending);
INIT_LIST_HEAD(&trans_info->complete);
INIT_LIST_HEAD(&trans_info->polled);
return 0; return 0;
......
...@@ -29,7 +29,6 @@ struct gsi_trans_pool; ...@@ -29,7 +29,6 @@ struct gsi_trans_pool;
* struct gsi_trans - a GSI transaction * struct gsi_trans - a GSI transaction
* *
* Most fields in this structure for internal use by the transaction core code: * Most fields in this structure for internal use by the transaction core code:
* @links: Links for channel transaction lists by state
* @gsi: GSI pointer * @gsi: GSI pointer
* @channel_id: Channel number transaction is associated with * @channel_id: Channel number transaction is associated with
* @cancelled: If set by the core code, transaction was cancelled * @cancelled: If set by the core code, transaction was cancelled
...@@ -50,8 +49,6 @@ struct gsi_trans_pool; ...@@ -50,8 +49,6 @@ struct gsi_trans_pool;
* received. * received.
*/ */
struct gsi_trans { struct gsi_trans {
struct list_head links; /* gsi_channel lists */
struct gsi *gsi; struct gsi *gsi;
u8 channel_id; u8 channel_id;
......
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