[PATCH 1/3] drivers: base: Add generic context device bus

From: Ekansh Gupta via B4 Relay

Date: Tue Apr 14 2026 - 12:38:04 EST


From: Ekansh Gupta <ekansh.gupta@xxxxxxxxxxxxxxxx>

Introduce a new generic bus type for synthetic context bank devices
that require IOMMU context isolation. This bus provides a shared
infrastructure for accelerator and GPU drivers that create virtual
devices representing IOMMU context banks.

Currently, drivers like host1x implement their own bus types for
context devices. This generic implementation allows multiple drivers
to share the same bus infrastructure, simplifying the IOMMU subsystem
integration and reducing code duplication.

Signed-off-by: Ekansh Gupta <ekansh.gupta@xxxxxxxxxxxxxxxx>
---
drivers/base/Kconfig | 3 +++
drivers/base/Makefile | 1 +
drivers/base/context_bus.c | 24 ++++++++++++++++++++++++
include/linux/context_bus.h | 15 +++++++++++++++
4 files changed, 43 insertions(+)

diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index f7d385cbd3ba..479bc4bb442b 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -4,6 +4,9 @@ menu "Generic Driver Options"
config AUXILIARY_BUS
bool

+config CONTEXT_DEVICE_BUS
+ bool
+
config UEVENT_HELPER
bool "Support for uevent helper"
help
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 8074a10183dc..ab9a0b2dc73b 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -8,6 +8,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \
topology.o container.o property.o cacheinfo.o \
swnode.o faux.o
obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o
+obj-$(CONFIG_CONTEXT_DEVICE_BUS) += context_bus.o
obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
obj-y += power/
obj-$(CONFIG_ISA_BUS_API) += isa.o
diff --git a/drivers/base/context_bus.c b/drivers/base/context_bus.c
new file mode 100644
index 000000000000..6ddb6c27bf69
--- /dev/null
+++ b/drivers/base/context_bus.c
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+
+#include <linux/context_bus.h>
+#include <linux/init.h>
+
+const struct bus_type context_device_bus_type = {
+ .name = "context-device",
+};
+EXPORT_SYMBOL_GPL(context_device_bus_type);
+
+static int __init context_device_bus_init(void)
+{
+ int err;
+
+ err = bus_register(&context_device_bus_type);
+ if (err < 0) {
+ pr_err("context-device bus registration failed: %d\n", err);
+ return err;
+ }
+
+ return 0;
+}
+postcore_initcall(context_device_bus_init);
diff --git a/include/linux/context_bus.h b/include/linux/context_bus.h
new file mode 100644
index 000000000000..0cd44cb5b147
--- /dev/null
+++ b/include/linux/context_bus.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef __LINUX_CONTEXT_BUS_H
+#define __LINUX_CONTEXT_BUS_H
+
+#include <linux/device.h>
+
+#ifdef CONFIG_CONTEXT_DEVICE_BUS
+extern const struct bus_type context_device_bus_type;
+#endif
+
+#endif /* __LINUX_CONTEXT_BUS_H */

--
2.34.1