]> Git Repo - linux.git/commitdiff
Merge tag 'pm-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
authorLinus Torvalds <[email protected]>
Tue, 24 May 2022 23:04:25 +0000 (16:04 -0700)
committerLinus Torvalds <[email protected]>
Tue, 24 May 2022 23:04:25 +0000 (16:04 -0700)
Pull power management updates from Rafael Wysocki:
 "These add support for 'artificial' Energy Models in which power
  numbers for different entities may be in different scales, add support
  for some new hardware, fix bugs and clean up code in multiple places.

  Specifics:

   - Update the Energy Model support code to allow the Energy Model to
     be artificial, which means that the power values may not be on a
     uniform scale with other devices providing power information, and
     update the cpufreq_cooling and devfreq_cooling thermal drivers to
     support artificial Energy Models (Lukasz Luba).

   - Make DTPM check the Energy Model type (Lukasz Luba).

   - Fix policy counter decrementation in cpufreq if Energy Model is in
     use (Pierre Gondois).

   - Add CPU-based scaling support to passive devfreq governor (Saravana
     Kannan, Chanwoo Choi).

   - Update the rk3399_dmc devfreq driver (Brian Norris).

   - Export dev_pm_ops instead of suspend() and resume() in the IIO
     chemical scd30 driver (Jonathan Cameron).

   - Add namespace variants of EXPORT[_GPL]_SIMPLE_DEV_PM_OPS and
     PM-runtime counterparts (Jonathan Cameron).

   - Move symbol exports in the IIO chemical scd30 driver into the
     IIO_SCD30 namespace (Jonathan Cameron).

   - Avoid device PM-runtime usage count underflows (Rafael Wysocki).

   - Allow dynamic debug to control printing of PM messages (David
     Cohen).

   - Fix some kernel-doc comments in hibernation code (Yang Li, Haowen
     Bai).

   - Preserve ACPI-table override during hibernation (Amadeusz
     Sławiński).

   - Improve support for suspend-to-RAM for PSCI OSI mode (Ulf Hansson).

   - Make Intel RAPL power capping driver support the RaptorLake and
     AlderLake N processors (Zhang Rui, Sumeet Pawnikar).

   - Remove redundant store to value after multiply in the RAPL power
     capping driver (Colin Ian King).

   - Add AlderLake processor support to the intel_idle driver (Zhang
     Rui).

   - Fix regression leading to no genpd governor in the PSCI cpuidle
     driver and fix the riscv-sbi cpuidle driver to allow a genpd
     governor to be used (Ulf Hansson).

   - Fix cpufreq governor clean up code to avoid using kfree() directly
     to free kobject-based items (Kevin Hao).

   - Prepare cpufreq for powerpc's asm/prom.h cleanup (Christophe
     Leroy).

   - Make intel_pstate notify frequency invariance code when no_turbo is
     turned on and off (Chen Yu).

   - Add Sapphire Rapids OOB mode support to intel_pstate (Srinivas
     Pandruvada).

   - Make cpufreq avoid unnecessary frequency updates due to mismatch
     between hardware and the frequency table (Viresh Kumar).

   - Make remove_cpu_dev_symlink() clear the real_cpus mask to simplify
     code (Viresh Kumar).

   - Rearrange cpufreq_offline() and cpufreq_remove_dev() to make the
     calling convention for some driver callbacks consistent (Rafael
     Wysocki).

   - Avoid accessing half-initialized cpufreq policies from the show()
     and store() sysfs functions (Schspa Shi).

   - Rearrange cpufreq_offline() to make the calling convention for some
     driver callbacks consistent (Schspa Shi).

   - Update CPPC handling in cpufreq (Pierre Gondois).

   - Extend dev_pm_domain_detach() doc (Krzysztof Kozlowski).

   - Move genpd's time-accounting to ktime_get_mono_fast_ns() (Ulf
     Hansson).

   - Improve the way genpd deals with its governors (Ulf Hansson).

   - Update the turbostat utility to version 2022.04.16 (Len Brown, Dan
     Merillat, Sumeet Pawnikar, Zephaniah E. Loss-Cutler-Hull, Chen Yu)"

* tag 'pm-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (94 commits)
  PM: domains: Trust domain-idle-states from DT to be correct by genpd
  PM: domains: Measure power-on/off latencies in genpd based on a governor
  PM: domains: Allocate governor data dynamically based on a genpd governor
  PM: domains: Clean up some code in pm_genpd_init() and genpd_remove()
  PM: domains: Fix initialization of genpd's next_wakeup
  PM: domains: Fixup QoS latency measurements for IRQ safe devices in genpd
  PM: domains: Measure suspend/resume latencies in genpd based on governor
  PM: domains: Move the next_wakeup variable into the struct gpd_timing_data
  PM: domains: Allocate gpd_timing_data dynamically based on governor
  PM: domains: Skip another warning in irq_safe_dev_in_sleep_domain()
  PM: domains: Rename irq_safe_dev_in_no_sleep_domain() in genpd
  PM: domains: Don't check PM_QOS_FLAG_NO_POWER_OFF in genpd
  PM: domains: Drop redundant code for genpd always-on governor
  PM: domains: Add GENPD_FLAG_RPM_ALWAYS_ON for the always-on governor
  powercap: intel_rapl: remove redundant store to value after multiply
  cpufreq: CPPC: Enable dvfs_possible_from_any_cpu
  cpufreq: CPPC: Enable fast_switch
  ACPI: CPPC: Assume no transition latency if no PCCT
  ACPI: bus: Set CPPC _OSC bits for all and when CPPC_LIB is supported
  ACPI: CPPC: Check _OSC for flexible address space
  ...

1  2 
arch/x86/include/asm/msr-index.h
arch/x86/kernel/acpi/boot.c
drivers/acpi/bus.c

index 14154b8b1720a3e70b3598b7142f233e9cfe09c4,3a6788b3ebcfde27977628ad9ab0034c5c05ce6f..403e83b4adc88ea3d61337279920de39f75df6ae
@@@ -76,8 -76,6 +76,8 @@@
  
  /* Abbreviated from Intel SDM name IA32_CORE_CAPABILITIES */
  #define MSR_IA32_CORE_CAPS                      0x000000cf
 +#define MSR_IA32_CORE_CAPS_INTEGRITY_CAPS_BIT   2
 +#define MSR_IA32_CORE_CAPS_INTEGRITY_CAPS       BIT(MSR_IA32_CORE_CAPS_INTEGRITY_CAPS_BIT)
  #define MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT_BIT  5
  #define MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT    BIT(MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT_BIT)
  
  #define MSR_IA32_POWER_CTL            0x000001fc
  #define MSR_IA32_POWER_CTL_BIT_EE     19
  
 +/* Abbreviated from Intel SDM name IA32_INTEGRITY_CAPABILITIES */
 +#define MSR_INTEGRITY_CAPS                    0x000002d9
 +#define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT  4
 +#define MSR_INTEGRITY_CAPS_PERIODIC_BIST      BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT)
 +
  #define MSR_LBR_NHM_FROM              0x00000680
  #define MSR_LBR_NHM_TO                        0x000006c0
  #define MSR_LBR_CORE_FROM             0x00000040
  
  /* Run Time Average Power Limiting (RAPL) Interface */
  
+ #define MSR_VR_CURRENT_CONFIG 0x00000601
  #define MSR_RAPL_POWER_UNIT           0x00000606
  
  #define MSR_PKG_POWER_LIMIT           0x00000610
  #define MSR_AMD64_SEV                 0xc0010131
  #define MSR_AMD64_SEV_ENABLED_BIT     0
  #define MSR_AMD64_SEV_ES_ENABLED_BIT  1
 +#define MSR_AMD64_SEV_SNP_ENABLED_BIT 2
  #define MSR_AMD64_SEV_ENABLED         BIT_ULL(MSR_AMD64_SEV_ENABLED_BIT)
  #define MSR_AMD64_SEV_ES_ENABLED      BIT_ULL(MSR_AMD64_SEV_ES_ENABLED_BIT)
 +#define MSR_AMD64_SEV_SNP_ENABLED     BIT_ULL(MSR_AMD64_SEV_SNP_ENABLED_BIT)
  
  #define MSR_AMD64_VIRT_SPEC_CTRL      0xc001011f
  
  #define AMD_CPPC_DES_PERF(x)          (((x) & 0xff) << 16)
  #define AMD_CPPC_ENERGY_PERF_PREF(x)  (((x) & 0xff) << 24)
  
 +/* AMD Performance Counter Global Status and Control MSRs */
 +#define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS     0xc0000300
 +#define MSR_AMD64_PERF_CNTR_GLOBAL_CTL                0xc0000301
 +#define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR 0xc0000302
 +
  /* Fam 17h MSRs */
  #define MSR_F17H_IRPERF                       0xc00000e9
  
  #define MSR_IA32_PERF_CTL             0x00000199
  #define INTEL_PERF_CTL_MASK           0xffff
  
 +/* AMD Branch Sampling configuration */
 +#define MSR_AMD_DBG_EXTN_CFG          0xc000010f
 +#define MSR_AMD_SAMP_BR_FROM          0xc0010300
 +
  #define MSR_IA32_MPERF                        0x000000e7
  #define MSR_IA32_APERF                        0x000000e8
  
index 058e7b924189f7f6594064182df1339be14361e0,2eeca97b730b3c1817c3087cbfc4d93bcb20fdfc..907cc98b1938084409350e5864b84558905b2846
@@@ -65,13 -65,6 +65,13 @@@ static u64 acpi_lapic_addr __initdata 
  static bool acpi_support_online_capable;
  #endif
  
 +#ifdef CONFIG_X86_64
 +/* Physical address of the Multiprocessor Wakeup Structure mailbox */
 +static u64 acpi_mp_wake_mailbox_paddr;
 +/* Virtual address of the Multiprocessor Wakeup Structure mailbox */
 +static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox;
 +#endif
 +
  #ifdef CONFIG_X86_IO_APIC
  /*
   * Locks related to IOAPIC hotplug
@@@ -343,60 -336,7 +343,60 @@@ acpi_parse_lapic_nmi(union acpi_subtabl
        return 0;
  }
  
 -#endif                                /*CONFIG_X86_LOCAL_APIC */
 +#ifdef CONFIG_X86_64
 +static int acpi_wakeup_cpu(int apicid, unsigned long start_ip)
 +{
 +      /*
 +       * Remap mailbox memory only for the first call to acpi_wakeup_cpu().
 +       *
 +       * Wakeup of secondary CPUs is fully serialized in the core code.
 +       * No need to protect acpi_mp_wake_mailbox from concurrent accesses.
 +       */
 +      if (!acpi_mp_wake_mailbox) {
 +              acpi_mp_wake_mailbox = memremap(acpi_mp_wake_mailbox_paddr,
 +                                              sizeof(*acpi_mp_wake_mailbox),
 +                                              MEMREMAP_WB);
 +      }
 +
 +      /*
 +       * Mailbox memory is shared between the firmware and OS. Firmware will
 +       * listen on mailbox command address, and once it receives the wakeup
 +       * command, the CPU associated with the given apicid will be booted.
 +       *
 +       * The value of 'apic_id' and 'wakeup_vector' must be visible to the
 +       * firmware before the wakeup command is visible.  smp_store_release()
 +       * ensures ordering and visibility.
 +       */
 +      acpi_mp_wake_mailbox->apic_id       = apicid;
 +      acpi_mp_wake_mailbox->wakeup_vector = start_ip;
 +      smp_store_release(&acpi_mp_wake_mailbox->command,
 +                        ACPI_MP_WAKE_COMMAND_WAKEUP);
 +
 +      /*
 +       * Wait for the CPU to wake up.
 +       *
 +       * The CPU being woken up is essentially in a spin loop waiting to be
 +       * woken up. It should not take long for it wake up and acknowledge by
 +       * zeroing out ->command.
 +       *
 +       * ACPI specification doesn't provide any guidance on how long kernel
 +       * has to wait for a wake up acknowledgement. It also doesn't provide
 +       * a way to cancel a wake up request if it takes too long.
 +       *
 +       * In TDX environment, the VMM has control over how long it takes to
 +       * wake up secondary. It can postpone scheduling secondary vCPU
 +       * indefinitely. Giving up on wake up request and reporting error opens
 +       * possible attack vector for VMM: it can wake up a secondary CPU when
 +       * kernel doesn't expect it. Wait until positive result of the wake up
 +       * request.
 +       */
 +      while (READ_ONCE(acpi_mp_wake_mailbox->command))
 +              cpu_relax();
 +
 +      return 0;
 +}
 +#endif /* CONFIG_X86_64 */
 +#endif /* CONFIG_X86_LOCAL_APIC */
  
  #ifdef CONFIG_X86_IO_APIC
  #define MP_ISA_BUS            0
@@@ -435,7 -375,7 +435,7 @@@ static void __init mp_override_legacy_i
        isa_irq_to_gsi[bus_irq] = gsi;
  }
  
 -static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
 +static void mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
                        int polarity)
  {
  #ifdef CONFIG_X86_MPPARSE
        u8 pin;
  
        if (!acpi_ioapic)
 -              return 0;
 +              return;
        if (!dev || !dev_is_pci(dev))
 -              return 0;
 +              return;
  
        pdev = to_pci_dev(dev);
        number = pdev->bus->number;
  
        mp_save_irq(&mp_irq);
  #endif
 -      return 0;
  }
  
  static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
@@@ -1142,29 -1083,6 +1142,29 @@@ static int __init acpi_parse_madt_lapic
        }
        return 0;
  }
 +
 +#ifdef CONFIG_X86_64
 +static int __init acpi_parse_mp_wake(union acpi_subtable_headers *header,
 +                                   const unsigned long end)
 +{
 +      struct acpi_madt_multiproc_wakeup *mp_wake;
 +
 +      if (!IS_ENABLED(CONFIG_SMP))
 +              return -ENODEV;
 +
 +      mp_wake = (struct acpi_madt_multiproc_wakeup *)header;
 +      if (BAD_MADT_ENTRY(mp_wake, end))
 +              return -EINVAL;
 +
 +      acpi_table_print_madt_entry(&header->common);
 +
 +      acpi_mp_wake_mailbox_paddr = mp_wake->base_address;
 +
 +      acpi_wake_cpu_handler_update(acpi_wakeup_cpu);
 +
 +      return 0;
 +}
 +#endif                                /* CONFIG_X86_64 */
  #endif                                /* CONFIG_X86_LOCAL_APIC */
  
  #ifdef        CONFIG_X86_IO_APIC
@@@ -1360,14 -1278,6 +1360,14 @@@ static void __init acpi_process_madt(vo
  
                                smp_found_config = 1;
                        }
 +
 +#ifdef CONFIG_X86_64
 +                      /*
 +                       * Parse MADT MP Wake entry.
 +                       */
 +                      acpi_table_parse_madt(ACPI_MADT_TYPE_MULTIPROC_WAKEUP,
 +                                            acpi_parse_mp_wake, 1);
 +#endif
                }
                if (error == -EINVAL) {
                        /*
@@@ -1862,7 -1772,7 +1862,7 @@@ int __acpi_release_global_lock(unsigne
  
  void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
  {
-       e820__range_add(addr, size, E820_TYPE_ACPI);
+       e820__range_add(addr, size, E820_TYPE_NVS);
        e820__update_table_print();
  }
  
diff --combined drivers/acpi/bus.c
index fe0000eb7cae911421fcda356fc1b059eadc2ca5,1fc24f4fbcb4ecd6c8276c7b1c6ac8cff9f28ef6..b67d2ee77cd136eeab5e1b0485d1a26b1be2b607
@@@ -278,6 -278,20 +278,20 @@@ bool osc_sb_apei_support_acked
  bool osc_pc_lpi_support_confirmed;
  EXPORT_SYMBOL_GPL(osc_pc_lpi_support_confirmed);
  
+ /*
+  * ACPI 6.2 Section 6.2.11.2 'Platform-Wide OSPM Capabilities':
+  *   Starting with ACPI Specification 6.2, all _CPC registers can be in
+  *   PCC, System Memory, System IO, or Functional Fixed Hardware address
+  *   spaces. OSPM support for this more flexible register space scheme is
+  *   indicated by the “Flexible Address Space for CPPC Registers” _OSC bit.
+  *
+  * Otherwise (cf ACPI 6.1, s8.4.7.1.1.X), _CPC registers must be in:
+  * - PCC or Functional Fixed Hardware address space if defined
+  * - SystemMemory address space (NULL register) if not defined
+  */
+ bool osc_cpc_flexible_adr_space_confirmed;
+ EXPORT_SYMBOL_GPL(osc_cpc_flexible_adr_space_confirmed);
  /*
   * ACPI 6.4 Operating System Capabilities for USB.
   */
@@@ -315,12 -329,15 +329,15 @@@ static void acpi_bus_osc_negotiate_plat
  #endif
  #ifdef CONFIG_X86
        capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_GENERIC_INITIATOR_SUPPORT;
-       if (boot_cpu_has(X86_FEATURE_HWP)) {
-               capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_SUPPORT;
-               capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPCV2_SUPPORT;
-       }
  #endif
  
+ #ifdef CONFIG_ACPI_CPPC_LIB
+       capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_SUPPORT;
+       capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPCV2_SUPPORT;
+ #endif
+       capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_FLEXIBLE_ADR_SPACE;
        if (IS_ENABLED(CONFIG_SCHED_MC_PRIO))
                capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_CPC_DIVERSE_HIGH_SUPPORT;
  
                return;
        }
  
- #ifdef CONFIG_X86
-       if (boot_cpu_has(X86_FEATURE_HWP))
-               osc_sb_cppc_not_supported = !(capbuf_ret[OSC_SUPPORT_DWORD] &
-                               (OSC_SB_CPC_SUPPORT | OSC_SB_CPCV2_SUPPORT));
+ #ifdef CONFIG_ACPI_CPPC_LIB
+       osc_sb_cppc_not_supported = !(capbuf_ret[OSC_SUPPORT_DWORD] &
+                       (OSC_SB_CPC_SUPPORT | OSC_SB_CPCV2_SUPPORT));
  #endif
  
        /*
                        capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
                osc_sb_native_usb4_support_confirmed =
                        capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
+               osc_cpc_flexible_adr_space_confirmed =
+                       capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_CPC_FLEXIBLE_ADR_SPACE;
        }
  
        kfree(context.ret.pointer);
@@@ -1070,32 -1088,6 +1088,32 @@@ int acpi_bus_for_each_dev(int (*fn)(str
  }
  EXPORT_SYMBOL_GPL(acpi_bus_for_each_dev);
  
 +struct acpi_dev_walk_context {
 +      int (*fn)(struct acpi_device *, void *);
 +      void *data;
 +};
 +
 +static int acpi_dev_for_one_check(struct device *dev, void *context)
 +{
 +      struct acpi_dev_walk_context *adwc = context;
 +
 +      if (dev->bus != &acpi_bus_type)
 +              return 0;
 +
 +      return adwc->fn(to_acpi_device(dev), adwc->data);
 +}
 +
 +int acpi_dev_for_each_child(struct acpi_device *adev,
 +                          int (*fn)(struct acpi_device *, void *), void *data)
 +{
 +      struct acpi_dev_walk_context adwc = {
 +              .fn = fn,
 +              .data = data,
 +      };
 +
 +      return device_for_each_child(&adev->dev, &adwc, acpi_dev_for_one_check);
 +}
 +
  /* --------------------------------------------------------------------------
                               Initialization/Cleanup
     -------------------------------------------------------------------------- */
This page took 0.145593 seconds and 4 git commands to generate.