From: Alex Elder <elder@linaro.org>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: mka@chromium.org, evgreen@chromium.org,
bjorn.andersson@linaro.org, quic_cpratapa@quicinc.com,
quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com,
quic_subashab@quicinc.com, elder@kernel.org,
netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 4/6] net: ipa: track pending transactions with an ID
Date: Wed, 31 Aug 2022 17:40:15 -0500 [thread overview]
Message-ID: <20220831224017.377745-5-elder@linaro.org> (raw)
In-Reply-To: <20220831224017.377745-1-elder@linaro.org>
Add a transaction ID field to track the first element in the
transaction array that is pending (sent to hardware) but not yet
complete. Advance the ID when a completion event for a channel
indicates that transactions have completed.
Temporarily add warnings that verify that the first pending
transaction tracked by the ID matches the first element on the
pending list, both when pending and completing, as well as when
resetting the channel.
Remove the temporary warnings added by the previous commit.
Signed-off-by: Alex Elder <elder@linaro.org>
---
drivers/net/ipa/gsi.h | 1 +
drivers/net/ipa/gsi_trans.c | 46 ++++++++++++++++++++++---------------
2 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h
index cc46a9119fc5b..f23e7e562585e 100644
--- a/drivers/net/ipa/gsi.h
+++ b/drivers/net/ipa/gsi.h
@@ -86,6 +86,7 @@ struct gsi_trans_info {
u16 free_id; /* first free trans in array */
u16 allocated_id; /* first allocated transaction */
u16 committed_id; /* first committed transaction */
+ u16 pending_id; /* first pending transaction */
struct gsi_trans *trans; /* transaction array */
struct gsi_trans **map; /* TRE -> transaction map */
diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c
index 72da795908fee..5e3b4f673d9fb 100644
--- a/drivers/net/ipa/gsi_trans.c
+++ b/drivers/net/ipa/gsi_trans.c
@@ -246,23 +246,15 @@ 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;
- u16 trans_index;
spin_lock_bh(&trans_info->spinlock);
list_move_tail(&trans->links, &trans_info->committed);
- trans = list_first_entry(&trans_info->committed,
- struct gsi_trans, links);
-
spin_unlock_bh(&trans_info->spinlock);
/* This allocated transaction is now committed */
trans_info->allocated_id++;
-
- WARN_ON(trans_info->committed_id == trans_info->allocated_id);
- trans_index = trans_info->committed_id % channel->tre_count;
- WARN_ON(trans != &trans_info->trans[trans_index]);
}
/* Move transactions from the committed list to the pending list */
@@ -280,8 +272,8 @@ static void gsi_trans_move_pending(struct gsi_trans *trans)
list_cut_position(&list, &trans_info->committed, &trans->links);
list_splice_tail(&list, &trans_info->pending);
- trans = list_first_entry_or_null(&trans_info->committed,
- struct gsi_trans, links);
+ trans = list_first_entry(&trans_info->pending,
+ struct gsi_trans, links);
spin_unlock_bh(&trans_info->spinlock);
@@ -289,13 +281,9 @@ static void gsi_trans_move_pending(struct gsi_trans *trans)
delta = trans_index - trans_info->committed_id + 1;
trans_info->committed_id += delta % channel->tre_count;
- if (trans) {
- trans_index = trans_info->committed_id % channel->tre_count;
- WARN_ON(trans != &trans_info->trans[trans_index]);
- } else {
- WARN_ON(trans_info->committed_id !=
- trans_info->allocated_id);
- }
+ WARN_ON(trans_info->pending_id == trans_info->committed_id);
+ trans_index = trans_info->pending_id % channel->tre_count;
+ WARN_ON(trans != &trans_info->trans[trans_index]);
}
/* Move a transaction and all of its predecessors from the pending list
@@ -305,7 +293,9 @@ void gsi_trans_move_complete(struct gsi_trans *trans)
{
struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];
struct gsi_trans_info *trans_info = &channel->trans_info;
+ u16 trans_index = trans - trans_info->trans;
struct list_head list;
+ u16 delta;
spin_lock_bh(&trans_info->spinlock);
@@ -313,7 +303,23 @@ void gsi_trans_move_complete(struct gsi_trans *trans)
list_cut_position(&list, &trans_info->pending, &trans->links);
list_splice_tail(&list, &trans_info->complete);
+ trans = list_first_entry_or_null(&trans_info->pending,
+ struct gsi_trans, links);
+
spin_unlock_bh(&trans_info->spinlock);
+
+ /* These pending transactions are now completed */
+ delta = trans_index - trans_info->pending_id + 1;
+ delta %= channel->tre_count;
+ trans_info->pending_id += delta;
+
+ if (trans) {
+ trans_index = trans_info->pending_id % channel->tre_count;
+ WARN_ON(trans != &trans_info->trans[trans_index]);
+ } else {
+ WARN_ON(trans_info->pending_id !=
+ trans_info->committed_id);
+ }
}
/* Move a transaction from the completed list to the polled list */
@@ -436,10 +442,13 @@ void gsi_trans_free(struct gsi_trans *trans)
if (!last)
return;
- /* Unused transactions are allocated but never committed or pending */
+ /* Unused transactions are allocated but never committed, pending,
+ * or completed.
+ */
if (!trans->used_count) {
trans_info->allocated_id++;
trans_info->committed_id++;
+ trans_info->pending_id++;
} else {
ipa_gsi_trans_release(trans);
}
@@ -780,6 +789,7 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id)
trans_info->free_id = 0; /* all modulo channel->tre_count */
trans_info->allocated_id = 0;
trans_info->committed_id = 0;
+ trans_info->pending_id = 0;
/* A completion event contains a pointer to the TRE that caused
* the event (which will be the last one used by the transaction).
--
2.34.1
next prev parent reply other threads:[~2022-08-31 22:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-31 22:40 [PATCH net-next 0/6] net: ipa: use IDs to track transaction state Alex Elder
2022-08-31 22:40 ` [PATCH net-next 1/6] net: ipa: use an array for transactions Alex Elder
2022-08-31 22:40 ` [PATCH net-next 2/6] net: ipa: track allocated transactions with an ID Alex Elder
2022-08-31 22:40 ` [PATCH net-next 3/6] net: ipa: track committed " Alex Elder
2022-08-31 22:40 ` Alex Elder [this message]
2022-08-31 22:40 ` [PATCH net-next 5/6] net: ipa: track completed " Alex Elder
2022-08-31 22:40 ` [PATCH net-next 6/6] net: ipa: track polled " Alex Elder
2022-09-02 11:30 ` [PATCH net-next 0/6] net: ipa: use IDs to track transaction state patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220831224017.377745-5-elder@linaro.org \
--to=elder@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=elder@kernel.org \
--cc=evgreen@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mka@chromium.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=quic_avuyyuru@quicinc.com \
--cc=quic_cpratapa@quicinc.com \
--cc=quic_jponduru@quicinc.com \
--cc=quic_subashab@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox