Skip to content

Commit 7931c53

Browse files
committed
Merge tag 'acpi-5.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI fixes from Rafael Wysocki: "These fix a memory management regression in ACPICA, repair an ACPI blacklist entry damaged inadvertently during the 5.11 cycle and fix the bookkeeping of devices with the same primary device ID in the ACPI core. Specifics: - Make ACPICA use the same object cache consistently when allocating and freeing objects (Vegard Nossum) - Add a callback pointer removed inadvertently during the 5.11 cycle to the ACPI backlight blacklist entry for Sony VPCEH3U1E (Chris Chiu) - Make the ACPI device enumeration core use IDA for creating names of ACPI device objects with the same primary device ID to avoid using duplicate device object names in some cases (Andy Shevchenko)" * tag 'acpi-5.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPICA: Always create namespace nodes using acpi_ns_create_node() ACPI: scan: Use unique number for instance_no ACPI: video: Add missing callback back for Sony VPCEH3U1E
2 parents 8a3cbdd + e1db18b commit 7931c53

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

drivers/acpi/acpica/nsaccess.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,12 @@ acpi_status acpi_ns_root_initialize(void)
9999
* just create and link the new node(s) here.
100100
*/
101101
new_node =
102-
ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_namespace_node));
102+
acpi_ns_create_node(*ACPI_CAST_PTR(u32, init_val->name));
103103
if (!new_node) {
104104
status = AE_NO_MEMORY;
105105
goto unlock_and_exit;
106106
}
107107

108-
ACPI_COPY_NAMESEG(new_node->name.ascii, init_val->name);
109108
new_node->descriptor_type = ACPI_DESC_TYPE_NAMED;
110109
new_node->type = init_val->type;
111110

drivers/acpi/internal.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef _ACPI_INTERNAL_H_
1010
#define _ACPI_INTERNAL_H_
1111

12+
#include <linux/idr.h>
13+
1214
#define PREFIX "ACPI: "
1315

1416
int early_acpi_osi_init(void);
@@ -96,9 +98,11 @@ void acpi_scan_table_handler(u32 event, void *table, void *context);
9698

9799
extern struct list_head acpi_bus_id_list;
98100

101+
#define ACPI_MAX_DEVICE_INSTANCES 4096
102+
99103
struct acpi_device_bus_id {
100104
const char *bus_id;
101-
unsigned int instance_no;
105+
struct ida instance_ida;
102106
struct list_head node;
103107
};
104108

drivers/acpi/scan.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,8 @@ static void acpi_device_del(struct acpi_device *device)
479479
list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node)
480480
if (!strcmp(acpi_device_bus_id->bus_id,
481481
acpi_device_hid(device))) {
482-
if (acpi_device_bus_id->instance_no > 0)
483-
acpi_device_bus_id->instance_no--;
484-
else {
482+
ida_simple_remove(&acpi_device_bus_id->instance_ida, device->pnp.instance_no);
483+
if (ida_is_empty(&acpi_device_bus_id->instance_ida)) {
485484
list_del(&acpi_device_bus_id->node);
486485
kfree_const(acpi_device_bus_id->bus_id);
487486
kfree(acpi_device_bus_id);
@@ -631,6 +630,21 @@ static struct acpi_device_bus_id *acpi_device_bus_id_match(const char *dev_id)
631630
return NULL;
632631
}
633632

633+
static int acpi_device_set_name(struct acpi_device *device,
634+
struct acpi_device_bus_id *acpi_device_bus_id)
635+
{
636+
struct ida *instance_ida = &acpi_device_bus_id->instance_ida;
637+
int result;
638+
639+
result = ida_simple_get(instance_ida, 0, ACPI_MAX_DEVICE_INSTANCES, GFP_KERNEL);
640+
if (result < 0)
641+
return result;
642+
643+
device->pnp.instance_no = result;
644+
dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, result);
645+
return 0;
646+
}
647+
634648
int acpi_device_add(struct acpi_device *device,
635649
void (*release)(struct device *))
636650
{
@@ -665,7 +679,9 @@ int acpi_device_add(struct acpi_device *device,
665679

666680
acpi_device_bus_id = acpi_device_bus_id_match(acpi_device_hid(device));
667681
if (acpi_device_bus_id) {
668-
acpi_device_bus_id->instance_no++;
682+
result = acpi_device_set_name(device, acpi_device_bus_id);
683+
if (result)
684+
goto err_unlock;
669685
} else {
670686
acpi_device_bus_id = kzalloc(sizeof(*acpi_device_bus_id),
671687
GFP_KERNEL);
@@ -681,9 +697,16 @@ int acpi_device_add(struct acpi_device *device,
681697
goto err_unlock;
682698
}
683699

700+
ida_init(&acpi_device_bus_id->instance_ida);
701+
702+
result = acpi_device_set_name(device, acpi_device_bus_id);
703+
if (result) {
704+
kfree(acpi_device_bus_id);
705+
goto err_unlock;
706+
}
707+
684708
list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list);
685709
}
686-
dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no);
687710

688711
if (device->parent)
689712
list_add_tail(&device->node, &device->parent->children);

drivers/acpi/video_detect.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
147147
},
148148
},
149149
{
150+
.callback = video_detect_force_vendor,
150151
.ident = "Sony VPCEH3U1E",
151152
.matches = {
152153
DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),

include/acpi/acpi_bus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ struct acpi_pnp_type {
233233

234234
struct acpi_device_pnp {
235235
acpi_bus_id bus_id; /* Object name */
236+
int instance_no; /* Instance number of this object */
236237
struct acpi_pnp_type type; /* ID type */
237238
acpi_bus_address bus_address; /* _ADR */
238239
char *unique_id; /* _UID */

0 commit comments

Comments
 (0)