* [PATCH v2 1/8] driver core: auxiliary bus: Introduce dev_is_auxiliary()
[not found] <6271415.lOV4Wx5bFT@rafael.j.wysocki>
@ 2026-03-13 12:53 ` Rafael J. Wysocki
2026-03-13 14:02 ` Greg Kroah-Hartman
2026-03-13 14:09 ` Danilo Krummrich
2026-03-13 12:56 ` [PATCH v2 2/8] ACPI: video: Rework checking for duplicate video bus devices Rafael J. Wysocki
1 sibling, 2 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2026-03-13 12:53 UTC (permalink / raw)
To: Linux ACPI
Cc: LKML, Hans de Goede, Greg Kroah-Hartman, Danilo Krummrich,
driver-core
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Introduce dev_is_auxiliary() in analogy with dev_is_platform() to
facilitate subsequent changes.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
Danilo, Greg, please let me know if you have objections or concerns
regarding this one.
The new function is used in the next patch to limit the scope of the
search when looking for duplicates of the device being probed.
---
drivers/base/auxiliary.c | 10 ++++++++++
include/linux/auxiliary_bus.h | 2 ++
2 files changed, 12 insertions(+)
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -502,6 +502,16 @@ struct auxiliary_device *__devm_auxiliar
}
EXPORT_SYMBOL_GPL(__devm_auxiliary_device_create);
+/**
+ * dev_is_auxiliary - check if the device is an auxiliary one
+ * @dev: device to check
+ */
+bool dev_is_auxiliary(struct device *dev)
+{
+ return dev->bus == &auxiliary_bus_type;
+}
+EXPORT_SYMBOL_GPL(dev_is_auxiliary);
+
void __init auxiliary_bus_init(void)
{
WARN_ON(bus_register(&auxiliary_bus_type));
--- a/include/linux/auxiliary_bus.h
+++ b/include/linux/auxiliary_bus.h
@@ -271,6 +271,8 @@ struct auxiliary_device *__devm_auxiliar
__devm_auxiliary_device_create(dev, KBUILD_MODNAME, devname, \
platform_data, 0)
+bool dev_is_auxiliary(struct device *dev);
+
/**
* module_auxiliary_driver() - Helper macro for registering an auxiliary driver
* @__auxiliary_driver: auxiliary driver struct
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 2/8] ACPI: video: Rework checking for duplicate video bus devices
[not found] <6271415.lOV4Wx5bFT@rafael.j.wysocki>
2026-03-13 12:53 ` [PATCH v2 1/8] driver core: auxiliary bus: Introduce dev_is_auxiliary() Rafael J. Wysocki
@ 2026-03-13 12:56 ` Rafael J. Wysocki
2026-03-13 14:08 ` Danilo Krummrich
1 sibling, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2026-03-13 12:56 UTC (permalink / raw)
To: Linux ACPI
Cc: LKML, Hans de Goede, Danilo Krummrich, Greg Kroah-Hartman,
Linux Driver Core Development
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
The current way of checking for duplicate video bus devices in
acpi_video_bus_probe() is based on walking the ACPI namespace which is
not necessary after recent driver conversions. It is also susceptible
to race conditions (for example, if two video bus devices are probed at
the same time) and ordering issues.
Instead of doing it the old way, inspect the children of the parent of
the device being probed, excluding the latter and the children that are
not auxiliary devices. For each of the remaining children, check if any
of the entries in the video_bus_head list is equal to its driver data
which can only happen if the given child has been processed by
acpi_video_bus_probe() successfully and so it is a duplicate of the
one being probed.
Moreover, to prevent acpi_video_bus_probe() from processing two devices
concurrently, which might defeat the above check, use a new internal
mutex in it.
Also, print the FW_BUG message only if allow_duplicates is unset which
allows the entire duplicates check to be skipped in that case (doing
it just to print the message about the case that is going to be
ignored anyway is kind of pointless).
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_video.c | 56 +++++++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 28 deletions(-)
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1681,26 +1681,6 @@ static int acpi_video_resume(struct noti
return NOTIFY_DONE;
}
-static acpi_status
-acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
- void **return_value)
-{
- struct acpi_device *device = context;
- struct acpi_device *sibling;
-
- if (handle == device->handle)
- return AE_CTRL_TERMINATE;
-
- sibling = acpi_fetch_acpi_dev(handle);
- if (!sibling)
- return AE_OK;
-
- if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
- return AE_ALREADY_EXISTS;
-
- return AE_OK;
-}
-
static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
{
struct backlight_properties props;
@@ -1976,29 +1956,49 @@ static int acpi_video_bus_put_devices(st
return 0;
}
+static int duplicate_dev_check(struct device *sibling, void *data)
+{
+ struct acpi_video_bus *video;
+
+ if (sibling == data || !dev_is_auxiliary(sibling))
+ return 0;
+
+ guard(mutex)(&video_list_lock);
+
+ list_for_each_entry(video, &video_bus_head, entry) {
+ if (video == dev_get_drvdata(sibling))
+ return -EEXIST;
+ }
+
+ return 0;
+}
+
+static bool acpi_video_bus_dev_is_duplicate(struct device *dev)
+{
+ return device_for_each_child(dev->parent, dev, duplicate_dev_check);
+}
+
static int instance;
static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
const struct auxiliary_device_id *id_unused)
{
struct acpi_device *device = ACPI_COMPANION(&aux_dev->dev);
+ static DEFINE_MUTEX(probe_lock);
struct acpi_video_bus *video;
bool auto_detect;
int error;
- acpi_status status;
- status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
- acpi_dev_parent(device)->handle, 1,
- acpi_video_bus_match, NULL,
- device, NULL);
- if (status == AE_ALREADY_EXISTS) {
+ /* Probe one video bus device at a time in case there are duplicates. */
+ guard(mutex)(&probe_lock);
+
+ if (!allow_duplicates && acpi_video_bus_dev_is_duplicate(&aux_dev->dev)) {
pr_info(FW_BUG
"Duplicate ACPI video bus devices for the"
" same VGA controller, please try module "
"parameter \"video.allow_duplicates=1\""
"if the current driver doesn't work.\n");
- if (!allow_duplicates)
- return -ENODEV;
+ return -ENODEV;
}
video = kzalloc_obj(struct acpi_video_bus);
^ permalink raw reply [flat|nested] 5+ messages in thread