gpu: nvgpu: add profiler api to execute regops

Implement new API nvgpu_prof_ioctl_exec_reg_ops() to support regops on
new profiler objects.

Add two new staging buffers to hold regops copied from userspace, and
to convert and execute regops in common code.
Buffers are allocated and released along with the profiler object.

New API will implements this :
-  copy regops data in chunks of 4K from userspace
- store them in staging buffer
- convert the new regop struct into common regop struct and also
  copy the content into second staging buffer
- trigger gops.regops.exec_regops() with second staging buffer as
  operation pointer
- convert common regop struct back into new regop struct and copy
  back to userspace

Export bunch of helper functions from ioctl_dbg.h. e.g.
nvgpu_get_regops_op_values_common()

Update regop execution code to skip regop execution if regop status
is not valid. This is only possible when userspace requests for
CONTINUE_ON_ERROR mode.

Add more documentation to some of the fields in UAPI header.

Note that maximum atomic operations reported by new API are same
as legacy API and are incorrect. This will be fixed up in upcoming
patches.

Bug 2510974
Jira NVGPU-5360

Change-Id: I9f82052b22143aec33f6e778c0784386744b699e
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2394208
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2020-07-29 13:20:38 +05:30
committed by Alex Waterman
parent a439d3767d
commit 2012a6b558
6 changed files with 276 additions and 13 deletions

View File

@@ -1577,14 +1577,31 @@ struct nvgpu_profiler_pma_stream_update_get_put_args {
__u32 reserved[3];
};
enum {
NVGPU_PROFILER_EXEC_REG_OPS_ARG_MODE_ALL_OR_NONE,
NVGPU_PROFILER_EXEC_REG_OPS_ARG_MODE_CONTINUE_ON_ERROR,
};
/*
* MODE_ALL_OR_NONE
* Reg_ops execution will bail out if any of the reg_op is not valid
* or if there is any other error such as failure to access context image.
* Subsequent reg_ops will not be executed and nvgpu_profiler_reg_op.status
* will not be populated for them.
* IOCTL will always return error for all of the errors.
*/
#define NVGPU_PROFILER_EXEC_REG_OPS_ARG_MODE_ALL_OR_NONE 0U
/*
* MODE_CONTINUE_ON_ERROR
* This mode allows continuing reg_ops execution even if some of the
* reg_ops are not valid. Invalid reg_ops will be skipped and valid
* ones will be executed.
* IOCTL will return error only if there is some other severe failure
* such as failure to access context image.
* If any of the reg_op is invalid, or if didn't pass, it will be
* reported via NVGPU_PROFILER_EXEC_REG_OPS_ARG_FLAG_ALL_PASSED flag.
* IOCTL will return success in such cases.
*/
#define NVGPU_PROFILER_EXEC_REG_OPS_ARG_MODE_CONTINUE_ON_ERROR 1U
struct nvgpu_profiler_reg_op {
__u8 op;
__u8 status;
__u8 op; /* Operation in the form NVGPU_DBG_GPU_REG_OP_READ/WRITE_* */
__u8 status; /* Status in the form NVGPU_DBG_GPU_REG_OP_STATUS_* */
__u32 offset;
__u64 value;
__u64 and_n_mask;
@@ -1593,7 +1610,10 @@ struct nvgpu_profiler_reg_op {
struct nvgpu_profiler_exec_reg_ops_args {
__u32 mode; /* in: operation mode NVGPU_PROFILER_EXEC_REG_OPS_ARG_MODE_* */
__u32 count; /* in: number of reg_ops operations */
__u32 count; /* in: number of reg_ops operations,
* upper limit nvgpu_gpu_characteristics.reg_ops_limit
*/
__u64 ops; /* in/out: pointer to actual operations nvgpu_profiler_reg_op */
/* out: if all reg_ops passed, valid only for MODE_CONTINUE_ON_ERROR */