Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92485978 authored by Ghanim Fodi's avatar Ghanim Fodi
Browse files

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



Q6 uses only 2 pipes for stats. Split the SRAM
specific region between Q6 (2 entries) and AP
(rest 3 entries).

Change-Id: Ie9eac932a6547e03f76a2a294d69f90db1d1b190
Signed-off-by: default avatarGhanim Fodi <gfodi@codeaurora.org>
parent 310c981d
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 */

#include <linux/clk.h>
@@ -3864,22 +3864,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) {
		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_ofst) - 4);
				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_ofst));
				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,
+26 −7
Original line number Diff line number Diff line
// 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]) {
+5 −3
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 */

#ifndef _IPA3_I_H_
@@ -2238,8 +2238,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;
+3 −3
Original line number Diff line number Diff line
// 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>
@@ -590,10 +590,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 =
+32 −14
Original line number Diff line number Diff line
@@ -2956,8 +2956,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,
@@ -3045,8 +3047,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,
@@ -3111,8 +3115,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,
@@ -3206,8 +3212,10 @@ static struct ipa3_mem_partition ipa_4_7_mem_part = {
	.nat_tbl_size			= 0xd00,
	.pdn_config_ofst		= 0x24A8,
	.pdn_config_size		= 0x50,
	.stats_quota_ofst		= 0x2500,
	.stats_quota_size		= 0x78,
	.stats_quota_q6_ofst		= 0x2500,
	.stats_quota_q6_size		= 0x30,
	.stats_quota_ap_ofst		= 0x2530,
	.stats_quota_ap_size		= 0x48,
	.stats_tethering_ofst		= 0x2578,
	.stats_tethering_size		= 0x238,
	.stats_flt_v4_ofst		= 0,
@@ -5840,13 +5848,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;
	}