diff options
| author | Tomeu Vizoso <tomeu@tomeuvizoso.net> | 2025-07-21 11:17:30 +0200 |
|---|---|---|
| committer | Jeff Hugo <jeff.hugo@oss.qualcomm.com> | 2025-07-25 10:00:36 -0600 |
| commit | 658ebeac33517bd3169d4b65ed801e9065d0211a (patch) | |
| tree | 7543b57a4a0592da8702ddb5f89ac30de4ed1a30 /drivers/accel/rocket/rocket_drv.c | |
| parent | ed98261b41687323ffa02ca20fef1e60b38fd1aa (diff) | |
accel/rocket: Add IOCTL for BO creation
This uses the SHMEM DRM helpers and we map right away to the CPU and NPU
sides, as all buffers are expected to be accessed from both.
v2:
- Sync the IOMMUs for the other cores when mapping and unmapping.
v3:
- Make use of GPL-2.0-only for the copyright notice (Jeff Hugo)
v6:
- Use mutexes guard (Markus Elfring)
v7:
- Assign its own IOMMU domain to each client, for isolation (Daniel
Stone and Robin Murphy)
v8:
- Correctly acquire a reference to the IOMMU (Robin Murphy)
- Allocate DMA address ourselves with drm_mm (Robin Murphy)
- Use refcount_read (Heiko Stuebner)
- Remove superfluous dma_sync_sgtable_for_device (Robin Murphy)
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Signed-off-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250721-6-10-rocket-v9-3-77ebd484941e@tomeuvizoso.net
Diffstat (limited to 'drivers/accel/rocket/rocket_drv.c')
| -rw-r--r-- | drivers/accel/rocket/rocket_drv.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c index a5df94f6b125..8b7fbe9226f4 100644 --- a/drivers/accel/rocket/rocket_drv.c +++ b/drivers/accel/rocket/rocket_drv.c @@ -5,6 +5,7 @@ #include <drm/drm_drv.h> #include <drm/drm_gem.h> #include <drm/drm_ioctl.h> +#include <drm/rocket_accel.h> #include <linux/clk.h> #include <linux/err.h> #include <linux/iommu.h> @@ -13,6 +14,7 @@ #include <linux/pm_runtime.h> #include "rocket_drv.h" +#include "rocket_gem.h" /* * Facade device, used to expose a single DRM device to userspace, that @@ -69,6 +71,7 @@ rocket_open(struct drm_device *dev, struct drm_file *file) { struct rocket_device *rdev = to_rocket_device(dev); struct rocket_file_priv *rocket_priv; + u64 start, end; int ret; if (!try_module_get(THIS_MODULE)) @@ -89,6 +92,11 @@ rocket_open(struct drm_device *dev, struct drm_file *file) file->driver_priv = rocket_priv; + start = rocket_priv->domain->domain->geometry.aperture_start; + end = rocket_priv->domain->domain->geometry.aperture_end; + drm_mm_init(&rocket_priv->mm, start, end - start + 1); + mutex_init(&rocket_priv->mm_lock); + return 0; err_free: @@ -103,6 +111,8 @@ rocket_postclose(struct drm_device *dev, struct drm_file *file) { struct rocket_file_priv *rocket_priv = file->driver_priv; + mutex_destroy(&rocket_priv->mm_lock); + drm_mm_takedown(&rocket_priv->mm); rocket_iommu_domain_put(rocket_priv->domain); kfree(rocket_priv); module_put(THIS_MODULE); @@ -111,6 +121,8 @@ rocket_postclose(struct drm_device *dev, struct drm_file *file) static const struct drm_ioctl_desc rocket_drm_driver_ioctls[] = { #define ROCKET_IOCTL(n, func) \ DRM_IOCTL_DEF_DRV(ROCKET_##n, rocket_ioctl_##func, 0) + + ROCKET_IOCTL(CREATE_BO, create_bo), }; DEFINE_DRM_ACCEL_FOPS(rocket_accel_driver_fops); @@ -120,9 +132,10 @@ DEFINE_DRM_ACCEL_FOPS(rocket_accel_driver_fops); * - 1.0 - initial interface */ static const struct drm_driver rocket_drm_driver = { - .driver_features = DRIVER_COMPUTE_ACCEL, + .driver_features = DRIVER_COMPUTE_ACCEL | DRIVER_GEM, .open = rocket_open, .postclose = rocket_postclose, + .gem_create_object = rocket_gem_create_object, .ioctls = rocket_drm_driver_ioctls, .num_ioctls = ARRAY_SIZE(rocket_drm_driver_ioctls), .fops = &rocket_accel_driver_fops, |
