mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-16 18:00:36 +01:00
nvk/nvkmd: Add an NVKMD_MEM_COHERENT flag
All discrete GPU maps are coherent but that's not true on Tegra. We need a way to request coherent memory and also to ask for it. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33959>
This commit is contained in:
parent
dd53232667
commit
fcb6c5c7a6
2 changed files with 24 additions and 0 deletions
|
|
@ -134,6 +134,19 @@ nvkmd_nouveau_alloc_tiled_mem(struct nvkmd_dev *_dev,
|
|||
if (!(flags & NVKMD_MEM_SHARED))
|
||||
nouveau_flags |= NOUVEAU_WS_BO_NO_SHARE;
|
||||
|
||||
if (dev->base.pdev->dev_info.type == NV_DEVICE_TYPE_SOC) {
|
||||
/* On Tegra, we have to explicitly request coherent maps by putting the
|
||||
* BO in NOUVEAU_GEM_DOMAIN_COHERENT.
|
||||
*/
|
||||
if (flags & NVKMD_MEM_COHERENT)
|
||||
nouveau_flags |= NOUVEAU_WS_BO_COHERENT;
|
||||
} else {
|
||||
/* We assume that all discrete GPU maps are coherent. They're either
|
||||
* CPU memory or WB VRAM maps.
|
||||
*/
|
||||
flags |= NVKMD_MEM_COHERENT;
|
||||
}
|
||||
|
||||
struct nouveau_ws_bo *bo = nouveau_ws_bo_new_tiled(dev->ws_dev,
|
||||
size_B, mem_align_B,
|
||||
pte_kind, tile_mode,
|
||||
|
|
@ -171,6 +184,14 @@ nvkmd_nouveau_import_dma_buf(struct nvkmd_dev *_dev,
|
|||
if (bo->flags & NOUVEAU_WS_BO_MAP)
|
||||
flags |= NVKMD_MEM_CAN_MAP;
|
||||
|
||||
/* We assume that all discrete GPU maps are coherent. They're either CPU
|
||||
* memory or WB VRAM maps. On Tegra, maps are only coherent if the BO is
|
||||
* in NOUVEAU_GEM_DOMAIN_COHERENT.
|
||||
*/
|
||||
if ((bo->flags & NOUVEAU_WS_BO_COHERENT) ||
|
||||
dev->base.pdev->dev_info.type != NV_DEVICE_TYPE_SOC)
|
||||
flags |= NVKMD_MEM_COHERENT;
|
||||
|
||||
return create_mem_or_close_bo(dev, log_obj, flags, bo,
|
||||
0 /* va_flags */,
|
||||
0 /* pte_kind */,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ enum nvkmd_mem_flags {
|
|||
|
||||
/** This memory object may be shared with other processes */
|
||||
NVKMD_MEM_SHARED = 1 << 4,
|
||||
|
||||
/** This memory object has coherent CPU maps */
|
||||
NVKMD_MEM_COHERENT = 1 << 5,
|
||||
};
|
||||
|
||||
#define NVKMD_MEM_PLACEMENT_FLAGS \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue