@@ -514,6 +514,21 @@ static int tegra_actmon_start(struct tegra_devfreq *tegra)
514
514
actmon_writel (tegra , ACTMON_SAMPLING_PERIOD - 1 ,
515
515
ACTMON_GLB_PERIOD_CTRL );
516
516
517
+ /*
518
+ * CLK notifications are needed in order to reconfigure the upper
519
+ * consecutive watermark in accordance to the actual clock rate
520
+ * to avoid unnecessary upper interrupts.
521
+ */
522
+ err = clk_notifier_register (tegra -> emc_clock ,
523
+ & tegra -> clk_rate_change_nb );
524
+ if (err ) {
525
+ dev_err (tegra -> devfreq -> dev .parent ,
526
+ "Failed to register rate change notifier\n" );
527
+ return err ;
528
+ }
529
+
530
+ tegra -> cur_freq = clk_get_rate (tegra -> emc_clock ) / KHZ ;
531
+
517
532
for (i = 0 ; i < ARRAY_SIZE (tegra -> devices ); i ++ )
518
533
tegra_actmon_configure_device (tegra , & tegra -> devices [i ]);
519
534
@@ -539,6 +554,8 @@ static int tegra_actmon_start(struct tegra_devfreq *tegra)
539
554
err_stop :
540
555
tegra_actmon_stop_devices (tegra );
541
556
557
+ clk_notifier_unregister (tegra -> emc_clock , & tegra -> clk_rate_change_nb );
558
+
542
559
return err ;
543
560
}
544
561
@@ -552,6 +569,8 @@ static void tegra_actmon_stop(struct tegra_devfreq *tegra)
552
569
cancel_delayed_work_sync (& tegra -> cpufreq_update_work );
553
570
554
571
tegra_actmon_stop_devices (tegra );
572
+
573
+ clk_notifier_unregister (tegra -> emc_clock , & tegra -> clk_rate_change_nb );
555
574
}
556
575
557
576
static int tegra_devfreq_target (struct device * dev , unsigned long * freq ,
@@ -768,7 +787,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
768
787
return rate ;
769
788
}
770
789
771
- tegra -> cur_freq = clk_get_rate (tegra -> emc_clock ) / KHZ ;
772
790
tegra -> max_freq = rate / KHZ ;
773
791
774
792
for (i = 0 ; i < ARRAY_SIZE (actmon_device_configs ); i ++ ) {
@@ -796,27 +814,20 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
796
814
797
815
platform_set_drvdata (pdev , tegra );
798
816
817
+ tegra -> clk_rate_change_nb .notifier_call = tegra_actmon_clk_notify_cb ;
799
818
tegra -> cpu_rate_change_nb .notifier_call = tegra_actmon_cpu_notify_cb ;
800
819
801
820
INIT_DELAYED_WORK (& tegra -> cpufreq_update_work ,
802
821
tegra_actmon_delayed_update );
803
822
804
- tegra -> clk_rate_change_nb .notifier_call = tegra_actmon_clk_notify_cb ;
805
- err = clk_notifier_register (tegra -> emc_clock ,
806
- & tegra -> clk_rate_change_nb );
807
- if (err ) {
808
- dev_err (& pdev -> dev ,
809
- "Failed to register rate change notifier\n" );
810
- goto remove_opps ;
811
- }
812
-
813
823
err = devfreq_add_governor (& tegra_devfreq_governor );
814
824
if (err ) {
815
825
dev_err (& pdev -> dev , "Failed to add governor: %d\n" , err );
816
- goto unreg_notifier ;
826
+ goto remove_opps ;
817
827
}
818
828
819
- tegra_devfreq_profile .initial_freq = tegra -> cur_freq ;
829
+ tegra_devfreq_profile .initial_freq = clk_get_rate (tegra -> emc_clock );
830
+ tegra_devfreq_profile .initial_freq /= KHZ ;
820
831
821
832
devfreq = devfreq_add_device (& pdev -> dev , & tegra_devfreq_profile ,
822
833
"tegra_actmon" , NULL );
@@ -830,9 +841,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
830
841
remove_governor :
831
842
devfreq_remove_governor (& tegra_devfreq_governor );
832
843
833
- unreg_notifier :
834
- clk_notifier_unregister (tegra -> emc_clock , & tegra -> clk_rate_change_nb );
835
-
836
844
remove_opps :
837
845
dev_pm_opp_remove_all_dynamic (& pdev -> dev );
838
846
@@ -849,7 +857,6 @@ static int tegra_devfreq_remove(struct platform_device *pdev)
849
857
devfreq_remove_device (tegra -> devfreq );
850
858
devfreq_remove_governor (& tegra_devfreq_governor );
851
859
852
- clk_notifier_unregister (tegra -> emc_clock , & tegra -> clk_rate_change_nb );
853
860
dev_pm_opp_remove_all_dynamic (& pdev -> dev );
854
861
855
862
reset_control_reset (tegra -> reset );
0 commit comments