Skip to content

Commit ed0afd1

Browse files
committed
Merge branches 'acpi-pm', 'acpi-sysfs', 'acpi-pci' and 'acpi-resource'
Merge ACPI power management updates, ACPI sysfs interface updates, an ACPI support update related to PCI, and an ACPI device resources management update for 6.20-rc1/7.0-rc1: - Rework ACPI PM notification setup for PCI root buses and modify the ACPI PM setup for devices to register wakeup source objects under physical (that is, PCI, platform, etc.) devices instead of doing that under their ACPI companions (Rafael Wysocki) - Adjust debug messages regarding postponed ACPI PM printed during system resume to be more accurate (Rafael Wysocki) - Remove dead code from lps0_device_attach() (Gergo Koteles) - Start to invoke Microsoft Function 9 (Turn On Display) of the Low- Power S0 Idle (LPS0) _DSM in the suspend-to-idle resume flow on systems with ACPI LPS0 support to address a functional issue on Lenovo Yoga Slim 7i Aura (15ILL9), where system fans and keyboard backlights fail to resume after suspend (Jakob Riemenschneider) - Add sysfs attribute cid for exposing _CID lists under ACPI device objects (Rafael Wysocki) - Replace sprintf() with sysfs_emit() in all of the core ACPI sysfs interface code (Sumeet Pawnikar) - Use acpi_get_local_u64_address() in the code implementing ACPI support for PCI to evaluate _ADR instead of evaluating that object directly (Andy Shevchenko) - Add JWIPC JVC9100 to irq1_level_low_skip_override[] to unbreak serial IRQs on that system (Ai Chao) * acpi-pm: ACPI: x86: s2idle: Invoke Microsoft _DSM Function 9 (Turn On Display) ACPI: PM: Adjust messages regarding postponed ACPI PM ACPI: x86: s2idle: Remove dead code in lps0_device_attach() ACPI: PM: Register wakeup sources under physical devices ACPI: PCI: PM: Rework root bus notification setup * acpi-sysfs: ACPI: sysfs: Replace sprintf() with sysfs_emit() ACPI: sysfs: Add device cid attribute for exposing _CID lists * acpi-pci: ACPI: PCI: simplify code with acpi_get_local_u64_address() * acpi-resource: ACPI: resource: Add JWIPC JVC9100 to irq1_level_low_skip_override[]
5 parents 04cd14f + 229ecba + 785632d + ed0a1ac + ba6ded2 commit ed0afd1

9 files changed

Lines changed: 87 additions & 48 deletions

File tree

drivers/acpi/device_pm.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,7 @@ acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
586586
goto out;
587587

588588
mutex_lock(&acpi_pm_notifier_lock);
589-
adev->wakeup.ws = wakeup_source_register(&adev->dev,
590-
dev_name(&adev->dev));
589+
adev->wakeup.ws = wakeup_source_register(dev, dev_name(&adev->dev));
591590
adev->wakeup.context.dev = dev;
592591
adev->wakeup.context.func = func;
593592
adev->wakeup.flags.notifier_present = true;
@@ -1252,7 +1251,7 @@ static int acpi_subsys_resume_early(struct device *dev)
12521251
return 0;
12531252

12541253
if (pm && !pm->resume_early) {
1255-
dev_dbg(dev, "postponing D0 transition to normal resume stage\n");
1254+
dev_dbg(dev, "Postponing ACPI PM to normal resume stage\n");
12561255
return 0;
12571256
}
12581257

@@ -1274,7 +1273,7 @@ static int acpi_subsys_resume(struct device *dev)
12741273
int ret = 0;
12751274

12761275
if (!dev_pm_skip_resume(dev) && pm && !pm->resume_early) {
1277-
dev_dbg(dev, "executing postponed D0 transition\n");
1276+
dev_dbg(dev, "Applying postponed ACPI PM\n");
12781277
ret = acpi_dev_resume(dev);
12791278
}
12801279

drivers/acpi/device_sysfs.c

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static ssize_t acpi_object_path(acpi_handle handle, char *buf)
2727
if (result)
2828
return result;
2929

30-
result = sprintf(buf, "%s\n", (char *)path.pointer);
30+
result = sysfs_emit(buf, "%s\n", (char *)path.pointer);
3131
kfree(path.pointer);
3232
return result;
3333
}
@@ -347,7 +347,7 @@ static ssize_t real_power_state_show(struct device *dev,
347347
if (ret)
348348
return ret;
349349

350-
return sprintf(buf, "%s\n", acpi_power_state_string(state));
350+
return sysfs_emit(buf, "%s\n", acpi_power_state_string(state));
351351
}
352352

353353
static DEVICE_ATTR_RO(real_power_state);
@@ -357,7 +357,7 @@ static ssize_t power_state_show(struct device *dev,
357357
{
358358
struct acpi_device *adev = to_acpi_device(dev);
359359

360-
return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state));
360+
return sysfs_emit(buf, "%s\n", acpi_power_state_string(adev->power.state));
361361
}
362362

363363
static DEVICE_ATTR_RO(power_state);
@@ -399,16 +399,43 @@ hid_show(struct device *dev, struct device_attribute *attr, char *buf)
399399
{
400400
struct acpi_device *acpi_dev = to_acpi_device(dev);
401401

402-
return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
402+
return sysfs_emit(buf, "%s\n", acpi_device_hid(acpi_dev));
403403
}
404404
static DEVICE_ATTR_RO(hid);
405405

406+
static ssize_t cid_show(struct device *dev, struct device_attribute *attr,
407+
char *buf)
408+
{
409+
struct acpi_device *acpi_dev = to_acpi_device(dev);
410+
struct acpi_device_info *info = NULL;
411+
ssize_t len = 0;
412+
413+
acpi_get_object_info(acpi_dev->handle, &info);
414+
if (!info)
415+
return 0;
416+
417+
if (info->valid & ACPI_VALID_CID) {
418+
struct acpi_pnp_device_id_list *cid_list = &info->compatible_id_list;
419+
int i;
420+
421+
for (i = 0; i < cid_list->count - 1; i++)
422+
len += sysfs_emit_at(buf, len, "%s,", cid_list->ids[i].string);
423+
424+
len += sysfs_emit_at(buf, len, "%s\n", cid_list->ids[i].string);
425+
}
426+
427+
kfree(info);
428+
429+
return len;
430+
}
431+
static DEVICE_ATTR_RO(cid);
432+
406433
static ssize_t uid_show(struct device *dev,
407434
struct device_attribute *attr, char *buf)
408435
{
409436
struct acpi_device *acpi_dev = to_acpi_device(dev);
410437

411-
return sprintf(buf, "%s\n", acpi_device_uid(acpi_dev));
438+
return sysfs_emit(buf, "%s\n", acpi_device_uid(acpi_dev));
412439
}
413440
static DEVICE_ATTR_RO(uid);
414441

@@ -418,9 +445,9 @@ static ssize_t adr_show(struct device *dev,
418445
struct acpi_device *acpi_dev = to_acpi_device(dev);
419446

420447
if (acpi_dev->pnp.bus_address > U32_MAX)
421-
return sprintf(buf, "0x%016llx\n", acpi_dev->pnp.bus_address);
448+
return sysfs_emit(buf, "0x%016llx\n", acpi_dev->pnp.bus_address);
422449
else
423-
return sprintf(buf, "0x%08llx\n", acpi_dev->pnp.bus_address);
450+
return sysfs_emit(buf, "0x%08llx\n", acpi_dev->pnp.bus_address);
424451
}
425452
static DEVICE_ATTR_RO(adr);
426453

@@ -482,7 +509,7 @@ sun_show(struct device *dev, struct device_attribute *attr,
482509
if (ACPI_FAILURE(status))
483510
return -EIO;
484511

485-
return sprintf(buf, "%llu\n", sun);
512+
return sysfs_emit(buf, "%llu\n", sun);
486513
}
487514
static DEVICE_ATTR_RO(sun);
488515

@@ -498,7 +525,7 @@ hrv_show(struct device *dev, struct device_attribute *attr,
498525
if (ACPI_FAILURE(status))
499526
return -EIO;
500527

501-
return sprintf(buf, "%llu\n", hrv);
528+
return sysfs_emit(buf, "%llu\n", hrv);
502529
}
503530
static DEVICE_ATTR_RO(hrv);
504531

@@ -513,13 +540,14 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr,
513540
if (ACPI_FAILURE(status))
514541
return -EIO;
515542

516-
return sprintf(buf, "%llu\n", sta);
543+
return sysfs_emit(buf, "%llu\n", sta);
517544
}
518545
static DEVICE_ATTR_RO(status);
519546

520547
static struct attribute *acpi_attrs[] = {
521548
&dev_attr_path.attr,
522549
&dev_attr_hid.attr,
550+
&dev_attr_cid.attr,
523551
&dev_attr_modalias.attr,
524552
&dev_attr_description.attr,
525553
&dev_attr_adr.attr,
@@ -562,6 +590,9 @@ static bool acpi_show_attr(struct acpi_device *dev, const struct device_attribut
562590
if (attr == &dev_attr_status)
563591
return acpi_has_method(dev->handle, "_STA");
564592

593+
if (attr == &dev_attr_cid)
594+
return acpi_has_method(dev->handle, "_CID");
595+
565596
/*
566597
* If device has _EJ0, 'eject' file is created that is used to trigger
567598
* hot-removal function from userland.

drivers/acpi/pci_root.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
738738
if (no_aspm)
739739
pcie_no_aspm();
740740

741-
pci_acpi_add_bus_pm_notifier(device);
741+
pci_acpi_add_root_pm_notifier(device, root);
742742
device_set_wakeup_capable(root->bus->bridge, device->wakeup.flags.valid);
743743

744744
if (hotadd) {

drivers/acpi/pci_slot.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ static int
4242
check_slot(acpi_handle handle, unsigned long long *sun)
4343
{
4444
int device = -1;
45-
unsigned long long adr, sta;
45+
unsigned long long sta;
4646
acpi_status status;
47+
u64 adr;
4748
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
4849

4950
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
@@ -56,10 +57,9 @@ check_slot(acpi_handle handle, unsigned long long *sun)
5657
goto out;
5758
}
5859

59-
status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
60-
if (ACPI_FAILURE(status)) {
61-
pr_debug("_ADR returned %d on %s\n",
62-
status, (char *)buffer.pointer);
60+
if (acpi_get_local_u64_address(handle, &adr)) {
61+
pr_debug("_ADR returned with failure on %s\n",
62+
(char *)buffer.pointer);
6363
goto out;
6464
}
6565

drivers/acpi/resource.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,12 @@ static const struct dmi_system_id irq1_level_low_skip_override[] = {
532532
DMI_MATCH(DMI_BOARD_NAME, "16T90SP"),
533533
},
534534
},
535+
{
536+
/* JWIPC JVC9100 */
537+
.matches = {
538+
DMI_MATCH(DMI_BOARD_NAME, "JVC9100"),
539+
},
540+
},
535541
{ }
536542
};
537543

@@ -706,6 +712,8 @@ struct irq_override_cmp {
706712

707713
static const struct irq_override_cmp override_table[] = {
708714
{ irq1_level_low_skip_override, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
715+
{ irq1_level_low_skip_override, 10, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 1, false },
716+
{ irq1_level_low_skip_override, 11, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 1, false },
709717
{ irq1_edge_low_force_override, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
710718
};
711719

drivers/acpi/sysfs.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ static ssize_t counter_show(struct kobject *kobj,
687687
acpi_irq_not_handled;
688688
all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count =
689689
acpi_gpe_count;
690-
size = sprintf(buf, "%8u", all_counters[index].count);
690+
size = sysfs_emit(buf, "%8u", all_counters[index].count);
691691

692692
/* "gpe_all" or "sci" */
693693
if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
@@ -698,29 +698,29 @@ static ssize_t counter_show(struct kobject *kobj,
698698
goto end;
699699

700700
if (status & ACPI_EVENT_FLAG_ENABLE_SET)
701-
size += sprintf(buf + size, " EN");
701+
size += sysfs_emit_at(buf, size, " EN");
702702
else
703-
size += sprintf(buf + size, " ");
703+
size += sysfs_emit_at(buf, size, " ");
704704
if (status & ACPI_EVENT_FLAG_STATUS_SET)
705-
size += sprintf(buf + size, " STS");
705+
size += sysfs_emit_at(buf, size, " STS");
706706
else
707-
size += sprintf(buf + size, " ");
707+
size += sysfs_emit_at(buf, size, " ");
708708

709709
if (!(status & ACPI_EVENT_FLAG_HAS_HANDLER))
710-
size += sprintf(buf + size, " invalid ");
710+
size += sysfs_emit_at(buf, size, " invalid ");
711711
else if (status & ACPI_EVENT_FLAG_ENABLED)
712-
size += sprintf(buf + size, " enabled ");
712+
size += sysfs_emit_at(buf, size, " enabled ");
713713
else if (status & ACPI_EVENT_FLAG_WAKE_ENABLED)
714-
size += sprintf(buf + size, " wake_enabled");
714+
size += sysfs_emit_at(buf, size, " wake_enabled");
715715
else
716-
size += sprintf(buf + size, " disabled ");
716+
size += sysfs_emit_at(buf, size, " disabled ");
717717
if (status & ACPI_EVENT_FLAG_MASKED)
718-
size += sprintf(buf + size, " masked ");
718+
size += sysfs_emit_at(buf, size, " masked ");
719719
else
720-
size += sprintf(buf + size, " unmasked");
720+
size += sysfs_emit_at(buf, size, " unmasked");
721721

722722
end:
723-
size += sprintf(buf + size, "\n");
723+
size += sysfs_emit_at(buf, size, "\n");
724724
return result ? result : size;
725725
}
726726

@@ -937,7 +937,7 @@ static void __exit interrupt_stats_exit(void)
937937

938938
static ssize_t pm_profile_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
939939
{
940-
return sprintf(buf, "%d\n", acpi_gbl_FADT.preferred_profile);
940+
return sysfs_emit(buf, "%d\n", acpi_gbl_FADT.preferred_profile);
941941
}
942942

943943
static const struct kobj_attribute pm_profile_attr = __ATTR_RO(pm_profile);
@@ -946,7 +946,7 @@ static ssize_t enabled_show(struct kobject *kobj, struct kobj_attribute *attr, c
946946
{
947947
struct acpi_hotplug_profile *hotplug = to_acpi_hotplug_profile(kobj);
948948

949-
return sprintf(buf, "%d\n", hotplug->enabled);
949+
return sysfs_emit(buf, "%d\n", hotplug->enabled);
950950
}
951951

952952
static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr,
@@ -1000,7 +1000,7 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
10001000
static ssize_t force_remove_show(struct kobject *kobj,
10011001
struct kobj_attribute *attr, char *buf)
10021002
{
1003-
return sprintf(buf, "%d\n", 0);
1003+
return sysfs_emit(buf, "%d\n", 0);
10041004
}
10051005

10061006
static ssize_t force_remove_store(struct kobject *kobj,

drivers/acpi/x86/s2idle.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static const struct acpi_device_id lps0_device_ids[] = {
4949
#define ACPI_LPS0_EXIT 6
5050
#define ACPI_LPS0_MS_ENTRY 7
5151
#define ACPI_LPS0_MS_EXIT 8
52+
#define ACPI_MS_TURN_ON_DISPLAY 9
5253

5354
/* AMD */
5455
#define ACPI_LPS0_DSM_UUID_AMD "e3f32452-febc-43ce-9039-932122d37721"
@@ -356,6 +357,8 @@ static const char *acpi_sleep_dsm_state_to_str(unsigned int state)
356357
return "lps0 ms entry";
357358
case ACPI_LPS0_MS_EXIT:
358359
return "lps0 ms exit";
360+
case ACPI_MS_TURN_ON_DISPLAY:
361+
return "lps0 ms turn on display";
359362
}
360363
} else {
361364
switch (state) {
@@ -463,9 +466,6 @@ static int lps0_device_attach(struct acpi_device *adev,
463466
lps0_dsm_func_mask = (lps0_dsm_func_mask << 1) | 0x1;
464467
acpi_handle_debug(adev->handle, "_DSM UUID %s: Adjusted function mask: 0x%x\n",
465468
ACPI_LPS0_DSM_UUID_AMD, lps0_dsm_func_mask);
466-
} else if (lps0_dsm_func_mask_microsoft > 0 && rev_id) {
467-
lps0_dsm_func_mask_microsoft = -EINVAL;
468-
acpi_handle_debug(adev->handle, "_DSM Using AMD method\n");
469469
}
470470
} else {
471471
rev_id = 1;
@@ -617,6 +617,9 @@ static void acpi_s2idle_restore_early_lps0(void)
617617
if (lps0_dsm_func_mask_microsoft > 0) {
618618
acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT,
619619
lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
620+
/* Intent to turn on display */
621+
acpi_sleep_run_lps0_dsm(ACPI_MS_TURN_ON_DISPLAY,
622+
lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
620623
/* Modern Standby exit */
621624
acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT,
622625
lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);

drivers/pci/pci-acpi.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -847,12 +847,7 @@ bool shpchp_is_native(struct pci_dev *bridge)
847847
*/
848848
static void pci_acpi_wake_bus(struct acpi_device_wakeup_context *context)
849849
{
850-
struct acpi_device *adev;
851-
struct acpi_pci_root *root;
852-
853-
adev = container_of(context, struct acpi_device, wakeup.context);
854-
root = acpi_driver_data(adev);
855-
pci_pme_wakeup_bus(root->bus);
850+
pci_pme_wakeup_bus(to_pci_host_bridge(context->dev)->bus);
856851
}
857852

858853
/**
@@ -885,12 +880,14 @@ static void pci_acpi_wake_dev(struct acpi_device_wakeup_context *context)
885880
}
886881

887882
/**
888-
* pci_acpi_add_bus_pm_notifier - Register PM notifier for root PCI bus.
883+
* pci_acpi_add_root_pm_notifier - Register PM notifier for root PCI bus.
889884
* @dev: PCI root bridge ACPI device.
885+
* @root: PCI root corresponding to @dev.
890886
*/
891-
acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev)
887+
acpi_status pci_acpi_add_root_pm_notifier(struct acpi_device *dev,
888+
struct acpi_pci_root *root)
892889
{
893-
return acpi_add_pm_notifier(dev, NULL, pci_acpi_wake_bus);
890+
return acpi_add_pm_notifier(dev, root->bus->bridge, pci_acpi_wake_bus);
894891
}
895892

896893
/**

include/linux/pci-acpi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#include <linux/acpi.h>
1313

1414
#ifdef CONFIG_ACPI
15-
extern acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev);
15+
extern acpi_status pci_acpi_add_root_pm_notifier(struct acpi_device *dev,
16+
struct acpi_pci_root *pci_root);
1617
static inline acpi_status pci_acpi_remove_bus_pm_notifier(struct acpi_device *dev)
1718
{
1819
return acpi_remove_pm_notifier(dev);

0 commit comments

Comments
 (0)