Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add support for bind immediate and bind readonly flags in xe path #717

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,12 @@ uint64_t IoctlHelperXe::getFlagsForVmBind(bool bindCapture, bool bindImmediate,
if (bindCapture) {
ret |= DRM_XE_VM_BIND_FLAG_DUMPABLE;
}
if (bindImmediate) {
ret |= DRM_XE_VM_BIND_FLAG_IMMEDIATE;
}
if (readOnlyResource) {
ret |= DRM_XE_VM_BIND_FLAG_READONLY;
}
return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,16 @@ TEST(IoctlHelperXeTest, whenGettingFlagsForVmBindThenPropertValueIsReturned) {
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);

EXPECT_EQ(static_cast<uint64_t>(DRM_XE_VM_BIND_FLAG_DUMPABLE), xeIoctlHelper->getFlagsForVmBind(true, true, true, true));
EXPECT_EQ(static_cast<uint64_t>(0), xeIoctlHelper->getFlagsForVmBind(false, true, true, true));
EXPECT_EQ(static_cast<uint64_t>(DRM_XE_VM_BIND_FLAG_DUMPABLE | DRM_XE_VM_BIND_FLAG_IMMEDIATE | DRM_XE_VM_BIND_FLAG_READONLY), xeIoctlHelper->getFlagsForVmBind(true, true, true, true));
EXPECT_EQ(static_cast<uint64_t>(DRM_XE_VM_BIND_FLAG_DUMPABLE | DRM_XE_VM_BIND_FLAG_IMMEDIATE), xeIoctlHelper->getFlagsForVmBind(true, true, true, false));
EXPECT_EQ(static_cast<uint64_t>(DRM_XE_VM_BIND_FLAG_DUMPABLE | DRM_XE_VM_BIND_FLAG_IMMEDIATE | DRM_XE_VM_BIND_FLAG_READONLY), xeIoctlHelper->getFlagsForVmBind(true, true, false, true));
EXPECT_EQ(static_cast<uint64_t>(DRM_XE_VM_BIND_FLAG_DUMPABLE | DRM_XE_VM_BIND_FLAG_READONLY), xeIoctlHelper->getFlagsForVmBind(true, false, true, true));
EXPECT_EQ(static_cast<uint64_t>(DRM_XE_VM_BIND_FLAG_IMMEDIATE | DRM_XE_VM_BIND_FLAG_READONLY), xeIoctlHelper->getFlagsForVmBind(false, true, true, true));
EXPECT_EQ(static_cast<uint64_t>(DRM_XE_VM_BIND_FLAG_DUMPABLE), xeIoctlHelper->getFlagsForVmBind(true, false, false, false));
EXPECT_EQ(static_cast<uint64_t>(DRM_XE_VM_BIND_FLAG_IMMEDIATE), xeIoctlHelper->getFlagsForVmBind(false, true, false, false));
EXPECT_EQ(static_cast<uint64_t>(0), xeIoctlHelper->getFlagsForVmBind(false, false, true, false));
EXPECT_EQ(static_cast<uint64_t>(DRM_XE_VM_BIND_FLAG_READONLY), xeIoctlHelper->getFlagsForVmBind(false, false, false, true));
EXPECT_EQ(static_cast<uint64_t>(0), xeIoctlHelper->getFlagsForVmBind(false, false, false, false));
}

TEST(IoctlHelperXeTest, whenGettingIoctlRequestValueThenPropertValueIsReturned) {
Expand Down
6 changes: 6 additions & 0 deletions third_party/uapi/drm/xe_drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,10 @@ struct drm_xe_vm_destroy {
* - %DRM_XE_VM_BIND_OP_PREFETCH
*
* and the @flags can be:
* - %DRM_XE_VM_BIND_FLAG_READONLY
* - %DRM_XE_VM_BIND_FLAG_IMMEDIATE - Valid on a faulting VM only, do the
* MAP operation immediately rather than deferring the MAP to the page
* fault handler.
* - %DRM_XE_VM_BIND_FLAG_NULL - When the NULL flag is set, the page
* tables are setup with a special bit which indicates writes are
* dropped and all reads return zero. In the future, the NULL flags
Expand Down Expand Up @@ -923,6 +927,8 @@ struct drm_xe_vm_bind_op {
/** @op: Bind operation to perform */
__u32 op;

#define DRM_XE_VM_BIND_FLAG_READONLY (1 << 0)
#define DRM_XE_VM_BIND_FLAG_IMMEDIATE (1 << 1)
#define DRM_XE_VM_BIND_FLAG_NULL (1 << 2)
#define DRM_XE_VM_BIND_FLAG_DUMPABLE (1 << 3)
/** @flags: Bind flags */
Expand Down
Loading