Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdkfd: Reuse CHIP_* from amdgpu v2

There are already CHIP_* definitions under amd_shared.h file on amdgpu
side, so KFD should reuse them rather than defining new ones.

Using enum for asic type requires default cases on switch statements
to prevent compiler warnings. WARN on unsupported ASICs. It should never
get there because KFD should not be initialized on unsupported devices.

v2: Replace BUG() with WARN and error return

Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>

authored by

Yong Zhao and committed by
Oded Gabbay
e596b903 44008d7a

+22 -12
+4
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
··· 1130 1130 case CHIP_KAVERI: 1131 1131 device_queue_manager_init_cik(&dqm->ops_asic_specific); 1132 1132 break; 1133 + default: 1134 + WARN(1, "Unexpected ASIC family %u", 1135 + dev->device_info->asic_family); 1136 + goto out_free; 1133 1137 } 1134 1138 1135 1139 if (!dqm->ops.initialize(dqm))
+12 -6
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
··· 303 303 case CHIP_KAVERI: 304 304 kernel_queue_init_cik(&kq->ops_asic_specific); 305 305 break; 306 + default: 307 + WARN(1, "Unexpected ASIC family %u", 308 + dev->device_info->asic_family); 309 + goto out_free; 306 310 } 307 311 308 - if (!kq->ops.initialize(kq, dev, type, KFD_KERNEL_QUEUE_SIZE)) { 309 - pr_err("Failed to init kernel queue\n"); 310 - kfree(kq); 311 - return NULL; 312 - } 313 - return kq; 312 + if (kq->ops.initialize(kq, dev, type, KFD_KERNEL_QUEUE_SIZE)) 313 + return kq; 314 + 315 + pr_err("Failed to init kernel queue\n"); 316 + 317 + out_free: 318 + kfree(kq); 319 + return NULL; 314 320 } 315 321 316 322 void kernel_queue_uninit(struct kernel_queue *kq)
+3
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
··· 31 31 return mqd_manager_init_cik(type, dev); 32 32 case CHIP_CARRIZO: 33 33 return mqd_manager_init_vi(type, dev); 34 + default: 35 + WARN(1, "Unexpected ASIC family %u", 36 + dev->device_info->asic_family); 34 37 } 35 38 36 39 return NULL;
+3 -6
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
··· 33 33 #include <linux/kfd_ioctl.h> 34 34 #include <kgd_kfd_interface.h> 35 35 36 + #include "amd_shared.h" 37 + 36 38 #define KFD_SYSFS_FILE_MODE 0444 37 39 38 40 #define KFD_MMAP_DOORBELL_MASK 0x8000000000000 ··· 114 112 cache_policy_noncoherent 115 113 }; 116 114 117 - enum asic_family_type { 118 - CHIP_KAVERI = 0, 119 - CHIP_CARRIZO 120 - }; 121 - 122 115 struct kfd_event_interrupt_class { 123 116 bool (*interrupt_isr)(struct kfd_dev *dev, 124 117 const uint32_t *ih_ring_entry); ··· 122 125 }; 123 126 124 127 struct kfd_device_info { 125 - unsigned int asic_family; 128 + enum amd_asic_type asic_family; 126 129 const struct kfd_event_interrupt_class *event_interrupt_class; 127 130 unsigned int max_pasid_bits; 128 131 unsigned int max_no_of_hqd;