]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
memory: tegra: Make CPU cluster BW request a multiple of MC channels
authorSumit Gupta <sumitg@nvidia.com>
Thu, 11 May 2023 17:32:08 +0000 (23:02 +0530)
committerThierry Reding <treding@nvidia.com>
Tue, 16 May 2023 10:11:01 +0000 (12:11 +0200)
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>
drivers/memory/tegra/mc.c
drivers/memory/tegra/mc.h
drivers/memory/tegra/tegra234.c
include/soc/tegra/mc.h

index 983455b1f98d65cae95801944444142864e7a475..4a750da1c12aaee09a1e17ea0108b01ac55aa52d 100644 (file)
@@ -843,6 +843,23 @@ remove_nodes:
        return err;
 }
 
+static void tegra_mc_num_channel_enabled(struct tegra_mc *mc)
+{
+       unsigned int i;
+       u32 value;
+
+       value = mc_ch_readl(mc, 0, MC_EMEM_ADR_CFG_CHANNEL_ENABLE);
+       if (value <= 0) {
+               mc->num_channels = mc->soc->num_channels;
+               return;
+       }
+
+       for (i = 0; i < 32; i++) {
+               if (value & BIT(i))
+                       mc->num_channels++;
+       }
+}
+
 static int tegra_mc_probe(struct platform_device *pdev)
 {
        struct tegra_mc *mc;
@@ -881,6 +898,8 @@ static int tegra_mc_probe(struct platform_device *pdev)
                        return err;
        }
 
+       tegra_mc_num_channel_enabled(mc);
+
        if (mc->soc->ops && mc->soc->ops->handle_irq) {
                mc->irq = platform_get_irq(pdev, 0);
                if (mc->irq < 0)
index bc01586b65602cc2259a6ef7dfe52477605cac2d..c3f6655bec60e8cc40aeb1caf29b4c9d7b86f48d 100644 (file)
@@ -53,6 +53,7 @@
 #define MC_ERR_ROUTE_SANITY_ADR                                0x9c4
 #define MC_ERR_GENERALIZED_CARVEOUT_STATUS             0xc00
 #define MC_ERR_GENERALIZED_CARVEOUT_ADR                        0xc04
+#define MC_EMEM_ADR_CFG_CHANNEL_ENABLE                 0xdf8
 #define MC_GLOBAL_INTSTATUS                            0xf24
 #define MC_ERR_ADR_HI                                  0x11fc
 
index 0fa68862749fc06d88baa2bf1b56f898be8de5cb..8e873a7bc34f29b98fc762e22b801037d58bffec 100644 (file)
@@ -867,6 +867,28 @@ error:
        return ret;
 }
 
+static int tegra234_mc_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
+                                    u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
+{
+       struct icc_provider *p = node->provider;
+       struct tegra_mc *mc = icc_provider_to_tegra_mc(p);
+
+       if (!mc->bwmgr_mrq_supported)
+               return -EINVAL;
+
+       if (node->id == TEGRA_ICC_MC_CPU_CLUSTER0 ||
+           node->id == TEGRA_ICC_MC_CPU_CLUSTER1 ||
+           node->id == TEGRA_ICC_MC_CPU_CLUSTER2) {
+               if (mc)
+                       peak_bw = peak_bw * mc->num_channels;
+       }
+
+       *agg_avg += avg_bw;
+       *agg_peak = max(*agg_peak, peak_bw);
+
+       return 0;
+}
+
 static struct icc_node*
 tegra234_mc_of_icc_xlate(struct of_phandle_args *spec, void *data)
 {
@@ -898,7 +920,7 @@ static int tegra234_mc_icc_get_init_bw(struct icc_node *node, u32 *avg, u32 *pea
 
 static const struct tegra_mc_icc_ops tegra234_mc_icc_ops = {
        .xlate = tegra234_mc_of_icc_xlate,
-       .aggregate = icc_std_aggregate,
+       .aggregate = tegra234_mc_icc_aggregate,
        .get_bw = tegra234_mc_icc_get_init_bw,
        .set = tegra234_mc_icc_set,
 };
index 900d88b26fae697bf28cdc5e27b5a69f121d44be..fc3001483e6242cd2d2c9d726ae8d103fa0c879b 100644 (file)
@@ -234,6 +234,7 @@ struct tegra_mc {
 
        struct tegra_mc_timing *timings;
        unsigned int num_timings;
+       unsigned int num_channels;
 
        bool bwmgr_mrq_supported;
        struct reset_controller_dev reset;