From: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
To: Bryan O'Donoghue <bod@kernel.org>,
Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Stefan Schmidt <stefan.schmidt@linaro.org>,
Hans Verkuil <hverkuil@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Thierry Reding <thierry.reding@kernel.org>,
Mikko Perttunen <mperttunen@nvidia.com>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
iommu@lists.linux.dev, driver-core@lists.linux.dev,
dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org,
Vishnu Reddy <busanna.reddy@oss.qualcomm.com>,
Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Subject: [PATCH v2 03/13] gpu: host1x: Migrate to generic dma context bus
Date: Thu, 23 Apr 2026 18:59:32 +0530 [thread overview]
Message-ID: <20260423-glymur-v2-3-0296bccb9f4e@oss.qualcomm.com> (raw)
In-Reply-To: <20260423-glymur-v2-0-0296bccb9f4e@oss.qualcomm.com>
From: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
The host1x driver creates context bank devices to map IOMMU contexts
for memory isolation. Previously, this required a host1x-specific bus
type with its own device setup and IOMMU configuration logic.
A generic "dma-context-bus" is now available in the driver core that
handles this for any driver. Replace the host1x-specific bus with this
shared generic bus. This removes the private bus registration, device
setup, and of_dma_configure_id() from host1x, as the generic bus handles
all of this internally.
The IOMMU subsystem is also updated to reference the generic bus instead
of the host1x-specific one.
Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
---
drivers/gpu/drm/tegra/uapi.c | 2 +-
drivers/gpu/host1x/Kconfig | 5 +---
drivers/gpu/host1x/Makefile | 1 -
drivers/gpu/host1x/context.c | 47 ++++++++++++--------------------------
drivers/gpu/host1x/context.h | 3 +--
drivers/gpu/host1x/context_bus.c | 26 ---------------------
drivers/iommu/iommu.c | 6 ++---
include/linux/host1x.h | 2 +-
include/linux/host1x_context_bus.h | 15 ------------
9 files changed, 21 insertions(+), 86 deletions(-)
diff --git a/drivers/gpu/drm/tegra/uapi.c b/drivers/gpu/drm/tegra/uapi.c
index c0ac6b45f2d7..9547725a6c3c 100644
--- a/drivers/gpu/drm/tegra/uapi.c
+++ b/drivers/gpu/drm/tegra/uapi.c
@@ -215,7 +215,7 @@ int tegra_drm_ioctl_channel_map(struct drm_device *drm, void *data, struct drm_f
kref_init(&mapping->ref);
if (context->memory_context)
- mapping_dev = &context->memory_context->dev;
+ mapping_dev = context->memory_context->dev;
else
mapping_dev = context->client->base.dev;
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
index e6c78ae2003a..0539ff057a51 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 DMA_CONTEXT_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..ab7b156ab002 100644
--- a/drivers/gpu/host1x/context.c
+++ b/drivers/gpu/host1x/context.c
@@ -13,16 +13,12 @@
#include "context.h"
#include "dev.h"
-static void host1x_memory_context_release(struct device *dev)
-{
- /* context device is freed in host1x_memory_context_list_free() */
-}
-
int host1x_memory_context_list_init(struct host1x *host1x)
{
struct host1x_memory_context_list *cdl = &host1x->context_list;
struct device_node *node = host1x->dev->of_node;
struct host1x_memory_context *ctx;
+ struct device *dev;
unsigned int i;
int err;
@@ -44,42 +40,27 @@ int host1x_memory_context_list_init(struct host1x *host1x)
ctx->host = host1x;
- device_initialize(&ctx->dev);
-
/*
* Due to an issue with T194 NVENC, only 38 bits can be used.
* Anyway, 256GiB of IOVA ought to be enough for anyone.
*/
ctx->dma_mask = DMA_BIT_MASK(38);
- 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.parent = host1x->dev;
- ctx->dev.release = host1x_memory_context_release;
-
- ctx->dev.dma_parms = &ctx->dma_parms;
- dma_set_max_seg_size(&ctx->dev, UINT_MAX);
-
- err = device_add(&ctx->dev);
- if (err) {
+
+ dev = create_dma_context_bus_device(host1x->dev, NULL, ctx->dma_mask, &i);
+ if (IS_ERR(dev)) {
+ err = PTR_ERR(dev);
dev_err(host1x->dev, "could not add context device %d: %d\n", i, err);
- put_device(&ctx->dev);
goto unreg_devices;
}
- err = of_dma_configure_id(&ctx->dev, node, true, &i);
- if (err) {
- dev_err(host1x->dev, "IOMMU configuration failed for context device %d: %d\n",
- i, err);
- device_unregister(&ctx->dev);
- goto unreg_devices;
- }
+ ctx->dev = dev;
+ ctx->dev->dma_parms = &ctx->dma_parms;
+ dma_set_max_seg_size(ctx->dev, UINT_MAX);
- if (!tegra_dev_iommu_get_stream_id(&ctx->dev, &ctx->stream_id) ||
- !device_iommu_mapped(&ctx->dev)) {
+ if (!tegra_dev_iommu_get_stream_id(ctx->dev, &ctx->stream_id) ||
+ !device_iommu_mapped(ctx->dev)) {
dev_err(host1x->dev, "Context device %d has no IOMMU!\n", i);
- device_unregister(&ctx->dev);
+ device_unregister(ctx->dev);
/*
* This means that if IOMMU is disabled but context devices
@@ -96,7 +77,7 @@ int host1x_memory_context_list_init(struct host1x *host1x)
unreg_devices:
while (i--)
- device_unregister(&cdl->devs[i].dev);
+ device_unregister(cdl->devs[i].dev);
kfree(cdl->devs);
cdl->devs = NULL;
@@ -110,7 +91,7 @@ void host1x_memory_context_list_free(struct host1x_memory_context_list *cdl)
unsigned int i;
for (i = 0; i < cdl->len; i++)
- device_unregister(&cdl->devs[i].dev);
+ device_unregister(cdl->devs[i].dev);
kfree(cdl->devs);
cdl->len = 0;
@@ -132,7 +113,7 @@ struct host1x_memory_context *host1x_memory_context_alloc(struct host1x *host1x,
for (i = 0; i < cdl->len; i++) {
struct host1x_memory_context *cd = &cdl->devs[i];
- if (cd->dev.iommu->iommu_dev != dev->iommu->iommu_dev)
+ if (cd->dev->iommu->iommu_dev != dev->iommu->iommu_dev)
continue;
if (cd->owner == pid) {
diff --git a/drivers/gpu/host1x/context.h b/drivers/gpu/host1x/context.h
index 3e03bc1d3bac..558638c457d6 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/dma_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..5d0fad1402eb 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/dma_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_DMA_CONTEXT_BUS
+ &dma_context_bus_type,
#endif
#ifdef CONFIG_CDX_BUS
&cdx_bus_type,
diff --git a/include/linux/host1x.h b/include/linux/host1x.h
index 1f5f55917d1c..30dbb3a71828 100644
--- a/include/linux/host1x.h
+++ b/include/linux/host1x.h
@@ -462,7 +462,7 @@ struct host1x_memory_context {
struct pid *owner;
struct device_dma_parameters dma_parms;
- struct device dev;
+ struct device *dev;
u64 dma_mask;
u32 stream_id;
};
diff --git a/include/linux/host1x_context_bus.h b/include/linux/host1x_context_bus.h
deleted file mode 100644
index c928cb432680..000000000000
--- a/include/linux/host1x_context_bus.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (c) 2021, NVIDIA Corporation. All rights reserved.
- */
-
-#ifndef __LINUX_HOST1X_CONTEXT_BUS_H
-#define __LINUX_HOST1X_CONTEXT_BUS_H
-
-#include <linux/device.h>
-
-#ifdef CONFIG_TEGRA_HOST1X_CONTEXT_BUS
-extern const struct bus_type host1x_context_device_bus_type;
-#endif
-
-#endif
--
2.34.1
next prev parent reply other threads:[~2026-04-23 13:30 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 13:29 [PATCH v2 00/13] media: iris: Add support for glymur platform Vishnu Reddy
2026-04-23 13:29 ` [PATCH v2 01/13] media: iris: Fix VM count passed to firmware Vishnu Reddy
2026-04-23 13:29 ` [PATCH v2 02/13] drivers: base: Add generic dma context bus Vishnu Reddy
2026-04-23 13:37 ` Greg Kroah-Hartman
2026-04-24 10:31 ` Vishnu Reddy
2026-04-24 11:13 ` Greg Kroah-Hartman
2026-04-24 11:45 ` Vishnu Reddy
2026-04-24 11:55 ` Greg Kroah-Hartman
2026-04-24 12:42 ` Vishnu Reddy
2026-04-24 13:34 ` Greg Kroah-Hartman
2026-04-24 16:11 ` Dmitry Baryshkov
2026-04-25 5:42 ` Greg Kroah-Hartman
2026-04-25 10:35 ` Dmitry Baryshkov
2026-04-24 16:40 ` Vishnu Reddy
2026-04-23 13:29 ` Vishnu Reddy [this message]
2026-04-23 13:40 ` [PATCH v2 03/13] gpu: host1x: Migrate to " Greg Kroah-Hartman
2026-04-23 13:29 ` [PATCH v2 04/13] dt-bindings: media: qcom,glymur-iris: Add glymur video codec Vishnu Reddy
2026-04-24 17:09 ` Krzysztof Kozlowski
2026-04-25 9:56 ` Vishnu Reddy
2026-04-25 10:40 ` Krzysztof Kozlowski
2026-04-25 16:23 ` Vishnu Reddy
2026-04-23 13:29 ` [PATCH v2 05/13] media: iris: Add context bank hooks for platform specific initialization Vishnu Reddy
2026-04-23 13:29 ` [PATCH v2 06/13] media: iris: Enable Secure PAS support with IOMMU managed by Linux Vishnu Reddy
2026-04-23 13:29 ` [PATCH v2 07/13] media: iris: Rename clock and power domain macros to use vcodec prefix Vishnu Reddy
2026-04-23 13:29 ` [PATCH v2 08/13] media: iris: Use power domain type to look up pd_devs index Vishnu Reddy
2026-04-23 13:29 ` [PATCH v2 09/13] media: iris: Add power sequence for Glymur Vishnu Reddy
2026-04-23 13:29 ` [PATCH v2 10/13] media: iris: Add support to select core for dual core platforms Vishnu Reddy
2026-04-23 13:29 ` [PATCH v2 11/13] media: iris: Select DMA_CONTEXT_BUS to create firmware device Vishnu Reddy
2026-04-23 13:38 ` Greg Kroah-Hartman
2026-04-26 12:16 ` Dmitry Baryshkov
2026-04-23 13:29 ` [PATCH v2 12/13] media: iris: Add platform data for glymur Vishnu Reddy
2026-04-26 12:24 ` Dmitry Baryshkov
2026-04-23 13:29 ` [PATCH v2 13/13] arm64: dts: qcom: glymur: Add iris video node Vishnu Reddy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260423-glymur-v2-3-0296bccb9f4e@oss.qualcomm.com \
--to=busanna.reddy@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=andersson@kernel.org \
--cc=bod@kernel.org \
--cc=conor+dt@kernel.org \
--cc=dakr@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=ekansh.gupta@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mperttunen@nvidia.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=simona@ffwll.ch \
--cc=stefan.schmidt@linaro.org \
--cc=thierry.reding@kernel.org \
--cc=vikash.garodia@oss.qualcomm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox