net: ipa: kill the allocated transaction list
authorAlex Elder <elder@linaro.org>
Tue, 6 Sep 2022 17:19:39 +0000 (12:19 -0500)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 Sep 2022 10:45:25 +0000 (11:45 +0100)
The only place the trans_info->alloc list is used is when
initializing it, when adding a transaction to it when allocation
finishes, and when moving a transaction from that list to the
committed list.

We can just skip putting a transaction on the allocated list, and
add it (rather than move it) to the committed list when it is
committed.

On additional caveat is that an allocated transaction that's
committed without any TREs added will be immediately freed.  Because
we aren't adding allocated transactions to a list any more, the
list links need to be initialized to ensure they're valid at the
time list_del() is called for the transaction.

Then we can safely eliminate the allocated transaction list.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ipa/gsi.h
drivers/net/ipa/gsi_trans.c

index 13468704c40000a7135d0e13cd10c2774588a1b6..a3f2d27a7e4b376b2c9078c78c9a09abb047d58c 100644 (file)
@@ -96,7 +96,6 @@ struct gsi_trans_info {
        struct gsi_trans_pool cmd_pool; /* command payload DMA pool */
 
        spinlock_t spinlock;            /* protects updates to the lists */
-       struct list_head alloc;         /* allocated, not committed */
        struct list_head committed;     /* committed, awaiting doorbell */
        struct list_head pending;       /* pending, awaiting completion */
        struct list_head complete;      /* completed, awaiting poll */
index a131a4fbb53fcae4b189005aba0fcb1c90e18d39..254c09824004c44010eece4c91ce1d1bf9010c3d 100644 (file)
@@ -246,7 +246,7 @@ struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel)
        return &trans_info->trans[trans_id %= channel->tre_count];
 }
 
-/* Move a transaction from the allocated list to the committed list */
+/* Move a transaction from allocated to committed state */
 static void gsi_trans_move_committed(struct gsi_trans *trans)
 {
        struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];
@@ -254,7 +254,7 @@ static void gsi_trans_move_committed(struct gsi_trans *trans)
 
        spin_lock_bh(&trans_info->spinlock);
 
-       list_move_tail(&trans->links, &trans_info->committed);
+       list_add_tail(&trans->links, &trans_info->committed);
 
        spin_unlock_bh(&trans_info->spinlock);
 
@@ -383,6 +383,7 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id,
        memset(trans, 0, sizeof(*trans));
 
        /* Initialize non-zero fields in the transaction */
+       INIT_LIST_HEAD(&trans->links);
        trans->gsi = gsi;
        trans->channel_id = channel_id;
        trans->rsvd_count = tre_count;
@@ -398,12 +399,6 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id,
        /* This free transaction will now be allocated */
        trans_info->free_id++;
 
-       spin_lock_bh(&trans_info->spinlock);
-
-       list_add_tail(&trans->links, &trans_info->alloc);
-
-       spin_unlock_bh(&trans_info->spinlock);
-
        return trans;
 }
 
@@ -821,7 +816,6 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id)
                goto err_map_free;
 
        spin_lock_init(&trans_info->spinlock);
-       INIT_LIST_HEAD(&trans_info->alloc);
        INIT_LIST_HEAD(&trans_info->committed);
        INIT_LIST_HEAD(&trans_info->pending);
        INIT_LIST_HEAD(&trans_info->complete);