drm/amdgpu: Add guest driver CUID support
Subsystems (2)
PATCH 1/1 drm/amdgpu: Add guest driver CUID support
1. Add guest driver CUID support
2. Do not expose vf index(variable "fcn_idx") to customers, replace the fcn_idx with pad.
Only expose the unitid to customers.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 55 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 8 ++- drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 2 +- 4 files changed, 63 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1074,6 +1074,7 @@ struct amdgpu_device {long psp_timeout;uint64_t unique_id; +uint8_t unitid;uint64_t df_perfmon_config_assign_mask[AMDGPU_MAX_DF_PERFMONS ];/* enable runtime pm on the device */
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +55 -0
67 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +6 -2
@@ -534,8 +534,12 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)if ((adev->virt.decode_max_dimension_pixels >0 ) || (adev->virt.encode_max_dimension_pixels >0 )) adev->virt.is_mm_bw_enabled = true; - adev->unique_id = - ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->uuid; + adev->unique_id = ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->uuid; + + adev->unitid =0 ; +if (amdgpu_sriov_is_unitid_support (adev)) + adev->unitid = ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->unitid; + adev->virt.ras_en_caps.all = ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->ras_en_caps.all; adev->virt.ras_telemetry_en_caps.all = ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->ras_telemetry_en_caps.all;
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h +1 -1
@@ -295,7 +295,7 @@ struct amd_sriov_msg_pf2vf_info {uint32_t vf2pf_update_interval_ms;/* identification in ROCm SMI */ uint64_t uuid; -uint32_t fcn_idx; +uint32_t pad;/* flags to indicate which register access method VF should use */ union amd_sriov_reg_access_flags reg_access_flags;/* MM BW management */
Signature · 1 line
2.48.1
Christian König
maintainerQuoted 63 lines · chong li
1. Add guest driver CUID support
2. Do not expose vfindex(variable "fcn_idx")to customers, replace thefcn_idxwith pad.
Only expose the unitid to customers.Signed-off-by chong li <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 55 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 8 ++- drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 2 +- 4 files changed, 63 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1074,6 +1074,7 @@ struct amdgpu_device {long psp_timeout;uint64_t unique_id; +uint8_t unitid;uint64_t df_perfmon_config_assign_mask[AMDGPU_MAX_DF_PERFMONS ];/* enable runtime pm on the device */ drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +29
-0@@ -2114,6 +2114,45 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,DEFINE_DEBUGFS_ATTRIBUTE (fops_sclk_set,NULL , amdgpu_debugfs_sclk_set,"%llu\n" ); + +static ssize_t amdgpu_debugfs_unique_id_read (struct file *f,char __user *buf, +size_t size,loff_t *pos) +{ +struct amdgpu_device *adev =file_inode (f)->i_private; +char tmp[34 ]; +int len; + + len =scnprintf (tmp,sizeof (tmp),"0x%016llx\n" , + adev->unique_id); + +return simple_read_from_buffer (buf, size, pos, tmp, len); +} + +static ssize_t amdgpu_debugfs_unitid_read (struct file *f,char __user *buf, +size_t size,loff_t *pos) +{ +struct amdgpu_device *adev =file_inode (f)->i_private; +char tmp[34 ]; +int len; + + len =scnprintf (tmp,sizeof (tmp),"0x%02x\n" , + adev->unitid); + +return simple_read_from_buffer (buf, size, pos, tmp, len); +} + +static const struct file_operations amdgpu_debugfs_unique_id_fops = { + .owner =THIS_MODULE ,
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 2156
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +10
-0+ .read = amdgpu_debugfs_unique_id_read, + .llseek = default_llseek, +}; + +static const struct file_operations amdgpu_debugfs_unitid_fops = { + .owner =THIS_MODULE , + .read = amdgpu_debugfs_unitid_read, + .llseek = default_llseek, +}; +
As far as I can see that is overkill, please use debugfs_create_x64() and debugfs_create_x8() instead.
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0int amdgpu_debugfs_init (struct amdgpu_device *adev) {drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0struct dentry *root =adev_to_drm (adev)->primary->debugfs_root;@@ -2126,6 +2165,22 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) debugfs_create_x32("amdgpu_smu_debug", 0600, root,
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device *adev) · line 2175
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +7
-0&adev->pm.smu_debug_mask); + ent =debugfs_create_file ("unique_id" ,0444 , root, adev, + &amdgpu_debugfs_unique_id_fops); +if (IS_ERR (ent)) { +drm_err (adev_to_drm (adev), +"unable to create unique_id debugfs file\n" ); +return PTR_ERR (ent); + }
Debugfs should never have error handling. Please drop that.
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+ + ent =debugfs_create_file ("unitid" ,0444 , root, adev, + &amdgpu_debugfs_unitid_fops); +if (IS_ERR (ent)) { +drm_err (adev_to_drm (adev), +"unable to create unitid debugfs file\n" ); +return PTR_ERR (ent); + } + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0if (IS_ERR (ent)) {drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev) · line 537
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1
-2@@ -534,8 +534,12 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev)if ((adev->virt.decode_max_dimension_pixels >0 ) || (adev->virt.encode_max_dimension_pixels >0 )) adev->virt.is_mm_bw_enabled = true; - adev->unique_id = - ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->uuid; + adev->unique_id = ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->uuid;
Please make sure that this passes checkpatch.pl. Of hand it looks like the line is to long.
Regards,
Christian.
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +5
-0+ + adev->unitid =0 ; +if (amdgpu_sriov_is_unitid_support (adev)) + adev->unitid = ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->unitid; + adev->virt.ras_en_caps.all = ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->ras_en_caps.all; adev->virt.ras_telemetry_en_caps.all = ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->ras_telemetry_en_caps.all;drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h +1
-1@@ -295,7 +295,7 @@ struct amd_sriov_msg_pf2vf_info {uint32_t vf2pf_update_interval_ms;/* identification in ROCm SMI */ uint64_t uuid; -uint32_t fcn_idx; +uint32_t pad;/* flags to indicate which register access method VF should use */ union amd_sriov_reg_access_flags reg_access_flags;/* MM BW management */