From: Eric Curtin <ericcurtin17@gmail.com>
To: linux-hyperv@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, iourit@linux.microsoft.com,
wei.liu@kernel.org, decui@microsoft.com, haiyangz@microsoft.com
Subject: [PATCH 43/55] drivers: hv: dxgkrnl: Implement D3DDKMTIsFeatureEnabled API
Date: Thu, 19 Mar 2026 20:24:57 +0000 [thread overview]
Message-ID: <20260319202509.63802-44-eric.curtin@docker.com> (raw)
In-Reply-To: <20260319202509.63802-1-eric.curtin@docker.com>
From: Iouri Tarassov <iourit@linux.microsoft.com>
D3DKMTIsFeatureEnabled is used to query if a particular feature is
supported by the given adapter.
Signed-off-by: Iouri Tarassov <iourit@linux.microsoft.com>
[kms: forward port to 6.6 from 6.1. No code changes made.]
Signed-off-by: Kelsey Steele <kelseysteele@microsoft.com>
---
drivers/hv/dxgkrnl/dxgkrnl.h | 2 ++
drivers/hv/dxgkrnl/dxgvmbus.c | 58 ++++++++++++++++++++++++++++++++---
drivers/hv/dxgkrnl/dxgvmbus.h | 31 +++++++++++++++++++
drivers/hv/dxgkrnl/ioctl.c | 46 +++++++++++++++++++++++++++
include/uapi/misc/d3dkmthk.h | 31 ++++++++++++++++++-
5 files changed, 163 insertions(+), 5 deletions(-)
diff --git a/drivers/hv/dxgkrnl/dxgkrnl.h b/drivers/hv/dxgkrnl/dxgkrnl.h
index 90bcd5377744..ebf81cffa289 100644
--- a/drivers/hv/dxgkrnl/dxgkrnl.h
+++ b/drivers/hv/dxgkrnl/dxgkrnl.h
@@ -994,6 +994,8 @@ int dxgvmb_send_share_object_with_host(struct dxgprocess *process,
int dxgvmb_send_invalidate_cache(struct dxgprocess *process,
struct dxgadapter *adapter,
struct d3dkmt_invalidatecache *args);
+int dxgvmb_send_is_feature_enabled(struct dxgadapter *adapter,
+ struct d3dkmt_isfeatureenabled *args);
void signal_host_cpu_event(struct dxghostevent *eventhdr);
int ntstatus2int(struct ntstatus status);
diff --git a/drivers/hv/dxgkrnl/dxgvmbus.c b/drivers/hv/dxgkrnl/dxgvmbus.c
index 916ed9071656..2436e1a7bc73 100644
--- a/drivers/hv/dxgkrnl/dxgvmbus.c
+++ b/drivers/hv/dxgkrnl/dxgvmbus.c
@@ -135,15 +135,16 @@ static int init_message_res(struct dxgvmbusmsgres *msg,
if (use_ext_header) {
msg->msg = (char *)&msg->hdr[1];
msg->hdr->command_offset = sizeof(msg->hdr[0]);
- msg->hdr->vgpu_luid = adapter->host_vgpu_luid;
+ if (adapter)
+ msg->hdr->vgpu_luid = adapter->host_vgpu_luid;
} else {
msg->msg = (char *)msg->hdr;
}
msg->res = (char *)msg->hdr + msg->size;
- if (dxgglobal->async_msg_enabled)
- msg->channel = &dxgglobal->channel;
- else
+ if (adapter && !dxgglobal->async_msg_enabled)
msg->channel = &adapter->channel;
+ else
+ msg->channel = &dxgglobal->channel;
return 0;
}
@@ -2049,6 +2050,55 @@ int dxgvmb_send_invalidate_cache(struct dxgprocess *process,
return ret;
}
+int dxgvmb_send_is_feature_enabled(struct dxgadapter *adapter,
+ struct d3dkmt_isfeatureenabled *args)
+{
+ int ret;
+ struct dxgkvmb_command_isfeatureenabled_return *result;
+ struct dxgvmbusmsgres msg = {.hdr = NULL};
+ int res_size = sizeof(*result);
+
+ if (adapter) {
+ struct dxgkvmb_command_isfeatureenabled *command;
+
+ ret = init_message_res(&msg, adapter, sizeof(*command),
+ res_size);
+ if (ret)
+ goto cleanup;
+ command = (void *)msg.msg;
+ command->feature_id = args->feature_id;
+ result = msg.res;
+ command_vgpu_to_host_init1(&command->hdr,
+ DXGK_VMBCOMMAND_ISFEATUREENABLED);
+ } else {
+ struct dxgkvmb_command_isfeatureenabled_gbl *command;
+
+ ret = init_message_res(&msg, adapter, sizeof(*command),
+ res_size);
+ if (ret)
+ goto cleanup;
+ command = (void *)msg.msg;
+ command->feature_id = args->feature_id;
+ result = msg.res;
+ command_vm_to_host_init1(&command->hdr,
+ DXGK_VMBCOMMAND_ISFEATUREENABLED_GLOBAL);
+ }
+ ret = dxgvmb_send_sync_msg(msg.channel, msg.hdr, msg.size,
+ result, res_size);
+ if (ret == 0) {
+ ret = ntstatus2int(result->status);
+ if (ret == 0)
+ args->result = result->result;
+ goto cleanup;
+ }
+
+cleanup:
+ free_message((struct dxgvmbusmsg *)&msg);
+ if (ret)
+ DXG_TRACE("err: %d", ret);
+ return ret;
+}
+
int dxgvmb_send_query_alloc_residency(struct dxgprocess *process,
struct dxgadapter *adapter,
struct d3dkmt_queryallocationresidency
diff --git a/drivers/hv/dxgkrnl/dxgvmbus.h b/drivers/hv/dxgkrnl/dxgvmbus.h
index 20c562b485de..a7e625b2f896 100644
--- a/drivers/hv/dxgkrnl/dxgvmbus.h
+++ b/drivers/hv/dxgkrnl/dxgvmbus.h
@@ -48,6 +48,7 @@ enum dxgkvmb_commandtype_global {
DXGK_VMBCOMMAND_SETIOSPACEREGION = 1010,
DXGK_VMBCOMMAND_COMPLETETRANSACTION = 1011,
DXGK_VMBCOMMAND_SHAREOBJECTWITHHOST = 1021,
+ DXGK_VMBCOMMAND_ISFEATUREENABLED_GLOBAL = 1022,
DXGK_VMBCOMMAND_INVALID_VM_TO_HOST
};
@@ -126,6 +127,7 @@ enum dxgkvmb_commandtype {
DXGK_VMBCOMMAND_LOGEVENT = 65,
DXGK_VMBCOMMAND_SETEXISTINGSYSMEMPAGES = 66,
DXGK_VMBCOMMAND_INVALIDATECACHE = 67,
+ DXGK_VMBCOMMAND_ISFEATUREENABLED = 68,
DXGK_VMBCOMMAND_INVALID
};
@@ -871,6 +873,35 @@ struct dxgkvmb_command_shareobjectwithhost_return {
u64 vail_nt_handle;
};
+struct dxgk_feature_desc {
+ u16 min_supported_version;
+ u16 max_supported_version;
+ struct {
+ u16 supported : 1;
+ u16 virtualization_mode : 3;
+ u16 global : 1;
+ u16 driver_feature : 1;
+ u16 internal : 1;
+ u16 reserved : 9;
+ };
+};
+
+struct dxgkvmb_command_isfeatureenabled {
+ struct dxgkvmb_command_vgpu_to_host hdr;
+ enum dxgk_feature_id feature_id;
+};
+
+struct dxgkvmb_command_isfeatureenabled_gbl {
+ struct dxgkvmb_command_vm_to_host hdr;
+ enum dxgk_feature_id feature_id;
+};
+
+struct dxgkvmb_command_isfeatureenabled_return {
+ struct ntstatus status;
+ struct dxgk_feature_desc descriptor;
+ struct dxgk_isfeatureenabled_result result;
+};
+
int
dxgvmb_send_sync_msg(struct dxgvmbuschannel *channel,
void *command, u32 command_size, void *result,
diff --git a/drivers/hv/dxgkrnl/ioctl.c b/drivers/hv/dxgkrnl/ioctl.c
index 24b84be2fb73..5ff4b27af19d 100644
--- a/drivers/hv/dxgkrnl/ioctl.c
+++ b/drivers/hv/dxgkrnl/ioctl.c
@@ -5318,6 +5318,51 @@ dxgkio_enum_processes(struct dxgprocess *process, void *__user inargs)
return ret;
}
+static int
+dxgkio_is_feature_enabled(struct dxgprocess *process, void *__user inargs)
+{
+ struct d3dkmt_isfeatureenabled args;
+ struct dxgadapter *adapter = NULL;
+ struct dxgglobal *dxgglobal = dxggbl();
+ struct d3dkmt_isfeatureenabled *__user uargs = inargs;
+ int ret;
+
+ ret = copy_from_user(&args, inargs, sizeof(args));
+ if (ret) {
+ DXG_ERR("failed to copy input args");
+ ret = -EFAULT;
+ goto cleanup;
+ }
+
+ adapter = dxgprocess_adapter_by_handle(process, args.adapter);
+ if (adapter == NULL) {
+ ret = -EINVAL;
+ goto cleanup;
+ }
+
+ if (adapter) {
+ ret = dxgadapter_acquire_lock_shared(adapter);
+ if (ret < 0)
+ goto cleanup;
+ }
+
+ ret = dxgvmb_send_is_feature_enabled(adapter, &args);
+ if (ret)
+ goto cleanup;
+
+ ret = copy_to_user(&uargs->result, &args.result, sizeof(args.result));
+
+cleanup:
+
+ if (adapter) {
+ dxgadapter_release_lock_shared(adapter);
+ kref_put(&adapter->adapter_kref, dxgadapter_release);
+ }
+
+ DXG_TRACE_IOCTL_END(ret);
+ return ret;
+}
+
static struct ioctl_desc ioctls[] = {
/* 0x00 */ {},
/* 0x01 */ {dxgkio_open_adapter_from_luid, LX_DXOPENADAPTERFROMLUID},
@@ -5406,6 +5451,7 @@ static struct ioctl_desc ioctls[] = {
/* 0x47 */ {dxgkio_open_syncobj_from_syncfile,
LX_DXOPENSYNCOBJECTFROMSYNCFILE},
/* 0x48 */ {dxgkio_enum_processes, LX_DXENUMPROCESSES},
+/* 0x49 */ {dxgkio_is_feature_enabled, LX_ISFEATUREENABLED},
};
/*
diff --git a/include/uapi/misc/d3dkmthk.h b/include/uapi/misc/d3dkmthk.h
index f9f817060fa9..5b345ddaf66e 100644
--- a/include/uapi/misc/d3dkmthk.h
+++ b/include/uapi/misc/d3dkmthk.h
@@ -1580,7 +1580,7 @@ struct d3dkmt_opensyncobjectfromsyncfile {
__u64 fence_value_gpu_va; /* out */
};
- struct d3dkmt_enumprocesses {
+struct d3dkmt_enumprocesses {
struct winluid adapter_luid;
#ifdef __KERNEL__
__u32 *buffer;
@@ -1590,6 +1590,33 @@ struct d3dkmt_opensyncobjectfromsyncfile {
__u64 buffer_count;
};
+enum dxgk_feature_id {
+ _DXGK_FEATURE_HWSCH = 0,
+ _DXGK_FEATURE_PAGE_BASED_MEMORY_MANAGER = 32,
+ _DXGK_FEATURE_KERNEL_MODE_TESTING = 33,
+ _DXGK_FEATURE_MAX
+};
+
+struct dxgk_isfeatureenabled_result {
+ __u16 version;
+ union {
+ struct {
+ __u16 enabled : 1;
+ __u16 known_feature : 1;
+ __u16 supported_by_driver : 1;
+ __u16 supported_on_config : 1;
+ __u16 reserved : 12;
+ };
+ __u16 value;
+ };
+};
+
+struct d3dkmt_isfeatureenabled {
+ struct d3dkmthandle adapter;
+ enum dxgk_feature_id feature_id;
+ struct dxgk_isfeatureenabled_result result;
+};
+
struct d3dkmt_invalidatecache {
struct d3dkmthandle device;
struct d3dkmthandle allocation;
@@ -1730,5 +1757,7 @@ struct d3dkmt_invalidatecache {
_IOWR(0x47, 0x47, struct d3dkmt_opensyncobjectfromsyncfile)
#define LX_DXENUMPROCESSES \
_IOWR(0x47, 0x48, struct d3dkmt_enumprocesses)
+#define LX_ISFEATUREENABLED \
+ _IOWR(0x47, 0x49, struct d3dkmt_isfeatureenabled)
#endif /* _D3DKMTHK_H */
next prev parent reply other threads:[~2026-03-19 20:26 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 20:24 [PATCH v4 00/55] drivers: hv: dxgkrnl: Driver for Hyper-V virtual compute device Eric Curtin
2026-03-19 20:24 ` [PATCH 01/55] drivers: hv: dxgkrnl: Driver initialization and loading Eric Curtin
2026-03-19 20:24 ` [PATCH 02/55] drivers: hv: dxgkrnl: Add VMBus message support, initialize VMBus channels Eric Curtin
2026-03-19 20:24 ` [PATCH 03/55] drivers: hv: dxgkrnl: Creation of dxgadapter object Eric Curtin
2026-03-19 20:24 ` [PATCH 04/55] drivers: hv: dxgkrnl: Opening of /dev/dxg device and dxgprocess creation Eric Curtin
2026-03-19 20:24 ` [PATCH 05/55] drivers: hv: dxgkrnl: Enumerate and open dxgadapter objects Eric Curtin
2026-03-19 20:24 ` [PATCH 06/55] drivers: hv: dxgkrnl: Creation of dxgdevice objects Eric Curtin
2026-03-19 20:24 ` [PATCH 07/55] drivers: hv: dxgkrnl: Creation of dxgcontext objects Eric Curtin
2026-03-19 20:24 ` [PATCH 08/55] drivers: hv: dxgkrnl: Creation of compute device allocations and resources Eric Curtin
2026-03-19 20:24 ` [PATCH 09/55] drivers: hv: dxgkrnl: Creation of compute device sync objects Eric Curtin
2026-03-19 20:24 ` [PATCH 10/55] drivers: hv: dxgkrnl: Operations using " Eric Curtin
2026-03-19 20:24 ` [PATCH 11/55] drivers: hv: dxgkrnl: Sharing of dxgresource objects Eric Curtin
2026-03-19 20:24 ` [PATCH 12/55] drivers: hv: dxgkrnl: Sharing of sync objects Eric Curtin
2026-03-19 20:24 ` [PATCH 13/55] drivers: hv: dxgkrnl: Creation of paging queue objects Eric Curtin
2026-03-19 20:24 ` [PATCH 14/55] drivers: hv: dxgkrnl: Submit execution commands to the compute device Eric Curtin
2026-03-19 20:24 ` [PATCH 15/55] drivers: hv: dxgkrnl: Share objects with the host Eric Curtin
2026-03-19 20:24 ` [PATCH 16/55] drivers: hv: dxgkrnl: Query the dxgdevice state Eric Curtin
2026-03-19 20:24 ` [PATCH 17/55] drivers: hv: dxgkrnl: Map(unmap) CPU address to device allocation Eric Curtin
2026-03-19 20:24 ` [PATCH 18/55] drivers: hv: dxgkrnl: Manage device allocation properties Eric Curtin
2026-03-19 20:24 ` [PATCH 19/55] drivers: hv: dxgkrnl: Flush heap transitions Eric Curtin
2026-03-19 20:24 ` [PATCH 20/55] drivers: hv: dxgkrnl: Query video memory information Eric Curtin
2026-03-19 20:24 ` [PATCH 21/55] drivers: hv: dxgkrnl: The escape ioctl Eric Curtin
2026-03-19 20:24 ` [PATCH 22/55] drivers: hv: dxgkrnl: Ioctl to put device to error state Eric Curtin
2026-03-19 20:24 ` [PATCH 23/55] drivers: hv: dxgkrnl: Ioctls to query statistics and clock calibration Eric Curtin
2026-03-19 20:24 ` [PATCH 24/55] drivers: hv: dxgkrnl: Offer and reclaim allocations Eric Curtin
2026-03-19 20:24 ` [PATCH 25/55] drivers: hv: dxgkrnl: Ioctls to manage scheduling priority Eric Curtin
2026-03-19 20:24 ` [PATCH 26/55] drivers: hv: dxgkrnl: Manage residency of allocations Eric Curtin
2026-03-19 20:24 ` [PATCH 27/55] drivers: hv: dxgkrnl: Manage compute device virtual addresses Eric Curtin
2026-03-19 20:24 ` [PATCH 28/55] drivers: hv: dxgkrnl: Add support to map guest pages by host Eric Curtin
2026-03-19 20:24 ` [PATCH 29/55] drivers: hv: dxgkrnl: Removed struct vmbus_gpadl, which was defined in the main linux branch Eric Curtin
2026-03-19 20:24 ` [PATCH 30/55] drivers: hv: dxgkrnl: Remove dxgk_init_ioctls Eric Curtin
2026-03-19 20:24 ` [PATCH 31/55] drivers: hv: dxgkrnl: Creation of dxgsyncfile objects Eric Curtin
2026-03-19 20:24 ` [PATCH 32/55] drivers: hv: dxgkrnl: Use tracing instead of dev_dbg Eric Curtin
2026-03-19 20:24 ` [PATCH 33/55] drivers: hv: dxgkrnl: Implement D3DKMTWaitSyncFile Eric Curtin
2026-03-19 20:24 ` [PATCH 34/55] drivers: hv: dxgkrnl: Improve tracing and return values from copy from user Eric Curtin
2026-03-19 20:24 ` [PATCH 35/55] drivers: hv: dxgkrnl: Fix synchronization locks Eric Curtin
2026-03-19 20:24 ` [PATCH 36/55] drivers: hv: dxgkrnl: Close shared file objects in case of a failure Eric Curtin
2026-03-19 20:24 ` [PATCH 37/55] drivers: hv: dxgkrnl: Added missed NULL check for resource object Eric Curtin
2026-03-19 20:24 ` [PATCH 38/55] drivers: hv: dxgkrnl: Fixed dxgkrnl to build for the 6.1 kernel Eric Curtin
2026-03-19 20:24 ` [PATCH 39/55] drivers: hv: dxgkrnl: Added support for compute only adapters Eric Curtin
2026-03-19 20:24 ` [PATCH 40/55] drivers: hv: dxgkrnl: Added implementation for D3DKMTInvalidateCache Eric Curtin
2026-03-19 20:24 ` [PATCH 41/55] drivers: hv: dxgkrnl: Handle process ID in D3DKMTQueryStatistics Eric Curtin
2026-03-19 20:24 ` [PATCH 42/55] drivers: hv: dxgkrnl: Implement the D3DKMTEnumProcesses API Eric Curtin
2026-03-19 20:24 ` Eric Curtin [this message]
2026-03-19 20:24 ` [PATCH 44/55] drivers: hv: dxgkrnl: Implement known escapes Eric Curtin
2026-03-19 20:24 ` [PATCH 45/55] drivers: hv: dxgkrnl: Fixed coding style issues Eric Curtin
2026-03-19 20:25 ` [PATCH 46/55] drivers: hv: dxgkrnl: Fixed the implementation of D3DKMTQueryClockCalibration Eric Curtin
2026-03-19 20:25 ` [PATCH 47/55] drivers: hv: dxgkrnl: Retry sending a VM bus packet when there is no place in the ring buffer Eric Curtin
2026-03-19 20:25 ` [PATCH 48/55] drivers: hv: dxgkrnl: Add support for locking a shared allocation by not the owner Eric Curtin
2026-03-19 20:25 ` [PATCH 49/55] drivers: hv: dxgkrnl: Fix build breaks when switching to 6.6 kernel due to hv_driver remove callback change Eric Curtin
2026-03-19 20:25 ` [PATCH 50/55] drivers: hv: dxgkrnl: Fix build breaks when switching to 6.6 kernel due to removed uuid_le_cmp Eric Curtin
2026-03-19 20:25 ` [PATCH 51/55] drivers: hv: dxgkrnl: Implement D3DKMTEnumProcesses to match the Windows implementation Eric Curtin
2026-03-19 20:25 ` [PATCH 52/55] drivers: hv: dxgkrnl: Use pin_user_pages instead of get_user_pages for DMA accessible memory Eric Curtin
2026-03-19 20:25 ` [PATCH 53/55] drivers: hv: dxgkrnl: Do not print error messages when virtual GPU is not present Eric Curtin
2026-03-19 20:25 ` [PATCH 54/55] drivers: hv: dxgkrnl: Fix crash at hmgrtable_free_handle Eric Curtin
2026-03-19 20:25 ` [PATCH 55/55] drivers: hv: dxgkrnl: Code cleanup for upstream submission Eric Curtin
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=20260319202509.63802-44-eric.curtin@docker.com \
--to=ericcurtin17@gmail.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=iourit@linux.microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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