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

Commit e0a9d621 authored by Ingrid Gallardo's avatar Ingrid Gallardo Committed by Steve Cohen
Browse files

drm/msm/sde: fix mdp ib bw vote calculations



Current driver divides the ib bandwidth vote based on
the number of dram channels; this is a wrong assumption
as the division needs to be only based in the number of
paths used for voting. This causes that the llcc as well
as the ebi votes are wrongly divided by two.
This change fixes this issue by dividing the ib vote
into the number of voting paths as well as removes
extra 400MBps that were added as nrt path.

Change-Id: Ibc18300aa4204478ebce8b64c88071bc014790ab
Signed-off-by: default avatarIngrid Gallardo <ingridg@codeaurora.org>
parent a0febbe6
Loading
Loading
Loading
Loading
+27 −26
Original line number Diff line number Diff line
@@ -360,7 +360,7 @@ static int _sde_power_data_bus_set_quota(
		ab_quota_nrt = max_t(u64, ab_quota_nrt,
				SDE_POWER_HANDLE_ENABLE_BUS_AB_QUOTA);
		ib_quota_nrt = max_t(u64, ib_quota_nrt,
				SDE_POWER_HANDLE_ENABLE_BUS_IB_QUOTA);
				SDE_POWER_HANDLE_ENABLE_NRT_BUS_IB_QUOTA);
	} else {
		ab_quota_rt = min_t(u64, ab_quota_rt,
				SDE_POWER_HANDLE_DISABLE_BUS_AB_QUOTA);
@@ -379,30 +379,30 @@ static int _sde_power_data_bus_set_quota(
		struct msm_bus_vectors *vect = NULL;
		struct msm_bus_scale_pdata *bw_table =
			pdbus->data_bus_scale_table;
		u32 nrt_axi_port_cnt = pdbus->nrt_axi_port_cnt;
		u32 total_axi_port_cnt = pdbus->axi_port_cnt;
		u32 rt_axi_port_cnt = total_axi_port_cnt - nrt_axi_port_cnt;
		u32 nrt_data_paths_cnt = pdbus->nrt_data_paths_cnt;
		u32 total_data_paths_cnt = pdbus->data_paths_cnt;
		u32 rt_data_paths_cnt = total_data_paths_cnt -
			nrt_data_paths_cnt;

		if (!bw_table || !total_axi_port_cnt ||
		    total_axi_port_cnt > MAX_AXI_PORT_COUNT) {
		if (!bw_table || !total_data_paths_cnt ||
		    total_data_paths_cnt > MAX_AXI_PORT_COUNT) {
			pr_err("invalid input\n");
			return -EINVAL;
		}

		if (pdbus->bus_channels) {
			ib_quota_rt = div_u64(ib_quota_rt,
						pdbus->bus_channels);
			ib_quota_nrt = div_u64(ib_quota_nrt,
						pdbus->bus_channels);
		}
		if (nrt_data_paths_cnt) {

		if (nrt_axi_port_cnt) {
			ab_quota_rt = div_u64(ab_quota_rt, rt_data_paths_cnt);
			ab_quota_nrt = div_u64(ab_quota_nrt,
						nrt_data_paths_cnt);

			ab_quota_rt = div_u64(ab_quota_rt, rt_axi_port_cnt);
			ab_quota_nrt = div_u64(ab_quota_nrt, nrt_axi_port_cnt);
			ib_quota_rt = div_u64(ib_quota_rt,
						rt_data_paths_cnt);
			ib_quota_nrt = div_u64(ib_quota_nrt,
						nrt_data_paths_cnt);

			for (i = 0; i < total_axi_port_cnt; i++) {
				if (i < rt_axi_port_cnt) {
			for (i = 0; i < total_data_paths_cnt; i++) {
				if (i < rt_data_paths_cnt) {
					ab_quota[i] = ab_quota_rt;
					ib_quota[i] = ib_quota_rt;
				} else {
@@ -412,10 +412,11 @@ static int _sde_power_data_bus_set_quota(
			}
		} else {
			ab_quota[0] = div_u64(ab_quota_rt + ab_quota_nrt,
					total_axi_port_cnt);
			ib_quota[0] = ib_quota_rt + ib_quota_nrt;
					total_data_paths_cnt);
			ib_quota[0] = div_u64(ib_quota_rt + ib_quota_nrt,
					total_data_paths_cnt);

			for (i = 1; i < total_axi_port_cnt; i++) {
			for (i = 1; i < total_data_paths_cnt; i++) {
				ab_quota[i] = ab_quota[0];
				ib_quota[i] = ib_quota[0];
			}
@@ -424,7 +425,7 @@ static int _sde_power_data_bus_set_quota(
		new_uc_idx = (pdbus->curr_bw_uc_idx %
			(bw_table->num_usecases - 1)) + 1;

		for (i = 0; i < total_axi_port_cnt; i++) {
		for (i = 0; i < total_data_paths_cnt; i++) {
			vect = &bw_table->usecase[new_uc_idx].vectors[i];
			vect->ab = ab_quota[i];
			vect->ib = ib_quota[i];
@@ -432,8 +433,8 @@ static int _sde_power_data_bus_set_quota(
			pr_debug(
				"%s uc_idx=%d %s path idx=%d ab=%llu ib=%llu\n",
				bw_table->name,
				new_uc_idx, (i < rt_axi_port_cnt) ? "rt" : "nrt"
				, i, vect->ab, vect->ib);
				new_uc_idx, (i < rt_data_paths_cnt) ?
				"rt" : "nrt", i, vect->ab, vect->ib);
		}
	}
	pdbus->curr_bw_uc_idx = new_uc_idx;
@@ -518,10 +519,10 @@ static int sde_power_data_bus_parse(struct platform_device *pdev,
		rc = 0;
	}

	pdbus->nrt_axi_port_cnt = 0;
	pdbus->nrt_data_paths_cnt = 0;
	rc = of_property_read_u32(pdev->dev.of_node,
			"qcom,sde-num-nrt-paths",
			&pdbus->nrt_axi_port_cnt);
			&pdbus->nrt_data_paths_cnt);
	if (rc) {
		pr_debug("number of axi port property not specified\n");
		rc = 0;
@@ -535,7 +536,7 @@ static int sde_power_data_bus_parse(struct platform_device *pdev,
			pr_err("Error. qcom,msm-bus,num-paths not found\n");
			return rc;
		}
		pdbus->axi_port_cnt = paths;
		pdbus->data_paths_cnt = paths;

		pdbus->data_bus_scale_table =
				msm_bus_pdata_from_node(pdev, node);
+6 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#define SDE_POWER_HANDLE_ENABLE_BUS_AB_QUOTA	0
#define SDE_POWER_HANDLE_DISABLE_BUS_AB_QUOTA	0
#define SDE_POWER_HANDLE_ENABLE_BUS_IB_QUOTA		400000000
#define SDE_POWER_HANDLE_ENABLE_NRT_BUS_IB_QUOTA	0
#define SDE_POWER_HANDLE_DISABLE_BUS_IB_QUOTA	0

#include <linux/sde_io_util.h>
@@ -101,8 +102,8 @@ struct sde_power_client {
 * struct sde_power_data_handle: power handle struct for data bus
 * @data_bus_scale_table: pointer to bus scaling table
 * @data_bus_hdl: current data bus handle
 * @axi_port_cnt: number of rt axi ports
 * @nrt_axi_port_cnt: number of nrt axi ports
 * @data_paths_cnt: number of rt data path ports
 * @nrt_data_paths_cnt: number of nrt data path ports
 * @bus_channels: number of memory bus channels
 * @curr_bw_uc_idx: current use case index of data bus
 * @ao_bw_uc_idx: active only use case index of data bus
@@ -115,8 +116,8 @@ struct sde_power_client {
struct sde_power_data_bus_handle {
	struct msm_bus_scale_pdata *data_bus_scale_table;
	u32 data_bus_hdl;
	u32 axi_port_cnt;
	u32 nrt_axi_port_cnt;
	u32 data_paths_cnt;
	u32 nrt_data_paths_cnt;
	u32 bus_channels;
	u32 curr_bw_uc_idx;
	u32 ao_bw_uc_idx;