mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 17:25:35 +03:00
Currently, each process holding an open TegraDRM channel reserves for itself one of the limited number of hardware memory contexts. Attempting to allocate a channel when all contexts are in use results in failure. While we cannot have more contexts than the hardware supports in active use, idle channels don't necessarily need to have a backing memory context. As such, in this patch, we add another layer to allow hardware memory contexts to be "stolen away" by channels that are in active use, from idle processes. The way this is implemented, is by keeping track of memory mappings on each abstracted memory context. If we need to steal that memory context's backing hardware context, we unmap everything from it and give it away. When that abstracted memory context is needed again (re-activated), we attempt to allocate or steal another hardware context and re-map the previously unmapped buffers. Unfortunately, this means additional overhead and unpredictability at submit time. Submit can fail if we cannot re-allocate a backing memory context. Future work includes a provision for un-stealable backing hardware memory contexts for processes requiring more determinism, as well as optimization and cosmetic improvements. Bug 4403250 Bug 4399310 Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com> Change-Id: I3d13e3476f1bff3c4757152254496cddaaafd76a Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3058905 Reviewed-by: Santosh BS <santoshb@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
59 lines
1.6 KiB
C
59 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/* Copyright (c) 2020 NVIDIA Corporation */
|
|
|
|
#ifndef _TEGRA_DRM_UAPI_H
|
|
#define _TEGRA_DRM_UAPI_H
|
|
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/idr.h>
|
|
#include <linux/kref.h>
|
|
#include <linux/xarray.h>
|
|
|
|
#include <drm/drm.h>
|
|
|
|
struct drm_file;
|
|
struct drm_device;
|
|
|
|
struct tegra_drm_file {
|
|
/* Legacy UAPI state */
|
|
struct idr legacy_contexts;
|
|
struct mutex lock;
|
|
|
|
/* New UAPI state */
|
|
struct xarray contexts;
|
|
struct xarray syncpoints;
|
|
};
|
|
|
|
struct tegra_drm_mapping {
|
|
struct kref ref;
|
|
|
|
struct host1x_bo_mapping *bo_map;
|
|
struct host1x_context_mapping *ctx_map;
|
|
struct host1x_bo *bo;
|
|
|
|
dma_addr_t iova;
|
|
dma_addr_t iova_end;
|
|
};
|
|
|
|
int tegra_drm_ioctl_channel_open(struct drm_device *drm, void *data,
|
|
struct drm_file *file);
|
|
int tegra_drm_ioctl_channel_close(struct drm_device *drm, void *data,
|
|
struct drm_file *file);
|
|
int tegra_drm_ioctl_channel_map(struct drm_device *drm, void *data,
|
|
struct drm_file *file);
|
|
int tegra_drm_ioctl_channel_unmap(struct drm_device *drm, void *data,
|
|
struct drm_file *file);
|
|
int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,
|
|
struct drm_file *file);
|
|
int tegra_drm_ioctl_syncpoint_allocate(struct drm_device *drm, void *data,
|
|
struct drm_file *file);
|
|
int tegra_drm_ioctl_syncpoint_free(struct drm_device *drm, void *data,
|
|
struct drm_file *file);
|
|
int tegra_drm_ioctl_syncpoint_wait(struct drm_device *drm, void *data,
|
|
struct drm_file *file);
|
|
|
|
void tegra_drm_uapi_close_file(struct tegra_drm_file *file);
|
|
void tegra_drm_mapping_put(struct tegra_drm_mapping *mapping);
|
|
|
|
#endif
|