Skip to contentSkip to conversation

net: ipa: small transaction updates

PATCH New Alex Elder 2 participants 7 messages Jul 19, 2022 – Jul 21, 2022

Subsystems (4)
lore
Share & tools
lore

Alex Elder

author
#0 lore raw

v2 cover net: ipa: small transaction updates

Version 2 of this series corrects a misspelling of "outstanding" pointed out by the netdev test bots. (For some reason I don't see that when I run "checkpatch".) I found and fixed a second instance of that word being misspelled as well.

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       |  8 ++--
 drivers/net/ipa/gsi_trans.c | 89 +++++++++++++++++++++++--------------
 drivers/net/ipa/ipa_main.c  |  2 +
 4 files changed, 66 insertions(+), 38 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 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       |  5 +++--
 drivers/net/ipa/gsi_trans.c | 26 ++++++++++++++++++++++----
 3 files changed, 29 insertions(+), 7 deletions(-)
drivers/net/ipa/gsi.c +4 -1
index 4e46974a69ecd..c70fd4bab1d68 100644
@@ -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 +3 -2
index bad1a78a96ede..1c8941911069d 100644
@@ -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() */
 };
@@ -184,7 +185,7 @@ void gsi_teardown(struct gsi *gsi);
  * @gsi:	GSI pointer
  * @channel_id:	Channel whose limit is to be returned
  *
- * Return:	 The maximum number of TREs oustanding on the channel
+ * Return:	 The maximum number of TREs outstanding on the channel
  */
 u32 gsi_channel_tre_max(struct gsi *gsi, u32 channel_id);
 
drivers/net/ipa/gsi_trans.c +22 -4
index 29496ca15825f..45572ebb76e95 100644
@@ -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);
 	}
 }
@@ -710,7 +727,7 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id)
 		return -ENOMEM;
 
 	/* We can't use more TREs than there are available in the ring.
-	 * This limits the number of transactions that can be oustanding.
+	 * This limits the number of transactions that can be outstanding.
 	 * Worst case is one TRE per transaction (but we actually limit
 	 * it to something a little less than that).  We allocate resources
 	 * for transactions (including transaction structures) based on
@@ -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
author
#2 lore raw

PATCH v2 2/5 net: ipa: rearrange transaction initialization

In reply to Alex Elder

The 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.

---
v2: Fixed the misspelling of "outstanding" in two spots.

 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
index 1c8941911069d..c197df64e69a2 100644
@@ -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
author
#3 lore raw

PATCH v2 3/5 net: ipa: skip some cleanup for unused transactions

In reply to Alex Elder

In 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
index 3f52932e9e413..55987e35af2dd 100644
@@ -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
author
#4 lore raw

PATCH v2 4/5 net: ipa: report when the driver has been removed

In reply to Alex Elder

When 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
index 3757ce3de2c59..96c649d889a7c 100644
@@ -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
author
#5 lore raw

PATCH v2 5/5 net: ipa: fix an outdated comment

In reply to Alex Elder

Since 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
index 55987e35af2dd..18e7e8c405bea 100644
@@ -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
#6 lore raw
In reply to Alex Elder
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 5 lines · On Tue, 19 Jul 2022 13:10:15 -0500 you wrote:

Version 2 of this series corrects a misspelling of "outstanding" pointed out by the netdev test bots. (For some reason I don't see that when I run "checkpatch".) I found and fixed a second instance of that word being misspelled as well.

Quoted 8 lines

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.

[...]

Here is the summary with links:
- [net-next,v2,1/5] net: ipa: add a transaction committed list

    https://git.kernel.org/netdev/net-next/c/b63f507c06e6
  - [net-next,v2,2/5] net: ipa: rearrange transaction initialization
    (no matching commit)
  - [net-next,v2,3/5] net: ipa: skip some cleanup for unused transactions
    https://git.kernel.org/netdev/net-next/c/4d8996cbeeab
  - [net-next,v2,4/5] net: ipa: report when the driver has been removed
    https://git.kernel.org/netdev/net-next/c/3c91c86d1bb6
  - [net-next,v2,5/5] net: ipa: fix an outdated comment
    https://git.kernel.org/netdev/net-next/c/616c4a83b6ea

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html