From: Iouri Tarassov <iourit@linux.microsoft.com>
To: kys@microsoft.com, haiyangz@microsoft.com,
sthemmin@microsoft.com, wei.liu@kernel.org,
linux-hyperv@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, spronovo@microsoft.com,
spronovo@linux.microsoft.com, gregkh@linuxfoundation.org
Subject: [PATCH v3 24/30] drivers: hv: dxgkrnl: Ioctl to put device to error state
Date: Tue, 1 Mar 2022 11:46:11 -0800 [thread overview]
Message-ID: <0381fb9117e596b299d162ed54a7bb8e4e6ff559.1646163379.git.iourit@linux.microsoft.com> (raw)
In-Reply-To: <719fe06b7cbe9ac12fa4a729e810e3383ab421c1.1646163378.git.iourit@linux.microsoft.com>
Implement the ioctl to put the virtual compute device to the error
state (LX_DXMARKDEVICEASERROR).
This ioctl is used by the user mode driver when it detects an
unrecoverable error condition.
When a compute device is put to the error state, all subsequent
ioctl calls to the device will fail.
Signed-off-by: Iouri Tarassov <iourit@linux.microsoft.com>
---
drivers/hv/dxgkrnl/dxgkrnl.h | 3 +++
drivers/hv/dxgkrnl/dxgvmbus.c | 25 ++++++++++++++++++++++
drivers/hv/dxgkrnl/dxgvmbus.h | 5 +++++
drivers/hv/dxgkrnl/ioctl.c | 39 +++++++++++++++++++++++++++++++++++
include/uapi/misc/d3dkmthk.h | 12 +++++++++++
5 files changed, 84 insertions(+)
diff --git a/drivers/hv/dxgkrnl/dxgkrnl.h b/drivers/hv/dxgkrnl/dxgkrnl.h
index 875e336c11d3..03acf8ce3baa 100644
--- a/drivers/hv/dxgkrnl/dxgkrnl.h
+++ b/drivers/hv/dxgkrnl/dxgkrnl.h
@@ -836,6 +836,9 @@ int dxgvmb_send_update_alloc_property(struct dxgprocess *process,
struct d3dddi_updateallocproperty *args,
struct d3dddi_updateallocproperty *__user
inargs);
+int dxgvmb_send_mark_device_as_error(struct dxgprocess *process,
+ struct dxgadapter *adapter,
+ struct d3dkmt_markdeviceaserror *args);
int dxgvmb_send_set_allocation_priority(struct dxgprocess *process,
struct dxgadapter *adapter,
struct d3dkmt_setallocationpriority *a);
diff --git a/drivers/hv/dxgkrnl/dxgvmbus.c b/drivers/hv/dxgkrnl/dxgvmbus.c
index c76ab993e9ba..bf65599635c6 100644
--- a/drivers/hv/dxgkrnl/dxgvmbus.c
+++ b/drivers/hv/dxgkrnl/dxgvmbus.c
@@ -2708,6 +2708,31 @@ int dxgvmb_send_update_alloc_property(struct dxgprocess *process,
return ret;
}
+int dxgvmb_send_mark_device_as_error(struct dxgprocess *process,
+ struct dxgadapter *adapter,
+ struct d3dkmt_markdeviceaserror *args)
+{
+ struct dxgkvmb_command_markdeviceaserror *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_MARKDEVICEASERROR,
+ process->host_handle);
+ command->args = *args;
+ ret = dxgvmb_send_sync_msg_ntstatus(msg.channel, msg.hdr, msg.size);
+cleanup:
+ free_message(&msg, process);
+ if (ret)
+ pr_debug("err: %s %d", __func__, ret);
+ return ret;
+}
+
int dxgvmb_send_set_allocation_priority(struct dxgprocess *process,
struct dxgadapter *adapter,
struct d3dkmt_setallocationpriority *args)
diff --git a/drivers/hv/dxgkrnl/dxgvmbus.h b/drivers/hv/dxgkrnl/dxgvmbus.h
index d2d22775645b..615a163f836e 100644
--- a/drivers/hv/dxgkrnl/dxgvmbus.h
+++ b/drivers/hv/dxgkrnl/dxgvmbus.h
@@ -627,6 +627,11 @@ struct dxgkvmb_command_updateallocationproperty_return {
struct ntstatus status;
};
+struct dxgkvmb_command_markdeviceaserror {
+ struct dxgkvmb_command_vgpu_to_host hdr;
+ struct d3dkmt_markdeviceaserror args;
+};
+
/* Returns ntstatus */
struct dxgkvmb_command_changevideomemoryreservation {
struct dxgkvmb_command_vgpu_to_host hdr;
diff --git a/drivers/hv/dxgkrnl/ioctl.c b/drivers/hv/dxgkrnl/ioctl.c
index 763bd76382a0..b2cc2c6fc725 100644
--- a/drivers/hv/dxgkrnl/ioctl.c
+++ b/drivers/hv/dxgkrnl/ioctl.c
@@ -3380,6 +3380,43 @@ dxgk_update_alloc_property(struct dxgprocess *process, void *__user inargs)
return ret;
}
+static int
+dxgk_mark_device_as_error(struct dxgprocess *process, void *__user inargs)
+{
+ struct d3dkmt_markdeviceaserror args;
+ struct dxgadapter *adapter = NULL;
+ struct dxgdevice *device = NULL;
+ int ret;
+
+ pr_debug("ioctl: %s", __func__);
+ ret = copy_from_user(&args, inargs, sizeof(args));
+ if (ret) {
+ pr_err("%s failed to copy input args", __func__);
+ ret = -EINVAL;
+ goto cleanup;
+ }
+ device = dxgprocess_device_by_handle(process, args.device);
+ if (device == NULL) {
+ ret = -EINVAL;
+ goto cleanup;
+ }
+ adapter = device->adapter;
+ ret = dxgadapter_acquire_lock_shared(adapter);
+ if (ret < 0) {
+ adapter = NULL;
+ goto cleanup;
+ }
+ device->execution_state = _D3DKMT_DEVICEEXECUTION_RESET;
+ ret = dxgvmb_send_mark_device_as_error(process, adapter, &args);
+cleanup:
+ if (adapter)
+ dxgadapter_release_lock_shared(adapter);
+ if (device)
+ kref_put(&device->device_kref, dxgdevice_release);
+ pr_debug("ioctl:%s %s %d", errorstr(ret), __func__, ret);
+ return ret;
+}
+
static int
dxgk_query_alloc_residency(struct dxgprocess *process, void *__user inargs)
{
@@ -4515,6 +4552,8 @@ void init_ioctls(void)
LX_DXFLUSHHEAPTRANSITIONS);
SET_IOCTL(/*0x25 */ dxgk_lock2,
LX_DXLOCK2);
+ SET_IOCTL(/*0x26 */ dxgk_mark_device_as_error,
+ LX_DXMARKDEVICEASERROR);
SET_IOCTL(/*0x2a */ dxgk_query_alloc_residency,
LX_DXQUERYALLOCATIONRESIDENCY);
SET_IOCTL(/*0x2e */ dxgk_set_allocation_priority,
diff --git a/include/uapi/misc/d3dkmthk.h b/include/uapi/misc/d3dkmthk.h
index cf08166f4e5d..fb4ff4b905c4 100644
--- a/include/uapi/misc/d3dkmthk.h
+++ b/include/uapi/misc/d3dkmthk.h
@@ -786,6 +786,16 @@ struct d3dkmt_unlock2 {
struct d3dkmthandle allocation;
};
+enum d3dkmt_device_error_reason {
+ _D3DKMT_DEVICE_ERROR_REASON_GENERIC = 0x80000000,
+ _D3DKMT_DEVICE_ERROR_REASON_DRIVER_ERROR = 0x80000006,
+};
+
+struct d3dkmt_markdeviceaserror {
+ struct d3dkmthandle device;
+ enum d3dkmt_device_error_reason reason;
+};
+
enum d3dkmt_standardallocationtype {
_D3DKMT_STANDARDALLOCATIONTYPE_EXISTINGHEAP = 1,
_D3DKMT_STANDARDALLOCATIONTYPE_CROSSADAPTER = 2,
@@ -1286,6 +1296,8 @@ struct d3dkmt_shareobjectwithhost {
_IOWR(0x47, 0x1f, struct d3dkmt_flushheaptransitions)
#define LX_DXLOCK2 \
_IOWR(0x47, 0x25, struct d3dkmt_lock2)
+#define LX_DXMARKDEVICEASERROR \
+ _IOWR(0x47, 0x26, struct d3dkmt_markdeviceaserror)
#define LX_DXQUERYALLOCATIONRESIDENCY \
_IOWR(0x47, 0x2a, struct d3dkmt_queryallocationresidency)
#define LX_DXSETALLOCATIONPRIORITY \
--
2.35.1
next prev parent reply other threads:[~2022-03-01 19:48 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 19:45 [PATCH v3 00/30] Driver for Hyper-v virtual compute device Iouri Tarassov
2022-03-01 19:45 ` [PATCH v3 01/30] drivers: hv: dxgkrnl: Add virtual compute device VM bus channel guids Iouri Tarassov
2022-03-01 19:45 ` [PATCH v3 02/30] drivers: hv: dxgkrnl: Driver initialization and loading Iouri Tarassov
2022-03-01 20:45 ` Greg KH
2022-03-01 22:23 ` Wei Liu
2022-03-01 22:47 ` Iouri Tarassov
2022-03-02 7:54 ` Greg KH
2022-03-02 7:53 ` Greg KH
2022-03-02 11:53 ` Wei Liu
2022-03-02 18:49 ` Iouri Tarassov
2022-03-02 20:20 ` Greg KH
2022-03-02 22:27 ` Iouri Tarassov
2022-03-03 13:16 ` Greg KH
2022-03-09 23:14 ` Steve Pronovost
2022-03-10 10:13 ` Greg KH
2022-03-10 18:31 ` Steve Pronovost
2022-03-02 20:34 ` Wei Liu
2022-03-03 1:09 ` Iouri Tarassov
2022-03-03 13:22 ` Greg KH
2022-03-04 16:04 ` Wei Liu
2022-03-04 17:55 ` Greg KH
2022-03-02 22:59 ` Iouri Tarassov
2022-03-03 13:29 ` Greg KH
2022-03-02 23:27 ` Iouri Tarassov
2022-03-03 13:10 ` Greg KH
2022-03-01 22:06 ` Wei Liu
2022-03-03 2:01 ` Iouri Tarassov
2022-03-01 19:45 ` [PATCH v3 03/30] drivers: hv: dxgkrnl: Add VM bus message support, initialize VM bus channels Iouri Tarassov
2022-03-01 22:57 ` Wei Liu
2022-03-01 19:45 ` [PATCH v3 04/30] drivers: hv: dxgkrnl: Creation of dxgadapter object Iouri Tarassov
2022-03-01 23:25 ` Wei Liu
2022-03-01 19:45 ` [PATCH v3 05/30] drivers: hv: dxgkrnl: Opening of /dev/dxg device and dxgprocess creation Iouri Tarassov
2022-03-01 20:46 ` Greg KH
2022-03-01 20:46 ` Greg KH
2022-03-01 23:47 ` Wei Liu
2022-03-01 19:45 ` [PATCH v3 06/30] drivers: hv: dxgkrnl: Enumerate and open dxgadapter objects Iouri Tarassov
2022-03-02 12:43 ` Wei Liu
2022-03-01 19:45 ` [PATCH v3 07/30] drivers: hv: dxgkrnl: Creation of dxgdevice objects Iouri Tarassov
2022-03-01 19:45 ` [PATCH v3 08/30] drivers: hv: dxgkrnl: Creation of dxgcontext objects Iouri Tarassov
2022-03-02 12:59 ` Wei Liu
2022-03-01 19:45 ` [PATCH v3 09/30] drivers: hv: dxgkrnl: Creation of compute device allocations and resources Iouri Tarassov
2022-03-01 19:45 ` [PATCH v3 10/30] drivers: hv: dxgkrnl: Creation of compute device sync objects Iouri Tarassov
2022-03-02 13:25 ` Wei Liu
2022-03-01 19:45 ` [PATCH v3 11/30] drivers: hv: dxgkrnl: Operations using " Iouri Tarassov
2022-03-01 19:45 ` [PATCH v3 12/30] drivers: hv: dxgkrnl: Sharing of dxgresource objects Iouri Tarassov
2022-03-02 14:13 ` Wei Liu
2022-03-02 14:15 ` Wei Liu
2022-03-01 19:46 ` [PATCH v3 13/30] drivers: hv: dxgkrnl: Sharing of sync objects Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 14/30] drivers: hv: dxgkrnl: Creation of hardware queues. Sync object operations to hw queue Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 15/30] drivers: hv: dxgkrnl: Creation of paging queue objects Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 16/30] drivers: hv: dxgkrnl: Submit execution commands to the compute device Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 17/30] drivers: hv: dxgkrnl: Share objects with the host Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 18/30] drivers: hv: dxgkrnl: Query the dxgdevice state Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 19/30] drivers: hv: dxgkrnl: Map(unmap) CPU address to device allocation Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 20/30] drivers: hv: dxgkrnl: Manage device allocation properties Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 21/30] drivers: hv: dxgkrnl: Flush heap transitions Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 22/30] drivers: hv: dxgkrnl: Query video memory information Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 23/30] drivers: hv: dxgkrnl: The escape ioctl Iouri Tarassov
2022-03-01 19:46 ` Iouri Tarassov [this message]
2022-03-01 19:46 ` [PATCH v3 25/30] drivers: hv: dxgkrnl: Ioctls to query statistics and clock calibration Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 26/30] drivers: hv: dxgkrnl: Offer and reclaim allocations Iouri Tarassov
2022-03-02 14:25 ` Wei Liu
2022-03-02 18:13 ` Iouri Tarassov
2022-03-02 18:23 ` Wei Liu
2022-03-01 19:46 ` [PATCH v3 27/30] drivers: hv: dxgkrnl: Ioctls to manage scheduling priority Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 28/30] drivers: hv: dxgkrnl: Manage residency of allocations Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 29/30] drivers: hv: dxgkrnl: Manage compute device virtual addresses Iouri Tarassov
2022-03-01 19:46 ` [PATCH v3 30/30] drivers: hv: dxgkrnl: Add support to map guest pages by host Iouri Tarassov
2022-03-02 14:29 ` Wei Liu
2022-03-01 21:37 ` [PATCH v3 01/30] drivers: hv: dxgkrnl: Add virtual compute device VM bus channel guids Wei Liu
2022-03-02 8:51 ` [PATCH v3 00/30] Driver for Hyper-v virtual compute device Christoph Hellwig
2022-03-02 14:53 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0381fb9117e596b299d162ed54a7bb8e4e6ff559.1646163379.git.iourit@linux.microsoft.com \
--to=iourit@linux.microsoft.com \
--cc=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=spronovo@linux.microsoft.com \
--cc=spronovo@microsoft.com \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox