Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] nvidiafb: ioremap and i2c fixes

- Add 'vram' option to specify amount of video RAM to remap
- Limit remap size to 64 MIB
- Use info->screen_size for remapped RAM
- Fix misplaced label in failure path

Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Antonino A. Daplas and committed by
Linus Torvalds
917bb077 71494376

+21 -5
+21 -5
drivers/video/nvidia/nvidia.c
··· 408 408 static int noaccel __devinitdata = 0; 409 409 static int noscale __devinitdata = 0; 410 410 static int paneltweak __devinitdata = 0; 411 + static int vram __devinitdata = 0; 411 412 #ifdef CONFIG_MTRR 412 413 static int nomtrr __devinitdata = 0; 413 414 #endif ··· 1181 1180 1182 1181 var->xres_virtual = (var->xres_virtual + 63) & ~63; 1183 1182 1184 - vramlen = info->fix.smem_len; 1183 + vramlen = info->screen_size; 1185 1184 pitch = ((var->xres_virtual * var->bits_per_pixel) + 7) / 8; 1186 1185 memlen = pitch * var->yres_virtual; 1187 1186 ··· 1344 1343 /* maximize virtual vertical length */ 1345 1344 lpitch = info->var.xres_virtual * 1346 1345 ((info->var.bits_per_pixel + 7) >> 3); 1347 - info->var.yres_virtual = info->fix.smem_len / lpitch; 1346 + info->var.yres_virtual = info->screen_size / lpitch; 1348 1347 1349 1348 info->pixmap.scan_align = 4; 1350 1349 info->pixmap.buf_align = 4; ··· 1508 1507 1509 1508 par->FbAddress = nvidiafb_fix.smem_start; 1510 1509 par->FbMapSize = par->RamAmountKBytes * 1024; 1510 + if (vram && vram * 1024 * 1024 < par->FbMapSize) 1511 + par->FbMapSize = vram * 1024 * 1024; 1512 + 1513 + /* Limit amount of vram to 64 MB */ 1514 + if (par->FbMapSize > 64 * 1024 * 1024) 1515 + par->FbMapSize = 64 * 1024 * 1024; 1516 + 1511 1517 par->FbUsableSize = par->FbMapSize - (128 * 1024); 1512 1518 par->ScratchBufferSize = (par->Architecture < NV_ARCH_10) ? 8 * 1024 : 1513 1519 16 * 1024; 1514 1520 par->ScratchBufferStart = par->FbUsableSize - par->ScratchBufferSize; 1515 1521 info->screen_base = ioremap(nvidiafb_fix.smem_start, par->FbMapSize); 1516 - nvidiafb_fix.smem_len = par->FbUsableSize; 1522 + info->screen_size = par->FbUsableSize; 1523 + nvidiafb_fix.smem_len = par->RamAmountKBytes * 1024; 1517 1524 1518 1525 if (!info->screen_base) { 1519 1526 printk(KERN_ERR PFX "cannot ioremap FB base\n"); ··· 1533 1524 #ifdef CONFIG_MTRR 1534 1525 if (!nomtrr) { 1535 1526 par->mtrr.vram = mtrr_add(nvidiafb_fix.smem_start, 1536 - par->FbMapSize, MTRR_TYPE_WRCOMB, 1); 1527 + par->RamAmountKBytes * 1024, 1528 + MTRR_TYPE_WRCOMB, 1); 1537 1529 if (par->mtrr.vram < 0) { 1538 1530 printk(KERN_ERR PFX "unable to setup MTRR\n"); 1539 1531 } else { ··· 1576 1566 1577 1567 err_out_iounmap_fb: 1578 1568 iounmap(info->screen_base); 1569 + err_out_free_base1: 1579 1570 fb_destroy_modedb(info->monspecs.modedb); 1580 1571 nvidia_delete_i2c_busses(par); 1581 - err_out_free_base1: 1582 1572 iounmap(par->REGS); 1583 1573 err_out_free_base0: 1584 1574 pci_release_regions(pd); ··· 1655 1645 noscale = 1; 1656 1646 } else if (!strncmp(this_opt, "paneltweak:", 11)) { 1657 1647 paneltweak = simple_strtoul(this_opt+11, NULL, 0); 1648 + } else if (!strncmp(this_opt, "vram:", 5)) { 1649 + vram = simple_strtoul(this_opt+5, NULL, 0); 1658 1650 #ifdef CONFIG_MTRR 1659 1651 } else if (!strncmp(this_opt, "nomtrr", 6)) { 1660 1652 nomtrr = 1; ··· 1728 1716 MODULE_PARM_DESC(forceCRTC, 1729 1717 "Forces usage of a particular CRTC in case autodetection " 1730 1718 "fails. (0 or 1) (default=autodetect)"); 1719 + module_param(vram, int, 0); 1720 + MODULE_PARM_DESC(vram, 1721 + "amount of framebuffer memory to remap in MiB" 1722 + "(default=0 - remap entire memory)"); 1731 1723 #ifdef CONFIG_MTRR 1732 1724 module_param(nomtrr, bool, 0); 1733 1725 MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) "