|
26 | 26 | #include "xe_reg_whitelist.h"
|
27 | 27 | #include "xe_rtp_types.h"
|
28 | 28 |
|
29 |
| -#define XE_REG_SR_GROW_STEP_DEFAULT 16 |
30 |
| - |
31 | 29 | static void reg_sr_fini(struct drm_device *drm, void *arg)
|
32 | 30 | {
|
33 | 31 | struct xe_reg_sr *sr = arg;
|
| 32 | + struct xe_reg_sr_entry *entry; |
| 33 | + unsigned long reg; |
| 34 | + |
| 35 | + xa_for_each(&sr->xa, reg, entry) |
| 36 | + kfree(entry); |
34 | 37 |
|
35 | 38 | xa_destroy(&sr->xa);
|
36 |
| - kfree(sr->pool.arr); |
37 |
| - memset(&sr->pool, 0, sizeof(sr->pool)); |
38 | 39 | }
|
39 | 40 |
|
40 | 41 | int xe_reg_sr_init(struct xe_reg_sr *sr, const char *name, struct xe_device *xe)
|
41 | 42 | {
|
42 | 43 | xa_init(&sr->xa);
|
43 |
| - memset(&sr->pool, 0, sizeof(sr->pool)); |
44 |
| - sr->pool.grow_step = XE_REG_SR_GROW_STEP_DEFAULT; |
45 | 44 | sr->name = name;
|
46 | 45 |
|
47 | 46 | return drmm_add_action_or_reset(&xe->drm, reg_sr_fini, sr);
|
48 | 47 | }
|
49 | 48 | EXPORT_SYMBOL_IF_KUNIT(xe_reg_sr_init);
|
50 | 49 |
|
51 |
| -static struct xe_reg_sr_entry *alloc_entry(struct xe_reg_sr *sr) |
52 |
| -{ |
53 |
| - if (sr->pool.used == sr->pool.allocated) { |
54 |
| - struct xe_reg_sr_entry *arr; |
55 |
| - |
56 |
| - arr = krealloc_array(sr->pool.arr, |
57 |
| - ALIGN(sr->pool.allocated + 1, sr->pool.grow_step), |
58 |
| - sizeof(*arr), GFP_KERNEL); |
59 |
| - if (!arr) |
60 |
| - return NULL; |
61 |
| - |
62 |
| - sr->pool.arr = arr; |
63 |
| - sr->pool.allocated += sr->pool.grow_step; |
64 |
| - } |
65 |
| - |
66 |
| - return &sr->pool.arr[sr->pool.used++]; |
67 |
| -} |
68 |
| - |
69 | 50 | static bool compatible_entries(const struct xe_reg_sr_entry *e1,
|
70 | 51 | const struct xe_reg_sr_entry *e2)
|
71 | 52 | {
|
@@ -111,7 +92,7 @@ int xe_reg_sr_add(struct xe_reg_sr *sr,
|
111 | 92 | return 0;
|
112 | 93 | }
|
113 | 94 |
|
114 |
| - pentry = alloc_entry(sr); |
| 95 | + pentry = kmalloc(sizeof(*pentry), GFP_KERNEL); |
115 | 96 | if (!pentry) {
|
116 | 97 | ret = -ENOMEM;
|
117 | 98 | goto fail;
|
|
0 commit comments