mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
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>
This commit is contained in:
parent
ef2bb50668
commit
657b6245ba
1 changed files with 21 additions and 26 deletions
|
@ -181,43 +181,42 @@ struct methods {
|
|||
const char desc[8];
|
||||
void (*loadbios)(struct drm_device *, uint8_t *);
|
||||
const bool rw;
|
||||
int score;
|
||||
};
|
||||
|
||||
static struct methods nv04_methods[] = {
|
||||
{ "PROM", load_vbios_prom, false },
|
||||
{ "PRAMIN", load_vbios_pramin, true },
|
||||
{ "PCIROM", load_vbios_pci, true },
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct methods nv50_methods[] = {
|
||||
{ "PRAMIN", load_vbios_pramin, true },
|
||||
{ "PROM", load_vbios_prom, false },
|
||||
{ "PCIROM", load_vbios_pci, true },
|
||||
{ }
|
||||
};
|
||||
|
||||
#define METHODCNT 3
|
||||
|
||||
static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
|
||||
{
|
||||
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
||||
struct methods *methods, *method;
|
||||
struct methods *methods;
|
||||
int i;
|
||||
int testscore = 3;
|
||||
int scores[METHODCNT];
|
||||
|
||||
if (nouveau_vbios) {
|
||||
method = nv04_methods;
|
||||
while (method->loadbios) {
|
||||
if (!strcasecmp(nouveau_vbios, method->desc))
|
||||
methods = nv04_methods;
|
||||
for (i = 0; i < METHODCNT; i++)
|
||||
if (!strcasecmp(nouveau_vbios, methods[i].desc))
|
||||
break;
|
||||
method++;
|
||||
}
|
||||
|
||||
if (method->loadbios) {
|
||||
if (i < METHODCNT) {
|
||||
NV_INFO(dev, "Attempting to use BIOS image from %s\n",
|
||||
method->desc);
|
||||
methods[i].desc);
|
||||
|
||||
method->loadbios(dev, data);
|
||||
if (score_vbios(dev, data, method->rw))
|
||||
methods[i].loadbios(dev, data);
|
||||
if (score_vbios(dev, data, methods[i].rw))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -229,28 +228,24 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
|
|||
else
|
||||
methods = nv50_methods;
|
||||
|
||||
method = methods;
|
||||
while (method->loadbios) {
|
||||
for (i = 0; i < METHODCNT; i++) {
|
||||
NV_TRACE(dev, "Attempting to load BIOS image from %s\n",
|
||||
method->desc);
|
||||
methods[i].desc);
|
||||
data[0] = data[1] = 0; /* avoid reuse of previous image */
|
||||
method->loadbios(dev, data);
|
||||
method->score = score_vbios(dev, data, method->rw);
|
||||
if (method->score == testscore)
|
||||
methods[i].loadbios(dev, data);
|
||||
scores[i] = score_vbios(dev, data, methods[i].rw);
|
||||
if (scores[i] == testscore)
|
||||
return true;
|
||||
method++;
|
||||
}
|
||||
|
||||
while (--testscore > 0) {
|
||||
method = methods;
|
||||
while (method->loadbios) {
|
||||
if (method->score == testscore) {
|
||||
for (i = 0; i < METHODCNT; i++) {
|
||||
if (scores[i] == testscore) {
|
||||
NV_TRACE(dev, "Using BIOS image from %s\n",
|
||||
method->desc);
|
||||
method->loadbios(dev, data);
|
||||
methods[i].desc);
|
||||
methods[i].loadbios(dev, data);
|
||||
return true;
|
||||
}
|
||||
method++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue