Skip to content

Commit

Permalink
Merge tag 'acpi-5.20-rc1' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These rework the handling of ACPI device objects to use the driver
  core facilities for managing child ones instead of some questionable
  home-grown ways without the requisite locking and reference counting,
  clean up the EC driver, improve suspend-to-idle handling on x86, add
  some systems to the ACPI backlight quirk list, fix some assorted
  issues, clean up code and improve documentation.

  Specifics:

   - Use facilities provided by the driver core and some additional
     helpers to handle the children of a given ACPI device object in
     multiple places instead of using the children and node list heads
     in struct acpi_device which is error prone (Rafael Wysocki).

   - Fix ACPI-related device reference counting issue in the hisi_lpc
     bus driver (Yang Yingliang).

   - Drop the children and node list heads that are not needed any more
     from struct acpi_device (Rafael Wysocki).

   - Drop driver member from struct acpi_device (Uwe Kleine-König).

   - Drop redundant check from acpi_device_remove() (Uwe Kleine-König).

   - Prepare the CPPC library for handling backwards-compatible future
     _CPC return package formats gracefully (Rafael Wysocki).

   - Clean up the ACPI EC driver after previous changes in it (Hans de
     Goede).

   - Drop leftover acpi_processor_get_limit_info() declaration (Riwen
     Lu).

   - Split out thermal initialization from ACPI PSS (Riwen Lu).

   - Annotate more functions in the ACPI CPU idle driver to live in the
     cpuidle section (Guilherme G. Piccoli).

   - Fix _EINJ vs "special purpose" EFI memory regions (Dan Williams).

   - Implement a better fix to avoid spamming the console with old error
     logs (Tony Luck).

   - Fix typo in a comment in the APEI code (Xiang wangx).

   - Save NVS memory during transitions into S3 on Lenovo G40-45 (Manyi
     Li).

   - Add support for upcoming AMD uPEP device ID AMDI008 to the ACPI
     suspend-to-idle driver for x86 platforms (Shyam Sundar S K).

   - Clean up checks related to the ACPI_FADT_LOW_POWER_S0 platform flag
     in the LPIT table driver and the suspend-to-idle driver for x86
     platforms (Rafael Wysocki).

   - Print information messages regarding declared LPS0 idle support in
     the platform firmware (Rafael Wysocki).

   - Fix missing check in register_device_clock() in the ACPI driver for
     Intel SoCs (huhai).

   - Fix ACS setup in the VIOT table parser (Eric Auger).

   - Skip IRQ override on AMD Zen platforms where it's harmful
     (Chuanhong Guo).

   - Use native backlight on Dell Inspiron N4010 (Hans de Goede).

   - Use native backlight on some TongFang devices (Werner Sembach).

   - Drop X86 dependency from the ACPI backlight driver Kconfig (Riwen
     Lu).

   - Shorten the quirk list in the ACPI backlight driver by identifying
     Clevo by board_name only (Werner Sembach).

   - Remove useless NULL pointer checks from 2 ACPI PCI link management
     functions (Andrey Strachuk).

   - Fix obsolete example in the ACPI EINJ documentation (Qifu Zhang).

   - Update links and references to _DSD-related documents (Sudeep
     Holla)"

* tag 'acpi-5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (46 commits)
  ACPI/PCI: Remove useless NULL pointer checks
  ACPI: CPPC: Do not prevent CPPC from working in the future
  ACPI: PM: x86: Print messages regarding LPS0 idle support
  ACPI: resource: skip IRQ override on AMD Zen platforms
  Documentation: ACPI: EINJ: Fix obsolete example
  ACPI: video: Use native backlight on Dell Inspiron N4010
  ACPI: PM: s2idle: Use LPS0 idle if ACPI_FADT_LOW_POWER_S0 is unset
  Revert "ACPI / PM: LPIT: Register sysfs attributes based on FADT"
  ACPI: video: Shortening quirk list by identifying Clevo by board_name only
  ACPI: video: Force backlight native for some TongFang devices
  ACPI: PM: s2idle: Add support for upcoming AMD uPEP HID AMDI008
  ACPI: VIOT: Fix ACS setup
  ACPI: bus: Drop unused list heads from struct acpi_device
  hisi_lpc: Use acpi_dev_for_each_child()
  bus: hisi_lpc: fix missing platform_device_put() in hisi_lpc_acpi_probe()
  ACPI: bus: Drop driver member of struct acpi_device
  ACPI: bus: Drop redundant check in acpi_device_remove()
  ACPI: APEI: Fix _EINJ vs EFI_MEMORY_SP
  ACPI: LPSS: Fix missing check in register_device_clock()
  ACPI: APEI: Better fix to avoid spamming the console with old error logs
  ...
  • Loading branch information
Linus Torvalds committed Aug 2, 2022
2 parents 64ae88f + 6352f34 commit 8fa0db3
Show file tree
Hide file tree
Showing 40 changed files with 748 additions and 648 deletions.
11 changes: 7 additions & 4 deletions Documentation/firmware-guide/acpi/DSD-properties-rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ specific type) associated with it.

In the ACPI _DSD context it is an element of the sub-package following the
generic Device Properties UUID in the _DSD return package as specified in the
Device Properties UUID definition document [1]_.
section titled "Well-Known _DSD UUIDs and Data Structure Formats" sub-section
"Device Properties UUID" in _DSD (Device Specific Data) Implementation Guide
document [1]_.

It also may be regarded as the definition of a key and the associated data type
that can be returned by _DSD in the Device Properties UUID sub-package for a
Expand All @@ -36,7 +38,9 @@ Property subsets are nested collections of properties. Each of them is
associated with an additional key (name) allowing the subset to be referred
to as a whole (and to be treated as a separate entity). The canonical
representation of property subsets is via the mechanism specified in the
Hierarchical Properties Extension UUID definition document [2]_.
section titled "Well-Known _DSD UUIDs and Data Structure Formats" sub-section
"Hierarchical Data Extension UUID" in _DSD (Device Specific Data)
Implementation Guide document [1]_.

Property sets may be hierarchical. That is, a property set may contain
multiple property subsets that each may contain property subsets of its
Expand Down Expand Up @@ -96,5 +100,4 @@ contents.
References
==========

.. [1] https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf
.. [2] https://www.uefi.org/sites/default/files/resources/_DSD-hierarchical-data-extension-UUID-v1.1.pdf
.. [1] https://github.com/UEFI/DSD-Guide
2 changes: 1 addition & 1 deletion Documentation/firmware-guide/acpi/apei/einj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ An error injection example::
0x00000008 Memory Correctable
0x00000010 Memory Uncorrectable non-fatal
# echo 0x12345000 > param1 # Set memory address for injection
# echo $((-1 << 12)) > param2 # Mask 0xfffffffffffff000 - anywhere in this page
# echo 0xfffffffffffff000 > param2 # Mask - anywhere in this page
# echo 0x8 > error_type # Choose correctable memory error
# echo 1 > error_inject # Inject now

Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ config ACPI_TINY_POWER_BUTTON_SIGNAL

config ACPI_VIDEO
tristate "Video"
depends on X86 && BACKLIGHT_CLASS_DEVICE
depends on BACKLIGHT_CLASS_DEVICE
depends on INPUT
select THERMAL
help
Expand Down Expand Up @@ -255,7 +255,6 @@ config ACPI_DOCK

config ACPI_CPU_FREQ_PSS
bool
select THERMAL

config ACPI_PROCESSOR_CSTATE
def_bool y
Expand Down Expand Up @@ -287,6 +286,7 @@ config ACPI_PROCESSOR
depends on X86 || IA64 || ARM64 || LOONGARCH
select ACPI_PROCESSOR_IDLE
select ACPI_CPU_FREQ_PSS if X86 || IA64 || LOONGARCH
select THERMAL
default y
help
This driver adds support for the ACPI Processor package. It is required
Expand Down
5 changes: 2 additions & 3 deletions drivers/acpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ obj-$(CONFIG_ACPI_PPTT) += pptt.o
obj-$(CONFIG_ACPI_PFRUT) += pfr_update.o pfr_telemetry.o

# processor has its own "processor." module_param namespace
processor-y := processor_driver.o
processor-y := processor_driver.o processor_thermal.o
processor-$(CONFIG_ACPI_PROCESSOR_IDLE) += processor_idle.o
processor-$(CONFIG_ACPI_CPU_FREQ_PSS) += processor_throttling.o \
processor_thermal.o
processor-$(CONFIG_ACPI_CPU_FREQ_PSS) += processor_throttling.o
processor-$(CONFIG_CPU_FREQ) += processor_perflib.o

obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o
Expand Down
6 changes: 0 additions & 6 deletions drivers/acpi/acpi_lpit.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,11 @@ static void lpit_update_residency(struct lpit_residency_info *info,
if (!info->iomem_addr)
return;

if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0))
return;

/* Silently fail, if cpuidle attribute group is not present */
sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
&dev_attr_low_power_idle_system_residency_us.attr,
"cpuidle");
} else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0))
return;

/* Silently fail, if cpuidle attribute group is not present */
sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
&dev_attr_low_power_idle_cpu_residency_us.attr,
Expand Down
3 changes: 3 additions & 0 deletions drivers/acpi/acpi_lpss.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ static int register_device_clock(struct acpi_device *adev,
if (!lpss_clk_dev)
lpt_register_clock_device();

if (IS_ERR(lpss_clk_dev))
return PTR_ERR(lpss_clk_dev);

clk_data = platform_get_drvdata(lpss_clk_dev);
if (!clk_data)
return -ENODEV;
Expand Down
41 changes: 16 additions & 25 deletions drivers/acpi/acpi_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,24 +1150,25 @@ acpi_video_get_device_type(struct acpi_video_bus *video,
return 0;
}

static int
acpi_video_bus_get_one_device(struct acpi_device *device,
struct acpi_video_bus *video)
static int acpi_video_bus_get_one_device(struct acpi_device *device, void *arg)
{
unsigned long long device_id;
int status, device_type;
struct acpi_video_device *data;
struct acpi_video_bus *video = arg;
struct acpi_video_device_attrib *attribute;
struct acpi_video_device *data;
unsigned long long device_id;
acpi_status status;
int device_type;

status =
acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
/* Some device omits _ADR, we skip them instead of fail */
status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
/* Skip devices without _ADR instead of failing. */
if (ACPI_FAILURE(status))
return 0;
goto exit;

data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
if (!data)
if (!data) {
dev_dbg(&device->dev, "Cannot attach\n");
return -ENOMEM;
}

strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
Expand Down Expand Up @@ -1230,7 +1231,9 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
list_add_tail(&data->entry, &video->video_device_list);
mutex_unlock(&video->device_list_lock);

return status;
exit:
video->child_count++;
return 0;
}

/*
Expand Down Expand Up @@ -1542,26 +1545,14 @@ static int
acpi_video_bus_get_devices(struct acpi_video_bus *video,
struct acpi_device *device)
{
int status = 0;
struct acpi_device *dev;

/*
* There are systems where video module known to work fine regardless
* of broken _DOD and ignoring returned value here doesn't cause
* any issues later.
*/
acpi_video_device_enumerate(video);

list_for_each_entry(dev, &device->children, node) {

status = acpi_video_bus_get_one_device(dev, video);
if (status) {
dev_err(&dev->dev, "Can't attach device\n");
break;
}
video->child_count++;
}
return status;
return acpi_dev_for_each_child(device, acpi_video_bus_get_one_device, video);
}

/* acpi_video interface */
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/apei/apei-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* apei-base.c - ACPI Platform Error Interface (APEI) supporting
* infrastructure
*
* APEI allows to report errors (for example from the chipset) to the
* APEI allows to report errors (for example from the chipset) to
* the operating system. This improves NMI handling especially. In
* addition it supports error serialization and error injection.
*
Expand Down
31 changes: 23 additions & 8 deletions drivers/acpi/apei/bert.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,53 @@

#undef pr_fmt
#define pr_fmt(fmt) "BERT: " fmt

#define ACPI_BERT_PRINT_MAX_RECORDS 5
#define ACPI_BERT_PRINT_MAX_LEN 1024

static int bert_disable;

/*
* Print "all" the error records in the BERT table, but avoid huge spam to
* the console if the BIOS included oversize records, or too many records.
* Skipping some records here does not lose anything because the full
* data is available to user tools in:
* /sys/firmware/acpi/tables/data/BERT
*/
static void __init bert_print_all(struct acpi_bert_region *region,
unsigned int region_len)
{
struct acpi_hest_generic_status *estatus =
(struct acpi_hest_generic_status *)region;
int remain = region_len;
int printed = 0, skipped = 0;
u32 estatus_len;

while (remain >= sizeof(struct acpi_bert_region)) {
estatus_len = cper_estatus_len(estatus);
if (remain < estatus_len) {
pr_err(FW_BUG "Truncated status block (length: %u).\n",
estatus_len);
return;
break;
}

/* No more error records. */
if (!estatus->block_status)
return;
break;

if (cper_estatus_check(estatus)) {
pr_err(FW_BUG "Invalid error record.\n");
return;
break;
}

pr_info_once("Error records from previous boot:\n");
if (region_len < ACPI_BERT_PRINT_MAX_LEN)
if (estatus_len < ACPI_BERT_PRINT_MAX_LEN &&
printed < ACPI_BERT_PRINT_MAX_RECORDS) {
pr_info_once("Error records from previous boot:\n");
cper_estatus_print(KERN_INFO HW_ERR, estatus);
else
pr_info_once("Max print length exceeded, table data is available at:\n"
"/sys/firmware/acpi/tables/data/BERT");
printed++;
} else {
skipped++;
}

/*
* Because the boot error source is "one-time polled" type,
Expand All @@ -75,6 +87,9 @@ static void __init bert_print_all(struct acpi_bert_region *region,
estatus = (void *)estatus + estatus_len;
remain -= estatus_len;
}

if (skipped)
pr_info(HW_ERR "Skipped %d error records\n", skipped);
}

static int __init setup_bert_disable(char *str)
Expand Down
2 changes: 2 additions & 0 deletions drivers/acpi/apei/einj.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
!= REGION_INTERSECTS) &&
(region_intersects(base_addr, size, IORESOURCE_MEM, IORES_DESC_PERSISTENT_MEMORY)
!= REGION_INTERSECTS) &&
(region_intersects(base_addr, size, IORESOURCE_MEM, IORES_DESC_SOFT_RESERVED)
!= REGION_INTERSECTS) &&
!arch_is_platform_page(base_addr)))
return -EINVAL;

Expand Down
47 changes: 30 additions & 17 deletions drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ static void acpi_bus_osc_negotiate_usb_control(void)
static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
{
struct acpi_device *adev;
struct acpi_driver *driver;
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
bool hotplug_event = false;

Expand Down Expand Up @@ -516,10 +515,13 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
if (!adev)
goto err;

driver = adev->driver;
if (driver && driver->ops.notify &&
(driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
driver->ops.notify(adev, type);
if (adev->dev.driver) {
struct acpi_driver *driver = to_acpi_driver(adev->dev.driver);

if (driver && driver->ops.notify &&
(driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
driver->ops.notify(adev, type);
}

if (!hotplug_event) {
acpi_bus_put_acpi_device(adev);
Expand All @@ -538,8 +540,9 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
static void acpi_notify_device(acpi_handle handle, u32 event, void *data)
{
struct acpi_device *device = data;
struct acpi_driver *acpi_drv = to_acpi_driver(device->dev.driver);

device->driver->ops.notify(device, event);
acpi_drv->ops.notify(device, event);
}

static void acpi_notify_device_fixed(void *data)
Expand Down Expand Up @@ -1032,8 +1035,6 @@ static int acpi_device_probe(struct device *dev)
if (ret)
return ret;

acpi_dev->driver = acpi_drv;

pr_debug("Driver [%s] successfully bound to device [%s]\n",
acpi_drv->name, acpi_dev->pnp.bus_id);

Expand All @@ -1043,7 +1044,6 @@ static int acpi_device_probe(struct device *dev)
if (acpi_drv->ops.remove)
acpi_drv->ops.remove(acpi_dev);

acpi_dev->driver = NULL;
acpi_dev->driver_data = NULL;
return ret;
}
Expand All @@ -1059,15 +1059,14 @@ static int acpi_device_probe(struct device *dev)
static void acpi_device_remove(struct device *dev)
{
struct acpi_device *acpi_dev = to_acpi_device(dev);
struct acpi_driver *acpi_drv = acpi_dev->driver;
struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);

if (acpi_drv->ops.notify)
acpi_device_remove_notify_handler(acpi_dev);

if (acpi_drv->ops.remove)
acpi_drv->ops.remove(acpi_dev);

if (acpi_drv) {
if (acpi_drv->ops.notify)
acpi_device_remove_notify_handler(acpi_dev);
if (acpi_drv->ops.remove)
acpi_drv->ops.remove(acpi_dev);
}
acpi_dev->driver = NULL;
acpi_dev->driver_data = NULL;

put_device(dev);
Expand Down Expand Up @@ -1101,6 +1100,7 @@ static int acpi_dev_for_one_check(struct device *dev, void *context)

return adwc->fn(to_acpi_device(dev), adwc->data);
}
EXPORT_SYMBOL_GPL(acpi_dev_for_each_child);

int acpi_dev_for_each_child(struct acpi_device *adev,
int (*fn)(struct acpi_device *, void *), void *data)
Expand All @@ -1113,6 +1113,18 @@ int acpi_dev_for_each_child(struct acpi_device *adev,
return device_for_each_child(&adev->dev, &adwc, acpi_dev_for_one_check);
}

int acpi_dev_for_each_child_reverse(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_reverse(&adev->dev, &adwc, acpi_dev_for_one_check);
}

/* --------------------------------------------------------------------------
Initialization/Cleanup
-------------------------------------------------------------------------- */
Expand Down Expand Up @@ -1402,6 +1414,7 @@ static int __init acpi_init(void)

pci_mmcfg_late_init();
acpi_iort_init();
acpi_viot_early_init();
acpi_hest_init();
acpi_ghes_init();
acpi_scan_init();
Expand Down
Loading

0 comments on commit 8fa0db3

Please sign in to comment.