20
20
21
21
struct xe_pt_dir {
22
22
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 ] ;
25
25
};
26
26
27
27
#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
44
45
45
static struct xe_pt * xe_pt_entry (struct xe_pt_dir * pt_dir , unsigned int index )
46
46
{
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 );
48
48
}
49
49
50
50
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
65
XE_PTE_NULL ;
66
66
}
67
67
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
+
68
76
/**
69
77
* xe_pt_create() - Create a page-table.
70
78
* @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
93
{
86
94
struct xe_pt * pt ;
87
95
struct xe_bo * bo ;
88
- size_t size ;
89
96
int err ;
90
97
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
+ }
94
105
if (!pt )
95
106
return ERR_PTR (- ENOMEM );
96
107
108
+ pt -> level = level ;
97
109
bo = xe_bo_create_pin_map (vm -> xe , tile , vm , SZ_4K ,
98
110
ttm_bo_type_kernel ,
99
111
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
118
goto err_kfree ;
107
119
}
108
120
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 ;
111
122
112
123
if (vm -> xef )
113
124
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
127
return pt ;
117
128
118
129
err_kfree :
119
- kfree (pt );
130
+ xe_pt_free (pt );
120
131
return ERR_PTR (err );
121
132
}
122
133
@@ -193,7 +204,7 @@ void xe_pt_destroy(struct xe_pt *pt, u32 flags, struct llist_head *deferred)
193
204
deferred );
194
205
}
195
206
}
196
- kfree (pt );
207
+ xe_pt_free (pt );
197
208
}
198
209
199
210
/**
@@ -358,7 +369,7 @@ xe_pt_insert_entry(struct xe_pt_stage_bind_walk *xe_walk, struct xe_pt *parent,
358
369
struct iosys_map * map = & parent -> bo -> vmap ;
359
370
360
371
if (unlikely (xe_child ))
361
- parent -> base .dir -> entries [offset ] = & xe_child -> base ;
372
+ parent -> base .children [offset ] = & xe_child -> base ;
362
373
363
374
xe_pt_write (xe_walk -> vm -> xe , map , offset , pte );
364
375
parent -> num_live ++ ;
@@ -853,7 +864,7 @@ static void xe_pt_commit_bind(struct xe_vma *vma,
853
864
xe_pt_destroy (xe_pt_entry (pt_dir , j_ ),
854
865
xe_vma_vm (vma )-> flags , deferred );
855
866
856
- pt_dir -> dir . entries [j_ ] = & newpte -> base ;
867
+ pt_dir -> children [j_ ] = & newpte -> base ;
857
868
}
858
869
kfree (entries [i ].pt_entries );
859
870
}
@@ -1506,7 +1517,7 @@ xe_pt_commit_unbind(struct xe_vma *vma,
1506
1517
xe_pt_destroy (xe_pt_entry (pt_dir , i ),
1507
1518
xe_vma_vm (vma )-> flags , deferred );
1508
1519
1509
- pt_dir -> dir . entries [i ] = NULL ;
1520
+ pt_dir -> children [i ] = NULL ;
1510
1521
}
1511
1522
}
1512
1523
}
0 commit comments