From 933d4c99000ddc23167ed2d61e08227f767b814f Mon Sep 17 00:00:00 2001 From: Mikko Perttunen Date: Tue, 12 Jan 2021 12:40:05 +0200 Subject: [PATCH] gpu: host1x: Add context device management code Add code to register context devices from device tree, allocate them out and manage their refcounts. Bug 3724727 Signed-off-by: Mikko Perttunen Change-Id: I5a48ef57c8e9c8bab199dbc2d449535251c7f198 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2745961 Reviewed-by: svc_kernel_abi Reviewed-by: Brad Griffis Reviewed-by: Jonathan Hunter Reviewed-by: Bibek Basu GVS: Gerrit_Virtual_Submit Tested-by: Brad Griffis --- .../gpu/host1x/include/linux/host1x-next.h | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/gpu/host1x/include/linux/host1x-next.h b/drivers/gpu/host1x/include/linux/host1x-next.h index 215802c4..6e943851 100644 --- a/drivers/gpu/host1x/include/linux/host1x-next.h +++ b/drivers/gpu/host1x/include/linux/host1x-next.h @@ -453,4 +453,38 @@ int tegra_mipi_disable(struct tegra_mipi_device *device); int tegra_mipi_start_calibration(struct tegra_mipi_device *device); int tegra_mipi_finish_calibration(struct tegra_mipi_device *device); +/* host1x memory contexts */ + +struct host1x_memory_context { + struct host1x *host; + + refcount_t ref; + struct pid *owner; + + struct device dev; + u64 dma_mask; + u32 stream_id; +}; + +#ifdef CONFIG_IOMMU_API +struct host1x_memory_context *host1x_memory_context_alloc(struct host1x *host1x, + struct pid *pid); +void host1x_memory_context_get(struct host1x_memory_context *cd); +void host1x_memory_context_put(struct host1x_memory_context *cd); +#else +static inline struct host1x_memory_context *host1x_memory_context_alloc(struct host1x *host1x, + struct pid *pid) +{ + return NULL; +} + +static inline void host1x_memory_context_get(struct host1x_memory_context *cd) +{ +} + +static inline void host1x_memory_context_put(struct host1x_memory_context *cd) +{ +} +#endif + #endif