@@ -609,10 +609,19 @@ static int policy_set_boost(struct cpufreq_policy *policy, bool enable)
609609 policy -> boost_enabled = enable ;
610610
611611 ret = cpufreq_driver -> set_boost (policy , enable );
612- if (ret )
612+ if (ret ) {
613613 policy -> boost_enabled = !policy -> boost_enabled ;
614+ return ret ;
615+ }
614616
615- return ret ;
617+ ret = freq_qos_update_request (& policy -> boost_freq_req , policy -> cpuinfo .max_freq );
618+ if (ret < 0 ) {
619+ policy -> boost_enabled = !policy -> boost_enabled ;
620+ cpufreq_driver -> set_boost (policy , policy -> boost_enabled );
621+ return ret ;
622+ }
623+
624+ return 0 ;
616625}
617626
618627static ssize_t store_local_boost (struct cpufreq_policy * policy ,
@@ -760,7 +769,7 @@ static ssize_t store_##file_name \
760769 if (ret) \
761770 return ret; \
762771 \
763- ret = freq_qos_update_request(policy->object##_freq_req, val);\
772+ ret = freq_qos_update_request(& policy->object##_freq_req, val); \
764773 return ret >= 0 ? count : ret; \
765774}
766775
@@ -1365,19 +1374,21 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)
13651374 /* Cancel any pending policy->update work before freeing the policy. */
13661375 cancel_work_sync (& policy -> update );
13671376
1368- if (policy -> max_freq_req ) {
1377+ if (freq_qos_request_active ( & policy -> max_freq_req ) ) {
13691378 /*
13701379 * Remove max_freq_req after sending CPUFREQ_REMOVE_POLICY
13711380 * notification, since CPUFREQ_CREATE_POLICY notification was
13721381 * sent after adding max_freq_req earlier.
13731382 */
13741383 blocking_notifier_call_chain (& cpufreq_policy_notifier_list ,
13751384 CPUFREQ_REMOVE_POLICY , policy );
1376- freq_qos_remove_request (policy -> max_freq_req );
1385+ freq_qos_remove_request (& policy -> max_freq_req );
13771386 }
13781387
1379- freq_qos_remove_request (policy -> min_freq_req );
1380- kfree (policy -> min_freq_req );
1388+ if (freq_qos_request_active (& policy -> min_freq_req ))
1389+ freq_qos_remove_request (& policy -> min_freq_req );
1390+ if (freq_qos_request_active (& policy -> boost_freq_req ))
1391+ freq_qos_remove_request (& policy -> boost_freq_req );
13811392
13821393 cpufreq_policy_put_kobj (policy );
13831394 free_cpumask_var (policy -> real_cpus );
@@ -1447,47 +1458,29 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
14471458 add_cpu_dev_symlink (policy , j , get_cpu_device (j ));
14481459 }
14491460
1450- policy -> min_freq_req = kzalloc (2 * sizeof (* policy -> min_freq_req ),
1451- GFP_KERNEL );
1452- if (!policy -> min_freq_req ) {
1453- ret = - ENOMEM ;
1454- goto out_destroy_policy ;
1461+ if (policy -> boost_supported ) {
1462+ ret = freq_qos_add_request (& policy -> constraints ,
1463+ & policy -> boost_freq_req ,
1464+ FREQ_QOS_MAX ,
1465+ policy -> cpuinfo .max_freq );
1466+ if (ret < 0 )
1467+ goto out_destroy_policy ;
14551468 }
14561469
14571470 ret = freq_qos_add_request (& policy -> constraints ,
1458- policy -> min_freq_req , FREQ_QOS_MIN ,
1471+ & policy -> min_freq_req , FREQ_QOS_MIN ,
14591472 FREQ_QOS_MIN_DEFAULT_VALUE );
1460- if (ret < 0 ) {
1461- /*
1462- * So we don't call freq_qos_remove_request() for an
1463- * uninitialized request.
1464- */
1465- kfree (policy -> min_freq_req );
1466- policy -> min_freq_req = NULL ;
1473+ if (ret < 0 )
14671474 goto out_destroy_policy ;
1468- }
1469-
1470- /*
1471- * This must be initialized right here to avoid calling
1472- * freq_qos_remove_request() on uninitialized request in case
1473- * of errors.
1474- */
1475- policy -> max_freq_req = policy -> min_freq_req + 1 ;
14761475
14771476 ret = freq_qos_add_request (& policy -> constraints ,
1478- policy -> max_freq_req , FREQ_QOS_MAX ,
1477+ & policy -> max_freq_req , FREQ_QOS_MAX ,
14791478 FREQ_QOS_MAX_DEFAULT_VALUE );
1480- if (ret < 0 ) {
1481- policy -> max_freq_req = NULL ;
1479+ if (ret < 0 )
14821480 goto out_destroy_policy ;
1483- }
14841481
14851482 blocking_notifier_call_chain (& cpufreq_policy_notifier_list ,
14861483 CPUFREQ_CREATE_POLICY , policy );
1487- } else {
1488- ret = freq_qos_update_request (policy -> max_freq_req , policy -> max );
1489- if (ret < 0 )
1490- goto out_destroy_policy ;
14911484 }
14921485
14931486 if (cpufreq_driver -> get && has_target ()) {
@@ -2364,8 +2357,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
23642357 target_freq = __resolve_freq (policy , target_freq , policy -> min ,
23652358 policy -> max , relation );
23662359
2367- pr_debug ("target for CPU %u: %u kHz, relation %u, requested %u kHz\n" ,
2368- policy -> cpu , target_freq , relation , old_target_freq );
2360+ pr_debug ("CPU %u: cur %u kHz -> target %u kHz (req %u kHz, rel %u) \n" ,
2361+ policy -> cpu , policy -> cur , target_freq , old_target_freq , relation );
23692362
23702363 /*
23712364 * This might look like a redundant call as we are checking it again
@@ -2789,16 +2782,10 @@ int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
27892782 return - ENXIO ;
27902783
27912784 ret = cpufreq_frequency_table_cpuinfo (policy );
2792- if (ret ) {
2785+ if (ret )
27932786 pr_err ("%s: Policy frequency update failed\n" , __func__ );
2794- return ret ;
2795- }
2796-
2797- ret = freq_qos_update_request (policy -> max_freq_req , policy -> max );
2798- if (ret < 0 )
2799- return ret ;
28002787
2801- return 0 ;
2788+ return ret ;
28022789}
28032790EXPORT_SYMBOL_GPL (cpufreq_boost_set_sw );
28042791
0 commit comments