mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-24 02:01:36 +03:00
gpu: host1x: Memory context stealing
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>
This commit is contained in:
committed by
mobile promotions
parent
7e85d429e7
commit
e062e9d49c
@@ -495,12 +495,26 @@ int tegra_mipi_finish_calibration(struct tegra_mipi_device *device);
|
||||
struct host1x_memory_context {
|
||||
struct host1x *host;
|
||||
|
||||
refcount_t ref;
|
||||
struct pid *owner;
|
||||
struct device *dev; /* Owning engine */
|
||||
struct pid *pid;
|
||||
|
||||
struct device dev;
|
||||
u64 dma_mask;
|
||||
u32 stream_id;
|
||||
refcount_t ref;
|
||||
|
||||
struct host1x_hw_memory_context *hw;
|
||||
struct device *context_dev; /* Context device */
|
||||
struct list_head entry; /* Entry in hw_memory_context's list */
|
||||
struct list_head mappings; /* List of mappings */
|
||||
};
|
||||
|
||||
struct host1x_context_mapping {
|
||||
struct host1x *host;
|
||||
|
||||
struct host1x_bo_mapping *mapping;
|
||||
|
||||
struct host1x_bo *bo;
|
||||
enum dma_data_direction direction;
|
||||
|
||||
struct list_head entry;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_IOMMU_API
|
||||
@@ -509,6 +523,11 @@ 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);
|
||||
int host1x_memory_context_active(struct host1x_memory_context *cd);
|
||||
void host1x_memory_context_inactive(struct host1x_memory_context *cd);
|
||||
struct host1x_context_mapping *host1x_memory_context_map(
|
||||
struct host1x_memory_context *ctx, struct host1x_bo *bo, enum dma_data_direction direction);
|
||||
void host1x_memory_context_unmap(struct host1x_context_mapping *m);
|
||||
#else
|
||||
static inline struct host1x_memory_context *host1x_memory_context_alloc(struct host1x *host1x,
|
||||
struct pid *pid)
|
||||
@@ -523,6 +542,25 @@ static inline void host1x_memory_context_get(struct host1x_memory_context *cd)
|
||||
static inline void host1x_memory_context_put(struct host1x_memory_context *cd)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int host1x_memory_context_active(struct host1x_memory_context *cd)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static inline void host1x_memory_context_inactive(struct host1x_memory_context *cd)
|
||||
{
|
||||
}
|
||||
|
||||
static inline struct host1x_context_mapping *host1x_memory_context_map(
|
||||
struct host1x_memory_context *ctx, struct host1x_bo *bo, enum dma_data_direction direction)
|
||||
{
|
||||
return ERR_PTR(-ENODEV);
|
||||
}
|
||||
|
||||
static inline void host1x_memory_context_unmap(struct host1x_context_mapping *m)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
int host1x_actmon_read_avg_count(struct host1x_client *client);
|
||||
|
||||
Reference in New Issue
Block a user