iris: Move bo_madvise to kmd backend
bo_madvise() is on hot path, so moving it to kmd backend. Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21494>
This commit is contained in:
committed by
Marge Bot
parent
d636e772c0
commit
bdfcc98001
@@ -27,22 +27,6 @@
|
||||
|
||||
#include "drm-uapi/i915_drm.h"
|
||||
|
||||
bool
|
||||
iris_i915_bo_madvise(struct iris_bo *bo, enum iris_madvice state)
|
||||
{
|
||||
uint32_t i915_state = state == IRIS_MADVICE_WILL_NEED ?
|
||||
I915_MADV_WILLNEED : I915_MADV_DONTNEED;
|
||||
struct drm_i915_gem_madvise madv = {
|
||||
.handle = bo->gem_handle,
|
||||
.madv = i915_state,
|
||||
.retained = 1,
|
||||
};
|
||||
|
||||
intel_ioctl(iris_bufmgr_get_fd(bo->bufmgr), DRM_IOCTL_I915_GEM_MADVISE, &madv);
|
||||
|
||||
return madv.retained;
|
||||
}
|
||||
|
||||
int iris_i915_bo_set_caching(struct iris_bo *bo, bool cached)
|
||||
{
|
||||
struct drm_i915_gem_caching arg = {
|
||||
|
||||
@@ -25,7 +25,5 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
struct iris_bo;
|
||||
enum iris_madvice;
|
||||
|
||||
bool iris_i915_bo_madvise(struct iris_bo *bo, enum iris_madvice state);
|
||||
int iris_i915_bo_set_caching(struct iris_bo *bo, bool cached);
|
||||
|
||||
@@ -91,10 +91,27 @@ i915_gem_create(struct iris_bufmgr *bufmgr,
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
static bool
|
||||
i915_bo_madvise(struct iris_bo *bo, enum iris_madvice state)
|
||||
{
|
||||
uint32_t i915_state = state == IRIS_MADVICE_WILL_NEED ?
|
||||
I915_MADV_WILLNEED : I915_MADV_DONTNEED;
|
||||
struct drm_i915_gem_madvise madv = {
|
||||
.handle = bo->gem_handle,
|
||||
.madv = i915_state,
|
||||
.retained = 1,
|
||||
};
|
||||
|
||||
intel_ioctl(iris_bufmgr_get_fd(bo->bufmgr), DRM_IOCTL_I915_GEM_MADVISE, &madv);
|
||||
|
||||
return madv.retained;
|
||||
}
|
||||
|
||||
const struct iris_kmd_backend *i915_get_backend(void)
|
||||
{
|
||||
static const struct iris_kmd_backend i915_backend = {
|
||||
.gem_create = i915_gem_create,
|
||||
.bo_madvise = i915_bo_madvise,
|
||||
};
|
||||
return &i915_backend;
|
||||
}
|
||||
|
||||
@@ -540,19 +540,13 @@ iris_bo_busy(struct iris_bo *bo)
|
||||
* Returns true if the buffer was retained, or false if it was discarded
|
||||
* whilst marked as IRIS_MADVICE_DONT_NEED.
|
||||
*/
|
||||
static bool
|
||||
static inline bool
|
||||
iris_bo_madvise(struct iris_bo *bo, enum iris_madvice state)
|
||||
{
|
||||
/* We can't madvise suballocated BOs. */
|
||||
assert(iris_bo_is_real(bo));
|
||||
|
||||
switch (iris_bufmgr_get_device_info(bo->bufmgr)->kmd_type) {
|
||||
case INTEL_KMD_TYPE_I915:
|
||||
return iris_i915_bo_madvise(bo, state);
|
||||
default:
|
||||
unreachable("missing");
|
||||
return false;
|
||||
}
|
||||
return bo->bufmgr->kmd_backend->bo_madvise(bo, state);
|
||||
}
|
||||
|
||||
static struct iris_bo *
|
||||
|
||||
@@ -28,14 +28,17 @@
|
||||
#include "dev/intel_device_info.h"
|
||||
#include "dev/intel_kmd.h"
|
||||
|
||||
struct iris_bo;
|
||||
struct iris_bufmgr;
|
||||
enum iris_heap;
|
||||
enum iris_madvice;
|
||||
|
||||
struct iris_kmd_backend {
|
||||
uint32_t (*gem_create)(struct iris_bufmgr *bufmgr,
|
||||
const struct intel_memory_class_instance **regions,
|
||||
uint16_t regions_count, uint64_t size,
|
||||
enum iris_heap heap_flags, unsigned alloc_flags);
|
||||
bool (*bo_madvise)(struct iris_bo *bo, enum iris_madvice state);
|
||||
};
|
||||
|
||||
const struct iris_kmd_backend *
|
||||
|
||||
Reference in New Issue
Block a user