[PATCH 2/3] gpu: host1x: Migrate to generic context device bus
From: Ekansh Gupta via B4 Relay
Date: Tue Apr 14 2026 - 12:31:38 EST
From: Ekansh Gupta <ekansh.gupta@xxxxxxxxxxxxxxxx>
Replace the host1x-specific context device bus with the generic
context_device_bus_type. This eliminates driver-specific bus
infrastructure in favor of shared code in the driver core.
The host1x driver creates synthetic context bank devices to represent
IOMMU contexts for memory isolation. These devices were previously
registered on a host1x-specific bus ("host1x-context"), but this
functionality is now provided by the generic "context-device" bus.
The IOMMU subsystem is updated to recognize the generic bus instead
of the host1x-specific one, allowing proper IOMMU operations on
context devices.
This change maintains functional equivalence - context devices still
work the same way, just on a different bus. The device names remain
"host1x-ctx.N" to preserve any userspace dependencies.
Signed-off-by: Ekansh Gupta <ekansh.gupta@xxxxxxxxxxxxxxxx>
---
drivers/gpu/host1x/Kconfig | 5 +----
drivers/gpu/host1x/Makefile | 1 -
drivers/gpu/host1x/context.c | 2 +-
drivers/gpu/host1x/context.h | 3 +--
drivers/gpu/host1x/context_bus.c | 26 --------------------------
drivers/iommu/iommu.c | 6 +++---
6 files changed, 6 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
index e6c78ae2003a..e3e3896f4d71 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -1,13 +1,10 @@
# SPDX-License-Identifier: GPL-2.0-only
-config TEGRA_HOST1X_CONTEXT_BUS
- bool
-
config TEGRA_HOST1X
tristate "NVIDIA Tegra host1x driver"
depends on ARCH_TEGRA || COMPILE_TEST
select DMA_SHARED_BUFFER
- select TEGRA_HOST1X_CONTEXT_BUS
+ select CONTEXT_DEVICE_BUS
select IOMMU_IOVA
help
Driver for the NVIDIA Tegra host1x hardware.
diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile
index fead483af0b4..2ccd9a5f1c65 100644
--- a/drivers/gpu/host1x/Makefile
+++ b/drivers/gpu/host1x/Makefile
@@ -23,4 +23,3 @@ host1x-$(CONFIG_IOMMU_API) += \
context.o
obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
-obj-$(CONFIG_TEGRA_HOST1X_CONTEXT_BUS) += context_bus.o
diff --git a/drivers/gpu/host1x/context.c b/drivers/gpu/host1x/context.c
index d50d41c20561..6411c17cc060 100644
--- a/drivers/gpu/host1x/context.c
+++ b/drivers/gpu/host1x/context.c
@@ -54,7 +54,7 @@ int host1x_memory_context_list_init(struct host1x *host1x)
ctx->dev.dma_mask = &ctx->dma_mask;
ctx->dev.coherent_dma_mask = ctx->dma_mask;
dev_set_name(&ctx->dev, "host1x-ctx.%d", i);
- ctx->dev.bus = &host1x_context_device_bus_type;
+ ctx->dev.bus = &context_device_bus_type;
ctx->dev.parent = host1x->dev;
ctx->dev.release = host1x_memory_context_release;
diff --git a/drivers/gpu/host1x/context.h b/drivers/gpu/host1x/context.h
index 3e03bc1d3bac..87ae522fafc7 100644
--- a/drivers/gpu/host1x/context.h
+++ b/drivers/gpu/host1x/context.h
@@ -8,13 +8,12 @@
#ifndef __HOST1X_CONTEXT_H
#define __HOST1X_CONTEXT_H
+#include <linux/context_bus.h>
#include <linux/mutex.h>
#include <linux/refcount.h>
struct host1x;
-extern struct bus_type host1x_context_device_bus_type;
-
struct host1x_memory_context_list {
struct mutex lock;
struct host1x_memory_context *devs;
diff --git a/drivers/gpu/host1x/context_bus.c b/drivers/gpu/host1x/context_bus.c
deleted file mode 100644
index 7cd0e1a5edd1..000000000000
--- a/drivers/gpu/host1x/context_bus.c
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (c) 2021, NVIDIA Corporation.
- */
-
-#include <linux/device.h>
-#include <linux/of.h>
-
-const struct bus_type host1x_context_device_bus_type = {
- .name = "host1x-context",
-};
-EXPORT_SYMBOL_GPL(host1x_context_device_bus_type);
-
-static int __init host1x_context_device_bus_init(void)
-{
- int err;
-
- err = bus_register(&host1x_context_device_bus_type);
- if (err < 0) {
- pr_err("bus type registration failed: %d\n", err);
- return err;
- }
-
- return 0;
-}
-postcore_initcall(host1x_context_device_bus_init);
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 61c12ba78206..f01a13e2e634 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -16,7 +16,7 @@
#include <linux/export.h>
#include <linux/slab.h>
#include <linux/errno.h>
-#include <linux/host1x_context_bus.h>
+#include <linux/context_bus.h>
#include <linux/iommu.h>
#include <linux/iommufd.h>
#include <linux/idr.h>
@@ -173,8 +173,8 @@ static const struct bus_type * const iommu_buses[] = {
#ifdef CONFIG_FSL_MC_BUS
&fsl_mc_bus_type,
#endif
-#ifdef CONFIG_TEGRA_HOST1X_CONTEXT_BUS
- &host1x_context_device_bus_type,
+#ifdef CONFIG_CONTEXT_DEVICE_BUS
+ &context_device_bus_type,
#endif
#ifdef CONFIG_CDX_BUS
&cdx_bus_type,
--
2.34.1