Skip to content

Commit 0e83828

Browse files
committed
Merge branches 'acpi-processor', 'acpi-pm', 'acpi-tables' and 'acpi-sysfs'
Merge ACPI processor driver changes, ACPI power management updates, changes related to parsing ACPI tables and an ACPI sysfs interface update for 6.4-rc1: - Fix evaluating the _PDC ACPI control method when running as Xen dom0 (Roger Pau Monne). - Use platform devices to load ACPI PPC and PCC drivers (Petr Pavlu). - Check for null return of devm_kzalloc() in fch_misc_setup() (Kang Chen). - Log a message if enable_irq_wake() fails for the ACPI SCI (Simon Gaiser). - Initialize the correct IOMMU fwspec while parsing ACPI VIOT (Jean-Philippe Brucker). - Amend indentation and prefix error messages with FW_BUG in the ACPI SPCR parsing code (Andy Shevchenko). - Enable ACPI sysfs support for CCEL records (Kuppuswamy Sathyanarayanan). * acpi-processor: ACPI: processor: Fix evaluating _PDC method when running as Xen dom0 ACPI: cpufreq: Use platform devices to load ACPI PPC and PCC drivers ACPI: processor: Check for null return of devm_kzalloc() in fch_misc_setup() * acpi-pm: ACPI: s2idle: Log when enabling wakeup IRQ fails * acpi-tables: ACPI: VIOT: Initialize the correct IOMMU fwspec ACPI: SPCR: Amend indentation ACPI: SPCR: Prefix error messages with FW_BUG * acpi-sysfs: ACPI: sysfs: Enable ACPI sysfs support for CCEL records
5 parents c90b29c + 073828e + f2cba54 + 47d2668 + 4f855dc commit 0e83828

11 files changed

Lines changed: 162 additions & 40 deletions

File tree

drivers/acpi/acpi_apd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ static int fch_misc_setup(struct apd_private_data *pdata)
8383
if (!acpi_dev_get_property(adev, "clk-name", ACPI_TYPE_STRING, &obj)) {
8484
clk_data->name = devm_kzalloc(&adev->dev, obj->string.length,
8585
GFP_KERNEL);
86+
if (!clk_data->name)
87+
return -ENOMEM;
8688

8789
strcpy(clk_data->name, obj->string.pointer);
8890
} else {

drivers/acpi/acpi_processor.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/kernel.h>
1616
#include <linux/module.h>
1717
#include <linux/pci.h>
18+
#include <linux/platform_device.h>
1819

1920
#include <acpi/processor.h>
2021

@@ -148,6 +149,34 @@ static int acpi_processor_errata(void)
148149
return result;
149150
}
150151

152+
/* Create a platform device to represent a CPU frequency control mechanism. */
153+
static void cpufreq_add_device(const char *name)
154+
{
155+
struct platform_device *pdev;
156+
157+
pdev = platform_device_register_simple(name, PLATFORM_DEVID_NONE, NULL, 0);
158+
if (IS_ERR(pdev))
159+
pr_info("%s device creation failed: %ld\n", name, PTR_ERR(pdev));
160+
}
161+
162+
#ifdef CONFIG_X86
163+
/* Check presence of Processor Clocking Control by searching for \_SB.PCCH. */
164+
static void __init acpi_pcc_cpufreq_init(void)
165+
{
166+
acpi_status status;
167+
acpi_handle handle;
168+
169+
status = acpi_get_handle(NULL, "\\_SB", &handle);
170+
if (ACPI_FAILURE(status))
171+
return;
172+
173+
if (acpi_has_method(handle, "PCCH"))
174+
cpufreq_add_device("pcc-cpufreq");
175+
}
176+
#else
177+
static void __init acpi_pcc_cpufreq_init(void) {}
178+
#endif /* CONFIG_X86 */
179+
151180
/* Initialization */
152181
#ifdef CONFIG_ACPI_HOTPLUG_CPU
153182
int __weak acpi_map_cpu(acpi_handle handle,
@@ -280,14 +309,22 @@ static int acpi_processor_get_info(struct acpi_device *device)
280309
dev_dbg(&device->dev, "Failed to get CPU physical ID.\n");
281310

282311
pr->id = acpi_map_cpuid(pr->phys_id, pr->acpi_id);
283-
if (!cpu0_initialized && !acpi_has_cpu_in_madt()) {
312+
if (!cpu0_initialized) {
284313
cpu0_initialized = 1;
285314
/*
286315
* Handle UP system running SMP kernel, with no CPU
287316
* entry in MADT
288317
*/
289-
if (invalid_logical_cpuid(pr->id) && (num_online_cpus() == 1))
318+
if (!acpi_has_cpu_in_madt() && invalid_logical_cpuid(pr->id) &&
319+
(num_online_cpus() == 1))
290320
pr->id = 0;
321+
/*
322+
* Check availability of Processor Performance Control by
323+
* looking at the presence of the _PCT object under the first
324+
* processor definition.
325+
*/
326+
if (acpi_has_method(pr->handle, "_PCT"))
327+
cpufreq_add_device("acpi-cpufreq");
291328
}
292329

293330
/*
@@ -686,6 +723,7 @@ void __init acpi_processor_init(void)
686723
acpi_processor_check_duplicates();
687724
acpi_scan_add_handler_with_hotplug(&processor_handler, "processor");
688725
acpi_scan_add_handler(&processor_container_handler);
726+
acpi_pcc_cpufreq_init();
689727
}
690728

691729
#ifdef CONFIG_ACPI_PROCESSOR_CSTATE

drivers/acpi/processor_pdc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/acpi.h>
1515
#include <acpi/processor.h>
1616

17+
#include <xen/xen.h>
18+
1719
#include "internal.h"
1820

1921
static bool __init processor_physically_present(acpi_handle handle)
@@ -47,6 +49,15 @@ static bool __init processor_physically_present(acpi_handle handle)
4749
return false;
4850
}
4951

52+
if (xen_initial_domain())
53+
/*
54+
* When running as a Xen dom0 the number of processors Linux
55+
* sees can be different from the real number of processors on
56+
* the system, and we still need to execute _PDC for all of
57+
* them.
58+
*/
59+
return xen_processor_present(acpi_id);
60+
5061
type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
5162
cpuid = acpi_get_cpuid(handle, type, acpi_id);
5263

drivers/acpi/sleep.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,13 @@ int acpi_s2idle_begin(void)
714714
int acpi_s2idle_prepare(void)
715715
{
716716
if (acpi_sci_irq_valid()) {
717-
enable_irq_wake(acpi_sci_irq);
717+
int error;
718+
719+
error = enable_irq_wake(acpi_sci_irq);
720+
if (error)
721+
pr_warn("Warning: Failed to enable wakeup from IRQ %d: %d\n",
722+
acpi_sci_irq, error);
723+
718724
acpi_ec_set_gpe_wake_mask(ACPI_GPE_ENABLE);
719725
}
720726

drivers/acpi/spcr.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ static bool xgene_8250_erratum_present(struct acpi_table_spcr *tb)
7171

7272
/**
7373
* acpi_parse_spcr() - parse ACPI SPCR table and add preferred console
74-
*
7574
* @enable_earlycon: set up earlycon for the console specified by the table
7675
* @enable_console: setup the console specified by the table.
7776
*
@@ -82,7 +81,6 @@ static bool xgene_8250_erratum_present(struct acpi_table_spcr *tb)
8281
*
8382
* When CONFIG_ACPI_SPCR_TABLE is defined, this function should be called
8483
* from arch initialization code as soon as the DT/ACPI decision is made.
85-
*
8684
*/
8785
int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
8886
{
@@ -97,9 +95,7 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
9795
if (acpi_disabled)
9896
return -ENODEV;
9997

100-
status = acpi_get_table(ACPI_SIG_SPCR, 0,
101-
(struct acpi_table_header **)&table);
102-
98+
status = acpi_get_table(ACPI_SIG_SPCR, 0, (struct acpi_table_header **)&table);
10399
if (ACPI_FAILURE(status))
104100
return -ENOENT;
105101

@@ -110,12 +106,12 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
110106
u32 bit_width = table->serial_port.access_width;
111107

112108
if (bit_width > ACPI_ACCESS_BIT_MAX) {
113-
pr_err("Unacceptable wide SPCR Access Width. Defaulting to byte size\n");
109+
pr_err(FW_BUG "Unacceptable wide SPCR Access Width. Defaulting to byte size\n");
114110
bit_width = ACPI_ACCESS_BIT_DEFAULT;
115111
}
116112
switch (ACPI_ACCESS_BIT_WIDTH((bit_width))) {
117113
default:
118-
pr_err("Unexpected SPCR Access Width. Defaulting to byte size\n");
114+
pr_err(FW_BUG "Unexpected SPCR Access Width. Defaulting to byte size\n");
119115
fallthrough;
120116
case 8:
121117
iotype = "mmio";
@@ -202,7 +198,8 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
202198
if (xgene_8250_erratum_present(table)) {
203199
iotype = "mmio32";
204200

205-
/* for xgene v1 and v2 we don't know the clock rate of the
201+
/*
202+
* For xgene v1 and v2 we don't know the clock rate of the
206203
* UART so don't attempt to change to the baud rate state
207204
* in the table because driver cannot calculate the dividers
208205
*/

drivers/acpi/sysfs.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,28 @@ static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr)
458458
return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
459459
}
460460

461+
static int acpi_ccel_data_init(void *th, struct acpi_data_attr *data_attr)
462+
{
463+
struct acpi_table_ccel *ccel = th;
464+
465+
if (ccel->header.length < sizeof(struct acpi_table_ccel) ||
466+
!ccel->log_area_start_address || !ccel->log_area_minimum_length) {
467+
kfree(data_attr);
468+
return -EINVAL;
469+
}
470+
data_attr->addr = ccel->log_area_start_address;
471+
data_attr->attr.size = ccel->log_area_minimum_length;
472+
data_attr->attr.attr.name = "CCEL";
473+
474+
return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
475+
}
476+
461477
static struct acpi_data_obj {
462478
char *name;
463479
int (*fn)(void *, struct acpi_data_attr *);
464480
} acpi_data_objs[] = {
465481
{ ACPI_SIG_BERT, acpi_bert_data_init },
482+
{ ACPI_SIG_CCEL, acpi_ccel_data_init },
466483
};
467484

468485
#define NUM_ACPI_DATA_OBJS ARRAY_SIZE(acpi_data_objs)

drivers/acpi/viot.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ static int viot_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
328328
{
329329
u32 epid;
330330
struct viot_endpoint *ep;
331+
struct device *aliased_dev = data;
331332
u32 domain_nr = pci_domain_nr(pdev->bus);
332333

333334
list_for_each_entry(ep, &viot_pci_ranges, list) {
@@ -338,7 +339,7 @@ static int viot_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
338339
epid = ((domain_nr - ep->segment_start) << 16) +
339340
dev_id - ep->bdf_start + ep->endpoint_id;
340341

341-
return viot_dev_iommu_init(&pdev->dev, ep->viommu,
342+
return viot_dev_iommu_init(aliased_dev, ep->viommu,
342343
epid);
343344
}
344345
}
@@ -372,7 +373,7 @@ int viot_iommu_configure(struct device *dev)
372373
{
373374
if (dev_is_pci(dev))
374375
return pci_for_each_dma_alias(to_pci_dev(dev),
375-
viot_pci_dev_iommu_init, NULL);
376+
viot_pci_dev_iommu_init, dev);
376377
else if (dev_is_platform(dev))
377378
return viot_mmio_dev_iommu_init(to_platform_device(dev));
378379
return -ENODEV;

drivers/cpufreq/acpi-cpufreq.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ static void __init acpi_cpufreq_boost_init(void)
965965
acpi_cpufreq_driver.boost_enabled = boost_state(0);
966966
}
967967

968-
static int __init acpi_cpufreq_init(void)
968+
static int __init acpi_cpufreq_probe(struct platform_device *pdev)
969969
{
970970
int ret;
971971

@@ -1010,13 +1010,32 @@ static int __init acpi_cpufreq_init(void)
10101010
return ret;
10111011
}
10121012

1013-
static void __exit acpi_cpufreq_exit(void)
1013+
static int acpi_cpufreq_remove(struct platform_device *pdev)
10141014
{
10151015
pr_debug("%s\n", __func__);
10161016

10171017
cpufreq_unregister_driver(&acpi_cpufreq_driver);
10181018

10191019
free_acpi_perf_data();
1020+
1021+
return 0;
1022+
}
1023+
1024+
static struct platform_driver acpi_cpufreq_platdrv = {
1025+
.driver = {
1026+
.name = "acpi-cpufreq",
1027+
},
1028+
.remove = acpi_cpufreq_remove,
1029+
};
1030+
1031+
static int __init acpi_cpufreq_init(void)
1032+
{
1033+
return platform_driver_probe(&acpi_cpufreq_platdrv, acpi_cpufreq_probe);
1034+
}
1035+
1036+
static void __exit acpi_cpufreq_exit(void)
1037+
{
1038+
platform_driver_unregister(&acpi_cpufreq_platdrv);
10201039
}
10211040

10221041
module_param(acpi_pstate_strict, uint, 0644);
@@ -1027,18 +1046,4 @@ MODULE_PARM_DESC(acpi_pstate_strict,
10271046
late_initcall(acpi_cpufreq_init);
10281047
module_exit(acpi_cpufreq_exit);
10291048

1030-
static const struct x86_cpu_id __maybe_unused acpi_cpufreq_ids[] = {
1031-
X86_MATCH_FEATURE(X86_FEATURE_ACPI, NULL),
1032-
X86_MATCH_FEATURE(X86_FEATURE_HW_PSTATE, NULL),
1033-
{}
1034-
};
1035-
MODULE_DEVICE_TABLE(x86cpu, acpi_cpufreq_ids);
1036-
1037-
static const struct acpi_device_id __maybe_unused processor_device_ids[] = {
1038-
{ACPI_PROCESSOR_OBJECT_HID, },
1039-
{ACPI_PROCESSOR_DEVICE_HID, },
1040-
{},
1041-
};
1042-
MODULE_DEVICE_TABLE(acpi, processor_device_ids);
1043-
1044-
MODULE_ALIAS("acpi");
1049+
MODULE_ALIAS("platform:acpi-cpufreq");

drivers/cpufreq/pcc-cpufreq.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static int __init pcc_cpufreq_do_osc(acpi_handle *handle)
384384
return ret;
385385
}
386386

387-
static int __init pcc_cpufreq_probe(void)
387+
static int __init pcc_cpufreq_evaluate(void)
388388
{
389389
acpi_status status;
390390
struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
@@ -576,7 +576,7 @@ static struct cpufreq_driver pcc_cpufreq_driver = {
576576
.name = "pcc-cpufreq",
577577
};
578578

579-
static int __init pcc_cpufreq_init(void)
579+
static int __init pcc_cpufreq_probe(struct platform_device *pdev)
580580
{
581581
int ret;
582582

@@ -587,9 +587,9 @@ static int __init pcc_cpufreq_init(void)
587587
if (acpi_disabled)
588588
return -ENODEV;
589589

590-
ret = pcc_cpufreq_probe();
590+
ret = pcc_cpufreq_evaluate();
591591
if (ret) {
592-
pr_debug("pcc_cpufreq_init: PCCH evaluation failed\n");
592+
pr_debug("pcc_cpufreq_probe: PCCH evaluation failed\n");
593593
return ret;
594594
}
595595

@@ -607,21 +607,35 @@ static int __init pcc_cpufreq_init(void)
607607
return ret;
608608
}
609609

610-
static void __exit pcc_cpufreq_exit(void)
610+
static int pcc_cpufreq_remove(struct platform_device *pdev)
611611
{
612612
cpufreq_unregister_driver(&pcc_cpufreq_driver);
613613

614614
pcc_clear_mapping();
615615

616616
free_percpu(pcc_cpu_info);
617+
618+
return 0;
617619
}
618620

619-
static const struct acpi_device_id __maybe_unused processor_device_ids[] = {
620-
{ACPI_PROCESSOR_OBJECT_HID, },
621-
{ACPI_PROCESSOR_DEVICE_HID, },
622-
{},
621+
static struct platform_driver pcc_cpufreq_platdrv = {
622+
.driver = {
623+
.name = "pcc-cpufreq",
624+
},
625+
.remove = pcc_cpufreq_remove,
623626
};
624-
MODULE_DEVICE_TABLE(acpi, processor_device_ids);
627+
628+
static int __init pcc_cpufreq_init(void)
629+
{
630+
return platform_driver_probe(&pcc_cpufreq_platdrv, pcc_cpufreq_probe);
631+
}
632+
633+
static void __exit pcc_cpufreq_exit(void)
634+
{
635+
platform_driver_unregister(&pcc_cpufreq_platdrv);
636+
}
637+
638+
MODULE_ALIAS("platform:pcc-cpufreq");
625639

626640
MODULE_AUTHOR("Matthew Garrett, Naga Chumbalkar");
627641
MODULE_VERSION(PCC_VERSION);

0 commit comments

Comments
 (0)