@@ -839,9 +839,6 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy)
839
839
840
840
/* set default policy */
841
841
ret = cpufreq_set_policy (policy , & new_policy );
842
- policy -> user_policy .policy = policy -> policy ;
843
- policy -> user_policy .governor = policy -> governor ;
844
-
845
842
if (ret ) {
846
843
pr_debug ("setting policy failed\n" );
847
844
if (cpufreq_driver -> exit )
@@ -1016,15 +1013,17 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
1016
1013
read_unlock_irqrestore (& cpufreq_driver_lock , flags );
1017
1014
#endif
1018
1015
1019
- if (frozen )
1020
- /* Restore the saved policy when doing light-weight init */
1021
- policy = cpufreq_policy_restore (cpu );
1022
- else
1016
+ /*
1017
+ * Restore the saved policy when doing light-weight init and fall back
1018
+ * to the full init if that fails.
1019
+ */
1020
+ policy = frozen ? cpufreq_policy_restore (cpu ) : NULL ;
1021
+ if (!policy ) {
1022
+ frozen = false;
1023
1023
policy = cpufreq_policy_alloc ();
1024
-
1025
- if (!policy )
1026
- goto nomem_out ;
1027
-
1024
+ if (!policy )
1025
+ goto nomem_out ;
1026
+ }
1028
1027
1029
1028
/*
1030
1029
* In the resume path, since we restore a saved policy, the assignment
@@ -1069,8 +1068,10 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
1069
1068
*/
1070
1069
cpumask_and (policy -> cpus , policy -> cpus , cpu_online_mask );
1071
1070
1072
- policy -> user_policy .min = policy -> min ;
1073
- policy -> user_policy .max = policy -> max ;
1071
+ if (!frozen ) {
1072
+ policy -> user_policy .min = policy -> min ;
1073
+ policy -> user_policy .max = policy -> max ;
1074
+ }
1074
1075
1075
1076
blocking_notifier_call_chain (& cpufreq_policy_notifier_list ,
1076
1077
CPUFREQ_START , policy );
@@ -1101,6 +1102,11 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
1101
1102
1102
1103
cpufreq_init_policy (policy );
1103
1104
1105
+ if (!frozen ) {
1106
+ policy -> user_policy .policy = policy -> policy ;
1107
+ policy -> user_policy .governor = policy -> governor ;
1108
+ }
1109
+
1104
1110
kobject_uevent (& policy -> kobj , KOBJ_ADD );
1105
1111
up_read (& cpufreq_rwsem );
1106
1112
@@ -1118,8 +1124,11 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
1118
1124
if (cpufreq_driver -> exit )
1119
1125
cpufreq_driver -> exit (policy );
1120
1126
err_set_policy_cpu :
1121
- if (frozen )
1127
+ if (frozen ) {
1128
+ /* Do not leave stale fallback data behind. */
1129
+ per_cpu (cpufreq_cpu_data_fallback , cpu ) = NULL ;
1122
1130
cpufreq_policy_put_kobj (policy );
1131
+ }
1123
1132
cpufreq_policy_free (policy );
1124
1133
1125
1134
nomem_out :
0 commit comments