Commit 6798676f authored by Oded Gabbay's avatar Oded Gabbay

habanalabs: fix etr asid configuration

Pass the user's context pointer into the etr configuration function
to extract its ASID.

Using the compute_ctx pointer is an error as it is just an indication
of whether a user has opened the compute device.
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 357ff3dc
...@@ -99,7 +99,7 @@ static void hl_ctx_fini(struct hl_ctx *ctx) ...@@ -99,7 +99,7 @@ static void hl_ctx_fini(struct hl_ctx *ctx)
* related to the stopped engines. Hence stop it explicitly. * related to the stopped engines. Hence stop it explicitly.
*/ */
if (hdev->in_debug) if (hdev->in_debug)
hl_device_set_debug_mode(hdev, false); hl_device_set_debug_mode(hdev, ctx, false);
hdev->asic_funcs->ctx_fini(ctx); hdev->asic_funcs->ctx_fini(ctx);
hl_cb_va_pool_fini(ctx); hl_cb_va_pool_fini(ctx);
......
...@@ -622,7 +622,7 @@ int hl_device_utilization(struct hl_device *hdev, u32 *utilization) ...@@ -622,7 +622,7 @@ int hl_device_utilization(struct hl_device *hdev, u32 *utilization)
return 0; return 0;
} }
int hl_device_set_debug_mode(struct hl_device *hdev, bool enable) int hl_device_set_debug_mode(struct hl_device *hdev, struct hl_ctx *ctx, bool enable)
{ {
int rc = 0; int rc = 0;
...@@ -637,7 +637,7 @@ int hl_device_set_debug_mode(struct hl_device *hdev, bool enable) ...@@ -637,7 +637,7 @@ int hl_device_set_debug_mode(struct hl_device *hdev, bool enable)
} }
if (!hdev->hard_reset_pending) if (!hdev->hard_reset_pending)
hdev->asic_funcs->halt_coresight(hdev); hdev->asic_funcs->halt_coresight(hdev, ctx);
hdev->in_debug = 0; hdev->in_debug = 0;
......
...@@ -1288,7 +1288,7 @@ struct hl_asic_funcs { ...@@ -1288,7 +1288,7 @@ struct hl_asic_funcs {
int (*send_heartbeat)(struct hl_device *hdev); int (*send_heartbeat)(struct hl_device *hdev);
void (*set_clock_gating)(struct hl_device *hdev); void (*set_clock_gating)(struct hl_device *hdev);
void (*disable_clock_gating)(struct hl_device *hdev); void (*disable_clock_gating)(struct hl_device *hdev);
int (*debug_coresight)(struct hl_device *hdev, void *data); int (*debug_coresight)(struct hl_device *hdev, struct hl_ctx *ctx, void *data);
bool (*is_device_idle)(struct hl_device *hdev, u64 *mask_arr, bool (*is_device_idle)(struct hl_device *hdev, u64 *mask_arr,
u8 mask_len, struct seq_file *s); u8 mask_len, struct seq_file *s);
int (*non_hard_reset_late_init)(struct hl_device *hdev); int (*non_hard_reset_late_init)(struct hl_device *hdev);
...@@ -1303,7 +1303,7 @@ struct hl_asic_funcs { ...@@ -1303,7 +1303,7 @@ struct hl_asic_funcs {
int (*init_iatu)(struct hl_device *hdev); int (*init_iatu)(struct hl_device *hdev);
u32 (*rreg)(struct hl_device *hdev, u32 reg); u32 (*rreg)(struct hl_device *hdev, u32 reg);
void (*wreg)(struct hl_device *hdev, u32 reg, u32 val); void (*wreg)(struct hl_device *hdev, u32 reg, u32 val);
void (*halt_coresight)(struct hl_device *hdev); void (*halt_coresight)(struct hl_device *hdev, struct hl_ctx *ctx);
int (*ctx_init)(struct hl_ctx *ctx); int (*ctx_init)(struct hl_ctx *ctx);
void (*ctx_fini)(struct hl_ctx *ctx); void (*ctx_fini)(struct hl_ctx *ctx);
int (*get_clk_rate)(struct hl_device *hdev, u32 *cur_clk, u32 *max_clk); int (*get_clk_rate)(struct hl_device *hdev, u32 *cur_clk, u32 *max_clk);
...@@ -2867,7 +2867,7 @@ int hl_device_open_ctrl(struct inode *inode, struct file *filp); ...@@ -2867,7 +2867,7 @@ int hl_device_open_ctrl(struct inode *inode, struct file *filp);
bool hl_device_operational(struct hl_device *hdev, bool hl_device_operational(struct hl_device *hdev,
enum hl_device_status *status); enum hl_device_status *status);
enum hl_device_status hl_device_status(struct hl_device *hdev); enum hl_device_status hl_device_status(struct hl_device *hdev);
int hl_device_set_debug_mode(struct hl_device *hdev, bool enable); int hl_device_set_debug_mode(struct hl_device *hdev, struct hl_ctx *ctx, bool enable);
int hl_hw_queues_create(struct hl_device *hdev); int hl_hw_queues_create(struct hl_device *hdev);
void hl_hw_queues_destroy(struct hl_device *hdev); void hl_hw_queues_destroy(struct hl_device *hdev);
int hl_hw_queue_send_cb_no_cmpl(struct hl_device *hdev, u32 hw_queue_id, int hl_hw_queue_send_cb_no_cmpl(struct hl_device *hdev, u32 hw_queue_id,
......
...@@ -158,7 +158,7 @@ static int hw_idle(struct hl_device *hdev, struct hl_info_args *args) ...@@ -158,7 +158,7 @@ static int hw_idle(struct hl_device *hdev, struct hl_info_args *args)
min((size_t) max_size, sizeof(hw_idle))) ? -EFAULT : 0; min((size_t) max_size, sizeof(hw_idle))) ? -EFAULT : 0;
} }
static int debug_coresight(struct hl_device *hdev, struct hl_debug_args *args) static int debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, struct hl_debug_args *args)
{ {
struct hl_debug_params *params; struct hl_debug_params *params;
void *input = NULL, *output = NULL; void *input = NULL, *output = NULL;
...@@ -200,7 +200,7 @@ static int debug_coresight(struct hl_device *hdev, struct hl_debug_args *args) ...@@ -200,7 +200,7 @@ static int debug_coresight(struct hl_device *hdev, struct hl_debug_args *args)
params->output_size = args->output_size; params->output_size = args->output_size;
} }
rc = hdev->asic_funcs->debug_coresight(hdev, params); rc = hdev->asic_funcs->debug_coresight(hdev, ctx, params);
if (rc) { if (rc) {
dev_err(hdev->dev, dev_err(hdev->dev,
"debug coresight operation failed %d\n", rc); "debug coresight operation failed %d\n", rc);
...@@ -738,13 +738,14 @@ static int hl_debug_ioctl(struct hl_fpriv *hpriv, void *data) ...@@ -738,13 +738,14 @@ static int hl_debug_ioctl(struct hl_fpriv *hpriv, void *data)
"Rejecting debug configuration request because device not in debug mode\n"); "Rejecting debug configuration request because device not in debug mode\n");
return -EFAULT; return -EFAULT;
} }
args->input_size = args->input_size = min(args->input_size, hl_debug_struct_size[args->op]);
min(args->input_size, hl_debug_struct_size[args->op]); rc = debug_coresight(hdev, hpriv->ctx, args);
rc = debug_coresight(hdev, args);
break; break;
case HL_DEBUG_OP_SET_MODE: case HL_DEBUG_OP_SET_MODE:
rc = hl_device_set_debug_mode(hdev, (bool) args->enable); rc = hl_device_set_debug_mode(hdev, hpriv->ctx, (bool) args->enable);
break; break;
default: default:
dev_err(hdev->dev, "Invalid request %d\n", args->op); dev_err(hdev->dev, "Invalid request %d\n", args->op);
rc = -ENOTTY; rc = -ENOTTY;
......
...@@ -357,8 +357,8 @@ void gaudi_init_security(struct hl_device *hdev); ...@@ -357,8 +357,8 @@ void gaudi_init_security(struct hl_device *hdev);
void gaudi_ack_protection_bits_errors(struct hl_device *hdev); void gaudi_ack_protection_bits_errors(struct hl_device *hdev);
void gaudi_add_device_attr(struct hl_device *hdev, void gaudi_add_device_attr(struct hl_device *hdev,
struct attribute_group *dev_attr_grp); struct attribute_group *dev_attr_grp);
int gaudi_debug_coresight(struct hl_device *hdev, void *data); int gaudi_debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, void *data);
void gaudi_halt_coresight(struct hl_device *hdev); void gaudi_halt_coresight(struct hl_device *hdev, struct hl_ctx *ctx);
void gaudi_mmu_prepare_reg(struct hl_device *hdev, u64 reg, u32 asid); void gaudi_mmu_prepare_reg(struct hl_device *hdev, u64 reg, u32 asid);
#endif /* GAUDIP_H_ */ #endif /* GAUDIP_H_ */
...@@ -848,7 +848,7 @@ static int gaudi_config_spmu(struct hl_device *hdev, ...@@ -848,7 +848,7 @@ static int gaudi_config_spmu(struct hl_device *hdev,
return 0; return 0;
} }
int gaudi_debug_coresight(struct hl_device *hdev, void *data) int gaudi_debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, void *data)
{ {
struct hl_debug_params *params = data; struct hl_debug_params *params = data;
int rc = 0; int rc = 0;
...@@ -887,7 +887,7 @@ int gaudi_debug_coresight(struct hl_device *hdev, void *data) ...@@ -887,7 +887,7 @@ int gaudi_debug_coresight(struct hl_device *hdev, void *data)
return rc; return rc;
} }
void gaudi_halt_coresight(struct hl_device *hdev) void gaudi_halt_coresight(struct hl_device *hdev, struct hl_ctx *ctx)
{ {
struct hl_debug_params params = {}; struct hl_debug_params params = {};
int i, rc; int i, rc;
......
...@@ -220,8 +220,8 @@ void goya_set_pll_profile(struct hl_device *hdev, enum hl_pll_frequency freq); ...@@ -220,8 +220,8 @@ void goya_set_pll_profile(struct hl_device *hdev, enum hl_pll_frequency freq);
void goya_add_device_attr(struct hl_device *hdev, void goya_add_device_attr(struct hl_device *hdev,
struct attribute_group *dev_attr_grp); struct attribute_group *dev_attr_grp);
int goya_cpucp_info_get(struct hl_device *hdev); int goya_cpucp_info_get(struct hl_device *hdev);
int goya_debug_coresight(struct hl_device *hdev, void *data); int goya_debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, void *data);
void goya_halt_coresight(struct hl_device *hdev); void goya_halt_coresight(struct hl_device *hdev, struct hl_ctx *ctx);
int goya_suspend(struct hl_device *hdev); int goya_suspend(struct hl_device *hdev);
int goya_resume(struct hl_device *hdev); int goya_resume(struct hl_device *hdev);
......
...@@ -652,7 +652,7 @@ static int goya_config_spmu(struct hl_device *hdev, ...@@ -652,7 +652,7 @@ static int goya_config_spmu(struct hl_device *hdev,
return 0; return 0;
} }
int goya_debug_coresight(struct hl_device *hdev, void *data) int goya_debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, void *data)
{ {
struct hl_debug_params *params = data; struct hl_debug_params *params = data;
int rc = 0; int rc = 0;
...@@ -691,7 +691,7 @@ int goya_debug_coresight(struct hl_device *hdev, void *data) ...@@ -691,7 +691,7 @@ int goya_debug_coresight(struct hl_device *hdev, void *data)
return rc; return rc;
} }
void goya_halt_coresight(struct hl_device *hdev) void goya_halt_coresight(struct hl_device *hdev, struct hl_ctx *ctx)
{ {
struct hl_debug_params params = {}; struct hl_debug_params params = {};
int i, rc; int i, rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment