Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpu: host1x: Add context bus

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>

authored by

Mikko Perttunen and committed by
Thierry Reding
597b89d3 cb7e1abc

+53 -2
+1 -2
drivers/gpu/Makefile
··· 2 2 # drm/tegra depends on host1x, so if both drivers are built-in care must be 3 3 # taken to initialize them in the correct order. Link order is the only way 4 4 # to ensure this currently. 5 - obj-$(CONFIG_TEGRA_HOST1X) += host1x/ 6 - obj-y += drm/ vga/ 5 + obj-y += host1x/ drm/ vga/ 7 6 obj-$(CONFIG_IMX_IPUV3_CORE) += ipu-v3/ 8 7 obj-$(CONFIG_TRACE_GPU_MEM) += trace/
+5
drivers/gpu/host1x/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + config TEGRA_HOST1X_CONTEXT_BUS 4 + bool 5 + 2 6 config TEGRA_HOST1X 3 7 tristate "NVIDIA Tegra host1x driver" 4 8 depends on ARCH_TEGRA || (ARM && COMPILE_TEST) 5 9 select DMA_SHARED_BUFFER 10 + select TEGRA_HOST1X_CONTEXT_BUS 6 11 select IOMMU_IOVA 7 12 help 8 13 Driver for the NVIDIA Tegra host1x hardware.
+1
drivers/gpu/host1x/Makefile
··· 18 18 hw/host1x07.o 19 19 20 20 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o 21 + obj-$(CONFIG_TEGRA_HOST1X_CONTEXT_BUS) += context_bus.o
+31
drivers/gpu/host1x/context_bus.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2021, NVIDIA Corporation. 4 + */ 5 + 6 + #include <linux/device.h> 7 + #include <linux/of.h> 8 + 9 + struct bus_type host1x_context_device_bus_type = { 10 + .name = "host1x-context", 11 + }; 12 + EXPORT_SYMBOL_GPL(host1x_context_device_bus_type); 13 + 14 + static int __init host1x_context_device_bus_init(void) 15 + { 16 + int err; 17 + 18 + if (!of_machine_is_compatible("nvidia,tegra186") && 19 + !of_machine_is_compatible("nvidia,tegra194") && 20 + !of_machine_is_compatible("nvidia,tegra234")) 21 + return 0; 22 + 23 + err = bus_register(&host1x_context_device_bus_type); 24 + if (err < 0) { 25 + pr_err("bus type registration failed: %d\n", err); 26 + return err; 27 + } 28 + 29 + return 0; 30 + } 31 + postcore_initcall(host1x_context_device_bus_init);
+15
include/linux/host1x_context_bus.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 + /* 3 + * Copyright (c) 2021, NVIDIA Corporation. All rights reserved. 4 + */ 5 + 6 + #ifndef __LINUX_HOST1X_CONTEXT_BUS_H 7 + #define __LINUX_HOST1X_CONTEXT_BUS_H 8 + 9 + #include <linux/device.h> 10 + 11 + #ifdef CONFIG_TEGRA_HOST1X_CONTEXT_BUS 12 + extern struct bus_type host1x_context_device_bus_type; 13 + #endif 14 + 15 + #endif