Skip to content

Commit b659ea7

Browse files
committed
Merge branches 'acpi-scan', 'acpi-pm', 'acpi-power' and 'acpi-pci'
Merge ACPI device enumeration updates, ACPI power management updates and PCI host bridge ACPI driver updates for 5.17-rc1: - Introduce acpi_fetch_acpi_dev() as a replacement for acpi_bus_get_device() and use it in the ACPI subsystem (Rafael Wysocki). - Avoid using _CID for device enumaration if _HID is missing or invalid (Rafael Wysocki). - Rework quirk handling during ACPI device enumeration and add some new quirks for known broken platforms (Hans de Goede). - Avoid unnecessary or redundant CPU cache flushing during system PM transitions (Kirill A. Shutemov). - Add PM debug messages related to power resources (Rafael Wysocki). - Fix kernel-doc comment in the PCI host bridge ACPI driver (Yang Li). * acpi-scan: serdev: Do not instantiate serdevs on boards with known bogus DSDT entries i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration() helpers ACPI: scan: Create platform device for BCM4752 and LNV4752 ACPI nodes ACPI: Use acpi_fetch_acpi_dev() instead of acpi_bus_get_device() ACPI: scan: Introduce acpi_fetch_acpi_dev() ACPI: scan: Do not add device IDs from _CID if _HID is not valid * acpi-pm: ACPI: PM: Remove redundant cache flushing ACPI: PM: Avoid CPU cache flush when entering S4 * acpi-power: ACPI: PM: Emit debug messages when enabling/disabling wakeup power * acpi-pci: PCI/ACPI: Fix acpi_pci_osc_control_set() kernel-doc comment
5 parents 77e2a04 + 0890186 + 3c89857 + 5b6a8f1 + 843438d commit b659ea7

19 files changed

Lines changed: 251 additions & 88 deletions

drivers/acpi/acpi_video.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,13 +1733,12 @@ acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
17331733
{
17341734
struct acpi_device *device = context;
17351735
struct acpi_device *sibling;
1736-
int result;
17371736

17381737
if (handle == device->handle)
17391738
return AE_CTRL_TERMINATE;
17401739

1741-
result = acpi_bus_get_device(handle, &sibling);
1742-
if (result)
1740+
sibling = acpi_fetch_acpi_dev(handle);
1741+
if (!sibling)
17431742
return AE_OK;
17441743

17451744
if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))

drivers/acpi/device_pm.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,12 @@ EXPORT_SYMBOL(acpi_device_set_power);
285285

286286
int acpi_bus_set_power(acpi_handle handle, int state)
287287
{
288-
struct acpi_device *device;
289-
int result;
288+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
290289

291-
result = acpi_bus_get_device(handle, &device);
292-
if (result)
293-
return result;
290+
if (device)
291+
return acpi_device_set_power(device, state);
294292

295-
return acpi_device_set_power(device, state);
293+
return -ENODEV;
296294
}
297295
EXPORT_SYMBOL(acpi_bus_set_power);
298296

@@ -410,21 +408,20 @@ EXPORT_SYMBOL_GPL(acpi_device_update_power);
410408

411409
int acpi_bus_update_power(acpi_handle handle, int *state_p)
412410
{
413-
struct acpi_device *device;
414-
int result;
411+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
415412

416-
result = acpi_bus_get_device(handle, &device);
417-
return result ? result : acpi_device_update_power(device, state_p);
413+
if (device)
414+
return acpi_device_update_power(device, state_p);
415+
416+
return -ENODEV;
418417
}
419418
EXPORT_SYMBOL_GPL(acpi_bus_update_power);
420419

421420
bool acpi_bus_power_manageable(acpi_handle handle)
422421
{
423-
struct acpi_device *device;
424-
int result;
422+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
425423

426-
result = acpi_bus_get_device(handle, &device);
427-
return result ? false : device->flags.power_manageable;
424+
return device && device->flags.power_manageable;
428425
}
429426
EXPORT_SYMBOL(acpi_bus_power_manageable);
430427

@@ -543,11 +540,9 @@ acpi_status acpi_remove_pm_notifier(struct acpi_device *adev)
543540

544541
bool acpi_bus_can_wakeup(acpi_handle handle)
545542
{
546-
struct acpi_device *device;
547-
int result;
543+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
548544

549-
result = acpi_bus_get_device(handle, &device);
550-
return result ? false : device->wakeup.flags.valid;
545+
return device && device->wakeup.flags.valid;
551546
}
552547
EXPORT_SYMBOL(acpi_bus_can_wakeup);
553548

drivers/acpi/dock.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,8 @@ static ssize_t docked_show(struct device *dev,
489489
struct device_attribute *attr, char *buf)
490490
{
491491
struct dock_station *dock_station = dev->platform_data;
492-
struct acpi_device *adev = NULL;
492+
struct acpi_device *adev = acpi_fetch_acpi_dev(dock_station->handle);
493493

494-
acpi_bus_get_device(dock_station->handle, &adev);
495494
return sysfs_emit(buf, "%u\n", acpi_device_enumerated(adev));
496495
}
497496
static DEVICE_ATTR_RO(docked);

drivers/acpi/pci_link.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,10 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
606606
int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
607607
int *polarity, char **name)
608608
{
609-
int result;
610-
struct acpi_device *device;
609+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
611610
struct acpi_pci_link *link;
612611

613-
result = acpi_bus_get_device(handle, &device);
614-
if (result) {
612+
if (!device) {
615613
acpi_handle_err(handle, "Invalid link device\n");
616614
return -1;
617615
}
@@ -658,12 +656,10 @@ int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
658656
*/
659657
int acpi_pci_link_free_irq(acpi_handle handle)
660658
{
661-
struct acpi_device *device;
659+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
662660
struct acpi_pci_link *link;
663-
acpi_status result;
664661

665-
result = acpi_bus_get_device(handle, &device);
666-
if (result) {
662+
if (!device) {
667663
acpi_handle_err(handle, "Invalid link device\n");
668664
return -1;
669665
}

drivers/acpi/pci_root.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ static struct acpi_scan_handler pci_root_handler = {
6767
*/
6868
int acpi_is_root_bridge(acpi_handle handle)
6969
{
70+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
7071
int ret;
71-
struct acpi_device *device;
7272

73-
ret = acpi_bus_get_device(handle, &device);
74-
if (ret)
73+
if (!device)
7574
return 0;
7675

7776
ret = acpi_match_device_ids(device, root_device_ids);
@@ -215,11 +214,10 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
215214

216215
struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
217216
{
217+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
218218
struct acpi_pci_root *root;
219-
struct acpi_device *device;
220219

221-
if (acpi_bus_get_device(handle, &device) ||
222-
acpi_match_device_ids(device, root_device_ids))
220+
if (!device || acpi_match_device_ids(device, root_device_ids))
223221
return NULL;
224222

225223
root = acpi_driver_data(device);
@@ -324,7 +322,7 @@ EXPORT_SYMBOL_GPL(acpi_get_pci_dev);
324322
* acpi_pci_osc_control_set - Request control of PCI root _OSC features.
325323
* @handle: ACPI handle of a PCI root bridge (or PCIe Root Complex).
326324
* @mask: Mask of _OSC bits to request control of, place to store control mask.
327-
* @req: Mask of _OSC bits the control of is essential to the caller.
325+
* @support: _OSC supported capability.
328326
*
329327
* Run _OSC query for @mask and if that is successful, compare the returned
330328
* mask of control bits with @req. If all of the @req bits are set in the

drivers/acpi/power.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ struct acpi_power_resource *to_power_resource(struct acpi_device *device)
8181

8282
static struct acpi_power_resource *acpi_power_get_context(acpi_handle handle)
8383
{
84-
struct acpi_device *device;
84+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
8585

86-
if (acpi_bus_get_device(handle, &device))
86+
if (!device)
8787
return NULL;
8888

8989
return to_power_resource(device);
@@ -716,6 +716,9 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
716716

717717
mutex_lock(&acpi_device_lock);
718718

719+
dev_dbg(&dev->dev, "Enabling wakeup power (count %d)\n",
720+
dev->wakeup.prepare_count);
721+
719722
if (dev->wakeup.prepare_count++)
720723
goto out;
721724

@@ -734,8 +737,11 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
734737
if (err) {
735738
acpi_power_off_list(&dev->wakeup.resources);
736739
dev->wakeup.prepare_count = 0;
740+
goto out;
737741
}
738742

743+
dev_dbg(&dev->dev, "Wakeup power enabled\n");
744+
739745
out:
740746
mutex_unlock(&acpi_device_lock);
741747
return err;
@@ -757,6 +763,9 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
757763

758764
mutex_lock(&acpi_device_lock);
759765

766+
dev_dbg(&dev->dev, "Disabling wakeup power (count %d)\n",
767+
dev->wakeup.prepare_count);
768+
760769
/* Do nothing if wakeup power has not been enabled for this device. */
761770
if (dev->wakeup.prepare_count <= 0)
762771
goto out;
@@ -782,8 +791,11 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
782791
if (err) {
783792
dev_err(&dev->dev, "Cannot turn off wakeup power resources\n");
784793
dev->wakeup.flags.valid = 0;
794+
goto out;
785795
}
786796

797+
dev_dbg(&dev->dev, "Wakeup power disabled\n");
798+
787799
out:
788800
mutex_unlock(&acpi_device_lock);
789801
return err;
@@ -916,15 +928,14 @@ static void acpi_power_add_resource_to_list(struct acpi_power_resource *resource
916928

917929
struct acpi_device *acpi_add_power_resource(acpi_handle handle)
918930
{
931+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
919932
struct acpi_power_resource *resource;
920-
struct acpi_device *device = NULL;
921933
union acpi_object acpi_object;
922934
struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
923935
acpi_status status;
924936
u8 state_dummy;
925937
int result;
926938

927-
acpi_bus_get_device(handle, &device);
928939
if (device)
929940
return device;
930941

drivers/acpi/processor_driver.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,13 @@ static int acpi_soft_cpu_online(unsigned int cpu)
9898
struct acpi_processor *pr = per_cpu(processors, cpu);
9999
struct acpi_device *device;
100100

101-
if (!pr || acpi_bus_get_device(pr->handle, &device))
101+
if (!pr)
102+
return 0;
103+
104+
device = acpi_fetch_acpi_dev(pr->handle);
105+
if (!device)
102106
return 0;
107+
103108
/*
104109
* CPU got physically hotplugged and onlined for the first time:
105110
* Initialize missing things.
@@ -125,9 +130,8 @@ static int acpi_soft_cpu_online(unsigned int cpu)
125130
static int acpi_soft_cpu_dead(unsigned int cpu)
126131
{
127132
struct acpi_processor *pr = per_cpu(processors, cpu);
128-
struct acpi_device *device;
129133

130-
if (!pr || acpi_bus_get_device(pr->handle, &device))
134+
if (!pr || !acpi_fetch_acpi_dev(pr->handle))
131135
return 0;
132136

133137
acpi_processor_reevaluate_tstate(pr, true);

drivers/acpi/processor_idle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
11011101

11021102
status = acpi_get_parent(handle, &pr_ahandle);
11031103
while (ACPI_SUCCESS(status)) {
1104-
acpi_bus_get_device(pr_ahandle, &d);
1104+
d = acpi_fetch_acpi_dev(pr_ahandle);
11051105
handle = pr_ahandle;
11061106

11071107
if (strcmp(acpi_device_hid(d), ACPI_PROCESSOR_CONTAINER_HID))

drivers/acpi/property.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,9 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
687687
if (index)
688688
return -EINVAL;
689689

690-
ret = acpi_bus_get_device(obj->reference.handle, &device);
691-
if (ret)
692-
return ret == -ENODEV ? -EINVAL : ret;
690+
device = acpi_fetch_acpi_dev(obj->reference.handle);
691+
if (!device)
692+
return -EINVAL;
693693

694694
args->fwnode = acpi_fwnode_handle(device);
695695
args->nargs = 0;
@@ -719,9 +719,8 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
719719
if (element->type == ACPI_TYPE_LOCAL_REFERENCE) {
720720
struct fwnode_handle *ref_fwnode;
721721

722-
ret = acpi_bus_get_device(element->reference.handle,
723-
&device);
724-
if (ret)
722+
device = acpi_fetch_acpi_dev(element->reference.handle);
723+
if (!device)
725724
return -EINVAL;
726725

727726
nargs = 0;

drivers/acpi/resource.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,9 @@ static acpi_status acpi_res_consumer_cb(acpi_handle handle, u32 depth,
791791
{
792792
struct resource *res = context;
793793
struct acpi_device **consumer = (struct acpi_device **) ret;
794-
struct acpi_device *adev;
794+
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
795795

796-
if (acpi_bus_get_device(handle, &adev))
796+
if (!adev)
797797
return AE_OK;
798798

799799
if (acpi_dev_consumes_res(adev, res)) {

0 commit comments

Comments
 (0)