habanalabs: read F/W versions before failure
PATCH 1/6 habanalabs: read F/W versions before failure
Move the read of the F/W boot versions before exiting on possible failures of the F/W boot. This will help debug boot failures as we will be able to know the F/W boot version.
--- drivers/misc/habanalabs/goya/goya.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/misc/habanalabs/goya/goya.c +4 -4
@@ -2296,6 +2296,10 @@ static int goya_init_cpu(struct hl_device *hdev, u32 cpu_timeout)10000 , cpu_timeout); +/* Read U-Boot version now in case we will later fail */ +goya_read_device_fw_version (hdev,FW_COMP_UBOOT ); +goya_read_device_fw_version (hdev,FW_COMP_PREBOOT ); +if (rc) {dev_err (hdev->dev,"Error in ARM u-boot!" );switch (status) {
@@ -2347,10 +2351,6 @@ static int goya_init_cpu(struct hl_device *hdev, u32 cpu_timeout)return -EIO ; } -/* Read U-Boot version now in case we will later fail */ -goya_read_device_fw_version (hdev,FW_COMP_UBOOT ); -goya_read_device_fw_version (hdev,FW_COMP_PREBOOT ); -if (!hdev->fw_loading) {dev_info (hdev->dev,"Skip loading FW\n" ); goto out;
Signature · 1 line
2.17.1
PATCH 3/6 habanalabs: set ETR as non-secured
ETR should always be non-secured as it is used by the users to record profiling/trace data.
--- drivers/misc/habanalabs/goya/goya_coresight.c | 4 +++- drivers/misc/habanalabs/include/goya/asic_reg/goya_masks.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/misc/habanalabs/goya/goya_coresight.c +3 -1
@@ -8,6 +8,7 @@#include "goyaP.h" #include "include/goya/goya_coresight.h" #include "include/goya/asic_reg/goya_regs.h" +#include "include/goya/asic_reg/goya_masks.h" #include <uapi/misc/habanalabs.h>
@@ -425,7 +426,8 @@ static int goya_config_etr(struct hl_device *hdev,WREG32 (mmPSOC_ETR_BUFWM,0x3FFC );WREG32 (mmPSOC_ETR_RSZ, input->buffer_size);WREG32 (mmPSOC_ETR_MODE, input->sink_mode); -WREG32 (mmPSOC_ETR_AXICTL,0x700 ); +WREG32 (mmPSOC_ETR_AXICTL, +0x700 |PSOC_ETR_AXICTL_PROTCTRLBIT1_SHIFT );WREG32 (mmPSOC_ETR_DBALO,lower_32_bits (input->buffer_address)); WREG32(mmPSOC_ETR_DBAHI,
drivers/misc/habanalabs/include/goya/asic_reg/goya_masks.h +2 -0
@@ -260,4 +260,6 @@#define DMA_QM_3_GLBL_CFG1_DMA_STOP_SHIFT DMA_QM_0_GLBL_CFG1_DMA_STOP_SHIFT#define DMA_QM_4_GLBL_CFG1_DMA_STOP_SHIFT DMA_QM_0_GLBL_CFG1_DMA_STOP_SHIFT +#define PSOC_ETR_AXICTL_PROTCTRLBIT1_SHIFT 1 +#endif /* ASIC_REG_GOYA_MASKS_H_ */
Signature · 1 line
2.17.1
PATCH 4/6 habanalabs: increase max jobs number to 512
In reply to Oded GabbayIn training, there is a need for a large amount of patching to the recipe. This results in many command buffers contains a lot of DMA packets. The number of command buffers per CS is larger than the current maximum of 64, which is an arbitrary number that is enough for inference, but it has no real affect on the code and/or resources of the host machine.
--- drivers/misc/habanalabs/habanalabs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/habanalabs.h +1 -1
@@ -40,7 +40,7 @@#define HL_MAX_QUEUES 128 -#define HL_MAX_JOBS_PER_CS 64 +#define HL_MAX_JOBS_PER_CS 512/* MUST BE POWER OF 2 and larger than 1 */ #define HL_MAX_PENDING_CS 64
Signature · 1 line
2.17.1
PATCH 5/6 habanalabs: don't print error when queues are full
In reply to Oded GabbayIf the queues are full and we return -EAGAIN to the user, there is no need to print an error, as that case isn't an error and the user is expected to re-submit the work.
--- drivers/misc/habanalabs/command_submission.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/misc/habanalabs/command_submission.c +4 -3
@@ -626,9 +626,10 @@ static int _hl_cs_ioctl(struct hl_fpriv *hpriv, void __user *chunks, rc =hl_hw_queue_schedule_cs (cs);if (rc) { -dev_err (hdev->dev, -"Failed to submit CS %d.%llu to H/W queues, error %d\n" , - cs->ctx->asid, cs->sequence, rc); +if (rc != -EAGAIN ) +dev_err (hdev->dev, +"Failed to submit CS %d.%llu to H/W queues, error %d\n" , + cs->ctx->asid, cs->sequence, rc); goto free_cs_object; }
Signature · 1 line
2.17.1
PATCH 6/6 habanalabs: export uapi defines to user-space
In reply to Oded GabbayThe two defines that control the maximum size of a command buffer and the maximum number of JOBS per CS need to be exported to the user as they are part of the API towards user-space.
--- drivers/misc/habanalabs/habanalabs.h | 4 ---- include/uapi/misc/habanalabs.h | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/misc/habanalabs/habanalabs.h +0 -4
@@ -40,8 +40,6 @@#define HL_MAX_QUEUES 128 -#define HL_MAX_JOBS_PER_CS 512 -/* MUST BE POWER OF 2 and larger than 1 */ #define HL_MAX_PENDING_CS 64
@@ -242,8 +240,6 @@ struct hl_dma_fence {* Command Buffers */ -#define HL_MAX_CB_SIZE 0x200000/* 2MB */ -/** * struct hl_cb_mgr - describes a Command Buffer Manager. * @cb_lock: protects cb_handles.
include/uapi/misc/habanalabs.h +12 -4
@@ -192,13 +192,15 @@ struct hl_info_args {/* Opcode to destroy previously created command buffer */ #define HL_CB_OP_DESTROY 1 +#define HL_MAX_CB_SIZE 0x200000/* 2MB */ +struct hl_cb_in {/* Handle of CB or 0 if we want to create one */ __u64 cb_handle;/* HL_CB_OP_* */ __u32 op; -/* Size of CB. Maximum size is 2MB. The minimum size that will be -* allocated, regardless of this parameter's value, is PAGE_SIZE +/* Size of CB. Maximum size is HL_MAX_CB_SIZE. The minimum size that +* will be allocated, regardless of this parameter's value, is PAGE_SIZE */ __u32 cb_size;/* Context ID - Currently not in use */
@@ -244,6 +246,8 @@ struct hl_cs_chunk {#define HL_CS_STATUS_SUCCESS 0 +#define HL_MAX_JOBS_PER_CS 512 +struct hl_cs_in {/* this holds address of array of hl_cs_chunk for restore phase */ __u64 chunks_restore;
@@ -253,9 +257,13 @@ struct hl_cs_in {* Currently not in use */ __u64 chunks_store; -/* Number of chunks in restore phase array */ +/* Number of chunks in restore phase array. Maximum number is +* HL_MAX_JOBS_PER_CS +*/ __u32 num_chunks_restore; -/* Number of chunks in execution array */ +/* Number of chunks in execution array. Maximum number is +* HL_MAX_JOBS_PER_CS +*/ __u32 num_chunks_execute;/* Number of chunks in restore phase array - Currently not in use */ __u32 num_chunks_store;
Signature · 1 line
2.17.1
PATCH 2/6 habanalabs: use registers name defines for ETR block
In reply to Oded GabbayWe have a single ETR block in the SOC, so use explicit register name defines for initializing this block. This makes it more readable and maintainable.
--- drivers/misc/habanalabs/goya/goya_coresight.c | 51 ++++---- .../include/goya/asic_reg/goya_regs.h | 1 + .../include/goya/asic_reg/psoc_etr_regs.h | 114 ++++++++++++++++++ 3 files changed, 140 insertions(+), 26 deletions(-) create mode 100644 drivers/misc/habanalabs/include/goya/asic_reg/psoc_etr_regs.h
drivers/misc/habanalabs/goya/goya_coresight.c +25 -26
@@ -377,33 +377,32 @@ static int goya_config_etr(struct hl_device *hdev, struct hl_debug_params *params) {struct hl_debug_params_etr *input; -u64 base_reg = mmPSOC_ETR_BASE -CFG_BASE ;u32 val;int rc; -WREG32 (base_reg +0xFB0 ,CORESIGHT_UNLOCK ); +WREG32 (mmPSOC_ETR_LAR,CORESIGHT_UNLOCK ); - val =RREG32 (base_reg +0x304 ); + val =RREG32 (mmPSOC_ETR_FFCR); val |=0x1000 ; -WREG32 (base_reg +0x304 , val); +WREG32 (mmPSOC_ETR_FFCR, val); val |=0x40 ; -WREG32 (base_reg +0x304 , val); +WREG32 (mmPSOC_ETR_FFCR, val); - rc =goya_coresight_timeout (hdev, base_reg +0x304 ,6 , false); + rc =goya_coresight_timeout (hdev, mmPSOC_ETR_FFCR,6 , false);if (rc) {dev_err (hdev->dev,"Failed to %s ETR on timeout, error %d\n" , params->enable ?"enable" :"disable" , rc);return rc; } - rc =goya_coresight_timeout (hdev, base_reg +0xC ,2 , true); + rc =goya_coresight_timeout (hdev, mmPSOC_ETR_STS,2 , true);if (rc) {dev_err (hdev->dev,"Failed to %s ETR on timeout, error %d\n" , params->enable ?"enable" :"disable" , rc);return rc; } -WREG32 (base_reg +0x20 ,0 ); +WREG32 (mmPSOC_ETR_CTL,0 );if (params->enable) { input = params->input;
@@ -423,25 +422,25 @@ static int goya_config_etr(struct hl_device *hdev,return -EINVAL ; } -WREG32 (base_reg +0x34 ,0x3FFC ); -WREG32 (base_reg +0x4 , input->buffer_size); -WREG32 (base_reg +0x28 , input->sink_mode); -WREG32 (base_reg +0x110 ,0x700 ); -WREG32 (base_reg +0x118 , +WREG32 (mmPSOC_ETR_BUFWM,0x3FFC ); +WREG32 (mmPSOC_ETR_RSZ, input->buffer_size); +WREG32 (mmPSOC_ETR_MODE, input->sink_mode); +WREG32 (mmPSOC_ETR_AXICTL,0x700 ); +WREG32 (mmPSOC_ETR_DBALO,lower_32_bits (input->buffer_address)); -WREG32 (base_reg +0x11C , +WREG32 (mmPSOC_ETR_DBAHI,upper_32_bits (input->buffer_address)); -WREG32 (base_reg +0x304 ,3 ); -WREG32 (base_reg +0x308 ,0xA ); -WREG32 (base_reg +0x20 ,1 ); +WREG32 (mmPSOC_ETR_FFCR,3 ); +WREG32 (mmPSOC_ETR_PSCR,0xA ); +WREG32 (mmPSOC_ETR_CTL,1 ); }else { -WREG32 (base_reg +0x34 ,0 ); -WREG32 (base_reg +0x4 ,0x400 ); -WREG32 (base_reg +0x118 ,0 ); -WREG32 (base_reg +0x11C ,0 ); -WREG32 (base_reg +0x308 ,0 ); -WREG32 (base_reg +0x28 ,0 ); -WREG32 (base_reg +0x304 ,0 ); +WREG32 (mmPSOC_ETR_BUFWM,0 ); +WREG32 (mmPSOC_ETR_RSZ,0x400 ); +WREG32 (mmPSOC_ETR_DBALO,0 ); +WREG32 (mmPSOC_ETR_DBAHI,0 ); +WREG32 (mmPSOC_ETR_PSCR,0 ); +WREG32 (mmPSOC_ETR_MODE,0 ); +WREG32 (mmPSOC_ETR_FFCR,0 );if (params->output_size >=sizeof (u64)) {u32 rwp, rwphi;
@@ -451,8 +450,8 @@ static int goya_config_etr(struct hl_device *hdev,* the buffer is set in the RWP register (lower 32 * bits), and in the RWPHI register (upper 8 bits). */ - rwp =RREG32 (base_reg +0x18 ); - rwphi =RREG32 (base_reg +0x3c ) &0xff ; + rwp =RREG32 (mmPSOC_ETR_RWP); + rwphi =RREG32 (mmPSOC_ETR_RWPHI) &0xff ; *(u64 *) params->output = ((u64 ) rwphi <<32 ) | rwp; } }
drivers/misc/habanalabs/include/goya/asic_reg/goya_regs.h +1 -0
@@ -84,6 +84,7 @@#include "tpc6_rtr_regs.h" #include "tpc7_nrtr_regs.h" #include "tpc0_eml_cfg_regs.h" +#include "psoc_etr_regs.h" #include "psoc_global_conf_masks.h" #include "dma_macro_masks.h"
drivers/misc/habanalabs/include/goya/asic_reg/psoc_etr_regs.h new file +114 -0
114 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 5 lines · Oded Gabbay
Move the read of the F/W boot versions before exiting on possible failures of the F/W boot. This will help debug boot failures as we will be able to know the F/W boot version.
Signed-off-by Oded Gabbay <[email protected]>
RE: [PATCH 2/6] habanalabs: use registers name defines for ETR block
In reply to Oded GabbayQuoted 4 lines · Oded Gabbay
We have a single ETR block in the SOC, so use explicit register name defines for initializing this block. This makes it more readable and maintainable.
Signed-off-by Oded Gabbay <[email protected]>
RE: [PATCH 3/6] habanalabs: set ETR as non-secured
In reply to Oded GabbayQuoted 4 lines · Oded Gabbay
ETR should always be non-secured as it is used by the users to record profiling/trace data.
Signed-off-by Oded Gabbay <[email protected]>
RE: [PATCH 4/6] habanalabs: increase max jobs number to 512
In reply to Oded GabbayQuoted 7 lines · Oded Gabbay
In training, there is a need for a large amount of patching to the recipe. This results in many command buffers contains a lot of DMA packets. The number of command buffers per CS is larger than the current maximum of 64, which is an arbitrary number that is enough for inference, but it has no real affect on the code and/or resources of the host machine.
Signed-off-by Oded Gabbay <[email protected]>
RE: [PATCH 5/6] habanalabs: don't print error when queues are full
In reply to Oded GabbayQuoted 5 lines · Oded Gabbay
If the queues are full and we return
-EAGAINto the user, there is no need to print an error, as that case isn't an error and the user is expected to re- submit the work.Signed-off-by Oded Gabbay <[email protected]>
RE: [PATCH 6/6] habanalabs: export uapi defines to user-space
In reply to Oded GabbayQuoted 5 lines · Oded Gabbay
The two defines that control the maximum size of a command buffer and the maximum number of JOBS per CS need to be exported to the user as they are part of the API towards user-space.
Signed-off-by Oded Gabbay <[email protected]>