This source file includes following definitions.
- nvkm_bar_flush
- nvkm_bar_bar1_vmm
- nvkm_bar_bar1_reset
- nvkm_bar_bar2_vmm
- nvkm_bar_bar2_reset
- nvkm_bar_bar2_fini
- nvkm_bar_bar2_init
- nvkm_bar_fini
- nvkm_bar_init
- nvkm_bar_oneinit
- nvkm_bar_dtor
- nvkm_bar_ctor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #include "priv.h"
25
26 void
27 nvkm_bar_flush(struct nvkm_bar *bar)
28 {
29 if (bar && bar->func->flush)
30 bar->func->flush(bar);
31 }
32
33 struct nvkm_vmm *
34 nvkm_bar_bar1_vmm(struct nvkm_device *device)
35 {
36 return device->bar->func->bar1.vmm(device->bar);
37 }
38
39 void
40 nvkm_bar_bar1_reset(struct nvkm_device *device)
41 {
42 struct nvkm_bar *bar = device->bar;
43 if (bar) {
44 bar->func->bar1.init(bar);
45 bar->func->bar1.wait(bar);
46 }
47 }
48
49 struct nvkm_vmm *
50 nvkm_bar_bar2_vmm(struct nvkm_device *device)
51 {
52
53
54
55 struct nvkm_bar *bar = device->bar;
56 if (bar && bar->bar2)
57 return bar->func->bar2.vmm(bar);
58 return NULL;
59 }
60
61 void
62 nvkm_bar_bar2_reset(struct nvkm_device *device)
63 {
64 struct nvkm_bar *bar = device->bar;
65 if (bar && bar->bar2) {
66 bar->func->bar2.init(bar);
67 bar->func->bar2.wait(bar);
68 }
69 }
70
71 void
72 nvkm_bar_bar2_fini(struct nvkm_device *device)
73 {
74 struct nvkm_bar *bar = device->bar;
75 if (bar && bar->bar2) {
76 bar->func->bar2.fini(bar);
77 bar->bar2 = false;
78 }
79 }
80
81 void
82 nvkm_bar_bar2_init(struct nvkm_device *device)
83 {
84 struct nvkm_bar *bar = device->bar;
85 if (bar && bar->subdev.oneinit && !bar->bar2 && bar->func->bar2.init) {
86 bar->func->bar2.init(bar);
87 bar->func->bar2.wait(bar);
88 bar->bar2 = true;
89 }
90 }
91
92 static int
93 nvkm_bar_fini(struct nvkm_subdev *subdev, bool suspend)
94 {
95 struct nvkm_bar *bar = nvkm_bar(subdev);
96 if (bar->func->bar1.fini)
97 bar->func->bar1.fini(bar);
98 return 0;
99 }
100
101 static int
102 nvkm_bar_init(struct nvkm_subdev *subdev)
103 {
104 struct nvkm_bar *bar = nvkm_bar(subdev);
105 bar->func->bar1.init(bar);
106 bar->func->bar1.wait(bar);
107 if (bar->func->init)
108 bar->func->init(bar);
109 return 0;
110 }
111
112 static int
113 nvkm_bar_oneinit(struct nvkm_subdev *subdev)
114 {
115 struct nvkm_bar *bar = nvkm_bar(subdev);
116 return bar->func->oneinit(bar);
117 }
118
119 static void *
120 nvkm_bar_dtor(struct nvkm_subdev *subdev)
121 {
122 struct nvkm_bar *bar = nvkm_bar(subdev);
123 nvkm_bar_bar2_fini(subdev->device);
124 return bar->func->dtor(bar);
125 }
126
127 static const struct nvkm_subdev_func
128 nvkm_bar = {
129 .dtor = nvkm_bar_dtor,
130 .oneinit = nvkm_bar_oneinit,
131 .init = nvkm_bar_init,
132 .fini = nvkm_bar_fini,
133 };
134
135 void
136 nvkm_bar_ctor(const struct nvkm_bar_func *func, struct nvkm_device *device,
137 int index, struct nvkm_bar *bar)
138 {
139 nvkm_subdev_ctor(&nvkm_bar, device, index, &bar->subdev);
140 bar->func = func;
141 spin_lock_init(&bar->lock);
142 }