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

Commit 831343aa authored by Skylar Chang's avatar Skylar Chang
Browse files

msm: ipa3: support ipa clk scaling for pcie modem



Add the QMI support to change ipa clk scaling
from PCIE modem.

Change-Id: Iee77ff4b8027c2a042f2e6c640749cdec09d92dc
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent edf9b17c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -6708,7 +6708,7 @@ static int get_ipa_dts_pm_info(struct platform_device *pdev,

		result = of_property_read_string_index(pdev->dev.of_node,
			"qcom,scaling-exceptions",
			i * ipa_drv_res->pm_init.threshold_size,
			i * (ipa_drv_res->pm_init.threshold_size + 1),
			&ex[i].usecase);
		if (result) {
			IPAERR("failed to read qcom,scaling-exceptions");
@@ -6721,7 +6721,8 @@ static int get_ipa_dts_pm_info(struct platform_device *pdev,
			result = of_property_read_string_index(
				pdev->dev.of_node,
				"qcom,scaling-exceptions",
				i * ipa_drv_res->pm_init.threshold_size + j + 1,
				i * (ipa_drv_res->pm_init.threshold_size + 1)
				+ j + 1,
				&str);
			if (result) {
				IPAERR("failed to read qcom,scaling-exceptions"
+29 −4
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include "../ipa_rm_i.h"
#include "ipahal/ipahal_nat.h"
#include "ipa_odl.h"
#include "ipa_qmi_service.h"

#define IPA_MAX_ENTRY_STRING_LEN 500
#define IPA_MAX_MSG_LEN 4096
@@ -319,17 +320,41 @@ static ssize_t ipa3_write_keep_awake(struct file *file, const char __user *buf,
{
	s8 option = 0;
	int ret;
	uint32_t bw_mbps = 0;

	ret = kstrtos8_from_user(buf, count, 0, &option);
	if (ret)
		return ret;

	if (option == 1)
		IPA_ACTIVE_CLIENTS_INC_SIMPLE();
	else if (option == 0)
	switch (option) {
	case 0:
		IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
	else
		bw_mbps = 0;
		break;
	case 1:
		IPA_ACTIVE_CLIENTS_INC_SIMPLE();
		bw_mbps = 0;
		break;
	case 2:
		IPA_ACTIVE_CLIENTS_INC_SIMPLE();
		bw_mbps = 700;
		break;
	case 3:
		IPA_ACTIVE_CLIENTS_INC_SIMPLE();
		bw_mbps = 3000;
		break;
	case 4:
		IPA_ACTIVE_CLIENTS_INC_SIMPLE();
		bw_mbps = 7000;
		break;
	default:
		pr_err("Not support this vote (%d)\n", option);
		return -EFAULT;
	}
	if (ipa3_vote_for_bus_bw(&bw_mbps)) {
		IPAERR("Failed to vote for bus BW (%u)\n", bw_mbps);
		return -EFAULT;
	}

	return count;
}
+41 −1
Original line number Diff line number Diff line
@@ -318,6 +318,30 @@ int ipa_setup_odl_pipe(void)

}

/**
 * ipa3_odl_register_pm - Register odl client for PM
 *
 * This function will register 1 client with IPA PM to represent odl
 * in clock scaling calculation:
 *	- "ODL" - this client will be activated when pipe connected
 */
static int ipa3_odl_register_pm(void)
{
	int result = 0;
	struct ipa_pm_register_params pm_reg;

	memset(&pm_reg, 0, sizeof(pm_reg));
	pm_reg.name = "ODL";
	pm_reg.group = IPA_PM_GROUP_DEFAULT;
	pm_reg.skip_clk_vote = true;
	result = ipa_pm_register(&pm_reg, &ipa3_odl_ctx->odl_pm_hdl);
	if (result) {
		IPAERR("failed to create IPA PM client %d\n", result);
		return result;
	}
	return result;
}

int ipa3_odl_pipe_open(void)
{
	int ret = 0;
@@ -367,6 +391,10 @@ static int ipa_adpl_open(struct inode *inode, struct file *filp)
	IPADBG("Called the function :\n");
	if (ipa3_odl_ctx->odl_state.odl_init &&
				!ipa3_odl_ctx->odl_state.adpl_open) {
		/* Activate ipa_pm*/
		ret = ipa_pm_activate_sync(ipa3_odl_ctx->odl_pm_hdl);
		if (ret)
			IPAERR("failed to activate pm\n");
		ipa3_odl_ctx->odl_state.adpl_open = true;
		ret = ipa3_odl_pipe_open();
	} else {
@@ -380,8 +408,13 @@ static int ipa_adpl_open(struct inode *inode, struct file *filp)

static int ipa_adpl_release(struct inode *inode, struct file *filp)
{
	int ret = 0;
	/* Deactivate ipa_pm */
	ret = ipa_pm_deactivate_sync(ipa3_odl_ctx->odl_pm_hdl);
	if (ret)
		IPAERR("failed to activate pm\n");
	ipa3_odl_pipe_cleanup(false);
	return 0;
	return ret;
}

void ipa3_odl_pipe_cleanup(bool is_ssr)
@@ -668,6 +701,13 @@ int ipa_odl_init(void)
	}

	ipa3_odl_ctx->odl_state.odl_init = true;

	/* register ipa_pm */
	result = ipa3_odl_register_pm();
	if (result) {
		IPAWANERR("ipa3_odl_register_pm failed, ret: %d\n",
				result);
	}
	return 0;
cdev1_add_fail:
	device_destroy(odl_cdev[1].class, odl_cdev[1].dev_num);
+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 */

#ifndef _IPA3_ODL_H_
@@ -56,6 +56,7 @@ struct ipa_odl_context {
	struct odl_state_bit_mask odl_state;
	bool odl_ctl_msg_wq_flag;
	struct ipa3_odlstats stats;
	u32 odl_pm_hdl;
};

struct ipa3_push_msg_odl {
+10 −3
Original line number Diff line number Diff line
@@ -361,7 +361,7 @@ static int do_clk_scaling(void)
	mutex_unlock(&ipa_pm_ctx->client_mutex);

	for (i = 0; i < clk_scaling->threshold_size; i++) {
		if (tput > clk_scaling->current_threshold[i])
		if (tput >= clk_scaling->current_threshold[i])
			new_th_idx++;
	}

@@ -526,15 +526,19 @@ static int find_next_open_array_element(const char *name)
 */
static int add_client_to_exception_list(u32 hdl)
{
	int i;
	int i, len = 0;
	struct ipa_pm_exception_list *exception;

	mutex_lock(&ipa_pm_ctx->client_mutex);
	len = strlen(ipa_pm_ctx->clients[hdl]->name);
	for (i = 0; i < ipa_pm_ctx->clk_scaling.exception_size; i++) {
		exception = &ipa_pm_ctx->clk_scaling.exception_list[i];
		if (strnstr(exception->clients, ipa_pm_ctx->clients[hdl]->name,
			strlen(exception->clients))) {
			len) && (strlen(exception->clients)
			== len)) {
			exception->pending--;
			IPA_PM_DBG("Pending: %d\n",
			exception->pending);

			if (exception->pending < 0) {
				WARN_ON(1);
@@ -568,6 +572,8 @@ static int remove_client_from_exception_list(u32 hdl)
		exception = &ipa_pm_ctx->clk_scaling.exception_list[i];
		if (exception->bitmask & (1 << hdl)) {
			exception->pending++;
			IPA_PM_DBG("Pending: %d\n",
			exception->pending);
			exception->bitmask &= ~(1 << hdl);
		}
	}
@@ -651,6 +657,7 @@ int ipa_pm_init(struct ipa_pm_init_params *params)
				clk_scaling->exception_list[i].pending++;
		}

		/* for the first client */
		clk_scaling->exception_list[i].pending++;
		IPA_PM_DBG("Pending: %d\n",
			clk_scaling->exception_list[i].pending);
Loading