habanalabs: fix few misspelled words in the code
Oded Gabbay
maintainerPATCH 1/5 habanalabs: fix few misspelled words in the code
From: farah kassabri <[email protected]>
Run spell checker on the code and fix accordingly.
--- drivers/accel/habanalabs/common/command_submission.c | 2 +- drivers/accel/habanalabs/common/habanalabs.h | 4 ++-- drivers/accel/habanalabs/common/memory.c | 4 ++-- drivers/accel/habanalabs/common/memory_mgr.c | 2 +- drivers/accel/habanalabs/common/mmu/mmu.c | 6 +++--- drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-)
drivers/accel/habanalabs/common/command_submission.c +1 -1
@@ -657,7 +657,7 @@ static inline void cs_release_sob_reset_handler(struct hl_device *hdev,/* * we get refcount upon reservation of signals or signal/wait cs for the * hw_sob object, and need to put it when the first staged cs -* (which cotains the encaps signals) or cs signal/wait is completed. +* (which contains the encaps signals) or cs signal/wait is completed. */ if ((hl_cs_cmpl->type == CS_TYPE_SIGNAL) || (hl_cs_cmpl->type == CS_TYPE_WAIT) ||
drivers/accel/habanalabs/common/habanalabs.h +2 -2
@@ -2976,8 +2976,8 @@ struct cs_timeout_info {* @cq_addr: the address of the current handled command buffer * @cq_size: the size of the current handled command buffer * @cb_addr_streams_len: num of streams - actual len of cb_addr_streams array. -* should be equal to 1 incase of undefined opcode -* in Upper-CP (specific stream) and equal to 4 incase +* should be equal to 1 in case of undefined opcode +* in Upper-CP (specific stream) and equal to 4 in case * of undefined opcode in Lower-CP. * @engine_id: engine-id that the error occurred on * @stream_id: the stream id the error occurred on. In case the stream equals to
drivers/accel/habanalabs/common/memory.c +2 -2
@@ -2230,11 +2230,11 @@ static struct hl_mmap_mem_buf_behavior hl_ts_behavior = {* allocate_timestamps_buffers() - allocate timestamps buffers * This function will allocate ts buffer that will later on be mapped to the user * in order to be able to read the timestamp. -* in additon it'll allocate an extra buffer for registration management. +* in addition it'll allocate an extra buffer for registration management. * since we cannot fail during registration for out-of-memory situation, so * we'll prepare a pool which will be used as user interrupt nodes and instead * of dynamically allocating nodes while registration we'll pick the node from -* this pool. in addtion it'll add node to the mapping hash which will be used +* this pool. in addition it'll add node to the mapping hash which will be used * to map user ts buffer to the internal kernel ts buffer. * @hpriv: pointer to the private data of the fd * @args: ioctl input
drivers/accel/habanalabs/common/memory_mgr.c +1 -1
@@ -275,7 +275,7 @@ int hl_mem_mgr_mmap(struct hl_mem_mgr *mmg, struct vm_area_struct *vma,if (atomic_cmpxchg (&buf->mmap,0 ,1 )) {dev_err (mmg->dev, -"%s, Memory mmap failed, already mmaped to user\n" , +"%s, Memory mmap failed, already maped to user\n" , buf->behavior->topic); rc = -EINVAL ; goto put_mem;
drivers/accel/habanalabs/common/mmu/mmu.c +3 -3
@@ -540,8 +540,8 @@ static void hl_mmu_pa_page_with_offset(struct hl_ctx *ctx, u64 virt_addr,u32 page_off;/* -* Bit arithmetics cannot be used for non power of two page -* sizes. In addition, since bit arithmetics is not used, +* Bit arithmetic cannot be used for non power of two page +* sizes. In addition, since bit arithmetic is not used, * we cannot ignore dram base. All that shall be considered. */
@@ -757,7 +757,7 @@ u64 hl_mmu_get_next_hop_addr(struct hl_ctx *ctx, u64 curr_pte)* @mmu_prop: MMU properties. * @hop_idx: HOP index. * @hop_addr: HOP address. -* @virt_addr: virtual address fro the translation. +* @virt_addr: virtual address for the translation. * * @return the matching PTE value on success, otherwise U64_MAX. */
drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c +1 -1
@@ -2657,7 +2657,7 @@ int gaudi2_coresight_init(struct hl_device *hdev)/* * Mask out all the disabled binned offsets. * so when user request to configure a binned or masked out component, -* driver will ignore programing it ( happens when offset value is set to 0x0 ) +* driver will ignore programming it ( happens when offset value is set to 0x0 ) * this is being set in gaudi2_coresight_set_disabled_components */
Signature · 1 line
2.39.2
Oded Gabbay
maintainerPATCH 2/5 habanalabs/gaudi2: remove a useless is_idle TPC flag
From: Koby Elbaz <[email protected]>
Is appears that the flag - DCORE0_TPC0_CFG_STATUS_VECTOR_PIPE_EMPTY_MASK, has no actual use when it comes to querying TPC idleness, since this flag's corresponding bit turns-off after stalling the engine, and turns back on after resuming it.
--- drivers/accel/habanalabs/gaudi2/gaudi2_masks.h | 1 - 1 file changed, 1 deletion(-)
drivers/accel/habanalabs/gaudi2/gaudi2_masks.h +0 -1
@@ -79,7 +79,6 @@ DCORE0_MME_CTRL_LO_ARCH_STATUS_QM_RDY_MASK)#define TPC_IDLE_MASK (DCORE0_TPC0_CFG_STATUS_SCALAR_PIPE_EMPTY_MASK | \ - DCORE0_TPC0_CFG_STATUS_VECTOR_PIPE_EMPTY_MASK | \ DCORE0_TPC0_CFG_STATUS_IQ_EMPTY_MASK | \ DCORE0_TPC0_CFG_STATUS_SB_EMPTY_MASK | \ DCORE0_TPC0_CFG_STATUS_QM_IDLE_MASK | \
Signature · 1 line
2.39.2
Oded Gabbay
maintainerPATCH 3/5 habanalabs/gaudi2: fix register address on PDMA/EDMA idle check
In reply to Oded GabbayFrom: Koby Elbaz <[email protected]>
The PDMA/EDMA is_idle routines didn't check the correct CORE register in order to get the accurate idle state.
Moreover, it's better to make the is_idle routine more robust by adding additional checks (IS_HALTED) before announcing that the core is idle.
--- drivers/accel/habanalabs/gaudi2/gaudi2.c | 44 ++++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-)
drivers/accel/habanalabs/gaudi2/gaudi2.c +22 -22
@@ -86,10 +86,11 @@#define KDMA_TIMEOUT_USEC USEC_PER_SEC -#define IS_DMA_IDLE (dma_core_idle_ind_mask) \ - (!((dma_core_idle_ind_mask) & \ - ((DCORE0_EDMA0_CORE_IDLE_IND_MASK_DESC_CNT_STS_MASK) | \ - (DCORE0_EDMA0_CORE_IDLE_IND_MASK_COMP_MASK)))) +#define IS_DMA_IDLE (dma_core_sts0) \ + (!((dma_core_sts0) & (DCORE0_EDMA0_CORE_STS0_BUSY_MASK))) + +#define IS_DMA_HALTED (dma_core_sts1) \ + ((dma_core_sts1) & (DCORE0_EDMA0_CORE_STS1_IS_HALT_MASK))#define IS_MME_IDLE (mme_arch_sts) (((mme_arch_sts) & MME_ARCH_IDLE_MASK) == MME_ARCH_IDLE_MASK)
@@ -6677,18 +6678,18 @@ static int gaudi2_compute_reset_late_init(struct hl_device *hdev)static bool gaudi2_get_edma_idle_status (struct hl_device *hdev,u64 *mask_arr,u8 mask_len,struct engines_data *e) { -u32 qm_glbl_sts0, qm_glbl_sts1, qm_cgm_sts, dma_core_idle_ind_mask; +u32 qm_glbl_sts0, qm_glbl_sts1, qm_cgm_sts, dma_core_sts0, dma_core_sts1;struct asic_fixed_properties *prop = &hdev->asic_prop;unsigned long *mask = (unsigned long *) mask_arr; -const char *edma_fmt ="%-6d%-6d%-9s%#-14x%#x\n" ; +const char *edma_fmt ="%-6d%-6d%-9s%#-14x%#-15x%#x\n" ;bool is_idle = true, is_eng_idle;int engine_idx, i, j;u64 offset;if (e)hl_engine_data_sprintf (e, -"\nCORE EDMA is_idle QM_GLBL_STS0 DMA_CORE_IDLE_IND_MASK\n" -"---- ---- ------- ------------ ----------------------\n" ); +"\nCORE EDMA is_idle QM_GLBL_STS0 DMA_CORE_STS0 DMA_CORE_STS1\n" +"---- ---- ------- ------------ ------------- -------------\n" );for (i =0 ; i <NUM_OF_DCORES ; i++) {for (j =0 ; j <NUM_OF_EDMA_PER_DCORE ; j++) {
@@ -6701,25 +6702,23 @@ static bool gaudi2_get_edma_idle_status(struct hl_device *hdev, u64 *mask_arr, u i *GAUDI2_ENGINE_ID_DCORE_OFFSET + j; offset = i *DCORE_OFFSET + j *DCORE_EDMA_OFFSET ; - dma_core_idle_ind_mask = -RREG32 (mmDCORE0_EDMA0_CORE_IDLE_IND_MASK + offset); + dma_core_sts0 =RREG32 (mmDCORE0_EDMA0_CORE_STS0 + offset); + dma_core_sts1 =RREG32 (mmDCORE0_EDMA0_CORE_STS1 + offset); qm_glbl_sts0 =RREG32 (mmDCORE0_EDMA0_QM_GLBL_STS0 + offset); qm_glbl_sts1 =RREG32 (mmDCORE0_EDMA0_QM_GLBL_STS1 + offset); qm_cgm_sts =RREG32 (mmDCORE0_EDMA0_QM_CGM_STS + offset); is_eng_idle =IS_QM_IDLE (qm_glbl_sts0, qm_glbl_sts1, qm_cgm_sts) && -IS_DMA_IDLE (dma_core_idle_ind_mask); +IS_DMA_IDLE (dma_core_sts0) && !IS_DMA_HALTED (dma_core_sts1); is_idle &= is_eng_idle;if (mask && !is_eng_idle)set_bit (engine_idx, mask);if (e) -hl_engine_data_sprintf (e, edma_fmt, i, j, - is_eng_idle ?"Y" :"N" , - qm_glbl_sts0, - dma_core_idle_ind_mask); +hl_engine_data_sprintf (e, edma_fmt, i, j, is_eng_idle ?"Y" :"N" , + qm_glbl_sts0, dma_core_sts0, dma_core_sts1); } }
@@ -6729,29 +6728,30 @@ static bool gaudi2_get_edma_idle_status(struct hl_device *hdev, u64 *mask_arr, ustatic bool gaudi2_get_pdma_idle_status (struct hl_device *hdev,u64 *mask_arr,u8 mask_len,struct engines_data *e) { -u32 qm_glbl_sts0, qm_glbl_sts1, qm_cgm_sts, dma_core_idle_ind_mask; +u32 qm_glbl_sts0, qm_glbl_sts1, qm_cgm_sts, dma_core_sts0, dma_core_sts1;unsigned long *mask = (unsigned long *) mask_arr; -const char *pdma_fmt ="%-6d%-9s%#-14x%#x\n" ; +const char *pdma_fmt ="%-6d%-9s%#-14x%#-15x%#x\n" ;bool is_idle = true, is_eng_idle;int engine_idx, i;u64 offset;if (e)hl_engine_data_sprintf (e, -"\nPDMA is_idle QM_GLBL_STS0 DMA_CORE_IDLE_IND_MASK\n" -"---- ------- ------------ ----------------------\n" ); +"\nPDMA is_idle QM_GLBL_STS0 DMA_CORE_STS0 DMA_CORE_STS1\n" +"---- ------- ------------ ------------- -------------\n" );for (i =0 ; i <NUM_OF_PDMA ; i++) { engine_idx =GAUDI2_ENGINE_ID_PDMA_0 + i; offset = i *PDMA_OFFSET ; - dma_core_idle_ind_mask =RREG32 (mmPDMA0_CORE_IDLE_IND_MASK + offset); + dma_core_sts0 =RREG32 (mmPDMA0_CORE_STS0 + offset); + dma_core_sts1 =RREG32 (mmPDMA0_CORE_STS1 + offset); qm_glbl_sts0 =RREG32 (mmPDMA0_QM_GLBL_STS0 + offset); qm_glbl_sts1 =RREG32 (mmPDMA0_QM_GLBL_STS1 + offset); qm_cgm_sts =RREG32 (mmPDMA0_QM_CGM_STS + offset); is_eng_idle =IS_QM_IDLE (qm_glbl_sts0, qm_glbl_sts1, qm_cgm_sts) && -IS_DMA_IDLE (dma_core_idle_ind_mask); +IS_DMA_IDLE (dma_core_sts0) && !IS_DMA_HALTED (dma_core_sts1); is_idle &= is_eng_idle;if (mask && !is_eng_idle)
@@ -6759,7 +6759,7 @@ static bool gaudi2_get_pdma_idle_status(struct hl_device *hdev, u64 *mask_arr, uif (e)hl_engine_data_sprintf (e, pdma_fmt, i, is_eng_idle ?"Y" :"N" , - qm_glbl_sts0, dma_core_idle_ind_mask); + qm_glbl_sts0, dma_core_sts0, dma_core_sts1); }return is_idle;
Signature · 1 line
2.39.2
Oded Gabbay
maintainerPATCH 4/5 habanalabs: allow getting HL_INFO_DRAM_USAGE during soft-reset
In reply to Oded GabbayFrom: Dafna Hirschfeld <[email protected]>
We can allow userspace to query the dram usage during soft-reset.
--- drivers/accel/habanalabs/common/habanalabs_ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/accel/habanalabs/common/habanalabs_ioctl.c +2 -4
@@ -1002,6 +1002,8 @@ static int _hl_info_ioctl(struct hl_fpriv *hpriv, void *data,case HL_INFO_FW_ERR_EVENT :return fw_err_info (hpriv, args); +case HL_INFO_DRAM_USAGE : +return dram_usage_info (hpriv, args);default :break ; }
@@ -1014,10 +1016,6 @@ static int _hl_info_ioctl(struct hl_fpriv *hpriv, void *data, }switch (args->op) { -case HL_INFO_DRAM_USAGE : - rc =dram_usage_info (hpriv, args); -break ; -case HL_INFO_HW_IDLE : rc =hw_idle (hdev, args);break ;
Signature · 1 line
2.39.2
Oded Gabbay
maintainerPATCH 5/5 habanalabs: use a mutex rather than a spinlock
In reply to Oded GabbayFrom: Koby Elbaz <[email protected]>
There are two reasons why mutex is better here:
1. There's a critical section relatively long, where in certain scenarios (e.g., multiple VM allocations) taking a spinlock might cause noticeable performance degradation.
2. It will remove the incorrect usage of mutex under spin_lock (where preemption is disabled).
--- drivers/accel/habanalabs/common/debugfs.c | 15 ++++++++------- drivers/accel/habanalabs/common/habanalabs.h | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/accel/habanalabs/common/debugfs.c +8 -7
@@ -258,7 +258,7 @@ static int vm_show(struct seq_file *s, void *data)if (!dev_entry->hdev->mmu_enable)return 0 ; -spin_lock (&dev_entry->ctx_mem_hash_spinlock); +mutex_lock (&dev_entry->ctx_mem_hash_mutex);list_for_each_entry (ctx, &dev_entry->ctx_mem_hash_list, debugfs_list) { once = false;
@@ -329,7 +329,7 @@ static int vm_show(struct seq_file *s, void *data) } -spin_unlock (&dev_entry->ctx_mem_hash_spinlock); +mutex_unlock (&dev_entry->ctx_mem_hash_mutex); ctx =hl_get_compute_ctx (dev_entry->hdev);if (ctx) {
@@ -1785,7 +1785,7 @@ void hl_debugfs_add_device(struct hl_device *hdev)spin_lock_init (&dev_entry->cs_spinlock);spin_lock_init (&dev_entry->cs_job_spinlock);spin_lock_init (&dev_entry->userptr_spinlock); -spin_lock_init (&dev_entry->ctx_mem_hash_spinlock); +mutex_init (&dev_entry->ctx_mem_hash_mutex); dev_entry->root =debugfs_create_dir (dev_name (hdev->dev), hl_debug_root);
@@ -1802,6 +1802,7 @@ void hl_debugfs_remove_device(struct hl_device *hdev)debugfs_remove_recursive (entry->root); +mutex_destroy (&entry->ctx_mem_hash_mutex);mutex_destroy (&entry->file_mutex);vfree (entry->data_dma_blob_desc.data);
@@ -1908,18 +1909,18 @@ void hl_debugfs_add_ctx_mem_hash(struct hl_device *hdev, struct hl_ctx *ctx) {struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; -spin_lock (&dev_entry->ctx_mem_hash_spinlock); +mutex_lock (&dev_entry->ctx_mem_hash_mutex);list_add (&ctx->debugfs_list, &dev_entry->ctx_mem_hash_list); -spin_unlock (&dev_entry->ctx_mem_hash_spinlock); +mutex_unlock (&dev_entry->ctx_mem_hash_mutex); }void hl_debugfs_remove_ctx_mem_hash (struct hl_device *hdev,struct hl_ctx *ctx) {struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; -spin_lock (&dev_entry->ctx_mem_hash_spinlock); +mutex_lock (&dev_entry->ctx_mem_hash_mutex);list_del (&ctx->debugfs_list); -spin_unlock (&dev_entry->ctx_mem_hash_spinlock); +mutex_unlock (&dev_entry->ctx_mem_hash_mutex); }/**
drivers/accel/habanalabs/common/habanalabs.h +2 -2
@@ -2320,7 +2320,7 @@ struct hl_debugfs_entry {* @userptr_list: list of available userptrs (virtual memory chunk descriptor). * @userptr_spinlock: protects userptr_list. * @ctx_mem_hash_list: list of available contexts with MMU mappings. -* @ctx_mem_hash_spinlock: protects cb_list. +* @ctx_mem_hash_mutex: protects list of available contexts with MMU mappings. * @data_dma_blob_desc: data DMA descriptor of blob. * @mon_dump_blob_desc: monitor dump descriptor of blob. * @state_dump: data of the system states in case of a bad cs.
@@ -2351,7 +2351,7 @@ struct hl_dbg_device_entry {struct list_head userptr_list;spinlock_t userptr_spinlock;struct list_head ctx_mem_hash_list; -spinlock_t ctx_mem_hash_spinlock; +struct mutex ctx_mem_hash_mutex;struct debugfs_blob_wrapper data_dma_blob_desc;struct debugfs_blob_wrapper mon_dump_blob_desc;char *state_dump[HL_STATE_DUMP_HIST_LEN ];
Signature · 1 line
2.39.2