]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
gpu: host1x: Add context bus
authorMikko Perttunen <mperttunen@nvidia.com>
Mon, 16 May 2022 08:52:51 +0000 (11:52 +0300)
committerThierry Reding <treding@nvidia.com>
Wed, 1 Jun 2022 09:50:42 +0000 (11:50 +0200)
The context bus is a "dummy" bus that contains struct devices that
correspond to IOMMU contexts assigned through Host1x to processes.

Even when host1x itself is built as a module, the bus is registered
in built-in code so that the built-in ARM SMMU driver is able to
reference it.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/Makefile
drivers/gpu/host1x/Kconfig
drivers/gpu/host1x/Makefile
drivers/gpu/host1x/context_bus.c [new file with mode: 0644]
include/linux/host1x_context_bus.h [new file with mode: 0644]

index 835c88318cec63a1594e0796f635ccd93bd39b02..8997f0096545e22363bb3b63ead71f0b145597dc 100644 (file)
@@ -2,7 +2,6 @@
 # drm/tegra depends on host1x, so if both drivers are built-in care must be
 # taken to initialize them in the correct order. Link order is the only way
 # to ensure this currently.
-obj-$(CONFIG_TEGRA_HOST1X)     += host1x/
-obj-y                  += drm/ vga/
+obj-y                  += host1x/ drm/ vga/
 obj-$(CONFIG_IMX_IPUV3_CORE)   += ipu-v3/
 obj-$(CONFIG_TRACE_GPU_MEM)            += trace/
index 6815b4db17c1b02c2a3addb5f44eb527c61ccbe7..1861a8180d3fa6531c2500f87941b9b6a4a980b4 100644 (file)
@@ -1,8 +1,13 @@
 # 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 || (ARM && COMPILE_TEST)
        select DMA_SHARED_BUFFER
+       select TEGRA_HOST1X_CONTEXT_BUS
        select IOMMU_IOVA
        help
          Driver for the NVIDIA Tegra host1x hardware.
index d2b6f7de0498931b71816063a103cb33d02f370d..c891a3e338441e8ef0317790107ab9ce4b5c478b 100644 (file)
@@ -18,3 +18,4 @@ host1x-y = \
        hw/host1x07.o
 
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
+obj-$(CONFIG_TEGRA_HOST1X_CONTEXT_BUS) += context_bus.o
diff --git a/drivers/gpu/host1x/context_bus.c b/drivers/gpu/host1x/context_bus.c
new file mode 100644 (file)
index 0000000..b0d35b2
--- /dev/null
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2021, NVIDIA Corporation.
+ */
+
+#include <linux/device.h>
+#include <linux/of.h>
+
+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;
+
+       if (!of_machine_is_compatible("nvidia,tegra186") &&
+           !of_machine_is_compatible("nvidia,tegra194") &&
+           !of_machine_is_compatible("nvidia,tegra234"))
+               return 0;
+
+       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/include/linux/host1x_context_bus.h b/include/linux/host1x_context_bus.h
new file mode 100644 (file)
index 0000000..7246273
--- /dev/null
@@ -0,0 +1,15 @@
+/* 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 struct bus_type host1x_context_device_bus_type;
+#endif
+
+#endif