check if the whole object region is in 32Bit address space boundary

checks the address + size of buffer object to determine
whether the object is located within 32bit address space
boundary.

v2: changed end year to 2019 in ther license term
v3: added unit test for checking of flag when size of
    bo is given.
v4: two different unit tests are created to cover two
    different case separately

Change-Id: Ie2df6025fc116aca679dcfe88d858ff240278c39
Signed-off-by: dongwonk <dongwon.kim@intel.com>
This commit is contained in:
dongwonk
2019-02-07 11:04:22 -08:00
committed by sys_ocldev
parent 856e0cc476
commit 0240f239ad
2 changed files with 19 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -29,6 +29,10 @@ class TestedBufferObject : public BufferObject {
execObjectPointerFilled = &execObject;
}
void setSize(size_t size) {
this->size = size;
}
drm_i915_gem_exec_object2 *execObjectPointerFilled = nullptr;
};
@@ -94,19 +98,25 @@ TEST_F(DrmBufferObjectTest, setTiling_ioctlFailed) {
EXPECT_FALSE(ret);
}
TEST_F(DrmBufferObjectTest, testExecObjectFlags) {
TEST_F(DrmBufferObjectTest, givenAddressThatWhenSizeIsAddedCrosses32BitBoundaryWhenExecIsCalledThen48BitFlagIsSet) {
drm_i915_gem_exec_object2 execObject;
#ifdef __x86_64__
memset(&execObject, 0, sizeof(execObject));
bo->setAddress((void *)((uint64_t)1u << 34)); //anything above 4GB
bo->setAddress((void *)(((uint64_t)1u << 32) - 0x1000u));
bo->setSize(0x1000);
bo->fillExecObject(execObject, 1);
//base address + size > size of 32bit address space
EXPECT_TRUE(execObject.flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS);
#endif
}
TEST_F(DrmBufferObjectTest, givenAddressThatWhenSizeIsAddedWithin32BitBoundaryWhenExecIsCalledThen48BitFlagIsNotSet) {
drm_i915_gem_exec_object2 execObject;
memset(&execObject, 0, sizeof(execObject));
bo->setAddress((void *)((uint64_t)1u << 31)); //anything below 4GB
bo->setAddress((void *)(((uint64_t)1u << 32) - 0x1000u));
bo->setSize(0xFFF);
bo->fillExecObject(execObject, 1);
//base address + size < size of 32bit address space
EXPECT_FALSE(execObject.flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS);
}