drm/tegra: Add option for explicit syncpoint free

Add kernel module parameter to enable a mode where syncpoints
must be freed explicitly (using the free IOCTL) or they will be
left dangling. This ensures that, for particularly locked down
configurations, a syncpoint will be forever left in an expected
state even if the process owning it dies -- for example another
process will not be able to allocate it.

Change-Id: I2f350c710775a296c70910df21e95737a36c6a45
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3284405
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Santosh BS <santoshb@nvidia.com>
This commit is contained in:
Mikko Perttunen
2025-01-15 07:24:36 +00:00
committed by Jon Hunter
parent 9feb2a4347
commit 48e383a1b9
3 changed files with 17 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: MIT */ /* SPDX-License-Identifier: MIT */
/* Copyright (c) 2012-2020 NVIDIA Corporation */ /* Copyright (c) 2012-2025 NVIDIA Corporation */
#ifndef _UAPI_TEGRA_DRM_H_ #ifndef _UAPI_TEGRA_DRM_H_
#define _UAPI_TEGRA_DRM_H_ #define _UAPI_TEGRA_DRM_H_

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2020 NVIDIA Corporation */ /* Copyright (c) 2020-2025 NVIDIA Corporation */
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#include <linux/host1x-next.h> #include <linux/host1x-next.h>
@@ -13,6 +13,10 @@
#include "drm.h" #include "drm.h"
#include "uapi.h" #include "uapi.h"
static bool explicit_syncpt_free;
module_param(explicit_syncpt_free, bool, 0644);
MODULE_PARM_DESC(explicit_syncpt_free, "If enabled, syncpoints need to be explicitly freed via IOCTL or they will be left dangling when the fd is closed");
static void tegra_drm_mapping_release(struct kref *ref) static void tegra_drm_mapping_release(struct kref *ref)
{ {
struct tegra_drm_mapping *mapping = struct tegra_drm_mapping *mapping =
@@ -60,8 +64,16 @@ void tegra_drm_uapi_close_file(struct tegra_drm_file *file)
xa_for_each(&file->contexts, id, context) xa_for_each(&file->contexts, id, context)
tegra_drm_channel_context_close(context); tegra_drm_channel_context_close(context);
/*
* If explicit_syncpt_free is enabled, users must free syncpoints
* explicitly or they will be left dangling. This prevents syncpoints
* from getting in an unexpected state if e.g. the application crashes.
* Obviously only usable on particularly locked down configurations.
*/
if (!explicit_syncpt_free) {
xa_for_each(&file->syncpoints, id, sp) xa_for_each(&file->syncpoints, id, sp)
host1x_syncpt_put(sp); host1x_syncpt_put(sp);
}
xa_destroy(&file->contexts); xa_destroy(&file->contexts);
xa_destroy(&file->syncpoints); xa_destroy(&file->syncpoints);

View File

@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2020 NVIDIA Corporation */ /* Copyright (c) 2020-2025 NVIDIA Corporation */
#ifndef _TEGRA_DRM_UAPI_H #ifndef _TEGRA_DRM_UAPI_H
#define _TEGRA_DRM_UAPI_H #define _TEGRA_DRM_UAPI_H