Skip to content

Commit e852af7

Browse files
Sumit Guptathierryreding
authored andcommitted
memory: tegra: Make CPU cluster BW request a multiple of MC channels
Make CPU cluster's bandwidth (BW) request a multiple of MC channels. CPU OPP tables have BW info per MC channel. But, the actual BW depends on the number of MC channels which can change as per the boot config. Get the number of MC channels which are actually enabled in current boot configuration and multiply the BW request from a CPU cluster with the number of enabled MC channels. This is not required to be done for other MC clients. Signed-off-by: Sumit Gupta <sumitg@nvidia.com> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Thierry Reding <treding@nvidia.com>
1 parent 80b19e0 commit e852af7

4 files changed

Lines changed: 44 additions & 1 deletion

File tree

drivers/memory/tegra/mc.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,23 @@ static int tegra_mc_interconnect_setup(struct tegra_mc *mc)
843843
return err;
844844
}
845845

846+
static void tegra_mc_num_channel_enabled(struct tegra_mc *mc)
847+
{
848+
unsigned int i;
849+
u32 value;
850+
851+
value = mc_ch_readl(mc, 0, MC_EMEM_ADR_CFG_CHANNEL_ENABLE);
852+
if (value <= 0) {
853+
mc->num_channels = mc->soc->num_channels;
854+
return;
855+
}
856+
857+
for (i = 0; i < 32; i++) {
858+
if (value & BIT(i))
859+
mc->num_channels++;
860+
}
861+
}
862+
846863
static int tegra_mc_probe(struct platform_device *pdev)
847864
{
848865
struct tegra_mc *mc;
@@ -881,6 +898,8 @@ static int tegra_mc_probe(struct platform_device *pdev)
881898
return err;
882899
}
883900

901+
tegra_mc_num_channel_enabled(mc);
902+
884903
if (mc->soc->ops && mc->soc->ops->handle_irq) {
885904
mc->irq = platform_get_irq(pdev, 0);
886905
if (mc->irq < 0)

drivers/memory/tegra/mc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#define MC_ERR_ROUTE_SANITY_ADR 0x9c4
5454
#define MC_ERR_GENERALIZED_CARVEOUT_STATUS 0xc00
5555
#define MC_ERR_GENERALIZED_CARVEOUT_ADR 0xc04
56+
#define MC_EMEM_ADR_CFG_CHANNEL_ENABLE 0xdf8
5657
#define MC_GLOBAL_INTSTATUS 0xf24
5758
#define MC_ERR_ADR_HI 0x11fc
5859

drivers/memory/tegra/tegra234.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,28 @@ static int tegra234_mc_icc_set(struct icc_node *src, struct icc_node *dst)
867867
return ret;
868868
}
869869

870+
static int tegra234_mc_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
871+
u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
872+
{
873+
struct icc_provider *p = node->provider;
874+
struct tegra_mc *mc = icc_provider_to_tegra_mc(p);
875+
876+
if (!mc->bwmgr_mrq_supported)
877+
return -EINVAL;
878+
879+
if (node->id == TEGRA_ICC_MC_CPU_CLUSTER0 ||
880+
node->id == TEGRA_ICC_MC_CPU_CLUSTER1 ||
881+
node->id == TEGRA_ICC_MC_CPU_CLUSTER2) {
882+
if (mc)
883+
peak_bw = peak_bw * mc->num_channels;
884+
}
885+
886+
*agg_avg += avg_bw;
887+
*agg_peak = max(*agg_peak, peak_bw);
888+
889+
return 0;
890+
}
891+
870892
static struct icc_node*
871893
tegra234_mc_of_icc_xlate(struct of_phandle_args *spec, void *data)
872894
{
@@ -898,7 +920,7 @@ static int tegra234_mc_icc_get_init_bw(struct icc_node *node, u32 *avg, u32 *pea
898920

899921
static const struct tegra_mc_icc_ops tegra234_mc_icc_ops = {
900922
.xlate = tegra234_mc_of_icc_xlate,
901-
.aggregate = icc_std_aggregate,
923+
.aggregate = tegra234_mc_icc_aggregate,
902924
.get_bw = tegra234_mc_icc_get_init_bw,
903925
.set = tegra234_mc_icc_set,
904926
};

include/soc/tegra/mc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ struct tegra_mc {
234234

235235
struct tegra_mc_timing *timings;
236236
unsigned int num_timings;
237+
unsigned int num_channels;
237238

238239
bool bwmgr_mrq_supported;
239240
struct reset_controller_dev reset;

0 commit comments

Comments
 (0)