KFD upstreaming September 2018
Subsystems (3)
cover KFD upstreaming September 2018
This patch series is based on amd-staging-drm-next.
Patches 1-3 are important fixes that would be good to be included in drm-fixes for 4.19.
Patches 3-8 are small feature enhancements.
Patch 9 is random cleanup.
I'll send a separate patch series that adds Vega20 support to KFD on top of this.
Amber Lin (1):
drm/amdgpu: Fix SDMA HQD destroy error on gfx_v7
Emily Deng (1):
drm/amdkfd: KFD doesn't support TONGA SRIOV
Eric Huang (1):
drm/amdkfd: reflect atomic support in IO link properties
Felix Kuehling (2):
drm/amdkfd: Report SDMA firmware version in the topology drm/amdgpu: remove unnecessary forward declaration
Harish Kasiviswanathan (1):
drm/amdgpu: Enable BAD_OPCODE intr for gfx8
Jay Cornwall (1):
drm/amdkfd: Add wavefront context save state retrieval ioctl
Yong Zhao (2):
drm/amdkfd: Change the control stack MTYPE from UC to NC on GFX9 drm/amdkfd: Fix ATS capablity was not reported correctly on some APUs
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 21 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 35 +++++------- .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 37 +++++++++++++ .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.h | 8 +++ drivers/gpu/drm/amd/amdkfd/kfd_iommu.c | 13 ++++- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | 8 +++ drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 25 ++++++++- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 23 ++++++++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 12 ++++ .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 22 ++++++++ drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 64 +++++++++++++++++----- drivers/gpu/drm/amd/include/kgd_kfd_interface.h | 2 +- include/uapi/linux/kfd_ioctl.h | 13 ++++- 17 files changed, 251 insertions(+), 47 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1536802946-29273-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org
PATCH 1/9 drm/amdgpu: Fix SDMA HQD destroy error on gfx_v7
From: Amber Lin <[email protected]>
A wrong register bit was examinated for checking SDMA status so it reports false failures. This typo only appears on gfx_v7. gfx_v8 checks the correct bit.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +1 -1
@@ -686,7 +686,7 @@ static int kgd_hqd_sdma_destroy(struct kgd_dev *kgd, void *mqd,while (true) { temp =RREG32 (sdma_base_addr + mmSDMA0_RLC0_CONTEXT_STATUS); -if (temp &SDMA0_STATUS_REG__RB_CMD_IDLE__SHIFT ) +if (temp &SDMA0_RLC0_CONTEXT_STATUS__IDLE_MASK )break ;if (time_after (jiffies, end_jiffies))return -ETIME ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/9 drm/amdkfd: Change the control stack MTYPE from UC to NC on GFX9
In reply to a message not in the archiveFrom: Yong Zhao <[email protected]>
CWSR fails on Raven if the control stack is MTYPE_UC, which is used for regular GART mappings. As a workaround we map it using MTYPE_NC.
The MEC firmware expects the control stack at one page offset from the start of the MQD so it is part of the MQD allocation on GFXv9. AMDGPU added a memory allocation flag just for this purpose.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 3 ++- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 2 +- drivers/gpu/drm/amd/include/kgd_kfd_interface.h | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +5 -1
@@ -253,7 +253,7 @@ void amdgpu_amdkfd_gpu_reset(struct kgd_dev *kgd)int alloc_gtt_mem (struct kgd_dev *kgd,size_t size,void **mem_obj,uint64_t *gpu_addr, -void **cpu_ptr) +void **cpu_ptr,bool mqd_gfx9) {struct amdgpu_device *adev = (struct amdgpu_device *)kgd;struct amdgpu_bo *bo =NULL ;
@@ -268,6 +268,10 @@ int alloc_gtt_mem(struct kgd_dev *kgd, size_t size, bp.flags =AMDGPU_GEM_CREATE_CPU_GTT_USWC ; bp.type = ttm_bo_type_kernel; bp.resv =NULL ; + +if (mqd_gfx9) + bp.flags |=AMDGPU_GEM_CREATE_MQD_GFX9 ; + r =amdgpu_bo_create (adev, &bp, &bo);if (r) { dev_err(adev->dev,
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1 -1
@@ -136,7 +136,7 @@ void amdgpu_amdkfd_gpu_reset(struct kgd_dev *kgd);/* Shared API */ int alloc_gtt_mem (struct kgd_dev *kgd,size_t size,void **mem_obj,uint64_t *gpu_addr, -void **cpu_ptr); +void **cpu_ptr,bool mqd_gfx9);void free_gtt_mem (struct kgd_dev *kgd,void *mem_obj);void get_local_mem_info (struct kgd_dev *kgd,struct kfd_local_mem_info *mem_info);
drivers/gpu/drm/amd/amdkfd/kfd_device.c +2 -1
@@ -457,7 +457,8 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,if (kfd->kfd2kgd->init_gtt_mem_allocation ( kfd->kgd, size, &kfd->gtt_mem, - &kfd->gtt_start_gpu_addr, &kfd->gtt_start_cpu_ptr)){ + &kfd->gtt_start_gpu_addr, &kfd->gtt_start_cpu_ptr, + false)) {dev_err (kfd_device,"Could not allocate %d bytes\n" , size); goto out; }
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +1 -1
@@ -88,7 +88,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,ALIGN (sizeof (struct v9_mqd ),PAGE_SIZE ), &((*mqd_mem_obj)->gtt_mem), &((*mqd_mem_obj)->gpu_addr), - (void *)&((*mqd_mem_obj)->cpu_ptr)); + (void *)&((*mqd_mem_obj)->cpu_ptr), true); }else retval =kfd_gtt_sa_allocate (mm->dev,sizeof (struct v9_mqd ), mqd_mem_obj);
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +1 -1
@@ -320,7 +320,7 @@ struct tile_config {struct kfd2kgd_calls {int (*init_gtt_mem_allocation)(struct kgd_dev *kgd,size_t size,void **mem_obj,uint64_t *gpu_addr, -void **cpu_ptr); +void **cpu_ptr,bool mqd_gfx9);void (*free_gtt_mem)(struct kgd_dev *kgd,void *mem_obj);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/9 drm/amdkfd: Fix ATS capablity was not reported correctly on some APUs
In reply to a message not in the archiveFrom: Yong Zhao <[email protected]>
Because CRAT_CU_FLAGS_IOMMU_PRESENT was not set in some BIOS crat, we need to workaround this.
For future compatibility, we also overwrite the bit in capability according to the value of needs_iommu_device.
--- drivers/gpu/drm/amd/amdkfd/kfd_iommu.c | 13 ++++++++++++- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 1 + drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 21 ++++++++++++++++----- 3 files changed, 29 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_iommu.c +12 -1
@@ -62,9 +62,20 @@ int kfd_iommu_device_init(struct kfd_dev *kfd)struct amd_iommu_device_info iommu_info;unsigned int pasid_limit;int err; +struct kfd_topology_device *top_dev; -if (!kfd->device_info->needs_iommu_device) + top_dev =kfd_topology_device_by_id (kfd->id); + +/* +* Overwrite ATS capability according to needs_iommu_device to fix +* potential missing corresponding bit in CRAT of BIOS. +*/ +if (!kfd->device_info->needs_iommu_device) { + top_dev->node_props.capability &= ~HSA_CAP_ATS_PRESENT ;return 0 ; + } + + top_dev->node_props.capability |=HSA_CAP_ATS_PRESENT ; iommu_info.flags =0 ; err =amd_iommu_device_info (kfd->pdev, &iommu_info);
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -0
@@ -778,6 +778,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu);int kfd_topology_remove_device (struct kfd_dev *gpu);struct kfd_topology_device *kfd_topology_device_by_proximity_domain (uint32_t proximity_domain); +struct kfd_topology_device *kfd_topology_device_by_id (uint32_t gpu_id);struct kfd_dev *kfd_device_by_id (uint32_t gpu_id);struct kfd_dev *kfd_device_by_pci_dev (const struct pci_dev *pdev);int kfd_topology_enum_kfd_devices (uint8_t idx,struct kfd_dev **kdev);
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +16 -5
@@ -63,22 +63,33 @@ struct kfd_topology_device *kfd_topology_device_by_proximity_domain(return device; } -struct kfd_dev *kfd_device_by_id (uint32_t gpu_id) +struct kfd_topology_device *kfd_topology_device_by_id (uint32_t gpu_id) { -struct kfd_topology_device *top_dev; -struct kfd_dev *device =NULL ; +struct kfd_topology_device *top_dev =NULL ; +struct kfd_topology_device *ret =NULL ;down_read (&topology_lock);list_for_each_entry (top_dev, &topology_device_list, list)if (top_dev->gpu_id == gpu_id) { - device = top_dev->gpu; + ret = top_dev;break ; }up_read (&topology_lock); -return device; +return ret; +} + +struct kfd_dev *kfd_device_by_id (uint32_t gpu_id) +{ +struct kfd_topology_device *top_dev; + + top_dev =kfd_topology_device_by_id (gpu_id); +if (!top_dev) +return NULL ; + +return top_dev->gpu; }struct kfd_dev *kfd_device_by_pci_dev (const struct pci_dev *pdev)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/9 drm/amdkfd: reflect atomic support in IO link properties
In reply to a message not in the archiveFrom: Eric Huang <[email protected]>
Add the flags of properties according to Asic type and pcie capabilities.
--- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 12 +++++----- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 ++ drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 37 +++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +7 -5
@@ -366,6 +366,10 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,return NULL ; } + kfd =kzalloc (sizeof (*kfd),GFP_KERNEL ); +if (!kfd) +return NULL ; +/* Allow BIF to recode atomics to PCIe 3.0 AtomicOps. * 32 and 64-bit requests are possible and must be * supported.
@@ -377,12 +381,10 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,dev_info (kfd_device,"skipped device %x:%x, PCI rejects atomics\n" , pdev->vendor, pdev->device); +kfree (kfd);return NULL ; - } - - kfd =kzalloc (sizeof (*kfd),GFP_KERNEL ); -if (!kfd) -return NULL ; + }else if (!ret) + kfd->pci_atomic_requested = true; kfd->kgd = kgd; kfd->device_info = device_info;
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2 -0
@@ -254,6 +254,8 @@ struct kfd_dev {bool cwsr_enabled;const void *cwsr_isa;unsigned int cwsr_isa_size; + +bool pci_atomic_requested; };/* KGD2KFD callbacks */
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +30 -7
@@ -1125,17 +1125,40 @@ static void kfd_fill_mem_clk_max_info(struct kfd_topology_device *dev)static void kfd_fill_iolink_non_crat_info (struct kfd_topology_device *dev) { -struct kfd_iolink_properties *link; +struct kfd_iolink_properties *link, *cpu_link; +struct kfd_topology_device *cpu_dev; +uint32_t cap; +uint32_t cpu_flag =CRAT_IOLINK_FLAGS_ENABLED ; +uint32_t flag =CRAT_IOLINK_FLAGS_ENABLED ;if (!dev || !dev->gpu)return ; -/* GPU only creates direck links so apply flags setting to all */ -if (dev->gpu->device_info->asic_family ==CHIP_HAWAII ) -list_for_each_entry (link, &dev->io_link_props, list) - link->flags =CRAT_IOLINK_FLAGS_ENABLED | -CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT | -CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT ; +pcie_capability_read_dword (dev->gpu->pdev, +PCI_EXP_DEVCAP2 , &cap); + +if (!(cap & (PCI_EXP_DEVCAP2_ATOMIC_COMP32 | +PCI_EXP_DEVCAP2_ATOMIC_COMP64 ))) + cpu_flag |=CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT | +CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT ; + +if (!dev->gpu->pci_atomic_requested || + dev->gpu->device_info->asic_family ==CHIP_HAWAII ) + flag |=CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT | +CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT ; + +/* GPU only creates direct links so apply flags setting to all */ +list_for_each_entry (link, &dev->io_link_props, list) { + link->flags = flag; + cpu_dev =kfd_topology_device_by_proximity_domain ( + link->node_to); +if (cpu_dev) { +list_for_each_entry (cpu_link, + &cpu_dev->io_link_props, list) +if (cpu_link->node_to == link->node_from) + cpu_link->flags = cpu_flag; + } + } }int kfd_topology_add_device (struct kfd_dev *gpu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/9 drm/amdkfd: KFD doesn't support TONGA SRIOV
In reply to a message not in the archiveFrom: Emily Deng <[email protected]>
KFD module doesn't support TONGA SRIOV, if init KFD module in TONGA SRIOV environment, it will let compute ring IB test fail.
--- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +0 -16
@@ -118,21 +118,6 @@ static const struct kfd_device_info tonga_device_info = { .num_sdma_engines = 2, }; -static const struct kfd_device_info tonga_vf_device_info = { - .asic_family =CHIP_TONGA , - .max_pasid_bits =16 , - .max_no_of_hqd =24 , - .doorbell_size =4 , - .ih_ring_entry_size =4 *sizeof (uint32_t ), - .event_interrupt_class = &event_interrupt_class_cik, - .num_of_watch_points =4 , - .mqd_size_aligned =MQD_SIZE_ALIGNED , - .supports_cwsr = false, - .needs_iommu_device = false, - .needs_pci_atomics = false, - .num_sdma_engines =2 , -}; -static const struct kfd_device_info fiji_device_info = { .asic_family =CHIP_FIJI , .max_pasid_bits =16 ,
@@ -293,7 +278,6 @@ static const struct kfd_deviceid supported_devices[] = { { 0x6928, &tonga_device_info }, /* Tonga */ { 0x6929, &tonga_device_info }, /* Tonga */ { 0x692B, &tonga_device_info }, /* Tonga */ - { 0x692F, &tonga_vf_device_info }, /* Tonga vf */ { 0x6938, &tonga_device_info }, /* Tonga */ { 0x6939, &tonga_device_info }, /* Tonga */ { 0x7300, &fiji_device_info }, /* Fiji */
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/9 drm/amdgpu: Enable BAD_OPCODE intr for gfx8
In reply to a message not in the archiveFrom: Harish Kasiviswanathan <[email protected]>
This enables KFD_EVENT_TYPE_HW_EXCEPTION notifications to user mode in response to bad opcodes in a CP queue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +2 -1
@@ -282,7 +282,8 @@ static int kgd_init_interrupts(struct kgd_dev *kgd, uint32_t pipe_id)lock_srbm (kgd, mec, pipe,0 ,0 ); -WREG32 (mmCPC_INT_CNTL,CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK ); +WREG32 (mmCPC_INT_CNTL,CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK | +CP_INT_CNTL_RING0__OPCODE_ERROR_INT_ENABLE_MASK );unlock_srbm (kgd);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/9 drm/amdkfd: Report SDMA firmware version in the topology
In reply to a message not in the archiveAlso save the version in struct kfd_dev so we only need to query it once.
--- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 4 ++++ drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +4 -0
@@ -405,6 +405,10 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, {unsigned int size; + kfd->mec_fw_version = kfd->kfd2kgd->get_fw_version (kfd->kgd, +KGD_ENGINE_MEC1 ); + kfd->sdma_fw_version = kfd->kfd2kgd->get_fw_version (kfd->kgd, +KGD_ENGINE_SDMA1 ); kfd->shared_resources = *gpu_resources; kfd->vm_info.first_vmid_kfd =ffs (gpu_resources->compute_vmid_bitmap)-1 ;
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4 -0
@@ -247,6 +247,10 @@ struct kfd_dev {/* Debug manager */ struct kfd_dbgmgr *dbgmgr; +/* Firmware versions */ +uint16_t mec_fw_version; +uint16_t sdma_fw_version; +/* Maximum process number mapped to HW scheduler */ unsigned int max_proc_per_quantum;
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +3 -3
@@ -480,11 +480,11 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr, (unsigned long long int) 0);sysfs_show_32bit_prop (buffer,"fw_version" , - dev->gpu->kfd2kgd->get_fw_version ( - dev->gpu->kgd, -KGD_ENGINE_MEC1 )); + dev->gpu->mec_fw_version);sysfs_show_32bit_prop (buffer,"capability" , dev->node_props.capability); +sysfs_show_32bit_prop (buffer,"sdma_fw_version" , + dev->gpu->sdma_fw_version); } return sysfs_show_32bit_prop(buffer, "max_engine_clk_ccompute",
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/9 drm/amdkfd: Add wavefront context save state retrieval ioctl
In reply to a message not in the archiveFrom: Jay Cornwall <[email protected]>
Wavefront context save data is of interest to userspace clients for debugging static wavefront state. The MQD contains two parameters required to parse the control stack and the control stack itself is kept in the MQD from gfx9 onwards.
Add an ioctl to fetch the context save area and control stack offsets and to copy the control stack to a userspace address if it is kept in the MQD.
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 21 ++++++++++++ .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 37 ++++++++++++++++++++++ .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.h | 8 +++++ drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | 8 +++++ drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 23 ++++++++++++++ drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 23 ++++++++++++++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 +++ .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 22 +++++++++++++ include/uapi/linux/kfd_ioctl.h | 13 +++++++- 9 files changed, 159 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +21 -0
@@ -447,6 +447,24 @@ static int kfd_ioctl_set_cu_mask(struct file *filp, struct kfd_process *p,return retval; } +static int kfd_ioctl_get_queue_wave_state (struct file *filep, +struct kfd_process *p,void *data) +{ +struct kfd_ioctl_get_queue_wave_state_args *args = data; +int r; + +mutex_lock (&p->mutex); + + r =pqm_get_wave_state (&p->pqm, args->queue_id, + (void __user *)args->ctl_stack_address, + &args->ctl_stack_used_size, + &args->save_area_used_size); + +mutex_unlock (&p->mutex); + +return r; +} +static int kfd_ioctl_set_memory_policy (struct file *filep,struct kfd_process *p,void *data) {
@@ -1615,6 +1633,9 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {AMDKFD_IOCTL_DEF (AMDKFD_IOC_SET_CU_MASK , kfd_ioctl_set_cu_mask,0 ), +AMDKFD_IOCTL_DEF (AMDKFD_IOC_GET_QUEUE_WAVE_STATE , + kfd_ioctl_get_queue_wave_state, 0) + };#define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +37 -0
@@ -1528,6 +1528,41 @@ static int process_termination_nocpsch(struct device_queue_manager *dqm,return retval; } +static int get_wave_state (struct device_queue_manager *dqm, +struct queue *q, +void __user *ctl_stack, +u32 *ctl_stack_used_size, +u32 *save_area_used_size) +{ +struct mqd_manager *mqd; +int r; + +dqm_lock (dqm); + +if (q->properties.type !=KFD_QUEUE_TYPE_COMPUTE || + q->properties.is_active || !q->device->cwsr_enabled) { + r = -EINVAL ; + goto dqm_unlock; + } + + mqd = dqm->ops.get_mqd_manager (dqm,KFD_MQD_TYPE_COMPUTE ); +if (!mqd) { + r = -ENOMEM ; + goto dqm_unlock; + } + +if (!mqd->get_wave_state) { + r = -EINVAL ; + goto dqm_unlock; + } + + r = mqd->get_wave_state (mqd, q->mqd, ctl_stack, ctl_stack_used_size, + save_area_used_size); + +dqm_unlock: +dqm_unlock (dqm); +return r; +}static int process_termination_cpsch (struct device_queue_manager *dqm,struct qcm_process_device *qpd)
@@ -1649,6 +1684,7 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) dqm->ops.process_termination = process_termination_cpsch; dqm->ops.evict_process_queues = evict_process_queues_cpsch; dqm->ops.restore_process_queues = restore_process_queues_cpsch; + dqm->ops.get_wave_state = get_wave_state;break ;case KFD_SCHED_POLICY_NO_HWS :/* initialize dqm for no cp scheduling */
@@ -1668,6 +1704,7 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) dqm->ops.evict_process_queues = evict_process_queues_nocpsch; dqm->ops.restore_process_queues = restore_process_queues_nocpsch; + dqm->ops.get_wave_state = get_wave_state;break ;default :pr_err ("Invalid scheduling policy %d\n" , dqm->sched_policy);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +8 -0
@@ -82,6 +82,8 @@ struct device_process_node {* * @restore_process_queues: Restore all evicted queues queues of a process * +* @get_wave_state: Retrieves context save state and optionally copies the +* control stack, if kept in the MQD, to the given userspace address. */ struct device_queue_manager_ops {
@@ -137,6 +139,12 @@ struct device_queue_manager_ops { struct qcm_process_device *qpd);int (*restore_process_queues)(struct device_queue_manager *dqm,struct qcm_process_device *qpd); + +int (*get_wave_state)(struct device_queue_manager *dqm, +struct queue *q, +void __user *ctl_stack, +u32 *ctl_stack_used_size, +u32 *save_area_used_size); };struct device_queue_manager_asic_ops {
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +8 -0
@@ -43,6 +43,9 @@* * @is_occupied: Checks if the relevant HQD slot is occupied. * +* @get_wave_state: Retrieves context save state and optionally copies the +* control stack, if kept in the MQD, to the given userspace address. +* * @mqd_mutex: Mqd manager mutex. * * @dev: The kfd device structure coupled with this module.
@@ -85,6 +88,11 @@ struct mqd_manager { uint64_t queue_address, uint32_t pipe_id, uint32_t queue_id); +int (*get_wave_state)(struct mqd_manager *mm,void *mqd, +void __user *ctl_stack, +u32 *ctl_stack_used_size, +u32 *save_area_used_size); +#if defined(CONFIG_DEBUG_FS )int (*debugfs_show_mqd)(struct seq_file *m,void *data);#endif
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +23 -0
@@ -266,6 +266,28 @@ static bool is_occupied(struct mqd_manager *mm, void *mqd, pipe_id, queue_id); } +static int get_wave_state (struct mqd_manager *mm,void *mqd, +void __user *ctl_stack, +u32 *ctl_stack_used_size, +u32 *save_area_used_size) +{ +struct v9_mqd *m; + +/* Control stack is located one page after MQD. */ +void *mqd_ctl_stack = (void *)((uintptr_t )mqd +PAGE_SIZE ); + + m =get_mqd (mqd); + + *ctl_stack_used_size = m->cp_hqd_cntl_stack_size - + m->cp_hqd_cntl_stack_offset; + *save_area_used_size = m->cp_hqd_wg_state_offset; + +if (copy_to_user (ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size)) +return -EFAULT ; + +return 0 ; +} +static int init_mqd_hiq (struct mqd_manager *mm,void **mqd,struct kfd_mem_obj **mqd_mem_obj,uint64_t *gart_addr,struct queue_properties *q)
@@ -435,6 +457,7 @@ struct mqd_manager *mqd_manager_init_v9(enum KFD_MQD_TYPE type, mqd->update_mqd = update_mqd; mqd->destroy_mqd = destroy_mqd; mqd->is_occupied = is_occupied; + mqd->get_wave_state = get_wave_state;#if defined(CONFIG_DEBUG_FS ) mqd->debugfs_show_mqd = debugfs_show_mqd;#endif
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +23 -0
@@ -269,6 +269,28 @@ static bool is_occupied(struct mqd_manager *mm, void *mqd, pipe_id, queue_id); } +static int get_wave_state (struct mqd_manager *mm,void *mqd, +void __user *ctl_stack, +u32 *ctl_stack_used_size, +u32 *save_area_used_size) +{ +struct vi_mqd *m; + + m =get_mqd (mqd); + + *ctl_stack_used_size = m->cp_hqd_cntl_stack_size - + m->cp_hqd_cntl_stack_offset; + *save_area_used_size = m->cp_hqd_wg_state_offset - + m->cp_hqd_cntl_stack_size; + +/* Control stack is not copied to user mode for GFXv8 because +* it's part of the context save area that is already +* accessible to user mode +*/ + +return 0 ; +} +static int init_mqd_hiq (struct mqd_manager *mm,void **mqd,struct kfd_mem_obj **mqd_mem_obj,uint64_t *gart_addr,struct queue_properties *q)
@@ -436,6 +458,7 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type, mqd->update_mqd = update_mqd; mqd->destroy_mqd = destroy_mqd; mqd->is_occupied = is_occupied; + mqd->get_wave_state = get_wave_state;#if defined(CONFIG_DEBUG_FS ) mqd->debugfs_show_mqd = debugfs_show_mqd;#endif
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +5 -0
@@ -858,6 +858,11 @@ int pqm_set_cu_mask(struct process_queue_manager *pqm, unsigned int qid, struct queue_properties *p);struct kernel_queue *pqm_get_kernel_queue (struct process_queue_manager *pqm,unsigned int qid); +int pqm_get_wave_state (struct process_queue_manager *pqm, +unsigned int qid, +void __user *ctl_stack, +u32 *ctl_stack_used_size, +u32 *save_area_used_size); int amdkfd_fence_wait_timeout(unsigned int *fence_addr, unsigned int fence_value,
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +22 -0
@@ -408,6 +408,28 @@ struct kernel_queue *pqm_get_kernel_queue(return NULL ; } +int pqm_get_wave_state (struct process_queue_manager *pqm, +unsigned int qid, +void __user *ctl_stack, +u32 *ctl_stack_used_size, +u32 *save_area_used_size) +{ +struct process_queue_node *pqn; + + pqn =get_queue_by_qid (pqm, qid); +if (!pqn) { +pr_debug ("amdkfd: No queue %d exists for operation\n" , + qid); +return -EFAULT ; + } + +return pqn->q->device->dqm->ops.get_wave_state (pqn->q->device->dqm, + pqn->q, + ctl_stack, + ctl_stack_used_size, + save_area_used_size); +} +#if defined(CONFIG_DEBUG_FS )int pqm_debugfs_mqds (struct seq_file *m,void *data)
include/uapi/linux/kfd_ioctl.h +12 -1
@@ -82,6 +82,14 @@ struct kfd_ioctl_set_cu_mask_args {__u64 cu_mask_ptr;/* to KFD */ }; +struct kfd_ioctl_get_queue_wave_state_args { +uint64_t ctl_stack_address;/* to KFD */ +uint32_t ctl_stack_used_size;/* from KFD */ +uint32_t save_area_used_size;/* from KFD */ +uint32_t queue_id;/* to KFD */ +uint32_t pad; +}; +/* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */ #define KFD_IOC_CACHE_POLICY_COHERENT 0#define KFD_IOC_CACHE_POLICY_NONCOHERENT 1
@@ -475,7 +483,10 @@ struct kfd_ioctl_unmap_memory_from_gpu_args {#define AMDKFD_IOC_SET_CU_MASK \ AMDKFD_IOW(0x1A, struct kfd_ioctl_set_cu_mask_args) +#define AMDKFD_IOC_GET_QUEUE_WAVE_STATE \ + AMDKFD_IOWR(0x1B, struct kfd_ioctl_get_queue_wave_state_args) +#define AMDKFD_COMMAND_START 0x01 -#define AMDKFD_COMMAND_END 0x1B +#define AMDKFD_COMMAND_END 0x1C#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/9 drm/amdgpu: remove unnecessary forward declaration
In reply to a message not in the archivestruct vi_sdma_mqd is defined in vi_structs.h.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +0 -2
@@ -45,8 +45,6 @@ enum hqd_dequeue_request_type { RESET_WAVES }; -struct vi_sdma_mqd ; -/* * Register access functions */
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
Acked-byQuoted 28 lines · Felix Kuehling
This patch series is based on amd-staging-drm-next.
Patches 1-3 are important fixes that would be good to be included in drm-fixes for 4.19.
Patches 3-8 are small feature enhancements.
Patch 9 is random cleanup.
I'll send a separate patch series that adds Vega20 support to KFD on top of this.
Amber Lin (1):
drm/amdgpu: Fix SDMA HQD destroy error ongfx_v7Emily Deng (1):
drm/amdkfd: KFD doesn't support TONGA SRIOVEric Huang (1):
drm/amdkfd: reflect atomic support in IO link propertiesFelix Kuehling (2):
drm/amdkfd: Report SDMA firmware version in the topology drm/amdgpu: remove unnecessary forward declarationHarish Kasiviswanathan (1):
drm/amdgpu: EnableBAD_OPCODEintr for gfx8
Quoted 7 lines
Jay Cornwall (1):
drm/amdkfd: Add wavefront context save state retrieval ioctlYong Zhao (2):
drm/amdkfd: Change the control stack MTYPE from UC to NC on GFX9 drm/amdkfd: Fix ATS capablity was not reported correctly on some APUs
Series is:
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 5 +- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 21 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 35 +++++------- .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 37 +++++++++++++ .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.h | 8 +++ drivers/gpu/drm/amd/amdkfd/kfd_iommu.c | 13 ++++- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | 8 +++ drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 25 ++++++++- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 23 ++++++++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 12 ++++ .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 22 ++++++++ drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 64 +++++++++++++++++----- drivers/gpu/drm/amd/include/kgd_kfd_interface.h | 2 +- include/uapi/linux/kfd_ioctl.h | 13 ++++- 17 files changed, 251 insertions(+), 47 deletions(-)
Quoted 7 lines
--
2.7.4_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx