Skip to content

Commit 427e337

Browse files
committed
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: Dave Airlie <airlied@redhat.com> From: Thomas Hellstrom <thomas.hellstrom@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/Zc4GpcrbFVqdK9Ws@fedora
2 parents 7e1c3be + 455dae7 commit 427e337

File tree

6 files changed

+46
-36
lines changed

6 files changed

+46
-36
lines changed

drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "xe_bo.h"
1212

13-
#define i915_gem_object_is_shmem(obj) ((obj)->flags & XE_BO_CREATE_SYSTEM_BIT)
13+
#define i915_gem_object_is_shmem(obj) (0) /* We don't use shmem */
1414

1515
static inline dma_addr_t i915_gem_object_get_dma_address(const struct xe_bo *bo, pgoff_t n)
1616
{

drivers/gpu/drm/xe/xe_pt.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
struct xe_pt_dir {
2222
struct xe_pt pt;
23-
/** @dir: Directory structure for the xe_pt_walk functionality */
24-
struct xe_ptw_dir dir;
23+
/** @children: Array of page-table child nodes */
24+
struct xe_ptw *children[XE_PDES];
2525
};
2626

2727
#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)
4444

4545
static struct xe_pt *xe_pt_entry(struct xe_pt_dir *pt_dir, unsigned int index)
4646
{
47-
return container_of(pt_dir->dir.entries[index], struct xe_pt, base);
47+
return container_of(pt_dir->children[index], struct xe_pt, base);
4848
}
4949

5050
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,
6565
XE_PTE_NULL;
6666
}
6767

68+
static void xe_pt_free(struct xe_pt *pt)
69+
{
70+
if (pt->level)
71+
kfree(as_xe_pt_dir(pt));
72+
else
73+
kfree(pt);
74+
}
75+
6876
/**
6977
* xe_pt_create() - Create a page-table.
7078
* @vm: The vm to create for.
@@ -85,15 +93,19 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile,
8593
{
8694
struct xe_pt *pt;
8795
struct xe_bo *bo;
88-
size_t size;
8996
int err;
9097

91-
size = !level ? sizeof(struct xe_pt) : sizeof(struct xe_pt_dir) +
92-
XE_PDES * sizeof(struct xe_ptw *);
93-
pt = kzalloc(size, GFP_KERNEL);
98+
if (level) {
99+
struct xe_pt_dir *dir = kzalloc(sizeof(*dir), GFP_KERNEL);
100+
101+
pt = (dir) ? &dir->pt : NULL;
102+
} else {
103+
pt = kzalloc(sizeof(*pt), GFP_KERNEL);
104+
}
94105
if (!pt)
95106
return ERR_PTR(-ENOMEM);
96107

108+
pt->level = level;
97109
bo = xe_bo_create_pin_map(vm->xe, tile, vm, SZ_4K,
98110
ttm_bo_type_kernel,
99111
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,
106118
goto err_kfree;
107119
}
108120
pt->bo = bo;
109-
pt->level = level;
110-
pt->base.dir = level ? &as_xe_pt_dir(pt)->dir : NULL;
121+
pt->base.children = level ? as_xe_pt_dir(pt)->children : NULL;
111122

112123
if (vm->xef)
113124
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,
116127
return pt;
117128

118129
err_kfree:
119-
kfree(pt);
130+
xe_pt_free(pt);
120131
return ERR_PTR(err);
121132
}
122133

@@ -193,7 +204,7 @@ void xe_pt_destroy(struct xe_pt *pt, u32 flags, struct llist_head *deferred)
193204
deferred);
194205
}
195206
}
196-
kfree(pt);
207+
xe_pt_free(pt);
197208
}
198209

199210
/**
@@ -358,7 +369,7 @@ xe_pt_insert_entry(struct xe_pt_stage_bind_walk *xe_walk, struct xe_pt *parent,
358369
struct iosys_map *map = &parent->bo->vmap;
359370

360371
if (unlikely(xe_child))
361-
parent->base.dir->entries[offset] = &xe_child->base;
372+
parent->base.children[offset] = &xe_child->base;
362373

363374
xe_pt_write(xe_walk->vm->xe, map, offset, pte);
364375
parent->num_live++;
@@ -853,7 +864,7 @@ static void xe_pt_commit_bind(struct xe_vma *vma,
853864
xe_pt_destroy(xe_pt_entry(pt_dir, j_),
854865
xe_vma_vm(vma)->flags, deferred);
855866

856-
pt_dir->dir.entries[j_] = &newpte->base;
867+
pt_dir->children[j_] = &newpte->base;
857868
}
858869
kfree(entries[i].pt_entries);
859870
}
@@ -1507,7 +1518,7 @@ xe_pt_commit_unbind(struct xe_vma *vma,
15071518
xe_pt_destroy(xe_pt_entry(pt_dir, i),
15081519
xe_vma_vm(vma)->flags, deferred);
15091520

1510-
pt_dir->dir.entries[i] = NULL;
1521+
pt_dir->children[i] = NULL;
15111522
}
15121523
}
15131524
}

drivers/gpu/drm/xe/xe_pt_walk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int xe_pt_walk_range(struct xe_ptw *parent, unsigned int level,
7474
u64 addr, u64 end, struct xe_pt_walk *walk)
7575
{
7676
pgoff_t offset = xe_pt_offset(addr, level, walk);
77-
struct xe_ptw **entries = parent->dir ? parent->dir->entries : NULL;
77+
struct xe_ptw **entries = parent->children ? parent->children : NULL;
7878
const struct xe_pt_walk_ops *ops = walk->ops;
7979
enum page_walk_action action;
8080
struct xe_ptw *child;

drivers/gpu/drm/xe/xe_pt_walk.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,15 @@
88
#include <linux/pagewalk.h>
99
#include <linux/types.h>
1010

11-
struct xe_ptw_dir;
12-
1311
/**
1412
* struct xe_ptw - base class for driver pagetable subclassing.
15-
* @dir: Pointer to an array of children if any.
13+
* @children: Pointer to an array of children if any.
1614
*
1715
* Drivers could subclass this, and if it's a page-directory, typically
18-
* embed the xe_ptw_dir::entries array in the same allocation.
16+
* embed an array of xe_ptw pointers.
1917
*/
2018
struct xe_ptw {
21-
struct xe_ptw_dir *dir;
22-
};
23-
24-
/**
25-
* struct xe_ptw_dir - page directory structure
26-
* @entries: Array holding page directory children.
27-
*
28-
* It is the responsibility of the user to ensure @entries is
29-
* correctly sized.
30-
*/
31-
struct xe_ptw_dir {
32-
struct xe_ptw *entries[0];
19+
struct xe_ptw **children;
3320
};
3421

3522
/**

drivers/gpu/drm/xe/xe_range_fence.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ xe_range_fence_tree_next(struct xe_range_fence *rfence, u64 start, u64 last)
151151
return xe_range_fence_tree_iter_next(rfence, start, last);
152152
}
153153

154+
static void xe_range_fence_free(struct xe_range_fence *rfence)
155+
{
156+
kfree(rfence);
157+
}
158+
154159
const struct xe_range_fence_ops xe_range_fence_kfree_ops = {
155-
.free = (void (*)(struct xe_range_fence *rfence)) kfree,
160+
.free = xe_range_fence_free,
156161
};

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -995,9 +995,16 @@ int xe_vm_prepare_vma(struct drm_exec *exec, struct xe_vma *vma,
995995
int err;
996996

997997
XE_WARN_ON(!vm);
998-
err = drm_exec_prepare_obj(exec, xe_vm_obj(vm), num_shared);
999-
if (!err && bo && !bo->vm)
1000-
err = drm_exec_prepare_obj(exec, &bo->ttm.base, num_shared);
998+
if (num_shared)
999+
err = drm_exec_prepare_obj(exec, xe_vm_obj(vm), num_shared);
1000+
else
1001+
err = drm_exec_lock_obj(exec, xe_vm_obj(vm));
1002+
if (!err && bo && !bo->vm) {
1003+
if (num_shared)
1004+
err = drm_exec_prepare_obj(exec, &bo->ttm.base, num_shared);
1005+
else
1006+
err = drm_exec_lock_obj(exec, &bo->ttm.base);
1007+
}
10011008

10021009
return err;
10031010
}

0 commit comments

Comments
 (0)