Subversion Repositories Kolibri OS

Rev

Rev 2332 | Rev 2344 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2332 Rev 2339
Line 36... Line 36...
36
 
36
 
37
 
37
 
38
#define PCI_VENDOR_ID_INTEL             0x8086
38
#define PCI_VENDOR_ID_INTEL             0x8086
-
 
39
#define PCI_DEVICE_ID_INTEL_82830_HB    0x3575
-
 
40
#define PCI_DEVICE_ID_INTEL_82845G_HB   0x2560
-
 
41
#define PCI_DEVICE_ID_INTEL_82915G_IG   0x2582
-
 
42
#define PCI_DEVICE_ID_INTEL_82915GM_IG  0x2592
Line 39... Line 43...
39
#define PCI_DEVICE_ID_INTEL_82830_HB    0x3575
43
#define PCI_DEVICE_ID_INTEL_82945G_IG   0x2772
Line 40... Line 44...
40
#define PCI_DEVICE_ID_INTEL_82845G_HB   0x2560
44
#define PCI_DEVICE_ID_INTEL_82945GM_IG  0x27A2
Line 69... Line 73...
69
}
73
}
Line 70... Line 74...
70
 
74
 
71
/*
75
/*
72
 * If we have Intel graphics, we're not going to have anything other than
76
 * If we have Intel graphics, we're not going to have anything other than
73
 * an Intel IOMMU. So make the correct use of the PCI DMA API contingent
77
 * an Intel IOMMU. So make the correct use of the PCI DMA API contingent
74
 * on the Intel IOMMU support (CONFIG_DMAR).
78
 * on the Intel IOMMU support (CONFIG_INTEL_IOMMU).
75
 * Only newer chipsets need to bother with this, of course.
79
 * Only newer chipsets need to bother with this, of course.
76
 */
80
 */
77
#ifdef CONFIG_DMAR
81
#ifdef CONFIG_INTEL_IOMMU
78
#define USE_PCI_DMA_API 1
82
#define USE_PCI_DMA_API 1
79
#else
83
#else
80
#define USE_PCI_DMA_API 0
84
#define USE_PCI_DMA_API 0
Line 438... Line 442...
438
    intel_private.driver->cleanup();
442
    intel_private.driver->cleanup();
Line 439... Line 443...
439
 
443
 
440
    FreeKernelSpace(intel_private.gtt);
444
    FreeKernelSpace(intel_private.gtt);
Line 441... Line 445...
441
    FreeKernelSpace(intel_private.registers);
445
    FreeKernelSpace(intel_private.registers);
442
 
446
 
Line 443... Line 447...
443
  //  intel_gtt_teardown_scratch_page();
447
	intel_gtt_teardown_scratch_page();
444
}
448
}
445
 
449
 
Line 467... Line 471...
467
            & ~I810_PGETBL_ENABLED;
471
            & ~I810_PGETBL_ENABLED;
468
    /* we only ever restore the register when enabling the PGTBL... */
472
    /* we only ever restore the register when enabling the PGTBL... */
469
    if (HAS_PGTBL_EN)
473
    if (HAS_PGTBL_EN)
470
        intel_private.PGETBL_save |= I810_PGETBL_ENABLED;
474
        intel_private.PGETBL_save |= I810_PGETBL_ENABLED;
Line -... Line 475...
-
 
475
 
471
 
476
	dev_info(&intel_private.bridge_dev->dev,
472
    dbgprintf("detected gtt size: %dK total, %dK mappable\n",
477
			"detected gtt size: %dK total, %dK mappable\n",
473
            intel_private.base.gtt_total_entries * 4,
478
            intel_private.base.gtt_total_entries * 4,
Line 474... Line 479...
474
            intel_private.base.gtt_mappable_entries * 4);
479
            intel_private.base.gtt_mappable_entries * 4);
Line 500... Line 505...
500
    LEAVE();
505
    LEAVE();
Line 501... Line 506...
501
 
506
 
502
    return 0;
507
    return 0;
Line -... Line 508...
-
 
508
}
-
 
509
 
-
 
510
static void i830_write_entry(dma_addr_t addr, unsigned int entry,
-
 
511
			     unsigned int flags)
-
 
512
{
-
 
513
	u32 pte_flags = I810_PTE_VALID;
-
 
514
 
-
 
515
	if (flags ==  AGP_USER_CACHED_MEMORY)
-
 
516
		pte_flags |= I830_PTE_SYSTEM_CACHED;
-
 
517
 
-
 
518
	writel(addr | pte_flags, intel_private.gtt + entry);
503
}
519
}
504
 
520
 
505
static bool intel_enable_gtt(void)
521
static bool intel_enable_gtt(void)
506
{
522
{
Line 557... Line 573...
557
        writel(0, intel_private.registers+GFX_FLSH_CNTL);
573
        writel(0, intel_private.registers+GFX_FLSH_CNTL);
Line 558... Line 574...
558
 
574
 
559
    return true;
575
    return true;
Line -... Line 576...
-
 
576
}
-
 
577
 
-
 
578
static bool i830_check_flags(unsigned int flags)
-
 
579
{
-
 
580
	switch (flags) {
-
 
581
	case 0:
-
 
582
	case AGP_PHYS_MEMORY:
-
 
583
	case AGP_USER_CACHED_MEMORY:
-
 
584
	case AGP_USER_MEMORY:
-
 
585
		return true;
-
 
586
	}
-
 
587
 
Line 560... Line 588...
560
}
588
	return false;
561
 
589
}
562
 
590
 
563
void intel_gtt_insert_pages(unsigned int first_entry, unsigned int num_entries,
591
void intel_gtt_insert_pages(unsigned int first_entry, unsigned int num_entries,
Line 583... Line 611...
583
						  i, 0);
611
						  i, 0);
584
	}
612
	}
585
	readl(intel_private.gtt+i-1);
613
	readl(intel_private.gtt+i-1);
586
}
614
}
Line 587... Line -...
587
 
-
 
588
 
615
 
589
static void intel_i9xx_setup_flush(void)
616
static void intel_i9xx_setup_flush(void)
590
{
617
{
591
    /* return if already configured */
618
    /* return if already configured */
592
    if (intel_private.ifp_resource.start)
619
    if (intel_private.ifp_resource.start)
Line 593... Line 620...
593
        return;
620
        return;
594
 
621
 
Line 595... Line -...
595
    if (INTEL_GTT_GEN == 6)
-
 
596
        return;
622
    if (INTEL_GTT_GEN == 6)
597
 
623
        return;
598
#if 0
624
 
-
 
625
    /* setup a resource for this object */
-
 
626
//    intel_private.ifp_resource.name = "Intel Flush Page";
Line 599... Line 627...
599
    /* setup a resource for this object */
627
//    intel_private.ifp_resource.flags = IORESOURCE_MEM;
600
    intel_private.ifp_resource.name = "Intel Flush Page";
628
 
601
    intel_private.ifp_resource.flags = IORESOURCE_MEM;
629
    intel_private.resource_valid = 0;
602
 
630
 
603
    /* Setup chipset flush for 915 */
631
    /* Setup chipset flush for 915 */
604
    if (IS_G33 || INTEL_GTT_GEN >= 4) {
632
//    if (IS_G33 || INTEL_GTT_GEN >= 4) {
Line 605... Line 633...
605
        intel_i965_g33_setup_chipset_flush();
633
//        intel_i965_g33_setup_chipset_flush();
606
    } else {
634
//    } else {
607
        intel_i915_setup_chipset_flush();
635
//        intel_i915_setup_chipset_flush();
608
    }
636
//    }
609
 
637
 
610
    if (intel_private.ifp_resource.start)
638
//    if (intel_private.ifp_resource.start)
Line -... Line 639...
-
 
639
//        intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE);
-
 
640
    if (!intel_private.i9xx_flush_page)
-
 
641
        dev_err(&intel_private.pcidev->dev,
-
 
642
            "can't ioremap flush page - no chipset flushing\n");
-
 
643
}
-
 
644
 
-
 
645
static void i9xx_cleanup(void)
-
 
646
{
611
        intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE);
647
	if (intel_private.i9xx_flush_page)
Line 612... Line 648...
612
    if (!intel_private.i9xx_flush_page)
648
		iounmap(intel_private.i9xx_flush_page);
613
        dev_err(&intel_private.pcidev->dev,
649
//	if (intel_private.resource_valid)
614
            "can't ioremap flush page - no chipset flushing\n");
650
//		release_resource(&intel_private.ifp_resource);
615
#endif
651
	intel_private.ifp_resource.start = 0;
616
 
652
	intel_private.resource_valid = 0;
Line -... Line 653...
-
 
653
}
-
 
654
 
-
 
655
static void i9xx_chipset_flush(void)
-
 
656
{
-
 
657
    if (intel_private.i9xx_flush_page)
-
 
658
        writel(1, intel_private.i9xx_flush_page);
-
 
659
}
-
 
660
 
-
 
661
static void i965_write_entry(dma_addr_t addr,
-
 
662
			     unsigned int entry,
-
 
663
			     unsigned int flags)
-
 
664
{
-
 
665
	u32 pte_flags;
-
 
666
 
-
 
667
	pte_flags = I810_PTE_VALID;
617
}
668
	if (flags == AGP_USER_CACHED_MEMORY)
618
 
669
		pte_flags |= I830_PTE_SYSTEM_CACHED;
619
static void i9xx_chipset_flush(void)
670
 
620
{
671
	/* Shift high bits down */
Line 653... Line 704...
653
 
704
 
654
static void gen6_cleanup(void)
705
static void gen6_cleanup(void)
655
{
706
{
Line -... Line 707...
-
 
707
}
-
 
708
 
-
 
709
/* Certain Gen5 chipsets require require idling the GPU before
-
 
710
 * unmapping anything from the GTT when VT-d is enabled.
-
 
711
 */
-
 
712
static inline int needs_idle_maps(void)
-
 
713
{
-
 
714
#ifdef CONFIG_INTEL_IOMMU
-
 
715
	const unsigned short gpu_devid = intel_private.pcidev->device;
-
 
716
	extern int intel_iommu_gfx_mapped;
-
 
717
 
-
 
718
	/* Query intel_iommu to see if we need the workaround. Presumably that
-
 
719
	 * was loaded first.
-
 
720
	 */
-
 
721
	if ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB ||
-
 
722
	     gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) &&
-
 
723
	     intel_iommu_gfx_mapped)
-
 
724
		return 1;
-
 
725
#endif
-
 
726
	return 0;
656
}
727
}
657
 
728
 
658
static int i9xx_setup(void)
729
static int i9xx_setup(void)
Line 659... Line 730...
659
{
730
{
Line 688... Line 759...
688
            break;
759
            break;
689
        }
760
        }
690
        intel_private.gtt_bus_addr = reg_addr + gtt_offset;
761
        intel_private.gtt_bus_addr = reg_addr + gtt_offset;
691
    }
762
    }
Line -... Line 763...
-
 
763
 
-
 
764
	if (needs_idle_maps())
-
 
765
		intel_private.base.do_idle_maps = 1;
692
 
766
 
Line 693... Line 767...
693
    intel_i9xx_setup_flush();
767
    intel_i9xx_setup_flush();
694
 
768
 
Line -... Line 769...
-
 
769
    return 0;
-
 
770
}
-
 
771
 
-
 
772
static const struct intel_gtt_driver i915_gtt_driver = {
-
 
773
	.gen = 3,
-
 
774
	.has_pgtbl_enable = 1,
-
 
775
	.setup = i9xx_setup,
-
 
776
	.cleanup = i9xx_cleanup,
-
 
777
	/* i945 is the last gpu to need phys mem (for overlay and cursors). */
-
 
778
	.write_entry = i830_write_entry,
-
 
779
	.dma_mask_size = 32,
-
 
780
	.check_flags = i830_check_flags,
-
 
781
	.chipset_flush = i9xx_chipset_flush,
-
 
782
};
-
 
783
static const struct intel_gtt_driver g33_gtt_driver = {
-
 
784
	.gen = 3,
-
 
785
	.is_g33 = 1,
-
 
786
	.setup = i9xx_setup,
-
 
787
	.cleanup = i9xx_cleanup,
-
 
788
	.write_entry = i965_write_entry,
-
 
789
	.dma_mask_size = 36,
-
 
790
	.check_flags = i830_check_flags,
-
 
791
	.chipset_flush = i9xx_chipset_flush,
-
 
792
};
-
 
793
static const struct intel_gtt_driver pineview_gtt_driver = {
-
 
794
	.gen = 3,
-
 
795
	.is_pineview = 1, .is_g33 = 1,
-
 
796
	.setup = i9xx_setup,
-
 
797
	.cleanup = i9xx_cleanup,
-
 
798
	.write_entry = i965_write_entry,
-
 
799
	.dma_mask_size = 36,
-
 
800
	.check_flags = i830_check_flags,
-
 
801
	.chipset_flush = i9xx_chipset_flush,
-
 
802
};
-
 
803
static const struct intel_gtt_driver i965_gtt_driver = {
-
 
804
	.gen = 4,
-
 
805
	.has_pgtbl_enable = 1,
-
 
806
	.setup = i9xx_setup,
-
 
807
	.cleanup = i9xx_cleanup,
-
 
808
	.write_entry = i965_write_entry,
-
 
809
	.dma_mask_size = 36,
-
 
810
	.check_flags = i830_check_flags,
-
 
811
	.chipset_flush = i9xx_chipset_flush,
-
 
812
};
-
 
813
static const struct intel_gtt_driver g4x_gtt_driver = {
-
 
814
	.gen = 5,
-
 
815
	.setup = i9xx_setup,
-
 
816
	.cleanup = i9xx_cleanup,
-
 
817
	.write_entry = i965_write_entry,
-
 
818
	.dma_mask_size = 36,
-
 
819
	.check_flags = i830_check_flags,
-
 
820
	.chipset_flush = i9xx_chipset_flush,
-
 
821
};
-
 
822
static const struct intel_gtt_driver ironlake_gtt_driver = {
-
 
823
	.gen = 5,
-
 
824
	.is_ironlake = 1,
-
 
825
	.setup = i9xx_setup,
-
 
826
	.cleanup = i9xx_cleanup,
-
 
827
	.write_entry = i965_write_entry,
-
 
828
	.dma_mask_size = 36,
695
    return 0;
829
	.check_flags = i830_check_flags,
696
}
830
	.chipset_flush = i9xx_chipset_flush,
697
 
831
};
698
static const struct intel_gtt_driver sandybridge_gtt_driver = {
832
static const struct intel_gtt_driver sandybridge_gtt_driver = {
699
    .gen = 6,
833
    .gen = 6,
Line 712... Line 846...
712
static const struct intel_gtt_driver_description {
846
static const struct intel_gtt_driver_description {
713
    unsigned int gmch_chip_id;
847
    unsigned int gmch_chip_id;
714
    char *name;
848
    char *name;
715
    const struct intel_gtt_driver *gtt_driver;
849
    const struct intel_gtt_driver *gtt_driver;
716
} intel_gtt_chipsets[] = {
850
} intel_gtt_chipsets[] = {
-
 
851
	{ PCI_DEVICE_ID_INTEL_E7221_IG, "E7221 (i915)",
-
 
852
		&i915_gtt_driver },
-
 
853
	{ PCI_DEVICE_ID_INTEL_82915G_IG, "915G",
-
 
854
		&i915_gtt_driver },
-
 
855
	{ PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM",
-
 
856
		&i915_gtt_driver },
-
 
857
	{ PCI_DEVICE_ID_INTEL_82945G_IG, "945G",
-
 
858
		&i915_gtt_driver },
-
 
859
	{ PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM",
-
 
860
		&i915_gtt_driver },
-
 
861
	{ PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME",
-
 
862
		&i915_gtt_driver },
-
 
863
	{ PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ",
-
 
864
		&i965_gtt_driver },
-
 
865
	{ PCI_DEVICE_ID_INTEL_82G35_IG, "G35",
-
 
866
		&i965_gtt_driver },
-
 
867
	{ PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q",
-
 
868
		&i965_gtt_driver },
-
 
869
	{ PCI_DEVICE_ID_INTEL_82965G_IG, "965G",
-
 
870
		&i965_gtt_driver },
-
 
871
	{ PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM",
-
 
872
		&i965_gtt_driver },
-
 
873
	{ PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE",
-
 
874
		&i965_gtt_driver },
-
 
875
	{ PCI_DEVICE_ID_INTEL_G33_IG, "G33",
-
 
876
		&g33_gtt_driver },
-
 
877
	{ PCI_DEVICE_ID_INTEL_Q35_IG, "Q35",
-
 
878
		&g33_gtt_driver },
-
 
879
	{ PCI_DEVICE_ID_INTEL_Q33_IG, "Q33",
-
 
880
		&g33_gtt_driver },
-
 
881
	{ PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, "GMA3150",
-
 
882
		&pineview_gtt_driver },
-
 
883
	{ PCI_DEVICE_ID_INTEL_PINEVIEW_IG, "GMA3150",
-
 
884
		&pineview_gtt_driver },
-
 
885
	{ PCI_DEVICE_ID_INTEL_GM45_IG, "GM45",
-
 
886
		&g4x_gtt_driver },
-
 
887
	{ PCI_DEVICE_ID_INTEL_EAGLELAKE_IG, "Eaglelake",
-
 
888
		&g4x_gtt_driver },
-
 
889
	{ PCI_DEVICE_ID_INTEL_Q45_IG, "Q45/Q43",
-
 
890
		&g4x_gtt_driver },
-
 
891
	{ PCI_DEVICE_ID_INTEL_G45_IG, "G45/G43",
-
 
892
		&g4x_gtt_driver },
-
 
893
	{ PCI_DEVICE_ID_INTEL_B43_IG, "B43",
-
 
894
		&g4x_gtt_driver },
-
 
895
	{ PCI_DEVICE_ID_INTEL_B43_1_IG, "B43",
-
 
896
		&g4x_gtt_driver },
-
 
897
	{ PCI_DEVICE_ID_INTEL_G41_IG, "G41",
-
 
898
		&g4x_gtt_driver },
-
 
899
	{ PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG,
-
 
900
	    "HD Graphics", &ironlake_gtt_driver },
-
 
901
	{ PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG,
-
 
902
	    "HD Graphics", &ironlake_gtt_driver },
717
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG,
903
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG,
718
        "Sandybridge", &sandybridge_gtt_driver },
904
        "Sandybridge", &sandybridge_gtt_driver },
719
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG,
905
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG,
720
        "Sandybridge", &sandybridge_gtt_driver },
906
        "Sandybridge", &sandybridge_gtt_driver },
721
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG,
907
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG,
Line 726... Line 912...
726
        "Sandybridge", &sandybridge_gtt_driver },
912
        "Sandybridge", &sandybridge_gtt_driver },
727
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG,
913
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG,
728
        "Sandybridge", &sandybridge_gtt_driver },
914
        "Sandybridge", &sandybridge_gtt_driver },
729
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG,
915
    { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG,
730
        "Sandybridge", &sandybridge_gtt_driver },
916
        "Sandybridge", &sandybridge_gtt_driver },
-
 
917
	{ PCI_DEVICE_ID_INTEL_IVYBRIDGE_GT1_IG,
-
 
918
	    "Ivybridge", &sandybridge_gtt_driver },
-
 
919
	{ PCI_DEVICE_ID_INTEL_IVYBRIDGE_GT2_IG,
-
 
920
	    "Ivybridge", &sandybridge_gtt_driver },
-
 
921
	{ PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT1_IG,
-
 
922
	    "Ivybridge", &sandybridge_gtt_driver },
-
 
923
	{ PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT2_IG,
-
 
924
	    "Ivybridge", &sandybridge_gtt_driver },
-
 
925
	{ PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG,
-
 
926
	    "Ivybridge", &sandybridge_gtt_driver },
731
    { 0, NULL, NULL }
927
    { 0, NULL, NULL }
732
};
928
};
Line 733... Line 929...
733
 
929
 
734
static int find_gmch(u16 device)
930
static int find_gmch(u16 device)
Line 787... Line 983...
787
    if (intel_gtt_init() != 0)
983
    if (intel_gtt_init() != 0)
788
        return 0;
984
        return 0;
Line 789... Line 985...
789
 
985
 
790
    return 1;
986
    return 1;
-
 
987
}
Line 791... Line 988...
791
}
988
EXPORT_SYMBOL(intel_gmch_probe);
792
 
989
 
793
const struct intel_gtt *intel_gtt_get(void)
990
const struct intel_gtt *intel_gtt_get(void)
794
{
991
{
-
 
992
    return &intel_private.base;
Line 795... Line 993...
795
    return &intel_private.base;
993
}
796
}
994
EXPORT_SYMBOL(intel_gtt_get);
797
 
995
 
798
void intel_gtt_chipset_flush(void)
996
void intel_gtt_chipset_flush(void)
799
{
997
{
-
 
998
	if (intel_private.driver->chipset_flush)
Line 800... Line 999...
800
	if (intel_private.driver->chipset_flush)
999
		intel_private.driver->chipset_flush();
801
		intel_private.driver->chipset_flush();
1000
}
802
}
1001
EXPORT_SYMBOL(intel_gtt_chipset_flush);