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

[PATCH] intelfb: Do not ioremap entire graphics aperture

Reported by: Pavel Kysilka (Bugzilla Bug 4738)

modprobe of intelfb results in the following error message:

intelfb: Framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G chi
intelfb: Version 0.9.2
ACPI: PCI Interrupt 0000:00:02.0[A] -> GSI 16 (level, low) -> IRQ 16
allocation failed: out of vmalloc space - use vmalloc=<size> to increase siz
intelfb: Cannot remap FB region.

This will fail if the graphics aperture size is greater than 128 MB.

Fix is to ioremap only from the beginning of graphics aperture to the
end of the used framebuffer memory.

Signed-off-by: Sylvain Meyer <sylvain.meyer@worldonline.fr>
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Sylvain Meyer and committed by
Linus Torvalds
6bd49341 89204c40

+27 -23
+27 -23
drivers/video/intelfb/intelfbdrv.c
··· 583 583 return -ENODEV; 584 584 } 585 585 586 - /* Map the fb and MMIO regions */ 587 - dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache 588 - (dinfo->aperture.physical, dinfo->aperture.size); 589 - if (!dinfo->aperture.virtual) { 590 - ERR_MSG("Cannot remap FB region.\n"); 591 - cleanup(dinfo); 592 - return -ENODEV; 593 - } 594 - dinfo->mmio_base = 595 - (u8 __iomem *)ioremap_nocache(dinfo->mmio_base_phys, 596 - INTEL_REG_SIZE); 597 - if (!dinfo->mmio_base) { 598 - ERR_MSG("Cannot remap MMIO region.\n"); 599 - cleanup(dinfo); 600 - return -ENODEV; 601 - } 602 - 603 586 /* Get the chipset info. */ 604 587 dinfo->pci_chipset = pdev->device; 605 588 ··· 613 630 dinfo->accel = 0; 614 631 } 615 632 633 + if (MB(voffset) < stolen_size) 634 + offset = (stolen_size >> 12); 635 + else 636 + offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE; 637 + 616 638 /* Framebuffer parameters - Use all the stolen memory if >= vram */ 617 - if (ROUND_UP_TO_PAGE(stolen_size) >= MB(vram)) { 639 + if (ROUND_UP_TO_PAGE(stolen_size) >= ((offset << 12) + MB(vram))) { 618 640 dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size); 641 + dinfo->fb.offset = 0; 619 642 dinfo->fbmem_gart = 0; 620 643 } else { 621 644 dinfo->fb.size = MB(vram); ··· 652 663 return -ENODEV; 653 664 } 654 665 655 - if (MB(voffset) < stolen_size) 656 - offset = (stolen_size >> 12); 657 - else 658 - offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE; 659 - 660 666 /* set the mem offsets - set them after the already used pages */ 661 667 if (dinfo->accel) { 662 668 dinfo->ring.offset = offset + gtt_info.current_memory; ··· 664 680 dinfo->fb.offset = offset + 665 681 + gtt_info.current_memory + (dinfo->ring.size >> 12) 666 682 + (dinfo->cursor.size >> 12); 683 + } 684 + 685 + /* Map the fb and MMIO regions */ 686 + /* ioremap only up to the end of used aperture */ 687 + dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache 688 + (dinfo->aperture.physical, (dinfo->fb.offset << 12) 689 + + dinfo->fb.size); 690 + if (!dinfo->aperture.virtual) { 691 + ERR_MSG("Cannot remap FB region.\n"); 692 + cleanup(dinfo); 693 + return -ENODEV; 694 + } 695 + 696 + dinfo->mmio_base = 697 + (u8 __iomem *)ioremap_nocache(dinfo->mmio_base_phys, 698 + INTEL_REG_SIZE); 699 + if (!dinfo->mmio_base) { 700 + ERR_MSG("Cannot remap MMIO region.\n"); 701 + cleanup(dinfo); 702 + return -ENODEV; 667 703 } 668 704 669 705 /* Allocate memories (which aren't stolen) */