net: ipa: small transaction updates
cover net: ipa: small transaction updates
This series includes three changes to the transaction code. The first adds a new transaction list that represents a distinct state that has not been maintained. The second moves a field in the transaction information structure, and reorders its initialization a bit. The third skips a function call when it is known not to be necessary.
The last two are very small "leftover" patches.
-Alex
Alex Elder (5):
net: ipa: add a transaction committed list
net: ipa: rearrange transaction initialization
net: ipa: skip some cleanup for unused transactions
net: ipa: report when the driver has been removed
net: ipa: fix an outdated comment
drivers/net/ipa/gsi.c | 5 ++- drivers/net/ipa/gsi.h | 6 ++- drivers/net/ipa/gsi_trans.c | 89 +++++++++++++++++++++++-------------- drivers/net/ipa/ipa_main.c | 2 + 4 files changed, 65 insertions(+), 37 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/5 net: ipa: add a transaction committed list
We currently put a transaction on the pending list when it has been committed. But until the channel's doorbell rings, these transactions aren't actually "owned" by the hardware yet.
Add a new "committed" state (and list), to represent transactions that have been committed but not yet sent to hardware. Define "pending" to mean committed transactions that have been sent to hardware but have not yet completed.
--- drivers/net/ipa/gsi.c | 5 ++++- drivers/net/ipa/gsi.h | 3 ++- drivers/net/ipa/gsi_trans.c | 24 +++++++++++++++++++++--- 3 files changed, 27 insertions(+), 5 deletions(-)
drivers/net/ipa/gsi.c +4 -1
@@ -718,6 +718,9 @@ static struct gsi_trans *gsi_channel_trans_last(struct gsi_channel *channel)*/ if (channel->toward_ipa) { list = &trans_info->alloc; +if (!list_empty (list)) + goto done; + list = &trans_info->committed;if (!list_empty (list)) goto done; list = &trans_info->pending;
@@ -1363,7 +1366,7 @@ gsi_event_trans(struct gsi *gsi, struct gsi_event *event)* first *unfilled* event in the ring (following the last filled one). * * Events are sequential within the event ring, and transactions are -* sequential within the transaction pool. +* sequential within the transaction array. * * Note that @index always refers to an element *within* the event ring. */
drivers/net/ipa/gsi.h +2 -1
@@ -88,7 +88,8 @@ struct gsi_trans_info {spinlock_t spinlock;/* protects updates to the lists */ struct list_head alloc;/* allocated, not committed */ -struct list_head pending;/* committed, awaiting completion */ +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() */ };
drivers/net/ipa/gsi_trans.c +21 -3
@@ -241,15 +241,31 @@ struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel) struct gsi_trans, links); } -/* Move a transaction from the allocated list to the pending list */ +/* Move a transaction from the allocated list to the committed list */ +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; + +spin_lock_bh (&trans_info->spinlock); + +list_move_tail (&trans->links, &trans_info->committed); + +spin_unlock_bh (&trans_info->spinlock); +} + +/* Move transactions from the committed list to the pending list */ static void gsi_trans_move_pending (struct gsi_trans *trans) {struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];struct gsi_trans_info *trans_info = &channel->trans_info; +struct list_head list;spin_lock_bh (&trans_info->spinlock); -list_move_tail (&trans->links, &trans_info->pending); +/* 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); }
@@ -581,13 +597,14 @@ static void __gsi_trans_commit(struct gsi_trans *trans, bool ring_db)if (channel->toward_ipa)gsi_trans_tx_committed (trans); -gsi_trans_move_pending (trans); +gsi_trans_move_committed (trans);/* Ring doorbell if requested, or if all TREs are allocated */ if (ring_db || !atomic_read (&channel->trans_info.tre_avail)) {/* Report what we're handing off to hardware for TX channels */ if (channel->toward_ipa)gsi_trans_tx_queued (trans); +gsi_trans_move_pending (trans);gsi_channel_doorbell (channel); } }
@@ -747,6 +764,7 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id)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);INIT_LIST_HEAD (&trans_info->polled);
Signature · 1 line
2.34.1
PATCH 2/5 net: ipa: rearrange transaction initialization
In reply to Alex ElderThe transaction map is really associated with the transaction pool; move its definition earlier in the gsi_trans_info structure.
Rearrange initialization in gsi_channel_trans_init() so it sets the tre_avail value first, then initializes the transaction pool, and finally allocating the transaction map.
Update comments.
--- drivers/net/ipa/gsi.h | 3 +- drivers/net/ipa/gsi_trans.c | 60 +++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 30 deletions(-)
drivers/net/ipa/gsi.h +2 -1
@@ -82,9 +82,10 @@ struct gsi_trans_pool {struct gsi_trans_info {atomic_t tre_avail;/* TREs available for allocation */ struct gsi_trans_pool pool;/* transaction pool */ +struct gsi_trans **map;/* TRE -> transaction map */ +struct gsi_trans_pool sg_pool;/* scatterlist pool */ struct gsi_trans_pool cmd_pool;/* command payload DMA pool */ -struct gsi_trans **map;/* TRE -> transaction map */ spinlock_t spinlock;/* protects updates to the lists */ struct list_head alloc;/* allocated, not committed */
drivers/net/ipa/gsi_trans.c +31 -29
93 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 3/5 net: ipa: skip some cleanup for unused transactions
In reply to Alex ElderIn gsi_trans_free(), there's no point in ipa_gsi_trans_release() if a transaction is unused. No used TREs means no IPA layer resources to clean up. So only call ipa_gsi_trans_release() if at least one TRE was used.
--- drivers/net/ipa/gsi_trans.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ipa/gsi_trans.c +2 -1
@@ -404,7 +404,8 @@ void gsi_trans_free(struct gsi_trans *trans)if (!last)return ; -ipa_gsi_trans_release (trans); +if (trans->used_count) +ipa_gsi_trans_release (trans);/* Releasing the reserved TREs implicitly frees the sgl[] and * (if present) info[] arrays, plus the transaction itself.
Signature · 1 line
2.34.1
PATCH 4/5 net: ipa: report when the driver has been removed
In reply to Alex ElderWhen the IPA driver has completed its initialization and setup stages, it emits a brief message to the log. Add a small message that reports when it has been removed.
--- drivers/net/ipa/ipa_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ipa/ipa_main.c +2 -0
@@ -836,6 +836,8 @@ static int ipa_remove(struct platform_device *pdev)kfree (ipa);ipa_power_exit (power); +dev_info (dev,"IPA driver removed" ); +return 0 ; }
Signature · 1 line
2.34.1
PATCH 5/5 net: ipa: fix an outdated comment
In reply to Alex ElderSince commit 8797972afff3d ("net: ipa: remove command info pool"), we don't allocate "command info" entries for command channel transactions. Fix a comment that seems to suggest we still do. (Even before that commit, the comment was out of place.)
--- drivers/net/ipa/gsi_trans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipa/gsi_trans.c +1 -1
@@ -362,7 +362,7 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, trans->rsvd_count = tre_count;init_completion (&trans->completion); -/* Allocate the scatterlist and (if requested) info entries. */ +/* Allocate the scatterlist */ trans->sgl =gsi_trans_pool_alloc (&trans_info->sg_pool, tre_count);sg_init_marker (trans->sgl, tre_count);
Signature · 1 line
2.34.1