From: Alex Elder <elder@linaro.org>
To: davem@davemloft.net, kuba@kernel.org
Cc: willemdebruijn.kernel@gmail.com, elder@kernel.org,
evgreen@chromium.org, bjorn.andersson@linaro.org,
cpratapa@codeaurora.org, subashab@codeaurora.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next v2 3/7] net: ipa: introduce __gsi_channel_start()
Date: Mon, 1 Feb 2021 11:28:46 -0600 [thread overview]
Message-ID: <20210201172850.2221624-4-elder@linaro.org> (raw)
In-Reply-To: <20210201172850.2221624-1-elder@linaro.org>
Create a new function that does most of the work of starting a
channel. What's different is that it takes a flag indicating
whether the channel should really be started or not. Create
another new function __gsi_channel_stop() that behaves similarly.
IPA v3.5.1 implements suspend using a special SUSPEND endpoint
setting. If the endpoint is suspended when an I/O completes on the
underlying GSI channel, a SUSPEND interrupt is generated.
Newer versions of IPA do not implement the SUSPEND endpoint mode.
Instead, endpoint suspend is implemented by simply stopping the
underlying GSI channel. In this case, a completing I/O on a
*stopped* channel causes the SUSPEND interrupt condition.
These new functions put all activity related to starting or stopping
a channel (including "thawing/freezing" the channel) in one place,
whether or not the channel is actually started or stopped.
Signed-off-by: Alex Elder <elder@linaro.org>
---
drivers/net/ipa/gsi.c | 71 ++++++++++++++++++++++---------------------
1 file changed, 37 insertions(+), 34 deletions(-)
diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c
index bd1bf388d9892..bba64887fe969 100644
--- a/drivers/net/ipa/gsi.c
+++ b/drivers/net/ipa/gsi.c
@@ -873,23 +873,30 @@ static void gsi_channel_deprogram(struct gsi_channel *channel)
/* Nothing to do */
}
+static int __gsi_channel_start(struct gsi_channel *channel, bool start)
+{
+ struct gsi *gsi = channel->gsi;
+ int ret;
+
+ mutex_lock(&gsi->mutex);
+
+ ret = start ? gsi_channel_start_command(channel) : 0;
+
+ mutex_unlock(&gsi->mutex);
+
+ /* Thaw the channel if successful */
+ if (!ret)
+ gsi_channel_thaw(channel);
+
+ return ret;
+}
+
/* Start an allocated GSI channel */
int gsi_channel_start(struct gsi *gsi, u32 channel_id)
{
struct gsi_channel *channel = &gsi->channel[channel_id];
- int ret;
- mutex_lock(&gsi->mutex);
-
- ret = gsi_channel_start_command(channel);
-
- mutex_unlock(&gsi->mutex);
-
- /* Thaw the channel if successful */
- if (!ret)
- gsi_channel_thaw(channel);
-
- return ret;
+ return __gsi_channel_start(channel, true);
}
static int gsi_channel_stop_retry(struct gsi_channel *channel)
@@ -912,21 +919,27 @@ static int gsi_channel_stop_retry(struct gsi_channel *channel)
return ret;
}
+static int __gsi_channel_stop(struct gsi_channel *channel, bool stop)
+{
+ int ret;
+
+ gsi_channel_freeze(channel);
+
+ ret = stop ? gsi_channel_stop_retry(channel) : 0;
+
+ /* Re-thaw the channel if an error occurred while stopping */
+ if (ret)
+ gsi_channel_thaw(channel);
+
+ return ret;
+}
+
/* Stop a started channel */
int gsi_channel_stop(struct gsi *gsi, u32 channel_id)
{
struct gsi_channel *channel = &gsi->channel[channel_id];
- int ret;
- gsi_channel_freeze(channel);
-
- ret = gsi_channel_stop_retry(channel);
-
- /* Re-thaw the channel if an error occurred while stopping */
- if (ret)
- gsi_channel_thaw(channel);
-
- return ret;
+ return __gsi_channel_stop(channel, true);
}
/* Reset and reconfigure a channel, (possibly) enabling the doorbell engine */
@@ -952,12 +965,7 @@ int gsi_channel_suspend(struct gsi *gsi, u32 channel_id, bool stop)
{
struct gsi_channel *channel = &gsi->channel[channel_id];
- if (stop)
- return gsi_channel_stop(gsi, channel_id);
-
- gsi_channel_freeze(channel);
-
- return 0;
+ return __gsi_channel_stop(channel, stop);
}
/* Resume a suspended channel (starting will be requested if STOPPED) */
@@ -965,12 +973,7 @@ int gsi_channel_resume(struct gsi *gsi, u32 channel_id, bool start)
{
struct gsi_channel *channel = &gsi->channel[channel_id];
- if (start)
- return gsi_channel_start(gsi, channel_id);
-
- gsi_channel_thaw(channel);
-
- return 0;
+ return __gsi_channel_start(channel, start);
}
/**
--
2.27.0
next prev parent reply other threads:[~2021-02-01 17:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 17:28 [PATCH net-next v2 0/7] net: ipa: don't disable NAPI in suspend Alex Elder
2021-02-01 17:28 ` [PATCH net-next v2 1/7] net: ipa: don't thaw channel if error starting Alex Elder
2021-02-01 17:28 ` [PATCH net-next v2 2/7] net: ipa: introduce gsi_channel_stop_retry() Alex Elder
2021-02-01 17:28 ` Alex Elder [this message]
2021-02-01 17:28 ` [PATCH net-next v2 4/7] net: ipa: kill gsi_channel_freeze() and gsi_channel_thaw() Alex Elder
2021-02-01 17:28 ` [PATCH net-next v2 5/7] net: ipa: disable interrupt and NAPI after channel stop Alex Elder
2021-02-01 17:28 ` [PATCH net-next v2 6/7] net: ipa: don't disable interrupt on suspend Alex Elder
2021-02-01 17:28 ` [PATCH net-next v2 7/7] net: ipa: expand last transaction check Alex Elder
2021-02-01 18:44 ` [PATCH net-next v2 0/7] net: ipa: don't disable NAPI in suspend Willem de Bruijn
2021-02-03 4:08 ` Jakub Kicinski
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=20210201172850.2221624-4-elder@linaro.org \
--to=elder@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=cpratapa@codeaurora.org \
--cc=davem@davemloft.net \
--cc=elder@kernel.org \
--cc=evgreen@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=subashab@codeaurora.org \
--cc=willemdebruijn.kernel@gmail.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
all inboxes | Powered by JetHome®