diff options
author | Marcin KoĆcielnicki <koriakin@0x04.net> | 2009-12-14 19:37:30 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2009-12-16 02:04:55 -0500 |
commit | 657b6245ba23d32c7a4fd273549c8c0beebec770 (patch) | |
tree | f2b743f13551de2a5f09af8d16898110bd011a8e /drivers/gpu/drm/nouveau/nouveau_bios.c | |
parent | ef2bb506687a5f1cc8ef2fef370bb168b2808106 (diff) |
drm/nouveau: Kill global state in NvShadowBIOS
Signed-off-by: Marcin KoĆcielnicki <koriakin@0x04.net>
Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_bios.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bios.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c index 62fadbbd1f40..519faa955045 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c | |||
@@ -181,43 +181,42 @@ struct methods { | |||
181 | const char desc[8]; | 181 | const char desc[8]; |
182 | void (*loadbios)(struct drm_device *, uint8_t *); | 182 | void (*loadbios)(struct drm_device *, uint8_t *); |
183 | const bool rw; | 183 | const bool rw; |
184 | int score; | ||
185 | }; | 184 | }; |
186 | 185 | ||
187 | static struct methods nv04_methods[] = { | 186 | static struct methods nv04_methods[] = { |
188 | { "PROM", load_vbios_prom, false }, | 187 | { "PROM", load_vbios_prom, false }, |
189 | { "PRAMIN", load_vbios_pramin, true }, | 188 | { "PRAMIN", load_vbios_pramin, true }, |
190 | { "PCIROM", load_vbios_pci, true }, | 189 | { "PCIROM", load_vbios_pci, true }, |
191 | { } | ||
192 | }; | 190 | }; |
193 | 191 | ||
194 | static struct methods nv50_methods[] = { | 192 | static struct methods nv50_methods[] = { |
195 | { "PRAMIN", load_vbios_pramin, true }, | 193 | { "PRAMIN", load_vbios_pramin, true }, |
196 | { "PROM", load_vbios_prom, false }, | 194 | { "PROM", load_vbios_prom, false }, |
197 | { "PCIROM", load_vbios_pci, true }, | 195 | { "PCIROM", load_vbios_pci, true }, |
198 | { } | ||
199 | }; | 196 | }; |
200 | 197 | ||
198 | #define METHODCNT 3 | ||
199 | |||
201 | static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) | 200 | static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) |
202 | { | 201 | { |
203 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 202 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
204 | struct methods *methods, *method; | 203 | struct methods *methods; |
204 | int i; | ||
205 | int testscore = 3; | 205 | int testscore = 3; |
206 | int scores[METHODCNT]; | ||
206 | 207 | ||
207 | if (nouveau_vbios) { | 208 | if (nouveau_vbios) { |
208 | method = nv04_methods; | 209 | methods = nv04_methods; |
209 | while (method->loadbios) { | 210 | for (i = 0; i < METHODCNT; i++) |
210 | if (!strcasecmp(nouveau_vbios, method->desc)) | 211 | if (!strcasecmp(nouveau_vbios, methods[i].desc)) |
211 | break; | 212 | break; |
212 | method++; | ||
213 | } | ||
214 | 213 | ||
215 | if (method->loadbios) { | 214 | if (i < METHODCNT) { |
216 | NV_INFO(dev, "Attempting to use BIOS image from %s\n", | 215 | NV_INFO(dev, "Attempting to use BIOS image from %s\n", |
217 | method->desc); | 216 | methods[i].desc); |
218 | 217 | ||
219 | method->loadbios(dev, data); | 218 | methods[i].loadbios(dev, data); |
220 | if (score_vbios(dev, data, method->rw)) | 219 | if (score_vbios(dev, data, methods[i].rw)) |
221 | return true; | 220 | return true; |
222 | } | 221 | } |
223 | 222 | ||
@@ -229,28 +228,24 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) | |||
229 | else | 228 | else |
230 | methods = nv50_methods; | 229 | methods = nv50_methods; |
231 | 230 | ||
232 | method = methods; | 231 | for (i = 0; i < METHODCNT; i++) { |
233 | while (method->loadbios) { | ||
234 | NV_TRACE(dev, "Attempting to load BIOS image from %s\n", | 232 | NV_TRACE(dev, "Attempting to load BIOS image from %s\n", |
235 | method->desc); | 233 | methods[i].desc); |
236 | data[0] = data[1] = 0; /* avoid reuse of previous image */ | 234 | data[0] = data[1] = 0; /* avoid reuse of previous image */ |
237 | method->loadbios(dev, data); | 235 | methods[i].loadbios(dev, data); |
238 | method->score = score_vbios(dev, data, method->rw); | 236 | scores[i] = score_vbios(dev, data, methods[i].rw); |
239 | if (method->score == testscore) | 237 | if (scores[i] == testscore) |
240 | return true; | 238 | return true; |
241 | method++; | ||
242 | } | 239 | } |
243 | 240 | ||
244 | while (--testscore > 0) { | 241 | while (--testscore > 0) { |
245 | method = methods; | 242 | for (i = 0; i < METHODCNT; i++) { |
246 | while (method->loadbios) { | 243 | if (scores[i] == testscore) { |
247 | if (method->score == testscore) { | ||
248 | NV_TRACE(dev, "Using BIOS image from %s\n", | 244 | NV_TRACE(dev, "Using BIOS image from %s\n", |
249 | method->desc); | 245 | methods[i].desc); |
250 | method->loadbios(dev, data); | 246 | methods[i].loadbios(dev, data); |
251 | return true; | 247 | return true; |
252 | } | 248 | } |
253 | method++; | ||
254 | } | 249 | } |
255 | } | 250 | } |
256 | 251 | ||