mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Add prelim ioctls for clos
Add several prelim ioctls related to clos for IoctlHelper Related-To: NEO-6510 Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
cdc064f478
commit
98d7258a0b
@@ -15,21 +15,34 @@
|
||||
namespace NEO {
|
||||
class Drm;
|
||||
class IoctlHelper;
|
||||
enum class CacheRegion : uint16_t;
|
||||
|
||||
extern IoctlHelper *ioctlHelperFactory[IGFX_MAX_PRODUCT];
|
||||
|
||||
class IoctlHelper {
|
||||
public:
|
||||
virtual ~IoctlHelper() {}
|
||||
static IoctlHelper *get(Drm *product);
|
||||
static IoctlHelper *get(Drm *drm);
|
||||
static uint32_t ioctl(Drm *drm, unsigned long request, void *arg);
|
||||
|
||||
virtual uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) = 0;
|
||||
virtual std::unique_ptr<uint8_t[]> translateIfRequired(uint8_t *dataQuery, int32_t length) = 0;
|
||||
virtual CacheRegion closAlloc(Drm *drm) = 0;
|
||||
virtual uint16_t closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) = 0;
|
||||
virtual CacheRegion closFree(Drm *drm, CacheRegion closIndex) = 0;
|
||||
};
|
||||
|
||||
class IoctlHelperUpstream : public IoctlHelper {
|
||||
public:
|
||||
virtual uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override;
|
||||
virtual std::unique_ptr<uint8_t[]> translateIfRequired(uint8_t *dataQuery, int32_t length) override;
|
||||
CacheRegion closAlloc(Drm *drm) override;
|
||||
uint16_t closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
|
||||
CacheRegion closFree(Drm *drm, CacheRegion closIndex) override;
|
||||
};
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
class IoctlHelperImpl : public IoctlHelper {
|
||||
class IoctlHelperImpl : public IoctlHelperUpstream {
|
||||
public:
|
||||
static IoctlHelper *get() {
|
||||
static IoctlHelperImpl<gfxProduct> instance;
|
||||
@@ -39,16 +52,13 @@ class IoctlHelperImpl : public IoctlHelper {
|
||||
std::unique_ptr<uint8_t[]> translateIfRequired(uint8_t *dataQuery, int32_t length) override;
|
||||
};
|
||||
|
||||
class IoctlHelperUpstream : public IoctlHelper {
|
||||
public:
|
||||
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override;
|
||||
std::unique_ptr<uint8_t[]> translateIfRequired(uint8_t *dataQuery, int32_t length) override;
|
||||
};
|
||||
|
||||
class IoctlHelperPrelim20 : public IoctlHelper {
|
||||
public:
|
||||
uint32_t createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) override;
|
||||
std::unique_ptr<uint8_t[]> translateIfRequired(uint8_t *dataQuery, int32_t length) override;
|
||||
CacheRegion closAlloc(Drm *drm) override;
|
||||
uint16_t closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
|
||||
CacheRegion closFree(Drm *drm, CacheRegion closIndex) override;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -6,10 +6,15 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/os_interface/linux/cache_info.h"
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
|
||||
#include "third_party/uapi/prelim/drm/i915_drm.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
uint32_t IoctlHelperPrelim20::createGemExt(Drm *drm, void *data, uint32_t dataSize, size_t allocSize, uint32_t &handle) {
|
||||
@@ -49,4 +54,51 @@ std::unique_ptr<uint8_t[]> IoctlHelperPrelim20::translateIfRequired(uint8_t *dat
|
||||
return std::unique_ptr<uint8_t[]>(dataQuery);
|
||||
}
|
||||
|
||||
CacheRegion IoctlHelperPrelim20::closAlloc(Drm *drm) {
|
||||
struct prelim_drm_i915_gem_clos_reserve clos = {};
|
||||
|
||||
int ret = IoctlHelper::ioctl(drm, PRELIM_DRM_IOCTL_I915_GEM_CLOS_RESERVE, &clos);
|
||||
if (ret != 0) {
|
||||
int err = errno;
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_CLOS_RESERVE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
|
||||
DEBUG_BREAK_IF(true);
|
||||
return CacheRegion::None;
|
||||
}
|
||||
|
||||
return static_cast<CacheRegion>(clos.clos_index);
|
||||
}
|
||||
|
||||
uint16_t IoctlHelperPrelim20::closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) {
|
||||
struct prelim_drm_i915_gem_cache_reserve cache = {};
|
||||
|
||||
cache.clos_index = static_cast<uint16_t>(closIndex);
|
||||
cache.cache_level = cacheLevel;
|
||||
cache.num_ways = numWays;
|
||||
|
||||
int ret = IoctlHelper::ioctl(drm, PRELIM_DRM_IOCTL_I915_GEM_CACHE_RESERVE, &cache);
|
||||
if (ret != 0) {
|
||||
int err = errno;
|
||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_CACHE_RESERVE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return cache.num_ways;
|
||||
}
|
||||
|
||||
CacheRegion IoctlHelperPrelim20::closFree(Drm *drm, CacheRegion closIndex) {
|
||||
struct prelim_drm_i915_gem_clos_free clos = {};
|
||||
|
||||
clos.clos_index = static_cast<uint16_t>(closIndex);
|
||||
|
||||
int ret = IoctlHelper::ioctl(drm, PRELIM_DRM_IOCTL_I915_GEM_CLOS_FREE, &clos);
|
||||
if (ret != 0) {
|
||||
int err = errno;
|
||||
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_CLOS_FREE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
|
||||
DEBUG_BREAK_IF(true);
|
||||
return CacheRegion::None;
|
||||
}
|
||||
|
||||
return closIndex;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/os_interface/linux/cache_info.h"
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
|
||||
#include "third_party/uapi/drm/i915_drm.h"
|
||||
@@ -45,4 +46,16 @@ std::unique_ptr<uint8_t[]> IoctlHelperUpstream::translateIfRequired(uint8_t *dat
|
||||
return std::unique_ptr<uint8_t[]>(dataQuery);
|
||||
}
|
||||
|
||||
CacheRegion IoctlHelperUpstream::closAlloc(Drm *drm) {
|
||||
return CacheRegion::None;
|
||||
}
|
||||
|
||||
uint16_t IoctlHelperUpstream::closAllocWays(Drm *drm, CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CacheRegion IoctlHelperUpstream::closFree(Drm *drm, CacheRegion closIndex) {
|
||||
return CacheRegion::None;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user