ARM: tegra11: clock: Account for memory access efficiency.
Alex Frid [Thu, 13 Sep 2012 03:32:31 +0000 (20:32 -0700)]
Change-Id: I6e2f45f35e8bd51f54bef12743a12d265dfde8e0
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/132027
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>

arch/arm/mach-tegra/tegra11_clocks.c
arch/arm/mach-tegra/tegra11_emc.c
arch/arm/mach-tegra/tegra11_emc.h

index ead4cde..a4632cc 100644 (file)
@@ -4493,6 +4493,7 @@ static unsigned long tegra11_clk_shared_bus_update(
        unsigned long rate = bus->min_rate;
        unsigned long bw = 0;
        unsigned long ceiling = bus->max_rate;
+       u8 emc_bw_efficiency = tegra_emc_bw_efficiency;
 
        list_for_each_entry(c, &bus->shared_bus_list,
                        u.shared_bus_user.node) {
@@ -4536,6 +4537,13 @@ static unsigned long tegra11_clk_shared_bus_update(
                                slow = c;
                }
        }
+
+       if ((bus->flags & PERIPH_EMC_ENB) && bw && (emc_bw_efficiency < 100)) {
+               bw = emc_bw_efficiency ?
+                       (bw / emc_bw_efficiency) : bus->max_rate;
+               bw = (bw < bus->max_rate / 100) ? (bw * 100) : bus->max_rate;
+       }
+
        rate = min(max(rate, bw), ceiling);
 
        if (bus_top)
index 3c88891..31cc927 100644 (file)
@@ -45,6 +45,8 @@ static bool emc_enable;
 #endif
 module_param(emc_enable, bool, 0644);
 
+u8 tegra_emc_bw_efficiency = 100;
+
 #define PLL_C_DIRECT_FLOOR             333500000
 #define EMC_STATUS_UPDATE_TIMEOUT      100
 #define TEGRA_EMC_TABLE_MAX_SIZE       16
@@ -641,6 +643,22 @@ static const struct file_operations emc_stats_fops = {
        .release        = single_release,
 };
 
+static int efficiency_get(void *data, u64 *val)
+{
+       *val = tegra_emc_bw_efficiency;
+       return 0;
+}
+static int efficiency_set(void *data, u64 val)
+{
+       tegra_emc_bw_efficiency = (val > 100) ? 100 : val;
+       if (emc)
+               tegra_clk_shared_bus_update(emc);
+
+       return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(efficiency_fops, efficiency_get,
+                       efficiency_set, "%llu\n");
+
 static int __init tegra_emc_debug_init(void)
 {
        if (!tegra_emc_table)
@@ -658,6 +676,10 @@ static int __init tegra_emc_debug_init(void)
                emc_debugfs_root, (u32 *)&clkchange_delay))
                goto err_out;
 
+       if (!debugfs_create_file("efficiency", S_IRUGO | S_IWUSR,
+                                emc_debugfs_root, NULL, &efficiency_fops))
+               goto err_out;
+
        return 0;
 
 err_out:
index e2b2319..d051c69 100644 (file)
@@ -25,6 +25,9 @@ struct clk;
 
 int tegra11_emc_init(void);
 
+/* FIXME: can be common declaration on all tegra arch */
+extern u8 tegra_emc_bw_efficiency;
+
 void tegra_emc_dram_type_init(struct clk *c);
 int tegra_emc_get_dram_type(void);