Commit 427e337f authored by Dave Airlie's avatar Dave Airlie

Merge tag 'drm-xe-fixes-2024-02-15' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes

Driver Changes:
- Fix an out-of-bounds shift.
- Fix the display code thinking xe uses shmem
- Fix a warning about index out-of-bound
- Fix a clang-16 compilation warning
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>

From: Thomas Hellstrom <thomas.hellstrom@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/Zc4GpcrbFVqdK9Ws@fedora
parents 7e1c3be3 455dae75
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "xe_bo.h" #include "xe_bo.h"
#define i915_gem_object_is_shmem(obj) ((obj)->flags & XE_BO_CREATE_SYSTEM_BIT) #define i915_gem_object_is_shmem(obj) (0) /* We don't use shmem */
static inline dma_addr_t i915_gem_object_get_dma_address(const struct xe_bo *bo, pgoff_t n) static inline dma_addr_t i915_gem_object_get_dma_address(const struct xe_bo *bo, pgoff_t n)
{ {
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
struct xe_pt_dir { struct xe_pt_dir {
struct xe_pt pt; struct xe_pt pt;
/** @dir: Directory structure for the xe_pt_walk functionality */ /** @children: Array of page-table child nodes */
struct xe_ptw_dir dir; struct xe_ptw *children[XE_PDES];
}; };
#if IS_ENABLED(CONFIG_DRM_XE_DEBUG_VM) #if IS_ENABLED(CONFIG_DRM_XE_DEBUG_VM)
...@@ -44,7 +44,7 @@ static struct xe_pt_dir *as_xe_pt_dir(struct xe_pt *pt) ...@@ -44,7 +44,7 @@ static struct xe_pt_dir *as_xe_pt_dir(struct xe_pt *pt)
static struct xe_pt *xe_pt_entry(struct xe_pt_dir *pt_dir, unsigned int index) static struct xe_pt *xe_pt_entry(struct xe_pt_dir *pt_dir, unsigned int index)
{ {
return container_of(pt_dir->dir.entries[index], struct xe_pt, base); return container_of(pt_dir->children[index], struct xe_pt, base);
} }
static u64 __xe_pt_empty_pte(struct xe_tile *tile, struct xe_vm *vm, static u64 __xe_pt_empty_pte(struct xe_tile *tile, struct xe_vm *vm,
...@@ -65,6 +65,14 @@ static u64 __xe_pt_empty_pte(struct xe_tile *tile, struct xe_vm *vm, ...@@ -65,6 +65,14 @@ static u64 __xe_pt_empty_pte(struct xe_tile *tile, struct xe_vm *vm,
XE_PTE_NULL; XE_PTE_NULL;
} }
static void xe_pt_free(struct xe_pt *pt)
{
if (pt->level)
kfree(as_xe_pt_dir(pt));
else
kfree(pt);
}
/** /**
* xe_pt_create() - Create a page-table. * xe_pt_create() - Create a page-table.
* @vm: The vm to create for. * @vm: The vm to create for.
...@@ -85,15 +93,19 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile, ...@@ -85,15 +93,19 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile,
{ {
struct xe_pt *pt; struct xe_pt *pt;
struct xe_bo *bo; struct xe_bo *bo;
size_t size;
int err; int err;
size = !level ? sizeof(struct xe_pt) : sizeof(struct xe_pt_dir) + if (level) {
XE_PDES * sizeof(struct xe_ptw *); struct xe_pt_dir *dir = kzalloc(sizeof(*dir), GFP_KERNEL);
pt = kzalloc(size, GFP_KERNEL);
pt = (dir) ? &dir->pt : NULL;
} else {
pt = kzalloc(sizeof(*pt), GFP_KERNEL);
}
if (!pt) if (!pt)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
pt->level = level;
bo = xe_bo_create_pin_map(vm->xe, tile, vm, SZ_4K, bo = xe_bo_create_pin_map(vm->xe, tile, vm, SZ_4K,
ttm_bo_type_kernel, ttm_bo_type_kernel,
XE_BO_CREATE_VRAM_IF_DGFX(tile) | XE_BO_CREATE_VRAM_IF_DGFX(tile) |
...@@ -106,8 +118,7 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile, ...@@ -106,8 +118,7 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile,
goto err_kfree; goto err_kfree;
} }
pt->bo = bo; pt->bo = bo;
pt->level = level; pt->base.children = level ? as_xe_pt_dir(pt)->children : NULL;
pt->base.dir = level ? &as_xe_pt_dir(pt)->dir : NULL;
if (vm->xef) if (vm->xef)
xe_drm_client_add_bo(vm->xef->client, pt->bo); xe_drm_client_add_bo(vm->xef->client, pt->bo);
...@@ -116,7 +127,7 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile, ...@@ -116,7 +127,7 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile,
return pt; return pt;
err_kfree: err_kfree:
kfree(pt); xe_pt_free(pt);
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -193,7 +204,7 @@ void xe_pt_destroy(struct xe_pt *pt, u32 flags, struct llist_head *deferred) ...@@ -193,7 +204,7 @@ void xe_pt_destroy(struct xe_pt *pt, u32 flags, struct llist_head *deferred)
deferred); deferred);
} }
} }
kfree(pt); xe_pt_free(pt);
} }
/** /**
...@@ -358,7 +369,7 @@ xe_pt_insert_entry(struct xe_pt_stage_bind_walk *xe_walk, struct xe_pt *parent, ...@@ -358,7 +369,7 @@ xe_pt_insert_entry(struct xe_pt_stage_bind_walk *xe_walk, struct xe_pt *parent,
struct iosys_map *map = &parent->bo->vmap; struct iosys_map *map = &parent->bo->vmap;
if (unlikely(xe_child)) if (unlikely(xe_child))
parent->base.dir->entries[offset] = &xe_child->base; parent->base.children[offset] = &xe_child->base;
xe_pt_write(xe_walk->vm->xe, map, offset, pte); xe_pt_write(xe_walk->vm->xe, map, offset, pte);
parent->num_live++; parent->num_live++;
...@@ -853,7 +864,7 @@ static void xe_pt_commit_bind(struct xe_vma *vma, ...@@ -853,7 +864,7 @@ static void xe_pt_commit_bind(struct xe_vma *vma,
xe_pt_destroy(xe_pt_entry(pt_dir, j_), xe_pt_destroy(xe_pt_entry(pt_dir, j_),
xe_vma_vm(vma)->flags, deferred); xe_vma_vm(vma)->flags, deferred);
pt_dir->dir.entries[j_] = &newpte->base; pt_dir->children[j_] = &newpte->base;
} }
kfree(entries[i].pt_entries); kfree(entries[i].pt_entries);
} }
...@@ -1507,7 +1518,7 @@ xe_pt_commit_unbind(struct xe_vma *vma, ...@@ -1507,7 +1518,7 @@ xe_pt_commit_unbind(struct xe_vma *vma,
xe_pt_destroy(xe_pt_entry(pt_dir, i), xe_pt_destroy(xe_pt_entry(pt_dir, i),
xe_vma_vm(vma)->flags, deferred); xe_vma_vm(vma)->flags, deferred);
pt_dir->dir.entries[i] = NULL; pt_dir->children[i] = NULL;
} }
} }
} }
......
...@@ -74,7 +74,7 @@ int xe_pt_walk_range(struct xe_ptw *parent, unsigned int level, ...@@ -74,7 +74,7 @@ int xe_pt_walk_range(struct xe_ptw *parent, unsigned int level,
u64 addr, u64 end, struct xe_pt_walk *walk) u64 addr, u64 end, struct xe_pt_walk *walk)
{ {
pgoff_t offset = xe_pt_offset(addr, level, walk); pgoff_t offset = xe_pt_offset(addr, level, walk);
struct xe_ptw **entries = parent->dir ? parent->dir->entries : NULL; struct xe_ptw **entries = parent->children ? parent->children : NULL;
const struct xe_pt_walk_ops *ops = walk->ops; const struct xe_pt_walk_ops *ops = walk->ops;
enum page_walk_action action; enum page_walk_action action;
struct xe_ptw *child; struct xe_ptw *child;
......
...@@ -8,28 +8,15 @@ ...@@ -8,28 +8,15 @@
#include <linux/pagewalk.h> #include <linux/pagewalk.h>
#include <linux/types.h> #include <linux/types.h>
struct xe_ptw_dir;
/** /**
* struct xe_ptw - base class for driver pagetable subclassing. * struct xe_ptw - base class for driver pagetable subclassing.
* @dir: Pointer to an array of children if any. * @children: Pointer to an array of children if any.
* *
* Drivers could subclass this, and if it's a page-directory, typically * Drivers could subclass this, and if it's a page-directory, typically
* embed the xe_ptw_dir::entries array in the same allocation. * embed an array of xe_ptw pointers.
*/ */
struct xe_ptw { struct xe_ptw {
struct xe_ptw_dir *dir; struct xe_ptw **children;
};
/**
* struct xe_ptw_dir - page directory structure
* @entries: Array holding page directory children.
*
* It is the responsibility of the user to ensure @entries is
* correctly sized.
*/
struct xe_ptw_dir {
struct xe_ptw *entries[0];
}; };
/** /**
......
...@@ -151,6 +151,11 @@ xe_range_fence_tree_next(struct xe_range_fence *rfence, u64 start, u64 last) ...@@ -151,6 +151,11 @@ xe_range_fence_tree_next(struct xe_range_fence *rfence, u64 start, u64 last)
return xe_range_fence_tree_iter_next(rfence, start, last); return xe_range_fence_tree_iter_next(rfence, start, last);
} }
static void xe_range_fence_free(struct xe_range_fence *rfence)
{
kfree(rfence);
}
const struct xe_range_fence_ops xe_range_fence_kfree_ops = { const struct xe_range_fence_ops xe_range_fence_kfree_ops = {
.free = (void (*)(struct xe_range_fence *rfence)) kfree, .free = xe_range_fence_free,
}; };
...@@ -995,9 +995,16 @@ int xe_vm_prepare_vma(struct drm_exec *exec, struct xe_vma *vma, ...@@ -995,9 +995,16 @@ int xe_vm_prepare_vma(struct drm_exec *exec, struct xe_vma *vma,
int err; int err;
XE_WARN_ON(!vm); XE_WARN_ON(!vm);
if (num_shared)
err = drm_exec_prepare_obj(exec, xe_vm_obj(vm), num_shared); err = drm_exec_prepare_obj(exec, xe_vm_obj(vm), num_shared);
if (!err && bo && !bo->vm) else
err = drm_exec_lock_obj(exec, xe_vm_obj(vm));
if (!err && bo && !bo->vm) {
if (num_shared)
err = drm_exec_prepare_obj(exec, &bo->ttm.base, num_shared); err = drm_exec_prepare_obj(exec, &bo->ttm.base, num_shared);
else
err = drm_exec_lock_obj(exec, &bo->ttm.base);
}
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment