to wire the AMDGPU_PROFILER_SPM operation into the profiler ioctl dispatch path, and introduce amdgpu_spm_ioctl() as the dedicated SPM sub-ioctl handler.
In amdgpu_profiler_ioctl(), the new AMDGPU_PROFILER_SPM case extracts the embedded drm_amdgpu_spm_args from the profiler args union and forwards it to amdgpu_spm_ioctl(dev, &args->spm, filp). amdgpu_spm_ioctl() resolves the per-device amdgpu_device from the drm_file's driver_priv and switches on args->op. At this point only the default error path is present, returning -EINVAL for all unknown operations. Subsequent patches will add cases for AMDGPU_SPM_OP_ACQUIRE, AMDGPU_SPM_OP_SET_DEST_BUF, and AMDGPU_SPM_OP_RELEASE. Signed-off-by: James Zhu <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_spm.c | 14 ++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_spm.h | 3 +++ 3 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c index d462d99dc8bb..194bd9339cad 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c @@ -50,6 +50,9 @@ int amdgpu_profiler_ioctl( AMDGPU_PROFILER_VERSION_MINOR; return 0; + case AMDGPU_PROFILER_SPM: + return amdgpu_spm_ioctl(dev, &args->spm, filp); + default: dev_dbg(adev->dev, "Invalid option: %i", args->op); } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_spm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_spm.c index af7ee74aaa35..6ff88dfabf1c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_spm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_spm.c @@ -47,6 +47,20 @@ static int amdgpu_spm_release(struct amdgpu_spm_mgr *spm_mgr, struct drm_file *f return 0; } +int amdgpu_spm_ioctl(struct drm_device *dev, void *data, + struct drm_file *filp) +{ + struct amdgpu_fpriv *fpriv = filp->driver_priv; + struct amdgpu_device *adev = fpriv_to_adev(fpriv); + struct drm_amdgpu_spm_args *args = data; + + switch (args->op) { + default: + dev_dbg(adev->dev, "Invalid option: %i\n", args->op); + return -EINVAL; + } +} + int amdgpu_spm_mgr_init(struct amdgpu_spm_mgr *spm_mgr) { amdgpu_spm_init_device(spm_mgr); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_spm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_spm.h index ade50abfa590..dc55d2a8f016 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_spm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_spm.h @@ -28,6 +28,9 @@ struct amdgpu_spm_mgr { struct drm_file *file; }; +int amdgpu_spm_ioctl(struct drm_device *dev, void *data, + struct drm_file *filp); + int amdgpu_spm_mgr_init(struct amdgpu_spm_mgr *spm_mgr); void amdgpu_spm_mgr_fini(struct amdgpu_spm_mgr *spm_mgr); void amdgpu_spm_interrupt(struct amdgpu_device *adev, int xcc_id); -- 2.34.1
