hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/cpufreq/cpufreq_interactive.c
....@@ -126,7 +126,6 @@
126126 struct interactive_policy *ipolicy;
127127
128128 struct irq_work irq_work;
129
- struct irq_work boost_irq_work;
130129 u64 last_sample_time;
131130 unsigned long next_sample_jiffies;
132131 bool work_in_progress;
....@@ -149,9 +148,6 @@
149148 u64 pol_hispeed_val_time; /* policy hispeed_validate_time */
150149 u64 loc_hispeed_val_time; /* per-cpu hispeed_validate_time */
151150 int cpu;
152
- unsigned int task_boost_freq;
153
- unsigned long task_boost_util;
154
- u64 task_boos_endtime;
155151 };
156152
157153 static DEFINE_PER_CPU(struct interactive_cpu, interactive_cpu);
....@@ -427,9 +423,6 @@
427423 new_freq < tunables->touchboost_freq) {
428424 new_freq = tunables->touchboost_freq;
429425 }
430
- if ((now < icpu->task_boos_endtime) && (new_freq < icpu->task_boost_freq)) {
431
- new_freq = icpu->task_boost_freq;
432
- }
433426 #endif
434427 if (policy->cur >= tunables->hispeed_freq &&
435428 new_freq > policy->cur &&
....@@ -520,7 +513,8 @@
520513 sampling_rate = icpu->ipolicy->tunables->sampling_rate;
521514 icpu->last_sample_time = local_clock();
522515 icpu->next_sample_jiffies = usecs_to_jiffies(sampling_rate) + jiffies;
523
- cpufreq_interactive_update(icpu);
516
+ icpu->work_in_progress = true;
517
+ irq_work_queue_on(&icpu->irq_work, icpu->cpu);
524518 }
525519 }
526520
....@@ -676,25 +670,31 @@
676670 unsigned long val, void *data)
677671 {
678672 struct cpufreq_freqs *freq = data;
679
- struct interactive_cpu *icpu = &per_cpu(interactive_cpu, freq->cpu);
673
+ struct cpufreq_policy *policy = freq->policy;
674
+ struct interactive_cpu *icpu;
680675 unsigned long flags;
676
+ int cpu;
681677
682678 if (val != CPUFREQ_POSTCHANGE)
683679 return 0;
684680
685
- if (!down_read_trylock(&icpu->enable_sem))
686
- return 0;
681
+ for_each_cpu(cpu, policy->cpus) {
682
+ icpu = &per_cpu(interactive_cpu, cpu);
687683
688
- if (!icpu->ipolicy) {
684
+ if (!down_read_trylock(&icpu->enable_sem))
685
+ continue;
686
+
687
+ if (!icpu->ipolicy) {
688
+ up_read(&icpu->enable_sem);
689
+ continue;
690
+ }
691
+
692
+ spin_lock_irqsave(&icpu->load_lock, flags);
693
+ update_load(icpu, cpu);
694
+ spin_unlock_irqrestore(&icpu->load_lock, flags);
695
+
689696 up_read(&icpu->enable_sem);
690
- return 0;
691697 }
692
-
693
- spin_lock_irqsave(&icpu->load_lock, flags);
694
- update_load(icpu, freq->cpu);
695
- spin_unlock_irqrestore(&icpu->load_lock, flags);
696
-
697
- up_read(&icpu->enable_sem);
698698
699699 return 0;
700700 }
....@@ -1137,15 +1137,12 @@
11371137 for_each_cpu(i, policy->cpus)
11381138 cpufreq_remove_update_util_hook(i);
11391139
1140
- synchronize_sched();
1140
+ synchronize_rcu();
11411141 }
11421142
11431143 static void icpu_cancel_work(struct interactive_cpu *icpu)
11441144 {
11451145 irq_work_sync(&icpu->irq_work);
1146
-#ifdef CONFIG_ARCH_ROCKCHIP
1147
- irq_work_sync(&icpu->boost_irq_work);
1148
-#endif
11491146 icpu->work_in_progress = false;
11501147 del_timer_sync(&icpu->slack_timer);
11511148 }
....@@ -1368,83 +1365,6 @@
13681365 attr_set = tunables->attr_set;
13691366 *tunables = backup_tunables[index];
13701367 tunables->attr_set = attr_set;
1371
- }
1372
-}
1373
-
1374
-static unsigned int get_freq_for_util(struct cpufreq_policy *policy, unsigned long util)
1375
-{
1376
- struct cpufreq_frequency_table *pos;
1377
- unsigned long max_cap, cur_cap;
1378
- unsigned int freq = 0;
1379
-
1380
- max_cap = arch_scale_cpu_capacity(NULL, policy->cpu);
1381
- cpufreq_for_each_valid_entry(pos, policy->freq_table) {
1382
- freq = pos->frequency;
1383
-
1384
- cur_cap = max_cap * freq / policy->max;
1385
- if (cur_cap > util)
1386
- break;
1387
- }
1388
-
1389
- return freq;
1390
-}
1391
-
1392
-static void task_boost_irq_work(struct irq_work *irq_work)
1393
-{
1394
- struct interactive_cpu *pcpu;
1395
- struct interactive_policy *ipolicy;
1396
- unsigned long flags[2];
1397
- u64 now, prev_boos_endtime;
1398
- unsigned int boost_freq;
1399
-
1400
- pcpu = container_of(irq_work, struct interactive_cpu, boost_irq_work);
1401
- if (!down_read_trylock(&pcpu->enable_sem))
1402
- return;
1403
-
1404
- ipolicy = pcpu->ipolicy;
1405
- if (!ipolicy)
1406
- goto out;
1407
-
1408
- if (ipolicy->policy->cur == ipolicy->policy->max)
1409
- goto out;
1410
-
1411
- now = ktime_to_us(ktime_get());
1412
- prev_boos_endtime = pcpu->task_boos_endtime;;
1413
- pcpu->task_boos_endtime = now + ipolicy->tunables->sampling_rate;
1414
- boost_freq = get_freq_for_util(ipolicy->policy, pcpu->task_boost_util);
1415
- if ((now < prev_boos_endtime) && (boost_freq <= pcpu->task_boost_freq))
1416
- goto out;
1417
- pcpu->task_boost_freq = boost_freq;
1418
-
1419
- spin_lock_irqsave(&speedchange_cpumask_lock, flags[0]);
1420
- spin_lock_irqsave(&pcpu->target_freq_lock, flags[1]);
1421
- if (pcpu->target_freq < pcpu->task_boost_freq) {
1422
- pcpu->target_freq = pcpu->task_boost_freq;
1423
- cpumask_set_cpu(pcpu->cpu, &speedchange_cpumask);
1424
- wake_up_process(speedchange_task);
1425
- }
1426
- spin_unlock_irqrestore(&pcpu->target_freq_lock, flags[1]);
1427
- spin_unlock_irqrestore(&speedchange_cpumask_lock, flags[0]);
1428
-
1429
-out:
1430
- up_read(&pcpu->enable_sem);
1431
-}
1432
-
1433
-extern unsigned long capacity_curr_of(int cpu);
1434
-
1435
-void cpufreq_task_boost(int cpu, unsigned long util)
1436
-{
1437
- struct interactive_cpu *pcpu = &per_cpu(interactive_cpu, cpu);
1438
- unsigned long cap, min_util;
1439
-
1440
- if (!speedchange_task)
1441
- return;
1442
-
1443
- min_util = util + (util >> 2);
1444
- cap = capacity_curr_of(cpu);
1445
- if (min_util > cap) {
1446
- pcpu->task_boost_util = min_util;
1447
- irq_work_queue(&pcpu->boost_irq_work);
14481368 }
14491369 }
14501370 #endif
....@@ -1675,9 +1595,6 @@
16751595 icpu = &per_cpu(interactive_cpu, cpu);
16761596
16771597 init_irq_work(&icpu->irq_work, irq_work);
1678
-#ifdef CONFIG_ARCH_ROCKCHIP
1679
- init_irq_work(&icpu->boost_irq_work, task_boost_irq_work);
1680
-#endif
16811598 spin_lock_init(&icpu->load_lock);
16821599 spin_lock_init(&icpu->target_freq_lock);
16831600 init_rwsem(&icpu->enable_sem);