Merge "msm: ipa: split quota stat memory between q6 and ap"

This commit is contained in:
qctecmdr 2020-01-23 08:18:16 -08:00 • committed by Gerrit - the friendly Code Review server
commit f5ad5307bc
5 changed files with 83 additions and 41 deletions

View file

@ -3862,22 +3862,23 @@ int _ipa_init_sram_v3(void)
if (ipa_get_hw_type() >= IPA_HW_v4_5) {
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(nat_tbl_ofst) - 12);
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(nat_tbl_ofst) - 8);
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(nat_tbl_ofst) - 4);
ipa3_sram_set_canary(ipa_sram_mmio, IPA_MEM_PART(nat_tbl_ofst));
}
if (ipa_get_hw_type() >= IPA_HW_v4_0) {
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(pdn_config_ofst) - 4);
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(pdn_config_ofst));
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(stats_quota_ofst) - 4);
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(stats_quota_ofst));
if (ipa_get_hw_type() < IPA_HW_v4_5) {
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(pdn_config_ofst) - 4);
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(pdn_config_ofst));
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(stats_quota_q6_ofst) - 4);
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(stats_quota_q6_ofst));
} else {
ipa3_sram_set_canary(ipa_sram_mmio,
IPA_MEM_PART(stats_quota_q6_ofst) - 12);
}
}
if (ipa_get_hw_type() <= IPA_HW_v3_5 ||
ipa_get_hw_type() >= IPA_HW_v4_5) {
ipa3_sram_set_canary(ipa_sram_mmio,

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/debugfs.h>
@ -271,6 +271,27 @@ static void ipa_close_coal_frame(struct ipahal_imm_cmd_pyld **coal_cmd_pyld)
&reg_write_coal_close, false);
}
static bool ipa_validate_quota_stats_sram_size(u32 needed_len)
{
u32 sram_size;
/* Starting IPA4.5 Quota stats is split between Q6 and AP */
if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
IPAERR("Not supported ipa_ver=%d\n", ipa3_ctx->ipa_hw_type);
return false;
}
sram_size = IPA_MEM_PART(stats_quota_ap_size);
if (needed_len > sram_size) {
IPAERR("SRAM partition too small: %u needed %u\n",
sram_size, needed_len);
return false;
}
return true;
}
int ipa_init_quota_stats(u32 pipe_bitmask)
{
struct ipahal_stats_init_pyld *pyld;
@ -301,9 +322,7 @@ int ipa_init_quota_stats(u32 pipe_bitmask)
return -EPERM;
}
if (pyld->len > IPA_MEM_PART(stats_quota_size)) {
IPAERR("SRAM partition too small: %d needed %d\n",
IPA_MEM_PART(stats_quota_size), pyld->len);
if (!ipa_validate_quota_stats_sram_size(pyld->len)) {
ret = -EPERM;
goto destroy_init_pyld;
}
@ -356,7 +375,7 @@ int ipa_init_quota_stats(u32 pipe_bitmask)
quota_base.offset = ipahal_get_reg_n_ofst(IPA_STAT_QUOTA_BASE_n,
ipa3_ctx->ee);
quota_base.value = ipa3_ctx->smem_restricted_bytes +
IPA_MEM_PART(stats_quota_ofst);
IPA_MEM_PART(stats_quota_ap_ofst);
quota_base.value_mask = ~0;
quota_base_pyld = ipahal_construct_imm_cmd(IPA_IMM_CMD_REGISTER_WRITE,
&quota_base, false);
@ -377,7 +396,7 @@ int ipa_init_quota_stats(u32 pipe_bitmask)
cmd.size = pyld->len;
cmd.system_addr = dma_address;
cmd.local_addr = ipa3_ctx->smem_restricted_bytes +
IPA_MEM_PART(stats_quota_ofst);
IPA_MEM_PART(stats_quota_ap_ofst);
cmd_pyld = ipahal_construct_imm_cmd(
IPA_IMM_CMD_DMA_SHARED_MEM, &cmd, false);
if (!cmd_pyld) {
@ -476,7 +495,7 @@ int ipa_get_quota_stats(struct ipa_quota_stats_all *out)
cmd.size = mem.size;
cmd.system_addr = mem.phys_base;
cmd.local_addr = ipa3_ctx->smem_restricted_bytes +
IPA_MEM_PART(stats_quota_ofst) + offset.offset;
IPA_MEM_PART(stats_quota_ap_ofst) + offset.offset;
cmd_pyld[num_cmd] = ipahal_construct_imm_cmd(
IPA_IMM_CMD_DMA_SHARED_MEM, &cmd, false);
if (!cmd_pyld[num_cmd]) {

View file

@ -2318,8 +2318,10 @@ struct ipa3_mem_partition {
u32 uc_descriptor_ram_size;
u32 pdn_config_ofst;
u32 pdn_config_size;
u32 stats_quota_ofst;
u32 stats_quota_size;
u32 stats_quota_q6_ofst;
u32 stats_quota_q6_size;
u32 stats_quota_ap_ofst;
u32 stats_quota_ap_size;
u32 stats_tethering_ofst;
u32 stats_tethering_size;
u32 stats_fnr_ofst;

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/module.h>
@ -589,10 +589,10 @@ static int ipa3_qmi_init_modem_send_sync_msg(void)
}
req.hw_stats_quota_base_addr_valid = true;
req.hw_stats_quota_base_addr =
IPA_MEM_PART(stats_quota_ofst) + smem_restr_bytes;
IPA_MEM_PART(stats_quota_q6_ofst) + smem_restr_bytes;
req.hw_stats_quota_size_valid = true;
req.hw_stats_quota_size = IPA_MEM_PART(stats_quota_size);
req.hw_stats_quota_size = IPA_MEM_PART(stats_quota_q6_size);
req.hw_drop_stats_base_addr_valid = true;
req.hw_drop_stats_base_addr =

View file

@ -3144,8 +3144,10 @@ static struct ipa3_mem_partition ipa_4_1_mem_part = {
.uc_descriptor_ram_size = 0x400,
.pdn_config_ofst = 0xbd8,
.pdn_config_size = 0x50,
.stats_quota_ofst = 0xc30,
.stats_quota_size = 0x60,
.stats_quota_q6_ofst = 0xc30,
.stats_quota_q6_size = 0x60,
.stats_quota_ap_ofst = 0,
.stats_quota_ap_size = 0,
.stats_tethering_ofst = 0xc90,
.stats_tethering_size = 0x140,
.stats_flt_v4_ofst = 0xdd0,
@ -3233,8 +3235,10 @@ static struct ipa3_mem_partition ipa_4_2_mem_part = {
.uc_descriptor_ram_size = 0x0,
.pdn_config_ofst = 0x9F8,
.pdn_config_size = 0x50,
.stats_quota_ofst = 0xa50,
.stats_quota_size = 0x60,
.stats_quota_q6_ofst = 0xa50,
.stats_quota_q6_size = 0x60,
.stats_quota_ap_ofst = 0,
.stats_quota_ap_size = 0,
.stats_tethering_ofst = 0xab0,
.stats_tethering_size = 0x140,
.stats_flt_v4_ofst = 0xbf0,
@ -3299,8 +3303,10 @@ static struct ipa3_mem_partition ipa_4_5_mem_part = {
.apps_hdr_proc_ctx_size_ddr = 0x0,
.nat_tbl_ofst = 0x1800,
.nat_tbl_size = 0xd00,
.stats_quota_ofst = 0x2510,
.stats_quota_size = 0x78,
.stats_quota_q6_ofst = 0x2510,
.stats_quota_q6_size = 0x30,
.stats_quota_ap_ofst = 0x2540,
.stats_quota_ap_size = 0x48,
.stats_tethering_ofst = 0x2588,
.stats_tethering_size = 0x238,
.stats_flt_v4_ofst = 0,
@ -3394,8 +3400,10 @@ static struct ipa3_mem_partition ipa_4_7_mem_part = {
.nat_tbl_size = 0xd00,
.pdn_config_ofst = 0x1be8,
.pdn_config_size = 0x50,
.stats_quota_ofst = 0x1c40,
.stats_quota_size = 0x78,
.stats_quota_q6_ofst = 0x1c40,
.stats_quota_q6_size = 0x30,
.stats_quota_ap_ofst = 0x1c70,
.stats_quota_ap_size = 0x48,
.stats_tethering_ofst = 0x1cb8,
.stats_tethering_size = 0x238,
.stats_flt_v4_ofst = 0,
@ -3485,8 +3493,10 @@ static struct ipa3_mem_partition ipa_4_9_mem_part = {
.apps_hdr_proc_ctx_size_ddr = 0x0,
.nat_tbl_ofst = 0x1800,
.nat_tbl_size = 0xd00,
.stats_quota_ofst = 0x2510,
.stats_quota_size = 0x78,
.stats_quota_q6_ofst = 0x2510,
.stats_quota_q6_size = 0x30,
.stats_quota_ap_ofst = 0x2540,
.stats_quota_ap_size = 0x48,
.stats_tethering_ofst = 0x2588,
.stats_tethering_size = 0x238,
.stats_flt_v4_ofst = 0,
@ -6131,13 +6141,23 @@ int ipa3_init_mem_partition(enum ipa_hw_type type)
return -ENODEV;
}
IPADBG("QUOTA STATS OFST 0x%x SIZE 0x%x\n",
IPA_MEM_PART(stats_quota_ofst),
IPA_MEM_PART(stats_quota_size));
IPADBG("Q6 QUOTA STATS OFST 0x%x SIZE 0x%x\n",
IPA_MEM_PART(stats_quota_q6_ofst),
IPA_MEM_PART(stats_quota_q6_size));
if (IPA_MEM_PART(stats_quota_ofst) & 7) {
IPAERR("QUOTA STATS OFST 0x%x is unaligned\n",
IPA_MEM_PART(stats_quota_ofst));
if (IPA_MEM_PART(stats_quota_q6_ofst) & 7) {
IPAERR("Q6 QUOTA STATS OFST 0x%x is unaligned\n",
IPA_MEM_PART(stats_quota_q6_ofst));
return -ENODEV;
}
IPADBG("AP QUOTA STATS OFST 0x%x SIZE 0x%x\n",
IPA_MEM_PART(stats_quota_ap_ofst),
IPA_MEM_PART(stats_quota_ap_size));
if (IPA_MEM_PART(stats_quota_ap_ofst) & 7) {
IPAERR("AP QUOTA STATS OFST 0x%x is unaligned\n",
IPA_MEM_PART(stats_quota_ap_ofst));
return -ENODEV;
}