summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ipa/gsi_private.h14
-rw-r--r--drivers/net/ipa/gsi_trans.c58
2 files changed, 16 insertions, 56 deletions
diff --git a/drivers/net/ipa/gsi_private.h b/drivers/net/ipa/gsi_private.h
index 51bbc7a40dc2..0b2516fa21b5 100644
--- a/drivers/net/ipa/gsi_private.h
+++ b/drivers/net/ipa/gsi_private.h
@@ -17,20 +17,6 @@ struct gsi_channel;
#define GSI_RING_ELEMENT_SIZE 16 /* bytes; must be a power of 2 */
/**
- * list_last_entry_or_null - get the last element from a list
- * @ptr: the list head to take the element from.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_head within the struct.
- *
- * Note that if the list is empty, it returns NULL.
- */
-#define list_last_entry_or_null(ptr, type, member) ({ \
- struct list_head *head__ = (ptr); \
- struct list_head *pos__ = READ_ONCE(head__->prev); \
- pos__ != head__ ? list_entry(pos__, type, member) : NULL; \
-})
-
-/**
* gsi_trans_move_complete() - Mark a GSI transaction completed
* @trans: Transaction to commit
*/
diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c
index 05ab4d052c68..a131a4fbb53f 100644
--- a/drivers/net/ipa/gsi_trans.c
+++ b/drivers/net/ipa/gsi_trans.c
@@ -239,22 +239,11 @@ struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel)
{
struct gsi_trans_info *trans_info = &channel->trans_info;
u16 trans_id = trans_info->completed_id;
- struct gsi_trans *trans;
-
- trans = list_first_entry_or_null(&trans_info->complete,
- struct gsi_trans, links);
- if (!trans) {
- WARN_ON(trans_id != trans_info->pending_id);
+ if (trans_id == trans_info->pending_id)
return NULL;
- }
- if (!WARN_ON(trans_id == trans_info->pending_id)) {
- trans_id %= channel->tre_count;
- WARN_ON(trans != &trans_info->trans[trans_id]);
- }
-
- return trans;
+ return &trans_info->trans[trans_id %= channel->tre_count];
}
/* Move a transaction from the allocated list to the committed list */
@@ -705,47 +694,32 @@ void gsi_trans_complete(struct gsi_trans *trans)
void gsi_channel_trans_cancel_pending(struct gsi_channel *channel)
{
struct gsi_trans_info *trans_info = &channel->trans_info;
- struct gsi_trans *trans;
- struct gsi_trans *first;
- struct gsi_trans *last;
- bool cancelled;
+ u16 trans_id = trans_info->pending_id;
/* channel->gsi->mutex is held by caller */
spin_lock_bh(&trans_info->spinlock);
- cancelled = !list_empty(&trans_info->pending);
- list_for_each_entry(trans, &trans_info->pending, links)
- trans->cancelled = true;
-
list_splice_tail_init(&trans_info->pending, &trans_info->complete);
- first = list_first_entry_or_null(&trans_info->complete,
- struct gsi_trans, links);
- last = list_last_entry_or_null(&trans_info->complete,
- struct gsi_trans, links);
-
spin_unlock_bh(&trans_info->spinlock);
- /* All pending transactions are now completed */
- WARN_ON(cancelled != (trans_info->pending_id !=
- trans_info->committed_id));
-
- trans_info->pending_id = trans_info->committed_id;
-
- /* Schedule NAPI polling to complete the cancelled transactions */
- if (cancelled) {
- u16 trans_id;
+ /* If there are no pending transactions, we're done */
+ if (trans_id == trans_info->committed_id)
+ return;
- napi_schedule(&channel->napi);
+ /* Mark all pending transactions cancelled */
+ do {
+ struct gsi_trans *trans;
- trans_id = trans_info->completed_id;
trans = &trans_info->trans[trans_id % channel->tre_count];
- WARN_ON(trans != first);
+ trans->cancelled = true;
+ } while (++trans_id != trans_info->committed_id);
- trans_id = trans_info->pending_id - 1;
- trans = &trans_info->trans[trans_id % channel->tre_count];
- WARN_ON(trans != last);
- }
+ /* All pending transactions are now completed */
+ trans_info->pending_id = trans_info->committed_id;
+
+ /* Schedule NAPI polling to complete the cancelled transactions */
+ napi_schedule(&channel->napi);
}
/* Issue a command to read a single byte from a channel */