forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/gpu/drm/nouveau/nvif/mmu.c
....@@ -25,16 +25,17 @@
2525 #include <nvif/if0008.h>
2626
2727 void
28
-nvif_mmu_fini(struct nvif_mmu *mmu)
28
+nvif_mmu_dtor(struct nvif_mmu *mmu)
2929 {
3030 kfree(mmu->kind);
3131 kfree(mmu->type);
3232 kfree(mmu->heap);
33
- nvif_object_fini(&mmu->object);
33
+ nvif_object_dtor(&mmu->object);
3434 }
3535
3636 int
37
-nvif_mmu_init(struct nvif_object *parent, s32 oclass, struct nvif_mmu *mmu)
37
+nvif_mmu_ctor(struct nvif_object *parent, const char *name, s32 oclass,
38
+ struct nvif_mmu *mmu)
3839 {
3940 static const struct nvif_mclass mems[] = {
4041 { NVIF_CLASS_MEM_GF100, -1 },
....@@ -50,8 +51,8 @@
5051 mmu->type = NULL;
5152 mmu->kind = NULL;
5253
53
- ret = nvif_object_init(parent, 0, oclass, &args, sizeof(args),
54
- &mmu->object);
54
+ ret = nvif_object_ctor(parent, name ? name : "nvifMmu", 0, oclass,
55
+ &args, sizeof(args), &mmu->object);
5556 if (ret)
5657 goto done;
5758
....@@ -110,7 +111,7 @@
110111
111112 if (mmu->kind_nr) {
112113 struct nvif_mmu_kind_v0 *kind;
113
- u32 argc = sizeof(*kind) + sizeof(*kind->data) * mmu->kind_nr;
114
+ size_t argc = struct_size(kind, data, mmu->kind_nr);
114115
115116 if (ret = -ENOMEM, !(kind = kmalloc(argc, GFP_KERNEL)))
116117 goto done;
....@@ -121,11 +122,12 @@
121122 kind, argc);
122123 if (ret == 0)
123124 memcpy(mmu->kind, kind->data, kind->count);
125
+ mmu->kind_inv = kind->kind_inv;
124126 kfree(kind);
125127 }
126128
127129 done:
128130 if (ret)
129
- nvif_mmu_fini(mmu);
131
+ nvif_mmu_dtor(mmu);
130132 return ret;
131133 }