mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
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:
committed by
Compute-Runtime-Automation
parent
833fa6bce1
commit
ef7dbc99f1
@@ -120,7 +120,6 @@ bool BufferObject::close() {
|
|||||||
|
|
||||||
GemClose close{};
|
GemClose close{};
|
||||||
close.handle = this->handle.getBoHandle();
|
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());
|
PRINT_DEBUG_STRING(debugManager.flags.PrintBOCreateDestroyResult.get(), stdout, "Calling gem close on handle: BO-%d\n", this->handle.getBoHandle());
|
||||||
|
|
||||||
|
|||||||
@@ -214,8 +214,6 @@ class BufferObject {
|
|||||||
BOType peekBOType() const { return boType; }
|
BOType peekBOType() const { return boType; }
|
||||||
void setBOType(BOType newBoType) { this->boType = newBoType; }
|
void setBOType(BOType newBoType) { this->boType = newBoType; }
|
||||||
|
|
||||||
void setUserptr(uint64_t ptr) { this->userptr = ptr; };
|
|
||||||
|
|
||||||
static constexpr int gpuHangDetected{-7171};
|
static constexpr int gpuHangDetected{-7171};
|
||||||
|
|
||||||
uint32_t getOsContextId(OsContext *osContext);
|
uint32_t getOsContextId(OsContext *osContext);
|
||||||
@@ -247,7 +245,6 @@ class BufferObject {
|
|||||||
uint64_t size;
|
uint64_t size;
|
||||||
uint64_t unmapSize = 0;
|
uint64_t unmapSize = 0;
|
||||||
uint64_t patIndex = CommonConstants::unsupportedPatIndex;
|
uint64_t patIndex = CommonConstants::unsupportedPatIndex;
|
||||||
uint64_t userptr = 0u;
|
|
||||||
CacheRegion cacheRegion = CacheRegion::defaultRegion;
|
CacheRegion cacheRegion = CacheRegion::defaultRegion;
|
||||||
CachePolicy cachePolicy = CachePolicy::writeBack;
|
CachePolicy cachePolicy = CachePolicy::writeBack;
|
||||||
StackVec<uint32_t, 2> bindExtHandles;
|
StackVec<uint32_t, 2> bindExtHandles;
|
||||||
|
|||||||
@@ -321,9 +321,8 @@ NEO::BufferObject *DrmMemoryManager::allocUserptr(uintptr_t address, size_t size
|
|||||||
DEBUG_BREAK_IF(true);
|
DEBUG_BREAK_IF(true);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
res->setAddress(address);
|
res->setAddress(address);
|
||||||
res->setUserptr(address);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,6 @@ struct Query {
|
|||||||
struct GemClose {
|
struct GemClose {
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
uint32_t reserved;
|
uint32_t reserved;
|
||||||
uint64_t userptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PrimeHandle {
|
struct PrimeHandle {
|
||||||
|
|||||||
@@ -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, flags) == offsetof(struct drm_i915_query, flags));
|
||||||
static_assert(offsetof(Query, itemsPtr) == offsetof(struct drm_i915_query, items_ptr));
|
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, handle) == offsetof(drm_gem_close, handle));
|
||||||
static_assert(offsetof(GemClose, reserved) == offsetof(drm_gem_close, pad));
|
static_assert(offsetof(GemClose, reserved) == offsetof(drm_gem_close, pad));
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,9 @@
|
|||||||
#define STRINGIFY_ME(X) return #X
|
#define STRINGIFY_ME(X) return #X
|
||||||
#define RETURN_ME(X) return X
|
#define RETURN_ME(X) return X
|
||||||
|
|
||||||
|
#define XE_USERPTR_FAKE_FLAG 0x800000
|
||||||
|
#define XE_USERPTR_FAKE_MASK 0x7FFFFF
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
const char *IoctlHelperXe::xeGetClassName(int className) {
|
const char *IoctlHelperXe::xeGetClassName(int className) {
|
||||||
@@ -972,7 +975,8 @@ int IoctlHelperXe::ioctl(DrmIoctl request, void *arg) {
|
|||||||
} break;
|
} break;
|
||||||
case DrmIoctl::gemUserptr: {
|
case DrmIoctl::gemUserptr: {
|
||||||
GemUserPtr *d = static_cast<GemUserPtr *>(arg);
|
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;
|
ret = 0;
|
||||||
xeLog(" -> IoctlHelperXe::ioctl GemUserptr p=0x%llx s=0x%llx f=0x%x h=0x%x r=%d\n", d->userPtr,
|
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);
|
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);
|
struct GemClose *d = static_cast<struct GemClose *>(arg);
|
||||||
int found = -1;
|
int found = -1;
|
||||||
xeShowBindTable();
|
xeShowBindTable();
|
||||||
bool isUserptr = false;
|
|
||||||
for (unsigned int i = 0; i < bindInfo.size(); i++) {
|
for (unsigned int i = 0; i < bindInfo.size(); i++) {
|
||||||
if (d->handle == bindInfo[i].handle) {
|
if (d->handle == bindInfo[i].handle) {
|
||||||
found = i;
|
found = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (d->userptr == bindInfo[i].userptr) {
|
|
||||||
found = i;
|
|
||||||
isUserptr = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (found != -1) {
|
if (found != -1) {
|
||||||
xeLog(" removing %d: 0x%x 0x%lx 0x%lx\n",
|
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);
|
std::unique_lock<std::mutex> lock(xeLock);
|
||||||
bindInfo.erase(bindInfo.begin() + found);
|
bindInfo.erase(bindInfo.begin() + found);
|
||||||
}
|
}
|
||||||
if (isUserptr) {
|
if (d->handle & XE_USERPTR_FAKE_FLAG) {
|
||||||
// nothing to do under XE
|
// nothing to do under XE
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -1310,7 +1308,7 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) {
|
|||||||
if (isBind) {
|
if (isBind) {
|
||||||
bind.bind.op = DRM_XE_VM_BIND_OP_MAP;
|
bind.bind.op = DRM_XE_VM_BIND_OP_MAP;
|
||||||
bind.bind.obj = vmBindParams.handle;
|
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.op = DRM_XE_VM_BIND_OP_MAP_USERPTR;
|
||||||
bind.bind.obj = 0;
|
bind.bind.obj = 0;
|
||||||
bind.bind.obj_offset = bindInfo[index].userptr;
|
bind.bind.obj_offset = bindInfo[index].userptr;
|
||||||
@@ -1318,7 +1316,7 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) {
|
|||||||
} else {
|
} else {
|
||||||
bind.bind.op = DRM_XE_VM_BIND_OP_UNMAP;
|
bind.bind.op = DRM_XE_VM_BIND_OP_UNMAP;
|
||||||
bind.bind.obj = 0;
|
bind.bind.obj = 0;
|
||||||
if (bindInfo[index].userptr) {
|
if (bindInfo[index].handle & XE_USERPTR_FAKE_FLAG) {
|
||||||
bind.bind.obj_offset = bindInfo[index].userptr;
|
bind.bind.obj_offset = bindInfo[index].userptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ class IoctlHelperXe : public IoctlHelper {
|
|||||||
int defaultAlignment = 0;
|
int defaultAlignment = 0;
|
||||||
int hasVram = 0;
|
int hasVram = 0;
|
||||||
uint32_t xeVmId = 0;
|
uint32_t xeVmId = 0;
|
||||||
|
uint32_t userPtrHandle = 0;
|
||||||
int xeFileHandle = 0;
|
int xeFileHandle = 0;
|
||||||
std::mutex xeLock;
|
std::mutex xeLock;
|
||||||
std::vector<BindInfo> bindInfo;
|
std::vector<BindInfo> bindInfo;
|
||||||
|
|||||||
@@ -1048,7 +1048,7 @@ TEST_F(DrmMemoryManagerTest, WhenAskedButNotAllowedHostPtrThenDoNotPinAfterAlloc
|
|||||||
TEST_F(DrmMemoryManagerTest, WhenUnreferenceIsCalledThenCallSucceeds) {
|
TEST_F(DrmMemoryManagerTest, WhenUnreferenceIsCalledThenCallSucceeds) {
|
||||||
mock->ioctlExpected.gemUserptr = 1;
|
mock->ioctlExpected.gemUserptr = 1;
|
||||||
mock->ioctlExpected.gemClose = 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);
|
ASSERT_NE(nullptr, bo);
|
||||||
memoryManager->unreference(bo, false);
|
memoryManager->unreference(bo, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -533,14 +533,11 @@ TEST(IoctlHelperXeTest, whenCallingIoctlThenProperValueIsReturned) {
|
|||||||
drm.testMode(0);
|
drm.testMode(0);
|
||||||
{
|
{
|
||||||
GemUserPtr test = {};
|
GemUserPtr test = {};
|
||||||
test.userPtr = 2;
|
test.handle = 1;
|
||||||
ret = mockXeIoctlHelper->ioctl(DrmIoctl::gemUserptr, &test);
|
ret = mockXeIoctlHelper->ioctl(DrmIoctl::gemUserptr, &test);
|
||||||
EXPECT_EQ(0, ret);
|
EXPECT_EQ(0, ret);
|
||||||
|
|
||||||
EXPECT_EQ(test.userPtr, mockXeIoctlHelper->bindInfo[0].userptr);
|
|
||||||
EXPECT_EQ(0u, mockXeIoctlHelper->bindInfo[0].handle);
|
|
||||||
GemClose cl = {};
|
GemClose cl = {};
|
||||||
cl.userptr = test.userPtr;
|
cl.handle = test.handle;
|
||||||
ret = mockXeIoctlHelper->ioctl(DrmIoctl::gemClose, &cl);
|
ret = mockXeIoctlHelper->ioctl(DrmIoctl::gemClose, &cl);
|
||||||
EXPECT_EQ(0, ret);
|
EXPECT_EQ(0, ret);
|
||||||
}
|
}
|
||||||
@@ -645,7 +642,6 @@ TEST(IoctlHelperXeTest, whenCallingIoctlThenProperValueIsReturned) {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
GemClose test = {};
|
GemClose test = {};
|
||||||
test.handle = 1;
|
|
||||||
ret = mockXeIoctlHelper->ioctl(DrmIoctl::gemClose, &test);
|
ret = mockXeIoctlHelper->ioctl(DrmIoctl::gemClose, &test);
|
||||||
EXPECT_EQ(0, ret);
|
EXPECT_EQ(0, ret);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user