Skip to content

Use workqueue for device init in amdkfd

Oded Gabbay dri-devel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 16 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3amdkfd: Don't clear *kfd2kgd on kfd_module_initdrivers/gpu/drm/amd/amdkfd/kfd_module.c+2 -316 replies
2/3amdkfd: Track when amdkfd init is completedrivers/gpu/drm/amd/amdkfd/kfd_module.c drivers/gpu/drm/amd/amdkfd/kfd_priv.h+11 -00 replies
3/3amdkfd: Use workqueue for GPU initdrivers/gpu/drm/amd/amdkfd/kfd_device.c drivers/gpu/drm/amd/amdkfd/kfd_priv.h+70 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] Use workqueue for device init in amdkfd

This small patch-set, together with amd_iommu_v2 patch at
http://lists.linuxfoundation.org/pipermail/iommu/2014-December/011435.html
was created to solve the bug described at
https://bugzilla.kernel.org/show_bug.cgi?id=89661 (Kernel panic when trying use amdkfd driver on Kaveri).

That bug appears only when radeon, amdkfd and amd_iommu_v2 are compiled inside the kernel (not as modules). In that case, the correct loading order, as determined by the exported symbol used by each driver, is not enforced anymore and the kernel loads them based on who was linked first. That makes radeon load first, amdkfd second and amd_iommu_v2 third.

Because the initialization of a device in amdkfd is initiated by radeon, and can only be completed if amdkfd and amd_iommu_v2 were loaded and initialized, then in the case mentioned above, this initalization fails and there is a kernel panic as some pointers are not initialized but used nontheless.

To solve this problem, amdkfd now checks if both it and amd_iommu_v2 were loaded before trying to initalize the device. If not, it enqueue the work using a workqueue, which allows radeon to continue its device initialization (because radeon calls amdkfd to initalize the device). The work function schedules itself as long as amdkfd and amd_iommu_v2 were not initialized.

Detection of when the modules finished their initialization is done by a simple variable that is initialized to 1 when the module_init function is completed successfully. Other methods for detection were checked, e.g. module_is_live() and MODULE_SOFTDEP(), but they were proved not to work when all modules are compiled in the kernel image (which is the problematic scenario to begin with).

Oded

Oded Gabbay (3):
amdkfd: Don't clear *kfd2kgd on kfd_module_init
amdkfd: Track when amdkfd init is complete
amdkfd: Use workqueue for GPU init

 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 72 +++++++++++++++++++++++++++++++--
 drivers/gpu/drm/amd/amdkfd/kfd_module.c | 14 +++++--
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h   |  4 ++
 3 files changed, 83 insertions(+), 7 deletions(-)
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel