diff options
| -rw-r--r-- | drivers/misc/habanalabs/command_submission.c | 6 | ||||
| -rw-r--r-- | drivers/misc/habanalabs/device.c | 1 | ||||
| -rw-r--r-- | drivers/misc/habanalabs/habanalabs.h | 13 | ||||
| -rw-r--r-- | drivers/misc/habanalabs/hw_queue.c | 5 |
4 files changed, 18 insertions, 7 deletions
diff --git a/drivers/misc/habanalabs/command_submission.c b/drivers/misc/habanalabs/command_submission.c index 3525236ed8d9..19c84214a7ea 100644 --- a/drivers/misc/habanalabs/command_submission.c +++ b/drivers/misc/habanalabs/command_submission.c | |||
| @@ -179,6 +179,12 @@ static void cs_do_release(struct kref *ref) | |||
| 179 | 179 | ||
| 180 | /* We also need to update CI for internal queues */ | 180 | /* We also need to update CI for internal queues */ |
| 181 | if (cs->submitted) { | 181 | if (cs->submitted) { |
| 182 | int cs_cnt = atomic_dec_return(&hdev->cs_active_cnt); | ||
| 183 | |||
| 184 | WARN_ONCE((cs_cnt < 0), | ||
| 185 | "hl%d: error in CS active cnt %d\n", | ||
| 186 | hdev->id, cs_cnt); | ||
| 187 | |||
| 182 | hl_int_hw_queue_update_ci(cs); | 188 | hl_int_hw_queue_update_ci(cs); |
| 183 | 189 | ||
| 184 | spin_lock(&hdev->hw_queues_mirror_lock); | 190 | spin_lock(&hdev->hw_queues_mirror_lock); |
diff --git a/drivers/misc/habanalabs/device.c b/drivers/misc/habanalabs/device.c index 93d67983ddba..470d8005b50e 100644 --- a/drivers/misc/habanalabs/device.c +++ b/drivers/misc/habanalabs/device.c | |||
| @@ -218,6 +218,7 @@ static int device_early_init(struct hl_device *hdev) | |||
| 218 | spin_lock_init(&hdev->hw_queues_mirror_lock); | 218 | spin_lock_init(&hdev->hw_queues_mirror_lock); |
| 219 | atomic_set(&hdev->in_reset, 0); | 219 | atomic_set(&hdev->in_reset, 0); |
| 220 | atomic_set(&hdev->fd_open_cnt, 0); | 220 | atomic_set(&hdev->fd_open_cnt, 0); |
| 221 | atomic_set(&hdev->cs_active_cnt, 0); | ||
| 221 | 222 | ||
| 222 | return 0; | 223 | return 0; |
| 223 | 224 | ||
diff --git a/drivers/misc/habanalabs/habanalabs.h b/drivers/misc/habanalabs/habanalabs.h index 806f0a5ee4d8..a8ee52c880cd 100644 --- a/drivers/misc/habanalabs/habanalabs.h +++ b/drivers/misc/habanalabs/habanalabs.h | |||
| @@ -1056,13 +1056,15 @@ struct hl_device_reset_work { | |||
| 1056 | * @cb_pool_lock: protects the CB pool. | 1056 | * @cb_pool_lock: protects the CB pool. |
| 1057 | * @user_ctx: current user context executing. | 1057 | * @user_ctx: current user context executing. |
| 1058 | * @dram_used_mem: current DRAM memory consumption. | 1058 | * @dram_used_mem: current DRAM memory consumption. |
| 1059 | * @in_reset: is device in reset flow. | ||
| 1060 | * @curr_pll_profile: current PLL profile. | ||
| 1061 | * @fd_open_cnt: number of open user processes. | ||
| 1062 | * @timeout_jiffies: device CS timeout value. | 1059 | * @timeout_jiffies: device CS timeout value. |
| 1063 | * @max_power: the max power of the device, as configured by the sysadmin. This | 1060 | * @max_power: the max power of the device, as configured by the sysadmin. This |
| 1064 | * value is saved so in case of hard-reset, KMD will restore this | 1061 | * value is saved so in case of hard-reset, KMD will restore this |
| 1065 | * value and update the F/W after the re-initialization | 1062 | * value and update the F/W after the re-initialization |
| 1063 | * @in_reset: is device in reset flow. | ||
| 1064 | * @curr_pll_profile: current PLL profile. | ||
| 1065 | * @fd_open_cnt: number of open user processes. | ||
| 1066 | * @cs_active_cnt: number of active command submissions on this device (active | ||
| 1067 | * means already in H/W queues) | ||
| 1066 | * @major: habanalabs KMD major. | 1068 | * @major: habanalabs KMD major. |
| 1067 | * @high_pll: high PLL profile frequency. | 1069 | * @high_pll: high PLL profile frequency. |
| 1068 | * @soft_reset_cnt: number of soft reset since KMD loading. | 1070 | * @soft_reset_cnt: number of soft reset since KMD loading. |
| @@ -1128,11 +1130,12 @@ struct hl_device { | |||
| 1128 | struct hl_ctx *user_ctx; | 1130 | struct hl_ctx *user_ctx; |
| 1129 | 1131 | ||
| 1130 | atomic64_t dram_used_mem; | 1132 | atomic64_t dram_used_mem; |
| 1133 | u64 timeout_jiffies; | ||
| 1134 | u64 max_power; | ||
| 1131 | atomic_t in_reset; | 1135 | atomic_t in_reset; |
| 1132 | atomic_t curr_pll_profile; | 1136 | atomic_t curr_pll_profile; |
| 1133 | atomic_t fd_open_cnt; | 1137 | atomic_t fd_open_cnt; |
| 1134 | u64 timeout_jiffies; | 1138 | atomic_t cs_active_cnt; |
| 1135 | u64 max_power; | ||
| 1136 | u32 major; | 1139 | u32 major; |
| 1137 | u32 high_pll; | 1140 | u32 high_pll; |
| 1138 | u32 soft_reset_cnt; | 1141 | u32 soft_reset_cnt; |
diff --git a/drivers/misc/habanalabs/hw_queue.c b/drivers/misc/habanalabs/hw_queue.c index 67bece26417c..ef3bb6951360 100644 --- a/drivers/misc/habanalabs/hw_queue.c +++ b/drivers/misc/habanalabs/hw_queue.c | |||
| @@ -370,12 +370,13 @@ int hl_hw_queue_schedule_cs(struct hl_cs *cs) | |||
| 370 | spin_unlock(&hdev->hw_queues_mirror_lock); | 370 | spin_unlock(&hdev->hw_queues_mirror_lock); |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | list_for_each_entry_safe(job, tmp, &cs->job_list, cs_node) { | 373 | atomic_inc(&hdev->cs_active_cnt); |
| 374 | |||
| 375 | list_for_each_entry_safe(job, tmp, &cs->job_list, cs_node) | ||
| 374 | if (job->ext_queue) | 376 | if (job->ext_queue) |
| 375 | ext_hw_queue_schedule_job(job); | 377 | ext_hw_queue_schedule_job(job); |
| 376 | else | 378 | else |
| 377 | int_hw_queue_schedule_job(job); | 379 | int_hw_queue_schedule_job(job); |
| 378 | } | ||
| 379 | 380 | ||
| 380 | cs->submitted = true; | 381 | cs->submitted = true; |
| 381 | 382 | ||
