diff options
| -rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 6 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_process.c | 9 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 8 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/include/kgd_kfd_interface.h | 15 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_kfd.c | 53 |
6 files changed, 85 insertions, 10 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 4f7b275f2f7b..7d4974b83af7 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | |||
| @@ -121,13 +121,9 @@ static int kfd_open(struct inode *inode, struct file *filep) | |||
| 121 | if (IS_ERR(process)) | 121 | if (IS_ERR(process)) |
| 122 | return PTR_ERR(process); | 122 | return PTR_ERR(process); |
| 123 | 123 | ||
| 124 | process->is_32bit_user_mode = is_32bit_user_mode; | ||
| 125 | |||
| 126 | dev_dbg(kfd_device, "process %d opened, compat mode (32 bit) - %d\n", | 124 | dev_dbg(kfd_device, "process %d opened, compat mode (32 bit) - %d\n", |
| 127 | process->pasid, process->is_32bit_user_mode); | 125 | process->pasid, process->is_32bit_user_mode); |
| 128 | 126 | ||
| 129 | kfd_init_apertures(process); | ||
| 130 | |||
| 131 | return 0; | 127 | return 0; |
| 132 | } | 128 | } |
| 133 | 129 | ||
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c index 66df4da01c29..e64aa99e5e41 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | |||
| @@ -299,13 +299,13 @@ int kfd_init_apertures(struct kfd_process *process) | |||
| 299 | struct kfd_dev *dev; | 299 | struct kfd_dev *dev; |
| 300 | struct kfd_process_device *pdd; | 300 | struct kfd_process_device *pdd; |
| 301 | 301 | ||
| 302 | mutex_lock(&process->mutex); | ||
| 303 | |||
| 304 | /*Iterating over all devices*/ | 302 | /*Iterating over all devices*/ |
| 305 | while ((dev = kfd_topology_enum_kfd_devices(id)) != NULL && | 303 | while ((dev = kfd_topology_enum_kfd_devices(id)) != NULL && |
| 306 | id < NUM_OF_SUPPORTED_GPUS) { | 304 | id < NUM_OF_SUPPORTED_GPUS) { |
| 307 | 305 | ||
| 308 | pdd = kfd_get_process_device_data(dev, process, 1); | 306 | pdd = kfd_get_process_device_data(dev, process, 1); |
| 307 | if (!pdd) | ||
| 308 | return -1; | ||
| 309 | 309 | ||
| 310 | /* | 310 | /* |
| 311 | * For 64 bit process aperture will be statically reserved in | 311 | * For 64 bit process aperture will be statically reserved in |
| @@ -348,8 +348,6 @@ int kfd_init_apertures(struct kfd_process *process) | |||
| 348 | id++; | 348 | id++; |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | mutex_unlock(&process->mutex); | ||
| 352 | |||
| 353 | return 0; | 351 | return 0; |
| 354 | } | 352 | } |
| 355 | 353 | ||
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index b85eb0b830b4..3c76ef05cbcf 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c | |||
| @@ -26,6 +26,8 @@ | |||
| 26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
| 27 | #include <linux/amd-iommu.h> | 27 | #include <linux/amd-iommu.h> |
| 28 | #include <linux/notifier.h> | 28 | #include <linux/notifier.h> |
| 29 | #include <linux/compat.h> | ||
| 30 | |||
| 29 | struct mm_struct; | 31 | struct mm_struct; |
| 30 | 32 | ||
| 31 | #include "kfd_priv.h" | 33 | #include "kfd_priv.h" |
| @@ -285,8 +287,15 @@ static struct kfd_process *create_process(const struct task_struct *thread) | |||
| 285 | if (err != 0) | 287 | if (err != 0) |
| 286 | goto err_process_pqm_init; | 288 | goto err_process_pqm_init; |
| 287 | 289 | ||
| 290 | /* init process apertures*/ | ||
| 291 | process->is_32bit_user_mode = is_compat_task(); | ||
| 292 | if (kfd_init_apertures(process) != 0) | ||
| 293 | goto err_init_apretures; | ||
| 294 | |||
| 288 | return process; | 295 | return process; |
| 289 | 296 | ||
| 297 | err_init_apretures: | ||
| 298 | pqm_uninit(&process->pqm); | ||
| 290 | err_process_pqm_init: | 299 | err_process_pqm_init: |
| 291 | hash_del_rcu(&process->kfd_processes); | 300 | hash_del_rcu(&process->kfd_processes); |
| 292 | synchronize_rcu(); | 301 | synchronize_rcu(); |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c index 5733e2859e8a..b11792d7e70e 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c | |||
| @@ -700,8 +700,6 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr, | |||
| 700 | dev->node_props.simd_per_cu); | 700 | dev->node_props.simd_per_cu); |
| 701 | sysfs_show_32bit_prop(buffer, "max_slots_scratch_cu", | 701 | sysfs_show_32bit_prop(buffer, "max_slots_scratch_cu", |
| 702 | dev->node_props.max_slots_scratch_cu); | 702 | dev->node_props.max_slots_scratch_cu); |
| 703 | sysfs_show_32bit_prop(buffer, "engine_id", | ||
| 704 | dev->node_props.engine_id); | ||
| 705 | sysfs_show_32bit_prop(buffer, "vendor_id", | 703 | sysfs_show_32bit_prop(buffer, "vendor_id", |
| 706 | dev->node_props.vendor_id); | 704 | dev->node_props.vendor_id); |
| 707 | sysfs_show_32bit_prop(buffer, "device_id", | 705 | sysfs_show_32bit_prop(buffer, "device_id", |
| @@ -715,6 +713,12 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr, | |||
| 715 | dev->gpu->kgd)); | 713 | dev->gpu->kgd)); |
| 716 | sysfs_show_64bit_prop(buffer, "local_mem_size", | 714 | sysfs_show_64bit_prop(buffer, "local_mem_size", |
| 717 | kfd2kgd->get_vmem_size(dev->gpu->kgd)); | 715 | kfd2kgd->get_vmem_size(dev->gpu->kgd)); |
| 716 | |||
| 717 | sysfs_show_32bit_prop(buffer, "fw_version", | ||
| 718 | kfd2kgd->get_fw_version( | ||
| 719 | dev->gpu->kgd, | ||
| 720 | KGD_ENGINE_MEC1)); | ||
| 721 | |||
| 718 | } | 722 | } |
| 719 | 723 | ||
| 720 | ret = sysfs_show_32bit_prop(buffer, "max_engine_clk_ccompute", | 724 | ret = sysfs_show_32bit_prop(buffer, "max_engine_clk_ccompute", |
diff --git a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h index 9c729dd8dd50..47b551970a14 100644 --- a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h +++ b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h | |||
| @@ -45,6 +45,17 @@ enum kgd_memory_pool { | |||
| 45 | KGD_POOL_FRAMEBUFFER = 3, | 45 | KGD_POOL_FRAMEBUFFER = 3, |
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | enum kgd_engine_type { | ||
| 49 | KGD_ENGINE_PFP = 1, | ||
| 50 | KGD_ENGINE_ME, | ||
| 51 | KGD_ENGINE_CE, | ||
| 52 | KGD_ENGINE_MEC1, | ||
| 53 | KGD_ENGINE_MEC2, | ||
| 54 | KGD_ENGINE_RLC, | ||
| 55 | KGD_ENGINE_SDMA, | ||
| 56 | KGD_ENGINE_MAX | ||
| 57 | }; | ||
| 58 | |||
| 48 | struct kgd2kfd_shared_resources { | 59 | struct kgd2kfd_shared_resources { |
| 49 | /* Bit n == 1 means VMID n is available for KFD. */ | 60 | /* Bit n == 1 means VMID n is available for KFD. */ |
| 50 | unsigned int compute_vmid_bitmap; | 61 | unsigned int compute_vmid_bitmap; |
| @@ -137,6 +148,8 @@ struct kgd2kfd_calls { | |||
| 137 | * | 148 | * |
| 138 | * @hqd_destroy: Destructs and preempts the queue assigned to that hqd slot. | 149 | * @hqd_destroy: Destructs and preempts the queue assigned to that hqd slot. |
| 139 | * | 150 | * |
| 151 | * @get_fw_version: Returns FW versions from the header | ||
| 152 | * | ||
| 140 | * This structure contains function pointers to services that the kgd driver | 153 | * This structure contains function pointers to services that the kgd driver |
| 141 | * provides to amdkfd driver. | 154 | * provides to amdkfd driver. |
| 142 | * | 155 | * |
| @@ -176,6 +189,8 @@ struct kfd2kgd_calls { | |||
| 176 | int (*hqd_destroy)(struct kgd_dev *kgd, uint32_t reset_type, | 189 | int (*hqd_destroy)(struct kgd_dev *kgd, uint32_t reset_type, |
| 177 | unsigned int timeout, uint32_t pipe_id, | 190 | unsigned int timeout, uint32_t pipe_id, |
| 178 | uint32_t queue_id); | 191 | uint32_t queue_id); |
| 192 | uint16_t (*get_fw_version)(struct kgd_dev *kgd, | ||
| 193 | enum kgd_engine_type type); | ||
| 179 | }; | 194 | }; |
| 180 | 195 | ||
| 181 | bool kgd2kfd_init(unsigned interface_version, | 196 | bool kgd2kfd_init(unsigned interface_version, |
diff --git a/drivers/gpu/drm/radeon/radeon_kfd.c b/drivers/gpu/drm/radeon/radeon_kfd.c index 065d02068ec3..242fd8b1b221 100644 --- a/drivers/gpu/drm/radeon/radeon_kfd.c +++ b/drivers/gpu/drm/radeon/radeon_kfd.c | |||
| @@ -28,6 +28,8 @@ | |||
| 28 | #include "cikd.h" | 28 | #include "cikd.h" |
| 29 | #include "cik_reg.h" | 29 | #include "cik_reg.h" |
| 30 | #include "radeon_kfd.h" | 30 | #include "radeon_kfd.h" |
| 31 | #include "radeon_ucode.h" | ||
| 32 | #include <linux/firmware.h> | ||
| 31 | 33 | ||
| 32 | #define CIK_PIPE_PER_MEC (4) | 34 | #define CIK_PIPE_PER_MEC (4) |
| 33 | 35 | ||
| @@ -49,6 +51,7 @@ static uint64_t get_vmem_size(struct kgd_dev *kgd); | |||
| 49 | static uint64_t get_gpu_clock_counter(struct kgd_dev *kgd); | 51 | static uint64_t get_gpu_clock_counter(struct kgd_dev *kgd); |
| 50 | 52 | ||
| 51 | static uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd); | 53 | static uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd); |
| 54 | static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type); | ||
| 52 | 55 | ||
| 53 | /* | 56 | /* |
| 54 | * Register access functions | 57 | * Register access functions |
| @@ -91,6 +94,7 @@ static const struct kfd2kgd_calls kfd2kgd = { | |||
| 91 | .hqd_load = kgd_hqd_load, | 94 | .hqd_load = kgd_hqd_load, |
| 92 | .hqd_is_occupies = kgd_hqd_is_occupies, | 95 | .hqd_is_occupies = kgd_hqd_is_occupies, |
| 93 | .hqd_destroy = kgd_hqd_destroy, | 96 | .hqd_destroy = kgd_hqd_destroy, |
| 97 | .get_fw_version = get_fw_version | ||
| 94 | }; | 98 | }; |
| 95 | 99 | ||
| 96 | static const struct kgd2kfd_calls *kgd2kfd; | 100 | static const struct kgd2kfd_calls *kgd2kfd; |
| @@ -561,3 +565,52 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, | |||
| 561 | release_queue(kgd); | 565 | release_queue(kgd); |
| 562 | return 0; | 566 | return 0; |
| 563 | } | 567 | } |
| 568 | |||
| 569 | static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type) | ||
| 570 | { | ||
| 571 | struct radeon_device *rdev = (struct radeon_device *) kgd; | ||
| 572 | const union radeon_firmware_header *hdr; | ||
| 573 | |||
| 574 | BUG_ON(kgd == NULL || rdev->mec_fw == NULL); | ||
| 575 | |||
| 576 | switch (type) { | ||
| 577 | case KGD_ENGINE_PFP: | ||
| 578 | hdr = (const union radeon_firmware_header *) rdev->pfp_fw->data; | ||
| 579 | break; | ||
| 580 | |||
| 581 | case KGD_ENGINE_ME: | ||
| 582 | hdr = (const union radeon_firmware_header *) rdev->me_fw->data; | ||
| 583 | break; | ||
| 584 | |||
| 585 | case KGD_ENGINE_CE: | ||
| 586 | hdr = (const union radeon_firmware_header *) rdev->ce_fw->data; | ||
| 587 | break; | ||
| 588 | |||
| 589 | case KGD_ENGINE_MEC1: | ||
| 590 | hdr = (const union radeon_firmware_header *) rdev->mec_fw->data; | ||
| 591 | break; | ||
| 592 | |||
| 593 | case KGD_ENGINE_MEC2: | ||
| 594 | hdr = (const union radeon_firmware_header *) | ||
| 595 | rdev->mec2_fw->data; | ||
| 596 | break; | ||
| 597 | |||
| 598 | case KGD_ENGINE_RLC: | ||
| 599 | hdr = (const union radeon_firmware_header *) rdev->rlc_fw->data; | ||
| 600 | break; | ||
| 601 | |||
| 602 | case KGD_ENGINE_SDMA: | ||
| 603 | hdr = (const union radeon_firmware_header *) | ||
| 604 | rdev->sdma_fw->data; | ||
| 605 | break; | ||
| 606 | |||
| 607 | default: | ||
| 608 | return 0; | ||
| 609 | } | ||
| 610 | |||
| 611 | if (hdr == NULL) | ||
| 612 | return 0; | ||
| 613 | |||
| 614 | /* Only 12 bit in use*/ | ||
| 615 | return hdr->common.ucode_version; | ||
| 616 | } | ||
