Skip to content

Commit 76d749c

Browse files
vlsunilrafaeljw
authored andcommitted
ACPI: scan: Refactor dependency creation
Some architectures like RISC-V will use implicit dependencies like GSI map to create dependencies between interrupt controller and devices. To support doing that, the function which creates the dependency, is refactored bit and made public so that dependency can be added from outside of scan.c as well. Signed-off-by: Sunil V L <[email protected]> Tested-by: Björn Töpel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent f7d7ccf commit 76d749c

File tree

2 files changed

+48
-39
lines changed

2 files changed

+48
-39
lines changed

drivers/acpi/scan.c

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,49 @@ void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val)
20132013
mutex_unlock(&acpi_scan_lock);
20142014
}
20152015

2016+
int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices)
2017+
{
2018+
u32 count;
2019+
int i;
2020+
2021+
for (count = 0, i = 0; i < dep_devices->count; i++) {
2022+
struct acpi_device_info *info;
2023+
struct acpi_dep_data *dep;
2024+
bool skip, honor_dep;
2025+
acpi_status status;
2026+
2027+
status = acpi_get_object_info(dep_devices->handles[i], &info);
2028+
if (ACPI_FAILURE(status)) {
2029+
acpi_handle_debug(handle, "Error reading _DEP device info\n");
2030+
continue;
2031+
}
2032+
2033+
skip = acpi_info_matches_ids(info, acpi_ignore_dep_ids);
2034+
honor_dep = acpi_info_matches_ids(info, acpi_honor_dep_ids);
2035+
kfree(info);
2036+
2037+
if (skip)
2038+
continue;
2039+
2040+
dep = kzalloc(sizeof(*dep), GFP_KERNEL);
2041+
if (!dep)
2042+
continue;
2043+
2044+
count++;
2045+
2046+
dep->supplier = dep_devices->handles[i];
2047+
dep->consumer = handle;
2048+
dep->honor_dep = honor_dep;
2049+
2050+
mutex_lock(&acpi_dep_list_lock);
2051+
list_add_tail(&dep->node, &acpi_dep_list);
2052+
mutex_unlock(&acpi_dep_list_lock);
2053+
}
2054+
2055+
acpi_handle_list_free(dep_devices);
2056+
return count;
2057+
}
2058+
20162059
static void acpi_scan_init_hotplug(struct acpi_device *adev)
20172060
{
20182061
struct acpi_hardware_id *hwid;
@@ -2035,8 +2078,7 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev)
20352078
static u32 acpi_scan_check_dep(acpi_handle handle)
20362079
{
20372080
struct acpi_handle_list dep_devices;
2038-
u32 count;
2039-
int i;
2081+
u32 count = 0;
20402082

20412083
/*
20422084
* Check for _HID here to avoid deferring the enumeration of:
@@ -2045,48 +2087,14 @@ static u32 acpi_scan_check_dep(acpi_handle handle)
20452087
* Still, checking for _HID catches more then just these cases ...
20462088
*/
20472089
if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID"))
2048-
return 0;
2090+
return count;
20492091

20502092
if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) {
20512093
acpi_handle_debug(handle, "Failed to evaluate _DEP.\n");
2052-
return 0;
2053-
}
2054-
2055-
for (count = 0, i = 0; i < dep_devices.count; i++) {
2056-
struct acpi_device_info *info;
2057-
struct acpi_dep_data *dep;
2058-
bool skip, honor_dep;
2059-
acpi_status status;
2060-
2061-
status = acpi_get_object_info(dep_devices.handles[i], &info);
2062-
if (ACPI_FAILURE(status)) {
2063-
acpi_handle_debug(handle, "Error reading _DEP device info\n");
2064-
continue;
2065-
}
2066-
2067-
skip = acpi_info_matches_ids(info, acpi_ignore_dep_ids);
2068-
honor_dep = acpi_info_matches_ids(info, acpi_honor_dep_ids);
2069-
kfree(info);
2070-
2071-
if (skip)
2072-
continue;
2073-
2074-
dep = kzalloc(sizeof(*dep), GFP_KERNEL);
2075-
if (!dep)
2076-
continue;
2077-
2078-
count++;
2079-
2080-
dep->supplier = dep_devices.handles[i];
2081-
dep->consumer = handle;
2082-
dep->honor_dep = honor_dep;
2083-
2084-
mutex_lock(&acpi_dep_list_lock);
2085-
list_add_tail(&dep->node , &acpi_dep_list);
2086-
mutex_unlock(&acpi_dep_list_lock);
2094+
return count;
20872095
}
20882096

2089-
acpi_handle_list_free(&dep_devices);
2097+
count += acpi_scan_add_dep(handle, &dep_devices);
20902098
return count;
20912099
}
20922100

include/acpi/acpi_bus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ static inline void acpi_put_acpi_dev(struct acpi_device *adev)
993993

994994
int acpi_wait_for_acpi_ipmi(void);
995995

996+
int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices);
996997
#else /* CONFIG_ACPI */
997998

998999
static inline int register_acpi_bus_type(void *bus) { return 0; }

0 commit comments

Comments
 (0)