Commit 6a5dc76a authored by David S. Miller's avatar David S. Miller

Merge branch 'net-ipa-kill-endpoint-delay-mode-workaround'

Alex Elder says:

====================
net: ipa: kill endpoint delay mode workaround

A "delay mode" feature was put in place to work around a problem
where packets could passed to the modem before it was ready to
handle them.  That problem no longer exists, and we don't need the
workaround any more so get rid of it.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 9c729e74 a4dcad34
...@@ -74,7 +74,6 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -74,7 +74,6 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.tx = { .tx = {
.status_endpoint = .status_endpoint =
IPA_ENDPOINT_MODEM_AP_RX, IPA_ENDPOINT_MODEM_AP_RX,
.delay = true,
}, },
}, },
}, },
......
...@@ -80,18 +80,12 @@ struct gsi_channel_data { ...@@ -80,18 +80,12 @@ struct gsi_channel_data {
/** /**
* struct ipa_endpoint_tx_data - configuration data for TX endpoints * struct ipa_endpoint_tx_data - configuration data for TX endpoints
* @status_endpoint: endpoint to which status elements are sent * @status_endpoint: endpoint to which status elements are sent
* @delay: whether endpoint starts in delay mode
*
* Delay mode prevents a TX endpoint from transmitting anything, even if
* commands have been presented to the hardware. Once the endpoint exits
* delay mode, queued transfer commands are sent.
* *
* The @status_endpoint is only valid if the endpoint's @status_enable * The @status_endpoint is only valid if the endpoint's @status_enable
* flag is set. * flag is set.
*/ */
struct ipa_endpoint_tx_data { struct ipa_endpoint_tx_data {
enum ipa_endpoint_name status_endpoint; enum ipa_endpoint_name status_endpoint;
bool delay;
}; };
/** /**
......
...@@ -284,25 +284,52 @@ static struct gsi_trans *ipa_endpoint_trans_alloc(struct ipa_endpoint *endpoint, ...@@ -284,25 +284,52 @@ static struct gsi_trans *ipa_endpoint_trans_alloc(struct ipa_endpoint *endpoint,
/* suspend_delay represents suspend for RX, delay for TX endpoints. /* suspend_delay represents suspend for RX, delay for TX endpoints.
* Note that suspend is not supported starting with IPA v4.0. * Note that suspend is not supported starting with IPA v4.0.
*/ */
static int static bool
ipa_endpoint_init_ctrl(struct ipa_endpoint *endpoint, bool suspend_delay) ipa_endpoint_init_ctrl(struct ipa_endpoint *endpoint, bool suspend_delay)
{ {
u32 offset = IPA_REG_ENDP_INIT_CTRL_N_OFFSET(endpoint->endpoint_id); u32 offset = IPA_REG_ENDP_INIT_CTRL_N_OFFSET(endpoint->endpoint_id);
struct ipa *ipa = endpoint->ipa; struct ipa *ipa = endpoint->ipa;
bool state;
u32 mask; u32 mask;
u32 val; u32 val;
/* assert(ipa->version == IPA_VERSION_3_5_1 */ /* Suspend is not supported for IPA v4.0+. Delay doesn't work
* correctly on IPA v4.2.
*
* if (endpoint->toward_ipa)
* assert(ipa->version != IPA_VERSION_4.2);
* else
* assert(ipa->version == IPA_VERSION_3_5_1);
*/
mask = endpoint->toward_ipa ? ENDP_DELAY_FMASK : ENDP_SUSPEND_FMASK; mask = endpoint->toward_ipa ? ENDP_DELAY_FMASK : ENDP_SUSPEND_FMASK;
val = ioread32(ipa->reg_virt + offset); val = ioread32(ipa->reg_virt + offset);
if (suspend_delay == !!(val & mask)) /* Don't bother if it's already in the requested state */
return -EALREADY; /* Already set to desired state */ state = !!(val & mask);
if (suspend_delay != state) {
val ^= mask; val ^= mask;
iowrite32(val, ipa->reg_virt + offset); iowrite32(val, ipa->reg_virt + offset);
}
return 0; return state;
}
/* We currently don't care what the previous state was for delay mode */
static void
ipa_endpoint_program_delay(struct ipa_endpoint *endpoint, bool enable)
{
/* assert(endpoint->toward_ipa); */
(void)ipa_endpoint_init_ctrl(endpoint, enable);
}
/* Returns previous suspend state (true means it was enabled) */
static bool
ipa_endpoint_program_suspend(struct ipa_endpoint *endpoint, bool enable)
{
/* assert(!endpoint->toward_ipa); */
return ipa_endpoint_init_ctrl(endpoint, enable);
} }
/* Enable or disable delay or suspend mode on all modem endpoints */ /* Enable or disable delay or suspend mode on all modem endpoints */
...@@ -311,7 +338,7 @@ void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool enable) ...@@ -311,7 +338,7 @@ void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool enable)
bool support_suspend; bool support_suspend;
u32 endpoint_id; u32 endpoint_id;
/* DELAY mode doesn't work right on IPA v4.2 */ /* DELAY mode doesn't work correctly on IPA v4.2 */
if (ipa->version == IPA_VERSION_4_2) if (ipa->version == IPA_VERSION_4_2)
return; return;
...@@ -325,8 +352,10 @@ void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool enable) ...@@ -325,8 +352,10 @@ void ipa_endpoint_modem_pause_all(struct ipa *ipa, bool enable)
continue; continue;
/* Set TX delay mode, or for IPA v3.5.1 RX suspend mode */ /* Set TX delay mode, or for IPA v3.5.1 RX suspend mode */
if (endpoint->toward_ipa || support_suspend) if (endpoint->toward_ipa)
(void)ipa_endpoint_init_ctrl(endpoint, enable); ipa_endpoint_program_delay(endpoint, enable);
else if (support_suspend)
(void)ipa_endpoint_program_suspend(endpoint, enable);
} }
} }
...@@ -1133,8 +1162,8 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) ...@@ -1133,8 +1162,8 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint)
{ {
struct device *dev = &endpoint->ipa->pdev->dev; struct device *dev = &endpoint->ipa->pdev->dev;
struct ipa *ipa = endpoint->ipa; struct ipa *ipa = endpoint->ipa;
bool endpoint_suspended = false;
struct gsi *gsi = &ipa->gsi; struct gsi *gsi = &ipa->gsi;
bool suspended = false;
dma_addr_t addr; dma_addr_t addr;
bool legacy; bool legacy;
u32 retries; u32 retries;
...@@ -1164,8 +1193,7 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) ...@@ -1164,8 +1193,7 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint)
/* Make sure the channel isn't suspended */ /* Make sure the channel isn't suspended */
if (endpoint->ipa->version == IPA_VERSION_3_5_1) if (endpoint->ipa->version == IPA_VERSION_3_5_1)
if (!ipa_endpoint_init_ctrl(endpoint, false)) suspended = ipa_endpoint_program_suspend(endpoint, false);
endpoint_suspended = true;
/* Start channel and do a 1 byte read */ /* Start channel and do a 1 byte read */
ret = gsi_channel_start(gsi, endpoint->channel_id); ret = gsi_channel_start(gsi, endpoint->channel_id);
...@@ -1210,8 +1238,8 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) ...@@ -1210,8 +1238,8 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint)
err_endpoint_stop: err_endpoint_stop:
ipa_endpoint_stop(endpoint); ipa_endpoint_stop(endpoint);
out_suspend_again: out_suspend_again:
if (endpoint_suspended) if (suspended)
(void)ipa_endpoint_init_ctrl(endpoint, true); (void)ipa_endpoint_program_suspend(endpoint, true);
dma_unmap_single(dev, addr, len, DMA_FROM_DEVICE); dma_unmap_single(dev, addr, len, DMA_FROM_DEVICE);
out_kfree: out_kfree:
kfree(virt); kfree(virt);
...@@ -1312,31 +1340,16 @@ int ipa_endpoint_stop(struct ipa_endpoint *endpoint) ...@@ -1312,31 +1340,16 @@ int ipa_endpoint_stop(struct ipa_endpoint *endpoint)
static void ipa_endpoint_program(struct ipa_endpoint *endpoint) static void ipa_endpoint_program(struct ipa_endpoint *endpoint)
{ {
struct device *dev = &endpoint->ipa->pdev->dev;
int ret;
if (endpoint->toward_ipa) { if (endpoint->toward_ipa) {
bool delay_mode = endpoint->data->tx.delay; if (endpoint->ipa->version != IPA_VERSION_4_2)
ipa_endpoint_program_delay(endpoint, false);
ret = ipa_endpoint_init_ctrl(endpoint, delay_mode);
/* Endpoint is expected to not be in delay mode */
if (!ret != delay_mode) {
dev_warn(dev,
"TX endpoint %u was %sin delay mode\n",
endpoint->endpoint_id,
delay_mode ? "already " : "");
}
ipa_endpoint_init_hdr_ext(endpoint); ipa_endpoint_init_hdr_ext(endpoint);
ipa_endpoint_init_aggr(endpoint); ipa_endpoint_init_aggr(endpoint);
ipa_endpoint_init_deaggr(endpoint); ipa_endpoint_init_deaggr(endpoint);
ipa_endpoint_init_seq(endpoint); ipa_endpoint_init_seq(endpoint);
} else { } else {
if (endpoint->ipa->version == IPA_VERSION_3_5_1) { if (endpoint->ipa->version == IPA_VERSION_3_5_1)
if (!ipa_endpoint_init_ctrl(endpoint, false)) (void)ipa_endpoint_program_suspend(endpoint, false);
dev_warn(dev,
"RX endpoint %u was suspended\n",
endpoint->endpoint_id);
}
ipa_endpoint_init_hdr_ext(endpoint); ipa_endpoint_init_hdr_ext(endpoint);
ipa_endpoint_init_aggr(endpoint); ipa_endpoint_init_aggr(endpoint);
} }
...@@ -1448,7 +1461,7 @@ void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint) ...@@ -1448,7 +1461,7 @@ void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint)
* aggregation frame, then simulating the arrival of such * aggregation frame, then simulating the arrival of such
* an interrupt. * an interrupt.
*/ */
WARN_ON(ipa_endpoint_init_ctrl(endpoint, true)); (void)ipa_endpoint_program_suspend(endpoint, true);
ipa_endpoint_suspend_aggr(endpoint); ipa_endpoint_suspend_aggr(endpoint);
} }
...@@ -1471,7 +1484,7 @@ void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint) ...@@ -1471,7 +1484,7 @@ void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint)
/* IPA v3.5.1 doesn't use channel start for resume */ /* IPA v3.5.1 doesn't use channel start for resume */
start_channel = endpoint->ipa->version != IPA_VERSION_3_5_1; start_channel = endpoint->ipa->version != IPA_VERSION_3_5_1;
if (!endpoint->toward_ipa && !start_channel) if (!endpoint->toward_ipa && !start_channel)
WARN_ON(ipa_endpoint_init_ctrl(endpoint, false)); (void)ipa_endpoint_program_suspend(endpoint, false);
ret = gsi_channel_resume(gsi, endpoint->channel_id, start_channel); ret = gsi_channel_resume(gsi, endpoint->channel_id, start_channel);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment