drivers: hv: dxgkrnl: Flush heap transitions
Implement the ioctl to flush heap transitions (LX_DXFLUSHHEAPTRANSITIONS). The ioctl is used to ensure that the video memory manager on the host flushes all internal operations. Signed-off-by: Iouri Tarassov <iourit@linux.microsoft.com>
This commit is contained in:
Родитель
77bf29aa37
Коммит
bcd35de6f4
|
@ -942,7 +942,7 @@ else
|
||||||
if (alloc->priv_drv_data)
|
if (alloc->priv_drv_data)
|
||||||
vfree(alloc->priv_drv_data);
|
vfree(alloc->priv_drv_data);
|
||||||
if (alloc->cpu_address_mapped)
|
if (alloc->cpu_address_mapped)
|
||||||
pr_err("Alloc IO space is mapped: %p", alloc);
|
DXG_ERR("Alloc IO space is mapped: %p", alloc);
|
||||||
kfree(alloc);
|
kfree(alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -882,6 +882,9 @@ int dxgvmb_send_query_adapter_info(struct dxgprocess *process,
|
||||||
int dxgvmb_send_submit_command_hwqueue(struct dxgprocess *process,
|
int dxgvmb_send_submit_command_hwqueue(struct dxgprocess *process,
|
||||||
struct dxgadapter *adapter,
|
struct dxgadapter *adapter,
|
||||||
struct d3dkmt_submitcommandtohwqueue *a);
|
struct d3dkmt_submitcommandtohwqueue *a);
|
||||||
|
int dxgvmb_send_flush_heap_transitions(struct dxgprocess *process,
|
||||||
|
struct dxgadapter *adapter,
|
||||||
|
struct d3dkmt_flushheaptransitions *arg);
|
||||||
int dxgvmb_send_open_sync_object_nt(struct dxgprocess *process,
|
int dxgvmb_send_open_sync_object_nt(struct dxgprocess *process,
|
||||||
struct dxgvmbuschannel *channel,
|
struct dxgvmbuschannel *channel,
|
||||||
struct d3dkmt_opensyncobjectfromnthandle2
|
struct d3dkmt_opensyncobjectfromnthandle2
|
||||||
|
|
|
@ -1829,6 +1829,29 @@ cleanup:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dxgvmb_send_flush_heap_transitions(struct dxgprocess *process,
|
||||||
|
struct dxgadapter *adapter,
|
||||||
|
struct d3dkmt_flushheaptransitions *args)
|
||||||
|
{
|
||||||
|
struct dxgkvmb_command_flushheaptransitions *command;
|
||||||
|
int ret;
|
||||||
|
struct dxgvmbusmsg msg = {.hdr = NULL};
|
||||||
|
|
||||||
|
ret = init_message(&msg, adapter, process, sizeof(*command));
|
||||||
|
if (ret)
|
||||||
|
goto cleanup;
|
||||||
|
command = (void *)msg.msg;
|
||||||
|
command_vgpu_to_host_init2(&command->hdr,
|
||||||
|
DXGK_VMBCOMMAND_FLUSHHEAPTRANSITIONS,
|
||||||
|
process->host_handle);
|
||||||
|
ret = dxgvmb_send_sync_msg_ntstatus(msg.channel, msg.hdr, msg.size);
|
||||||
|
cleanup:
|
||||||
|
free_message(&msg, process);
|
||||||
|
if (ret)
|
||||||
|
DXG_TRACE("err: %d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int dxgvmb_send_query_alloc_residency(struct dxgprocess *process,
|
int dxgvmb_send_query_alloc_residency(struct dxgprocess *process,
|
||||||
struct dxgadapter *adapter,
|
struct dxgadapter *adapter,
|
||||||
struct d3dkmt_queryallocationresidency
|
struct d3dkmt_queryallocationresidency
|
||||||
|
|
|
@ -367,6 +367,11 @@ struct dxgkvmb_command_submitcommandtohwqueue {
|
||||||
/* PrivateDriverData */
|
/* PrivateDriverData */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Returns ntstatus */
|
||||||
|
struct dxgkvmb_command_flushheaptransitions {
|
||||||
|
struct dxgkvmb_command_vgpu_to_host hdr;
|
||||||
|
};
|
||||||
|
|
||||||
struct dxgkvmb_command_createallocation_allocinfo {
|
struct dxgkvmb_command_createallocation_allocinfo {
|
||||||
u32 flags;
|
u32 flags;
|
||||||
u32 priv_drv_data_size;
|
u32 priv_drv_data_size;
|
||||||
|
|
|
@ -3500,6 +3500,53 @@ cleanup:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dxgkio_flush_heap_transitions(struct dxgprocess *process, void *__user inargs)
|
||||||
|
{
|
||||||
|
struct d3dkmt_flushheaptransitions args;
|
||||||
|
int ret;
|
||||||
|
struct dxgadapter *adapter = NULL;
|
||||||
|
bool adapter_locked = false;
|
||||||
|
|
||||||
|
ret = copy_from_user(&args, inargs, sizeof(args));
|
||||||
|
if (ret) {
|
||||||
|
DXG_ERR("failed to copy input args");
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
adapter = dxgprocess_adapter_by_handle(process, args.adapter);
|
||||||
|
if (adapter == NULL) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = dxgadapter_acquire_lock_shared(adapter);
|
||||||
|
if (ret < 0) {
|
||||||
|
adapter = NULL;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
adapter_locked = true;
|
||||||
|
|
||||||
|
args.adapter = adapter->host_handle;
|
||||||
|
ret = dxgvmb_send_flush_heap_transitions(process, adapter, &args);
|
||||||
|
if (ret < 0)
|
||||||
|
goto cleanup;
|
||||||
|
ret = copy_to_user(inargs, &args, sizeof(args));
|
||||||
|
if (ret) {
|
||||||
|
DXG_ERR("failed to copy output args");
|
||||||
|
ret = -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
|
||||||
|
if (adapter_locked)
|
||||||
|
dxgadapter_release_lock_shared(adapter);
|
||||||
|
if (adapter)
|
||||||
|
kref_put(&adapter->adapter_kref, dxgadapter_release);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dxgkio_get_device_state(struct dxgprocess *process, void *__user inargs)
|
dxgkio_get_device_state(struct dxgprocess *process, void *__user inargs)
|
||||||
{
|
{
|
||||||
|
@ -4262,7 +4309,7 @@ static struct ioctl_desc ioctls[] = {
|
||||||
/* 0x1c */ {dxgkio_destroy_paging_queue, LX_DXDESTROYPAGINGQUEUE},
|
/* 0x1c */ {dxgkio_destroy_paging_queue, LX_DXDESTROYPAGINGQUEUE},
|
||||||
/* 0x1d */ {dxgkio_destroy_sync_object, LX_DXDESTROYSYNCHRONIZATIONOBJECT},
|
/* 0x1d */ {dxgkio_destroy_sync_object, LX_DXDESTROYSYNCHRONIZATIONOBJECT},
|
||||||
/* 0x1e */ {},
|
/* 0x1e */ {},
|
||||||
/* 0x1f */ {},
|
/* 0x1f */ {dxgkio_flush_heap_transitions, LX_DXFLUSHHEAPTRANSITIONS},
|
||||||
/* 0x20 */ {},
|
/* 0x20 */ {},
|
||||||
/* 0x21 */ {},
|
/* 0x21 */ {},
|
||||||
/* 0x22 */ {},
|
/* 0x22 */ {},
|
||||||
|
|
|
@ -936,6 +936,10 @@ struct d3dkmt_queryadapterinfo {
|
||||||
__u32 private_data_size;
|
__u32 private_data_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct d3dkmt_flushheaptransitions {
|
||||||
|
struct d3dkmthandle adapter;
|
||||||
|
};
|
||||||
|
|
||||||
struct d3dddi_openallocationinfo2 {
|
struct d3dddi_openallocationinfo2 {
|
||||||
struct d3dkmthandle allocation;
|
struct d3dkmthandle allocation;
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
@ -1228,6 +1232,8 @@ struct d3dkmt_shareobjectwithhost {
|
||||||
_IOWR(0x47, 0x19, struct d3dkmt_destroydevice)
|
_IOWR(0x47, 0x19, struct d3dkmt_destroydevice)
|
||||||
#define LX_DXDESTROYSYNCHRONIZATIONOBJECT \
|
#define LX_DXDESTROYSYNCHRONIZATIONOBJECT \
|
||||||
_IOWR(0x47, 0x1d, struct d3dkmt_destroysynchronizationobject)
|
_IOWR(0x47, 0x1d, struct d3dkmt_destroysynchronizationobject)
|
||||||
|
#define LX_DXFLUSHHEAPTRANSITIONS \
|
||||||
|
_IOWR(0x47, 0x1f, struct d3dkmt_flushheaptransitions)
|
||||||
#define LX_DXLOCK2 \
|
#define LX_DXLOCK2 \
|
||||||
_IOWR(0x47, 0x25, struct d3dkmt_lock2)
|
_IOWR(0x47, 0x25, struct d3dkmt_lock2)
|
||||||
#define LX_DXQUERYALLOCATIONRESIDENCY \
|
#define LX_DXQUERYALLOCATIONRESIDENCY \
|
||||||
|
|
Загрузка…
Ссылка в новой задаче