habanalabs: leave space for 2xMSG_PROT in CB
The user must leave space for 2xMSG_PROT in the external CB, so adjust the define of max size accordingly. The driver, however, can still create a CB with the maximum size of 2MB. Therefore, we need to add a check specifically for the user requested size. Reviewed-by: Tomer Tayar <ttayar@habana.ai> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
This commit is contained in:
parent
8e708af284
commit
39b425170d
|
@ -105,10 +105,9 @@ int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr,
|
|||
goto out_err;
|
||||
}
|
||||
|
||||
if (cb_size > HL_MAX_CB_SIZE) {
|
||||
dev_err(hdev->dev,
|
||||
"CB size %d must be less then %d\n",
|
||||
cb_size, HL_MAX_CB_SIZE);
|
||||
if (cb_size > SZ_2M) {
|
||||
dev_err(hdev->dev, "CB size %d must be less than %d\n",
|
||||
cb_size, SZ_2M);
|
||||
rc = -EINVAL;
|
||||
goto out_err;
|
||||
}
|
||||
|
@ -211,7 +210,7 @@ int hl_cb_ioctl(struct hl_fpriv *hpriv, void *data)
|
|||
{
|
||||
union hl_cb_args *args = data;
|
||||
struct hl_device *hdev = hpriv->hdev;
|
||||
u64 handle;
|
||||
u64 handle = 0;
|
||||
int rc;
|
||||
|
||||
if (hl_device_disabled_or_in_reset(hdev)) {
|
||||
|
@ -223,15 +222,26 @@ int hl_cb_ioctl(struct hl_fpriv *hpriv, void *data)
|
|||
|
||||
switch (args->in.op) {
|
||||
case HL_CB_OP_CREATE:
|
||||
rc = hl_cb_create(hdev, &hpriv->cb_mgr, args->in.cb_size,
|
||||
&handle, hpriv->ctx->asid);
|
||||
if (args->in.cb_size > HL_MAX_CB_SIZE) {
|
||||
dev_err(hdev->dev,
|
||||
"User requested CB size %d must be less than %d\n",
|
||||
args->in.cb_size, HL_MAX_CB_SIZE);
|
||||
rc = -EINVAL;
|
||||
} else {
|
||||
rc = hl_cb_create(hdev, &hpriv->cb_mgr,
|
||||
args->in.cb_size, &handle,
|
||||
hpriv->ctx->asid);
|
||||
}
|
||||
|
||||
memset(args, 0, sizeof(*args));
|
||||
args->out.cb_handle = handle;
|
||||
break;
|
||||
|
||||
case HL_CB_OP_DESTROY:
|
||||
rc = hl_cb_destroy(hdev, &hpriv->cb_mgr,
|
||||
args->in.cb_handle);
|
||||
break;
|
||||
|
||||
default:
|
||||
rc = -ENOTTY;
|
||||
break;
|
||||
|
|
|
@ -209,7 +209,8 @@ struct hl_info_args {
|
|||
/* Opcode to destroy previously created command buffer */
|
||||
#define HL_CB_OP_DESTROY 1
|
||||
|
||||
#define HL_MAX_CB_SIZE 0x200000 /* 2MB */
|
||||
/* 2MB minus 32 bytes for 2xMSG_PROT */
|
||||
#define HL_MAX_CB_SIZE (0x200000 - 32)
|
||||
|
||||
struct hl_cb_in {
|
||||
/* Handle of CB or 0 if we want to create one */
|
||||
|
|
Loading…
Reference in New Issue