2018-05-08 21:20:54 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2017-01-16 22:09:51 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Etnaviv Project
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ETNAVIV_CMDBUF_H__
|
|
|
|
#define __ETNAVIV_CMDBUF_H__
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
2019-07-06 00:17:22 +07:00
|
|
|
struct device;
|
drm/etnaviv: rework MMU handling
This reworks the MMU handling to make it possible to have multiple MMU contexts.
A context is basically one instance of GPU page tables. Currently we have one
set of page tables per GPU, which isn't all that clever, as it has the
following two consequences:
1. All GPU clients (aka processes) are sharing the same pagetables, which means
there is no isolation between clients, but only between GPU assigned memory
spaces and the rest of the system. Better than nothing, but also not great.
2. Clients operating on the same set of buffers with different etnaviv GPU
cores, e.g. a workload using both the 2D and 3D GPU, need to map the used
buffers into the pagetable sets of each used GPU.
This patch reworks all the MMU handling to introduce the abstraction of the
MMU context. A context can be shared across different GPU cores, as long as
they have compatible MMU implementations, which is the case for all systems
with Vivante GPUs seen in the wild.
As MMUv1 is not able to change pagetables on the fly, without a
"stop the world" operation, which stops GPU, changes pagetables via CPU
interaction, restarts GPU, the implementation introduces a shared context on
MMUv1, which is returned whenever there is a request for a new context.
This patch assigns a MMU context to each GPU, so on MMUv2 systems there is
still one set of pagetables per GPU, but due to the shared context MMUv1
systems see a change in behavior as now a single pagetable set is used
across all GPU cores.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Guido Günther <agx@sigxcpu.org>
2019-07-06 00:17:24 +07:00
|
|
|
struct etnaviv_iommu_context;
|
2019-07-06 00:17:21 +07:00
|
|
|
struct etnaviv_vram_mapping;
|
2017-01-16 23:29:57 +07:00
|
|
|
struct etnaviv_cmdbuf_suballoc;
|
2017-09-24 20:15:23 +07:00
|
|
|
struct etnaviv_perfmon_request;
|
2017-01-16 23:29:57 +07:00
|
|
|
|
2017-01-16 22:09:51 +07:00
|
|
|
struct etnaviv_cmdbuf {
|
2017-01-16 23:29:57 +07:00
|
|
|
/* suballocator this cmdbuf is allocated from */
|
|
|
|
struct etnaviv_cmdbuf_suballoc *suballoc;
|
2017-01-16 22:09:51 +07:00
|
|
|
/* cmdbuf properties */
|
2017-01-16 23:29:57 +07:00
|
|
|
int suballoc_offset;
|
2017-01-16 22:09:51 +07:00
|
|
|
void *vaddr;
|
|
|
|
u32 size;
|
|
|
|
u32 user_size;
|
|
|
|
};
|
|
|
|
|
2017-01-16 23:29:57 +07:00
|
|
|
struct etnaviv_cmdbuf_suballoc *
|
2019-07-06 00:17:22 +07:00
|
|
|
etnaviv_cmdbuf_suballoc_new(struct device *dev);
|
2017-01-16 23:29:57 +07:00
|
|
|
void etnaviv_cmdbuf_suballoc_destroy(struct etnaviv_cmdbuf_suballoc *suballoc);
|
2019-07-06 00:17:21 +07:00
|
|
|
int etnaviv_cmdbuf_suballoc_map(struct etnaviv_cmdbuf_suballoc *suballoc,
|
drm/etnaviv: rework MMU handling
This reworks the MMU handling to make it possible to have multiple MMU contexts.
A context is basically one instance of GPU page tables. Currently we have one
set of page tables per GPU, which isn't all that clever, as it has the
following two consequences:
1. All GPU clients (aka processes) are sharing the same pagetables, which means
there is no isolation between clients, but only between GPU assigned memory
spaces and the rest of the system. Better than nothing, but also not great.
2. Clients operating on the same set of buffers with different etnaviv GPU
cores, e.g. a workload using both the 2D and 3D GPU, need to map the used
buffers into the pagetable sets of each used GPU.
This patch reworks all the MMU handling to introduce the abstraction of the
MMU context. A context can be shared across different GPU cores, as long as
they have compatible MMU implementations, which is the case for all systems
with Vivante GPUs seen in the wild.
As MMUv1 is not able to change pagetables on the fly, without a
"stop the world" operation, which stops GPU, changes pagetables via CPU
interaction, restarts GPU, the implementation introduces a shared context on
MMUv1, which is returned whenever there is a request for a new context.
This patch assigns a MMU context to each GPU, so on MMUv2 systems there is
still one set of pagetables per GPU, but due to the shared context MMUv1
systems see a change in behavior as now a single pagetable set is used
across all GPU cores.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Guido Günther <agx@sigxcpu.org>
2019-07-06 00:17:24 +07:00
|
|
|
struct etnaviv_iommu_context *context,
|
2019-07-06 00:17:21 +07:00
|
|
|
struct etnaviv_vram_mapping *mapping,
|
|
|
|
u32 memory_base);
|
drm/etnaviv: rework MMU handling
This reworks the MMU handling to make it possible to have multiple MMU contexts.
A context is basically one instance of GPU page tables. Currently we have one
set of page tables per GPU, which isn't all that clever, as it has the
following two consequences:
1. All GPU clients (aka processes) are sharing the same pagetables, which means
there is no isolation between clients, but only between GPU assigned memory
spaces and the rest of the system. Better than nothing, but also not great.
2. Clients operating on the same set of buffers with different etnaviv GPU
cores, e.g. a workload using both the 2D and 3D GPU, need to map the used
buffers into the pagetable sets of each used GPU.
This patch reworks all the MMU handling to introduce the abstraction of the
MMU context. A context can be shared across different GPU cores, as long as
they have compatible MMU implementations, which is the case for all systems
with Vivante GPUs seen in the wild.
As MMUv1 is not able to change pagetables on the fly, without a
"stop the world" operation, which stops GPU, changes pagetables via CPU
interaction, restarts GPU, the implementation introduces a shared context on
MMUv1, which is returned whenever there is a request for a new context.
This patch assigns a MMU context to each GPU, so on MMUv2 systems there is
still one set of pagetables per GPU, but due to the shared context MMUv1
systems see a change in behavior as now a single pagetable set is used
across all GPU cores.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Guido Günther <agx@sigxcpu.org>
2019-07-06 00:17:24 +07:00
|
|
|
void etnaviv_cmdbuf_suballoc_unmap(struct etnaviv_iommu_context *context,
|
2019-07-06 00:17:21 +07:00
|
|
|
struct etnaviv_vram_mapping *mapping);
|
2017-01-16 23:29:57 +07:00
|
|
|
|
2017-11-24 22:56:37 +07:00
|
|
|
|
|
|
|
int etnaviv_cmdbuf_init(struct etnaviv_cmdbuf_suballoc *suballoc,
|
|
|
|
struct etnaviv_cmdbuf *cmdbuf, u32 size);
|
2017-01-16 23:29:57 +07:00
|
|
|
void etnaviv_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf);
|
|
|
|
|
2019-07-06 00:17:21 +07:00
|
|
|
u32 etnaviv_cmdbuf_get_va(struct etnaviv_cmdbuf *buf,
|
|
|
|
struct etnaviv_vram_mapping *mapping);
|
2017-01-16 23:00:08 +07:00
|
|
|
dma_addr_t etnaviv_cmdbuf_get_pa(struct etnaviv_cmdbuf *buf);
|
2017-01-16 22:52:44 +07:00
|
|
|
|
2017-01-16 22:09:51 +07:00
|
|
|
#endif /* __ETNAVIV_CMDBUF_H__ */
|