* showing it to users.
* @ack_protection_bits_errors: ack and dump all security violations
* @get_hw_block_id: retrieve a HW block id to be used by the user to mmap it.
+ * also returns the size of the block if caller supplies
+ * a valid pointer for it
* @hw_block_mmap: mmap a HW block with a given id.
* @enable_events_from_fw: send interrupt to firmware to notify them the
* driver is ready to receive asynchronous events. This
u64 (*descramble_addr)(struct hl_device *hdev, u64 addr);
void (*ack_protection_bits_errors)(struct hl_device *hdev);
int (*get_hw_block_id)(struct hl_device *hdev, u64 block_addr,
- u32 *block_id);
+ u32 *block_size, u32 *block_id);
int (*hw_block_mmap)(struct hl_device *hdev, struct vm_area_struct *vma,
u32 block_id, u32 block_size);
void (*enable_events_from_fw)(struct hl_device *hdev);
return rc;
}
-static int map_block(struct hl_device *hdev, u64 address, u64 *handle)
+static int map_block(struct hl_device *hdev, u64 address, u64 *handle,
+ u32 *size)
{
u32 block_id = 0;
int rc;
- rc = hdev->asic_funcs->get_hw_block_id(hdev, address, &block_id);
+ rc = hdev->asic_funcs->get_hw_block_id(hdev, address, size, &block_id);
*handle = block_id | HL_MMAP_TYPE_BLOCK;
*handle <<= PAGE_SHIFT;
struct hl_device *hdev = hpriv->hdev;
struct hl_ctx *ctx = hpriv->ctx;
u64 block_handle, device_addr = 0;
- u32 handle = 0;
+ u32 handle = 0, block_size;
int rc;
switch (args->in.op) {
case HL_MEM_OP_MAP_BLOCK:
rc = map_block(hdev, args->in.map_block.block_addr,
- &block_handle);
- args->out.handle = block_handle;
+ &block_handle, &block_size);
+ args->out.block_handle = block_handle;
+ args->out.block_size = block_size;
break;
default:
struct hl_device *hdev = hpriv->hdev;
struct hl_ctx *ctx = hpriv->ctx;
u64 block_handle, device_addr = 0;
- u32 handle = 0;
+ u32 handle = 0, block_size;
int rc;
if (!hl_device_operational(hdev, &status)) {
case HL_MEM_OP_MAP_BLOCK:
rc = map_block(hdev, args->in.map_block.block_addr,
- &block_handle);
- args->out.handle = block_handle;
+ &block_handle, &block_size);
+ args->out.block_handle = block_handle;
+ args->out.block_size = block_size;
break;
default:
}
static int gaudi_get_hw_block_id(struct hl_device *hdev, u64 block_addr,
- u32 *block_id)
+ u32 *block_size, u32 *block_id)
{
return -EPERM;
}
}
static int goya_get_hw_block_id(struct hl_device *hdev, u64 block_addr,
- u32 *block_id)
+ u32 *block_size, u32 *block_id)
{
return -EPERM;
}
/* HL_MEM_OP_MAP_BLOCK - map a hw block */
struct {
/*
- * HW block address to map, a handle will be returned
- * to the user and will be used to mmap the relevant
- * block. Only addresses from configuration space are
- * allowed.
+ * HW block address to map, a handle and size will be
+ * returned to the user and will be used to mmap the
+ * relevant block. Only addresses from configuration
+ * space are allowed.
*/
__u64 block_addr;
} map_block;
__u64 device_virt_addr;
/*
- * Used for HL_MEM_OP_ALLOC and HL_MEM_OP_MAP_BLOCK.
+ * Used in HL_MEM_OP_ALLOC
* This is the assigned handle for the allocated memory
- * or mapped block
*/
__u64 handle;
+
+ struct {
+ /*
+ * Used in HL_MEM_OP_MAP_BLOCK.
+ * This is the assigned handle for the mapped block
+ */
+ __u64 block_handle;
+
+ /*
+ * Used in HL_MEM_OP_MAP_BLOCK
+ * This is the size of the mapped block
+ */
+ __u32 block_size;
+
+ __u32 pad;
+ };
};
};