Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'pm-5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management updates from Rafael Wysocki:
"These add a new CPU ID to the RAPL power capping driver and prevent
the ACPI processor idle driver from triggering RCU-lockdep complaints.

Specifics:

- Add support for the Lakefield chip to the RAPL power capping driver
(Ricardo Neri).

- Modify the ACPI processor idle driver to prevent it from triggering
RCU-lockdep complaints which has started to happen after recent
changes in that area (Peter Zijlstra)"

* tag 'pm-5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
ACPI: processor: Take over RCU-idle for C3-BM idle
cpuidle: Allow cpuidle drivers to take over RCU-idle
ACPI: processor: Use CPUIDLE_FLAG_TLB_FLUSHED
ACPI: processor: Use CPUIDLE_FLAG_TIMER_STOP
powercap: RAPL: Add support for Lakefield

+72 -57
-2
arch/ia64/include/asm/acpi.h
··· 74 74 buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP; 75 75 } 76 76 77 - #define acpi_unlazy_tlb(x) 78 - 79 77 #ifdef CONFIG_ACPI_NUMA 80 78 extern cpumask_t early_cpu_possible_map; 81 79 #define for_each_possible_early_cpu(cpu) \
-2
arch/x86/include/asm/acpi.h
··· 159 159 extern int x86_acpi_numa_init(void); 160 160 #endif /* CONFIG_ACPI_NUMA */ 161 161 162 - #define acpi_unlazy_tlb(x) leave_mm(x) 163 - 164 162 #ifdef CONFIG_ACPI_APEI 165 163 static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) 166 164 {
+60 -48
drivers/acpi/processor_idle.c
··· 161 161 } 162 162 163 163 /* Power(C) State timer broadcast control */ 164 - static void lapic_timer_state_broadcast(struct acpi_processor *pr, 165 - struct acpi_processor_cx *cx, 166 - int broadcast) 164 + static bool lapic_timer_needs_broadcast(struct acpi_processor *pr, 165 + struct acpi_processor_cx *cx) 167 166 { 168 - int state = cx - pr->power.states; 169 - 170 - if (state >= pr->power.timer_broadcast_on_state) { 171 - if (broadcast) 172 - tick_broadcast_enter(); 173 - else 174 - tick_broadcast_exit(); 175 - } 167 + return cx - pr->power.states >= pr->power.timer_broadcast_on_state; 176 168 } 177 169 178 170 #else ··· 172 180 static void lapic_timer_check_state(int state, struct acpi_processor *pr, 173 181 struct acpi_processor_cx *cstate) { } 174 182 static void lapic_timer_propagate_broadcast(struct acpi_processor *pr) { } 175 - static void lapic_timer_state_broadcast(struct acpi_processor *pr, 176 - struct acpi_processor_cx *cx, 177 - int broadcast) 183 + 184 + static bool lapic_timer_needs_broadcast(struct acpi_processor *pr, 185 + struct acpi_processor_cx *cx) 178 186 { 179 187 } 180 188 ··· 558 566 559 567 /** 560 568 * acpi_idle_enter_bm - enters C3 with proper BM handling 569 + * @drv: cpuidle driver 561 570 * @pr: Target processor 562 571 * @cx: Target state context 563 - * @timer_bc: Whether or not to change timer mode to broadcast 572 + * @index: index of target state 564 573 */ 565 - static void acpi_idle_enter_bm(struct acpi_processor *pr, 566 - struct acpi_processor_cx *cx, bool timer_bc) 574 + static int acpi_idle_enter_bm(struct cpuidle_driver *drv, 575 + struct acpi_processor *pr, 576 + struct acpi_processor_cx *cx, 577 + int index) 567 578 { 568 - acpi_unlazy_tlb(smp_processor_id()); 569 - 570 - /* 571 - * Must be done before busmaster disable as we might need to 572 - * access HPET ! 573 - */ 574 - if (timer_bc) 575 - lapic_timer_state_broadcast(pr, cx, 1); 579 + static struct acpi_processor_cx safe_cx = { 580 + .entry_method = ACPI_CSTATE_HALT, 581 + }; 576 582 577 583 /* 578 584 * disable bus master 579 585 * bm_check implies we need ARB_DIS 580 586 * bm_control implies whether we can do ARB_DIS 581 587 * 582 - * That leaves a case where bm_check is set and bm_control is 583 - * not set. In that case we cannot do much, we enter C3 584 - * without doing anything. 588 + * That leaves a case where bm_check is set and bm_control is not set. 589 + * In that case we cannot do much, we enter C3 without doing anything. 585 590 */ 586 - if (pr->flags.bm_control) { 591 + bool dis_bm = pr->flags.bm_control; 592 + 593 + /* If we can skip BM, demote to a safe state. */ 594 + if (!cx->bm_sts_skip && acpi_idle_bm_check()) { 595 + dis_bm = false; 596 + index = drv->safe_state_index; 597 + if (index >= 0) { 598 + cx = this_cpu_read(acpi_cstate[index]); 599 + } else { 600 + cx = &safe_cx; 601 + index = -EBUSY; 602 + } 603 + } 604 + 605 + if (dis_bm) { 587 606 raw_spin_lock(&c3_lock); 588 607 c3_cpu_count++; 589 608 /* Disable bus master arbitration when all CPUs are in C3 */ ··· 603 600 raw_spin_unlock(&c3_lock); 604 601 } 605 602 603 + rcu_idle_enter(); 604 + 606 605 acpi_idle_do_entry(cx); 607 606 607 + rcu_idle_exit(); 608 + 608 609 /* Re-enable bus master arbitration */ 609 - if (pr->flags.bm_control) { 610 + if (dis_bm) { 610 611 raw_spin_lock(&c3_lock); 611 612 acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 0); 612 613 c3_cpu_count--; 613 614 raw_spin_unlock(&c3_lock); 614 615 } 615 616 616 - if (timer_bc) 617 - lapic_timer_state_broadcast(pr, cx, 0); 617 + return index; 618 618 } 619 619 620 620 static int acpi_idle_enter(struct cpuidle_device *dev, ··· 631 625 return -EINVAL; 632 626 633 627 if (cx->type != ACPI_STATE_C1) { 628 + if (cx->type == ACPI_STATE_C3 && pr->flags.bm_check) 629 + return acpi_idle_enter_bm(drv, pr, cx, index); 630 + 631 + /* C2 to C1 demotion. */ 634 632 if (acpi_idle_fallback_to_c1(pr) && num_online_cpus() > 1) { 635 633 index = ACPI_IDLE_STATE_START; 636 634 cx = per_cpu(acpi_cstate[index], dev->cpu); 637 - } else if (cx->type == ACPI_STATE_C3 && pr->flags.bm_check) { 638 - if (cx->bm_sts_skip || !acpi_idle_bm_check()) { 639 - acpi_idle_enter_bm(pr, cx, true); 640 - return index; 641 - } else if (drv->safe_state_index >= 0) { 642 - index = drv->safe_state_index; 643 - cx = per_cpu(acpi_cstate[index], dev->cpu); 644 - } else { 645 - acpi_safe_halt(); 646 - return -EBUSY; 647 - } 648 635 } 649 636 } 650 - 651 - lapic_timer_state_broadcast(pr, cx, 1); 652 637 653 638 if (cx->type == ACPI_STATE_C3) 654 639 ACPI_FLUSH_CPU_CACHE(); 655 640 656 641 acpi_idle_do_entry(cx); 657 - 658 - lapic_timer_state_broadcast(pr, cx, 0); 659 642 660 643 return index; 661 644 } ··· 661 666 return 0; 662 667 663 668 if (pr->flags.bm_check) { 664 - acpi_idle_enter_bm(pr, cx, false); 669 + u8 bm_sts_skip = cx->bm_sts_skip; 670 + 671 + /* Don't check BM_STS, do an unconditional ARB_DIS for S2IDLE */ 672 + cx->bm_sts_skip = 1; 673 + acpi_idle_enter_bm(drv, pr, cx, index); 674 + cx->bm_sts_skip = bm_sts_skip; 675 + 665 676 return 0; 666 677 } else { 667 678 ACPI_FLUSH_CPU_CACHE(); ··· 683 682 { 684 683 int i, count = ACPI_IDLE_STATE_START; 685 684 struct acpi_processor_cx *cx; 685 + struct cpuidle_state *state; 686 686 687 687 if (max_cstate == 0) 688 688 max_cstate = 1; 689 689 690 690 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { 691 + state = &acpi_idle_driver.states[count]; 691 692 cx = &pr->power.states[i]; 692 693 693 694 if (!cx->valid) 694 695 continue; 695 696 696 697 per_cpu(acpi_cstate[count], dev->cpu) = cx; 698 + 699 + if (lapic_timer_needs_broadcast(pr, cx)) 700 + state->flags |= CPUIDLE_FLAG_TIMER_STOP; 701 + 702 + if (cx->type == ACPI_STATE_C3) { 703 + state->flags |= CPUIDLE_FLAG_TLB_FLUSHED; 704 + if (pr->flags.bm_check) 705 + state->flags |= CPUIDLE_FLAG_RCU_IDLE; 706 + } 697 707 698 708 count++; 699 709 if (count == CPUIDLE_STATE_MAX)
+10 -5
drivers/cpuidle/cpuidle.c
··· 138 138 struct cpuidle_device *dev, int index) 139 139 { 140 140 ktime_t time_start, time_end; 141 + struct cpuidle_state *target_state = &drv->states[index]; 141 142 142 143 time_start = ns_to_ktime(local_clock()); 143 144 ··· 154 153 * suspended is generally unsafe. 155 154 */ 156 155 stop_critical_timings(); 157 - rcu_idle_enter(); 158 - drv->states[index].enter_s2idle(dev, drv, index); 156 + if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) 157 + rcu_idle_enter(); 158 + target_state->enter_s2idle(dev, drv, index); 159 159 if (WARN_ON_ONCE(!irqs_disabled())) 160 160 local_irq_disable(); 161 161 /* ··· 164 162 * first CPU executing it calls functions containing RCU read-side 165 163 * critical sections, so tell RCU about that. 166 164 */ 167 - rcu_idle_exit(); 165 + if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) 166 + rcu_idle_exit(); 168 167 tick_unfreeze(); 169 168 start_critical_timings(); 170 169 ··· 242 239 time_start = ns_to_ktime(local_clock()); 243 240 244 241 stop_critical_timings(); 245 - rcu_idle_enter(); 242 + if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) 243 + rcu_idle_enter(); 246 244 entered_state = target_state->enter(dev, drv, index); 247 - rcu_idle_exit(); 245 + if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) 246 + rcu_idle_exit(); 248 247 start_critical_timings(); 249 248 250 249 sched_clock_idle_wakeup_event();
+1
drivers/powercap/intel_rapl_common.c
··· 1039 1039 X86_MATCH_INTEL_FAM6_MODEL(ROCKETLAKE, &rapl_defaults_core), 1040 1040 X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE, &rapl_defaults_core), 1041 1041 X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &rapl_defaults_spr_server), 1042 + X86_MATCH_INTEL_FAM6_MODEL(LAKEFIELD, &rapl_defaults_core), 1042 1043 1043 1044 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT, &rapl_defaults_byt), 1044 1045 X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT, &rapl_defaults_cht),
+1
include/linux/cpuidle.h
··· 82 82 #define CPUIDLE_FLAG_UNUSABLE BIT(3) /* avoid using this state */ 83 83 #define CPUIDLE_FLAG_OFF BIT(4) /* disable this state by default */ 84 84 #define CPUIDLE_FLAG_TLB_FLUSHED BIT(5) /* idle-state flushes TLBs */ 85 + #define CPUIDLE_FLAG_RCU_IDLE BIT(6) /* idle-state takes care of RCU */ 85 86 86 87 struct cpuidle_device_kobj; 87 88 struct cpuidle_state_kobj;