From 010b82e754e20b47bfaf6202c5b696f4b2849713 Mon Sep 17 00:00:00 2001 From: Oded Gabbay Date: Thu, 22 Jan 2015 11:09:27 +0200 Subject: [PATCH 1/6] drm/amdkfd: Remove negative check of uint variable Signed-off-by: Oded Gabbay Reviewed-by: Jammy Zhou --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index a5c69e96ba6f..23a1e95f32c3 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -587,7 +587,7 @@ static int allocate_sdma_queue(struct device_queue_manager *dqm, static void deallocate_sdma_queue(struct device_queue_manager *dqm, unsigned int sdma_queue_id) { - if (sdma_queue_id < 0 || sdma_queue_id >= CIK_SDMA_QUEUES) + if (sdma_queue_id >= CIK_SDMA_QUEUES) return; set_bit(sdma_queue_id, (unsigned long *)&dqm->sdma_bitmap); } From 300dec9578f77111d5fe0c236681b9e25a00cee7 Mon Sep 17 00:00:00 2001 From: Oded Gabbay Date: Thu, 22 Jan 2015 11:15:51 +0200 Subject: [PATCH 2/6] drm/amdkfd: Add break at the end of case Signed-off-by: Oded Gabbay Reviewed-by: Jammy Zhou --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 23a1e95f32c3..85387c8b296c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -1114,8 +1114,11 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev) switch (dev->device_info->asic_family) { case CHIP_CARRIZO: device_queue_manager_init_vi(&dqm->ops_asic_specific); + break; + case CHIP_KAVERI: device_queue_manager_init_cik(&dqm->ops_asic_specific); + break; } if (dqm->ops.initialize(dqm) != 0) { diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c index c04b1ac60bd9..e415a2a9207e 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c @@ -288,8 +288,11 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev, switch (dev->device_info->asic_family) { case CHIP_CARRIZO: kernel_queue_init_vi(&kq->ops_asic_specific); + break; + case CHIP_KAVERI: kernel_queue_init_cik(&kq->ops_asic_specific); + break; } if (kq->ops.initialize(kq, dev, type, KFD_KERNEL_QUEUE_SIZE) == false) { From 7113cd652969fe1a59a9560e700000633df6a3e1 Mon Sep 17 00:00:00 2001 From: Oded Gabbay Date: Thu, 22 Jan 2015 11:40:06 +0200 Subject: [PATCH 3/6] drm/amdkfd: Handle case of invalid queue type This patch handles a case where amdkfd tries to destroy a queue but the queue type is invalid. This case occurs in non-HWS path. Signed-off-by: Oded Gabbay Reviewed-by: Jammy Zhou --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 85387c8b296c..99e2dbbb4862 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -301,6 +301,11 @@ static int destroy_queue_nocpsch(struct device_queue_manager *dqm, } dqm->sdma_queue_count--; deallocate_sdma_queue(dqm, q->sdma_id); + } else { + pr_debug("q->properties.type is invalid (%d)\n", + q->properties.type); + retval = -EINVAL; + goto out; } retval = mqd->destroy_mqd(mqd, q->mqd, From 0b3674ae1c8b9539dde694a70391e974aedde8c2 Mon Sep 17 00:00:00 2001 From: Oded Gabbay Date: Thu, 22 Jan 2015 13:42:28 +0200 Subject: [PATCH 4/6] drm/amdkfd: Fix sparse errors Signed-off-by: Oded Gabbay Reviewed-by: Alex Deucher --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 16 +++++------ .../drm/amd/amdkfd/kfd_device_queue_manager.c | 28 ++----------------- .../drm/amd/amdkfd/kfd_device_queue_manager.h | 20 +++++++++++-- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 732087dcac91..5c50aa8a8908 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -141,8 +141,6 @@ static int kfd_ioctl_get_version(struct file *filep, struct kfd_process *p, static int set_queue_properties_from_user(struct queue_properties *q_properties, struct kfd_ioctl_create_queue_args *args) { - void *tmp; - if (args->queue_percentage > KFD_MAX_QUEUE_PERCENTAGE) { pr_err("kfd: queue percentage must be between 0 to KFD_MAX_QUEUE_PERCENTAGE\n"); return -EINVAL; @@ -180,16 +178,18 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties, return -EFAULT; } - tmp = (void *)(uintptr_t)args->eop_buffer_address; - if (tmp != NULL && - !access_ok(VERIFY_WRITE, tmp, sizeof(uint32_t))) { + if (args->eop_buffer_address && + !access_ok(VERIFY_WRITE, + (const void __user *) args->eop_buffer_address, + sizeof(uint32_t))) { pr_debug("kfd: can't access eop buffer"); return -EFAULT; } - tmp = (void *)(uintptr_t)args->ctx_save_restore_address; - if (tmp != NULL && - !access_ok(VERIFY_WRITE, tmp, sizeof(uint32_t))) { + if (args->ctx_save_restore_address && + !access_ok(VERIFY_WRITE, + (const void __user *) args->ctx_save_restore_address, + sizeof(uint32_t))) { pr_debug("kfd: can't access ctx save restore buffer"); return -EFAULT; } diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 99e2dbbb4862..b189f9791c90 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -62,12 +62,6 @@ enum KFD_MQD_TYPE get_mqd_type_from_queue_type(enum kfd_queue_type type) return KFD_MQD_TYPE_CP; } -inline unsigned int get_pipes_num(struct device_queue_manager *dqm) -{ - BUG_ON(!dqm || !dqm->dev); - return dqm->dev->shared_resources.compute_pipe_count; -} - static inline unsigned int get_first_pipe(struct device_queue_manager *dqm) { BUG_ON(!dqm); @@ -79,25 +73,6 @@ static inline unsigned int get_pipes_num_cpsch(void) return PIPE_PER_ME_CP_SCHEDULING; } -inline unsigned int -get_sh_mem_bases_nybble_64(struct kfd_process_device *pdd) -{ - uint32_t nybble; - - nybble = (pdd->lds_base >> 60) & 0x0E; - - return nybble; -} - -inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *pdd) -{ - unsigned int shared_base; - - shared_base = (pdd->lds_base >> 16) & 0xFF; - - return shared_base; -} - void program_sh_mem_settings(struct device_queue_manager *dqm, struct qcm_process_device *qpd) { @@ -336,7 +311,8 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q) BUG_ON(!dqm || !q || !q->mqd); mutex_lock(&dqm->lock); - mqd = dqm->ops.get_mqd_manager(dqm, q->properties.type); + mqd = dqm->ops.get_mqd_manager(dqm, + get_mqd_type_from_queue_type(q->properties.type)); if (mqd == NULL) { mutex_unlock(&dqm->lock); return -ENOMEM; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h index 19347956eeb9..e7b17b28330e 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h @@ -160,10 +160,24 @@ void device_queue_manager_init_cik(struct device_queue_manager_ops *ops); void device_queue_manager_init_vi(struct device_queue_manager_ops *ops); void program_sh_mem_settings(struct device_queue_manager *dqm, struct qcm_process_device *qpd); -inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *qpd); -inline unsigned int get_sh_mem_bases_nybble_64(struct kfd_process_device *pdd); int init_pipelines(struct device_queue_manager *dqm, unsigned int pipes_num, unsigned int first_pipe); -inline unsigned int get_pipes_num(struct device_queue_manager *dqm); + +extern inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *pdd) +{ + return (pdd->lds_base >> 16) & 0xFF; +} + +extern inline unsigned int +get_sh_mem_bases_nybble_64(struct kfd_process_device *pdd) +{ + return (pdd->lds_base >> 60) & 0x0E; +} + +extern inline unsigned int get_pipes_num(struct device_queue_manager *dqm) +{ + BUG_ON(!dqm || !dqm->dev); + return dqm->dev->shared_resources.compute_pipe_count; +} #endif /* KFD_DEVICE_QUEUE_MANAGER_H_ */ From 55e3ad34ce09805d08b238549b6c86fe90cf271d Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Wed, 21 Jan 2015 20:32:11 +0800 Subject: [PATCH 5/6] drm/radeon: cik_sdma_ctx_switch_enable() can be static drivers/gpu/drm/radeon/cik_sdma.c:293:6: sparse: symbol 'cik_sdma_ctx_switch_enable' was not declared. Should it be static? Signed-off-by: Fengguang Wu Signed-off-by: Oded Gabbay --- drivers/gpu/drm/radeon/cik_sdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/cik_sdma.c b/drivers/gpu/drm/radeon/cik_sdma.c index 479519c24a1f..7d2ff31c35a5 100644 --- a/drivers/gpu/drm/radeon/cik_sdma.c +++ b/drivers/gpu/drm/radeon/cik_sdma.c @@ -290,7 +290,7 @@ static void cik_sdma_rlc_stop(struct radeon_device *rdev) * * Halt or unhalt the async dma engines (CIK). */ -void cik_sdma_ctx_switch_enable(struct radeon_device *rdev, bool enable) +static void cik_sdma_ctx_switch_enable(struct radeon_device *rdev, bool enable) { uint32_t reg_offset, value; int i; From f9dcced8d49804081850f78b2336c83cf050eeab Mon Sep 17 00:00:00 2001 From: Oded Gabbay Date: Thu, 22 Jan 2015 14:57:52 +0200 Subject: [PATCH 6/6] drm/amdkfd: change amdkfd version to 0.7.1 Signed-off-by: Oded Gabbay --- drivers/gpu/drm/amd/amdkfd/kfd_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_module.c b/drivers/gpu/drm/amd/amdkfd/kfd_module.c index 14c4115c4ae1..ac5445415667 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_module.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_module.c @@ -29,10 +29,10 @@ #define KFD_DRIVER_AUTHOR "AMD Inc. and others" #define KFD_DRIVER_DESC "Standalone HSA driver for AMD's GPUs" -#define KFD_DRIVER_DATE "20141113" +#define KFD_DRIVER_DATE "20150122" #define KFD_DRIVER_MAJOR 0 #define KFD_DRIVER_MINOR 7 -#define KFD_DRIVER_PATCHLEVEL 0 +#define KFD_DRIVER_PATCHLEVEL 1 const struct kfd2kgd_calls *kfd2kgd; static const struct kgd2kfd_calls kgd2kfd = {