Skip to content

Commit

Permalink
net: ipa: use version in gsi_channel_program()
Browse files Browse the repository at this point in the history
Use the IPA version in gsi_channel_program() to determine whether
we should enable the GSI doorbell engine when requested.  This way,
callers only say whether or not it should be enabled if needed,
regardless of hardware version.

Rename the "legacy" argument to gsi_channel_reset(), and have
it indicate whether the doorbell engine should be enabled when
reprogramming following the reset.

Change all callers of gsi_channel_reset() to indicate whether to
enable the doorbell engine after reset, independent of hardware
version.

Rework a little logic in ipa_endpoint_reset() to get rid of the
"legacy" variable previously passed to gsi_channel_reset().

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Alex Elder authored and Jakub Kicinski committed Nov 5, 2020
1 parent 9de4a4c commit ce54993
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
10 changes: 5 additions & 5 deletions drivers/net/ipa/gsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)

/* Max prefetch is 1 segment (do not set MAX_PREFETCH_FMASK) */

/* Enable the doorbell engine if requested */
if (doorbell)
/* We enable the doorbell engine for IPA v3.5.1 */
if (gsi->version == IPA_VERSION_3_5_1 && doorbell)
val |= USE_DB_ENG_FMASK;

/* Starting with IPA v4.0 the command channel uses the escape buffer */
Expand Down Expand Up @@ -831,8 +831,8 @@ int gsi_channel_stop(struct gsi *gsi, u32 channel_id)
return ret;
}

/* Reset and reconfigure a channel (possibly leaving doorbell disabled) */
void gsi_channel_reset(struct gsi *gsi, u32 channel_id, bool legacy)
/* Reset and reconfigure a channel, (possibly) enabling the doorbell engine */
void gsi_channel_reset(struct gsi *gsi, u32 channel_id, bool doorbell)
{
struct gsi_channel *channel = &gsi->channel[channel_id];

Expand All @@ -843,7 +843,7 @@ void gsi_channel_reset(struct gsi *gsi, u32 channel_id, bool legacy)
if (gsi->version == IPA_VERSION_3_5_1 && !channel->toward_ipa)
gsi_channel_reset_command(channel);

gsi_channel_program(channel, legacy);
gsi_channel_program(channel, doorbell);
gsi_channel_trans_cancel_pending(channel);

mutex_unlock(&gsi->mutex);
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/ipa/gsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ int gsi_channel_stop(struct gsi *gsi, u32 channel_id);
* gsi_channel_reset() - Reset an allocated GSI channel
* @gsi: GSI pointer
* @channel_id: Channel to be reset
* @legacy: Legacy behavior
* @doorbell: Whether to (possibly) enable the doorbell engine
*
* Reset a channel and reconfigure it. The @legacy flag indicates
* that some steps should be done differently for legacy hardware.
* Reset a channel and reconfigure it. The @doorbell flag indicates
* that the doorbell engine should be enabled if needed.
*
* GSI hardware relinquishes ownership of all pending receive buffer
* transactions and they will complete with their cancelled flag set.
*/
void gsi_channel_reset(struct gsi *gsi, u32 channel_id, bool legacy);
void gsi_channel_reset(struct gsi *gsi, u32 channel_id, bool doorbell);

int gsi_channel_suspend(struct gsi *gsi, u32 channel_id, bool stop);
int gsi_channel_resume(struct gsi *gsi, u32 channel_id, bool start);
Expand Down
16 changes: 6 additions & 10 deletions drivers/net/ipa/ipa_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,6 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint)
struct gsi *gsi = &ipa->gsi;
bool suspended = false;
dma_addr_t addr;
bool legacy;
u32 retries;
u32 len = 1;
void *virt;
Expand Down Expand Up @@ -1279,8 +1278,7 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint)
* complete the channel reset sequence. Finish by suspending the
* channel again (if necessary).
*/
legacy = ipa->version == IPA_VERSION_3_5_1;
gsi_channel_reset(gsi, endpoint->channel_id, legacy);
gsi_channel_reset(gsi, endpoint->channel_id, true);

msleep(1);

Expand All @@ -1303,21 +1301,19 @@ static void ipa_endpoint_reset(struct ipa_endpoint *endpoint)
u32 channel_id = endpoint->channel_id;
struct ipa *ipa = endpoint->ipa;
bool special;
bool legacy;
int ret = 0;

/* On IPA v3.5.1, if an RX endpoint is reset while aggregation
* is active, we need to handle things specially to recover.
* All other cases just need to reset the underlying GSI channel.
*
* IPA v3.5.1 enables the doorbell engine. Newer versions do not.
*/
legacy = ipa->version == IPA_VERSION_3_5_1;
special = !endpoint->toward_ipa && endpoint->data->aggregation;
if (legacy && special && ipa_endpoint_aggr_active(endpoint))
special = ipa->version == IPA_VERSION_3_5_1 &&
!endpoint->toward_ipa &&
endpoint->data->aggregation;
if (special && ipa_endpoint_aggr_active(endpoint))
ret = ipa_endpoint_reset_rx_aggr(endpoint);
else
gsi_channel_reset(&ipa->gsi, channel_id, legacy);
gsi_channel_reset(&ipa->gsi, channel_id, true);

if (ret)
dev_err(&ipa->pdev->dev,
Expand Down

0 comments on commit ce54993

Please sign in to comment.