drm/amdgpu: Add SMI-LIB ioctl
Subsystems (5)
PATCH 1/7 drm/amdgpu: Add SMI-LIB ioctl
From: David M Nieto <[email protected]>
Add definition for the SMI ioctl
--- include/uapi/drm/amdgpu_drm.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/uapi/drm/amdgpu_drm.h +20 -0
@@ -56,6 +56,7 @@ extern "C" {#define DRM_AMDGPU_SCHED 0x15/* not upstream */ #define DRM_AMDGPU_FREESYNC 0x5d +#define DRM_AMDGPU_SMI 0x5e#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -74,6 +75,7 @@ extern "C" {#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)#define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)#define DRM_IOCTL_AMDGPU_FREESYNC DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync) +#define DRM_IOCTL_AMDGPU_SMI DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_SMI, struct drm_amdgpu_smi)/** * DOC: memory domains
@@ -1138,6 +1140,24 @@ struct drm_amdgpu_freesync {__u32 spare[7 ]; }; +/* Definition of the SMI handlers */ +#define AMDGPU_SMI_MAX_PAYLOAD 1024 +struct drm_amdgpu_smi_in_hdr { +__u32 code; +__u16 in_len; +__u16 out_len; +}; + +struct drm_amdgpu_smi_out_hdr { +__s32 status; +}; + +struct drm_amdgpu_smi { +struct drm_amdgpu_smi_in_hdr in; +struct drm_amdgpu_smi_out_hdr out; +__u64 payload; +}; +#if defined(__cplusplus) }#endif
Signature · 6 lines
2.29.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/7 drm: Change scheduled fence track
From: David M Nieto <[email protected]>
Update the timestamp of the scheduled fence on
HW completion of the previous fence.
This allows more accurate tracking of the fence
execution in HW
--- drivers/gpu/drm/scheduler/sched_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/scheduler/sched_main.c +8 -1
@@ -671,7 +671,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)static struct drm_sched_job *drm_sched_get_cleanup_job (struct drm_gpu_scheduler *sched) { -struct drm_sched_job *job; +struct drm_sched_job *job, *next;/* * Don't destroy jobs while the timeout worker is running OR thread
@@ -690,6 +690,13 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)if (job &&dma_fence_is_signaled (&job->s_fence->finished)) {/* remove job from pending_list */ list_del_init (&job->list); +/* account for the next fence in the queue */ + next =list_first_entry_or_null (&sched->pending_list, + struct drm_sched_job, list); +if (next) { + next->s_fence->scheduled.timestamp = + job->s_fence->finished.timestamp; + } }else { job =NULL ;/* queue timeout for next job */
Signature · 6 lines
2.29.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/7 drm/amdgpu: SMI-LIB handlers
In reply to Roy SunFrom: David M Nieto <[email protected]>
Add fence tracking interfaces and core
structures for SMI ioctl management
--- drivers/gpu/drm/amd/amdgpu/Makefile | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 12 + drivers/gpu/drm/amd/amdgpu/amdgpu_smi.c | 433 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_smi.h | 61 ++++ 4 files changed, 514 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_smi.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_smi.h
drivers/gpu/drm/amd/amdgpu/Makefile +8 -2
@@ -36,7 +36,8 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ -I$(FULL_AMD_DISPLAY_PATH)/include \ -I$(FULL_AMD_DISPLAY_PATH)/dc \ -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \ - -I$(FULL_AMD_PATH)/amdkfd + -I$(FULL_AMD_PATH)/amdkfd \ + -I$(FULL_AMD_PATH)/amdsmi/inc amdgpu-y := amdgpu_drv.o
@@ -56,7 +57,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ amdgpu_gmc.o amdgpu_mmhub.o amdgpu_xgmi.o amdgpu_csa.o amdgpu_ras.o amdgpu_vm_cpu.o \ amdgpu_vm_sdma.o amdgpu_discovery.o amdgpu_ras_eeprom.o amdgpu_nbio.o \ amdgpu_umc.o smu_v11_0_i2c.o amdgpu_fru_eeprom.o amdgpu_rap.o \ - amdgpu_fw_attestation.o amdgpu_securedisplay.o + amdgpu_fw_attestation.o amdgpu_securedisplay.o amdgpu_smi.o amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o
@@ -236,4 +237,9 @@ amdgpu-y += $(AMD_DISPLAY_FILES) endif +# SMI component +AMDSMI_PATH := ../amdsmi +include $(FULL_AMD_PATH)/amdsmi/Makefile +amdgpu-y += $(AMDSMI_FILES) + obj-$(CONFIG_DRM_AMDGPU)+= amdgpu.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +12 -0
@@ -108,6 +108,7 @@#include "amdgpu_df.h" #include "amdgpu_smuio.h" #include "amdgpu_hdp.h" +#include "amdgpu_smi.h" #define MAX_GPU_INSTANCE 16
@@ -268,6 +269,7 @@ struct amdgpu_irq_src;struct amdgpu_fpriv ;struct amdgpu_bo_va_mapping ;struct amdgpu_atif ; +struct amdgpu_smi_proc ;struct kfd_vm_fault_info ;struct amdgpu_hive_info ;
@@ -475,6 +477,9 @@ struct amdgpu_fpriv {struct mutex bo_list_lock;struct idr bo_list_handles;struct amdgpu_ctx_mgr ctx_mgr; +struct drm_file *file; +struct amdgpu_smi_proc *proc; +void *smi_priv; };int amdgpu_file_to_fpriv (struct file *filp,struct amdgpu_fpriv **fpriv);
@@ -824,6 +829,9 @@ struct amdgpu_device {struct notifier_block acpi_nb;struct amdgpu_i2c_chan *i2c_bus[AMDGPU_MAX_I2C_BUS ];struct debugfs_blob_wrapper debugfs_vbios_blob; +#if defined(CONFIG_DEBUG_FS ) +struct dentry *debugfs_proc; +#endif struct amdgpu_atif *atif;struct amdgpu_atcs atcs;struct mutex srbm_mutex;
@@ -1082,6 +1090,10 @@ struct amdgpu_device {bool in_pci_err_recovery;struct pci_saved_state *pci_state; + +/* SMI process tracking */ +struct idr procs; +struct mutex proc_lock; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)
drivers/gpu/drm/amd/amdgpu/amdgpu_smi.c new file +433 -0
433 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_smi.h new file +61 -0
61 lines not on this page · raw message
Signature · 6 lines
2.29.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/7 drm/amdgpu: Track fences on KMS
In reply to Roy SunFrom: David M Nieto <[email protected]>
Create SMI fence tracking structures of KMS open
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -1679,7 +1679,8 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {DRM_IOCTL_DEF_DRV (AMDGPU_GEM_VA , amdgpu_gem_va_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_GEM_OP , amdgpu_gem_op_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_GEM_USERPTR , amdgpu_gem_userptr_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ), -DRM_IOCTL_DEF_DRV (AMDGPU_FREESYNC , amdgpu_display_freesync_ioctl,DRM_MASTER ) +DRM_IOCTL_DEF_DRV (AMDGPU_FREESYNC , amdgpu_display_freesync_ioctl,DRM_MASTER ), +DRM_IOCTL_DEF_DRV (AMDGPU_SMI , amdgpu_smi_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ) }; static const struct drm_driver amdgpu_kms_driver = {
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +10 -0
@@ -41,6 +41,7 @@#include "amdgpu_gem.h" #include "amdgpu_display.h" #include "amdgpu_ras.h" +#include "amdgpu_smi.h" void amdgpu_unregister_gpu_instance (struct amdgpu_device *adev) {
@@ -210,6 +211,10 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)pm_runtime_put_autosuspend (dev->dev); } +/* SMI */ +mutex_init (&adev->proc_lock); +idr_init (&adev->procs); + out:if (r) {/* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
@@ -1135,6 +1140,9 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)amdgpu_ctx_mgr_init (&fpriv->ctx_mgr); file_priv->driver_priv = fpriv; + fpriv->file = file_priv; + +amdgpu_smi_create_proc_node (adev, fpriv, pasid); goto out_suspend; error_vm:
@@ -1177,6 +1185,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,pm_runtime_get_sync (dev->dev); +amdgpu_smi_remove_proc_node (adev, fpriv); +if (amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_UVD ) !=NULL )amdgpu_uvd_free_handles (adev, file_priv);if (amdgpu_device_ip_get_ip_block (adev,AMD_IP_BLOCK_TYPE_VCE ) !=NULL )
Signature · 6 lines
2.29.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/7 drm/amdgpu: SMI debugfs tracking
In reply to Roy SunFrom: David M Nieto <[email protected]>
Add folder in debugfs structure for tracking of per pid fences
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +5 -0
@@ -1544,7 +1544,12 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)struct dentry *ent;int r, i; + ent =debugfs_create_dir ("proc" , root); +if (!ent) { +DRM_ERROR ("unable to create proc debugfs dir\n" ); +return -EIO ; + } ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);
Signature · 6 lines
2.29.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/7 drm/amdkfd: Add fence tracking
In reply to Roy SunFrom: David M Nieto <[email protected]>
Add fence tracking for amdgpu resources on gpuvm creation
--- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +13 -4
@@ -1042,13 +1042,16 @@ int amdgpu_amdkfd_gpuvm_create_process_vm(struct kgd_dev *kgd, u32 pasid, struct dma_fence **ef) {struct amdgpu_device *adev =get_amdgpu_device (kgd); +struct amdgpu_fpriv *fpriv;struct amdgpu_vm *new_vm;int ret; - new_vm =kzalloc (sizeof (*new_vm),GFP_KERNEL ); -if (!new_vm) + fpriv =kzalloc (sizeof (*fpriv),GFP_KERNEL ); +if (!fpriv)return -ENOMEM ; + new_vm = &fpriv->vm; +/* Initialize AMDGPU part of the VM */ ret =amdgpu_vm_init (adev, new_vm,AMDGPU_VM_CONTEXT_COMPUTE , pasid);if (ret) {
@@ -1063,12 +1066,14 @@ int amdgpu_amdkfd_gpuvm_create_process_vm(struct kgd_dev *kgd, u32 pasid, *vm = (void *) new_vm; +amdgpu_smi_create_proc_node (adev, fpriv, pasid); +return 0 ; init_kfd_vm_fail:amdgpu_vm_fini (adev, new_vm); amdgpu_vm_init_fail: -kfree (new_vm); +kfree (fpriv);return ret; }
@@ -1142,6 +1147,8 @@ void amdgpu_amdkfd_gpuvm_destroy_process_vm(struct kgd_dev *kgd, void *vm) {struct amdgpu_device *adev =get_amdgpu_device (kgd);struct amdgpu_vm *avm = (struct amdgpu_vm *)vm; +struct amdgpu_fpriv *fpriv = + container_of(avm, struct amdgpu_fpriv, vm);if (WARN_ON (!kgd || !vm))return ;
@@ -1149,8 +1156,10 @@ void amdgpu_amdkfd_gpuvm_destroy_process_vm(struct kgd_dev *kgd, void *vm)pr_debug ("Destroying process vm %p\n" , vm);/* Release the VM context */ +amdgpu_smi_remove_proc_node (adev, fpriv); +amdgpu_vm_fini (adev, avm); -kfree (vm); +kfree (fpriv); }void amdgpu_amdkfd_gpuvm_release_process_vm (struct kgd_dev *kgd,void *vm)
Signature · 6 lines
2.29.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx