#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/sizes.h>
+#include <drm/drm_drv.h>
#include <drm/drm_managed.h>
#include <drm/i915_drm.h>
void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
bool invalidate)
{
- xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
+ struct xe_device *xe = tile_to_xe(ggtt->tile);
+ bool bound;
+ int idx;
+
+ bound = drm_dev_enter(&xe->drm, &idx);
+ if (bound)
+ xe_pm_runtime_get_noresume(xe);
mutex_lock(&ggtt->lock);
- xe_ggtt_clear(ggtt, node->start, node->size);
+ if (bound)
+ xe_ggtt_clear(ggtt, node->start, node->size);
drm_mm_remove_node(node);
node->size = 0;
mutex_unlock(&ggtt->lock);
+ if (!bound)
+ return;
+
if (invalidate)
xe_ggtt_invalidate(ggtt);
- xe_pm_runtime_put(tile_to_xe(ggtt->tile));
+ xe_pm_runtime_put(xe);
+ drm_dev_exit(idx);
}
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)