On 1/14/26 2:46 AM, Tomeu Vizoso wrote:
Some SoCs from Texas Instruments contain DSPs that can be used for general compute tasks.
This driver provides a drm/accel UABI to userspace for submitting jobs to the DSP cores and managing the input, output and intermediate memory.
Signed-off-by: Tomeu Vizoso tomeu@tomeuvizoso.net
Documentation/accel/thames/index.rst | 28 +++++ MAINTAINERS | 9 ++ drivers/accel/Kconfig | 1 + drivers/accel/Makefile | 3 +- drivers/accel/thames/Kconfig | 26 +++++ drivers/accel/thames/Makefile | 9 ++ drivers/accel/thames/thames_core.c | 155 ++++++++++++++++++++++++++ drivers/accel/thames/thames_core.h | 53 +++++++++ drivers/accel/thames/thames_device.c | 93 ++++++++++++++++ drivers/accel/thames/thames_device.h | 46 ++++++++ drivers/accel/thames/thames_drv.c | 155 ++++++++++++++++++++++++++ drivers/accel/thames/thames_drv.h | 21 ++++ drivers/accel/thames/thames_ipc.h | 204 +++++++++++++++++++++++++++++++++++ drivers/accel/thames/thames_rpmsg.c | 155 ++++++++++++++++++++++++++ drivers/accel/thames/thames_rpmsg.h | 27 +++++ 15 files changed, 984 insertions(+), 1 deletion(-)
diff --git a/Documentation/accel/thames/index.rst b/Documentation/accel/thames/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..ca8391031f226f7ef1dc210a356c86acbe126c6f --- /dev/null +++ b/Documentation/accel/thames/index.rst @@ -0,0 +1,28 @@ +.. SPDX-License-Identifier: GPL-2.0-only
+============================================================
- accel/thames Driver for the C7x DSPs from Texas Instruments
+============================================================
+The accel/thames driver supports the C7x DSPs inside some Texas Instruments SoCs +such as the J722S. These can be used as accelerators for various workloads, +including machine learning inference.
+This driver controls the power state of the hardware via :doc:`remoteproc </staging/remoteproc>` +and communicates with the firmware running on the DSP via :doc:`rpmsg_virtio </staging/rpmsg_virtio>`. +The kernel driver itself allocates buffers, manages contexts, and submits jobs +to the DSP firmware. Buffers are mapped by the DSP itself using its MMU, +providing memory isolation among different clients.
+The source code for the firmware running on the DSP is available at: +https://gitlab.freedesktop.org/tomeu/thames_firmware/.
+Everything else is done in userspace, as a Gallium driver (also called thames) +that is part of the Mesa3D project: https://docs.mesa3d.org/teflon.html
+If there is more than one core that advertises the same rpmsg_virtio service +name, the driver will load balance jobs between them with drm-gpu-scheduler.
+Hardware currently supported:
+* J722S diff --git a/MAINTAINERS b/MAINTAINERS index dc731d37c8feeff25613c59fe9c929927dadaa7e..a3fc809c797269d0792dfe5202cc1b49f6ff57e9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7731,6 +7731,15 @@ F: Documentation/devicetree/bindings/npu/rockchip,rk3588-rknn-core.yaml F: drivers/accel/rocket/ F: include/uapi/drm/rocket_accel.h +DRM ACCEL DRIVER FOR TI C7x DSPS +M: Tomeu Vizoso tomeu@tomeuvizoso.net +L: dri-devel@lists.freedesktop.org +S: Supported +T: git https://gitlab.freedesktop.org/drm/misc/kernel.git +F: Documentation/accel/thames/ +F: drivers/accel/thames/ +F: include/uapi/drm/thames_accel.h
- DRM COMPUTE ACCELERATORS DRIVERS AND FRAMEWORK M: Oded Gabbay ogabbay@kernel.org L: dri-devel@lists.freedesktop.org
diff --git a/drivers/accel/Kconfig b/drivers/accel/Kconfig index bdf48ccafcf21b2fd685ec963e39e256196e6e17..cb49c71cd4e4a4220624f7041a75ba950a1a2ee1 100644 --- a/drivers/accel/Kconfig +++ b/drivers/accel/Kconfig @@ -30,5 +30,6 @@ source "drivers/accel/habanalabs/Kconfig" source "drivers/accel/ivpu/Kconfig" source "drivers/accel/qaic/Kconfig" source "drivers/accel/rocket/Kconfig" +source "drivers/accel/thames/Kconfig" endif diff --git a/drivers/accel/Makefile b/drivers/accel/Makefile index 1d3a7251b950f39e2ae600a2fc07a3ef7e41831e..8472989cbe22746f1e7292d2401fa0f7424a6c15 100644 --- a/drivers/accel/Makefile +++ b/drivers/accel/Makefile @@ -5,4 +5,5 @@ obj-$(CONFIG_DRM_ACCEL_ARM_ETHOSU) += ethosu/ obj-$(CONFIG_DRM_ACCEL_HABANALABS) += habanalabs/ obj-$(CONFIG_DRM_ACCEL_IVPU) += ivpu/ obj-$(CONFIG_DRM_ACCEL_QAIC) += qaic/ -obj-$(CONFIG_DRM_ACCEL_ROCKET) += rocket/ \ No newline at end of file +obj-$(CONFIG_DRM_ACCEL_ROCKET) += rocket/ +obj-$(CONFIG_DRM_ACCEL_THAMES) += thames/ \ No newline at end of file diff --git a/drivers/accel/thames/Kconfig b/drivers/accel/thames/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..50e0b6ac2a16a942ba8463333991f5b0161b99ac --- /dev/null +++ b/drivers/accel/thames/Kconfig @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only
+config DRM_ACCEL_THAMES
- tristate "Thames (support for TI C7x DSP accelerators)"
- depends on DRM_ACCEL
- depends on TI_K3_R5_REMOTEPROC || COMPILE_TEST
COMPILE_TEST part shouldn't be needed here, TI_K3_R5_REMOTEPROC can be built under COMPILE_TEST so TI_K3_R5_REMOTEPROC would just be enabled to test.
- depends on RPMSG
- depends on MMU
- select DRM_SCHED
- select DRM_GEM_SHMEM_HELPER
- help
Choose this option if you have a Texas Instruments SoC that containsC7x DSP cores that can be used as compute accelerators. This includesSoCs such as the AM62A, J721E, J721S2, and J784S4.The C7x DSP cores can be used for general-purpose compute accelerationand are exposed through the DRM accel subsystem.The interface exposed to userspace is described ininclude/uapi/drm/thames_accel.h and is used by the Thames userspacedriver in Mesa3D.If unsure, say N.To compile this driver as a module, choose M here: themodule will be called thames.diff --git a/drivers/accel/thames/Makefile b/drivers/accel/thames/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7ccd8204f0f5ea800f30e84b319f355be948109d --- /dev/null +++ b/drivers/accel/thames/Makefile @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_DRM_ACCEL_THAMES) := thames.o
+thames-y := \
- thames_core.o \
- thames_device.o \
- thames_drv.o \
- thames_rpmsg.o
diff --git a/drivers/accel/thames/thames_core.c b/drivers/accel/thames/thames_core.c new file mode 100644 index 0000000000000000000000000000000000000000..92af1d68063116bcfa28a33960cbe829029fc1bf --- /dev/null +++ b/drivers/accel/thames/thames_core.c @@ -0,0 +1,155 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright 2026 Texas Instruments Incorporated - https://www.ti.com/ */
+#include "linux/remoteproc.h" +#include <linux/dev_printk.h> +#include <linux/err.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/completion.h> +#include <linux/jiffies.h> +#include <linux/rpmsg.h>
+#include "thames_core.h" +#include "thames_device.h" +#include "thames_rpmsg.h"
+/* Shift to convert bytes to megabytes (divide by 1048576) */ +#define THAMES_BYTES_TO_MB_SHIFT 20
Seems unused/unneeded.
[...]
+static const struct rpmsg_device_id thames_rpmsg_id_table[] = { { .name = THAMES_SERVICE_NAME },
{} };
Some odd formatting here.
+static struct rpmsg_driver thames_rpmsg_driver = {
- .drv = {
.name = "thames",.owner = THIS_MODULE,
Above line shoulnd't be needed.
Andrew
linaro-mm-sig@lists.linaro.org