Commit 1880f7ac authored by Dani Liberman's avatar Dani Liberman Committed by Oded Gabbay

habanalabs: add SOB information to signal submission uAPI

For debug purpose, add SOB address and SOB initial counter value
before current submission to uAPI output.

Using SOB address and initial counter, user can calculate how much of
the submmision has been completed.
Signed-off-by: default avatarDani Liberman <dliberman@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 4fac990f
...@@ -1277,7 +1277,8 @@ static u32 get_stream_master_qid_mask(struct hl_device *hdev, u32 qid) ...@@ -1277,7 +1277,8 @@ static u32 get_stream_master_qid_mask(struct hl_device *hdev, u32 qid)
static int cs_ioctl_default(struct hl_fpriv *hpriv, void __user *chunks, static int cs_ioctl_default(struct hl_fpriv *hpriv, void __user *chunks,
u32 num_chunks, u64 *cs_seq, u32 flags, u32 num_chunks, u64 *cs_seq, u32 flags,
u32 encaps_signals_handle, u32 timeout) u32 encaps_signals_handle, u32 timeout,
u16 *signal_initial_sob_count)
{ {
bool staged_mid, int_queues_only = true; bool staged_mid, int_queues_only = true;
struct hl_device *hdev = hpriv->hdev; struct hl_device *hdev = hpriv->hdev;
...@@ -1444,6 +1445,8 @@ static int cs_ioctl_default(struct hl_fpriv *hpriv, void __user *chunks, ...@@ -1444,6 +1445,8 @@ static int cs_ioctl_default(struct hl_fpriv *hpriv, void __user *chunks,
goto free_cs_object; goto free_cs_object;
} }
*signal_initial_sob_count = cs->initial_sob_count;
rc = HL_CS_STATUS_SUCCESS; rc = HL_CS_STATUS_SUCCESS;
goto put_cs; goto put_cs;
...@@ -1472,6 +1475,7 @@ static int hl_cs_ctx_switch(struct hl_fpriv *hpriv, union hl_cs_args *args, ...@@ -1472,6 +1475,7 @@ static int hl_cs_ctx_switch(struct hl_fpriv *hpriv, union hl_cs_args *args,
int rc = 0, do_ctx_switch; int rc = 0, do_ctx_switch;
void __user *chunks; void __user *chunks;
u32 num_chunks, tmp; u32 num_chunks, tmp;
u16 sob_count;
int ret; int ret;
do_ctx_switch = atomic_cmpxchg(&ctx->thread_ctx_switch_token, 1, 0); do_ctx_switch = atomic_cmpxchg(&ctx->thread_ctx_switch_token, 1, 0);
...@@ -1512,7 +1516,7 @@ static int hl_cs_ctx_switch(struct hl_fpriv *hpriv, union hl_cs_args *args, ...@@ -1512,7 +1516,7 @@ static int hl_cs_ctx_switch(struct hl_fpriv *hpriv, union hl_cs_args *args,
rc = 0; rc = 0;
} else { } else {
rc = cs_ioctl_default(hpriv, chunks, num_chunks, rc = cs_ioctl_default(hpriv, chunks, num_chunks,
cs_seq, 0, 0, hdev->timeout_jiffies); cs_seq, 0, 0, hdev->timeout_jiffies, &sob_count);
} }
mutex_unlock(&hpriv->restore_phase_mutex); mutex_unlock(&hpriv->restore_phase_mutex);
...@@ -1963,7 +1967,8 @@ static int cs_ioctl_unreserve_signals(struct hl_fpriv *hpriv, u32 handle_id) ...@@ -1963,7 +1967,8 @@ static int cs_ioctl_unreserve_signals(struct hl_fpriv *hpriv, u32 handle_id)
static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type, static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type,
void __user *chunks, u32 num_chunks, void __user *chunks, u32 num_chunks,
u64 *cs_seq, u32 flags, u32 timeout) u64 *cs_seq, u32 flags, u32 timeout,
u32 *signal_sob_addr_offset, u16 *signal_initial_sob_count)
{ {
struct hl_cs_encaps_sig_handle *encaps_sig_hdl = NULL; struct hl_cs_encaps_sig_handle *encaps_sig_hdl = NULL;
bool handle_found = false, is_wait_cs = false, bool handle_found = false, is_wait_cs = false,
...@@ -2195,6 +2200,9 @@ static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type, ...@@ -2195,6 +2200,9 @@ static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type,
goto free_cs_object; goto free_cs_object;
} }
*signal_sob_addr_offset = cs->sob_addr_offset;
*signal_initial_sob_count = cs->initial_sob_count;
rc = HL_CS_STATUS_SUCCESS; rc = HL_CS_STATUS_SUCCESS;
if (is_wait_cs) if (is_wait_cs)
wait_cs_submitted = true; wait_cs_submitted = true;
...@@ -2225,6 +2233,7 @@ int hl_cs_ioctl(struct hl_fpriv *hpriv, void *data) ...@@ -2225,6 +2233,7 @@ int hl_cs_ioctl(struct hl_fpriv *hpriv, void *data)
void __user *chunks; void __user *chunks;
u32 num_chunks, flags, timeout, u32 num_chunks, flags, timeout,
signals_count = 0, sob_addr = 0, handle_id = 0; signals_count = 0, sob_addr = 0, handle_id = 0;
u16 sob_initial_count = 0;
int rc; int rc;
rc = hl_cs_sanity_checks(hpriv, args); rc = hl_cs_sanity_checks(hpriv, args);
...@@ -2255,7 +2264,8 @@ int hl_cs_ioctl(struct hl_fpriv *hpriv, void *data) ...@@ -2255,7 +2264,8 @@ int hl_cs_ioctl(struct hl_fpriv *hpriv, void *data)
case CS_TYPE_WAIT: case CS_TYPE_WAIT:
case CS_TYPE_COLLECTIVE_WAIT: case CS_TYPE_COLLECTIVE_WAIT:
rc = cs_ioctl_signal_wait(hpriv, cs_type, chunks, num_chunks, rc = cs_ioctl_signal_wait(hpriv, cs_type, chunks, num_chunks,
&cs_seq, args->in.cs_flags, timeout); &cs_seq, args->in.cs_flags, timeout,
&sob_addr, &sob_initial_count);
break; break;
case CS_RESERVE_SIGNALS: case CS_RESERVE_SIGNALS:
rc = cs_ioctl_reserve_signals(hpriv, rc = cs_ioctl_reserve_signals(hpriv,
...@@ -2271,20 +2281,33 @@ int hl_cs_ioctl(struct hl_fpriv *hpriv, void *data) ...@@ -2271,20 +2281,33 @@ int hl_cs_ioctl(struct hl_fpriv *hpriv, void *data)
rc = cs_ioctl_default(hpriv, chunks, num_chunks, &cs_seq, rc = cs_ioctl_default(hpriv, chunks, num_chunks, &cs_seq,
args->in.cs_flags, args->in.cs_flags,
args->in.encaps_sig_handle_id, args->in.encaps_sig_handle_id,
timeout); timeout, &sob_initial_count);
break; break;
} }
out: out:
if (rc != -EAGAIN) { if (rc != -EAGAIN) {
memset(args, 0, sizeof(*args)); memset(args, 0, sizeof(*args));
if (cs_type == CS_RESERVE_SIGNALS) { switch (cs_type) {
case CS_RESERVE_SIGNALS:
args->out.handle_id = handle_id; args->out.handle_id = handle_id;
args->out.sob_base_addr_offset = sob_addr; args->out.sob_base_addr_offset = sob_addr;
args->out.count = signals_count; args->out.count = signals_count;
} else { break;
case CS_TYPE_SIGNAL:
args->out.sob_base_addr_offset = sob_addr;
args->out.sob_count_before_submission = sob_initial_count;
args->out.seq = cs_seq;
break;
case CS_TYPE_DEFAULT:
args->out.sob_count_before_submission = sob_initial_count;
args->out.seq = cs_seq;
break;
default:
args->out.seq = cs_seq; args->out.seq = cs_seq;
break;
} }
args->out.status = rc; args->out.status = rc;
} }
......
...@@ -1545,6 +1545,9 @@ struct hl_userptr { ...@@ -1545,6 +1545,9 @@ struct hl_userptr {
* @submission_time_jiffies: submission time of the cs * @submission_time_jiffies: submission time of the cs
* @type: CS_TYPE_*. * @type: CS_TYPE_*.
* @encaps_sig_hdl_id: encaps signals handle id, set for the first staged cs. * @encaps_sig_hdl_id: encaps signals handle id, set for the first staged cs.
* @sob_addr_offset: sob offset from the configuration base address.
* @initial_sob_count: count of completed signals in SOB before current submission of signal or
* cs with encaps signals.
* @submitted: true if CS was submitted to H/W. * @submitted: true if CS was submitted to H/W.
* @completed: true if CS was completed by device. * @completed: true if CS was completed by device.
* @timedout : true if CS was timedout. * @timedout : true if CS was timedout.
...@@ -1580,6 +1583,8 @@ struct hl_cs { ...@@ -1580,6 +1583,8 @@ struct hl_cs {
u64 submission_time_jiffies; u64 submission_time_jiffies;
enum hl_cs_type type; enum hl_cs_type type;
u32 encaps_sig_hdl_id; u32 encaps_sig_hdl_id;
u32 sob_addr_offset;
u16 initial_sob_count;
u8 submitted; u8 submitted;
u8 completed; u8 completed;
u8 timedout; u8 timedout;
......
...@@ -429,6 +429,9 @@ static int init_signal_cs(struct hl_device *hdev, ...@@ -429,6 +429,9 @@ static int init_signal_cs(struct hl_device *hdev,
rc = hl_cs_signal_sob_wraparound_handler(hdev, q_idx, &hw_sob, 1, rc = hl_cs_signal_sob_wraparound_handler(hdev, q_idx, &hw_sob, 1,
false); false);
job->cs->sob_addr_offset = hw_sob->sob_addr;
job->cs->initial_sob_count = prop->next_sob_val - 1;
return rc; return rc;
} }
......
...@@ -929,9 +929,17 @@ struct hl_cs_out { ...@@ -929,9 +929,17 @@ struct hl_cs_out {
/* /*
* SOB base address offset * SOB base address offset
* Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY is set * Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY or HL_CS_FLAGS_SIGNAL is set
*/ */
__u32 sob_base_addr_offset; __u32 sob_base_addr_offset;
/*
* Count of completed signals in SOB before current signal submission.
* Valid only when (HL_CS_FLAGS_ENCAP_SIGNALS & HL_CS_FLAGS_STAGED_SUBMISSION)
* or HL_CS_FLAGS_SIGNAL is set
*/
__u16 sob_count_before_submission;
__u16 pad[3];
}; };
union hl_cs_args { union hl_cs_args {
......
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