Skip to content

Commit 04119ab

Browse files
committed
nvidiafb: detect the hardware support before removing console.
This driver removed the console, but hasn't yet decided if it could take over the console yet. Instead of doing that, probe the hw for support and then remove the console afterwards. Link: https://bugzilla.kernel.org/show_bug.cgi?id=216859 Fixes: 145eed4 ("fbdev: Remove conflicting devices on PCI bus") Reported-by: Zeno Davatz <[email protected]> Tested-by: Zeno Davatz <[email protected]> Tested-by: Thomas Zimmermann <[email protected]> Reviewed-by: Thomas Zimmermann <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4ec5183 commit 04119ab

File tree

1 file changed

+42
-39
lines changed

1 file changed

+42
-39
lines changed

drivers/video/fbdev/nvidia/nvidia.c

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,17 +1197,17 @@ static int nvidia_set_fbinfo(struct fb_info *info)
11971197
return nvidiafb_check_var(&info->var, info);
11981198
}
11991199

1200-
static u32 nvidia_get_chipset(struct fb_info *info)
1200+
static u32 nvidia_get_chipset(struct pci_dev *pci_dev,
1201+
volatile u32 __iomem *REGS)
12011202
{
1202-
struct nvidia_par *par = info->par;
1203-
u32 id = (par->pci_dev->vendor << 16) | par->pci_dev->device;
1203+
u32 id = (pci_dev->vendor << 16) | pci_dev->device;
12041204

12051205
printk(KERN_INFO PFX "Device ID: %x \n", id);
12061206

12071207
if ((id & 0xfff0) == 0x00f0 ||
12081208
(id & 0xfff0) == 0x02e0) {
12091209
/* pci-e */
1210-
id = NV_RD32(par->REGS, 0x1800);
1210+
id = NV_RD32(REGS, 0x1800);
12111211

12121212
if ((id & 0x0000ffff) == 0x000010DE)
12131213
id = 0x10DE0000 | (id >> 16);
@@ -1220,12 +1220,11 @@ static u32 nvidia_get_chipset(struct fb_info *info)
12201220
return id;
12211221
}
12221222

1223-
static u32 nvidia_get_arch(struct fb_info *info)
1223+
static u32 nvidia_get_arch(u32 Chipset)
12241224
{
1225-
struct nvidia_par *par = info->par;
12261225
u32 arch = 0;
12271226

1228-
switch (par->Chipset & 0x0ff0) {
1227+
switch (Chipset & 0x0ff0) {
12291228
case 0x0100: /* GeForce 256 */
12301229
case 0x0110: /* GeForce2 MX */
12311230
case 0x0150: /* GeForce2 */
@@ -1278,16 +1277,44 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
12781277
struct fb_info *info;
12791278
unsigned short cmd;
12801279
int ret;
1280+
volatile u32 __iomem *REGS;
1281+
int Chipset;
1282+
u32 Architecture;
12811283

12821284
NVTRACE_ENTER();
12831285
assert(pd != NULL);
12841286

1287+
if (pci_enable_device(pd)) {
1288+
printk(KERN_ERR PFX "cannot enable PCI device\n");
1289+
return -ENODEV;
1290+
}
1291+
1292+
/* enable IO and mem if not already done */
1293+
pci_read_config_word(pd, PCI_COMMAND, &cmd);
1294+
cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
1295+
pci_write_config_word(pd, PCI_COMMAND, cmd);
1296+
1297+
nvidiafb_fix.mmio_start = pci_resource_start(pd, 0);
1298+
nvidiafb_fix.mmio_len = pci_resource_len(pd, 0);
1299+
1300+
REGS = ioremap(nvidiafb_fix.mmio_start, nvidiafb_fix.mmio_len);
1301+
if (!REGS) {
1302+
printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
1303+
return -ENODEV;
1304+
}
1305+
1306+
Chipset = nvidia_get_chipset(pd, REGS);
1307+
Architecture = nvidia_get_arch(Chipset);
1308+
if (Architecture == 0) {
1309+
printk(KERN_ERR PFX "unknown NV_ARCH\n");
1310+
goto err_out;
1311+
}
1312+
12851313
ret = aperture_remove_conflicting_pci_devices(pd, "nvidiafb");
12861314
if (ret)
1287-
return ret;
1315+
goto err_out;
12881316

12891317
info = framebuffer_alloc(sizeof(struct nvidia_par), &pd->dev);
1290-
12911318
if (!info)
12921319
goto err_out;
12931320

@@ -1298,11 +1325,6 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
12981325
if (info->pixmap.addr == NULL)
12991326
goto err_out_kfree;
13001327

1301-
if (pci_enable_device(pd)) {
1302-
printk(KERN_ERR PFX "cannot enable PCI device\n");
1303-
goto err_out_enable;
1304-
}
1305-
13061328
if (pci_request_regions(pd, "nvidiafb")) {
13071329
printk(KERN_ERR PFX "cannot request PCI regions\n");
13081330
goto err_out_enable;
@@ -1318,34 +1340,17 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
13181340
par->paneltweak = paneltweak;
13191341
par->reverse_i2c = reverse_i2c;
13201342

1321-
/* enable IO and mem if not already done */
1322-
pci_read_config_word(pd, PCI_COMMAND, &cmd);
1323-
cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
1324-
pci_write_config_word(pd, PCI_COMMAND, cmd);
1325-
1326-
nvidiafb_fix.mmio_start = pci_resource_start(pd, 0);
13271343
nvidiafb_fix.smem_start = pci_resource_start(pd, 1);
1328-
nvidiafb_fix.mmio_len = pci_resource_len(pd, 0);
1329-
1330-
par->REGS = ioremap(nvidiafb_fix.mmio_start, nvidiafb_fix.mmio_len);
13311344

1332-
if (!par->REGS) {
1333-
printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
1334-
goto err_out_free_base0;
1335-
}
1345+
par->REGS = REGS;
13361346

1337-
par->Chipset = nvidia_get_chipset(info);
1338-
par->Architecture = nvidia_get_arch(info);
1339-
1340-
if (par->Architecture == 0) {
1341-
printk(KERN_ERR PFX "unknown NV_ARCH\n");
1342-
goto err_out_arch;
1343-
}
1347+
par->Chipset = Chipset;
1348+
par->Architecture = Architecture;
13441349

13451350
sprintf(nvidiafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4);
13461351

13471352
if (NVCommonSetup(info))
1348-
goto err_out_arch;
1353+
goto err_out_free_base0;
13491354

13501355
par->FbAddress = nvidiafb_fix.smem_start;
13511356
par->FbMapSize = par->RamAmountKBytes * 1024;
@@ -1401,7 +1406,6 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
14011406
goto err_out_iounmap_fb;
14021407
}
14031408

1404-
14051409
printk(KERN_INFO PFX
14061410
"PCI nVidia %s framebuffer (%dMB @ 0x%lX)\n",
14071411
info->fix.id,
@@ -1415,15 +1419,14 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
14151419
err_out_free_base1:
14161420
fb_destroy_modedb(info->monspecs.modedb);
14171421
nvidia_delete_i2c_busses(par);
1418-
err_out_arch:
1419-
iounmap(par->REGS);
1420-
err_out_free_base0:
1422+
err_out_free_base0:
14211423
pci_release_regions(pd);
14221424
err_out_enable:
14231425
kfree(info->pixmap.addr);
14241426
err_out_kfree:
14251427
framebuffer_release(info);
14261428
err_out:
1429+
iounmap(REGS);
14271430
return -ENODEV;
14281431
}
14291432

0 commit comments

Comments
 (0)