Commit d62b9a69 authored by Ofir Bitton's avatar Ofir Bitton Committed by Oded Gabbay

habanalabs: add support for a long interrupt target value

In order to avoid user target value wraparound, we modify the
current interface so user will be able to wait for an 8-byte
target value rather than a 4-byte value.
Signed-off-by: default avatarOfir Bitton <obitton@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 027d53b0
...@@ -2739,13 +2739,13 @@ static int hl_cs_wait_ioctl(struct hl_fpriv *hpriv, void *data) ...@@ -2739,13 +2739,13 @@ static int hl_cs_wait_ioctl(struct hl_fpriv *hpriv, void *data)
static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx, static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
u32 timeout_us, u64 user_address, u32 timeout_us, u64 user_address,
u32 target_value, u16 interrupt_offset, u64 target_value, u16 interrupt_offset,
enum hl_cs_wait_status *status) enum hl_cs_wait_status *status)
{ {
struct hl_user_pending_interrupt *pend; struct hl_user_pending_interrupt *pend;
struct hl_user_interrupt *interrupt; struct hl_user_interrupt *interrupt;
unsigned long timeout, flags; unsigned long timeout, flags;
u32 completion_value; u64 completion_value;
long completion_rc; long completion_rc;
int rc = 0; int rc = 0;
...@@ -2779,7 +2779,7 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx, ...@@ -2779,7 +2779,7 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
/* We check for completion value as interrupt could have been received /* We check for completion value as interrupt could have been received
* before we added the node to the wait list * before we added the node to the wait list
*/ */
if (copy_from_user(&completion_value, u64_to_user_ptr(user_address), 4)) { if (copy_from_user(&completion_value, u64_to_user_ptr(user_address), 8)) {
dev_err(hdev->dev, "Failed to copy completion value from user\n"); dev_err(hdev->dev, "Failed to copy completion value from user\n");
rc = -EFAULT; rc = -EFAULT;
goto remove_pending_user_interrupt; goto remove_pending_user_interrupt;
...@@ -2811,7 +2811,7 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx, ...@@ -2811,7 +2811,7 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
reinit_completion(&pend->fence.completion); reinit_completion(&pend->fence.completion);
spin_unlock_irqrestore(&interrupt->wait_list_lock, flags); spin_unlock_irqrestore(&interrupt->wait_list_lock, flags);
if (copy_from_user(&completion_value, u64_to_user_ptr(user_address), 4)) { if (copy_from_user(&completion_value, u64_to_user_ptr(user_address), 8)) {
dev_err(hdev->dev, "Failed to copy completion value from user\n"); dev_err(hdev->dev, "Failed to copy completion value from user\n");
rc = -EFAULT; rc = -EFAULT;
......
...@@ -897,11 +897,7 @@ struct hl_wait_cs_in { ...@@ -897,11 +897,7 @@ struct hl_wait_cs_in {
*/ */
__u64 addr; __u64 addr;
/* Target value for completion comparison */ /* Target value for completion comparison */
__u32 target; __u64 target;
/* Absolute timeout to wait for interrupt
* in microseconds
*/
__u32 interrupt_timeout_us;
}; };
}; };
...@@ -917,7 +913,12 @@ struct hl_wait_cs_in { ...@@ -917,7 +913,12 @@ struct hl_wait_cs_in {
/* Multi CS API info- valid entries in multi-CS array */ /* Multi CS API info- valid entries in multi-CS array */
__u8 seq_arr_len; __u8 seq_arr_len;
__u8 pad[7]; __u8 pad[3];
/* Absolute timeout to wait for an interrupt in microseconds.
* Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set
*/
__u32 interrupt_timeout_us;
}; };
#define HL_WAIT_CS_STATUS_COMPLETED 0 #define HL_WAIT_CS_STATUS_COMPLETED 0
......
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