gpu: nvgpu: Direct GMMU PTE kind control

Allow userspace to control directly the PTE kind for the mappings by
supplying NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL for MAP_BUFFER_EX.

In particular, in this mode, the userspace will tell the kernel
whether the kind is compressible, and if so, what is the
incompressible fallback kind. By supplying only the compressible kind,
the userspace can require that the map kind will not be demoted to the
incompressible fallback kind in case of comptag allocation failure.

Add also a GPU characteristics flag
NVGPU_GPU_FLAGS_SUPPORT_MAP_DIRECT_KIND_CTRL to signal whether direct
kind control is supported.

Fix indentation of nvgpu_as_map_buffer_ex_args header comment.

Bug 1705731

Change-Id: I317ab474ae53b78eb8fdd31bd6bca0541fcba9a4
Signed-off-by: Sami Kiminki <skiminki@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1543462
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
Sami Kiminki
2017-08-22 16:14:56 +03:00
committed by mobile promotions
parent 2b7e8a2c2a
commit 5d09c908b0
8 changed files with 205 additions and 31 deletions

View File

@@ -146,6 +146,9 @@ struct nvgpu_gpu_zbc_query_table_args {
#define NVGPU_GPU_FLAGS_SUPPORT_IO_COHERENCE (1ULL << 20)
/* NVGPU_SUBMIT_GPFIFO_FLAGS_RESCHEDULE_RUNLIST is available */
#define NVGPU_GPU_FLAGS_SUPPORT_RESCHEDULE_RUNLIST (1ULL << 21)
/* Direct PTE kind control is supported (map_buffer_ex) */
#define NVGPU_GPU_FLAGS_SUPPORT_MAP_DIRECT_KIND_CTRL (1ULL << 23)
struct nvgpu_gpu_characteristics {
__u32 arch;
@@ -1751,6 +1754,7 @@ struct nvgpu_as_map_buffer_args {
#define NVGPU_AS_MAP_BUFFER_FLAGS_IO_COHERENT (1 << 4)
#define NVGPU_AS_MAP_BUFFER_FLAGS_UNMAPPED_PTE (1 << 5)
#define NVGPU_AS_MAP_BUFFER_FLAGS_MAPPABLE_COMPBITS (1 << 6)
#define NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL (1 << 8)
__u32 reserved; /* in */
__u32 dmabuf_fd; /* in */
__u32 page_size; /* inout, 0:= best fit to buffer */
@@ -1760,7 +1764,7 @@ struct nvgpu_as_map_buffer_args {
} o_a;
};
/*
/*
* Mapping dmabuf fds into an address space:
*
* The caller requests a mapping to a particular page 'kind'.
@@ -1772,7 +1776,37 @@ struct nvgpu_as_map_buffer_args {
struct nvgpu_as_map_buffer_ex_args {
__u32 flags; /* in/out */
#define NV_KIND_DEFAULT -1
__s32 kind; /* in (-1 represents default) */
union {
/*
* Used if NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL
* is not set.
*/
__s32 kind; /* in (-1 represents default) */
/*
* If NVGPU_AS_MAP_BUFFER_FLAGS_DIRECT_KIND_CTRL is
* set, this is used, instead. The rules are:
*
* - If both compr_kind and incompr_kind are set
* (i.e., value is other than NV_KIND_INVALID),
* kernel attempts to use compr_kind first.
*
* - If compr_kind is set, kernel attempts to allocate
* comptags for the buffer. If successful,
* compr_kind is used as the PTE kind.
*
* - If incompr_kind is set, kernel uses incompr_kind
* as the PTE kind. Comptags are not allocated.
*
* - If neither compr_kind or incompr_kind is set, the
* map call will fail.
*/
#define NV_KIND_INVALID -1
struct {
__s16 compr_kind;
__s16 incompr_kind;
};
};
__u32 dmabuf_fd; /* in */
__u32 page_size; /* inout, 0:= best fit to buffer */