msm: ipa: Fix init and add overflow check for drop stats

Fix init_drop_stats to have it only enable 4 pipes max.
Enable different pipes depending on kernel version.
Use more descriptive names for WLAN2_CONS pipes drop stats.
Add a temp variable to not enable drop stats bitmask when # of
pipes is more than allocated.

Change-Id: I3d678569eb94bfd43d90d2d4f84f5b1148b8ec42
Signed-off-by: Michael Adisumarta <madisuma@codeaurora.org>
This commit is contained in:
Michael Adisumarta
2021-08-26 21:25:13 -07:00
parent a0ca972920
commit 78e9ad583c

View File

@@ -1835,35 +1835,44 @@ int ipa_drop_stats_init(void)
u32 reg_idx; u32 reg_idx;
u32 mask, pipe_bitmask[IPA_EP_ARR_SIZE] = {0}; u32 mask, pipe_bitmask[IPA_EP_ARR_SIZE] = {0};
/* If HOLB Monitoring is enabled, enable drop stats for USB and WLAN. */
if (ipa3_ctx->uc_ctx.ipa_use_uc_holb_monitor) {
mask = ipa_hw_stats_get_ep_bit_n_idx( mask = ipa_hw_stats_get_ep_bit_n_idx(
IPA_CLIENT_USB_CONS, IPA_CLIENT_USB_CONS,
&reg_idx); &reg_idx);
pipe_bitmask[reg_idx] |= mask; pipe_bitmask[reg_idx] |= mask;
if (ipa3_ctx->ipa_wdi3_5g_holb_timeout || ipa3_ctx->uc_ctx.ipa_use_uc_holb_monitor) {
mask = ipa_hw_stats_get_ep_bit_n_idx( mask = ipa_hw_stats_get_ep_bit_n_idx(
IPA_CLIENT_WLAN2_CONS, IPA_CLIENT_WLAN2_CONS,
&reg_idx); &reg_idx);
pipe_bitmask[reg_idx] |= mask; pipe_bitmask[reg_idx] |= mask;
} }
if (ipa3_ctx->platform_type == IPA_PLAT_TYPE_MDM) {
if (ipa3_ctx->ipa_wdi3_2g_holb_timeout) {
mask = ipa_hw_stats_get_ep_bit_n_idx(
IPA_CLIENT_WLAN2_CONS1,
&reg_idx);
pipe_bitmask[reg_idx] |= mask;
}
if (ipa3_ctx->use_tput_est_ep) { if (ipa3_ctx->use_tput_est_ep) {
mask = ipa_hw_stats_get_ep_bit_n_idx( mask = ipa_hw_stats_get_ep_bit_n_idx(
IPA_CLIENT_TPUT_CONS, IPA_CLIENT_TPUT_CONS,
&reg_idx); &reg_idx);
pipe_bitmask[reg_idx] |= mask; pipe_bitmask[reg_idx] |= mask;
} }
/* Always enable drop stats for USB DPL Pipe. */ } else {
mask = ipa_hw_stats_get_ep_bit_n_idx( mask = ipa_hw_stats_get_ep_bit_n_idx(
IPA_CLIENT_USB_DPL_CONS, IPA_CLIENT_USB_DPL_CONS,
&reg_idx); &reg_idx);
pipe_bitmask[reg_idx] |= mask; pipe_bitmask[reg_idx] |= mask;
/* Always enable drop stats for ODL DPL Pipe. */
mask = ipa_hw_stats_get_ep_bit_n_idx( mask = ipa_hw_stats_get_ep_bit_n_idx(
IPA_CLIENT_ODL_DPL_CONS, IPA_CLIENT_ODL_DPL_CONS,
&reg_idx); &reg_idx);
pipe_bitmask[reg_idx] |= mask; pipe_bitmask[reg_idx] |= mask;
}
/* Currently we have option to enable drop stats using debugfs. /* Currently we have option to enable drop stats using debugfs.
* To enable drop stats for a different pipe, first user needs * To enable drop stats for a different pipe, first user needs
@@ -1886,6 +1895,7 @@ int ipa_init_drop_stats(u32 *pipe_bitmask)
{0}; {0};
struct ipahal_imm_cmd_pyld *coal_cmd_pyld = NULL; struct ipahal_imm_cmd_pyld *coal_cmd_pyld = NULL;
struct ipa3_desc desc[IPA_INIT_DROP_STATS_MAX_CMD_NUM] = { {0} }; struct ipa3_desc desc[IPA_INIT_DROP_STATS_MAX_CMD_NUM] = { {0} };
struct ipa_hw_stats_drop tmp_drop;
dma_addr_t dma_address; dma_addr_t dma_address;
int ret, i; int ret, i;
int num_cmd = 0; int num_cmd = 0;
@@ -1896,28 +1906,34 @@ int ipa_init_drop_stats(u32 *pipe_bitmask)
if (!pipe_bitmask) if (!pipe_bitmask)
return -EPERM; return -EPERM;
/* reset driver's cache */ /* check if IPA has enough space for # of pipes drop stats enabled*/
memset(&ipa3_ctx->hw_stats->drop, 0, sizeof(ipa3_ctx->hw_stats->drop)); memset(&tmp_drop, 0, sizeof(tmp_drop));
for (i = 0; i < IPA5_PIPE_REG_NUM; i++) { for (i = 0; i < IPA5_PIPE_REG_NUM; i++) {
ipa3_ctx->hw_stats->drop.init.enabled_bitmask[i] = tmp_drop.init.enabled_bitmask[i] = pipe_bitmask[i];
pipe_bitmask[i];
IPADBG_LOW("pipe_bitmask[%d]=0x%x\n", i, pipe_bitmask[i]); IPADBG_LOW("pipe_bitmask[%d]=0x%x\n", i, pipe_bitmask[i]);
} }
pyld = ipahal_stats_generate_init_pyld(IPAHAL_HW_STATS_DROP, pyld = ipahal_stats_generate_init_pyld(IPAHAL_HW_STATS_DROP,
&ipa3_ctx->hw_stats->drop.init, false); &tmp_drop.init, false);
if (!pyld) { if (!pyld) {
IPAERR("failed to generate pyld\n"); IPAERR("failed to generate pyld\n");
return -EPERM; return -EPERM;
} }
if (pyld->len > IPA_MEM_PART(stats_drop_size)) { if (pyld->len > IPA_MEM_PART(stats_drop_size)) {
IPAERR("SRAM partition too small: %d needed %d\n", IPAERR("SRAM partition too small: %d bytes (%d pipes)."
IPA_MEM_PART(stats_drop_size), pyld->len); "Tried to add %d bytes (%d pipes)."
"Please disable some stats before adding new ones.\n",
IPA_MEM_PART(stats_drop_size), IPA_MEM_PART(stats_drop_size)/8,
pyld->len, pyld->len/8);
ret = -EPERM; ret = -EPERM;
goto destroy_init_pyld; goto destroy_init_pyld;
} }
/* reset driver's cache and copy the bitmask of new drop enabled pipes */
memset(&ipa3_ctx->hw_stats->drop, 0, sizeof(ipa3_ctx->hw_stats->drop));
ipa3_ctx->hw_stats->drop = tmp_drop;
dma_address = dma_map_single(ipa3_ctx->pdev, dma_address = dma_map_single(ipa3_ctx->pdev,
pyld->data, pyld->data,
pyld->len, pyld->len,
@@ -2629,11 +2645,21 @@ static ssize_t ipa_debugfs_print_drop_stats(struct file *file,
ipahal_get_ep_bit(ep_idx))) ipahal_get_ep_bit(ep_idx)))
continue; continue;
/* Use more descriptive names for WLAN2_CONS pipes */
if(i == IPA_CLIENT_WLAN2_CONS) {
nbytes += scnprintf(dbg_buff + nbytes,
IPA_MAX_MSG_LEN - nbytes,
"IPA_CLIENT_WLAN2_HIGHSPEED_CONS:\n");
} else if(i == IPA_CLIENT_WLAN2_CONS1) {
nbytes += scnprintf(dbg_buff + nbytes,
IPA_MAX_MSG_LEN - nbytes,
" IPA_CLIENT_WLAN2_LOWSPEED_CONS:\n");
} else {
nbytes += scnprintf(dbg_buff + nbytes, nbytes += scnprintf(dbg_buff + nbytes,
IPA_MAX_MSG_LEN - nbytes, IPA_MAX_MSG_LEN - nbytes,
"%s:\n", "%s:\n",
ipa_clients_strings[i]); ipa_clients_strings[i]);
}
nbytes += scnprintf(dbg_buff + nbytes, nbytes += scnprintf(dbg_buff + nbytes,
IPA_MAX_MSG_LEN - nbytes, IPA_MAX_MSG_LEN - nbytes,