Revert "fix: don't use fake userptr flag in ioctl helper xe"

This reverts commit 98824fdaf6.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation 2024-03-14 14:04:40 +01:00 committed by Compute-Runtime-Automation
parent 833fa6bce1
commit ef7dbc99f1
9 changed files with 14 additions and 25 deletions

View File

@ -120,7 +120,6 @@ bool BufferObject::close() {
GemClose close{};
close.handle = this->handle.getBoHandle();
close.userptr = this->userptr;
PRINT_DEBUG_STRING(debugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Calling gem close on handle: BO-%d\n", this->handle.getBoHandle());

View File

@ -214,8 +214,6 @@ class BufferObject {
BOType peekBOType() const { return boType; }
void setBOType(BOType newBoType) { this->boType = newBoType; }
void setUserptr(uint64_t ptr) { this->userptr = ptr; };
static constexpr int gpuHangDetected{-7171};
uint32_t getOsContextId(OsContext *osContext);
@ -247,7 +245,6 @@ class BufferObject {
uint64_t size;
uint64_t unmapSize = 0;
uint64_t patIndex = CommonConstants::unsupportedPatIndex;
uint64_t userptr = 0u;
CacheRegion cacheRegion = CacheRegion::defaultRegion;
CachePolicy cachePolicy = CachePolicy::writeBack;
StackVec<uint32_t, 2> bindExtHandles;

View File

@ -321,9 +321,8 @@ NEO::BufferObject *DrmMemoryManager::allocUserptr(uintptr_t address, size_t size
DEBUG_BREAK_IF(true);
return nullptr;
}
res->setAddress(address);
res->setUserptr(address);
return res;
}

View File

@ -179,7 +179,6 @@ struct Query {
struct GemClose {
uint32_t handle;
uint32_t reserved;
uint64_t userptr;
};
struct PrimeHandle {

View File

@ -137,7 +137,7 @@ static_assert(offsetof(Query, numItems) == offsetof(struct drm_i915_query, num_i
static_assert(offsetof(Query, flags) == offsetof(struct drm_i915_query, flags));
static_assert(offsetof(Query, itemsPtr) == offsetof(struct drm_i915_query, items_ptr));
static_assert(sizeof(GemClose) >= sizeof(drm_gem_close));
static_assert(sizeof(GemClose) == sizeof(drm_gem_close));
static_assert(offsetof(GemClose, handle) == offsetof(drm_gem_close, handle));
static_assert(offsetof(GemClose, reserved) == offsetof(drm_gem_close, pad));

View File

@ -37,6 +37,9 @@
#define STRINGIFY_ME(X) return #X
#define RETURN_ME(X) return X
#define XE_USERPTR_FAKE_FLAG 0x800000
#define XE_USERPTR_FAKE_MASK 0x7FFFFF
namespace NEO {
const char *IoctlHelperXe::xeGetClassName(int className) {
@ -972,7 +975,8 @@ int IoctlHelperXe::ioctl(DrmIoctl request, void *arg) {
} break;
case DrmIoctl::gemUserptr: {
GemUserPtr *d = static_cast<GemUserPtr *>(arg);
updateBindInfo(0, d->userPtr, d->userSize);
d->handle = userPtrHandle++ | XE_USERPTR_FAKE_FLAG;
updateBindInfo(d->handle, d->userPtr, d->userSize);
ret = 0;
xeLog(" -> IoctlHelperXe::ioctl GemUserptr p=0x%llx s=0x%llx f=0x%x h=0x%x r=%d\n", d->userPtr,
d->userSize, d->flags, d->handle, ret);
@ -1050,17 +1054,11 @@ int IoctlHelperXe::ioctl(DrmIoctl request, void *arg) {
struct GemClose *d = static_cast<struct GemClose *>(arg);
int found = -1;
xeShowBindTable();
bool isUserptr = false;
for (unsigned int i = 0; i < bindInfo.size(); i++) {
if (d->handle == bindInfo[i].handle) {
found = i;
break;
}
if (d->userptr == bindInfo[i].userptr) {
found = i;
isUserptr = true;
break;
}
}
if (found != -1) {
xeLog(" removing %d: 0x%x 0x%lx 0x%lx\n",
@ -1072,7 +1070,7 @@ int IoctlHelperXe::ioctl(DrmIoctl request, void *arg) {
std::unique_lock<std::mutex> lock(xeLock);
bindInfo.erase(bindInfo.begin() + found);
}
if (isUserptr) {
if (d->handle & XE_USERPTR_FAKE_FLAG) {
// nothing to do under XE
ret = 0;
} else {
@ -1310,7 +1308,7 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) {
if (isBind) {
bind.bind.op = DRM_XE_VM_BIND_OP_MAP;
bind.bind.obj = vmBindParams.handle;
if (bindInfo[index].userptr) {
if (bindInfo[index].handle & XE_USERPTR_FAKE_FLAG) {
bind.bind.op = DRM_XE_VM_BIND_OP_MAP_USERPTR;
bind.bind.obj = 0;
bind.bind.obj_offset = bindInfo[index].userptr;
@ -1318,7 +1316,7 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) {
} else {
bind.bind.op = DRM_XE_VM_BIND_OP_UNMAP;
bind.bind.obj = 0;
if (bindInfo[index].userptr) {
if (bindInfo[index].handle & XE_USERPTR_FAKE_FLAG) {
bind.bind.obj_offset = bindInfo[index].userptr;
}
}

View File

@ -173,6 +173,7 @@ class IoctlHelperXe : public IoctlHelper {
int defaultAlignment = 0;
int hasVram = 0;
uint32_t xeVmId = 0;
uint32_t userPtrHandle = 0;
int xeFileHandle = 0;
std::mutex xeLock;
std::vector<BindInfo> bindInfo;

View File

@ -1048,7 +1048,7 @@ TEST_F(DrmMemoryManagerTest, WhenAskedButNotAllowedHostPtrThenDoNotPinAfterAlloc
TEST_F(DrmMemoryManagerTest, WhenUnreferenceIsCalledThenCallSucceeds) {
mock->ioctlExpected.gemUserptr = 1;
mock->ioctlExpected.gemClose = 1;
BufferObject *bo = memoryManager->allocUserptr(1234, (size_t)1024, rootDeviceIndex);
BufferObject *bo = memoryManager->allocUserptr(0, (size_t)1024, rootDeviceIndex);
ASSERT_NE(nullptr, bo);
memoryManager->unreference(bo, false);
}

View File

@ -533,14 +533,11 @@ TEST(IoctlHelperXeTest, whenCallingIoctlThenProperValueIsReturned) {
drm.testMode(0);
{
GemUserPtr test = {};
test.userPtr = 2;
test.handle = 1;
ret = mockXeIoctlHelper->ioctl(DrmIoctl::gemUserptr, &test);
EXPECT_EQ(0, ret);
EXPECT_EQ(test.userPtr, mockXeIoctlHelper->bindInfo[0].userptr);
EXPECT_EQ(0u, mockXeIoctlHelper->bindInfo[0].handle);
GemClose cl = {};
cl.userptr = test.userPtr;
cl.handle = test.handle;
ret = mockXeIoctlHelper->ioctl(DrmIoctl::gemClose, &cl);
EXPECT_EQ(0, ret);
}
@ -645,7 +642,6 @@ TEST(IoctlHelperXeTest, whenCallingIoctlThenProperValueIsReturned) {
}
{
GemClose test = {};
test.handle = 1;
ret = mockXeIoctlHelper->ioctl(DrmIoctl::gemClose, &test);
EXPECT_EQ(0, ret);
}