Skip to content

Commit 6a575e8

Browse files
digetxchanwoochoi
authored andcommitted
PM / devfreq: tegra30: Separate configurations per-SoC generation
Previously we were using count-weight of the T124 for T30 in order to get EMC clock rate that was reasonable for T30. In fact the count-weight should be x2 times smaller on T30, but then devfreq was producing a bit too low EMC clock rate for ISO memory clients, like display controller for example. Now both Tegra ACTMON and Tegra DRM display drivers support interconnect framework and display driver tells to ICC what a minimum memory bandwidth is needed, preventing FIFO underflows. Thus, now we can use a proper count-weight value for Tegra30 and MC_ALL device config needs a bit more aggressive boosting. Add a separate ACTMON driver configuration that is specific to Tegra30. Tested-by: Peter Geis <[email protected]> Tested-by: Nicolas Chauvet <[email protected]> Acked-by: Chanwoo Choi <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Chanwoo Choi <[email protected]>
1 parent 16e8b2a commit 6a575e8

File tree

1 file changed

+54
-14
lines changed

1 file changed

+54
-14
lines changed

drivers/devfreq/tegra30-devfreq.c

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@
5757
#define ACTMON_BELOW_WMARK_WINDOW 3
5858
#define ACTMON_BOOST_FREQ_STEP 16000
5959

60-
/*
61-
* Activity counter is incremented every 256 memory transactions, and each
62-
* transaction takes 4 EMC clocks for Tegra124; So the COUNT_WEIGHT is
63-
* 4 * 256 = 1024.
64-
*/
65-
#define ACTMON_COUNT_WEIGHT 0x400
66-
6760
/*
6861
* ACTMON_AVERAGE_WINDOW_LOG2: default value for @DEV_CTRL_K_VAL, which
6962
* translates to 2 ^ (K_VAL + 1). ex: 2 ^ (6 + 1) = 128
@@ -111,7 +104,7 @@ enum tegra_actmon_device {
111104
MCCPU,
112105
};
113106

114-
static const struct tegra_devfreq_device_config actmon_device_configs[] = {
107+
static const struct tegra_devfreq_device_config tegra124_device_configs[] = {
115108
{
116109
/* MCALL: All memory accesses (including from the CPUs) */
117110
.offset = 0x1c0,
@@ -133,6 +126,28 @@ static const struct tegra_devfreq_device_config actmon_device_configs[] = {
133126
},
134127
};
135128

129+
static const struct tegra_devfreq_device_config tegra30_device_configs[] = {
130+
{
131+
/* MCALL: All memory accesses (including from the CPUs) */
132+
.offset = 0x1c0,
133+
.irq_mask = 1 << 26,
134+
.boost_up_coeff = 200,
135+
.boost_down_coeff = 50,
136+
.boost_up_threshold = 20,
137+
.boost_down_threshold = 10,
138+
},
139+
{
140+
/* MCCPU: memory accesses from the CPUs */
141+
.offset = 0x200,
142+
.irq_mask = 1 << 25,
143+
.boost_up_coeff = 800,
144+
.boost_down_coeff = 40,
145+
.boost_up_threshold = 27,
146+
.boost_down_threshold = 10,
147+
.avg_dependency_threshold = 16000, /* 16MHz in kHz units */
148+
},
149+
};
150+
136151
/**
137152
* struct tegra_devfreq_device - state specific to an ACTMON device
138153
*
@@ -155,6 +170,12 @@ struct tegra_devfreq_device {
155170
unsigned long target_freq;
156171
};
157172

173+
struct tegra_devfreq_soc_data {
174+
const struct tegra_devfreq_device_config *configs;
175+
/* Weight value for count measurements */
176+
unsigned int count_weight;
177+
};
178+
158179
struct tegra_devfreq {
159180
struct devfreq *devfreq;
160181
struct opp_table *opp_table;
@@ -171,11 +192,13 @@ struct tegra_devfreq {
171192
struct delayed_work cpufreq_update_work;
172193
struct notifier_block cpu_rate_change_nb;
173194

174-
struct tegra_devfreq_device devices[ARRAY_SIZE(actmon_device_configs)];
195+
struct tegra_devfreq_device devices[2];
175196

176197
unsigned int irq;
177198

178199
bool started;
200+
201+
const struct tegra_devfreq_soc_data *soc;
179202
};
180203

181204
struct tegra_actmon_emc_ratio {
@@ -488,7 +511,7 @@ static void tegra_actmon_configure_device(struct tegra_devfreq *tegra,
488511
tegra_devfreq_update_avg_wmark(tegra, dev);
489512
tegra_devfreq_update_wmark(tegra, dev);
490513

491-
device_writel(dev, ACTMON_COUNT_WEIGHT, ACTMON_DEV_COUNT_WEIGHT);
514+
device_writel(dev, tegra->soc->count_weight, ACTMON_DEV_COUNT_WEIGHT);
492515
device_writel(dev, ACTMON_INTR_STATUS_CLEAR, ACTMON_DEV_INTR_STATUS);
493516

494517
val |= ACTMON_DEV_CTRL_ENB_PERIODIC;
@@ -779,6 +802,8 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
779802
if (!tegra)
780803
return -ENOMEM;
781804

805+
tegra->soc = of_device_get_match_data(&pdev->dev);
806+
782807
tegra->regs = devm_platform_ioremap_resource(pdev, 0);
783808
if (IS_ERR(tegra->regs))
784809
return PTR_ERR(tegra->regs);
@@ -852,9 +877,9 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
852877

853878
tegra->max_freq = rate / KHZ;
854879

855-
for (i = 0; i < ARRAY_SIZE(actmon_device_configs); i++) {
880+
for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) {
856881
dev = tegra->devices + i;
857-
dev->config = actmon_device_configs + i;
882+
dev->config = tegra->soc->configs + i;
858883
dev->regs = tegra->regs + dev->config->offset;
859884
}
860885

@@ -916,9 +941,24 @@ static int tegra_devfreq_remove(struct platform_device *pdev)
916941
return 0;
917942
}
918943

944+
static const struct tegra_devfreq_soc_data tegra124_soc = {
945+
.configs = tegra124_device_configs,
946+
947+
/*
948+
* Activity counter is incremented every 256 memory transactions,
949+
* and each transaction takes 4 EMC clocks.
950+
*/
951+
.count_weight = 4 * 256,
952+
};
953+
954+
static const struct tegra_devfreq_soc_data tegra30_soc = {
955+
.configs = tegra30_device_configs,
956+
.count_weight = 2 * 256,
957+
};
958+
919959
static const struct of_device_id tegra_devfreq_of_match[] = {
920-
{ .compatible = "nvidia,tegra30-actmon" },
921-
{ .compatible = "nvidia,tegra124-actmon" },
960+
{ .compatible = "nvidia,tegra30-actmon", .data = &tegra30_soc, },
961+
{ .compatible = "nvidia,tegra124-actmon", .data = &tegra124_soc, },
922962
{ },
923963
};
924964

0 commit comments

Comments
 (0)